Wt  3.2.2
Public Member Functions
Wt::WDatePicker Class Reference

A date picker. More...

#include <Wt/WDatePicker>

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

List of all members.

Public Member Functions

 WDatePicker (WContainerWidget *parent=0)
 Create a new date picker.
 WDatePicker (WInteractWidget *displayWidget, WLineEdit *forEdit, WContainerWidget *parent=0)
 Create a new date picker for existing line edit and with custom display widget.
 ~WDatePicker ()
 Destructor.
void setFormat (const WString &format)
 Sets the format used for parsing or writing the date in the line edit.
const WStringformat () const
 Returns the format.
WCalendarcalendar () const
 The calendar widget.
WLineEditlineEdit () const
 The line edit.
WInteractWidgetdisplayWidget () const
 The display widget.
WDate date () const
 The current date.
void setDate (const WDate &date)
 Sets the current date.
void setEnabled (bool enabled)
 Sets whether the widget is enabled.
virtual void setDisabled (bool disabled)
 Sets whether the widget is disabled.
virtual void setHidden (bool hidden, const WAnimation &animation=WAnimation())
 Hide/unhide the widget.
void setBottom (const WDate &bottom)
 Sets the bottom of the valid date range.
WDate bottom () const
 Returns the bottom date of the valid range.
void setTop (const WDate &top)
 Sets the top of the valid date range.
WDate top () const
 Returns the top date of the valid range.
Signalchanged ()
 Signal emitted when the value has changed.
void setGlobalPopup (bool global)
 Controls how the calendar popup is positioned.
void setPopupVisible (bool visible)
 Shows or hides the popup.

Detailed Description

A date picker.

A date picker shows a line edit and an icon which when clicked popups a WCalendar for editing the date. Any date entered in the line edit is reflected in the calendar, and vice-versa.

Each of these widgets may be accessed individually (lineEdit(), calendar(), and displayWidget()) and there is a constructor that allows you to specify an existing line edit and display widget.

The date format used by default is "dd/MM/yyyy" and can be changed using setFormat(). At any time, the date set may be read using date(), or can be changed using setDate().

Usage example:

 Wt::WDatePicker *picker = new Wt::WDatePicker(this);
 picker->setFormat("dd-MM-yyyy");
 picker->setDate(Wt::WDate(1976, 6, 14));

i18n

Internationalization of WDatePicker is mostly handled through the internationalization mechanism of WDate. The 'Close' button can be internationalized by overriding the default value for the localization key Wt.DatePicker.Close.

CSS

The date picker is styled by the current CSS theme. The look can be overridden using the Wt-datepicker and Wt-outset CSS class; the calendar itself can be styled as documented in WCalendar.

WDatePicker-default-1.png
Example of a WDatePicker (default theme)
WDatePicker-polished-1.png
Example of a WDatePicker (polished theme)

Constructor & Destructor Documentation

Wt::WDatePicker::WDatePicker ( WContainerWidget parent = 0)

Create a new date picker.

This constructor creates a line edit with an icon that leads to a popup calendar. A WDateValidator is configured for the line edit.

Wt::WDatePicker::WDatePicker ( WInteractWidget displayWidget,
WLineEdit forEdit,
WContainerWidget parent = 0 
)

Create a new date picker for existing line edit and with custom display widget.

The displayWidget is a button or image which much be clicked to open the date picker. This widget will become owned by the picker.

The forEdit argument is the lineEdit that works in conjunction with the date picker. This widget does not become part of the date picker, and may be located anywhere else.


Member Function Documentation

WCalendar* Wt::WDatePicker::calendar ( ) const

The calendar widget.

Returns the calendar widget.

Signal & Wt::WDatePicker::changed ( )

Signal emitted when the value has changed.

This signal is emitted when a new date has been entered (either through the line edit, or through the calendar popup).

WDate Wt::WDatePicker::date ( ) const

The current date.

Reads the current date from the lineEdit().

Returns an invalid date (for which WDate::isValid() returns false) if the date could not be parsed using the current format().

See also:
setDate(), WDate::fromString(), WLineEdit::text()
WInteractWidget* Wt::WDatePicker::displayWidget ( ) const

The display widget.

Returns the widget which is displayed to activate the calendar.

const WString& Wt::WDatePicker::format ( ) const

Returns the format.

See also:
setFormat()
WLineEdit* Wt::WDatePicker::lineEdit ( ) const

The line edit.

Returns the line edit which works in conjunction with this date picker.

void Wt::WDatePicker::setDate ( const WDate date)

Sets the current date.

Does nothing if the current date is Null.

See also:
date()
void Wt::WDatePicker::setDisabled ( bool  disabled) [virtual]

Sets whether the widget is disabled.

Enables or disables the widget (including all its descendant widgets). setDisabled(false) will enable this widget and all descendant widgets that are not disabled. A widget is only enabled if it and all its ancestors in the widget tree are disabled.

Typically, a disabled form widget will not allow changing the value, and disabled widgets will not react to mouse click events.

See also:
disable(), enable()

Reimplemented from Wt::WCompositeWidget.

void Wt::WDatePicker::setEnabled ( bool  enabled)

Sets whether the widget is enabled.

This is the oppositie of setDisabled().

void Wt::WDatePicker::setFormat ( const WString format)

Sets the format used for parsing or writing the date in the line edit.

Sets the format used for representing the date in the line edit. If the line edit has a WDateValidator configured for it, then also there the format is updated.

The default format is 'dd/MM/yyyy'.

See also:
format(), WDate::toString()
void Wt::WDatePicker::setGlobalPopup ( bool  global)

Controls how the calendar popup is positioned.

When global is true, then the popup will position itself globally. This avoids that the popup is affected by enclosing parents with overflow settings that clip the popup. This makes the popup however no longer follow the popup button when this button moves.

The default is false.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator

Generated on Fri Jul 27 2012 for the C++ Web Toolkit (Wt) by doxygen 1.7.5.1