added forcing to image conversion to always attempt a color icon (needed eg for menus)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16788 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -129,7 +129,7 @@ PicHandle wxMacCreatePict( GWorldPtr gw , GWorldPtr mask = NULL ) ;
|
|||||||
CIconHandle wxMacCreateCIcon(GWorldPtr image , GWorldPtr mask , short dstDepth , short iconSize ) ;
|
CIconHandle wxMacCreateCIcon(GWorldPtr image , GWorldPtr mask , short dstDepth , short iconSize ) ;
|
||||||
void wxMacSetColorTableEntry( CTabHandle newColors , int index , int red , int green , int blue ) ;
|
void wxMacSetColorTableEntry( CTabHandle newColors , int index , int red , int green , int blue ) ;
|
||||||
CTabHandle wxMacCreateColorTable( int numColors ) ;
|
CTabHandle wxMacCreateColorTable( int numColors ) ;
|
||||||
void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bitmap ) ;
|
void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bitmap , bool forceColorIcon = false ) ;
|
||||||
|
|
||||||
#define MAC_WXCOLORREF(a) (*((RGBColor*)&(a)))
|
#define MAC_WXCOLORREF(a) (*((RGBColor*)&(a)))
|
||||||
#define MAC_WXHBITMAP(a) (GWorldPtr(a))
|
#define MAC_WXHBITMAP(a) (GWorldPtr(a))
|
||||||
|
@@ -218,20 +218,24 @@ CIconHandle wxMacCreateCIcon(GWorldPtr image , GWorldPtr mask , short dstDepth ,
|
|||||||
|
|
||||||
if ( mask )
|
if ( mask )
|
||||||
{
|
{
|
||||||
|
Rect r ;
|
||||||
|
GetPortBounds( image , &r ) ;
|
||||||
LockPixels(GetGWorldPixMap(mask) ) ;
|
LockPixels(GetGWorldPixMap(mask) ) ;
|
||||||
CopyBits(GetPortBitMapForCopyBits(mask) ,
|
CopyBits(GetPortBitMapForCopyBits(mask) ,
|
||||||
&(**icon).iconBMap , &imageBounds , &imageBounds, srcCopy , nil ) ;
|
&(**icon).iconBMap , &r , &r, srcCopy , nil ) ;
|
||||||
CopyBits(GetPortBitMapForCopyBits(mask) ,
|
CopyBits(GetPortBitMapForCopyBits(mask) ,
|
||||||
&(**icon).iconMask , &imageBounds , &imageBounds, srcCopy , nil ) ;
|
&(**icon).iconMask , &r , &r, srcCopy , nil ) ;
|
||||||
UnlockPixels(GetGWorldPixMap( mask ) ) ;
|
UnlockPixels(GetGWorldPixMap( mask ) ) ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Rect r ;
|
||||||
|
GetPortBounds( image , &r ) ;
|
||||||
LockPixels(GetGWorldPixMap(image));
|
LockPixels(GetGWorldPixMap(image));
|
||||||
CopyBits(GetPortBitMapForCopyBits(image) ,
|
CopyBits(GetPortBitMapForCopyBits(image) ,
|
||||||
&(**icon).iconBMap , &imageBounds , &imageBounds, srcCopy , nil ) ;
|
&(**icon).iconBMap , &r , &r, srcCopy , nil ) ;
|
||||||
CopyBits(GetPortBitMapForCopyBits(image) ,
|
CopyBits(GetPortBitMapForCopyBits(image) ,
|
||||||
&(**icon).iconMask , &imageBounds , &imageBounds, srcCopy , nil ) ;
|
&(**icon).iconMask , &r , &r, srcCopy , nil ) ;
|
||||||
UnlockPixels(GetGWorldPixMap(image));
|
UnlockPixels(GetGWorldPixMap(image));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -289,7 +293,7 @@ PicHandle wxMacCreatePict(GWorldPtr wp, GWorldPtr mask)
|
|||||||
return pict;
|
return pict;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bitmap )
|
void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bitmap , bool forceColorIcon )
|
||||||
{
|
{
|
||||||
memset( info , 0 , sizeof(ControlButtonContentInfo) ) ;
|
memset( info , 0 , sizeof(ControlButtonContentInfo) ) ;
|
||||||
if ( bitmap.Ok() )
|
if ( bitmap.Ok() )
|
||||||
@@ -305,7 +309,7 @@ void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bi
|
|||||||
}
|
}
|
||||||
else if ( bmap->m_bitmapType == kMacBitmapTypeGrafWorld )
|
else if ( bmap->m_bitmapType == kMacBitmapTypeGrafWorld )
|
||||||
{
|
{
|
||||||
if ( (bmap->m_width == bmap->m_height) && (bmap->m_width & 0x3 == 0) )
|
if ( (forceColorIcon || bmap->m_width == bmap->m_height) && ((bmap->m_width & 0x3) == 0) )
|
||||||
{
|
{
|
||||||
info->contentType = kControlContentCIconHandle ;
|
info->contentType = kControlContentCIconHandle ;
|
||||||
if ( bitmap.GetMask() )
|
if ( bitmap.GetMask() )
|
||||||
|
@@ -218,20 +218,24 @@ CIconHandle wxMacCreateCIcon(GWorldPtr image , GWorldPtr mask , short dstDepth ,
|
|||||||
|
|
||||||
if ( mask )
|
if ( mask )
|
||||||
{
|
{
|
||||||
|
Rect r ;
|
||||||
|
GetPortBounds( image , &r ) ;
|
||||||
LockPixels(GetGWorldPixMap(mask) ) ;
|
LockPixels(GetGWorldPixMap(mask) ) ;
|
||||||
CopyBits(GetPortBitMapForCopyBits(mask) ,
|
CopyBits(GetPortBitMapForCopyBits(mask) ,
|
||||||
&(**icon).iconBMap , &imageBounds , &imageBounds, srcCopy , nil ) ;
|
&(**icon).iconBMap , &r , &r, srcCopy , nil ) ;
|
||||||
CopyBits(GetPortBitMapForCopyBits(mask) ,
|
CopyBits(GetPortBitMapForCopyBits(mask) ,
|
||||||
&(**icon).iconMask , &imageBounds , &imageBounds, srcCopy , nil ) ;
|
&(**icon).iconMask , &r , &r, srcCopy , nil ) ;
|
||||||
UnlockPixels(GetGWorldPixMap( mask ) ) ;
|
UnlockPixels(GetGWorldPixMap( mask ) ) ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Rect r ;
|
||||||
|
GetPortBounds( image , &r ) ;
|
||||||
LockPixels(GetGWorldPixMap(image));
|
LockPixels(GetGWorldPixMap(image));
|
||||||
CopyBits(GetPortBitMapForCopyBits(image) ,
|
CopyBits(GetPortBitMapForCopyBits(image) ,
|
||||||
&(**icon).iconBMap , &imageBounds , &imageBounds, srcCopy , nil ) ;
|
&(**icon).iconBMap , &r , &r, srcCopy , nil ) ;
|
||||||
CopyBits(GetPortBitMapForCopyBits(image) ,
|
CopyBits(GetPortBitMapForCopyBits(image) ,
|
||||||
&(**icon).iconMask , &imageBounds , &imageBounds, srcCopy , nil ) ;
|
&(**icon).iconMask , &r , &r, srcCopy , nil ) ;
|
||||||
UnlockPixels(GetGWorldPixMap(image));
|
UnlockPixels(GetGWorldPixMap(image));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -289,7 +293,7 @@ PicHandle wxMacCreatePict(GWorldPtr wp, GWorldPtr mask)
|
|||||||
return pict;
|
return pict;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bitmap )
|
void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bitmap , bool forceColorIcon )
|
||||||
{
|
{
|
||||||
memset( info , 0 , sizeof(ControlButtonContentInfo) ) ;
|
memset( info , 0 , sizeof(ControlButtonContentInfo) ) ;
|
||||||
if ( bitmap.Ok() )
|
if ( bitmap.Ok() )
|
||||||
@@ -305,7 +309,7 @@ void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bi
|
|||||||
}
|
}
|
||||||
else if ( bmap->m_bitmapType == kMacBitmapTypeGrafWorld )
|
else if ( bmap->m_bitmapType == kMacBitmapTypeGrafWorld )
|
||||||
{
|
{
|
||||||
if ( (bmap->m_width == bmap->m_height) && (bmap->m_width & 0x3 == 0) )
|
if ( (forceColorIcon || bmap->m_width == bmap->m_height) && ((bmap->m_width & 0x3) == 0) )
|
||||||
{
|
{
|
||||||
info->contentType = kControlContentCIconHandle ;
|
info->contentType = kControlContentCIconHandle ;
|
||||||
if ( bitmap.GetMask() )
|
if ( bitmap.GetMask() )
|
||||||
|
@@ -209,10 +209,34 @@ bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos)
|
|||||||
if ( pos == (size_t)-1 )
|
if ( pos == (size_t)-1 )
|
||||||
{
|
{
|
||||||
UMAAppendMenuItem(MAC_WXHMENU(m_hMenu), label,key,modifiers);
|
UMAAppendMenuItem(MAC_WXHMENU(m_hMenu), label,key,modifiers);
|
||||||
|
if ( pItem->GetBitmap().Ok() )
|
||||||
|
{
|
||||||
|
ControlButtonContentInfo info ;
|
||||||
|
wxMacCreateBitmapButton( &info , pItem->GetBitmap() , true ) ;
|
||||||
|
if ( info.contentType != kControlNoContent )
|
||||||
|
{
|
||||||
|
if ( info.contentType == kControlContentCIconHandle )
|
||||||
|
SetMenuItemIconHandle( MAC_WXHMENU(m_hMenu) , CountMenuItems(MAC_WXHMENU(m_hMenu) ) ,
|
||||||
|
kMenuColorIconType , (Handle) info.u.cIconHandle ) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
UMAInsertMenuItem(MAC_WXHMENU(m_hMenu), label , pos,key,modifiers);
|
UMAInsertMenuItem(MAC_WXHMENU(m_hMenu), label , pos,key,modifiers);
|
||||||
|
if ( pItem->GetBitmap().Ok() )
|
||||||
|
{
|
||||||
|
ControlButtonContentInfo info ;
|
||||||
|
wxMacCreateBitmapButton( &info , pItem->GetBitmap() , true ) ;
|
||||||
|
if ( info.contentType != kControlNoContent )
|
||||||
|
{
|
||||||
|
if ( info.contentType == kControlContentCIconHandle )
|
||||||
|
SetMenuItemIconHandle( MAC_WXHMENU(m_hMenu) , pos ,
|
||||||
|
kMenuColorIconType , (Handle) info.u.cIconHandle ) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ( pItem->GetId() == idMenuTitle )
|
if ( pItem->GetId() == idMenuTitle )
|
||||||
{
|
{
|
||||||
|
@@ -209,10 +209,34 @@ bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos)
|
|||||||
if ( pos == (size_t)-1 )
|
if ( pos == (size_t)-1 )
|
||||||
{
|
{
|
||||||
UMAAppendMenuItem(MAC_WXHMENU(m_hMenu), label,key,modifiers);
|
UMAAppendMenuItem(MAC_WXHMENU(m_hMenu), label,key,modifiers);
|
||||||
|
if ( pItem->GetBitmap().Ok() )
|
||||||
|
{
|
||||||
|
ControlButtonContentInfo info ;
|
||||||
|
wxMacCreateBitmapButton( &info , pItem->GetBitmap() , true ) ;
|
||||||
|
if ( info.contentType != kControlNoContent )
|
||||||
|
{
|
||||||
|
if ( info.contentType == kControlContentCIconHandle )
|
||||||
|
SetMenuItemIconHandle( MAC_WXHMENU(m_hMenu) , CountMenuItems(MAC_WXHMENU(m_hMenu) ) ,
|
||||||
|
kMenuColorIconType , (Handle) info.u.cIconHandle ) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
UMAInsertMenuItem(MAC_WXHMENU(m_hMenu), label , pos,key,modifiers);
|
UMAInsertMenuItem(MAC_WXHMENU(m_hMenu), label , pos,key,modifiers);
|
||||||
|
if ( pItem->GetBitmap().Ok() )
|
||||||
|
{
|
||||||
|
ControlButtonContentInfo info ;
|
||||||
|
wxMacCreateBitmapButton( &info , pItem->GetBitmap() , true ) ;
|
||||||
|
if ( info.contentType != kControlNoContent )
|
||||||
|
{
|
||||||
|
if ( info.contentType == kControlContentCIconHandle )
|
||||||
|
SetMenuItemIconHandle( MAC_WXHMENU(m_hMenu) , pos ,
|
||||||
|
kMenuColorIconType , (Handle) info.u.cIconHandle ) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ( pItem->GetId() == idMenuTitle )
|
if ( pItem->GetId() == idMenuTitle )
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user