* When cloning the ref data, copy the NSBitmapImageRep instead of retaining it

* Added SetNSBitmapImageRep so that wxMemoryDC can update the contents by
  replacing the entire NSBitmapImageRep.
* Added ability to create bitmaps from width/height


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@22704 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Elliott 2003-08-08 14:49:53 +00:00
parent 4e209a2064
commit ab13160e71
2 changed files with 29 additions and 2 deletions

View File

@ -144,6 +144,7 @@ public:
// wxCocoa
WX_NSBitmapImageRep GetNSBitmapImageRep();
void SetNSBitmapImageRep(WX_NSBitmapImageRep bitmapImageRep);
static void InitStandardHandlers() { }
static void CleanUpHandlers() { }

View File

@ -70,8 +70,7 @@ wxBitmapRefData::wxBitmapRefData( const wxBitmapRefData& data)
m_numColors = data.m_numColors;
m_bitmapPalette = data.m_bitmapPalette;
m_quality = data.m_quality;
m_cocoaNSBitmapImageRep = data.m_cocoaNSBitmapImageRep;
[m_cocoaNSBitmapImageRep retain];
m_cocoaNSBitmapImageRep = [data.m_cocoaNSBitmapImageRep copyWithZone:nil];
m_bitmapMask = data.m_bitmapMask?new wxMask(*data.m_bitmapMask):NULL;
}
@ -142,6 +141,16 @@ WX_NSBitmapImageRep wxBitmap::GetNSBitmapImageRep()
return M_BITMAPDATA->m_cocoaNSBitmapImageRep;
}
void wxBitmap::SetNSBitmapImageRep(WX_NSBitmapImageRep bitmapImageRep)
{
if(!M_BITMAPDATA)
return;
// NOTE: No checking is done to make sure width/height agree
[bitmapImageRep retain];
[M_BITMAPDATA->m_cocoaNSBitmapImageRep release];
M_BITMAPDATA->m_cocoaNSBitmapImageRep = bitmapImageRep;
}
void wxBitmap::SetWidth(int w)
{
if (!M_BITMAPDATA)
@ -249,6 +258,23 @@ bool wxBitmap::Create(int w, int h, int d)
M_BITMAPDATA->m_depth = d;
/* TODO: create new bitmap */
M_BITMAPDATA->m_cocoaNSBitmapImageRep = [[NSBitmapImageRep alloc]
initWithBitmapDataPlanes: NULL
pixelsWide: w
pixelsHigh: h
bitsPerSample: 8
samplesPerPixel: 3
hasAlpha: NO
isPlanar: NO
colorSpaceName: NSCalibratedRGBColorSpace
bytesPerRow: 0
bitsPerPixel: 0];
wxLogDebug("M_BITMAPDATA=%p NSBitmapImageRep bitmapData=%p", M_BITMAPDATA, [M_BITMAPDATA->m_cocoaNSBitmapImageRep bitmapData]);
M_BITMAPDATA->m_ok = true;
M_BITMAPDATA->m_numColors = 0;
M_BITMAPDATA->m_quality = 0;
M_BITMAPDATA->m_bitmapMask = NULL;
return M_BITMAPDATA->m_ok;
}