Wt  3.2.1
Public Types | Public Member Functions | Protected Member Functions
Wt::WCalendar Class Reference

A calendar. More...

#include <Wt/WCalendar>

Inheritance diagram for Wt::WCalendar:
Inheritance graph
[legend]

List of all members.

Public Types

enum  HorizontalHeaderFormat { SingleLetterDayNames, ShortDayNames, LongDayNames }
 The format of the horizontal header. More...

Public Member Functions

 WCalendar (WContainerWidget *parent=0)
 Creates a new calendar.
void setSelectionMode (SelectionMode mode)
 Sets the selection mode.
void browseToPreviousYear ()
 Browses to the same month in the previous year.
void browseToPreviousMonth ()
 Browses to the previous month.
void browseToNextYear ()
 Browses to the same month in the next year.
void browseToNextMonth ()
 Browses to the next month.
void browseTo (const WDate &date)
 Browses to a date.
int currentMonth () const
 Returns the current month displayed.
int currentYear () const
 Returns the current year displayed.
void clearSelection ()
 Clears the current selection.
void select (const WDate &date)
 Selects a date.
void select (const std::set< WDate > &dates)
 Selects multiple dates.
void setHorizontalHeaderFormat (HorizontalHeaderFormat format)
 Sets the horizontal header format.
HorizontalHeaderFormat horizontalHeaderFormat ()
 Returns the horizontal header format.
void setFirstDayOfWeek (int dayOfWeek)
 Sets the first day of the week.
const std::set< WDate > & selection () const
 Returns the current selection.
SignalselectionChanged ()
 Signal emitted when the user changes the selection.
Signal< WDate > & activated ()
 Signal emitted when the user double-clicks a date.
Signal< WDate > & clicked ()
 Signal emitted when the user clicks a date.
Signal< int, int > & currentPageChanged ()
 Signal emitted when the current month is changed.
void setMultipleSelection (bool multiple)
 Configures single or multiple selection mode ( deprecated ).
Signal< WDate > & selected ()
 Signal emitted when the user has double clicked on a date (deprecated).
void setSingleClickSelect (bool single)
 Configures the calendar to use single click for activation (deprecated)
void setDayOfWeekLength (int chars)
 Sets the length for the abbreviated day of week ( deprecated ).
void setBottom (const WDate &bottom)
 Sets the bottom of the valid date range.
const WDatebottom () const
 Returns the bottom date of the valid range.
void setTop (const WDate &top)
 Sets the top of the valid date range.
const WDatetop () const
 Returns the top date of the valid range.

Protected Member Functions

virtual WWidgetrenderCell (WWidget *widget, const WDate &date)
 Creates or updates a widget that renders a cell.
bool isSelected (const WDate &date) const
 Returns whether a date is selected.

Detailed Description

A calendar.

The calendar provides navigation by month and year, and indicates the current day.

You can listen for single click or double click events on a calendar cell using the clicked() and activated() methods.

The calendar may be configured to allow selection of single or multiple days using setSelectionMode(), and you may listen for changes in the selection using the selectionChanged() signals. Selection can also be entirely disabled in which case you can implement your own selection handling by listening for cell click events.

Cell rendering may be customized by reimplementing renderCell().

Internationalization is provided by the internationalization features of the Wt::WDate class.

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(this, &MyWidget::daySelected);

Here is a snapshot, taken on 19/01/2010 (shown as today), and 14/01/2010 currently selected.

WCalendar-default-1.png
WCalendar with default look
WCalendar-polished-1.png
WCalendar with polished look

CSS

The calendar is styled by the current CSS theme. The look can be overridden using the Wt-calendar CSS class and the following selectors:

.Wt-cal table       : The table
.Wt-cal table.d1    : The table (single letter day headers)
.Wt-cal table.d3    : The table (three letter day headers)
.Wt-cal table.dlong : The table (long day headers)

.Wt-cal caption	    : The caption (containing the navigation buttons)
.Wt-cal-year        : The caption year in-place-edit

.Wt-cal th          : Header cell (week day)

.Wt-cal td          : Day cell
.Wt-cal-oom         : Out-of-month day
.Wt-cal-oor         : Out-of-range day (day < bottom or day > top)
.Wt-cal-sel         : Selected day
.Wt-cal-now         : Today day

Member Enumeration Documentation

The format of the horizontal header.

Enumerator:
SingleLetterDayNames 

First letter of a day (e.g. 'M' for Monday)

ShortDayNames 

First 3 letters of a day (e.g. 'Mon' for Monday)

LongDayNames 

Full day name.


Constructor & Destructor Documentation

Wt::WCalendar::WCalendar ( WContainerWidget parent = 0)

Creates a new calendar.

Constructs a new calendar with English day/month names. The calendar shows the current day, and has an empty selection.


Member Function Documentation

Signal<WDate>& Wt::WCalendar::activated ( )

Signal emitted when the user double-clicks a date.

You may want to connect to this signal to treat a double click as the selection of a date.

void Wt::WCalendar::browseTo ( const WDate date)

Browses to a date.

Displays the month which contains the given date. This does not change the current selection.

This will emit the currentPageChanged() signal if another month is displayed.

void Wt::WCalendar::browseToNextMonth ( )

Browses to the next month.

Displays the next month. This does not change the current selection.

This will emit the currentPageChanged() singal.

void Wt::WCalendar::browseToNextYear ( )

Browses to the same month in the next year.

Displays the same month in the next year. This does not change the current selection.

This will emit the currentPageChanged() singal.

void Wt::WCalendar::browseToPreviousMonth ( )

Browses to the previous month.

Displays the previous month. This does not affect the selection.

This will emit the currentPageChanged() singal.

void Wt::WCalendar::browseToPreviousYear ( )

Browses to the same month in the previous year.

Displays the same month in the previous year. This does not affect the selection.

This will emit the currentPageChanged() singal.

void Wt::WCalendar::clearSelection ( )

Clears the current selection.

Clears the current selection. Will result in a selection() that is empty().

Signal<WDate>& Wt::WCalendar::clicked ( )

Signal emitted when the user clicks a date.

You may want to connect to this signal if you want to provide a custom selection handling.

int Wt::WCalendar::currentMonth ( ) const

Returns the current month displayed.

Returns the month (1-12) that is currently displayed.

Signal<int, int>& Wt::WCalendar::currentPageChanged ( )

Signal emitted when the current month is changed.

The method is emitted both when the change is done through the user interface or via the public API. The two parameters are respectively the new year and month.

int Wt::WCalendar::currentYear ( ) const

Returns the current year displayed.

Returns the year that is currently displayed.

HorizontalHeaderFormat Wt::WCalendar::horizontalHeaderFormat ( )

Returns the horizontal header format.

See also:
setHorizontalHeaderFormat()
bool Wt::WCalendar::isSelected ( const WDate date) const [protected]

Returns whether a date is selected.

This is a convenience method that can be used when reimplementing renderCell().

WWidget * Wt::WCalendar::renderCell ( WWidget widget,
const WDate date 
) [protected, virtual]

Creates or updates a widget that renders a cell.

The default implementation creates a WText

You may want to reimplement this method if you wish to customize how a cell is rendered. When widget is 0, a new widget should be created and returned. Otherwise, you may either modify the passed widget, or return a new widget. If you return a new widget, the prevoius widget will be deleted.

void Wt::WCalendar::select ( const WDate date)

Selects 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)

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

Signal<WDate>& Wt::WCalendar::selected ( )

Signal emitted when the user has double clicked on a date (deprecated).

This signal indicates that he user has selected a new date, which is only available when in single selection mode.

Deprecated:
use activated() instead.
const std::set<WDate>& Wt::WCalendar::selection ( ) const

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

Signal emitted when the user changes the selection.

Emitted after the user has changed the current selection.

void Wt::WCalendar::setBottom ( const WDate bottom)

Sets the bottom of the valid date range.

The default is a null date constructed using WDate().

void Wt::WCalendar::setDayOfWeekLength ( int  chars)

Sets the length for the abbreviated day of week ( deprecated ).

The chars may be 1 or 3, which render "Monday" as respectively "M" or "Mon".

The default length is 3.

Deprecated:
use setHorizontalHeaderFormat() instead.
void Wt::WCalendar::setFirstDayOfWeek ( int  dayOfWeek)

Sets the first day of the week.

Possible values or 1 to 7, as accepted by WDate::shortDayName().

The default value is 1 ("Monday").

void Wt::WCalendar::setHorizontalHeaderFormat ( HorizontalHeaderFormat  format)

Sets the horizontal header format.

The default horizontal header format is WCalendar::ShortDayNames.

void Wt::WCalendar::setMultipleSelection ( bool  multiple)

Configures single or multiple selection mode ( deprecated ).

In single selection mode, only one date may be selected: the selection() will be empty or contain exactly one item.

Deprecated:
use setSelectionMode() instead.
void Wt::WCalendar::setSelectionMode ( SelectionMode  mode)

Sets the selection mode.

The default selection mode is SingleSelection.

void Wt::WCalendar::setSingleClickSelect ( bool  single)

Configures the calendar to use single click for activation (deprecated)

By default, double click will trigger activate(). Use this method if you want a single click to trigger activate() (and the now deprecated selected() method). This only applies to a single-selection calendar.

Deprecated:
listen to the clicked() signal if you want to react to a single click, or activated() signal if you want to react to a double click.
See also:
setMultipleSelection()
void Wt::WCalendar::setTop ( const WDate top)

Sets the top of the valid date range.

The default is a null date constructed using WDate().

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator

Generated on Fri Mar 30 2012 for the C++ Web Toolkit (Wt) by doxygen 1.7.5.1