]> git.saurik.com Git - wxWidgets.git/commitdiff
always use wxBU_NOTEXT and wxBU_EXACTFIT for wxBitmapButton under all platforms ...
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 28 Jun 2009 16:14:37 +0000 (16:14 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 28 Jun 2009 16:14:37 +0000 (16:14 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61232 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/bmpbuttn.h
src/gtk/bmpbuttn.cpp
src/msw/bmpbuttn.cpp
src/osx/bmpbuttn_osx.cpp
src/osx/button_osx.cpp

index 62262cad41f18d0a4d19f5469049ead71ecbf735..a355111bc9f9533bba0479a22421134fe8935cd9 100644 (file)
@@ -41,6 +41,29 @@ public:
 #endif // wxHAS_BUTTON_BITMAP
     }
 
 #endif // wxHAS_BUTTON_BITMAP
     }
 
+    bool Create(wxWindow *parent,
+                wxWindowID winid,
+                const wxBitmap& bitmap,
+                const wxPoint& pos,
+                const wxSize& size,
+                long style,
+                const wxValidator& validator,
+                const wxString& name)
+    {
+        // We use wxBU_NOTEXT to let the base class Create() know that we are
+        // not going to show the label: this is a hack needed for wxGTK where
+        // we can show both label and bitmap only with GTK 2.6+ but we always
+        // can show just one of them and this style allows us to choose which
+        // one we need.
+        //
+        // And we also use wxBU_EXACTFIT to avoid being resized up to the
+        // standard button size as this doesn't make sense for bitmap buttons
+        // which are not standard anyhow and should fit their bitmap size.
+        return wxButton::Create(parent, id, pos, size,
+                                style | wxBU_NOTEXT | wxBU_EXACTFIT,
+                                validator, name);
+    }
+
     // set/get the margins around the button
     virtual void SetMargins(int x, int y)
     {
     // set/get the margins around the button
     virtual void SetMargins(int x, int y)
     {
index a3df929f8dccf49afaff1f3ea63587254973979e..a99810f993b845a6f2088c984c7346792f64a408 100644 (file)
@@ -25,9 +25,15 @@ bool wxBitmapButton::Create(wxWindow *parent,
                             const wxValidator& validator,
                             const wxString& name)
 {
                             const wxValidator& validator,
                             const wxString& name)
 {
-    if ( !wxBitmapButtonBase::Create(parent, id, "",
-                                     pos, size,
-                                     style | wxBU_NOTEXT,
+    // we use wxBU_NOTEXT to let the base class Create() know that we are not
+    // going to show the label -- this is a hack, but like this it can support
+    // bitmaps with all GTK+ versions, not just 2.6+ which support both labels
+    // and bitmaps
+    //
+    // and we also use wxBU_EXACTFIT to avoid being resized up to the standard
+    // button size as this doesn't make sense for bitmap buttons which are not
+    // standard anyhow
+    if ( !wxBitmapButtonBase::Create(parent, id, pos, size, style,
                                      validator, name) )
         return false;
 
                                      validator, name) )
         return false;
 
index 2627bf51cc21bd84dae8861418c6fd87fbfb8df7..a77672cbfbd45a5b16276c935ba98b8b3628cd9a 100644 (file)
@@ -130,9 +130,7 @@ bool wxBitmapButton::Create(wxWindow *parent,
                             const wxValidator& wxVALIDATOR_PARAM(validator),
                             const wxString& name)
 {
                             const wxValidator& wxVALIDATOR_PARAM(validator),
                             const wxString& name)
 {
-    if ( !wxBitmapButtonBase::Create(parent, id, "",
-                                     pos, size,
-                                     style | wxBU_NOTEXT,
+    if ( !wxBitmapButtonBase::Create(parent, id, pos, size, style,
                                      validator, name) )
         return false;
 
                                      validator, name) )
         return false;
 
index c79f4fd47c51582e1ffe61d869bb1c59f5539bc4..d22411f27ee8a54a7d5629035278874c583a033c 100644 (file)
@@ -37,8 +37,8 @@ bool wxBitmapButton::Create( wxWindow *parent,
 {
     m_macIsUserPane = false;
 
 {
     m_macIsUserPane = false;
 
-    if ( !wxControl::Create( parent, id, pos, size, style | wxBU_NOTEXT,
-                             validator, name ) )
+    if ( !wxBitmapButtonBase::Create(parent, id, pos, size, style,
+                                     validator, name) )
         return false;
 
     if ( style & wxBU_AUTODRAW )
         return false;
 
     if ( style & wxBU_AUTODRAW )
index 12b630c412bf7f39b5b058f3990d2e9c6c0e9478..29afcd388274b84eb33dfcd3945374c0fb57da9d 100644 (file)
@@ -34,6 +34,18 @@ bool wxButton::Create(wxWindow *parent,
     const wxValidator& validator,
     const wxString& name)
 {
     const wxValidator& validator,
     const wxString& name)
 {
+    // FIXME: this hack is needed because we're called from
+    //        wxBitmapButton::Create() with this style and we currently use a
+    //        different wxWidgetImpl method (CreateBitmapButton() rather than
+    //        CreateButton()) for creating bitmap buttons, but we really ought
+    //        to unify the creation of buttons of all kinds and then remove
+    //        this check
+    if ( style & wxBU_NOTEXT )
+    {
+        return wxControl::Create(parent, id, lbl, pos, size, style,
+                                 validator, name);
+    }
+
     wxString label(lbl);
     if (label.empty() && wxIsStockID(id) && !(id == wxID_HELP))
         label = wxGetStockLabel(id);
     wxString label(lbl);
     if (label.empty() && wxIsStockID(id) && !(id == wxID_HELP))
         label = wxGetStockLabel(id);