// different window variants, on platforms like eg mac uses different
// rendering sizes
-enum wxWindowVariant
+enum wxWindowVariant
{
wxWINDOW_VARIANT_NORMAL, // Normal size
wxWINDOW_VARIANT_SMALL, // Smaller size (about 25 % smaller than normal)
// sets the window variant, calls internally DoSetVariant if variant has changed
void SetWindowVariant( wxWindowVariant variant ) ;
wxWindowVariant GetWindowVariant() const { return m_windowVariant ; }
-
+
// window id uniquely identifies the window among its siblings unless
// it is -1 which means "don't care"
virtual void SetSizeHints( int minW, int minH,
int maxW = -1, int maxH = -1,
int incW = -1, int incH = -1 );
+ void SetSizeHints( const wxSize& minSize,
+ const wxSize& maxSize=wxDefaultSize,
+ const wxSize& incSize=wxDefaultSize)
+ {
+ SetSizeHints(minSize.x, minSize.y,
+ maxSize.x, maxSize.y,
+ incSize.x, incSize.y);
+ }
virtual void SetVirtualSizeHints( int minW, int minH,
int maxW = -1, int maxH = -1 );
+ void SetVirtualSizeHints( const wxSize& minSize,
+ const wxSize& maxSize=wxDefaultSize)
+ {
+ SetVirtualSizeHints(minSize.x, minSize.y, maxSize.x, maxSize.y);
+ }
virtual int GetMinWidth() const { return m_minWidth; }
virtual int GetMinHeight() const { return m_minHeight; }
// Override this method to control the values given to Sizers etc.
virtual wxSize GetMaxSize() const { return wxSize( m_maxWidth, m_maxHeight ); }
+ virtual wxSize GetMinSize() const { return wxSize( m_minWidth, m_minHeight ); }
// Methods for accessing the virtual size of a window. For most
// windows this is just the client area of the window, but for
// 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; }
// not all windows/controls can do this without looking wrong.
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
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);
wxSizer *GetSizer() const { return m_windowSizer; }
// Track if this window is a member of a sizer
- void SetContainingSizer(wxSizer* sizer)
- {
- // adding a window to a sizer twice is going to result in fatal and
- // hard to debug problems later because when deleting the second
- // associated wxSizerItem we're going to dereference a dangling
- // pointer; so try to detect this as early as possible
- wxASSERT_MSG( !sizer || m_containingSizer != sizer,
- _T("Adding a window to the same sizer twice?") );
-
- m_containingSizer = sizer;
- }
+ void SetContainingSizer(wxSizer* sizer);
wxSizer *GetContainingSizer() const { return m_containingSizer; }
// accessibility
wxWindow *GetAncestorWithCustomPalette() const;
#endif // wxUSE_PALETTE
+ // 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; }
+
protected:
// event handling specific to wxWindow
virtual bool TryValidator(wxEvent& event);
#if wxUSE_ACCESSIBILITY
wxAccessible* m_accessible;
#endif
- // Best size for controls which fail to implement DoGetBestSize()
- wxSize m_bestSize;
// Virtual size (scrolling)
wxSize m_virtualSize;
int m_minVirtualHeight;
int m_maxVirtualWidth;
int m_maxVirtualHeight;
-
+
wxWindowVariant m_windowVariant ;
// override this to change the default (i.e. used when no style is
// smarter SetSize / convenience function for expanding wxDefaultSize.
// Note that it does not influence the value returned by GetBestSize
// at all.
- void SetBestSize(const wxSize& size)
- {
- // the size only needs to be changed if the current size is incomplete,
- // i.e. one of the components was specified as default -- so if both
- // were given, simply don't do anything
- if ( size.x == -1 || size.y == -1 )
- {
- wxSize sizeBest = DoGetBestSize();
- if ( size.x != -1 )
- sizeBest.x = size.x;
- if ( size.y != -1 )
- sizeBest.y = size.y;
-
- SetSize(sizeBest);
- }
- }
+ void SetBestSize(const wxSize& size);
+
+ // set the initial window size if none is given (i.e. at least one of the
+ // components of the size passed to ctor/Create() is -1)
+ //
+ // normally just calls SetBestSize() for controls, but can be overridden
+ // not to do it for the controls which have to do some additional
+ // initialization (e.g. add strings to list box) before their best size
+ // can be accurately calculated
+ virtual void SetInitialBestSize(const wxSize& WXUNUSED(size)) {}
+
// more pure virtual functions
// ---------------------------