From bf956fac0e89eab569c41a9f121e728958767de7 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 1 Apr 2008 23:43:34 +0000 Subject: [PATCH] move all appearace-related methods down to wxCalendarCtrlBase from wxGenericCalendarCtrl git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@52966 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/calctrl.h | 41 ++++++++++++++++++++++++++++++++++ include/wx/generic/calctrlg.h | 22 +++++++++--------- interface/calctrl.h | 42 ++++++++++++++++++++++++++++------- samples/calendar/calendar.cpp | 8 +------ 4 files changed, 87 insertions(+), 26 deletions(-) diff --git a/include/wx/calctrl.h b/include/wx/calctrl.h index 7e293b247a..0be77175d4 100644 --- a/include/wx/calctrl.h +++ b/include/wx/calctrl.h @@ -228,6 +228,47 @@ public: virtual void ResetAttr(size_t WXUNUSED(day)) { } + // holidays support + // + // currently all functions in this section are implemented in the generic + // version of the control only and are simply ignored by native ones + + // equivalent to changing wxCAL_SHOW_HOLIDAYS flag but should be called + // instead of just changing it + virtual void EnableHolidayDisplay(bool WXUNUSED(display) = true) { } + + // set/get the colours to use for holidays (if they're enabled) + virtual void SetHolidayColours(const wxColour& WXUNUSED(colFg), + const wxColour& WXUNUSED(colBg)) { } + + virtual const wxColour& GetHolidayColourFg() const { return wxNullColour; } + virtual const wxColour& GetHolidayColourBg() const { return wxNullColour; } + + // mark the given day of the current month as being a holiday + virtual void SetHoliday(size_t WXUNUSED(day)) { } + + + // customizing the colours of the controls + // + // most of the methods in this section are only implemented by the native + // version of the control and do nothing in the native ones + + // set/get the colours to use for the display of the week day names at the + // top of the controls + virtual void SetHeaderColours(const wxColour& WXUNUSED(colFg), + const wxColour& WXUNUSED(colBg)) { } + + virtual const wxColour& GetHeaderColourFg() const { return wxNullColour; } + virtual const wxColour& GetHeaderColourBg() const { return wxNullColour; } + + // set/get the colours used for the currently selected date + virtual void SetHighlightColours(const wxColour& WXUNUSED(colFg), + const wxColour& WXUNUSED(colBg)) { } + + virtual const wxColour& GetHighlightColourFg() const { return wxNullColour; } + virtual const wxColour& GetHighlightColourBg() const { return wxNullColour; } + + // implementation only from now on // generate the given calendar event(s) diff --git a/include/wx/generic/calctrlg.h b/include/wx/generic/calctrlg.h index 682227cc37..253890e056 100644 --- a/include/wx/generic/calctrlg.h +++ b/include/wx/generic/calctrlg.h @@ -82,7 +82,7 @@ public: void EnableYearChange(bool enable = true); // corresponds to wxCAL_SHOW_HOLIDAYS bit, generic only - void EnableHolidayDisplay(bool display = true); + virtual void EnableHolidayDisplay(bool display = true); // customization @@ -93,34 +93,34 @@ 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 { @@ -139,7 +139,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, diff --git a/interface/calctrl.h b/interface/calctrl.h index ceb3e131ec..b57c2945a3 100644 --- a/interface/calctrl.h +++ b/interface/calctrl.h @@ -308,13 +308,18 @@ public: /** Gets the background colour of the header part of the calendar window. + This method is currently only implemented in generic wxCalendarCtrl and + always returns @c wxNullColour in the native versions. + @see SetHeaderColours() */ const wxColour GetHeaderColourBg() const; /** Gets the foreground colour of the header part of the calendar window. - Only in generic wxCalendarCtrl. + + This method is currently only implemented in generic wxCalendarCtrl and + always returns @c wxNullColour in the native versions. @see SetHeaderColours() */ @@ -323,6 +328,9 @@ public: /** Gets the background highlight colour. Only in generic wxCalendarCtrl. + This method is currently only implemented in generic wxCalendarCtrl and + always returns @c wxNullColour in the native versions. + @see SetHighlightColours() */ const wxColour GetHighlightColourBg() const; @@ -330,13 +338,18 @@ public: /** Gets the foreground highlight colour. Only in generic wxCalendarCtrl. + This method is currently only implemented in generic wxCalendarCtrl and + always returns @c wxNullColour in the native versions. + @see SetHighlightColours() */ const wxColour GetHighlightColourFg() const; /** Return the background colour currently used for holiday highlighting. - Only in generic wxCalendarCtrl. + + Only useful with generic wxCalendarCtrl as native versions currently + don't support holidays display at all and always return @c wxNullColour. @see SetHolidayColours() */ @@ -344,7 +357,9 @@ public: /** Return the foreground colour currently used for holiday highlighting. - Only in generic wxCalendarCtrl. + + Only useful with generic wxCalendarCtrl as native versions currently + don't support holidays display at all and always return @c wxNullColour. @see SetHolidayColours() */ @@ -381,27 +396,38 @@ public: /** Set the colours used for painting the weekdays at the top of the control. - Only in generic wxCalendarCtrl. + + This method is currently only implemented in generic wxCalendarCtrl and + does nothing in the native versions. */ void SetHeaderColours(const wxColour& colFg, const wxColour& colBg); /** Set the colours to be used for highlighting the currently selected date. - Only in generic wxCalendarCtrl. + + This method is currently only implemented in generic wxCalendarCtrl and + does nothing in the native versions. */ void SetHighlightColours(const wxColour& colFg, const wxColour& colBg); /** Marks the specified day as being a holiday in the current month. + + This method is only implemented in the generic version of the control + and does nothing in the native ones. */ void SetHoliday(size_t day); /** - Sets the colours to be used for the holidays highlighting (only used if the - window style includes @c wxCAL_SHOW_HOLIDAYS flag). - Only in generic wxCalendarCtrl. + 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); diff --git a/samples/calendar/calendar.cpp b/samples/calendar/calendar.cpp index 5241a440a6..42714c2345 100644 --- a/samples/calendar/calendar.cpp +++ b/samples/calendar/calendar.cpp @@ -449,13 +449,7 @@ void MyFrame::OnCalMonday(wxCommandEvent& event) void MyFrame::OnCalHolidays(wxCommandEvent& event) { - wxCalendarCtrlBase * cal = m_panel->GetCal(); -#ifdef wxHAS_NATIVE_CALENDARCTRL - wxStaticCast(cal, wxGenericCalendarCtrl) -#else - cal -#endif - ->EnableHolidayDisplay(event.IsChecked()); + m_panel->GetCal()->EnableHolidayDisplay(event.IsChecked()); } void MyFrame::OnCalSpecial(wxCommandEvent& event) -- 2.47.2