add wxSize overloads to wxBitmap ctors and to wxBitmap::Create

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@59526 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Francesco Montorsi
2009-03-14 13:57:51 +00:00
parent 72a9034bd4
commit 732d8c74f8
22 changed files with 129 additions and 119 deletions

View File

@@ -148,6 +148,7 @@ public:
wxBitmap(const wxBitmap& bmp);
wxBitmap(const char bits[], int width, int height, int depth = 1);
wxBitmap(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH);
wxBitmap(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH);
wxBitmap(const char* const* bits);
wxBitmap(const wxString &filename, wxBitmapType type = wxBITMAP_TYPE_XPM);
wxBitmap(const wxImage& image, int depth = wxBITMAP_SCREEN_DEPTH);
@@ -156,6 +157,7 @@ public:
*/
virtual bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH) = 0;
virtual bool Create(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH) = 0;
virtual int GetHeight() const = 0;
virtual int GetWidth() const = 0;

View File

@@ -59,9 +59,11 @@ protected:
WX_NSBitmapImageRep m_cocoaNSBitmapImageRep;
};
// ========================================================================
// wxBitmap
// ========================================================================
class WXDLLIMPEXP_CORE wxBitmap: public wxGDIObject
{
// ------------------------------------------------------------------------
@@ -83,7 +85,10 @@ public:
// Constructor for generalised creation from data
wxBitmap(const void* data, wxBitmapType type, int width, int height, int depth = 1);
// If depth is omitted, will create a bitmap compatible with the display
wxBitmap(int width, int height, int depth = -1);
wxBitmap(int width, int height, int depth = -1)
{ (void)Create(width, height, depth); }
wxBitmap(const wxSize& sz, int depth = -1)
{ (void)Create(sz, depth); }
// Convert from wxImage:
wxBitmap(const wxImage& image, int depth = -1)
{ CreateFromImage(image, depth); }
@@ -100,7 +105,10 @@ public:
// Initialize from wxImage
bool CreateFromImage(const wxImage& image, int depth=-1);
virtual bool Create(int width, int height, int depth = -1);
virtual bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH);
virtual bool Create(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH)
{ return Create(sz.GetWidth(), sz.GetHeight(), depth); }
bool Create(NSImage* cocoaNSImage);
bool Create(NSBitmapImageRep* cocoaNSBitmapImageRep);
virtual bool Create(const void* data, wxBitmapType type, int width, int height, int depth = 1);

View File

@@ -26,7 +26,8 @@ class WXDLLIMPEXP_CORE wxBitmap : public wxBitmapBase
public:
wxBitmap() {}
wxBitmap(const wxIDirectFBSurfacePtr& surface) { Create(surface); }
wxBitmap(int width, int height, int depth = -1);
wxBitmap(int width, int height, int depth = -1) { Create(width, height, depth); }
wxBitmap(const wxSize& sz, int depth = -1) { Create(sz, depth); }
wxBitmap(const char bits[], int width, int height, int depth = 1);
wxBitmap(const wxString &filename, wxBitmapType type = wxBITMAP_DEFAULT_TYPE);
wxBitmap(const char* const* bits);
@@ -35,7 +36,9 @@ public:
#endif
bool Create(const wxIDirectFBSurfacePtr& surface);
bool Create(int width, int height, int depth = -1);
bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH);
bool Create(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH)
{ return Create(sz.GetWidth(), sz.GetHeight(), depth); }
virtual int GetHeight() const;
virtual int GetWidth() const;

View File

@@ -51,7 +51,10 @@ class WXDLLIMPEXP_CORE wxBitmap: public wxBitmapBase
{
public:
wxBitmap() { }
wxBitmap( int width, int height, int depth = wxBITMAP_SCREEN_DEPTH );
wxBitmap( int width, int height, int depth = wxBITMAP_SCREEN_DEPTH )
{ Create(width, height, depth); }
wxBitmap( const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH )
{ Create(sz, depth); }
wxBitmap( const char bits[], int width, int height, int depth = 1 );
wxBitmap( const char* const* bits );
#ifdef wxNEEDS_CHARPP
@@ -67,6 +70,8 @@ public:
virtual ~wxBitmap();
bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH);
bool Create(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH)
{ return Create(sz.GetWidth(), sz.GetHeight(), depth); }
virtual int GetHeight() const;
virtual int GetWidth() const;

View File

@@ -64,8 +64,9 @@ private:
class WXDLLIMPEXP_CORE wxBitmap: public wxBitmapBase
{
public:
wxBitmap();
wxBitmap( int width, int height, int depth = -1 );
wxBitmap() {}
wxBitmap( int width, int height, int depth = -1 ) { Create( width, height, depth ); }
wxBitmap( const wxSize& sz, int depth = -1 ) { Create( sz, depth ); }
wxBitmap( const char bits[], int width, int height, int depth = 1 );
wxBitmap( const char* const* bits );
#ifdef wxNEEDS_CHARPP
@@ -79,7 +80,9 @@ public:
wxBitmap( const wxImage& image, int depth = -1 ) { (void)CreateFromImage(image, depth); }
virtual ~wxBitmap();
bool Create(int width, int height, int depth = -1);
bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH);
bool Create(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH)
{ return Create(sz.GetWidth(), sz.GetHeight(), depth); }
virtual int GetHeight() const;
virtual int GetWidth() const;

View File

@@ -27,14 +27,19 @@ class WXDLLIMPEXP_CORE wxBitmap: public wxBitmapBase
{
public:
wxBitmap() {}
wxBitmap(int width, int height, int depth = -1);
wxBitmap(int width, int height, int depth = -1)
{ Create(width, height, depth); }
wxBitmap(const wxSize& sz, int depth = -1)
{ Create(sz, depth); }
wxBitmap(const char bits[], int width, int height, int depth = 1);
wxBitmap(const char* const* bits);
wxBitmap(const wxString &filename, wxBitmapType type = wxBITMAP_DEFAULT_TYPE);
wxBitmap(const wxImage& image, int depth = -1);
virtual ~wxBitmap() {}
bool Create(int width, int height, int depth = -1);
bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH);
bool Create(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH)
{ return Create(sz.GetWidth(), sz.GetHeight(), depth); }
virtual int GetHeight() const;
virtual int GetWidth() const;

View File

@@ -73,7 +73,8 @@ public:
//
// NB: this ctor will create a DIB for 24 and 32bpp bitmaps, use ctor
// taking a DC argument if you want to force using DDB in this case
wxBitmap(int width, int height, int depth = -1);
wxBitmap(int width, int height, int depth = -1) { (void)Create(width, height, depth); }
wxBitmap(const wxSize& sz, int depth = -1) { (void)Create(sz, depth); }
// Create a bitmap compatible with the given DC
wxBitmap(int width, int height, const wxDC& dc);
@@ -137,6 +138,9 @@ public:
#endif
virtual bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH);
virtual bool Create(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH)
{ return Create(sz.GetWidth(), sz.GetHeight(), depth); }
virtual bool Create(int width, int height, const wxDC& dc);
virtual bool Create(const void* data, wxBitmapType type, int width, int height, int depth = 1);
virtual bool LoadFile(const wxString& name, wxBitmapType type = wxBITMAP_DEFAULT_TYPE);

View File

@@ -114,7 +114,16 @@ public:
);
// If depth is omitted, will create a bitmap compatible with the display
wxBitmap( int nWidth, int nHeight, int nDepth = -1 );
wxBitmap( int nWidth, int nHeight, int nDepth = -1 )
{
Init();
(void)Create(nWidth, nHeight, nDepth);
}
wxBitmap( const wxSize& sz, int nDepth = -1 )
{
Init();
(void)Create(sz, nDepth);
}
wxBitmap( const wxImage& image, int depth = -1 )
{ (void)CreateFromImage(image, depth); }
@@ -152,8 +161,11 @@ public:
virtual bool Create( int nWidth
,int nHeight
,int nDepth = -1
,int nDepth = wxBITMAP_SCREEN_DEPTH
);
virtual bool Create(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH)
{ return Create(sz.GetWidth(), sz.GetHeight(), depth); }
virtual bool Create( const void* pData
,wxBitmapType lType
,int nWidth

View File

@@ -87,7 +87,7 @@ class WXDLLIMPEXP_CORE wxBitmap: public wxBitmapBase
friend class WXDLLIMPEXP_FWD_CORE wxBitmapHandler;
public:
wxBitmap(); // Platform-specific
wxBitmap() {} // Platform-specific
// Initialize with raw data.
wxBitmap(const char bits[], int width, int height, int depth = 1);
@@ -102,7 +102,8 @@ public:
wxBitmap(const void* data, wxBitmapType type, int width, int height, int depth = 1);
// If depth is omitted, will create a bitmap compatible with the display
wxBitmap(int width, int height, int depth = -1);
wxBitmap(int width, int height, int depth = -1) { (void)Create(width, height, depth); }
wxBitmap(const wxSize& sz, int depth = -1) { (void)Create(sz, depth); }
// Convert from wxImage:
wxBitmap(const wxImage& image, int depth = -1);
@@ -110,14 +111,17 @@ public:
// Convert from wxIcon
wxBitmap(const wxIcon& icon) { CopyFromIcon(icon); }
virtual ~wxBitmap();
virtual ~wxBitmap() {}
wxImage ConvertToImage() const;
// get the given part of bitmap
wxBitmap GetSubBitmap( const wxRect& rect ) const;
virtual bool Create(int width, int height, int depth = -1);
virtual bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH);
virtual bool Create(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH)
{ return Create(sz.GetWidth(), sz.GetHeight(), depth); }
virtual bool Create(const void* data, wxBitmapType type, int width, int height, int depth = 1);
// virtual bool Create( WXHICON icon) ;
virtual bool LoadFile(const wxString& name, wxBitmapType type = wxBITMAP_DEFAULT_TYPE);

View File

@@ -58,7 +58,8 @@ public:
//
// NB: this ctor will create a DIB for 24 and 32bpp bitmaps, use ctor
// taking a DC argument if you want to force using DDB in this case
wxBitmap(int width, int height, int depth = -1);
wxBitmap(int width, int height, int depth = -1) { /*TODO*/ }
wxBitmap(const wxSize& sz, int depth = -1) { /*TODO*/ }
// Create a bitmap compatible with the given DC
wxBitmap(int width, int height, const wxDC& dc);
@@ -91,7 +92,7 @@ public:
return *this;
}
virtual ~wxBitmap();
virtual ~wxBitmap() {}
#if wxUSE_IMAGE && wxUSE_WXDIB
wxImage ConvertToImage() const;
@@ -111,7 +112,10 @@ public:
bool CopyFromDIB(const wxDIB& dib);
#endif
virtual bool Create(int width, int height, int depth = -1);
virtual bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH);
virtual bool Create(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH)
{ return Create(sz.GetWidth(), sz.GetHeight(), depth); }
virtual bool Create(int width, int height, const wxDC& dc);
virtual bool Create(const void* data, long type, int width, int height, int depth = 1);
virtual bool LoadFile(const wxString& name, long type = wxBITMAP_DEFAULT_TYPE);

View File

@@ -65,8 +65,10 @@ private:
class WXDLLIMPEXP_CORE wxBitmap: public wxBitmapBase
{
public:
wxBitmap();
wxBitmap( int width, int height, int depth = -1 );
wxBitmap() {}
wxBitmap( int width, int height, int depth = -1 ) { Create( width, height, depth ); }
wxBitmap( const wxSize& sz, int depth = -1 ) { Create( sz, depth ); }
wxBitmap( const char bits[], int width, int height, int depth = 1 );
wxBitmap( const char* const* bits );
#ifdef wxNEEDS_CHARPP
@@ -81,7 +83,10 @@ public:
static void InitStandardHandlers();
bool Create(int width, int height, int depth = -1);
bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH);
bool Create(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH)
{ return Create(sz.GetWidth(), sz.GetHeight(), depth); }
bool Create(const void* data, wxBitmapType type,
int width, int height, int depth = -1);
// create the wxBitmap using a _copy_ of the pixmap

View File

@@ -274,6 +274,11 @@ public:
*/
wxBitmap(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH);
/**
@overload
*/
wxBitmap(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH);
/**
Creates a bitmap from XPM data.
*/
@@ -375,10 +380,15 @@ public:
Creates a fresh bitmap.
If the final argument is omitted, the display depth of the screen is used.
This overload works on all platforms.
@return @true if the creation was successful.
*/
virtual bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH);
/**
@overload
*/
virtual bool Create(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH);
/*
Creates a bitmap from the given data, which can be of arbitrary type.

View File

@@ -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);

View File

@@ -394,11 +394,6 @@ public:
IMPLEMENT_DYNAMIC_CLASS(wxBitmap, wxBitmapBase)
wxBitmap::wxBitmap(int width, int height, int depth)
{
Create(width, height, depth);
}
bool wxBitmap::Create(const wxIDirectFBSurfacePtr& surface)
{
UnRef();

View File

@@ -179,7 +179,7 @@ GdkBitmap *wxMask::GetBitmap() const
}
//-----------------------------------------------------------------------------
// wxBitmap
// wxBitmapRefData
//-----------------------------------------------------------------------------
class wxBitmapRefData: public wxGDIRefData
@@ -226,17 +226,15 @@ wxBitmapRefData::~wxBitmapRefData()
#endif // wxUSE_PALETTE
}
//-----------------------------------------------------------------------------
// wxBitmap
//-----------------------------------------------------------------------------
#define M_BMPDATA static_cast<wxBitmapRefData*>(m_refData)
IMPLEMENT_DYNAMIC_CLASS(wxBitmap,wxGDIObject)
wxBitmap::wxBitmap(int width, int height, int depth)
{
Create(width, height, depth);
}
wxBitmap::wxBitmap(const wxString &filename, wxBitmapType type)
{
LoadFile(filename, type);

View File

@@ -220,8 +220,9 @@ GdkBitmap *wxMask::GetBitmap() const
return m_bitmap;
}
//-----------------------------------------------------------------------------
// wxBitmap
// wxBitmapRefData
//-----------------------------------------------------------------------------
class wxBitmapRefData : public wxGDIRefData
@@ -347,21 +348,15 @@ wxBitmapRefData::~wxBitmapRefData()
#endif // wxUSE_PALETTE
}
//-----------------------------------------------------------------------------
// wxBitmap
//-----------------------------------------------------------------------------
#define M_BMPDATA ((wxBitmapRefData *)m_refData)
IMPLEMENT_DYNAMIC_CLASS(wxBitmap,wxGDIObject)
wxBitmap::wxBitmap()
{
}
wxBitmap::wxBitmap( int width, int height, int depth )
{
Create( width, height, depth );
}
wxGDIRefData *wxBitmap::CreateGDIRefData() const
{
return new wxBitmapRefData;

View File

@@ -58,7 +58,7 @@ static pixel_format_t gs_pixel_format_wxImage =
{0xFF,0x00,0, 0xFF,0x08,0, 0xFF,0x10,0, 0x00,0x00,0}; // RGB 24bpp for wxImage
//-----------------------------------------------------------------------------
// wxBitmap
// wxBitmapRefData
//-----------------------------------------------------------------------------
class wxBitmapRefData: public wxGDIRefData
@@ -163,18 +163,15 @@ wxBitmapRefData::~wxBitmapRefData()
delete m_palette;
}
//-----------------------------------------------------------------------------
// wxBitmap
//-----------------------------------------------------------------------------
#define M_BMPDATA ((wxBitmapRefData *)m_refData)
IMPLEMENT_DYNAMIC_CLASS(wxBitmap,wxBitmapBase)
wxBitmap::wxBitmap(int width, int height, int depth)
{
Create(width, height, depth);
}
wxGDIRefData *wxBitmap::CreateGDIRefData() const
{
return new wxBitmapRefData;

View File

@@ -56,7 +56,7 @@
#endif // no CLR_INVALID
// ----------------------------------------------------------------------------
// Bitmap data
// wxBitmapRefData
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxBitmapRefData : public wxGDIImageRefData
@@ -512,11 +512,6 @@ wxBitmap::wxBitmap(const char bits[], int width, int height, int depth)
#endif
}
wxBitmap::wxBitmap(int w, int h, int d)
{
(void)Create(w, h, d);
}
wxBitmap::wxBitmap(int w, int h, const wxDC& dc)
{
(void)Create(w, h, dc);

View File

@@ -276,19 +276,6 @@ wxBitmap::wxBitmap(
SetHBITMAP((WXHBITMAP)hBmp);
} // end of wxBitmap::wxBitmap
wxBitmap::wxBitmap(
int nW
, int nH
, int nD
)
{
Init();
(void)Create( nW
,nH
,nD
);
} // end of wxBitmap::wxBitmap
wxBitmap::wxBitmap(
const void* pData
, wxBitmapType lType

View File

@@ -785,6 +785,12 @@ wxBitmapRefData::~wxBitmapRefData()
Free() ;
}
// ----------------------------------------------------------------------------
// wxBitmap
// ----------------------------------------------------------------------------
bool wxBitmap::CopyFromIcon(const wxIcon& icon)
{
bool created = false ;
@@ -890,14 +896,6 @@ bool wxBitmap::CopyFromIcon(const wxIcon& icon)
return true;
}
wxBitmap::wxBitmap()
{
}
wxBitmap::~wxBitmap()
{
}
wxBitmap::wxBitmap(const char bits[], int the_width, int the_height, int no_bits)
{
wxBitmapRefData* bitmapRefData;
@@ -952,11 +950,6 @@ wxBitmap::wxBitmap(const char bits[], int the_width, int the_height, int no_bits
} /* bitmapRefData->IsOk() */
}
wxBitmap::wxBitmap(int w, int h, int d)
{
(void)Create(w, h, d);
}
wxBitmap::wxBitmap(const void* data, wxBitmapType type, int width, int height, int depth)
{
(void) Create(data, type, width, height, depth);

View File

@@ -198,19 +198,11 @@ bool wxBitmap::CopyFromDIB(const wxDIB& dib)
#endif // NEVER_USE_DIB
wxBitmap::~wxBitmap()
{
}
wxBitmap::wxBitmap(const char bits[], int width, int height, int depth)
{
Init();
}
wxBitmap::wxBitmap(int w, int h, int d)
{
}
wxBitmap::wxBitmap(int w, int h, const wxDC& dc)
{
}

View File

@@ -224,7 +224,7 @@ bool wxMask::Create( const wxBitmap& bitmap )
}
//-----------------------------------------------------------------------------
// wxBitmap
// wxBitmapRefData
//-----------------------------------------------------------------------------
class wxBitmapRefData : public wxGDIRefData
@@ -347,19 +347,15 @@ static WXPixmap wxGetSubPixmap( WXDisplay* xdisplay, WXPixmap xpixmap,
return (WXPixmap)ret;
}
//-----------------------------------------------------------------------------
// wxBitmap
//-----------------------------------------------------------------------------
#define M_BMPDATA ((wxBitmapRefData *)m_refData)
IMPLEMENT_DYNAMIC_CLASS(wxBitmap,wxGDIObject)
wxBitmap::wxBitmap()
{
}
wxBitmap::wxBitmap( int width, int height, int depth )
{
Create( width, height, depth );
}
bool wxBitmap::Create( int width, int height, int depth )
{
UnRef();