]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/bmpbuttn_osx.cpp
Fix wxGrid editors background painting.
[wxWidgets.git] / src / osx / bmpbuttn_osx.cpp
index 195c0ffc79fbd50ac803ebde1fc7e3330121b20b..a2c2eadfeef7bdfdd043d62fb99958804f93cd6f 100644 (file)
@@ -4,7 +4,7 @@
 // Author:      Stefan Csomor
 // Modified by:
 // Created:     1998-01-01
-// RCS-ID:      $Id: bmpbuttn.cpp 54820 2008-07-29 20:04:11Z SC $
+// RCS-ID:      $Id$
 // Copyright:   (c) Stefan Csomor
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
     #include "wx/dcmemory.h"
 #endif
 
-IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton, wxButton)
-
 #include "wx/osx/private.h"
 
 //---------------------------------------------------------------------------
 
 bool wxBitmapButton::Create( wxWindow *parent,
-                             wxWindowID id, const wxBitmap& bitmap,
+                             wxWindowID id,
+                             const wxBitmap& bitmap,
                              const wxPoint& pos,
                              const wxSize& size,
                              long style,
                              const wxValidator& validator,
                              const wxString& name )
 {
-    m_macIsUserPane = false;
-
-    // since bitmapbuttonbase is subclass of button calling wxBitmapButtonBase::Create
-    // essentially creates an additional button
-    if ( !wxControl::Create( parent, id, pos, size, style, validator, name ) )
+    DontCreatePeer();
+    
+    if ( !wxBitmapButtonBase::Create(parent, id, pos, size, style,
+                                     validator, name) )
         return false;
 
     if ( style & wxBU_AUTODRAW )
@@ -52,35 +50,27 @@ bool wxBitmapButton::Create( wxWindow *parent,
         m_marginY = 0;
     }
 
-    m_bmpNormal = bitmap;
+    m_bitmaps[State_Normal] = bitmap;
 
-    m_peer = wxWidgetImpl::CreateBitmapButton( this, parent, id, bitmap, pos, size, style, GetExtraStyle() );
+    SetPeer(wxWidgetImpl::CreateBitmapButton( this, parent, id, bitmap, pos, size, style, GetExtraStyle() ));
 
     MacPostControlCreate( pos, size );
 
     return true;
 }
 
-void wxBitmapButton::SetBitmapLabel( const wxBitmap& bitmap )
-{    
-    InvalidateBestSize();
-    
-    m_peer->SetBitmap( bitmap );
-}
-
 wxSize wxBitmapButton::DoGetBestSize() const
 {
-    wxSize best;
+    wxSize best(m_marginX, m_marginY);
 
-    best.x = 2 * m_marginX;
-    best.y = 2 * m_marginY;
-    if ( m_bmpNormal.Ok() )
+    best *= 2;
+
+    if ( GetBitmapLabel().IsOk() )
     {
-        best.x += m_bmpNormal.GetWidth();
-        best.y += m_bmpNormal.GetHeight();
+        best += GetBitmapLabel().GetSize();
     }
 
     return best;
 }
 
-#endif
+#endif // wxUSE_BMPBUTTON