#include <Wt/WCalendar>
Public Member Functions | |
WCalendar (bool i18n=false, WContainerWidget *parent=0) | |
Create a new calendar. | |
void | setMultipleSelection (bool multiple) |
Configure single or multiple selection mode. | |
void | browseToPreviousYear () |
Browse to the same month in the previous year. | |
void | browseToPreviousMonth () |
Browse to the previous month. | |
void | browseToNextYear () |
Browse to the same month in the next year. | |
void | browseToNextMonth () |
Browse to the next month. | |
void | browseTo (const WDate &date) |
Browse to a date. | |
int | currentMonth () const |
Returns the current month displayed. | |
int | currentYear () const |
Returns the current year displayed. | |
void | clearSelection () |
Clear the current selection. | |
void | select (const WDate &date) |
Select a date. | |
void | select (const std::set< WDate > &dates) |
Select multiple dates. | |
const std::set< WDate > & | selection () const |
Returns the current selection. | |
Signal & | selectionChanged () |
Signal emitted when the user changes the selection. | |
Signal< WDate > & | selected () |
Signal emitted when the user has double clicked on a date. | |
void | setSingleClickSelect (bool single) |
Configure the calendar to use single click to select. |
The calendar provides navigation by month and year, and indicates the current day.
The calendar may be configured to allow selection of single or multiple days, and you may listen for changes in the selection using the selectionChanged() or selected() signals.
Internationalization may be provided by indicating i18n == true in the constructor, and providing the appropriate messages for months (with keys from WDate::longMonthName()) and days (with keys from WDate::shortDayName()) in your message resource bundle.
The look can be overridden using the following style class selectors:
table.Wt-cal-table : The table td.Wt-cal-header : Header cell (week day) td.Wt-cal-header-weekend : Header cell (weekend day) table.Wt-cal-table TD : In-month day cell td.Wt-cal-oom : Out-of-month day cell td.Wt-cal-sel : Selected day cell td.Wt-cal-now : Today day cell
Usage example:
Wt::WDate today = Wt::WDate::currentDate(); Wt::WCalendar *calendar = new Wt::WCalendar(this); calendar->browseTo(today.addMonths(1)); calendar->select(today.addMonths(1).addDays(3)); calendar->selected().connect(SLOT(this, MyWidget::daySelected));
Here is a snapshot of the default look, taken on 31/08/2007 (shown as today), and 11/08/2007 currently selected.
WCalendar with default look
Wt::WCalendar::WCalendar | ( | bool | i18n = false , |
|
WContainerWidget * | parent = 0 | |||
) |
Create a new calendar.
Constructs a new calendar, with optional support for internationalization. The calendar shows the current day, and has an empty selection.
void Wt::WCalendar::setMultipleSelection | ( | bool | multiple | ) |
Configure single or multiple selection mode.
In single selection mode, only one date may be selected: the selection() will be empty or contain exactly one item.
void Wt::WCalendar::browseToPreviousYear | ( | ) |
Browse to the same month in the previous year.
Displays the same month in the previous year. This does not change the current selection.
void Wt::WCalendar::browseToPreviousMonth | ( | ) |
Browse to the previous month.
Displays the previous month. This does not change the current selection.
void Wt::WCalendar::browseToNextYear | ( | ) |
Browse to the same month in the next year.
Displays the same month in the next year. This does not change the current selection.
void Wt::WCalendar::browseToNextMonth | ( | ) |
Browse to the next month.
Displays the next month. This does not change the current selection.
void Wt::WCalendar::browseTo | ( | const WDate & | date | ) |
Browse to a date.
Displays the month which contains the given date. This does not change the current selection.
int Wt::WCalendar::currentMonth | ( | ) | const [inline] |
Returns the current month displayed.
Returns the month (1-12) that is currently displayed.
int Wt::WCalendar::currentYear | ( | ) | const [inline] |
Returns the current year displayed.
Returns the year that is currently displayed.
void Wt::WCalendar::clearSelection | ( | ) |
Clear the current selection.
Clears the current selection. Will result in a selection() that is empty().
void Wt::WCalendar::select | ( | const WDate & | date | ) |
Select a date.
Select one date. Both in single or multiple selection mode, this results in a selection() that contains exactly one date.
void Wt::WCalendar::select | ( | const std::set< WDate > & | dates | ) |
Select multiple dates.
Select multiple dates. In multiple selection mode, this results in a selection() that contains exactly the given dates. In single selection mode, at most one date is set.
const std::set<WDate>& Wt::WCalendar::selection | ( | ) | const [inline] |
Returns the current selection.
Returns the set of dates currently selected. In single selection mode, this set contains 0 or 1 dates.
Signal& Wt::WCalendar::selectionChanged | ( | ) | [inline] |
Signal emitted when the user changes the selection.
Emitted after the user has changed the current selection.
Signal emitted when the user has double clicked on a date.
This signal indicates that he user has selected a new date, which is only available when in single selection mode.
void Wt::WCalendar::setSingleClickSelect | ( | bool | single | ) |
Configure the calendar to use single click to select.
This only applies to a single-selection calendar.