]> git.saurik.com Git - wxWidgets.git/blobdiff - src/ribbon/panel.cpp
Avoid id clashes
[wxWidgets.git] / src / ribbon / panel.cpp
index 69225d32c92c9713596b60fc5434bdcc667d3bb3..ca0af0601e737c6e437024c19c44aac180676275 100644 (file)
@@ -8,21 +8,24 @@
 // Copyright:   (C) Peter Cawley
 // Licence:     wxWindows licence
 ///////////////////////////////////////////////////////////////////////////////
+
 #include "wx/wxprec.h"
 
 #ifdef __BORLANDC__
     #pragma hdrstop
 #endif
 
+#if wxUSE_RIBBON
+
+#include "wx/ribbon/panel.h"
 #include "wx/ribbon/art.h"
 #include "wx/ribbon/bar.h"
-#include "wx/ribbon/panel.h"
 #include "wx/dcbuffer.h"
 #include "wx/display.h"
-
-#if wxUSE_RIBBON
+#include "wx/sizer.h"
 
 #ifndef WX_PRECOMP
+#include "wx/frame.h"
 #endif
 
 #ifdef __WXMSW__
@@ -41,7 +44,7 @@ BEGIN_EVENT_TABLE(wxRibbonPanel, wxRibbonControl)
     EVT_SIZE(wxRibbonPanel::OnSize)
 END_EVENT_TABLE()
 
-wxRibbonPanel::wxRibbonPanel()
+wxRibbonPanel::wxRibbonPanel() : m_expanded_dummy(NULL), m_expanded_panel(NULL)
 {
 }
 
@@ -245,7 +248,7 @@ void wxRibbonPanel::DoSetSize(int x, int y, int width, int height, int sizeFlags
 
         Refresh();
     }
-    
+
     wxRibbonControl::DoSetSize(x, y, width, height, sizeFlags);
 }
 
@@ -255,7 +258,7 @@ bool wxRibbonPanel::IsMinimised(wxSize at_size) const
         return false;
 
     return (at_size.GetX() <= m_minimised_size.GetX() &&
-        at_size.GetY() <= m_minimised_size.GetY()) || 
+        at_size.GetY() <= m_minimised_size.GetY()) ||
         at_size.GetX() < m_smallest_unminimised_size.GetX() ||
         at_size.GetY() < m_smallest_unminimised_size.GetY();
 }
@@ -308,7 +311,7 @@ wxSize wxRibbonPanel::DoGetNextSmallerSize(wxOrientation direction,
         wxRibbonControl* ribbon_child = wxDynamicCast(child, wxRibbonControl);
         if(m_art != NULL && ribbon_child != NULL)
         {
-            wxMemoryDC dc;
+            wxClientDC dc((wxRibbonPanel*) this);
             wxSize child_relative = m_art->GetPanelClientSize(dc, this, relative_to, NULL);
             wxSize smaller = ribbon_child->GetNextSmallerSize(direction, child_relative);
             if(smaller == child_relative)
@@ -405,7 +408,7 @@ wxSize wxRibbonPanel::DoGetNextLargerSize(wxOrientation direction,
         wxRibbonControl* ribbon_child = wxDynamicCast(child, wxRibbonControl);
         if(ribbon_child != NULL)
         {
-            wxMemoryDC dc;
+            wxClientDC dc((wxRibbonPanel*) this);
             wxSize child_relative = m_art->GetPanelClientSize(dc, this, relative_to, NULL);
             wxSize larger = ribbon_child->GetNextLargerSize(direction, child_relative);
             if(larger == child_relative)
@@ -414,7 +417,7 @@ wxSize wxRibbonPanel::DoGetNextLargerSize(wxOrientation direction,
             }
             else
             {
-                wxMemoryDC dc;
+                wxClientDC dc((wxRibbonPanel*) this);
                 return m_art->GetPanelSize(dc, this, larger, NULL);
             }
         }
@@ -471,7 +474,7 @@ wxSize wxRibbonPanel::GetMinNotMinimisedSize() const
     if(GetChildren().GetCount() == 1)
     {
         wxWindow* child = GetChildren().Item(0)->GetData();
-        wxMemoryDC dc;
+        wxClientDC dc((wxRibbonPanel*) this);
         return m_art->GetPanelSize(dc, this, child->GetMinSize(), NULL);
     }
 
@@ -486,7 +489,7 @@ wxSize wxRibbonPanel::DoGetBestSize() const
     if(GetChildren().GetCount() == 1)
     {
         wxWindow* child = GetChildren().Item(0)->GetData();
-        wxMemoryDC dc;
+        wxClientDC dc((wxRibbonPanel*) this);
         return m_art->GetPanelSize(dc, this, child->GetBestSize(), NULL);
     }
 
@@ -521,7 +524,7 @@ bool wxRibbonPanel::Realize()
 
     if(m_art != NULL)
     {
-        wxMemoryDC temp_dc;
+        wxClientDC temp_dc(this);
 
         m_smallest_unminimised_size =
             m_art->GetPanelSize(temp_dc, this, minimum_children_size, NULL);
@@ -575,15 +578,20 @@ bool wxRibbonPanel::Layout()
         return true;
     }
 
-    // TODO: Delegate to a sizer
+    // Get wxRibbonPanel client size
+    wxPoint position;
+    wxClientDC dc(this);
+    wxSize size = m_art->GetPanelClientSize(dc, this, GetSize(), &position);
 
-    // Common case of no sizer and single child taking up the entire panel
-    if(GetChildren().GetCount() == 1)
+    // If there is a sizer, use it instead
+    if ( GetSizer() )
+    {
+        GetSizer()->SetDimension(position.x, position.y, size.GetWidth(), size.GetHeight());
+    }
+    else if(GetChildren().GetCount() == 1)
     {
+        // Common case of no sizer and single child taking up the entire panel
         wxWindow* child = GetChildren().Item(0)->GetData();
-        wxPoint position;
-        wxMemoryDC dc;
-        wxSize size = m_art->GetPanelClientSize(dc, this, GetSize(), &position);
         child->SetSize(position.x, position.y, size.GetWidth(), size.GetHeight());
     }
     return true;