X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8208e181cb576ec6cda37624923f95a59af43072..b4b830ec00c099ae83596fa3fe9d8a4398fd2929:/include/wx/msw/bitmap.h?ds=sidebyside diff --git a/include/wx/msw/bitmap.h b/include/wx/msw/bitmap.h index d71506f944..dff632bbb3 100644 --- a/include/wx/msw/bitmap.h +++ b/include/wx/msw/bitmap.h @@ -28,6 +28,8 @@ class WXDLLEXPORT wxIcon; class WXDLLEXPORT wxMask; class WXDLLEXPORT wxCursor; class WXDLLEXPORT wxControl; +class WXDLLEXPORT wxImage; +class WXDLLEXPORT wxPalette; // ---------------------------------------------------------------------------- // Bitmap data @@ -46,7 +48,9 @@ public: public: int m_numColors; +#if wxUSE_PALETTE wxPalette m_bitmapPalette; +#endif // wxUSE_PALETTE int m_quality; // MSW-specific @@ -78,10 +82,11 @@ 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); + wxBitmap(const wxString& name, wxBitmapType type = wxBITMAP_TYPE_BMP_RESOURCE); // New constructor for generalised creation from data wxBitmap(void *data, long type, int width, int height, int depth = 1); @@ -89,6 +94,12 @@ public: // If depth is omitted, will create a bitmap compatible with the display wxBitmap(int width, int height, int depth = -1); +#if wxUSE_IMAGE + // Convert from wxImage: + wxBitmap(const wxImage& image, int depth = -1) + { (void)CreateFromImage(image, depth); } +#endif // wxUSE_IMAGE + // we must have this, otherwise icons are silently copied into bitmaps using // the copy ctor but the resulting bitmap is invalid! wxBitmap(const wxIcon& icon) { Init(); CopyFromIcon(icon); } @@ -116,9 +127,13 @@ public: virtual ~wxBitmap(); - // GRG, Dic/99 +#if wxUSE_IMAGE + wxImage ConvertToImage() const; +#endif // wxUSE_IMAGE + + // 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); @@ -135,23 +150,27 @@ public: int GetQuality() const { return (GetBitmapData() ? GetBitmapData()->m_quality : 0); } void SetQuality(int q); +#if wxUSE_PALETTE wxPalette* GetPalette() const { return (GetBitmapData() ? (& GetBitmapData()->m_bitmapPalette) : (wxPalette*) NULL); } void SetPalette(const wxPalette& palette); +#endif // wxUSE_PALETTE 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); #endif // WXWIN_COMPATIBILITY_2 +#if wxUSE_PALETTE #if WXWIN_COMPATIBILITY wxPalette *GetColourMap() const { return GetPalette(); } void SetColourMap(wxPalette *cmap) { SetPalette(*cmap); }; #endif // WXWIN_COMPATIBILITY +#endif // wxUSE_PALETTE // Implementation public: @@ -182,6 +201,14 @@ 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); + +#if wxUSE_IMAGE + // creates the bitmap from wxImage, supposed to be called from ctor + bool CreateFromImage(const wxImage& image, int depth); +#endif // wxUSE_IMAGE + private: #ifdef __WIN32__ // common part of CopyFromIcon/CopyFromCursor for Win32