bool wxWindowBase::CreateBase(wxWindowBase *parent,
wxWindowID id,
const wxPoint& WXUNUSED(pos),
- const wxSize& WXUNUSED(size),
+ const wxSize& size,
long style,
- const wxValidator& wxVALIDATOR_PARAM(validator),
const wxString& name)
{
// ids are limited to 16 bits under MSW so if you care about portability,
// flags by updating the window dynamically and we don't need this here
m_windowStyle = style;
+ // assume the user doesn't want this window to shrink beneath its initial
+ // size, this worked like this in wxWidgets 2.8 and before and generally
+ // often makes sense for child windows (for top level ones it definitely
+ // does not as the user should be able to resize the window)
+ //
+ // note that we can't use IsTopLevel() from ctor
+ if ( !wxTopLevelWindows.Find((wxWindow *)this) )
+ SetMinSize(size);
+
SetName(name);
SetParent(parent);
+ return true;
+}
+
+bool wxWindowBase::CreateBase(wxWindowBase *parent,
+ wxWindowID id,
+ const wxPoint& pos,
+ const wxSize& size,
+ long style,
+ const wxValidator& wxVALIDATOR_PARAM(validator),
+ const wxString& name)
+{
+ if ( !CreateBase(parent, id, pos, size, style, name) )
+ return false;
+
#if wxUSE_VALIDATORS
SetValidator(validator);
#endif // wxUSE_VALIDATORS
node = node->GetNext() )
{
wxWindow *win = node->GetData();
- if ( !win->IsTopLevel() && win->IsShown()
+ if ( !win->IsTopLevel() && win->IsShown()
#if wxUSE_SCROLLBAR
&& !win->IsKindOf(CLASSINFO(wxScrollBar))
#endif
}
else // ! has children
{
- // for a generic window there is no natural best size so, if the
- // minimal size is not set, use the current size but take care to
- // remember it as minimal size for the next time because our best size
- // should be constant: otherwise we could get into a situation when the
- // window is initially at some size, then expanded to a larger size and
- // then, when the containing window is shrunk back (because our initial
- // best size had been used for computing the parent min size), we can't
- // be shrunk back any more because our best size is now bigger
wxSize size = GetMinSize();
if ( !size.IsFullySpecified() )
{
- size.SetDefaults(GetSize());
- wxConstCast(this, wxWindowBase)->SetMinSize(size);
+ // if the window doesn't define its best size we assume that it can
+ // be arbitrarily small -- usually this is not the case, of course,
+ // but we have no way to know what the limit is, it should really
+ // override DoGetBestClientSize() itself to tell us
+ size.SetDefaults(wxSize(1, 1));
}
// return as-is, unadjusted by the client size difference.
return min;
}
+wxSize wxWindowBase::DoGetBorderSize() const
+{
+ // there is one case in which we can implement it for all ports easily:
+ // do it as some classes used by both wxUniv and native ports (e.g.
+ // wxGenericStaticText) do override DoGetBestClientSize() and so this
+ // method must work for them and that ensures that it does, at least in
+ // the default case)
+ if ( GetBorder() == wxBORDER_NONE )
+ return wxSize(0, 0);
+
+ wxFAIL_MSG( "must be overridden if called" );
+
+ return wxDefaultSize;
+}
+
wxSize wxWindowBase::GetBestSize() const
{
if ( !m_windowSizer && m_bestSizeCache.IsFullySpecified() )
parent->SendSizeEvent(flags);
}
+bool wxWindowBase::HasScrollbar(int orient) const
+{
+ // if scrolling in the given direction is disabled, we can't have the
+ // corresponding scrollbar no matter what
+ if ( !CanScroll(orient) )
+ return false;
+
+ const wxSize sizeVirt = GetVirtualSize();
+ const wxSize sizeClient = GetClientSize();
+
+ return orient == wxHORIZONTAL ? sizeVirt.x > sizeClient.x
+ : sizeVirt.y > sizeClient.y;
+}
+
// ----------------------------------------------------------------------------
// show/hide/enable/disable the window
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// propagate the colour change event to the subwindows
-void wxWindowBase::OnSysColourChanged(wxSysColourChangedEvent& event)
+void wxWindowBase::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(event))
{
wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
while ( node )
if ( !win->IsTopLevel() )
{
wxSysColourChangedEvent event2;
- event.SetEventObject(win);
+ event2.SetEventObject(win);
win->GetEventHandler()->ProcessEvent(event2);
}
#endif // wxUSE_MENUS
-// methods for drawing the sizers in a visible way
-#ifdef __WXDEBUG__
+// methods for drawing the sizers in a visible way: this is currently only
+// enabled for "full debug" builds with wxDEBUG_LEVEL==2 as it doesn't work
+// that well and also because we don't want to leave it enabled in default
+// builds used for production
+#if wxDEBUG_LEVEL > 1
static void DrawSizers(wxWindowBase *win);
}
}
-#endif // __WXDEBUG__
+#endif // wxDEBUG_LEVEL
// process special middle clicks
void wxWindowBase::OnMiddleClick( wxMouseEvent& event )
{
if ( event.ControlDown() && event.AltDown() )
{
-#ifdef __WXDEBUG__
+#if wxDEBUG_LEVEL > 1
// Ctrl-Alt-Shift-mclick makes the sizers visible in debug builds
if ( event.ShiftDown() )
{
DrawSizers(this);
- return;
}
+ else
#endif // __WXDEBUG__
- ::wxInfoMessageBox((wxWindow*)this);
+ {
+ // just Ctrl-Alt-middle click shows information about wx version
+ ::wxInfoMessageBox((wxWindow*)this);
+ }
}
else
{