]> git.saurik.com Git - wxWidgets.git/commitdiff
Fixed sample; enhanced wxLayoutAlgorithm to give remaining space to
authorJulian Smart <julian@anthemion.co.uk>
Fri, 25 Aug 2000 15:51:23 +0000 (15:51 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Fri, 25 Aug 2000 15:51:23 +0000 (15:51 +0000)
last window

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@8185 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/latex/wx/layalgor.tex
samples/dialogs/dialogs.cpp
src/generic/laywin.cpp

index e4d58e3264a796be864b3fbb1d4cc094ed21749f..76a36feb10fbbff32aed2a1ac59bd783874c1832 100644 (file)
@@ -141,5 +141,8 @@ The MDI client window is set to occupy the remaining space.
 
 Lays out the children of a normal frame or other window.
 
-{\it mainWindow} is set to occupy the remaining space.
+{\it mainWindow} is set to occupy the remaining space. If this is not specified, then
+the last window that responds to a calculate layout event in query mode will get the remaining space
+(that is, a non-query OnCalculateLayout event will not be sent to this window and the window will be set
+to the remaining size).
 
index 8617990daa7796db7b3044d02068f682eb48d381..a33bc636d32e74b983044379c5918d946ddb18b6 100644 (file)
@@ -473,7 +473,7 @@ void MyFrame::ModalDlg(wxCommandEvent& WXUNUSED(event))
 
 void MyFrame::ModelessDlg(wxCommandEvent& event)
 {
-    bool show = GetMenuBar()->IsChecked(event.GetInt());
+    bool show = GetMenuBar()->IsChecked(event.GetId());
 
     if ( show )
     {
index 409814e68277696729d3e672379ee2e85326a5c1..92344499351b6c286c4341aca67d5f30f3b51888 100644 (file)
@@ -249,12 +249,35 @@ bool wxLayoutAlgorithm::LayoutWindow(wxWindow* parent, wxWindow* mainWindow)
     wxCalculateLayoutEvent event;
     event.SetRect(rect);
 
+    // Find the last layout-aware window, so we can make it fill all remaining
+    // space.
+    wxWindow* lastAwareWindow = NULL;
     wxNode* node = parent->GetChildren().First();
     while (node)
     {
         wxWindow* win = (wxWindow*) node->Data();
 
-        if (win != mainWindow)
+        if (win->IsShown())
+        {
+            wxCalculateLayoutEvent tempEvent(win->GetId());
+            tempEvent.SetEventObject(win);
+            tempEvent.SetFlags(wxLAYOUT_QUERY);
+            tempEvent.SetRect(event.GetRect());
+            if (win->GetEventHandler()->ProcessEvent(tempEvent))
+                lastAwareWindow = win;
+        }
+
+        node = node->Next();
+    }
+
+    node = parent->GetChildren().First();
+    while (node)
+    {
+        wxWindow* win = (wxWindow*) node->Data();
+
+        // If mainWindow is NULL and we're at the last window,
+        // skip this, because we'll simply make it fit the remaining space.
+        if ((win != mainWindow) && (mainWindow != NULL || win != lastAwareWindow))
         {
             event.SetId(win->GetId());
             event.SetEventObject(win);
@@ -270,6 +293,11 @@ bool wxLayoutAlgorithm::LayoutWindow(wxWindow* parent, wxWindow* mainWindow)
 
     if (mainWindow)
         mainWindow->SetSize(rect.x, rect.y, rect.width, rect.height);
+    else if (lastAwareWindow)
+    {
+        // Fit the remaining space
+        lastAwareWindow->SetSize(rect.x, rect.y, rect.width, rect.height);
+    }
 
     return TRUE;
 }