void wxMacSetColorTableEntry( CTabHandle newColors , int index , int red , int green , int blue )
{
(**newColors).ctTable[index].value = index;
- (**newColors).ctTable[index].rgb.red = 0 ;// someRedValue;
- (**newColors).ctTable[index].rgb.green = 0 ; // someGreenValue;
- (**newColors).ctTable[index].rgb.blue = 0 ; // someBlueValue;
+ (**newColors).ctTable[index].rgb.red = red ; // someRedValue;
+ (**newColors).ctTable[index].rgb.green = green ; // someGreenValue;
+ (**newColors).ctTable[index].rgb.blue = blue ; // someBlueValue;
}
GWorldPtr wxMacCreateGWorld( int width , int height , int depth )
if ( mask )
{
+ Rect r ;
+ GetPortBounds( image , &r ) ;
LockPixels(GetGWorldPixMap(mask) ) ;
CopyBits(GetPortBitMapForCopyBits(mask) ,
- &(**icon).iconBMap , &imageBounds , &imageBounds, srcCopy , nil ) ;
+ &(**icon).iconBMap , &r , &r, srcCopy , nil ) ;
CopyBits(GetPortBitMapForCopyBits(mask) ,
- &(**icon).iconMask , &imageBounds , &imageBounds, srcCopy , nil ) ;
+ &(**icon).iconMask , &r , &r, srcCopy , nil ) ;
UnlockPixels(GetGWorldPixMap( mask ) ) ;
}
else
{
+ Rect r ;
+ GetPortBounds( image , &r ) ;
LockPixels(GetGWorldPixMap(image));
CopyBits(GetPortBitMapForCopyBits(image) ,
- &(**icon).iconBMap , &imageBounds , &imageBounds, srcCopy , nil ) ;
+ &(**icon).iconBMap , &r , &r, srcCopy , nil ) ;
CopyBits(GetPortBitMapForCopyBits(image) ,
- &(**icon).iconMask , &imageBounds , &imageBounds, srcCopy , nil ) ;
+ &(**icon).iconMask , &r , &r, srcCopy , nil ) ;
UnlockPixels(GetGWorldPixMap(image));
}
SetGWorld( wp , NULL ) ;
Rect portRect ;
- GetPortBounds( wp , &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),
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 ) ;
+ }
+ }
+ 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_width(0)
+ , m_height(0)
+ , m_depth(0)
+ , m_ok(FALSE)
+ , m_numColors(0)
+ , m_quality(0)
{
- m_ok = FALSE;
- m_width = 0;
- m_height = 0;
- m_depth = 0;
- m_quality = 0;
- m_numColors = 0;
m_bitmapMask = NULL;
m_hBitmap = NULL ;
m_hPict = NULL ;
m_bitmapType = kMacBitmapTypeUnknownType ;
}
-// TODO move this do a public function of Bitmap Ref
+// TODO move this to a public function of Bitmap Ref
static void DisposeBitmapRefData(wxBitmapRefData *data)
{
switch (data->m_bitmapType)
SetGWorld( (GWorldPtr) GetHBITMAP() , NULL ) ;
// Render image
- RGBColor colorRGB ;
-
register unsigned char* data = image.GetData();
char* destinationBase = GetPixBaseAddr( pixMap );
register unsigned char* destination = (unsigned char*) destinationBase ;
GWorldPtr origPort;
GDHandle origDevice;
+ RgnHandle maskRgn = NULL ;
+ GWorldPtr tempPort = NULL ;
int index;
RGBColor color;
// background color set to RGB(16,16,16) in consistent with wxGTK
wxMask *mask = GetMask();
GetGWorld( &origPort, &origDevice );
- LockPixels(GetGWorldPixMap( (GWorldPtr) GetHBITMAP()));
- SetGWorld( (GWorldPtr) GetHBITMAP(), NULL);
-
+ if ( GetBitmapType() != kMacBitmapTypeGrafWorld )
+ {
+ tempPort = wxMacCreateGWorld( width , height , -1) ;
+ }
+ else
+ {
+ tempPort = (GWorldPtr) GetHBITMAP() ;
+ }
+ LockPixels(GetGWorldPixMap(tempPort));
+ SetGWorld( tempPort, NULL);
+ if ( GetBitmapType() == kMacBitmapTypePict || GetBitmapType() == kMacBitmapTypeIcon )
+ {
+ Rect bitmaprect = { 0 , 0 , height, width };
+ if ( GetBitmapType() == kMacBitmapTypeIcon )
+ {
+ ::PlotCIconHandle( &bitmaprect , atNone , ttNone , MAC_WXHICON(GetHICON()) ) ;
+ maskRgn = NewRgn() ;
+ BitMapToRegion( maskRgn , &(**(MAC_WXHICON(GetHICON()))).iconMask ) ;
+ }
+ else
+ ::DrawPicture( (PicHandle) GetPict(), &bitmaprect ) ;
+ }
// Copy data into image
index = 0;
for (int yy = 0; yy < height; yy++)
data[index ] = r;
data[index + 1] = g;
data[index + 2] = b;
- if (mask)
- {
- if (mask->PointMasked(xx,yy))
- {
+ if ( maskRgn )
+ {
+ Point pt ;
+ pt.h = xx ;
+ pt.v = yy ;
+ if ( !PtInRgn( pt , maskRgn ) )
+ {
data[index ] = mask_r;
data[index + 1] = mask_g;
data[index + 2] = mask_b;
- }
+ }
+ }
+ else
+ {
+ if (mask)
+ {
+ if (mask->PointMasked(xx,yy))
+ {
+ data[index ] = mask_r;
+ data[index + 1] = mask_g;
+ data[index + 2] = mask_b;
+ }
+ }
}
index += 3;
}
}
- if (mask)
+ if (mask || maskRgn )
{
image.SetMaskColour( mask_r, mask_g, mask_b );
image.SetMask( true );
}
// Free resources
- UnlockPixels(GetGWorldPixMap( (GWorldPtr) GetHBITMAP()));
+ UnlockPixels(GetGWorldPixMap( tempPort ));
SetGWorld(origPort, origDevice);
+ if ( GetBitmapType() != kMacBitmapTypeGrafWorld )
+ {
+ wxMacDestroyGWorld( tempPort ) ;
+ }
+ if ( maskRgn )
+ {
+ DisposeRgn( maskRgn ) ;
+ }
return image;
}
*/
wxMask::wxMask()
+ : m_maskBitmap(NULL)
{
- m_maskBitmap = 0;
}
// Construct a mask from a bitmap and a colour indicating
// the transparent area
wxMask::wxMask(const wxBitmap& bitmap, const wxColour& colour)
+ : m_maskBitmap(NULL)
{
- m_maskBitmap = 0;
Create(bitmap, colour);
}
// Construct a mask from a bitmap and a palette index indicating
// the transparent area
wxMask::wxMask(const wxBitmap& bitmap, int paletteIndex)
+ : m_maskBitmap(NULL)
{
- m_maskBitmap = 0;
Create(bitmap, paletteIndex);
}
// Construct a mask from a mono bitmap (copies the bitmap).
wxMask::wxMask(const wxBitmap& bitmap)
+ : m_maskBitmap(NULL)
{
- m_maskBitmap = 0;
Create(bitmap);
}
// the transparent area
bool wxMask::Create(const wxBitmap& bitmap, int paletteIndex)
{
-// TODO
- wxCHECK_MSG( 0, false, wxT("Not implemented"));
+ // TODO
+ wxCHECK_MSG( 0, false, wxT("wxMask::Create not yet implemented"));
return FALSE;
}
* wxBitmapHandler
*/
+wxBitmapHandler::~wxBitmapHandler()
+{
+}
+
bool wxBitmapHandler::Create(wxBitmap *bitmap, void *data, long type, int width, int height, int depth)
{
return FALSE;