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
This commit is contained in:
@@ -61,6 +61,8 @@ public:
|
|||||||
int GetMarginX() const { return m_marginX; }
|
int GetMarginX() const { return m_marginX; }
|
||||||
int GetMarginY() const { return m_marginY; }
|
int GetMarginY() const { return m_marginY; }
|
||||||
|
|
||||||
|
virtual bool CanApplyParentThemeBackground() const { return true; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// function called when any of the bitmaps changes
|
// function called when any of the bitmaps changes
|
||||||
virtual void OnSetBitmap() { }
|
virtual void OnSetBitmap() { }
|
||||||
|
@@ -106,6 +106,8 @@ public:
|
|||||||
return HasFlag(wxCHK_ALLOW_3RD_STATE_FOR_USER);
|
return HasFlag(wxCHK_ALLOW_3RD_STATE_FOR_USER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual bool CanApplyParentThemeBackground() const { return true; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void DoSet3StateValue(wxCheckBoxState WXUNUSED(state)) { wxFAIL; }
|
virtual void DoSet3StateValue(wxCheckBoxState WXUNUSED(state)) { wxFAIL; }
|
||||||
|
|
||||||
|
@@ -86,6 +86,8 @@ public:
|
|||||||
virtual bool ProvidesBackground() const { return TRUE; }
|
virtual bool ProvidesBackground() const { return TRUE; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
virtual bool CanApplyParentThemeBackground() const { return true; }
|
||||||
|
|
||||||
WX_DECLARE_CONTROL_CONTAINER();
|
WX_DECLARE_CONTROL_CONTAINER();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@@ -198,6 +198,8 @@ public:
|
|||||||
void SelectAll();
|
void SelectAll();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
virtual bool CanApplyParentThemeBackground() const { return false; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void Init();
|
void Init();
|
||||||
|
|
||||||
|
@@ -52,6 +52,7 @@ public:
|
|||||||
// implementation only from now on
|
// implementation only from now on
|
||||||
virtual bool MSWCommand(WXUINT param, WXWORD id);
|
virtual bool MSWCommand(WXUINT param, WXWORD id);
|
||||||
virtual void Command(wxCommandEvent& event);
|
virtual void Command(wxCommandEvent& event);
|
||||||
|
virtual bool CanApplyParentThemeBackground() const { return true; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual wxSize DoGetBestSize() const;
|
virtual wxSize DoGetBestSize() const;
|
||||||
|
@@ -86,6 +86,7 @@ public:
|
|||||||
|
|
||||||
// implement some base class functions
|
// implement some base class functions
|
||||||
virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
|
virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
|
||||||
|
virtual bool CanApplyParentThemeBackground() const { return true; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
DECLARE_NO_COPY_CLASS(wxNotebookBase)
|
DECLARE_NO_COPY_CLASS(wxNotebookBase)
|
||||||
|
@@ -46,6 +46,8 @@ public:
|
|||||||
virtual void Position(const wxPoint& ptOrigin,
|
virtual void Position(const wxPoint& ptOrigin,
|
||||||
const wxSize& size);
|
const wxSize& size);
|
||||||
|
|
||||||
|
virtual bool IsTopLevel() const { return TRUE; }
|
||||||
|
|
||||||
DECLARE_NO_COPY_CLASS(wxPopupWindowBase)
|
DECLARE_NO_COPY_CLASS(wxPopupWindowBase)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -86,6 +86,8 @@ public:
|
|||||||
// return the item above/below/to the left/right of the given one
|
// return the item above/below/to the left/right of the given one
|
||||||
int GetNextItem(int item, wxDirection dir, long style) const;
|
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!
|
// for compatibility only, don't use these methods in new code!
|
||||||
#if WXWIN_COMPATIBILITY_2_2
|
#if WXWIN_COMPATIBILITY_2_2
|
||||||
int Number() const { return GetCount(); }
|
int Number() const { return GetCount(); }
|
||||||
|
@@ -80,6 +80,9 @@ public:
|
|||||||
virtual int GetSelStart() const { return GetMax(); }
|
virtual int GetSelStart() const { return GetMax(); }
|
||||||
virtual void SetSelection(int WXUNUSED(min), int WXUNUSED(max)) { }
|
virtual void SetSelection(int WXUNUSED(min), int WXUNUSED(max)) { }
|
||||||
|
|
||||||
|
|
||||||
|
virtual bool CanApplyParentThemeBackground() const { return true; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DECLARE_NO_COPY_CLASS(wxSliderBase)
|
DECLARE_NO_COPY_CLASS(wxSliderBase)
|
||||||
};
|
};
|
||||||
|
@@ -17,7 +17,8 @@ public:
|
|||||||
wxStaticBoxBase() { }
|
wxStaticBoxBase() { }
|
||||||
|
|
||||||
// overriden base class virtuals
|
// overriden base class virtuals
|
||||||
virtual bool AcceptsFocus() const { return FALSE; }
|
virtual bool AcceptsFocus() const { return false; }
|
||||||
|
virtual bool CanApplyParentThemeBackground() const { return true; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DECLARE_NO_COPY_CLASS(wxStaticBoxBase)
|
DECLARE_NO_COPY_CLASS(wxStaticBoxBase)
|
||||||
|
@@ -47,7 +47,8 @@ public:
|
|||||||
static int GetDefaultSize() { return 2; }
|
static int GetDefaultSize() { return 2; }
|
||||||
|
|
||||||
// overriden base class virtuals
|
// overriden base class virtuals
|
||||||
virtual bool AcceptsFocus() const { return FALSE; }
|
virtual bool AcceptsFocus() const { return false; }
|
||||||
|
virtual bool CanApplyParentThemeBackground() const { return true; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// set the right size for the right dimension
|
// set the right size for the right dimension
|
||||||
|
@@ -12,8 +12,9 @@ class WXDLLEXPORT wxStaticTextBase : public wxControl
|
|||||||
public:
|
public:
|
||||||
wxStaticTextBase() { }
|
wxStaticTextBase() { }
|
||||||
|
|
||||||
// overriden base cirtuals
|
// overriden base virtuals
|
||||||
virtual bool AcceptsFocus() const { return FALSE; }
|
virtual bool AcceptsFocus() const { return false; }
|
||||||
|
virtual bool CanApplyParentThemeBackground() const { return true; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DECLARE_NO_COPY_CLASS(wxStaticTextBase)
|
DECLARE_NO_COPY_CLASS(wxStaticTextBase)
|
||||||
|
@@ -189,6 +189,8 @@ public:
|
|||||||
void SetSelectionBackground(const wxColour& col);
|
void SetSelectionBackground(const wxColour& col);
|
||||||
|
|
||||||
|
|
||||||
|
virtual bool CanApplyParentThemeBackground() const { return false; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// the derived class must implement this function to actually draw the item
|
// the derived class must implement this function to actually draw the item
|
||||||
// with the given index on the provided DC
|
// with the given index on the provided DC
|
||||||
|
@@ -394,6 +394,13 @@ public:
|
|||||||
virtual void SetThemeEnabled(bool enableTheme) { m_themeEnabled = enableTheme; }
|
virtual void SetThemeEnabled(bool enableTheme) { m_themeEnabled = enableTheme; }
|
||||||
virtual bool GetThemeEnabled() const { return m_themeEnabled; }
|
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
|
// returns true if this window should inherit its parent colours on
|
||||||
// creation
|
// creation
|
||||||
virtual bool ShouldInheritColours() const { return false; }
|
virtual bool ShouldInheritColours() const { return false; }
|
||||||
|
@@ -966,24 +966,15 @@ void wxNotebook::ApplyThemeBackground(wxWindow*, const wxColour&)
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#if wxUSE_UXTHEME
|
#if wxUSE_UXTHEME
|
||||||
// Don't set the background for buttons since this will
|
// Special case for wxButton: Don't set the background for buttons since
|
||||||
// switch it into ownerdraw mode
|
// this will switch it into ownerdraw mode
|
||||||
if (window->IsKindOf(CLASSINFO(wxButton)) && !window->IsKindOf(CLASSINFO(wxBitmapButton)))
|
if (window->IsKindOf(CLASSINFO(wxButton)) && !window->IsKindOf(CLASSINFO(wxBitmapButton)))
|
||||||
// This is essential, otherwise you'll see dark grey
|
// This is essential, otherwise you'll see dark grey
|
||||||
// corners in the buttons.
|
// corners in the buttons.
|
||||||
((wxButton*)window)->wxControl::SetBackgroundColour(colour);
|
((wxButton*)window)->wxControl::SetBackgroundColour(colour);
|
||||||
else if (window->IsKindOf(CLASSINFO(wxStaticText)) ||
|
|
||||||
window->IsKindOf(CLASSINFO(wxStaticBox)) ||
|
// for all other classes let them decide
|
||||||
window->IsKindOf(CLASSINFO(wxStaticLine)) ||
|
else if ((window != this) && window->CanApplyParentThemeBackground())
|
||||||
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))
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
window->SetBackgroundColour(colour);
|
window->SetBackgroundColour(colour);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user