|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objecteu.webtoolkit.jwt.WObject
eu.webtoolkit.jwt.WWidget
eu.webtoolkit.jwt.WCompositeWidget
eu.webtoolkit.jwt.WCalendar
public class WCalendar
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
WDate class.
Here is a snapshot, taken on 19/01/2010 (shown as today), and 14/01/2010 currently selected.
WCalendar with default look |
WCalendar with polished look |
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
| Nested Class Summary | |
|---|---|
static class |
WCalendar.HorizontalHeaderFormat
The format of the horizontal header. |
| Constructor Summary | |
|---|---|
WCalendar()
Creates a new calendar. |
|
WCalendar(WContainerWidget parent)
Creates a new calendar. |
|
| Method Summary | |
|---|---|
Signal1<WDate> |
activated()
Signal emitted when the user double-clicks a date. |
void |
browseTo(WDate date)
Browses to a date. |
void |
browseToNextMonth()
Browses to the next month. |
void |
browseToNextYear()
Browses to the same month in the next year. |
void |
browseToPreviousMonth()
Browses to the previous month. |
void |
browseToPreviousYear()
Browses to the same month in the previous year. |
void |
clearSelection()
Clears the current selection. |
Signal1<WDate> |
clicked()
Signal emitted when the user clicks a date. |
Signal2<java.lang.Integer,java.lang.Integer> |
currentPageChanged()
Signal emitted when the current month is changed. |
WDate |
getBottom()
Returns the bottom date of the valid range. |
int |
getCurrentMonth()
Returns the current month displayed. |
int |
getCurrentYear()
Returns the current year displayed. |
WCalendar.HorizontalHeaderFormat |
getHorizontalHeaderFormat()
Returns the horizontal header format. |
java.util.Set<WDate> |
getSelection()
Returns the current selection. |
WDate |
getTop()
Returns the top date of the valid range. |
protected boolean |
isSelected(WDate d)
Returns whether a date is selected. |
protected WWidget |
renderCell(WWidget widget,
WDate date)
Creates or updates a widget that renders a cell. |
void |
select(java.util.Set<WDate> dates)
Selects multiple dates. |
void |
select(WDate date)
Selects a date. |
Signal1<WDate> |
selected()
Deprecated. use activated() instead. |
Signal |
selectionChanged()
Signal emitted when the user changes the selection. |
void |
setBottom(WDate bottom)
Sets the bottom of the valid date range. |
void |
setDayOfWeekLength(int chars)
Deprecated. use setHorizontalHeaderFormat() instead. |
void |
setFirstDayOfWeek(int dayOfWeek)
Sets the first day of the week. |
void |
setHorizontalHeaderFormat(WCalendar.HorizontalHeaderFormat format)
Sets the horizontal header format. |
void |
setMultipleSelection(boolean multiple)
Deprecated. use setSelectionMode() instead. |
void |
setSelectionMode(SelectionMode mode)
Sets the selection mode. |
void |
setSingleClickSelect(boolean single)
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. |
void |
setTop(WDate top)
Sets the top of the valid date range. |
| Methods inherited from class eu.webtoolkit.jwt.WWidget |
|---|
acceptDrops, acceptDrops, addCssRule, addCssRule, addStyleClass, animateHide, animateShow, containsExposed, disable, dropEvent, enable, getDrop, getJsRef, getParent, hide, htmlText, isLayoutSizeAware, isRendered, layoutSizeChanged, positionAt, positionAt, removeStyleClass, resize, setClearSides, setHeight, setHidden, setLayoutSizeAware, setMargin, setMargin, setMargin, setMargin, setMargin, setOffsets, setOffsets, setOffsets, setOffsets, setOffsets, setToolTip, setVerticalAlignment, setWidth, show, stopAcceptDrops, toggleStyleClass, toggleStyleClass, tr |
| Methods inherited from class eu.webtoolkit.jwt.WObject |
|---|
addChild, getObjectName, setObjectName |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public WCalendar(WContainerWidget parent)
Constructs a new calendar with English day/month names. The calendar shows the current day, and has an empty selection.
public WCalendar()
Calls this((WContainerWidget)null)
| Method Detail |
|---|
public void setSelectionMode(SelectionMode mode)
The default selection mode is SingleSelection.
public void browseToPreviousYear()
Displays the same month in the previous year. This does not affect the selection.
This will emit the currentPageChanged() singal.
public void browseToPreviousMonth()
Displays the previous month. This does not affect the selection.
This will emit the currentPageChanged() singal.
public void browseToNextYear()
Displays the same month in the next year. This does not change the current selection.
This will emit the currentPageChanged() singal.
public void browseToNextMonth()
Displays the next month. This does not change the current selection.
This will emit the currentPageChanged() singal.
public void browseTo(WDate 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.
public int getCurrentMonth()
Returns the month (1-12) that is currently displayed.
public int getCurrentYear()
Returns the year that is currently displayed.
public void clearSelection()
Clears the current selection. Will result in a
getSelection() that is empty().
public void select(WDate date)
Select one date. Both in single or multiple selection mode, this results
in a getSelection() that contains
exactly one date.
public void select(java.util.Set<WDate> dates)
Select multiple dates. In multiple selection mode, this results in a
getSelection() that contains exactly the
given dates. In single selection mode, at most one date is set.
public void setHorizontalHeaderFormat(WCalendar.HorizontalHeaderFormat format)
The default horizontal header format is
WCalendar.HorizontalHeaderFormat.ShortDayNames.
public WCalendar.HorizontalHeaderFormat getHorizontalHeaderFormat()
setHorizontalHeaderFormat(WCalendar.HorizontalHeaderFormat
format)public void setFirstDayOfWeek(int dayOfWeek)
Possible values or 1 to 7, as accepted by
WDate#getShortDayName().
The default value is 1 ("Monday").
public java.util.Set<WDate> getSelection()
Returns the set of dates currently selected. In single selection mode, this set contains 0 or 1 dates.
public Signal selectionChanged()
Emitted after the user has changed the current selection.
public Signal1<WDate> activated()
You may want to connect to this signal to treat a double click as the selection of a date.
public Signal1<WDate> clicked()
You may want to connect to this signal if you want to provide a custom selection handling.
public Signal2<java.lang.Integer,java.lang.Integer> currentPageChanged()
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.
public void setMultipleSelection(boolean multiple)
setSelectionMode() instead.
In single selection mode, only one date may be selected: the
getSelection() will be empty or contain
exactly one item.
public Signal1<WDate> selected()
activated() instead.
This signal indicates that he user has selected a new date, which is only available when in single selection mode.
public void setSingleClickSelect(boolean single)
clicked() signal if
you want to react to a single click, or
activated() signal if you want
to react to a double click.
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.
setMultipleSelection(boolean multiple)public void setDayOfWeekLength(int chars)
setHorizontalHeaderFormat() instead.
The chars may be 1 or 3, which render "Monday" as
respectively "M" or "Mon".
The default length is 3.
public void setBottom(WDate bottom)
The default bottom is null.
public WDate getBottom()
public void setTop(WDate top)
The default top is null.
public WDate getTop()
protected WWidget renderCell(WWidget widget,
WDate date)
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 null, 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.
protected boolean isSelected(WDate d)
This is a convenience method that can be used when reimplementing
renderCell().
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||