X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3f399a69cceccea1f955dab85af0c21b361c78a0..809f39fe42dbc118540dfa2c18c6f3f538f68752:/include/wx/msw/bitmap.h diff --git a/include/wx/msw/bitmap.h b/include/wx/msw/bitmap.h index 82b5d30251..d96f86a163 100644 --- a/include/wx/msw/bitmap.h +++ b/include/wx/msw/bitmap.h @@ -28,6 +28,7 @@ class WXDLLEXPORT wxIcon; class WXDLLEXPORT wxMask; class WXDLLEXPORT wxCursor; class WXDLLEXPORT wxControl; +class WXDLLEXPORT wxImage; // ---------------------------------------------------------------------------- // Bitmap data @@ -78,7 +79,8 @@ public: wxBitmap(const char bits[], int width, int height, int depth = 1); // Initialize with XPM data - wxBitmap(char **data, wxControl *anItem = NULL); + wxBitmap(const char **data) { CreateFromXpm(data); } + wxBitmap(char **data) { CreateFromXpm((const char **)data); } // Load a file or resource wxBitmap(const wxString& name, long type = wxBITMAP_TYPE_BMP_RESOURCE); @@ -88,6 +90,9 @@ public: // If depth is omitted, will create a bitmap compatible with the display wxBitmap(int width, int height, int depth = -1); + + // Convert from wxImage: + wxBitmap(const wxImage& image, int depth = -1) { (void)CreateFromImage(image, depth); } // we must have this, otherwise icons are silently copied into bitmaps using // the copy ctor but the resulting bitmap is invalid! @@ -116,8 +121,10 @@ public: virtual ~wxBitmap(); - // GRG, Dic/99 - wxBitmap wxBitmap::GetSubBitmap( const wxRect& rect ) const; + wxImage ConvertToImage() const; + + // get the given part of bitmap + wxBitmap GetSubBitmap( const wxRect& rect ) const; // copies the contents and mask of the given (colour) icon to the bitmap bool CopyFromIcon(const wxIcon& icon); @@ -141,8 +148,8 @@ public: wxMask *GetMask() const { return (GetBitmapData() ? GetBitmapData()->m_bitmapMask : (wxMask*) NULL); } void SetMask(wxMask *mask) ; - bool operator==(const wxBitmap& bitmap) { return m_refData == bitmap.m_refData; } - bool operator!=(const wxBitmap& bitmap) { return m_refData != bitmap.m_refData; } + bool operator==(const wxBitmap& bitmap) const { return m_refData == bitmap.m_refData; } + bool operator!=(const wxBitmap& bitmap) const { return m_refData != bitmap.m_refData; } #if WXWIN_COMPATIBILITY_2 void SetOk(bool isOk); @@ -182,6 +189,12 @@ protected: virtual wxGDIImageRefData *CreateData() const { return new wxBitmapRefData; } + // creates the bitmap from XPM data, supposed to be called from ctor + bool CreateFromXpm(const char **bits); + // creates the bitmap from wxImage, supposed to be called from ctor + bool CreateFromImage(const wxImage& image, int depth); + + private: #ifdef __WIN32__ // common part of CopyFromIcon/CopyFromCursor for Win32