Wt: Wt::WTextEdit Class Reference

Wt 3.3.0

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | Protected Member Functions
Wt::WTextEdit Class Reference

A rich-text XHTML editor. More...

`#include <Wt/WTextEdit>`

Inheritance diagram for Wt::WTextEdit:
[legend]

List of all members.

## 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.

## Detailed Description

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);

### CSS

Styling through CSS is not applicable.

Default configuration of a WTextEdit

## Constructor & Destructor Documentation

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.

## Member Function Documentation

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.

See also:
  boxPadding()

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.

See also:
  boxBorder()

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.

See also:
  setExtraPlugins()

void Wt::WTextEdit::resize | ( | const WLength & | width,
|  | const WLength & | height
| ) |  | `[virtual]`

Resizes the widget.

Specifies a fixed size for this widget, setting CSS `width` and `height` properties. By default a widget has automatic width and height, which sets a size for the widget following CSS rules.

When the widget is not managed by a layout manager, the automatic (natural) size of a widget depends on whether they widget is a block or inline widget:

- a block widget takes by default the width of the parent, and the height that it needs based on its contents
- an inline widget takes the width and height that it needs based on its contents (possibly wrapping over multiple lines). The width and height of an inline widget cannot be changed (by the letter of CSS, although most browsers will react to it in varying ways).

When inserted in a layout manager, the size set will be used as a widget's preferred size, but the widget may be given a different size by the layout manager based on available space and stretch factors. The actual size given by a layout manager may be retrieved by making the widget "layout size aware", using setLayoutSizeAware(). If you have defined a `"wtResize()"` JavaScript method for the widget, then this method will also be called.

The default width and height of a widget is WLength::Auto.

See also:
  width(), height()

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.

Note:
  Plugins can only be loaded before the initial display of the widget.

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().

Note:
  The tool bar configuration can only be set before the initial display of the widget.

const std::string Wt::WTextEdit::styleSheet | ( |  | ) | const

Returns the content stylesheet.

See also:
  setStyleSheet()

const std::string Wt::WTextEdit::toolBar | ( | int | i | ) | const

Returns a tool bar configuration.

See also:
  setToolBar()

All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator