X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/69d90995bb90845723261e29b3895f3004887881..7b162e540e98415f8ac6bc1fd5b880e143aa85e5:/include/wx/window.h diff --git a/include/wx/window.h b/include/wx/window.h index 795fe59b75..9c3744965e 100644 --- a/include/wx/window.h +++ b/include/wx/window.h @@ -73,6 +73,35 @@ class WXDLLEXPORT wxWindow; 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 // ---------------------------------------------------------------------------- @@ -96,17 +125,6 @@ WXDLLEXPORT_DATA(extern wxWindowList) wxTopLevelWindows; // temporarily switches event handlers). // ---------------------------------------------------------------------------- -// different window variants, on platforms like eg mac uses different rendering sizes - -enum wxWindowVariant -{ - wxWINDOW_VARIANT_DEFAULT, // Default size (usually == normal, may be set by a wxSystemOptions entry) - 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 ) -}; - class WXDLLEXPORT wxWindowBase : public wxEvtHandler { public: @@ -649,13 +667,28 @@ public: // 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) @@ -666,8 +699,8 @@ public: // 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 @@ -980,8 +1013,9 @@ protected: // 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; @@ -1043,6 +1077,9 @@ protected: #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; @@ -1057,11 +1094,10 @@ protected: // specified) border for the window class virtual wxBorder GetDefaultBorder() const; - // Get the default size for the new window if no explicit size given If - // there are better default sizes then these can be changed, just as long - // as they are not too small for TLWs. - static int WidthDefault(int w) { return w == -1 ? 400 : w; } - static int HeightDefault(int h) { return h == -1 ? 250 : h; } + // 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; } // set the best size for the control if the default size was given: // replaces the fields of size == -1 with the best values for them and @@ -1154,13 +1190,16 @@ protected: 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()