Patch #972 2006-03-29 21:41

olorin

Make the toolbars have their "best" size
Download
972-Make_the_toolba.patch (1.1 KB)
Category
Application::Refinement
Status
Accepted
Close date
2006-03-31 09:42
Assigned to
 
Index: main.cpp
===================================================================
--- main.cpp    (revision 2274)
+++ main.cpp    (working copy)
@@ -696,9 +696,10 @@
     wxSize size = m_SmallToolBar ? wxSize(16, 16) : wxSize(22, 22);
     m_pToolbar = new wxToolBar(this, -1, wxDefaultPosition, size, wxTB_FLAT | wxTB_NODIVIDER);
     m_pToolbar->SetToolBitmapSize(size);
+
     Manager::Get()->AddonToolBar(m_pToolbar,xrcToolbarName);
-
     m_pToolbar->Realize();
+    m_pToolbar->SetBestFittingSize();
 
     // add toolbars in docking system
     m_LayoutManager.AddPane(m_pToolbar, wxPaneInfo().
@@ -1007,10 +1008,13 @@
     wxSize size = m_SmallToolBar ? wxSize(16, 16) : wxSize(22, 22);
     wxToolBar* tb = new wxToolBar(this, -1, wxDefaultPosition, size, wxTB_FLAT | wxTB_NODIVIDER);
     tb->SetToolBitmapSize(size);
+
     if (plugin->BuildToolBar(tb))
     {
         SetToolBar(0);
 
+        tb->SetBestFittingSize();
+
         // add View->Toolbars menu item for toolbar
         wxMenu* viewToolbars = 0;
         GetMenuBar()->FindItem(idViewToolMain, &viewToolbars);
olorin 2006-03-29 21:46

After switching to wxWidgets 2.6.3 all my C::B toolbars looked the same size (much higher and wider than necessary, about 790x26 pixels for "small icons" settings, while height should be 22 and width depends on the toolbar itself, but in general is much shorter). This caused also some repaint problems, with areas not being repainted.

This patch should fix this problem.

olorin 2006-03-29 22:16

I don't want to start a void discussion, it's just my curiosity: I saw some duplicated code about toolbar creation. Could the BuildToolbar prototype be changed? My idea would be to pass a bool to specify if small or big icons are used, and thus avoid setting bitmap size, and later retrieving the "flag" by inspecting that size itself. and then add a common function, shared by the main frame and the plugins, that does all the work, taking a pointer to the owner, a xrc basename and a bool for small/big icons as arguments and returning the respective toolbar.

olorin 2006-04-06 21:05

Please apply the patch as it is: for main toolbar

m_pToolbar->SetBestFittingSize();

should follow

m_pToolbar->Realize();

as this last call restores the oversized width. This is the procedure used for the plugins toolbars, which display the right width.