]> git.saurik.com Git - wxWidgets.git/commitdiff
restore the default bitmap icons size to 16*15, making them larger if necessary is...
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 4 Feb 2009 12:19:45 +0000 (12:19 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 4 Feb 2009 12:19:45 +0000 (12:19 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58646 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/msw/toolbar.h
interface/wx/toolbar.h
samples/toolbar/toolbar.cpp
src/msw/toolbar.cpp

index 5e9c3e32b103706e3bb87eb9c846c84b4501194c..7a689eba01d401d620a3986988096f3314a078ee 100644 (file)
@@ -88,9 +88,6 @@ protected:
     // create the native toolbar control
     bool MSWCreateToolbar(const wxPoint& pos, const wxSize& size);
 
-    // just a wrapper for TB_SETBITMAPSIZE
-    void MSWSetBitmapSize(const wxSize& size);
-
     // recreate the control completely
     void Recreate();
 
index a7ccb783a747ee8a171490bb607bedb55ef309d5..958ce46caf7db4239e827e4844d0870e1613eeea 100644 (file)
@@ -403,8 +403,15 @@ public:
     wxSize GetMargins() const;
 
     /**
-        Returns the size of bitmap that the toolbar expects to have. The default
-        bitmap size is 16 by 15 pixels.
+        Returns the size of bitmap that the toolbar expects to have.
+
+        The default bitmap size is platform-dependent: for example, it is 16*15
+        for MSW and 24*24 for GTK. This size does @em not necessarily indicate
+        the best size to use for the toolbars on the given platform, for this
+        you should use @c wxArtProvider::GetNativeSizeHint(wxART_TOOLBAR) but
+        in any case, as the bitmap size is deduced automatically from the size
+        of the bitmaps associated with the tools added to the toolbar, it is
+        usually unnecessary to call SetToolBitmapSize() explicitly.
 
         @remarks Note that this is the size of the bitmap you pass to AddTool(),
             and not the eventual size of the tool button.
index c1c95e469b6283c13370cc22bf83eaf05aeb2380..3b9d95cac011f33b4c550e74824cff2e538c4484 100644 (file)
@@ -424,6 +424,8 @@ void MyFrame::PopulateToolbar(wxToolBarBase* toolBar)
         }
     }
 
+    // this call is actually unnecessary as the toolbar will adjust its tools
+    // size to fit the biggest icon used anyhow but it doesn't hurt neither
     toolBar->SetToolBitmapSize(wxSize(w, h));
 
     toolBar->AddTool(wxID_NEW, _T("New"),
index b5d1b6ef2faf514af68eb5bd3bfa67fa7fa709b7..5dcbef4abe6184f562bf2d5e7713c405c7299e63 100644 (file)
@@ -282,9 +282,13 @@ void wxToolBar::Init()
 
     m_nButtons = 0;
 
-    const wxSize size = wxArtProvider::GetNativeSizeHint(wxART_TOOLBAR);
-    m_defaultWidth = size.x;
-    m_defaultHeight = size.y;
+    // even though modern Windows applications typically use 24*24 (or even
+    // 32*32) size for their bitmaps, the native control itself still uses the
+    // old 16*15 default size (see TB_SETBITMAPSIZE documentation in MSDN), so
+    // default to it so that we don't call SetToolBitmapSize() unnecessarily in
+    // AdjustToolBitmapSize()
+    m_defaultWidth = 16;
+    m_defaultHeight = 15;
 
     m_pInTool = NULL;
 }
@@ -630,29 +634,22 @@ void wxToolBar::CreateDisabledImageList()
     }
 }
 
-void wxToolBar::MSWSetBitmapSize(const wxSize& size)
-{
-    ::SendMessage(GetHwnd(), TB_SETBITMAPSIZE, 0, MAKELONG(size.x, size.y));
-}
-
 void wxToolBar::AdjustToolBitmapSize()
 {
-    // this is the default bitmap size, we only need to call TB_SETBITMAPSIZE
-    // if we use something different
-    static const wxSize sizeStd(16, 15);
+    const wxSize sizeOrig(m_defaultWidth, m_defaultHeight);
 
-    wxSize s(m_defaultWidth, m_defaultHeight);
+    wxSize sizeActual(sizeOrig);
 
     for ( wxToolBarToolsList::const_iterator i = m_tools.begin();
           i != m_tools.end();
           ++i )
     {
         const wxBitmap& bmp = (*i)->GetNormalBitmap();
-        s.IncTo(bmp.GetSize());
+        sizeActual.IncTo(bmp.GetSize());
     }
 
-    if ( s != sizeStd )
-        MSWSetBitmapSize(s);
+    if ( sizeActual != sizeOrig )
+        SetToolBitmapSize(sizeActual);
 }
 
 bool wxToolBar::Realize()
@@ -1354,7 +1351,7 @@ void wxToolBar::SetToolBitmapSize(const wxSize& size)
 {
     wxToolBarBase::SetToolBitmapSize(size);
 
-    MSWSetBitmapSize(size);
+    ::SendMessage(GetHwnd(), TB_SETBITMAPSIZE, 0, MAKELONG(size.x, size.y));
 }
 
 void wxToolBar::SetRows(int nRows)