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 (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 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)
 Set the current date.
void setEnabled (bool enabled)
 Sets enabled.
virtual void setDisabled (bool disabled)
 Sets whether the widget is disabled.
void setHidden (bool hidden)
 Hide/unhide 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));

WDatePicker-1.png

Example of WDatePicker with visible calendar.


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


Member Function Documentation

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

See also:
format(), WDate::toString()

const WString& Wt::WDatePicker::format (  )  const [inline]

Returns the format.

See also:
setFormat()

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().

See also:
setDate(), WDate::fromString(), WLineEdit::text()

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

Set the current date.

Does nothing if the current date is Null.

See also:
date()

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

Sets enabled.

This is the oppositie of setDisabled().

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.

See also:
disable(), enable()

Reimplemented from Wt::WCompositeWidget.


Generated on Tue Nov 3 15:34:32 2009 for Wt by doxygen 1.5.6