From cc0bffacebe299b312ce7fdf49a8825f466cf73f Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Fri, 5 Mar 2004 05:28:21 +0000 Subject: [PATCH] Changed CanApplyParentThemeBackground to ApplyParentThemeBackground and let the windows set the the background colour themselves (or not) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26090 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/bmpbuttn.h | 4 +++- include/wx/bookctrl.h | 3 +++ include/wx/checkbox.h | 3 ++- include/wx/generic/panelg.h | 4 +++- include/wx/html/htmlwin.h | 3 ++- include/wx/msw/button.h | 6 ++++++ include/wx/msw/radiobox.h | 3 +++ include/wx/msw/radiobut.h | 4 +++- include/wx/notebook.h | 1 - include/wx/radiobox.h | 2 -- include/wx/slider.h | 4 +++- include/wx/statbox.h | 3 ++- include/wx/statline.h | 3 ++- include/wx/stattext.h | 3 ++- include/wx/vlbox.h | 4 +++- include/wx/window.h | 3 ++- src/msw/notebook.cpp | 14 ++------------ 17 files changed, 41 insertions(+), 26 deletions(-) diff --git a/include/wx/bmpbuttn.h b/include/wx/bmpbuttn.h index 6827496a50..c874c9d9da 100644 --- a/include/wx/bmpbuttn.h +++ b/include/wx/bmpbuttn.h @@ -61,7 +61,9 @@ public: int GetMarginX() const { return m_marginX; } int GetMarginY() const { return m_marginY; } - virtual bool CanApplyParentThemeBackground() const { return true; } + virtual void ApplyParentThemeBackground(const wxColour& bg) + { SetBackgroundColour(bg); } + protected: // function called when any of the bitmaps changes diff --git a/include/wx/bookctrl.h b/include/wx/bookctrl.h index 26f1f2d31c..883a27bebc 100644 --- a/include/wx/bookctrl.h +++ b/include/wx/bookctrl.h @@ -161,6 +161,9 @@ public: } } + virtual void ApplyParentThemeBackground(const wxColour& bg) + { SetBackgroundColour(bg); } + protected: // remove the page and return a pointer to it virtual wxWindow *DoRemovePage(size_t page) = 0; diff --git a/include/wx/checkbox.h b/include/wx/checkbox.h index bb97f9d5ca..6d3ec75c4d 100644 --- a/include/wx/checkbox.h +++ b/include/wx/checkbox.h @@ -106,7 +106,8 @@ public: return HasFlag(wxCHK_ALLOW_3RD_STATE_FOR_USER); } - virtual bool CanApplyParentThemeBackground() const { return true; } + virtual void ApplyParentThemeBackground(const wxColour& bg) + { SetBackgroundColour(bg); } protected: virtual void DoSet3StateValue(wxCheckBoxState WXUNUSED(state)) { wxFAIL; } diff --git a/include/wx/generic/panelg.h b/include/wx/generic/panelg.h index 9fbe9ceb26..28852dd454 100644 --- a/include/wx/generic/panelg.h +++ b/include/wx/generic/panelg.h @@ -86,7 +86,9 @@ public: virtual bool ProvidesBackground() const { return TRUE; } #endif - virtual bool CanApplyParentThemeBackground() const { return true; } + virtual void ApplyParentThemeBackground(const wxColour& bg) + { SetBackgroundColour(bg); } + WX_DECLARE_CONTROL_CONTAINER(); diff --git a/include/wx/html/htmlwin.h b/include/wx/html/htmlwin.h index f8b88670d7..0e4fab1eda 100644 --- a/include/wx/html/htmlwin.h +++ b/include/wx/html/htmlwin.h @@ -198,7 +198,8 @@ public: void SelectAll(); #endif - virtual bool CanApplyParentThemeBackground() const { return false; } + virtual void ApplyParentThemeBackground(const wxColour& WXUNUSED(bg)) + { /* do nothing */ } protected: void Init(); diff --git a/include/wx/msw/button.h b/include/wx/msw/button.h index 8e5a62461e..bb844575e3 100644 --- a/include/wx/msw/button.h +++ b/include/wx/msw/button.h @@ -54,6 +54,12 @@ public: virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); virtual bool MSWCommand(WXUINT param, WXWORD id); + virtual void ApplyParentThemeBackground(const wxColour& bg) + { + // avoide switching into owner-drawn mode + wxControl::SetBackgroundColour(bg); + } + #ifdef __WIN32__ // coloured buttons support virtual bool SetBackgroundColour(const wxColour &colour); diff --git a/include/wx/msw/radiobox.h b/include/wx/msw/radiobox.h index 093dca1f3a..698bde3d7a 100644 --- a/include/wx/msw/radiobox.h +++ b/include/wx/msw/radiobox.h @@ -124,6 +124,9 @@ public: int GetNumVer() const; int GetNumHor() const; + virtual void ApplyParentThemeBackground(const wxColour& bg) + { SetBackgroundColour(bg); } + protected: // subclass one radio button void SubclassRadioButton(WXHWND hWndBtn); diff --git a/include/wx/msw/radiobut.h b/include/wx/msw/radiobut.h index b04f477ae6..da92a8e18f 100644 --- a/include/wx/msw/radiobut.h +++ b/include/wx/msw/radiobut.h @@ -52,7 +52,9 @@ public: // implementation only from now on virtual bool MSWCommand(WXUINT param, WXWORD id); virtual void Command(wxCommandEvent& event); - virtual bool CanApplyParentThemeBackground() const { return true; } + virtual void ApplyParentThemeBackground(const wxColour& bg) + { SetBackgroundColour(bg); } + protected: virtual wxSize DoGetBestSize() const; diff --git a/include/wx/notebook.h b/include/wx/notebook.h index ef5419d807..d29d1a32e1 100644 --- a/include/wx/notebook.h +++ b/include/wx/notebook.h @@ -86,7 +86,6 @@ public: // implement some base class functions virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const; - virtual bool CanApplyParentThemeBackground() const { return true; } protected: DECLARE_NO_COPY_CLASS(wxNotebookBase) diff --git a/include/wx/radiobox.h b/include/wx/radiobox.h index 575fab95d9..0a18908021 100644 --- a/include/wx/radiobox.h +++ b/include/wx/radiobox.h @@ -86,8 +86,6 @@ public: // return the item above/below/to the left/right of the given one int GetNextItem(int item, wxDirection dir, long style) const; - virtual bool CanApplyParentThemeBackground() const { return true; } - // for compatibility only, don't use these methods in new code! #if WXWIN_COMPATIBILITY_2_2 int Number() const { return GetCount(); } diff --git a/include/wx/slider.h b/include/wx/slider.h index 512e401328..dfd4a63904 100644 --- a/include/wx/slider.h +++ b/include/wx/slider.h @@ -81,7 +81,9 @@ public: virtual void SetSelection(int WXUNUSED(min), int WXUNUSED(max)) { } - virtual bool CanApplyParentThemeBackground() const { return true; } + virtual void ApplyParentThemeBackground(const wxColour& bg) + { SetBackgroundColour(bg); } + private: DECLARE_NO_COPY_CLASS(wxSliderBase) diff --git a/include/wx/statbox.h b/include/wx/statbox.h index 4d409ab373..d5661e10fc 100644 --- a/include/wx/statbox.h +++ b/include/wx/statbox.h @@ -18,7 +18,8 @@ public: // overriden base class virtuals virtual bool AcceptsFocus() const { return false; } - virtual bool CanApplyParentThemeBackground() const { return true; } + virtual void ApplyParentThemeBackground(const wxColour& bg) + { SetBackgroundColour(bg); } private: DECLARE_NO_COPY_CLASS(wxStaticBoxBase) diff --git a/include/wx/statline.h b/include/wx/statline.h index 6beb05a2c5..7bd1939ceb 100644 --- a/include/wx/statline.h +++ b/include/wx/statline.h @@ -48,7 +48,8 @@ public: // overriden base class virtuals virtual bool AcceptsFocus() const { return false; } - virtual bool CanApplyParentThemeBackground() const { return true; } + virtual void ApplyParentThemeBackground(const wxColour& bg) + { SetBackgroundColour(bg); } protected: // set the right size for the right dimension diff --git a/include/wx/stattext.h b/include/wx/stattext.h index 525ad9eb8d..8590052f74 100644 --- a/include/wx/stattext.h +++ b/include/wx/stattext.h @@ -14,7 +14,8 @@ public: // overriden base virtuals virtual bool AcceptsFocus() const { return false; } - virtual bool CanApplyParentThemeBackground() const { return true; } + virtual void ApplyParentThemeBackground(const wxColour& bg) + { SetBackgroundColour(bg); } private: DECLARE_NO_COPY_CLASS(wxStaticTextBase) diff --git a/include/wx/vlbox.h b/include/wx/vlbox.h index 42c5ce2ad4..9e5bf64c5b 100644 --- a/include/wx/vlbox.h +++ b/include/wx/vlbox.h @@ -189,7 +189,9 @@ public: void SetSelectionBackground(const wxColour& col); - virtual bool CanApplyParentThemeBackground() const { return false; } + virtual void ApplyParentThemeBackground(const wxColour& WXUNUSED(bg)) + { /* do nothing */ } + protected: // the derived class must implement this function to actually draw the item diff --git a/include/wx/window.h b/include/wx/window.h index b02a9ecf44..0f1d01072d 100644 --- a/include/wx/window.h +++ b/include/wx/window.h @@ -399,7 +399,8 @@ public: // page is added to a notebook it and it's children may need to have // the colours adjusted depending on the current theme settings, but // not all windows/controls can do this without looking wrong. - virtual bool CanApplyParentThemeBackground() const { return false; } + virtual void ApplyParentThemeBackground(const wxColour& WXUNUSED(bg)) + { /* do nothing */ } // returns true if this window should inherit its parent colours on // creation diff --git a/src/msw/notebook.cpp b/src/msw/notebook.cpp index e04027b7da..765866b191 100644 --- a/src/msw/notebook.cpp +++ b/src/msw/notebook.cpp @@ -966,19 +966,9 @@ void wxNotebook::ApplyThemeBackground(wxWindow*, const wxColour&) #endif { #if wxUSE_UXTHEME - // Special case for wxButton: Don't set the background for buttons since - // this will switch it into ownerdraw mode - if (window->IsKindOf(CLASSINFO(wxButton)) && !window->IsKindOf(CLASSINFO(wxBitmapButton))) - // This is essential, otherwise you'll see dark grey - // corners in the buttons. - ((wxButton*)window)->wxControl::SetBackgroundColour(colour); - - // for all other classes let them decide - else if ((window != this) && window->CanApplyParentThemeBackground()) - { - window->SetBackgroundColour(colour); - } + window->ApplyParentThemeBackground(colour); + for ( wxWindowList::compatibility_iterator node = window->GetChildren().GetFirst(); node; node = node->GetNext() ) { wxWindow *child = node->GetData(); -- 2.47.2