Wt 3.1.10
Public Member Functions | Protected Member Functions
Wt::WLabel Class Reference

A label for a form field. More...

#include <Wt/WLabel>

Inheritance diagram for Wt::WLabel:
Inheritance graph
[legend]

List of all members.

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.
WFormWidgetbuddy () 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 WStringtext () const
 Returns the label text.
void setImage (WImage *image, Side side=Left)
 Sets the image.
WImageimage () 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.

Detailed Description

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.

CSS

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.


Member Function Documentation

WFormWidget* Wt::WLabel::buddy ( ) const

Returns the buddy of this label.

See also:
setBuddy(WFormWidget *)
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::WInteractWidget.

void Wt::WLabel::setBuddy ( WFormWidget buddy)

Sets the buddy of this label.

Sets the buddy FormWidget for which this label acts as a proxy.

See also:
WFormWidget::label(), setBuddy(Ext::FormField *), buddy()
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.

See also:
Ext::FormField::label(), setBuddy(WFormWidget *)
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.

See also:
wordWrap()
bool Wt::WLabel::wordWrap ( ) const

Returns whether word wrapping is on.

See also:
setWordWrap()
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator

Generated on Sat Dec 24 2011 for the C++ Web Toolkit (Wt) by doxygen 1.7.4