+ UnlockPixels(GetGWorldPixMap(image));
+ HUnlock( (**icon).iconData ) ;
+
+ (**icon).iconMask.rowBytes = iconSize / 8 ;
+ (**icon).iconMask.bounds = frame ;
+
+ (**icon).iconBMap.rowBytes = iconSize / 8 ;
+ (**icon).iconBMap.bounds = frame ;
+ (**icon).iconMask.baseAddr = (char*) &(**icon).iconMaskData ;
+ (**icon).iconBMap.baseAddr = (char*) &(**icon).iconMaskData + bwSize ;
+
+ if ( mask )
+ {
+ Rect r ;
+ GetPortBounds( image , &r ) ;
+ LockPixels(GetGWorldPixMap(mask) ) ;
+ CopyBits(GetPortBitMapForCopyBits(mask) ,
+ &(**icon).iconBMap , &r , &r, srcCopy , nil ) ;
+ CopyBits(GetPortBitMapForCopyBits(mask) ,
+ &(**icon).iconMask , &r , &r, srcCopy , nil ) ;
+ UnlockPixels(GetGWorldPixMap( mask ) ) ;
+ }
+ else
+ {
+ Rect r ;
+ GetPortBounds( image , &r ) ;
+ LockPixels(GetGWorldPixMap(image));
+ CopyBits(GetPortBitMapForCopyBits(image) ,
+ &(**icon).iconBMap , &r , &r, srcCopy , nil ) ;
+ CopyBits(GetPortBitMapForCopyBits(image) ,
+ &(**icon).iconMask , &r , &r, srcCopy , nil ) ;
+ UnlockPixels(GetGWorldPixMap(image));
+ }
+
+ (**icon).iconMask.baseAddr = NULL ;
+ (**icon).iconBMap.baseAddr = NULL ;
+ (**icon).iconPMap.baseAddr = NULL ;
+ HUnlock((Handle)icon) ;
+ SetGWorld(saveWorld,saveHandle);
+
+ return icon;
+}
+
+PicHandle wxMacCreatePict(GWorldPtr wp, GWorldPtr mask)
+{
+ CGrafPtr origPort ;
+ GDHandle origDev ;
+
+ PicHandle pict;
+
+ RGBColor white = { 0xffff ,0xffff , 0xffff } ;
+ RGBColor black = { 0x0000 ,0x0000 , 0x0000 } ;
+
+ GetGWorld( &origPort , &origDev ) ;
+
+ RgnHandle clipRgn = NULL ;
+
+ if ( mask )
+ {
+ clipRgn = NewRgn() ;
+ LockPixels( GetGWorldPixMap( mask ) ) ;
+ BitMapToRegion( clipRgn , (BitMap*) *GetGWorldPixMap( mask ) ) ;
+ UnlockPixels( GetGWorldPixMap( mask ) ) ;
+ }
+
+ SetGWorld( wp , NULL ) ;
+ Rect portRect ;
+ if ( clipRgn )
+ GetRegionBounds( clipRgn , &portRect ) ;
+ else
+ GetPortBounds( wp , &portRect ) ;
+ pict = OpenPicture(&portRect);
+ if(pict)
+ {
+ RGBForeColor( &black ) ;
+ RGBBackColor( &white ) ;
+
+ if ( clipRgn )
+ SetClip( clipRgn ) ;
+
+ LockPixels( GetGWorldPixMap( wp ) ) ;
+ CopyBits(GetPortBitMapForCopyBits(wp),
+ GetPortBitMapForCopyBits(wp),
+ &portRect,
+ &portRect,
+ srcCopy,clipRgn);
+ UnlockPixels( GetGWorldPixMap( wp ) ) ;
+ ClosePicture();
+ }
+ SetGWorld( origPort , origDev ) ;
+ if ( clipRgn )
+ DisposeRgn( clipRgn ) ;
+ return pict;
+}
+
+void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bitmap , int forceType )
+{
+ 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 ( (forceType == kControlContentCIconHandle || ( bmap->m_width == bmap->m_height && forceType != kControlContentPictHandle ) ) && ((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 ) ;
+ }