return pict;
}
+void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bitmap )
+{
+ memset( info , 0 , sizeof(ControlButtonContentInfo) ) ;
+ if ( bitmap.Ok() )
+ {
+ wxBitmapRefData * bmap = (wxBitmapRefData*) ( bitmap.GetRefData()) ;
+ if ( bmap == NULL )
+ return ;
+
+ if ( bmap->m_bitmapType == kMacBitmapTypePict )
+ {
+ info->contentType = kControlContentPictHandle ;
+ info->u.picture = MAC_WXHMETAFILE(bmap->m_hPict) ;
+ }
+ else if ( bmap->m_bitmapType == kMacBitmapTypeGrafWorld )
+ {
+ if ( (bmap->m_width == bmap->m_height) && (bmap->m_width & 0x3 == 0) )
+ {
+ info->contentType = kControlContentCIconHandle ;
+ if ( bitmap.GetMask() )
+ {
+ info->u.cIconHandle = wxMacCreateCIcon( MAC_WXHBITMAP(bmap->m_hBitmap) , MAC_WXHBITMAP(bitmap.GetMask()->GetMaskBitmap()) ,
+ 8 , bmap->m_width ) ;
+ }
+ else
+ {
+ info->u.cIconHandle = wxMacCreateCIcon( MAC_WXHBITMAP(bmap->m_hBitmap) , NULL ,
+ 8 , bmap->m_width ) ;
+ }
+ }
+ else
+ {
+ info->contentType = kControlContentPictHandle ;
+ if ( bitmap.GetMask() )
+ {
+ info->u.picture = wxMacCreatePict( MAC_WXHBITMAP(bmap->m_hBitmap) , MAC_WXHBITMAP(bitmap.GetMask()->GetMaskBitmap() ) ) ;
+ }
+ else
+ {
+ info->u.picture = wxMacCreatePict( MAC_WXHBITMAP(bmap->m_hBitmap) , NULL ) ;
+ }
+ }
+ }
+ else if ( bmap->m_bitmapType == kMacBitmapTypeIcon )
+ {
+ info->contentType = kControlContentCIconHandle ;
+ info->u.cIconHandle = MAC_WXHICON(bmap->m_hIcon) ;
+ }
+ }
+}
+
wxBitmapRefData::wxBitmapRefData()
{
m_ok = FALSE;
wxASSERT_MSG( (ControlHandle) m_macControl != NULL , "No valid mac control" ) ;
ControlButtonContentInfo info ;
-
-
- if ( m_buttonBitmap.Ok() )
+ wxMacCreateBitmapButton( &info , m_buttonBitmap ) ;
+ if ( info.contentType != kControlNoContent )
{
- if ( bmap->m_bitmapType == kMacBitmapTypePict ) {
- info.contentType = kControlContentPictHandle ;
- info.u.picture = MAC_WXHMETAFILE( bmap->m_hPict ) ;
- }
- else if ( bmap->m_bitmapType == kMacBitmapTypeGrafWorld )
- {
- if ( m_buttonBitmap.GetMask() )
- {
- info.contentType = kControlContentCIconHandle ;
- info.u.cIconHandle = wxMacCreateCIcon( MAC_WXHBITMAP( bmap->m_hBitmap ) , MAC_WXHBITMAP(m_buttonBitmap.GetMask()->GetMaskBitmap()) ,
- 8 , 16 ) ;
- }
- else
- {
- info.contentType = kControlContentCIconHandle ;
- info.u.cIconHandle = wxMacCreateCIcon( MAC_WXHBITMAP( bmap->m_hBitmap ) , NULL ,
- 8 , 16 ) ;
- }
- }
- else if ( bmap->m_bitmapType == kMacBitmapTypeIcon )
- {
- info.contentType = kControlContentCIconHandle ;
- info.u.cIconHandle = MAC_WXHICON(bmap->m_hIcon) ;
- }
- }
-
- ::SetControlData( (ControlHandle) m_macControl , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ;
-
+ ::SetControlData( (ControlHandle) m_macControl , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ;
+ }
MacPostControlCreate() ;
return TRUE;
void wxBitmapButton::SetBitmapLabel(const wxBitmap& bitmap)
{
- ControlButtonContentInfo info ;
m_buttonBitmap = bitmap;
- if ( m_buttonBitmap.Ok() )
+ ControlButtonContentInfo info ;
+ wxMacCreateBitmapButton( &info , m_buttonBitmap ) ;
+ if ( info.contentType != kControlNoContent )
{
- wxBitmapRefData * bmap = (wxBitmapRefData*) ( m_buttonBitmap.GetRefData()) ;
- if ( bmap->m_bitmapType == kMacBitmapTypePict ) {
- info.contentType = kControlContentPictHandle ;
- info.u.picture = MAC_WXHMETAFILE(bmap->m_hPict) ;
- }
- else if ( bmap->m_bitmapType == kMacBitmapTypeGrafWorld )
- {
- if ( m_buttonBitmap.GetMask() )
- {
- info.contentType = kControlContentCIconHandle ;
- info.u.cIconHandle = wxMacCreateCIcon( MAC_WXHBITMAP(bmap->m_hBitmap) , MAC_WXHBITMAP(m_buttonBitmap.GetMask()->GetMaskBitmap()) ,
- 8 , 16 ) ;
- }
- else
- {
- info.contentType = kControlContentCIconHandle ;
- info.u.cIconHandle = wxMacCreateCIcon( MAC_WXHBITMAP(bmap->m_hBitmap) , NULL ,
- 8 , 16 ) ;
- }
- }
- else if ( bmap->m_bitmapType == kMacBitmapTypeIcon )
- {
- info.contentType = kControlContentCIconHandle ;
- info.u.cIconHandle = MAC_WXHICON( bmap->m_hIcon ) ;
- }
-
-
::SetControlData( (ControlHandle) m_macControl , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ;
}
}
return pict;
}
+void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bitmap )
+{
+ memset( info , 0 , sizeof(ControlButtonContentInfo) ) ;
+ if ( bitmap.Ok() )
+ {
+ wxBitmapRefData * bmap = (wxBitmapRefData*) ( bitmap.GetRefData()) ;
+ if ( bmap == NULL )
+ return ;
+
+ if ( bmap->m_bitmapType == kMacBitmapTypePict )
+ {
+ info->contentType = kControlContentPictHandle ;
+ info->u.picture = MAC_WXHMETAFILE(bmap->m_hPict) ;
+ }
+ else if ( bmap->m_bitmapType == kMacBitmapTypeGrafWorld )
+ {
+ if ( (bmap->m_width == bmap->m_height) && (bmap->m_width & 0x3 == 0) )
+ {
+ info->contentType = kControlContentCIconHandle ;
+ if ( bitmap.GetMask() )
+ {
+ info->u.cIconHandle = wxMacCreateCIcon( MAC_WXHBITMAP(bmap->m_hBitmap) , MAC_WXHBITMAP(bitmap.GetMask()->GetMaskBitmap()) ,
+ 8 , bmap->m_width ) ;
+ }
+ else
+ {
+ info->u.cIconHandle = wxMacCreateCIcon( MAC_WXHBITMAP(bmap->m_hBitmap) , NULL ,
+ 8 , bmap->m_width ) ;
+ }
+ }
+ else
+ {
+ info->contentType = kControlContentPictHandle ;
+ if ( bitmap.GetMask() )
+ {
+ info->u.picture = wxMacCreatePict( MAC_WXHBITMAP(bmap->m_hBitmap) , MAC_WXHBITMAP(bitmap.GetMask()->GetMaskBitmap() ) ) ;
+ }
+ else
+ {
+ info->u.picture = wxMacCreatePict( MAC_WXHBITMAP(bmap->m_hBitmap) , NULL ) ;
+ }
+ }
+ }
+ else if ( bmap->m_bitmapType == kMacBitmapTypeIcon )
+ {
+ info->contentType = kControlContentCIconHandle ;
+ info->u.cIconHandle = MAC_WXHICON(bmap->m_hIcon) ;
+ }
+ }
+}
+
wxBitmapRefData::wxBitmapRefData()
{
m_ok = FALSE;
wxASSERT_MSG( (ControlHandle) m_macControl != NULL , "No valid mac control" ) ;
ControlButtonContentInfo info ;
-
-
- if ( m_buttonBitmap.Ok() )
+ wxMacCreateBitmapButton( &info , m_buttonBitmap ) ;
+ if ( info.contentType != kControlNoContent )
{
- if ( bmap->m_bitmapType == kMacBitmapTypePict ) {
- info.contentType = kControlContentPictHandle ;
- info.u.picture = MAC_WXHMETAFILE( bmap->m_hPict ) ;
- }
- else if ( bmap->m_bitmapType == kMacBitmapTypeGrafWorld )
- {
- if ( m_buttonBitmap.GetMask() )
- {
- info.contentType = kControlContentCIconHandle ;
- info.u.cIconHandle = wxMacCreateCIcon( MAC_WXHBITMAP( bmap->m_hBitmap ) , MAC_WXHBITMAP(m_buttonBitmap.GetMask()->GetMaskBitmap()) ,
- 8 , 16 ) ;
- }
- else
- {
- info.contentType = kControlContentCIconHandle ;
- info.u.cIconHandle = wxMacCreateCIcon( MAC_WXHBITMAP( bmap->m_hBitmap ) , NULL ,
- 8 , 16 ) ;
- }
- }
- else if ( bmap->m_bitmapType == kMacBitmapTypeIcon )
- {
- info.contentType = kControlContentCIconHandle ;
- info.u.cIconHandle = MAC_WXHICON(bmap->m_hIcon) ;
- }
- }
-
- ::SetControlData( (ControlHandle) m_macControl , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ;
-
+ ::SetControlData( (ControlHandle) m_macControl , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ;
+ }
MacPostControlCreate() ;
return TRUE;
void wxBitmapButton::SetBitmapLabel(const wxBitmap& bitmap)
{
- ControlButtonContentInfo info ;
m_buttonBitmap = bitmap;
- if ( m_buttonBitmap.Ok() )
+ ControlButtonContentInfo info ;
+ wxMacCreateBitmapButton( &info , m_buttonBitmap ) ;
+ if ( info.contentType != kControlNoContent )
{
- wxBitmapRefData * bmap = (wxBitmapRefData*) ( m_buttonBitmap.GetRefData()) ;
- if ( bmap->m_bitmapType == kMacBitmapTypePict ) {
- info.contentType = kControlContentPictHandle ;
- info.u.picture = MAC_WXHMETAFILE(bmap->m_hPict) ;
- }
- else if ( bmap->m_bitmapType == kMacBitmapTypeGrafWorld )
- {
- if ( m_buttonBitmap.GetMask() )
- {
- info.contentType = kControlContentCIconHandle ;
- info.u.cIconHandle = wxMacCreateCIcon( MAC_WXHBITMAP(bmap->m_hBitmap) , MAC_WXHBITMAP(m_buttonBitmap.GetMask()->GetMaskBitmap()) ,
- 8 , 16 ) ;
- }
- else
- {
- info.contentType = kControlContentCIconHandle ;
- info.u.cIconHandle = wxMacCreateCIcon( MAC_WXHBITMAP(bmap->m_hBitmap) , NULL ,
- 8 , 16 ) ;
- }
- }
- else if ( bmap->m_bitmapType == kMacBitmapTypeIcon )
- {
- info.contentType = kControlContentCIconHandle ;
- info.u.cIconHandle = MAC_WXHICON( bmap->m_hIcon ) ;
- }
-
-
::SetControlData( (ControlHandle) m_macControl , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ;
}
}
toolrect.bottom = toolrect.top + toolSize.y ;
ControlButtonContentInfo info ;
- if ( bmap )
- {
- if ( bmap->m_bitmapType == kMacBitmapTypePict )
- {
- info.contentType = kControlContentPictHandle ;
- info.u.picture = MAC_WXHMETAFILE(bmap->m_hPict) ;
- }
- else if ( bmap->m_bitmapType == kMacBitmapTypeGrafWorld )
- {
- if ( tool->GetBitmap1().GetMask() )
- {
- info.contentType = kControlContentCIconHandle ;
- info.u.cIconHandle = wxMacCreateCIcon( MAC_WXHBITMAP(bmap->m_hBitmap) , MAC_WXHBITMAP(tool->GetBitmap1().GetMask()->GetMaskBitmap()) ,
- 8 , 16 ) ;
- }
- else
- {
- info.contentType = kControlContentCIconHandle ;
- info.u.cIconHandle = wxMacCreateCIcon( MAC_WXHBITMAP(bmap->m_hBitmap) , NULL ,
- 8 , 16 ) ;
- }
- }
- }
-
+ wxMacCreateBitmapButton( &info , tool->GetBitmap1() ) ;
ControlHandle m_macToolHandle ;
SInt16 behaviour = kControlBehaviorOffsetContents ;
if ( tool->CanBeToggled() )
behaviour += kControlBehaviorToggles ;
- if ( info.u.cIconHandle ) // since it is a handle we can use one of them
+ if ( info.contentType != kControlNoContent )
{
m_macToolHandle = ::NewControl( window , &toolrect , "\p" , false , 0 ,
behaviour + info.contentType , 0 , kControlBevelButtonNormalBevelProc , (long) this ) ;
toolrect.bottom = toolrect.top + toolSize.y ;
ControlButtonContentInfo info ;
- if ( bmap )
- {
- if ( bmap->m_bitmapType == kMacBitmapTypePict )
- {
- info.contentType = kControlContentPictHandle ;
- info.u.picture = MAC_WXHMETAFILE(bmap->m_hPict) ;
- }
- else if ( bmap->m_bitmapType == kMacBitmapTypeGrafWorld )
- {
- if ( tool->GetBitmap1().GetMask() )
- {
- info.contentType = kControlContentCIconHandle ;
- info.u.cIconHandle = wxMacCreateCIcon( MAC_WXHBITMAP(bmap->m_hBitmap) , MAC_WXHBITMAP(tool->GetBitmap1().GetMask()->GetMaskBitmap()) ,
- 8 , 16 ) ;
- }
- else
- {
- info.contentType = kControlContentCIconHandle ;
- info.u.cIconHandle = wxMacCreateCIcon( MAC_WXHBITMAP(bmap->m_hBitmap) , NULL ,
- 8 , 16 ) ;
- }
- }
- }
-
+ wxMacCreateBitmapButton( &info , tool->GetBitmap1() ) ;
ControlHandle m_macToolHandle ;
SInt16 behaviour = kControlBehaviorOffsetContents ;
if ( tool->CanBeToggled() )
behaviour += kControlBehaviorToggles ;
- if ( info.u.cIconHandle ) // since it is a handle we can use one of them
+ if ( info.contentType != kControlNoContent )
{
m_macToolHandle = ::NewControl( window , &toolrect , "\p" , false , 0 ,
behaviour + info.contentType , 0 , kControlBevelButtonNormalBevelProc , (long) this ) ;