class WXDLLEXPORT wxAccessible;
#endif
+// ----------------------------------------------------------------------------
+// helper stuff used by wxWindow
+// ----------------------------------------------------------------------------
+
+// struct containing all the visual attributes of a control
+struct WXDLLEXPORT wxVisualAttributes
+{
+ // the font used for control label/text inside it
+ wxFont font;
+
+ // the foreground colour
+ wxColour colFg;
+
+ // the background colour, may be wxNullColour if the controls background
+ // colour is not solid
+ wxColour colBg;
+};
+
+// different window variants, on platforms like eg mac uses different
+// rendering sizes
+enum wxWindowVariant
+{
+ wxWINDOW_VARIANT_NORMAL, // Normal size
+ wxWINDOW_VARIANT_SMALL, // Smaller size (about 25 % smaller than normal)
+ wxWINDOW_VARIANT_MINI, // Mini size (about 33 % smaller than normal)
+ wxWINDOW_VARIANT_LARGE, // Large size (about 25 % larger than normal)
+ wxWINDOW_VARIANT_MAX
+};
+
// ----------------------------------------------------------------------------
// (pseudo)template list classes
// ----------------------------------------------------------------------------
// creating the window
// -------------------
- // default ctor
- wxWindowBase() { InitBase(); }
+ // default ctor, initializes everything which can be initialized before
+ // Create()
+ wxWindowBase() ;
// pseudo ctor (can't be virtual, called from ctor)
bool CreateBase(wxWindowBase *parent,
virtual void SetName( const wxString &name ) { m_windowName = name; }
virtual wxString GetName() const { return m_windowName; }
+ // 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"
void SetId( wxWindowID winid ) { m_windowId = winid; }
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 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; }
// colours, fonts and cursors
// --------------------------
+ // get the default attributes for the controls of this class: we
+ // provide a virtual function which can be used to query the default
+ // attributes of an existing control and a static function which can
+ // be used even when no existing object of the given class is
+ // available, but which won't return any styles specific to this
+ // particular control, of course (e.g. "Ok" button might have
+ // different -- bold for example -- font)
+ virtual wxVisualAttributes GetDefaultAttributes() const
+ {
+ return GetClassDefaultAttributes(GetWindowVariant());
+ }
+
+ static wxVisualAttributes
+ 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 );
- wxColour GetBackgroundColour() const { return m_backgroundColour; }
- wxColour GetForegroundColour() const { return m_foregroundColour; }
+ wxColour GetBackgroundColour() const;
+ wxColour GetForegroundColour() const;
// set/retrieve the cursor for this window (SetCursor() returns true
// if the cursor was really changed)
// 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 m_font; }
- wxFont& GetFont() { return m_font; }
+ const wxFont& GetFont() const { return DoGetFont(); }
+ wxFont& GetFont() { return DoGetFont(); }
#if wxUSE_CARET
// associate a caret with the window
// visual window attributes
wxCursor m_cursor;
- wxFont m_font;
- wxColour m_backgroundColour, m_foregroundColour;
+ wxFont m_font; // see m_hasFont
+ wxColour m_backgroundColour, // m_hasBgCol
+ m_foregroundColour; // m_hasFgCol
#if wxUSE_CARET
wxCaret *m_caret;
int m_minVirtualHeight;
int m_maxVirtualWidth;
int m_maxVirtualHeight;
-
- // common part of all ctors: it is not virtual because it is called from
- // ctor
- void InitBase();
+
+ wxWindowVariant m_windowVariant ;
// override this to change the default (i.e. used when no style is
// specified) border for the window class
virtual wxBorder GetDefaultBorder() const;
- // get the default size for the new window if no explicit size given
- // FIXME why 20 and not 30, 10 or ...?
+ // Get the default size for the new window if no explicit size given. TLWs
+ // have their own default size so this is just for non top-level windows.
static int WidthDefault(int w) { return w == -1 ? 20 : w; }
static int HeightDefault(int h) { return h == -1 ? 20 : h; }
virtual bool DoPopupMenu( wxMenu *menu, int x, int y ) = 0;
#endif // wxUSE_MENUS
- // Makes an adjustment to the window position (for example, a frame that has
- // a toolbar that it manages itself).
- virtual void AdjustForParentClientOrigin(int& x, int& y, int sizeFlags) const;
+ // Makes an adjustment to the window position to make it relative to the
+ // parents client area, e.g. if the parent is a frame with a toolbar, its
+ // (0, 0) is just below the toolbar
+ virtual void AdjustForParentClientOrigin(int& x, int& y,
+ int sizeFlags = 0) const;
+ // implements the window variants
+ virtual void DoSetWindowVariant( wxWindowVariant variant ) ;
private:
-
// contains the last id generated by NewControlId
static int ms_lastControlId;
// the stack of windows which have captured the mouse
static struct WXDLLEXPORT wxWindowNext *ms_winCaptureNext;
+ // implementation of both const and non-const versions of GetFont()
+ wxFont& DoGetFont() const;
+
+
DECLARE_ABSTRACT_CLASS(wxWindowBase)
DECLARE_NO_COPY_CLASS(wxWindowBase)
DECLARE_EVENT_TABLE()
#define wxWindowNative wxWindowMSW
#else // !wxUniv
#define wxWindowMSW wxWindow
- #define sm_classwxWindowMSW sm_classwxWindow
- #define sm_constructorPropertiesCountwxWindowMSW sm_constructorPropertiesCountwxWindow
- #define sm_constructorPropertieswxWindowMSW sm_constructorPropertieswxWindow
- #define sm_constructorwxWindowMSW sm_constructorwxWindow
#endif // wxUniv/!wxUniv
#include "wx/msw/window.h"
#elif defined(__WXMOTIF__)
#define wxWindowNative wxWindowGTK
#else // !wxUniv
#define wxWindowGTK wxWindow
- #define sm_classwxWindowGTK sm_classwxWindow
#endif // wxUniv
#include "wx/gtk/window.h"
#elif defined(__WXX11__)
#define wxWindowNative wxWindowX11
#else // !wxUniv
#define wxWindowX11 wxWindow
- #define sm_classwxWindowX11 sm_classwxWindow
#endif // wxUniv
#include "wx/x11/window.h"
#elif defined(__WXMGL__)
#define wxWindowNative wxWindowMGL
#else // !wxUniv
#define wxWindowMGL wxWindow
- #define sm_classwxWindowMGL sm_classwxWindow
#endif // wxUniv
#include "wx/mgl/window.h"
#elif defined(__WXMAC__)
#define wxWindowNative wxWindowMac
#else // !wxUniv
#define wxWindowMac wxWindow
- #define sm_classwxWindowMac sm_classwxWindow
#endif // wxUniv
#include "wx/mac/window.h"
#elif defined(__WXCOCOA__)
#define wxWindowNative wxWindowCocoa
#else // !wxUniv
#define wxWindowCocoa wxWindow
- #define sm_classwxWindowCocoa sm_classwxWindow
#endif // wxUniv
#include "wx/cocoa/window.h"
#elif defined(__WXPM__)
#define wxWindowNative wxWindowOS2
#else // !wxUniv
#define wxWindowOS2 wxWindow
- #define sm_classwxWindowOS2 sm_classwxWindow
#endif // wxUniv/!wxUniv
#include "wx/os2/window.h"
#endif