// Created: 2003/07/19
// RCS-ID: $Id$
// Copyright: (c) 2003 David Elliott
-// Licence: wxWidgets licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#include "wx/wxprec.h"
// ========================================================================
// wxBitmapRefData
// ========================================================================
+
class wxBitmapRefData: public wxGDIRefData
{
friend class wxBitmap;
wxMask *m_bitmapMask; // Optional mask
};
-#define M_BITMAPDATA ((wxBitmapRefData *)m_refData)
-
wxBitmapRefData::wxBitmapRefData()
{
m_ok = FALSE;
// ========================================================================
// wxBitmap
// ========================================================================
+
+#define M_BITMAPDATA ((wxBitmapRefData *)m_refData)
+
IMPLEMENT_DYNAMIC_CLASS(wxBitmap, wxGDIObject)
wxBitmap::wxBitmap()
/* 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);
WX_NSImage wxBitmap::GetNSImage(bool useMask) const
{
- if(!Ok())
+ if(!IsOk())
return nil;
NSImage *nsimage = [[[NSImage alloc]
initWithSize:NSMakeSize(GetWidth(), GetHeight())] autorelease];
wxImage image;
if(!image.LoadFile(filename,type))
return false;
- if(!image.Ok())
+ if(!image.IsOk())
return false;
*this = wxBitmap(image);
return true;
wxBitmap wxBitmap::GetSubBitmap(const wxRect& rect) const
{
wxAutoNSAutoreleasePool pool;
- if(!Ok())
+ if(!IsOk())
return wxNullBitmap;
NSImage *nsimage = GetNSImage(false);
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<CGFloat>(rect.width) / GetWidth();
+ imageRect.size.height *= static_cast<CGFloat>(rect.height) / GetHeight();
NSBitmapImageRep *newBitmapRep = [[NSBitmapImageRep alloc] initWithFocusedViewRect:imageRect];
[nsimage unlockFocus];
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);
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();
void *wxBitmap::GetRawData(wxPixelDataBase& data, int bpp)
{
- if(!Ok())
+ if(!IsOk())
return NULL;
NSBitmapImageRep *bitmapRep = M_BITMAPDATA->m_cocoaNSBitmapImageRep;
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];
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();