Wt: Wt::WDatePicker Class Reference

Wt 3.3.0

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | Protected Member Functions
Wt::WDatePicker Class Reference

A date picker. More...

`#include <Wt/WDatePicker>`

Inheritance diagram for Wt::WDatePicker:
[legend]

List of all members.

## Public Member Functions
| WDatePicker (WContainerWidget *parent=0)
| Create a new date picker.
| WDatePicker (WLineEdit *forEdit, WContainerWidget *parent=0)
| Create a new date picker for a line edit.
| 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.
Signal & | popupClosed ()
| A signal which indicates that the popup has been closed.
## Protected Member Functions
virtual void | render (WFlags< RenderFlag > flags)
| Renders the widget.

## 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.

## 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 | ( | WLineEdit * | forEdit,
|  | WContainerWidget * | parent = `0`
| ) |  |

Create a new date picker for a line edit.

This constructor creates an icon that leads to a popup calendar.

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.

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.

Signal& Wt::WDatePicker::popupClosed | ( |  | ) |

A signal which indicates that the popup has been closed.

The signal is only fired when the popup has been closed by the user.

void Wt::WDatePicker::render | ( | WFlags< RenderFlag > | flags | ) | `[protected, virtual]`

Renders the widget.

This function renders the widget (or an update for the widget), after this has been scheduled using scheduleRender().

The default implementation will render the widget by serializing changes to JavaScript and HTML. You may want to reimplement this widget if you have been postponing some of the layout / rendering implementation until the latest moment possible. In that case you should make sure you call the base implementation however.

Reimplemented from Wt::WCompositeWidget.

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 Functions Variables Typedefs Enumerations Enumerator