X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/628e155d8c70da0f962289cf1e1dea3699255707..58ce18f2fdadecffb21e27555115af708325cf18:/include/wx/generic/calctrlg.h diff --git a/include/wx/generic/calctrlg.h b/include/wx/generic/calctrlg.h index 682227cc37..02abe01210 100644 --- a/include/wx/generic/calctrlg.h +++ b/include/wx/generic/calctrlg.h @@ -18,6 +18,7 @@ class WXDLLIMPEXP_FWD_CORE wxComboBox; class WXDLLIMPEXP_FWD_CORE wxStaticText; class WXDLLIMPEXP_FWD_CORE wxSpinCtrl; +class WXDLLIMPEXP_FWD_CORE wxSpinEvent; // ---------------------------------------------------------------------------- // wxGenericCalendarCtrl @@ -58,15 +59,18 @@ public: // set/get the range in which selection can occur // --------------------------------------------- - // all functions in this section are for generic version only + virtual bool SetDateRange(const wxDateTime& lowerdate = wxDefaultDateTime, + const wxDateTime& upperdate = wxDefaultDateTime); + + virtual bool GetDateRange(wxDateTime *lowerdate, wxDateTime *upperdate) const; + + // these functions are for generic version only, don't use them but use the + // Set/GetDateRange() above instead bool SetLowerDateLimit(const wxDateTime& date = wxDefaultDateTime); const wxDateTime& GetLowerDateLimit() const { return m_lowdate; } bool SetUpperDateLimit(const wxDateTime& date = wxDefaultDateTime); const wxDateTime& GetUpperDateLimit() const { return m_highdate; } - bool SetDateRange(const wxDateTime& lowerdate = wxDefaultDateTime, - const wxDateTime& upperdate = wxDefaultDateTime); - // calendar mode // ------------- @@ -81,9 +85,6 @@ public: // corresponds to wxCAL_NO_YEAR_CHANGE bit, deprecated, generic only void EnableYearChange(bool enable = true); - // corresponds to wxCAL_SHOW_HOLIDAYS bit, generic only - void EnableHolidayDisplay(bool display = true); - // customization // ------------- @@ -93,45 +94,45 @@ public: // all other functions in this section are for generic version only // header colours are used for painting the weekdays at the top - void SetHeaderColours(const wxColour& colFg, const wxColour& colBg) + virtual void SetHeaderColours(const wxColour& colFg, const wxColour& colBg) { m_colHeaderFg = colFg; m_colHeaderBg = colBg; } - const wxColour& GetHeaderColourFg() const { return m_colHeaderFg; } - const wxColour& GetHeaderColourBg() const { return m_colHeaderBg; } + virtual const wxColour& GetHeaderColourFg() const { return m_colHeaderFg; } + virtual const wxColour& GetHeaderColourBg() const { return m_colHeaderBg; } // highlight colour is used for the currently selected date - void SetHighlightColours(const wxColour& colFg, const wxColour& colBg) + virtual void SetHighlightColours(const wxColour& colFg, const wxColour& colBg) { m_colHighlightFg = colFg; m_colHighlightBg = colBg; } - const wxColour& GetHighlightColourFg() const { return m_colHighlightFg; } - const wxColour& GetHighlightColourBg() const { return m_colHighlightBg; } + virtual const wxColour& GetHighlightColourFg() const { return m_colHighlightFg; } + virtual const wxColour& GetHighlightColourBg() const { return m_colHighlightBg; } // holiday colour is used for the holidays (if style & wxCAL_SHOW_HOLIDAYS) - void SetHolidayColours(const wxColour& colFg, const wxColour& colBg) + virtual void SetHolidayColours(const wxColour& colFg, const wxColour& colBg) { m_colHolidayFg = colFg; m_colHolidayBg = colBg; } - const wxColour& GetHolidayColourFg() const { return m_colHolidayFg; } - const wxColour& GetHolidayColourBg() const { return m_colHolidayBg; } + virtual const wxColour& GetHolidayColourFg() const { return m_colHolidayFg; } + virtual const wxColour& GetHolidayColourBg() const { return m_colHolidayBg; } virtual wxCalendarDateAttr *GetAttr(size_t day) const { - wxCHECK_MSG( day > 0 && day < 32, NULL, _T("invalid day") ); + wxCHECK_MSG( day > 0 && day < 32, NULL, wxT("invalid day") ); return m_attrs[day - 1]; } virtual void SetAttr(size_t day, wxCalendarDateAttr *attr) { - wxCHECK_RET( day > 0 && day < 32, _T("invalid day") ); + wxCHECK_RET( day > 0 && day < 32, wxT("invalid day") ); delete m_attrs[day - 1]; m_attrs[day - 1] = attr; @@ -139,7 +140,7 @@ public: virtual void ResetAttr(size_t day) { SetAttr(day, NULL); } - void SetHoliday(size_t day); + virtual void SetHoliday(size_t day); virtual wxCalendarHitTestResult HitTest(const wxPoint& pos, wxDateTime *date = NULL, @@ -165,10 +166,8 @@ public: protected: // override some base class virtuals virtual wxSize DoGetBestSize() const; - virtual void DoGetPosition(int *x, int *y) const; - virtual void DoGetSize(int *width, int *height) const; - virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags); virtual void DoMoveWindow(int x, int y, int width, int height); + virtual void DoGetSize(int *width, int *height) const; private: // common part of all ctors @@ -183,7 +182,9 @@ private: void OnDClick(wxMouseEvent& event); void OnChar(wxKeyEvent& event); void OnMonthChange(wxCommandEvent& event); - void OnYearChange(wxCommandEvent& event); + + void HandleYearChange(wxCommandEvent& event); + void OnYearChange(wxSpinEvent& event); void OnYearTextChange(wxCommandEvent& event); // (re)calc m_widthCol and m_heightRow @@ -198,15 +199,29 @@ private: // get the date from which we start drawing days wxDateTime GetStartDate() const; + // get the first/last days of the week corresponding to the current style + wxDateTime::WeekDay GetWeekStart() const + { + return HasFlag(wxCAL_MONDAY_FIRST) ? wxDateTime::Mon + : wxDateTime::Sun; + } + + wxDateTime::WeekDay GetWeekEnd() const + { + return HasFlag(wxCAL_MONDAY_FIRST) ? wxDateTime::Sun + : wxDateTime::Sat; + } + + // is this date shown? bool IsDateShown(const wxDateTime& date) const; - // is this date in the given range? + // is this date in the currently allowed range? bool IsDateInRange(const wxDateTime& date) const; - // range helpers - bool ChangeYear(wxDateTime* target) const; - bool ChangeMonth(wxDateTime* target) const; + // adjust the date to the currently allowed range, return true if it was + // changed + bool AdjustDateToRange(wxDateTime *date) const; // redraw the given date void RefreshDate(const wxDateTime& date); @@ -214,12 +229,6 @@ private: // change the date inside the same month/year void ChangeDay(const wxDateTime& date); - // set the attributes for the holidays if needed - void SetHolidayAttrs(); - - // reset all holidays - void ResetHolidayAttrs(); - // deprecated bool AllowYearChange() const { @@ -239,6 +248,9 @@ public: wxControl *GetYearControl() const; private: + virtual void ResetHolidayAttrs(); + virtual void RefreshHolidays() { Refresh(); } + // OnPaint helper-methods // Highlight the [fromdate : todate] range using pen and brush @@ -253,6 +265,7 @@ private: // typed in by the user void SetUserChangedYear() { m_userChangedYear = true; } + // the subcontrols wxStaticText *m_staticMonth; wxComboBox *m_comboMonth; @@ -275,7 +288,7 @@ private: m_colHeaderFg, m_colHeaderBg, m_colBackground, - m_colSorrounding; + m_colSurrounding; // the attributes for each of the month days wxCalendarDateAttr *m_attrs[31]; @@ -283,7 +296,8 @@ private: // the width and height of one column/row in the calendar wxCoord m_widthCol, m_heightRow, - m_rowOffset; + m_rowOffset, + m_calendarWeekWidth; wxRect m_leftArrowRect, m_rightArrowRect; @@ -297,7 +311,7 @@ private: DECLARE_DYNAMIC_CLASS(wxGenericCalendarCtrl) DECLARE_EVENT_TABLE() - DECLARE_NO_COPY_CLASS(wxGenericCalendarCtrl) + wxDECLARE_NO_COPY_CLASS(wxGenericCalendarCtrl); }; #endif // _WX_GENERIC_CALCTRLG_H