From bd507486e07b742bb7acb118811efd60ee027859 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Thu, 4 Mar 2004 17:03:55 +0000 Subject: [PATCH] Added CanApplyParentThemeBackground and use it in wxMSW's wxNotebook::ApplyThemeBackground. It's in the common base classes so that someday it's usage can expand to the other platforms as well. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26085 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/bmpbuttn.h | 2 ++ include/wx/checkbox.h | 2 ++ include/wx/generic/panelg.h | 2 ++ include/wx/html/htmlwin.h | 2 ++ include/wx/msw/radiobut.h | 1 + include/wx/notebook.h | 1 + include/wx/popupwin.h | 2 ++ include/wx/radiobox.h | 2 ++ include/wx/slider.h | 3 +++ include/wx/statbox.h | 3 ++- include/wx/statline.h | 3 ++- include/wx/stattext.h | 5 +++-- include/wx/vlbox.h | 2 ++ include/wx/window.h | 7 +++++++ src/msw/notebook.cpp | 19 +++++-------------- 15 files changed, 38 insertions(+), 18 deletions(-) diff --git a/include/wx/bmpbuttn.h b/include/wx/bmpbuttn.h index ebaafefda3..6827496a50 100644 --- a/include/wx/bmpbuttn.h +++ b/include/wx/bmpbuttn.h @@ -61,6 +61,8 @@ public: int GetMarginX() const { return m_marginX; } int GetMarginY() const { return m_marginY; } + virtual bool CanApplyParentThemeBackground() const { return true; } + protected: // function called when any of the bitmaps changes virtual void OnSetBitmap() { } diff --git a/include/wx/checkbox.h b/include/wx/checkbox.h index 6b30a0a25f..bb97f9d5ca 100644 --- a/include/wx/checkbox.h +++ b/include/wx/checkbox.h @@ -106,6 +106,8 @@ public: return HasFlag(wxCHK_ALLOW_3RD_STATE_FOR_USER); } + virtual bool CanApplyParentThemeBackground() const { return true; } + protected: virtual void DoSet3StateValue(wxCheckBoxState WXUNUSED(state)) { wxFAIL; } diff --git a/include/wx/generic/panelg.h b/include/wx/generic/panelg.h index b79a59e0f4..9fbe9ceb26 100644 --- a/include/wx/generic/panelg.h +++ b/include/wx/generic/panelg.h @@ -86,6 +86,8 @@ public: virtual bool ProvidesBackground() const { return TRUE; } #endif + virtual bool CanApplyParentThemeBackground() const { return true; } + WX_DECLARE_CONTROL_CONTAINER(); protected: diff --git a/include/wx/html/htmlwin.h b/include/wx/html/htmlwin.h index c62febbf6d..f8b88670d7 100644 --- a/include/wx/html/htmlwin.h +++ b/include/wx/html/htmlwin.h @@ -198,6 +198,8 @@ public: void SelectAll(); #endif + virtual bool CanApplyParentThemeBackground() const { return false; } + protected: void Init(); diff --git a/include/wx/msw/radiobut.h b/include/wx/msw/radiobut.h index b47ee2e241..b04f477ae6 100644 --- a/include/wx/msw/radiobut.h +++ b/include/wx/msw/radiobut.h @@ -52,6 +52,7 @@ public: // implementation only from now on virtual bool MSWCommand(WXUINT param, WXWORD id); virtual void Command(wxCommandEvent& event); + virtual bool CanApplyParentThemeBackground() const { return true; } protected: virtual wxSize DoGetBestSize() const; diff --git a/include/wx/notebook.h b/include/wx/notebook.h index d29d1a32e1..ef5419d807 100644 --- a/include/wx/notebook.h +++ b/include/wx/notebook.h @@ -86,6 +86,7 @@ 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/popupwin.h b/include/wx/popupwin.h index 6eb26bacb7..18ca40e2f3 100644 --- a/include/wx/popupwin.h +++ b/include/wx/popupwin.h @@ -46,6 +46,8 @@ public: virtual void Position(const wxPoint& ptOrigin, const wxSize& size); + virtual bool IsTopLevel() const { return TRUE; } + DECLARE_NO_COPY_CLASS(wxPopupWindowBase) }; diff --git a/include/wx/radiobox.h b/include/wx/radiobox.h index 0a18908021..575fab95d9 100644 --- a/include/wx/radiobox.h +++ b/include/wx/radiobox.h @@ -86,6 +86,8 @@ 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 894b8515fa..512e401328 100644 --- a/include/wx/slider.h +++ b/include/wx/slider.h @@ -80,6 +80,9 @@ public: virtual int GetSelStart() const { return GetMax(); } virtual void SetSelection(int WXUNUSED(min), int WXUNUSED(max)) { } + + virtual bool CanApplyParentThemeBackground() const { return true; } + private: DECLARE_NO_COPY_CLASS(wxSliderBase) }; diff --git a/include/wx/statbox.h b/include/wx/statbox.h index c0a5ed5da3..4d409ab373 100644 --- a/include/wx/statbox.h +++ b/include/wx/statbox.h @@ -17,7 +17,8 @@ public: wxStaticBoxBase() { } // overriden base class virtuals - virtual bool AcceptsFocus() const { return FALSE; } + virtual bool AcceptsFocus() const { return false; } + virtual bool CanApplyParentThemeBackground() const { return true; } private: DECLARE_NO_COPY_CLASS(wxStaticBoxBase) diff --git a/include/wx/statline.h b/include/wx/statline.h index 6a8b7db0d5..6beb05a2c5 100644 --- a/include/wx/statline.h +++ b/include/wx/statline.h @@ -47,7 +47,8 @@ public: static int GetDefaultSize() { return 2; } // overriden base class virtuals - virtual bool AcceptsFocus() const { return FALSE; } + virtual bool AcceptsFocus() const { return false; } + virtual bool CanApplyParentThemeBackground() const { return true; } protected: // set the right size for the right dimension diff --git a/include/wx/stattext.h b/include/wx/stattext.h index 6af02942a7..525ad9eb8d 100644 --- a/include/wx/stattext.h +++ b/include/wx/stattext.h @@ -12,8 +12,9 @@ class WXDLLEXPORT wxStaticTextBase : public wxControl public: wxStaticTextBase() { } - // overriden base cirtuals - virtual bool AcceptsFocus() const { return FALSE; } + // overriden base virtuals + virtual bool AcceptsFocus() const { return false; } + virtual bool CanApplyParentThemeBackground() const { return true; } private: DECLARE_NO_COPY_CLASS(wxStaticTextBase) diff --git a/include/wx/vlbox.h b/include/wx/vlbox.h index 8c8223dd4b..42c5ce2ad4 100644 --- a/include/wx/vlbox.h +++ b/include/wx/vlbox.h @@ -189,6 +189,8 @@ public: void SetSelectionBackground(const wxColour& col); + virtual bool CanApplyParentThemeBackground() const { return false; } + protected: // the derived class must implement this function to actually draw the item // with the given index on the provided DC diff --git a/include/wx/window.h b/include/wx/window.h index f1eed002ac..b02a9ecf44 100644 --- a/include/wx/window.h +++ b/include/wx/window.h @@ -394,6 +394,13 @@ public: virtual void SetThemeEnabled(bool enableTheme) { m_themeEnabled = enableTheme; } virtual bool GetThemeEnabled() const { return m_themeEnabled; } + // Returns true if this class should have the background colour + // changed to match the parent window's theme. For example when a + // 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; } + // returns true if this window should inherit its parent colours on // creation virtual bool ShouldInheritColours() const { return false; } diff --git a/src/msw/notebook.cpp b/src/msw/notebook.cpp index c027ef2d79..e04027b7da 100644 --- a/src/msw/notebook.cpp +++ b/src/msw/notebook.cpp @@ -966,24 +966,15 @@ void wxNotebook::ApplyThemeBackground(wxWindow*, const wxColour&) #endif { #if wxUSE_UXTHEME - // Don't set the background for buttons since this will - // switch it into ownerdraw mode + // 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); - else if (window->IsKindOf(CLASSINFO(wxStaticText)) || - window->IsKindOf(CLASSINFO(wxStaticBox)) || - window->IsKindOf(CLASSINFO(wxStaticLine)) || - window->IsKindOf(CLASSINFO(wxRadioButton)) || - window->IsKindOf(CLASSINFO(wxRadioBox)) || - window->IsKindOf(CLASSINFO(wxCheckBox)) || - window->IsKindOf(CLASSINFO(wxBitmapButton)) || - window->IsKindOf(CLASSINFO(wxSlider)) || - window->IsKindOf(CLASSINFO(wxPanel)) || - (window->IsKindOf(CLASSINFO(wxNotebook)) && (window != this)) || - window->IsKindOf(CLASSINFO(wxScrolledWindow)) - ) + + // for all other classes let them decide + else if ((window != this) && window->CanApplyParentThemeBackground()) { window->SetBackgroundColour(colour); } -- 2.47.2