]> git.saurik.com Git - wxWidgets.git/commitdiff
make wxWindow::SetAutoLayout() now works for all windows, not just panels
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 23 May 2009 11:26:58 +0000 (11:26 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 23 May 2009 11:26:58 +0000 (11:26 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@60722 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
include/wx/generic/panelg.h
include/wx/window.h
interface/wx/window.h
src/common/wincmn.cpp
src/generic/panelg.cpp
src/html/htmlwin.cpp

index 9ffd122ebf3c26a7f5aa811227a93c3827a78280..2772b268103c43e943d70311a30cee50605e65bd 100644 (file)
@@ -333,6 +333,7 @@ All:
 
 All (GUI):
 
+- wxWindow::SetAutoLayout() now works for all windows, not just panels.
 - Support loading wxListCtrl items and image lists from XRC (Kinaou HervĂ©).
 - wxGrid: add possibility to prevent resizing of individual rows/columns.
 - wxHTML: add support for table borders width (Laurent Humbertclaude).
index 8d5475a46dc883f296b1b2cbcb7ea4c1a3071c42..5824c0efc43890083e62523cdcd72b0d016255e7 100644 (file)
@@ -70,9 +70,6 @@ public:
     // implementation from now on
     // --------------------------
 
-        // calls layout for layout constraints and sizers
-    void OnSize(wxSizeEvent& event);
-
     virtual void InitDialog();
 
 #ifdef __WXUNIVERSAL__
index c9243e702779464d50c69fe4e93f1e41bebde7c4..7e2470214ae92c8aa029d9d766dc6e92de807fa7 100644 (file)
@@ -1694,6 +1694,11 @@ private:
     int DoGetPopupMenuSelectionFromUser(wxMenu& menu, int x, int y);
 #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
     static struct WXDLLIMPEXP_FWD_CORE wxWindowNext *ms_winCaptureNext;
 
index 6eb30c66bb72a1fe20f01aababa7efaf0f40e367..4835c550b8a720608b2ceb76051aa64bbacc9476 100644 (file)
@@ -2600,19 +2600,23 @@ public:
 
     /**
         Sets the window to have the given layout sizer.
+
         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
-        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
-        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
             The sizer to set. Pass @NULL to disassociate and conditionally delete
             the window's sizer. See below.
         @param deleteOld
             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.
     */
@@ -2665,20 +2669,17 @@ public:
 
     /**
         Determines whether the Layout() function will be called automatically
-        when the window is resized. Please note that this only happens for the
-        windows usually used to contain children, namely wxPanel and wxTopLevelWindow
-        (and the classes deriving from them).
+        when the window is resized.
 
         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
         updated when its size changes.
 
         @param autoLayout
-            Set this to @true if you wish the Layout() function to be
-            called automatically when the window is resized
-            (really happens only if you derive from wxPanel or wxTopLevelWindow).
+            Set this to @true if you wish the Layout() function to be called
+            automatically when the window is resized.
 
-        @see SetConstraints()
+        @see SetSizer(), SetConstraints()
     */
     void SetAutoLayout(bool autoLayout);
 
index cd95242587354080dd9d62638486394fa2bc07d0..8d3fa0af2cfa6ad9782857944ef0b99a0d633cf3 100644 (file)
@@ -102,6 +102,7 @@ BEGIN_EVENT_TABLE(wxWindowBase, wxEvtHandler)
     EVT_HELP(wxID_ANY, wxWindowBase::OnHelp)
 #endif // wxUSE_HELP
 
+    EVT_SIZE(wxWindowBase::InternalOnSize)
 END_EVENT_TABLE()
 
 // ============================================================================
@@ -2095,6 +2096,14 @@ bool wxWindowBase::Layout()
     return true;
 }
 
+void wxWindowBase::InternalOnSize(wxSizeEvent& event)
+{
+    if ( GetAutoLayout() )
+        Layout();
+
+    event.Skip();
+}
+
 #if wxUSE_CONSTRAINTS
 
 // first phase of the constraints evaluation: set our own constraints
index d714bce3c08935bc3602c6f9453b590ea8e3adb7..3bff49d8d709497c2e080076093fe53dd74b827f 100644 (file)
@@ -88,8 +88,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxPanel, wxWindow)
 #endif
 
 BEGIN_EVENT_TABLE(wxPanel, wxWindow)
-    EVT_SIZE(wxPanel::OnSize)
-
     WX_EVENT_TABLE_CONTROL_CONTAINER(wxPanel)
 END_EVENT_TABLE()
 
@@ -139,42 +137,3 @@ void wxPanel::InitDialog()
     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();
-}
index 56c6f5d7b7f5becfd1a6557b6567461ec4771489..82f7c105579ab0396298deb2afc39e0bf550a927 100644 (file)
@@ -1103,9 +1103,10 @@ void wxHtmlWindow::OnPaint(wxPaintEvent& WXUNUSED(event))
 
 void wxHtmlWindow::OnSize(wxSizeEvent& event)
 {
+    event.Skip();
+
     wxDELETE(m_backBuffer);
 
-    wxScrolledWindow::OnSize(event);
     CreateLayout();
 
     // Recompute selection if necessary: