Wt
3.2.1
|
A rich-text XHTML editor. More...
#include <Wt/WTextEdit>
Public Member Functions | |
WTextEdit (WContainerWidget *parent=0) | |
Creates a new text editor. | |
WTextEdit (const WString &text, WContainerWidget *parent=0) | |
Creates a new text editor and initialize with given text. | |
~WTextEdit () | |
Destructor. | |
virtual void | setText (const WString &text) |
Sets the content. | |
void | setStyleSheet (const std::string &uri) |
Sets the stylesheet for displaying the content. | |
const std::string | styleSheet () const |
Returns the content stylesheet. | |
void | setExtraPlugins (const std::string &plugins) |
Loads additional TinyMCE plugins. | |
const std::string | extraPlugins () const |
Returns the extra plugins. | |
void | setToolBar (int i, const std::string &config) |
Configures a tool bar. | |
const std::string | toolBar (int i) const |
Returns a tool bar configuration. | |
void | setConfigurationSetting (const std::string &name, const boost::any &value) |
Configure a TinyMCE setting. | |
boost::any | configurationSetting (const std::string &name) const |
Returns a TinyMCE configuration setting's value. | |
virtual void | resize (const WLength &width, const WLength &height) |
Resizes the widget. | |
Protected Member Functions | |
virtual int | boxPadding (Orientation orientation) const |
Returns the widget's built-in padding. | |
virtual int | boxBorder (Orientation orientation) const |
Returns the widget's built-in border width. |
A rich-text XHTML editor.
The editor provides interactive editing of XHTML text. By default it provides basic mark-up (font, formatting, color, links, and lists), but additional buttons may be added to the tool bars that add additional formatting options.
The implementation is based on TinyMCE. The widget may be configured and tailored using the setConfigurationSetting() and related methods that provide direct access to the underlying TinyMCE component.
To use this widget, you need to download TinyMCE (version 3.5b1 or later) and deploy the tinymce/jscripts/tiny_mce
folder to tinyMCEBaseURL. The default value for tinyMCEBaseURL is resourcesURL/tiny_mce
, where resourcesURL is the configuration property that locates the Wt resources/
folder (i.e., we assume by default that you copy the tiny_mce
folder to the resources/
folder), see also deployment and resources.
The value may be overridden with a URL that points to the directory where the tiny_mce
folder is located, by configuring the <i<>tinyMCEBaseURL/i> property in your Wt configuration file, see configuration properties.
Usage example:
Wt::WContainerWidget *w = new Wt::WContainerWidget(); Wt::WLabel *label = new Wt::WLabel("Comments:", w); Wt::WTextEdit *edit = new Wt::WTextEdit("", w); label->setBuddy(edit);
Styling through CSS is not applicable.
Wt::WTextEdit::WTextEdit | ( | const WString & | text, |
WContainerWidget * | parent = 0 |
||
) |
Creates a new text editor and initialize with given text.
The text
should be valid XHTML.
int Wt::WTextEdit::boxBorder | ( | Orientation | orientation | ) | const [protected, virtual] |
Returns the widget's built-in border width.
This is used by the layout managers to correct for a built-in border which interferes with setting a widget's width (or height) to 100%.
A layout manager needs to set the width to 100% only for form widgets (WTextArea, WLineEdit, WComboBox, etc...). Therefore, only for those widgets this needs to return the border width (the default implementation returns 0).
For form widgets, the border width depends on the specific browser/platform combination, unless an explicit border is set for the widget.
When setting an explicit border for the widget using a style class, you will want to reimplement this method to return this border width, in case you want to set the widget inside a layout manager.
Reimplemented from Wt::WTextArea.
int Wt::WTextEdit::boxPadding | ( | Orientation | orientation | ) | const [protected, virtual] |
Returns the widget's built-in padding.
This is used by the layout managers to correct for a built-in padding which interferes with setting a widget's width (or height) to 100%.
A layout manager needs to set the width to 100% only for form widgets (WTextArea, WLineEdit, WComboBox, etc...). Therefore, only for those widgets this needs to return the padding (the default implementation returns 0).
For form widgets, the padding depends on the specific browser/platform combination, unless an explicit padding is set for the widget.
When setting an explicit padding for the widget using a style class, you will want to reimplement this method to return this padding in case you want to set the widget inside a layout manager.
Reimplemented from Wt::WTextArea.
boost::any Wt::WTextEdit::configurationSetting | ( | const std::string & | name | ) | const |
Returns a TinyMCE configuration setting's value.
An empty boost::any is returned when no value could be found for the provided argument.
const std::string Wt::WTextEdit::extraPlugins | ( | ) | const |
Returns the extra plugins.
Resizes the widget.
Specify a new size for this widget, by specifying width and height. By default a widget has automatic width and height, see WLength::isAuto().
This applies to CSS-based layout, and only block widgets can be given a size reliably.
When inserted in a layout manager, the widget may be informed about its current size using setLayoutSizeAware(). If you have defined a "wtResize()"
JavaScript method for the widget, then this method will also be called. operation.
Reimplemented from Wt::WWebWidget.
void Wt::WTextEdit::setConfigurationSetting | ( | const std::string & | name, |
const boost::any & | value | ||
) |
Configure a TinyMCE setting.
A list of possible settings can be found at: http://tinymce.moxiecode.com/wiki.php/Configuration.
The widget itself will also define a number of configuration settings and these may be overridden using this method.
void Wt::WTextEdit::setExtraPlugins | ( | const std::string & | plugins | ) |
Loads additional TinyMCE plugins.
Wt loads by default only the plugin 'safari' (which adds support for the Safari web browser). Use this method to load additional plugins. Multiple plugins may be specified as a comma separated list.
The various plugins are described in the TinyMCE documentation.
void Wt::WTextEdit::setStyleSheet | ( | const std::string & | uri | ) |
Sets the stylesheet for displaying the content.
The content is rendered using the rules defined in this stylesheet. The stylesheet is also used to derive additional styles that are available in the text editor, for example in the "styleselect" button.
Multiple stylesheets may be specified as a comma separated list.
void Wt::WTextEdit::setText | ( | const WString & | text | ) | [virtual] |
Sets the content.
The text
should be valid XHTML.
The default value is "".
Reimplemented from Wt::WTextArea.
void Wt::WTextEdit::setToolBar | ( | int | i, |
const std::string & | config | ||
) |
Configures a tool bar.
This configures the buttons for the i'th
tool bar (with 0 <= i
<= 3).
The syntax and available buttons is documented in the TinyMCE documentation.
The default config for the first tool bar (i
= 0) is: "fontselect, |, bold, italic, underline, |, fontsizeselect, |, forecolor, backcolor, |, justifyleft, justifycenter, justifyright, justifyfull, |, anchor, |, numlist, bullist".
By default, the other three tool bars are disabled (config
= "").
Some buttons are only available after loading extra plugins using setExtraPlugins().
const std::string Wt::WTextEdit::styleSheet | ( | ) | const |
Returns the content stylesheet.
const std::string Wt::WTextEdit::toolBar | ( | int | i | ) | const |
Returns a tool bar configuration.