/usr/include/Wt/WDatePicker is in libwt-dev 3.1.10-1ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | // This may look like C code, but it's really -*- C++ -*-
/*
* Copyright (C) 2008 Emweb bvba, Kessel-Lo, Belgium.
*
* See the LICENSE file for terms of use.
*/
#ifndef WDATEPICKER_H_
#define WDATEPICKER_H_
#include <Wt/WCompositeWidget>
#include <Wt/WDate>
#include <Wt/WJavaScriptSlot>
#include <set>
namespace Wt {
class WCalendar;
class WInteractWidget;
class WLineEdit;
class WTemplate;
/*! \class WDatePicker Wt/WDatePicker Wt/WDatePicker
* \brief 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 <tt>"dd/MM/yyyy"</tt> and can be
* changed using setFormat(). At any time, the date set may be read
* using date(), or can be changed using setDate().
*
* \if cpp
* Usage example:
* \code
* Wt::WDatePicker *picker = new Wt::WDatePicker(this);
* picker->setFormat("dd-MM-yyyy");
* picker->setDate(Wt::WDate(1976, 6, 14));
* \endcode
* \endif
*
* <h3>i18n</h3>
*
* Internationalization of WDatePicker is mostly handled through
* the internationalization mechanism of WDate. The 'Close' button
* can be internationalized by overriding the default value for
* the localization key Wt.DatePicker.Close.
*
* <h3>CSS</h3>
*
* The date picker is styled by the current CSS theme. The look can be
* overridden using the <tt>Wt-datepicker</tt> and <tt>Wt-outset</tt>
* CSS class; the calendar itself can be styled as documented in
* WCalendar.
*
* <TABLE border="0" align="center"> <TR> <TD>
* \image html WDatePicker-default-1.png "Example of a WDatePicker (default theme)
* </TD> <TD>
* \image html WDatePicker-polished-1.png "Example of a WDatePicker (polished theme)
* </TD> </TR> </TABLE>
*/
class WT_API WDatePicker : public WCompositeWidget
{
public:
/*! \brief 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.
*/
WDatePicker(WContainerWidget *parent = 0);
/*! \brief Create a new date picker for existing line edit and with custom
* display widget.
*
* The \p displayWidget is a button or image which much be
* clicked to open the date picker. This widget will become owned by
* the picker.
*
* The \p 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.
*/
WDatePicker(WInteractWidget *displayWidget,
WLineEdit *forEdit,
WContainerWidget *parent = 0);
/*! \brief Destructor.
*/
~WDatePicker();
/*! \brief 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 <tt>'dd/MM/yyyy'</tt>.
*
* \sa format(), WDate::toString()
*/
void setFormat(const WT_USTRING& format);
/*! \brief Returns the format.
*
* \sa setFormat()
*/
const WT_USTRING& format() const { return format_; }
/*! \brief The calendar widget.
*
* Returns the calendar widget.
*/
WCalendar *calendar() const { return calendar_; }
/*! \brief The line edit.
*
* Returns the line edit which works in conjunction with this date
* picker.
*/
WLineEdit *lineEdit() const { return forEdit_; }
/*! \brief The display widget.
*
* Returns the widget which is displayed to activate the calendar.
*/
WInteractWidget *displayWidget() const { return displayWidget_; }
/*! \brief The current date.
*
* Reads the current date from the lineEdit().
*
* \if cpp
* Returns an invalid date (for which WDate::isValid() returns
* \c false) if the date could not be parsed using the current
* format(). <br>
* \elseif java
* Returns \c null if the date could not be parsed using the current
* format(). <br>
* \endif
*
* \sa setDate(), WDate::fromString(), WLineEdit::text()
*/
WDate date() const;
/*! \brief Sets the current date.
*
* Does nothing if the current date is \p Null.
*
* \sa date()
*/
void setDate(const WDate& date);
/*! \brief Sets whether the widget is enabled.
*
* This is the oppositie of setDisabled().
*/
void setEnabled(bool enabled);
virtual void setDisabled(bool disabled);
/*! \brief Hide/unhide the widget.
*/
virtual void setHidden(bool hidden, const WAnimation& animation = WAnimation());
/*! \brief Sets the bottom of the valid date range.
*/
void setBottom(const WDate& bottom);
/*! \brief Returns the bottom date of the valid range.
*/
WDate bottom() const;
/*! \brief Sets the top of the valid date range.
*/
void setTop(const WDate& top);
/*! \brief Returns the top date of the valid range.
*/
WDate top() const;
/*! \brief %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).
*/
Signal<>& changed();
/*! \brief Controls how the calendar popup is positioned.
*
* When \p global is \c 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 \c false.
*/
void setGlobalPopup(bool global);
/*! \brief Shows or hides the popup.
*/
void setPopupVisible(bool visible);
private:
WT_USTRING format_;
WInteractWidget *displayWidget_;
WLineEdit *forEdit_;
WContainerWidget *layout_;
WTemplate *popup_;
WCalendar *calendar_;
JSlot positionJS_;
void createDefault();
void create(WInteractWidget *displayWidget, WLineEdit *forEdit);
void setFromCalendar();
void setFromLineEdit();
};
}
#endif // WDATEPICKER_H_
|