A label for a form field. More...
#include <Wt/WLabel>
Inherits Wt::WInteractWidget.
Public Member Functions | |
WLabel (WContainerWidget *parent=0) | |
Creates a label with empty text and optional parent. | |
WLabel (const WString &text, WContainerWidget *parent=0) | |
Creates a label with a given text. | |
WLabel (WImage *image, WContainerWidget *parent=0) | |
Creates a label with an image. | |
WFormWidget * | buddy () const |
Returns the buddy of this label. | |
void | setBuddy (WFormWidget *buddy) |
Sets the buddy of this label. | |
void | setBuddy (Ext::FormField *buddy) |
Sets the buddy of this label. | |
void | setText (const WString &text) |
Sets the label text. | |
const WString & | text () const |
Returns the label text. | |
void | setImage (WImage *image, Side side=Left) |
Sets the image. | |
WImage * | image () const |
Returns the image. | |
void | setWordWrap (bool wordWrap) |
Configures word wrapping. | |
bool | wordWrap () const |
Returns whether word wrapping is on. | |
Protected Member Functions | |
virtual void | propagateSetEnabled (bool enabled) |
Propagates that a widget was enabled or disabled through children. |
A label for a form field.
The label may contain an image and/or text. It acts like a proxy for giving focus to a WFormWidget. When both an image and text are specified, the image is put to the left of the text.
Usage example:
Wt::WContainerWidget *w = new Wt::WContainerWidget(); Wt::WLabel *label = new Wt::WLabel("Favourite Actress: ", w); Wt::WLineEdit *edit = new Wt::WLineEdit("Renee Zellweger", w); label->setBuddy(edit);
The widget corresponds to the HTML <label>
tag. When no buddy is set, it is rendered using an HTML <span>
or <div>
to avoid click event handling misbehavior on Microsoft Internet Explorer.
WLabel is an inline widget.
This widget does not provide styling, and can be styled using inline or external CSS as appropriate. A label's text may be styled via a nested <span>
element, and it's image may be styled via a nested <img>
element.
WFormWidget* Wt::WLabel::buddy | ( | ) | const [inline] |
Returns the buddy of this label.
void Wt::WLabel::propagateSetEnabled | ( | bool | enabled | ) | [protected, virtual] |
Propagates that a widget was enabled or disabled through children.
When enabling or disabling a widget, you usually also want to disable contained children. This method is called by setDisabled() to propagate its state to all children.
You may want to reimplement this method if they wish to render differently when a widget is disabled. The default implementation will propagate the signal to all children.
Reimplemented from Wt::WWebWidget.
void Wt::WLabel::setBuddy | ( | Ext::FormField * | buddy | ) |
Sets the buddy of this label.
Sets the buddy Ext::FormField for which this label acts as a proxy. When using this method, the result of buddy() is not defined.
void Wt::WLabel::setBuddy | ( | WFormWidget * | buddy | ) |
Sets the buddy of this label.
Sets the buddy FormWidget for which this label acts as a proxy.
void Wt::WLabel::setWordWrap | ( | bool | wordWrap | ) |
Configures word wrapping.
When wordWrap
is true
, the widget may break lines, creating a multi-line text. When wordWrap
is false
, the text will displayed on a single line, unless the text contains end-of-lines (for Wt::PlainText) or <br /> tags or other block-level tags (for Wt::XHTMLText).
The default value is false
.
bool Wt::WLabel::wordWrap | ( | ) | const |
Returns whether word wrapping is on.