1. moved InheritAttributes() from wxControl to wxWindow

2. made it inherit only the attributes explicitly set for the parent
3. "explicitly set" means set with SetXXX(), not newly added SetDefaultXXX()
4. documented InheritAttributes(), ShouldInheritColours() and SetDefaultXXX()


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26670 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2004-04-08 12:11:22 +00:00
parent 26b6f3d3d8
commit b8e7b6738f
4 changed files with 169 additions and 21 deletions

View File

@@ -74,10 +74,6 @@ protected:
const wxValidator& validator,
const wxString& name);
// this function is obsolete, it is only kept for backwards compatibility,
// do *not* use it
void InheritAttributes() { }
// initialize the common fields of wxCommandEvent
void InitCommandEvent(wxCommandEvent& event) const;

View File

@@ -439,6 +439,10 @@ public:
// make the window modal (all other windows unresponsive)
virtual void MakeModal(bool modal = true);
// (primitive) theming support
// ---------------------------
virtual void SetThemeEnabled(bool enableTheme) { m_themeEnabled = enableTheme; }
virtual bool GetThemeEnabled() const { return m_themeEnabled; }
@@ -450,10 +454,6 @@ public:
virtual void ApplyParentThemeBackground(const wxColour& WXUNUSED(bg))
{ /* do nothing */ }
// returns true if this window should inherit its parent colours on
// creation
virtual bool ShouldInheritColours() const { return false; }
// focus and keyboard handling
// ---------------------------
@@ -697,25 +697,42 @@ public:
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
// set/retrieve the window colours (system defaults are used by
// default): Set functions return true if colour was changed
virtual bool SetBackgroundColour( const wxColour &colour );
virtual bool SetForegroundColour( const wxColour &colour );
// default): SetXXX() functions return true if colour was changed,
// SetDefaultXXX() reset the "m_hasXXX" flag after setting the value
// to prevent it from being inherited by our children
virtual bool SetBackgroundColour(const wxColour& colour);
void SetDefaultBackgroundColour(const wxColour& colour)
{
if ( SetBackgroundColour(colour) )
m_hasBgCol = false;
}
wxColour GetBackgroundColour() const;
virtual bool SetForegroundColour(const wxColour& colour);
void SetDefaultForegroundColour(const wxColour& colour)
{
if ( SetForegroundColour(colour) )
m_hasFgCol = false;
}
wxColour GetForegroundColour() const;
// set/retrieve the font for the window (SetFont() returns true if the
// font really changed)
virtual bool SetFont(const wxFont& font) = 0;
void SetDefaultFont(const wxFont& font)
{
if ( SetFont(font) )
m_hasFont = false;
}
const wxFont& GetFont() const { return DoGetFont(); }
wxFont& GetFont() { return DoGetFont(); }
// set/retrieve the cursor for this window (SetCursor() returns true
// if the cursor was really changed)
virtual bool SetCursor( const wxCursor &cursor );
const wxCursor& GetCursor() const { return m_cursor; }
wxCursor& GetCursor() { return m_cursor; }
// set/retrieve the font for the window (SetFont() returns true if the
// font really changed)
virtual bool SetFont( const wxFont &font ) = 0;
const wxFont& GetFont() const { return DoGetFont(); }
wxFont& GetFont() { return DoGetFont(); }
#if wxUSE_CARET
// associate a caret with the window
void SetCaret(wxCaret *caret);
@@ -987,6 +1004,18 @@ protected:
virtual bool TryValidator(wxEvent& event);
virtual bool TryParent(wxEvent& event);
// inherit the parents visual attributes if they had been explicitly set
// by the user (i.e. we don't inherit default attributes) and if we don't
// have our own explicitly set
virtual void InheritAttributes();
// returns false from here if this window doesn't want to inherit the
// parents colours even if InheritAttributes() would normally do it
//
// this just provides a simple way to customize InheritAttributes()
// behaviour in the most common case
virtual bool ShouldInheritColours() const { return false; }
#if wxUSE_CONSTRAINTS
// satisfy the constraints for the windows but don't set the window sizes