]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/sizer.cpp
fixing pattern phase bugs
[wxWidgets.git] / src / common / sizer.cpp
index d645137e7c3b6220a5c52100cd2eff2b9da189c6..3429e7b01f2205751fd54b25bba9f55a55536029 100644 (file)
@@ -25,7 +25,9 @@
     #include "wx/math.h"
     #include "wx/utils.h"
     #include "wx/settings.h"
     #include "wx/math.h"
     #include "wx/utils.h"
     #include "wx/settings.h"
+    #include "wx/button.h"
     #include "wx/statbox.h"
     #include "wx/statbox.h"
+    #include "wx/toplevel.h"
 #endif // WX_PRECOMP
 
 #include "wx/listimpl.cpp"
 #endif // WX_PRECOMP
 
 #include "wx/listimpl.cpp"
@@ -274,7 +276,7 @@ wxSize wxSizerItem::CalcMin()
     {
         // Since the size of the window may change during runtime, we
         // should use the current minimal/best size.
     {
         // Since the size of the window may change during runtime, we
         // should use the current minimal/best size.
-        m_minSize = m_window->GetBestFittingSize();
+        m_minSize = m_window->GetEffectiveMinSize();
     }
 
     return GetMinSizeWithBorder();
     }
 
     return GetMinSizeWithBorder();
@@ -352,6 +354,11 @@ void wxSizerItem::SetDimension( const wxPoint& pos_, const wxSize& size_ )
         size.y -= m_border;
     }
 
         size.y -= m_border;
     }
 
+    if (size.x < 0)
+        size.x = 0;
+    if (size.y < 0)
+        size.y = 0;
+
     m_rect = wxRect(pos, size);
 
     switch ( m_kind )
     m_rect = wxRect(pos, size);
 
     switch ( m_kind )
@@ -506,6 +513,29 @@ wxSizerItem* wxSizer::Insert( size_t index, wxSizerItem *item )
     return item;
 }
 
     return item;
 }
 
+void wxSizer::SetContainingWindow(wxWindow *win)
+{
+    if ( win == m_containingWindow )
+        return;
+
+    m_containingWindow = win;
+
+    // set the same window for all nested sizers as well, they also are in the
+    // same window
+    for ( wxSizerItemList::compatibility_iterator node = m_children.GetFirst();
+          node;
+          node = node->GetNext() )
+    {
+        wxSizerItem *const item = node->GetData();
+        wxSizer *const sizer = item->GetSizer();
+
+        if ( sizer )
+        {
+            sizer->SetContainingWindow(win);
+        }
+    }
+}
+
 #if WXWIN_COMPATIBILITY_2_6
 bool wxSizer::Remove( wxWindow *window )
 {
 #if WXWIN_COMPATIBILITY_2_6
 bool wxSizer::Remove( wxWindow *window )
 {
@@ -643,7 +673,7 @@ bool wxSizer::Replace( wxWindow *oldwin, wxWindow *newwin, bool recursive )
             if (item->GetSizer()->Replace( oldwin, newwin, true ))
                 return true;
         }
             if (item->GetSizer()->Replace( oldwin, newwin, true ))
                 return true;
         }
-        
+
         node = node->GetNext();
     }
 
         node = node->GetNext();
     }
 
@@ -671,8 +701,8 @@ bool wxSizer::Replace( wxSizer *oldsz, wxSizer *newsz, bool recursive )
         {
             if (item->GetSizer()->Replace( oldsz, newsz, true ))
                 return true;
         {
             if (item->GetSizer()->Replace( oldsz, newsz, true ))
                 return true;
-        }        
-        
+        }
+
         node = node->GetNext();
     }
 
         node = node->GetNext();
     }
 
@@ -690,7 +720,7 @@ bool wxSizer::Replace( size_t old, wxSizerItem *newitem )
 
     wxSizerItem *item = node->GetData();
     node->SetData(newitem);
 
     wxSizerItem *item = node->GetData();
     node->SetData(newitem);
-    delete item;    
+    delete item;
 
     return true;
 }
 
     return true;
 }
@@ -1671,6 +1701,16 @@ void wxBoxSizer::RecalcSizes()
                 //     wxALIGN_CENTER should be used in new code
                     child_pos.y += (m_size.y - size.y) / 2;
 
                 //     wxALIGN_CENTER should be used in new code
                     child_pos.y += (m_size.y - size.y) / 2;
 
+                if ( m_containingWindow )
+                {
+                    child_pos.x = m_containingWindow->AdjustForLayoutDirection
+                                                      (
+                                                        child_pos.x,
+                                                        width,
+                                                        m_size.x
+                                                      );
+                }
+
                 item->SetDimension( child_pos, child_size );
 
                 pt.x += width;
                 item->SetDimension( child_pos, child_size );
 
                 pt.x += width;