X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/12f5e1e78fe906050ff2fee9529476db332633f0..92c0fc34c104c8d7c12d6a3b78ea232690fc23f4:/interface/wx/calctrl.h?ds=sidebyside diff --git a/interface/wx/calctrl.h b/interface/wx/calctrl.h index 7b0388416d..a59e64f5e0 100644 --- a/interface/wx/calctrl.h +++ b/interface/wx/calctrl.h @@ -2,10 +2,39 @@ // Name: calctrl.h // Purpose: interface of wxCalendarCtrl // Author: wxWidgets team -// RCS-ID: $Id$ -// Licence: wxWindows license +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// +enum +{ + // show Sunday as the first day of the week (default) + wxCAL_SUNDAY_FIRST = 0x0000, + + // show Monday as the first day of the week + wxCAL_MONDAY_FIRST = 0x0001, + + // highlight holidays + wxCAL_SHOW_HOLIDAYS = 0x0002, + + // disable the year change control, show only the month change one + // deprecated + wxCAL_NO_YEAR_CHANGE = 0x0004, + + // don't allow changing neither month nor year (implies + // wxCAL_NO_YEAR_CHANGE) + wxCAL_NO_MONTH_CHANGE = 0x000c, + + // use MS-style month-selection instead of combo-spin combination + wxCAL_SEQUENTIAL_MONTH_SELECTION = 0x0010, + + // show the neighbouring weeks in the previous and next month + wxCAL_SHOW_SURROUNDING_WEEKS = 0x0020, + + // show week numbers on the left side of the calendar. + wxCAL_SHOW_WEEK_NUMBERS = 0x0040 +}; + + /** @class wxCalendarEvent @@ -19,6 +48,9 @@ class wxCalendarEvent : public wxDateEvent { public: + wxCalendarEvent(); + wxCalendarEvent(wxWindow *win, const wxDateTime& dt, wxEventType type); + /** Returns the week day on which the user clicked in @c EVT_CALENDAR_WEEKDAY_CLICKED handler. It doesn't make sense to call @@ -30,9 +62,15 @@ public: Sets the week day carried by the event, normally only used by the library internally. */ - void SetWeekDay(wxDateTime::WeekDay day); + void SetWeekDay(const wxDateTime::WeekDay day); }; +wxEventType wxEVT_CALENDAR_SEL_CHANGED; +wxEventType wxEVT_CALENDAR_PAGE_CHANGED; +wxEventType wxEVT_CALENDAR_DOUBLECLICKED; +wxEventType wxEVT_CALENDAR_WEEKDAY_CLICKED; +wxEventType wxEVT_CALENDAR_WEEK_CLICKED; + /** @@ -53,22 +91,17 @@ enum wxCalendarDateBorder of this class are used with wxCalendarCtrl. @library{wxadv} - @category{misc} + @category{data} @see wxCalendarCtrl */ class wxCalendarDateAttr { public: - /** - Default constructor. - */ - wxCalendarDateAttr(); - /** Constructor for specifying all wxCalendarDateAttr properties. */ - wxCalendarDateAttr(const wxColour& colText, + wxCalendarDateAttr(const wxColour& colText = wxNullColour, const wxColour& colBack = wxNullColour, const wxColour& colBorder = wxNullColour, const wxFont& font = wxNullFont, @@ -83,7 +116,7 @@ public: /** Returns the background colour set for the calendar date. */ - const wxColour GetBackgroundColour() const; + const wxColour& GetBackgroundColour() const; /** Returns the border set for the calendar date. @@ -93,17 +126,17 @@ public: /** Returns the border colour set for the calendar date. */ - const wxColour GetBorderColour() const; + const wxColour& GetBorderColour() const; /** Returns the font set for the calendar date. */ - const wxFont GetFont() const; + const wxFont& GetFont() const; /** Returns the text colour set for the calendar date. */ - const wxColour GetTextColour() const; + const wxColour& GetTextColour() const; /** Returns @true if a non-default text background colour is set. @@ -111,7 +144,7 @@ public: bool HasBackgroundColour() const; /** - Returns @true if a non-default (i.e. any) border is set. + Returns @true if a non-default (i.e.\ any) border is set. */ bool HasBorder() const; @@ -175,7 +208,7 @@ public: Set the attributes that will be used to Mark() days on the generic wxCalendarCtrl. */ - static void SetMark(wxCalendarDateAttr const& m); + static void SetMark(const wxCalendarDateAttr& m); }; @@ -187,7 +220,11 @@ enum wxCalendarHitTestResult { wxCAL_HITTEST_NOWHERE, ///< Hit outside of anything. wxCAL_HITTEST_HEADER, ///< Hit on the header (weekdays). - wxCAL_HITTEST_DAY ///< Hit on a day in the calendar. + wxCAL_HITTEST_DAY, ///< Hit on a day in the calendar. + wxCAL_HITTEST_INCMONTH, ///< Hit on next month arrow (in alternate month selector mode). + wxCAL_HITTEST_DECMONTH, ///< Hit on previous month arrow (in alternate month selector mode). + wxCAL_HITTEST_SURROUNDING_WEEK, ///< Hit on surrounding week of previous/next month (if shown). + wxCAL_HITTEST_WEEK ///< Hit on week of the year number (if shown). }; /** @@ -238,7 +275,7 @@ enum wxCalendarHitTestResult Show week numbers on the left side of the calendar. (not in generic) @endStyleTable - @beginEventTable{wxCalendarEvent} + @beginEventEmissionTable{wxCalendarEvent} @event{EVT_CALENDAR(id, func)} A day was double clicked in the calendar. @event{EVT_CALENDAR_SEL_CHANGED(id, func)} @@ -247,6 +284,8 @@ enum wxCalendarHitTestResult The selected month (and/or year) changed. @event{EVT_CALENDAR_WEEKDAY_CLICKED(id, func)} User clicked on the week day header (only generic). + @event{EVT_CALENDAR_WEEK_CLICKED(id, func)} + User clicked on the week of the year number (only generic). @endEventTable @note Changing the selected date will trigger an EVT_CALENDAR_DAY, MONTH or @@ -254,7 +293,7 @@ enum wxCalendarHitTestResult @library{wxadv} @category{ctrl} - + @appearance{calendarctrl} @nativeimpl{wxgtk,wxmsw} @@ -300,18 +339,18 @@ public: style bit directly. It enables or disables the special highlighting of the holidays. */ - void EnableHolidayDisplay(bool display = true); + virtual void EnableHolidayDisplay(bool display = true); /** This function should be used instead of changing @c wxCAL_NO_MONTH_CHANGE style bit. It allows or disallows the user to - change the month interactively. Note that if the month can not be - changed, the year can not be changed neither. + change the month interactively. Note that if the month cannot be + changed, the year cannot be changed neither. @return @true if the value of this option really changed or @false if it was already set to the requested value. */ - bool EnableMonthChange(bool enable = true); + virtual bool EnableMonthChange(bool enable = true); /** @deprecated @@ -320,19 +359,19 @@ public: @c wxCAL_NO_YEAR_CHANGE style bit directly. It allows or disallows the user to change the year interactively. Only in generic wxCalendarCtrl. */ - void EnableYearChange(bool enable = true); + virtual void EnableYearChange(bool enable = true); /** Returns the attribute for the given date (should be in the range 1...31). The returned pointer may be @NULL. Only in generic wxCalendarCtrl. */ - wxCalendarDateAttr* GetAttr(size_t day) const; + virtual wxCalendarDateAttr* GetAttr(size_t day) const; /** Gets the currently selected date. */ - const wxDateTime GetDate() const; + virtual wxDateTime GetDate() const; /** Gets the background colour of the header part of the calendar window. @@ -342,7 +381,7 @@ public: @see SetHeaderColours() */ - const wxColour GetHeaderColourBg() const; + virtual const wxColour& GetHeaderColourBg() const; /** Gets the foreground colour of the header part of the calendar window. @@ -352,7 +391,7 @@ public: @see SetHeaderColours() */ - const wxColour GetHeaderColourFg() const; + virtual const wxColour& GetHeaderColourFg() const; /** Gets the background highlight colour. Only in generic wxCalendarCtrl. @@ -362,7 +401,7 @@ public: @see SetHighlightColours() */ - const wxColour GetHighlightColourBg() const; + virtual const wxColour& GetHighlightColourBg() const; /** Gets the foreground highlight colour. Only in generic wxCalendarCtrl. @@ -372,7 +411,7 @@ public: @see SetHighlightColours() */ - const wxColour GetHighlightColourFg() const; + virtual const wxColour& GetHighlightColourFg() const; /** Return the background colour currently used for holiday highlighting. @@ -383,7 +422,7 @@ public: @see SetHolidayColours() */ - const wxColour GetHolidayColourBg() const; + virtual const wxColour& GetHolidayColourBg() const; /** Return the foreground colour currently used for holiday highlighting. @@ -394,38 +433,40 @@ public: @see SetHolidayColours() */ - const wxColour GetHolidayColourFg() const; + virtual const wxColour& GetHolidayColourFg() const; /** Returns one of wxCalendarHitTestResult constants and fills either @a date or @a wd pointer with the corresponding value depending on the hit test code. - + Not implemented in wxGTK currently. */ - wxCalendarHitTestResult HitTest(const wxPoint& pos, - wxDateTime* date = NULL, - wxDateTime::WeekDay* wd = NULL); + virtual wxCalendarHitTestResult HitTest(const wxPoint& pos, + wxDateTime* date = NULL, + wxDateTime::WeekDay* wd = NULL); /** Clears any attributes associated with the given day (in the range 1...31). Only in generic wxCalendarCtrl. */ - void ResetAttr(size_t day); + virtual void ResetAttr(size_t day); /** Associates the attribute with the specified date (in the range 1...31). If the pointer is @NULL, the items attribute is cleared. Only in generic wxCalendarCtrl. */ - void SetAttr(size_t day, wxCalendarDateAttr* attr); + virtual void SetAttr(size_t day, wxCalendarDateAttr* attr); /** Sets the current date. - The @a date parameter must be valid. + The @a date parameter must be valid and in the currently valid range as + set by SetDateRange(), otherwise the current date is not changed and + the function returns @false. */ - void SetDate(const wxDateTime& date); + virtual bool SetDate(const wxDateTime& date); /** Set the colours used for painting the weekdays at the top of the @@ -434,8 +475,8 @@ public: This method is currently only implemented in generic wxCalendarCtrl and does nothing in the native versions. */ - void SetHeaderColours(const wxColour& colFg, - const wxColour& colBg); + virtual void SetHeaderColours(const wxColour& colFg, + const wxColour& colBg); /** Set the colours to be used for highlighting the currently selected @@ -444,8 +485,8 @@ public: This method is currently only implemented in generic wxCalendarCtrl and does nothing in the native versions. */ - void SetHighlightColours(const wxColour& colFg, - const wxColour& colBg); + virtual void SetHighlightColours(const wxColour& colFg, + const wxColour& colBg); /** Marks the specified day as being a holiday in the current month. @@ -453,36 +494,34 @@ public: This method is only implemented in the generic version of the control and does nothing in the native ones. */ - void SetHoliday(size_t day); + virtual void SetHoliday(size_t day); /** Sets the colours to be used for the holidays highlighting. - + This method is only implemented in the generic version of the control and does nothing in the native ones. It should also only be called if the window style includes @c wxCAL_SHOW_HOLIDAYS flag or EnableHolidayDisplay() had been called. */ - void SetHolidayColours(const wxColour& colFg, - const wxColour& colBg); + virtual void SetHolidayColours(const wxColour& colFg, + const wxColour& colBg); /** Mark or unmark the day. This day of month will be marked in every month. In generic wxCalendarCtrl, */ - void Mark(size_t day, bool mark); + virtual void Mark(size_t day, bool mark); /** @name Date Range Functions - - The functions in this section are currently implemented in the generic - and MSW versions and do nothing in the native GTK implementation. */ //@{ /** - Restrict the dates shown by the control to the specified range. + Restrict the dates that can be selected in the control to the specified + range. If either date is set, the corresponding limit will be enforced and @true returned. If none are set, the existing restrictions are removed @@ -492,10 +531,10 @@ public: @param lowerdate The low limit for the dates shown by the control or - @c wxDefaultDateTime. - @param highlighting + ::wxDefaultDateTime. + @param upperdate The high limit for the dates shown by the control or - @c wxDefaultDateTime. + ::wxDefaultDateTime. @return @true if either limit is valid, @false otherwise */ @@ -509,11 +548,11 @@ public: @param lowerdate If non-@NULL, the value of the low limit for the dates shown by the - control is returned (which may be @c wxDefaultDateTime if no limit + control is returned (which may be ::wxDefaultDateTime if no limit is set). @param upperdate If non-@NULL, the value of the upper limit for the dates shown by - the control is returned (which may be @c wxDefaultDateTime if no + the control is returned (which may be ::wxDefaultDateTime if no limit is set). @return @true if either limit is set, @false otherwise