Wt
3.2.0
|
A date picker. More...
#include <Wt/WDatePicker>
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 WString & | format () const |
Returns the format. | |
WCalendar * | calendar () const |
The calendar widget. | |
WLineEdit * | lineEdit () const |
The line edit. | |
WInteractWidget * | displayWidget () 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. | |
Signal & | changed () |
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. |
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));
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.
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.
![]()
Example of a WDatePicker (default theme) | ![]()
Example of a WDatePicker (polished theme) |
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.
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().
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.
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 | ) |
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.
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'
.
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
.