make wxWindow::SetAutoLayout() now works for all windows, not just panels

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@60722 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2009-05-23 11:26:58 +00:00
parent 112d941fe1
commit 6528a7f145
7 changed files with 28 additions and 55 deletions

View File

@@ -333,6 +333,7 @@ All:
All (GUI): All (GUI):
- wxWindow::SetAutoLayout() now works for all windows, not just panels.
- Support loading wxListCtrl items and image lists from XRC (Kinaou Herv<72>). - Support loading wxListCtrl items and image lists from XRC (Kinaou Herv<72>).
- wxGrid: add possibility to prevent resizing of individual rows/columns. - wxGrid: add possibility to prevent resizing of individual rows/columns.
- wxHTML: add support for table borders width (Laurent Humbertclaude). - wxHTML: add support for table borders width (Laurent Humbertclaude).

View File

@@ -70,9 +70,6 @@ public:
// implementation from now on // implementation from now on
// -------------------------- // --------------------------
// calls layout for layout constraints and sizers
void OnSize(wxSizeEvent& event);
virtual void InitDialog(); virtual void InitDialog();
#ifdef __WXUNIVERSAL__ #ifdef __WXUNIVERSAL__

View File

@@ -1694,6 +1694,11 @@ private:
int DoGetPopupMenuSelectionFromUser(wxMenu& menu, int x, int y); int DoGetPopupMenuSelectionFromUser(wxMenu& menu, int x, int y);
#endif // wxUSE_MENUS #endif // wxUSE_MENUS
// layout the window children when its size changes unless this was
// explicitly disabled with SetAutoLayout(false)
void InternalOnSize(wxSizeEvent& event);
// the stack of windows which have captured the mouse // the stack of windows which have captured the mouse
static struct WXDLLIMPEXP_FWD_CORE wxWindowNext *ms_winCaptureNext; static struct WXDLLIMPEXP_FWD_CORE wxWindowNext *ms_winCaptureNext;

View File

@@ -2600,19 +2600,23 @@ public:
/** /**
Sets the window to have the given layout sizer. Sets the window to have the given layout sizer.
The window will then own the object, and will take care of its deletion. The window will then own the object, and will take care of its deletion.
If an existing layout constraints object is already owned by the If an existing layout constraints object is already owned by the
window, it will be deleted if the deleteOld parameter is @true. window, it will be deleted if the @a deleteOld parameter is @true.
Note that this function will also call SetAutoLayout() implicitly with @true Note that this function will also call SetAutoLayout() implicitly with @true
parameter if the @a sizer is non-@NULL and @false otherwise. parameter if the @a sizer is non-@NULL and @false otherwise so that the
sizer will be effectively used to layout the window children whenever
it is resized.
@param sizer @param sizer
The sizer to set. Pass @NULL to disassociate and conditionally delete The sizer to set. Pass @NULL to disassociate and conditionally delete
the window's sizer. See below. the window's sizer. See below.
@param deleteOld @param deleteOld
If @true (the default), this will delete any pre-existing sizer. If @true (the default), this will delete any pre-existing sizer.
Pass @false if you wish to handle deleting the old sizer yourself. Pass @false if you wish to handle deleting the old sizer yourself
but remember to do it yourself in this case to avoid memory leaks.
@remarks SetSizer enables and disables Layout automatically. @remarks SetSizer enables and disables Layout automatically.
*/ */
@@ -2665,20 +2669,17 @@ public:
/** /**
Determines whether the Layout() function will be called automatically Determines whether the Layout() function will be called automatically
when the window is resized. Please note that this only happens for the when the window is resized.
windows usually used to contain children, namely wxPanel and wxTopLevelWindow
(and the classes deriving from them).
This method is called implicitly by SetSizer() but if you use SetConstraints() This method is called implicitly by SetSizer() but if you use SetConstraints()
you should call it manually or otherwise the window layout won't be correctly you should call it manually or otherwise the window layout won't be correctly
updated when its size changes. updated when its size changes.
@param autoLayout @param autoLayout
Set this to @true if you wish the Layout() function to be Set this to @true if you wish the Layout() function to be called
called automatically when the window is resized automatically when the window is resized.
(really happens only if you derive from wxPanel or wxTopLevelWindow).
@see SetConstraints() @see SetSizer(), SetConstraints()
*/ */
void SetAutoLayout(bool autoLayout); void SetAutoLayout(bool autoLayout);

View File

@@ -102,6 +102,7 @@ BEGIN_EVENT_TABLE(wxWindowBase, wxEvtHandler)
EVT_HELP(wxID_ANY, wxWindowBase::OnHelp) EVT_HELP(wxID_ANY, wxWindowBase::OnHelp)
#endif // wxUSE_HELP #endif // wxUSE_HELP
EVT_SIZE(wxWindowBase::InternalOnSize)
END_EVENT_TABLE() END_EVENT_TABLE()
// ============================================================================ // ============================================================================
@@ -2095,6 +2096,14 @@ bool wxWindowBase::Layout()
return true; return true;
} }
void wxWindowBase::InternalOnSize(wxSizeEvent& event)
{
if ( GetAutoLayout() )
Layout();
event.Skip();
}
#if wxUSE_CONSTRAINTS #if wxUSE_CONSTRAINTS
// first phase of the constraints evaluation: set our own constraints // first phase of the constraints evaluation: set our own constraints

View File

@@ -88,8 +88,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxPanel, wxWindow)
#endif #endif
BEGIN_EVENT_TABLE(wxPanel, wxWindow) BEGIN_EVENT_TABLE(wxPanel, wxWindow)
EVT_SIZE(wxPanel::OnSize)
WX_EVENT_TABLE_CONTROL_CONTAINER(wxPanel) WX_EVENT_TABLE_CONTROL_CONTAINER(wxPanel)
END_EVENT_TABLE() END_EVENT_TABLE()
@@ -139,42 +137,3 @@ void wxPanel::InitDialog()
GetEventHandler()->ProcessEvent(event); GetEventHandler()->ProcessEvent(event);
} }
// ----------------------------------------------------------------------------
// event handlers
// ----------------------------------------------------------------------------
void wxPanel::OnSize(wxSizeEvent& event)
{
if (GetAutoLayout())
Layout();
#if wxUSE_CONSTRAINTS
#if defined(__WXPM__) && 0
else
{
// Need to properly move child windows under OS/2
PSWP pWinSwp = GetSwp();
if (pWinSwp->cx == 0 && pWinSwp->cy == 0 && pWinSwp->fl == 0)
{
// Uninitialized
::WinQueryWindowPos(GetHWND(), pWinSwp);
}
else
{
SWP vSwp;
int nYDiff;
::WinQueryWindowPos(GetHWND(), &vSwp);
nYDiff = pWinSwp->cy - vSwp.cy;
MoveChildren(nYDiff);
pWinSwp->cx = vSwp.cx;
pWinSwp->cy = vSwp.cy;
}
}
#endif
#endif // wxUSE_CONSTRAINTS
event.Skip();
}

View File

@@ -1103,9 +1103,10 @@ void wxHtmlWindow::OnPaint(wxPaintEvent& WXUNUSED(event))
void wxHtmlWindow::OnSize(wxSizeEvent& event) void wxHtmlWindow::OnSize(wxSizeEvent& event)
{ {
event.Skip();
wxDELETE(m_backBuffer); wxDELETE(m_backBuffer);
wxScrolledWindow::OnSize(event);
CreateLayout(); CreateLayout();
// Recompute selection if necessary: // Recompute selection if necessary: