#include <Wt/WDatePicker>
Public Member Functions | |
WDatePicker (WContainerWidget *parent=0) | |
Create a new date picker. | |
WDatePicker (bool i18n, WContainerWidget *parent=0) | |
Create a new date picker. | |
WDatePicker (WInteractWidget *displayWidget, WLineEdit *forEdit, bool i18n=false, WContainerWidget *parent=0) | |
Create a new date picker for existing line edit and with custom display widget. | |
void | setFormat (const WString &format) |
Set 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) |
Set the current date. | |
void | setEnabled (bool enabled) |
Change the enabled state of the widget. | |
void | enable () |
Enable the widget. | |
void | disable () |
Disable the widget. |
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));
Example of WDatePicker with visible calendar.
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 | ( | bool | i18n, | |
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.
i18n is passed to the WCalendar constructor.
Wt::WDatePicker::WDatePicker | ( | WInteractWidget * | displayWidget, | |
WLineEdit * | forEdit, | |||
bool | i18n = false , |
|||
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.
i18n is passed to the WCalendar constructor.
void Wt::WDatePicker::setFormat | ( | const WString & | format | ) |
Set 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'
.
const WString& Wt::WDatePicker::format | ( | ) | const [inline] |
WCalendar* Wt::WDatePicker::calendar | ( | ) | const [inline] |
The calendar widget.
Returns the calendar widget.
WLineEdit* Wt::WDatePicker::lineEdit | ( | ) | const [inline] |
The line edit.
Returns the line edit which works in conjunction with this date picker.
WInteractWidget* Wt::WDatePicker::displayWidget | ( | ) | const [inline] |
The display widget.
Returns the widget which is displayed to activate the calendar.
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().
void Wt::WDatePicker::setDate | ( | const WDate & | date | ) |
void Wt::WDatePicker::setEnabled | ( | bool | enabled | ) |
Change the enabled state of the widget.
A widget that is disabled cannot receive focus or user interaction.
void Wt::WDatePicker::enable | ( | ) |
void Wt::WDatePicker::disable | ( | ) |