1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxBitmapButton
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
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
,
32 if ( !wxBitmapButtonBase::Create(parent
, id
, _T(""), pos
, size
,
33 style
, validator
, name
) )
46 if ( width
== -1 && bitmap
.Ok())
47 width
= bitmap
.GetWidth() + 2*m_marginX
;
49 if ( height
== -1 && bitmap
.Ok())
50 height
= bitmap
.GetHeight() + 2*m_marginY
;
55 wxBitmapRefData
* bmap
= NULL
;
57 if ( m_bmpNormal
.Ok() )
58 bmap
= (wxBitmapRefData
*) ( m_bmpNormal
.GetRefData()) ;
60 MacPreControlCreate( parent
, id
, wxEmptyString
, pos
, wxSize( width
, height
) ,style
, validator
, name
, &bounds
, title
) ;
62 m_macControl
= ::NewControl( MAC_WXHWND(parent
->MacGetRootWindow()) , &bounds
, title
, false , 0 ,
63 kControlBehaviorOffsetContents
+
64 ( bmap
&& bmap
->m_bitmapType
== kMacBitmapTypeIcon
?
65 kControlContentCIconHandle
: kControlContentPictHandle
) , 0,
66 (( style
& wxBU_AUTODRAW
) ? kControlBevelButtonSmallBevelProc
: kControlBevelButtonNormalBevelProc
), (long) this ) ;
67 wxASSERT_MSG( (ControlHandle
) m_macControl
!= NULL
, wxT("No valid mac control") ) ;
69 ControlButtonContentInfo info
;
70 wxMacCreateBitmapButton( &info
, m_bmpNormal
) ;
71 if ( info
.contentType
!= kControlNoContent
)
73 ::SetControlData( (ControlHandle
) m_macControl
, kControlButtonPart
, kControlBevelButtonContentTag
, sizeof(info
) , (char*) &info
) ;
75 MacPostControlCreate() ;
80 void wxBitmapButton::SetBitmapLabel(const wxBitmap
& bitmap
)
84 ControlButtonContentInfo info
;
85 wxMacCreateBitmapButton( &info
, m_bmpNormal
) ;
86 if ( info
.contentType
!= kControlNoContent
)
88 ::SetControlData( (ControlHandle
) m_macControl
, kControlButtonPart
, kControlBevelButtonContentTag
, sizeof(info
) , (char*) &info
) ;