X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2aeec9ecccdb1b051848768f45a4ac1859ded5f3..d9e2e4c2425b8338ff6e6cd2fb62438c9fb2a12b:/include/wx/msw/bitmap.h diff --git a/include/wx/msw/bitmap.h b/include/wx/msw/bitmap.h index 2aab4a41ee..75b41e7521 100644 --- a/include/wx/msw/bitmap.h +++ b/include/wx/msw/bitmap.h @@ -24,43 +24,13 @@ class WXDLLEXPORT wxDC; class WXDLLEXPORT wxControl; class WXDLLEXPORT wxBitmap; class WXDLLEXPORT wxBitmapHandler; +class WXDLLEXPORT wxBitmapRefData; class WXDLLEXPORT wxIcon; class WXDLLEXPORT wxMask; class WXDLLEXPORT wxCursor; class WXDLLEXPORT wxControl; class WXDLLEXPORT wxImage; - -// ---------------------------------------------------------------------------- -// Bitmap data -// -// NB: this class is private, but declared here to make it possible inline -// wxBitmap functions accessing it -// ---------------------------------------------------------------------------- - -class WXDLLEXPORT wxBitmapRefData : public wxGDIImageRefData -{ -public: - wxBitmapRefData(); - virtual ~wxBitmapRefData() { Free(); } - - virtual void Free(); - -public: - int m_numColors; - wxPalette m_bitmapPalette; - int m_quality; - - // MSW-specific - // ------------ - - // this field is solely for error checking: we detect selecting a bitmap - // into more than one DC at once or deleting a bitmap still selected into a - // DC (both are serious programming errors under Windows) - wxDC *m_selectedInto; - - // optional mask for transparent drawing - wxMask *m_bitmapMask; -}; +class WXDLLEXPORT wxPalette; // ---------------------------------------------------------------------------- // wxBitmap: a mono or colour bitmap @@ -90,9 +60,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); } + 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! @@ -121,11 +94,13 @@ public: virtual ~wxBitmap(); +#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); @@ -137,36 +112,50 @@ public: virtual bool LoadFile(const wxString& name, long type = wxBITMAP_TYPE_BMP_RESOURCE); virtual bool SaveFile(const wxString& name, int type, const wxPalette *cmap = NULL); - wxBitmapRefData *GetBitmapData() const { return (wxBitmapRefData *)m_refData; } + wxBitmapRefData *GetBitmapData() const + { return (wxBitmapRefData *)m_refData; } - int GetQuality() const { return (GetBitmapData() ? GetBitmapData()->m_quality : 0); } - void SetQuality(int q); - - wxPalette* GetPalette() const { return (GetBitmapData() ? (& GetBitmapData()->m_bitmapPalette) : (wxPalette*) NULL); } +#if wxUSE_PALETTE + wxPalette* GetPalette() const; void SetPalette(const wxPalette& palette); +#endif // wxUSE_PALETTE - wxMask *GetMask() const { return (GetBitmapData() ? GetBitmapData()->m_bitmapMask : (wxMask*) NULL); } - void SetMask(wxMask *mask) ; + wxMask *GetMask() const; + void SetMask(wxMask *mask); bool operator==(const wxBitmap& bitmap) const { return m_refData == bitmap.m_refData; } bool operator!=(const wxBitmap& bitmap) const { return m_refData != bitmap.m_refData; } + // this function is internal and shouldn't be used, it risks to disappear + bool HasAlpha() const; + +#if WXWIN_COMPATIBILITY_2_4 + // these functions do nothing and are only there for backwards + // compatibility + wxDEPRECATED( int GetQuality() const ); + wxDEPRECATED( void SetQuality(int quality) ); +#endif // WXWIN_COMPATIBILITY_2_4 + #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: void SetHBITMAP(WXHBITMAP bmp) { SetHandle((WXHANDLE)bmp); } WXHBITMAP GetHBITMAP() const { return (WXHBITMAP)GetHandle(); } - void SetSelectedInto(wxDC *dc) { if (GetBitmapData()) GetBitmapData()->m_selectedInto = dc; } - wxDC *GetSelectedInto() const { return (GetBitmapData() ? GetBitmapData()->m_selectedInto : (wxDC*) NULL); } +#ifdef __WXDEBUG__ + void SetSelectedInto(wxDC *dc); + wxDC *GetSelectedInto() const; +#endif // __WXDEBUG__ // Creates a bitmap that matches the device context's depth, from an // arbitray bitmap. At present, the original bitmap must have an associated @@ -186,14 +175,21 @@ protected: // common part of all ctors void Init(); - virtual wxGDIImageRefData *CreateData() const - { return new wxBitmapRefData; } + virtual wxGDIImageRefData *CreateData() const; // 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 + +#if wxUSE_DIB_FOR_BITMAP + void *CreateDIB(int width, int height, int depth); + void CopyDIBLine(void* src, void* dest, int count) const; +#endif // wxUSE_DIB_FOR_BITMAP private: #ifdef __WIN32__