1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxBitmapButton
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "bmpbuttn.h"
16 #include "wx/window.h"
17 #include "wx/bmpbuttn.h"
19 #if !USE_SHARED_LIBRARY
20 IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton
, wxButton
)
23 #include "wx/mac/uma.h"
24 #include "wx/bitmap.h"
26 bool wxBitmapButton::Create(wxWindow
*parent
, wxWindowID id
, const wxBitmap
& bitmap
,
28 const wxSize
& size
, long style
,
29 const wxValidator
& validator
,
43 m_windowId
= NewControlId();
47 if ( width
== -1 && bitmap
.Ok())
48 width
= bitmap
.GetWidth() + 2*m_marginX
;
50 if ( height
== -1 && bitmap
.Ok())
51 height
= bitmap
.GetHeight() + 2*m_marginY
;
56 wxBitmapRefData
* bmap
= NULL
;
58 if ( m_bmpNormal
.Ok() )
59 bmap
= (wxBitmapRefData
*) ( m_bmpNormal
.GetRefData()) ;
61 MacPreControlCreate( parent
, id
, "" , pos
, wxSize( width
, height
) ,style
, validator
, name
, &bounds
, title
) ;
63 m_macControl
= ::NewControl( MAC_WXHWND(parent
->MacGetRootWindow()) , &bounds
, title
, false , 0 ,
64 kControlBehaviorOffsetContents
+
65 ( bmap
&& bmap
->m_bitmapType
== kMacBitmapTypeIcon
?
66 kControlContentCIconHandle
: kControlContentPictHandle
) , 0,
67 (( style
& wxBU_AUTODRAW
) ? kControlBevelButtonSmallBevelProc
: kControlBevelButtonNormalBevelProc
), (long) this ) ;
68 wxASSERT_MSG( (ControlHandle
) m_macControl
!= NULL
, "No valid mac control" ) ;
70 ControlButtonContentInfo info
;
71 wxMacCreateBitmapButton( &info
, m_bmpNormal
) ;
72 if ( info
.contentType
!= kControlNoContent
)
74 ::SetControlData( (ControlHandle
) m_macControl
, kControlButtonPart
, kControlBevelButtonContentTag
, sizeof(info
) , (char*) &info
) ;
76 MacPostControlCreate() ;
81 void wxBitmapButton::SetBitmapLabel(const wxBitmap
& bitmap
)
85 ControlButtonContentInfo info
;
86 wxMacCreateBitmapButton( &info
, m_bmpNormal
) ;
87 if ( info
.contentType
!= kControlNoContent
)
89 ::SetControlData( (ControlHandle
) m_macControl
, kControlButtonPart
, kControlBevelButtonContentTag
, sizeof(info
) , (char*) &info
) ;