X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6a5c31c2853ed9e6290da4b534bd4078e961e438..eea4d01c65f9b29baa1193db762b4c6b8144af24:/src/cocoa/bitmap.mm diff --git a/src/cocoa/bitmap.mm b/src/cocoa/bitmap.mm index 58f1c729fb..16ca2a7847 100644 --- a/src/cocoa/bitmap.mm +++ b/src/cocoa/bitmap.mm @@ -6,7 +6,7 @@ // Created: 2003/07/19 // RCS-ID: $Id$ // Copyright: (c) 2003 David Elliott -// Licence: wxWidgets licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #include "wx/wxprec.h" @@ -39,6 +39,7 @@ IMPLEMENT_ABSTRACT_CLASS(wxBitmapHandler, wxBitmapHandlerBase) // ======================================================================== // wxBitmapRefData // ======================================================================== + class wxBitmapRefData: public wxGDIRefData { friend class wxBitmap; @@ -61,8 +62,6 @@ protected: wxMask *m_bitmapMask; // Optional mask }; -#define M_BITMAPDATA ((wxBitmapRefData *)m_refData) - wxBitmapRefData::wxBitmapRefData() { m_ok = FALSE; @@ -102,6 +101,9 @@ wxBitmapRefData::~wxBitmapRefData() // ======================================================================== // wxBitmap // ======================================================================== + +#define M_BITMAPDATA ((wxBitmapRefData *)m_refData) + IMPLEMENT_DYNAMIC_CLASS(wxBitmap, wxGDIObject) wxBitmap::wxBitmap() @@ -125,11 +127,6 @@ wxBitmap::wxBitmap(const char bits[], int the_width, int the_height, int no_bits /* TODO: create the bitmap from data */ } -wxBitmap::wxBitmap(int w, int h, int d) -{ - (void)Create(w, h, d); -} - wxBitmap::wxBitmap(NSImage* cocoaNSImage) { (void) Create(cocoaNSImage); @@ -169,7 +166,7 @@ WX_NSBitmapImageRep wxBitmap::GetNSBitmapImageRep() WX_NSImage wxBitmap::GetNSImage(bool useMask) const { - if(!Ok()) + if(!IsOk()) return nil; NSImage *nsimage = [[[NSImage alloc] initWithSize:NSMakeSize(GetWidth(), GetHeight())] autorelease]; @@ -354,7 +351,7 @@ bool wxBitmap::LoadFile(const wxString& filename, wxBitmapType type) wxImage image; if(!image.LoadFile(filename,type)) return false; - if(!image.Ok()) + if(!image.IsOk()) return false; *this = wxBitmap(image); return true; @@ -431,7 +428,7 @@ bool wxBitmap::CopyFromIcon(const wxIcon& icon) wxBitmap wxBitmap::GetSubBitmap(const wxRect& rect) const { wxAutoNSAutoreleasePool pool; - if(!Ok()) + if(!IsOk()) return wxNullBitmap; NSImage *nsimage = GetNSImage(false); @@ -439,8 +436,8 @@ wxBitmap wxBitmap::GetSubBitmap(const wxRect& rect) const NSRect imageRect = {{0,0}, [nsimage size]}; imageRect.origin.x = imageRect.size.width * rect.x / GetWidth(); imageRect.origin.y = imageRect.size.height * rect.y / GetHeight(); - imageRect.size.width *= wx_static_cast(CGFloat, rect.width) / GetWidth(); - imageRect.size.height *= wx_static_cast(CGFloat, rect.height) / GetHeight(); + imageRect.size.width *= static_cast(rect.width) / GetWidth(); + imageRect.size.height *= static_cast(rect.height) / GetHeight(); NSBitmapImageRep *newBitmapRep = [[NSBitmapImageRep alloc] initWithFocusedViewRect:imageRect]; [nsimage unlockFocus]; @@ -453,7 +450,7 @@ wxBitmap wxBitmap::GetSubBitmap(const wxRect& rect) const wxImage wxBitmap::ConvertToImage() const { wxAutoNSAutoreleasePool pool; - if(!Ok()) + if(!IsOk()) return /*wxImage(5,5)*/wxNullImage; NSImage *nsimage = GetNSImage(false /* don't use mask */); wxImage newImage(M_BITMAPDATA->m_width,M_BITMAPDATA->m_height); @@ -479,7 +476,7 @@ bool wxBitmap::CreateFromImage(const wxImage& image, int depth) wxAutoNSAutoreleasePool pool; UnRef(); - wxCHECK_MSG(image.Ok(), false, wxT("invalid image")); + wxCHECK_MSG(image.IsOk(), false, wxT("invalid image")); wxCHECK_MSG(depth == -1 || depth == 1, false, wxT("invalid bitmap depth")); m_refData = new wxBitmapRefData(); @@ -514,7 +511,7 @@ bool wxBitmap::CreateFromImage(const wxImage& image, int depth) void *wxBitmap::GetRawData(wxPixelDataBase& data, int bpp) { - if(!Ok()) + if(!IsOk()) return NULL; NSBitmapImageRep *bitmapRep = M_BITMAPDATA->m_cocoaNSBitmapImageRep; @@ -523,7 +520,7 @@ void *wxBitmap::GetRawData(wxPixelDataBase& data, int bpp) if([bitmapRep bitsPerPixel]!=bpp) { - wxFAIL_MSG( _T("incorrect bitmap type in wxBitmap::GetRawData()") ); + wxFAIL_MSG( wxT("incorrect bitmap type in wxBitmap::GetRawData()") ); return NULL; } data.m_width = [bitmapRep pixelsWide]; @@ -660,7 +657,7 @@ static bool wxMask_CreateFromBitmapData(PixelData srcData, const wxColour& colou bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour) { wxAutoNSAutoreleasePool pool; - if(!bitmap.Ok()) + if(!bitmap.IsOk()) return false; int bmpWidth = bitmap.GetWidth(); int bmpHeight = bitmap.GetHeight();