// 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"
// 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
// some like scrolled windows it is more or less independent of
// not all windows/controls can do this without looking wrong.
virtual void ApplyParentThemeBackground(const wxColour& WXUNUSED(bg))
{ /* do nothing */ }
-
+
// focus and keyboard handling
// ---------------------------
wxAccessible* m_accessible;
#endif
- // Initial window size, used as minimal size in Sizers
- wxSize m_initialSize;
-
// 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);
// more pure virtual functions
// ---------------------------
m_parent = (wxWindow *)NULL;
m_windowId = wxID_ANY;
- m_initialSize = wxDefaultSize;
-
// no constraints on the minimal window size
m_minWidth =
m_minHeight =
bool wxWindowBase::CreateBase(wxWindowBase *parent,
wxWindowID id,
const wxPoint& WXUNUSED(pos),
- const wxSize& size,
+ const wxSize& WXUNUSED(size),
long style,
const wxValidator& wxVALIDATOR_PARAM(validator),
const wxString& name)
SetWindowStyleFlag(style);
SetParent(parent);
- // Save the size passed to the ctor (if any.) This will be used later as
- // the minimal size if the window is added to a sizer.
- m_initialSize = size;
-
#if wxUSE_VALIDATORS
SetValidator(validator);
#endif // wxUSE_VALIDATORS
}
}
+void wxWindowBase::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);
+
+ // don't shrink the control below its best size
+ m_minWidth = sizeBest.x;
+ m_minHeight = sizeBest.y;
+ }
+}
+
// by default the origin is not shifted
wxPoint wxWindowBase::GetClientAreaOrigin() const
{
sizer->SetSizeHints( (wxWindow*) this );
}
-
+
void wxWindowBase::SetContainingSizer(wxSizer* sizer)
{
// adding a window to a sizer twice is going to result in fatal and
// 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;
- // If there was an initial size for this window, and if a minsize has not
- // been set, then set the initial size as the minsize. This helps with
- // sizer layout when a larger than GetBestSize size is needed for
- // controls.
- if (m_initialSize != wxDefaultSize && GetMinSize() == wxDefaultSize)
- SetSizeHints(m_initialSize);
+ m_containingSizer = sizer;
}
-
+
#if wxUSE_CONSTRAINTS
void wxWindowBase::SatisfyConstraints()