]> git.saurik.com Git - wxWidgets.git/commitdiff
Add possibility to use sizers in ribbon panel, fixes #12404: wxRibbonPanel and wxSizer
authorRobert Roebling <robert@roebling.de>
Sun, 29 Aug 2010 09:42:55 +0000 (09:42 +0000)
committerRobert Roebling <robert@roebling.de>
Sun, 29 Aug 2010 09:42:55 +0000 (09:42 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65436 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/ribbon/ribbondemo.cpp
src/ribbon/panel.cpp

index aac6468f4a38486c0d1b8ff1240a22f208ba4d11..126c75b51378a35037dd6db713331d7a271189fd 100644 (file)
@@ -27,6 +27,8 @@
 #include "wx/dcbuffer.h"
 #include "wx/colordlg.h"
 #include "wx/artprov.h"
+#include "wx/combobox.h"
+#include "wx/wrapsizer.h"
 
 // -- application --
 
@@ -247,9 +249,26 @@ MyFrame::MyFrame()
         shapes->AddButton(ID_SQUARE, wxT("Square"), wxBitmap(square_xpm), wxEmptyString);
         shapes->AddDropdownButton(ID_POLYGON, wxT("Other Polygon"), wxBitmap(hexagon_xpm), wxEmptyString);
 
-        new wxRibbonPanel(home, wxID_ANY, wxT("Another Panel"), wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxRIBBON_PANEL_EXT_BUTTON);
-    }
-    {
+        wxRibbonPanel *sizer_panel = new wxRibbonPanel(home, wxID_ANY, wxT("Panel with Sizer"), 
+                                        wxNullBitmap, wxDefaultPosition, wxDefaultSize, 
+                                        wxRIBBON_PANEL_EXT_BUTTON);
+
+        wxArrayString as;
+        as.Add("Item 1");
+        as.Add("Item 2");
+        wxComboBox* sizer_panelcombo = new wxComboBox(sizer_panel, wxID_ANY, wxEmptyString, 
+                             wxDefaultPosition, wxDefaultSize, as, wxCB_READONLY);
+        wxComboBox* sizer_panelcombo2 = new wxComboBox(sizer_panel, wxID_ANY, wxEmptyString, 
+                             wxDefaultPosition, wxDefaultSize, as, wxCB_READONLY);
+    
+        sizer_panelcombo->SetMinSize(wxSize(150, -1));
+        sizer_panelcombo2->SetMinSize(wxSize(150, -1));
+
+        wxSizer* sizer_panelsizer = new wxWrapSizer(wxHORIZONTAL);
+        sizer_panelsizer->Add(sizer_panelcombo, 2, wxALL|wxEXPAND, 2);
+        sizer_panelsizer->Add(sizer_panelcombo2, 2, wxALL|wxEXPAND, 2);
+        sizer_panel->SetSizer(sizer_panelsizer);
+
         wxFont label_font(8, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_LIGHT);
         m_bitmap_creation_dc.SetFont(label_font);
 
index bb6257dfcf27cb7d48be03f6f9a04c176d642a02..512ec8ae3296567f0be0d100251d2857daa27323 100644 (file)
@@ -577,15 +577,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;
-        wxClientDC dc(this);
-        wxSize size = m_art->GetPanelClientSize(dc, this, GetSize(), &position);
         child->SetSize(position.x, position.y, size.GetWidth(), size.GetHeight());
     }
     return true;