X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1777b9bbf4573dabecf4a3256d0d3c2c0c2a3fdf..a05da1b6827f40c0beb97225e9861356343e196b:/include/wx/window.h diff --git a/include/wx/window.h b/include/wx/window.h index 5ae7d448c9..f78da2dbfc 100644 --- a/include/wx/window.h +++ b/include/wx/window.h @@ -28,6 +28,7 @@ #include "wx/font.h" // so we can't do without them #include "wx/colour.h" #include "wx/region.h" +#include "wx/utils.h" #if wxUSE_VALIDATORS #include "wx/validate.h" // defines wxDefaultValidator @@ -120,6 +121,7 @@ public: const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, + #if wxUSE_VALIDATORS const wxValidator& validator = wxDefaultValidator, #endif // wxUSE_VALIDATORS @@ -262,6 +264,18 @@ public: return wxSize(w, h); } + // get the size best suited for the window (in fact, minimal + // acceptable size using which it will still look "nice") + wxSize GetBestSize() const { return DoGetBestSize(); } + void GetBestSize(int *w, int *h) const + { + wxSize s = DoGetBestSize(); + if ( w ) + *w = s.x; + if ( h ) + *h = s.y; + } + // centre with respect to the the parent window void Centre( int direction = wxBOTH ); void Center( int direction = wxBOTH ) { Centre(direction); } @@ -276,6 +290,11 @@ public: int maxW = -1, int maxH = -1, int incW = -1, int incH = -1 ); + int GetMinWidth() const { return m_minWidth; } + int GetMinHeight() const { return m_minHeight; } + int GetMaxWidth() const { return m_maxWidth; } + int GetMaxHeight() const { return m_maxHeight; } + // window state // ------------ @@ -332,7 +351,7 @@ public: inline wxWindow *GetGrandParent() const; // is this window a top level one? - bool IsTopLevel() const; + virtual bool IsTopLevel() const; // it doesn't really change parent, use ReParent() instead void SetParent( wxWindowBase *parent ) { m_parent = (wxWindow *)parent; } @@ -606,7 +625,6 @@ public: virtual bool DoPhase(int); // these methods are virtual but normally won't be overridden - virtual void TransformSizerToActual(int *x, int *y) const ; virtual void SetSizeConstraint(int x, int y, int w, int h); virtual void MoveConstraint(int x, int y); virtual void GetSizeConstraint(int *w, int *h) const ; @@ -617,12 +635,6 @@ public: // TODO: what are they and how do they work?? void SetSizer( wxSizer *sizer ); wxSizer *GetSizer() const { return m_windowSizer; } - - void SetSizerParent( wxWindowBase *win ) { m_sizerParent = win; } - wxWindowBase *GetSizerParent() const { return m_sizerParent; } - - virtual void SizerSetSize(int x, int y, int w, int h); - virtual void SizerMove(int x, int y); #endif // wxUSE_CONSTRAINTS // backward compatibility @@ -745,6 +757,26 @@ protected: static int WidthDefault(int w) { return w == -1 ? 20 : w; } static int HeightDefault(int h) { return h == -1 ? 20 : h; } + // sets the size to be size but take width and/or height from + // DoGetBestSize() if width/height of size is -1 + // + // NB: when calling this function from the ctor, the DoGetBestSize() of + // the class with the same name as the ctor, not the real (most + // derived) one - but this is what we usually want + void SetSizeOrDefault(const wxSize& size = wxDefaultSize) + { + if ( size.x == -1 || size.y == -1 ) + { + wxSize sizeDef = GetBestSize(); + SetSize( size.x == -1 ? sizeDef.x : size.x, + size.y == -1 ? sizeDef.y : size.y); + } + else + { + SetSize(size); + } + } + // more pure virtual functions // --------------------------- @@ -766,6 +798,11 @@ protected: virtual void DoGetSize( int *width, int *height ) const = 0; virtual void DoGetClientSize( int *width, int *height ) const = 0; + // get the size which best suits the window: for a control, it would be + // the minimal size which doesn't truncate the control, for a panel - the + // same size as it would have after a call to Fit() + virtual wxSize DoGetBestSize() const; + // this is the virtual function to be overriden in any derived class which // wants to change how SetSize() or Move() works - it is called by all // versions of these functions in the base class @@ -838,6 +875,8 @@ inline wxWindow *wxWindowBase::GetGrandParent() const // ---------------------------------------------------------------------------- WXDLLEXPORT extern wxWindow* wxGetActiveWindow(); + +// deprecated (doesn't start with 'wx' prefix), use wxWindow::NewControlId() inline WXDLLEXPORT int NewControlId() { return wxWindowBase::NewControlId(); } #endif