Make wxBitmap::ConvertToDisabled() available in all ports.

This method was defined in wxBitmapBase which is not used by wxMSW (and wxOS2)
so it wasn't available there. Move the definition of the method inline and
reuse it for all ports, making it part of either wxBitmapBase or wxBitmap as
appropriate.

This is clearly ugly but we still have no good solution for deriving wxBitmap
from wxBitmapBase in wxMSW as it already inherits from MSW-specific wxGDIImage
there.

Also document that ConvertToDisabled() is only available when wxUSE_IMAGE==1.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66086 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2010-11-10 13:51:51 +00:00
parent 82302ad45a
commit ac04aa9943
6 changed files with 24 additions and 16 deletions

View File

@@ -19,11 +19,11 @@
#include "wx/string.h"
#include "wx/gdicmn.h" // for wxBitmapType
#include "wx/colour.h"
#include "wx/image.h"
class WXDLLIMPEXP_FWD_CORE wxBitmap;
class WXDLLIMPEXP_FWD_CORE wxBitmapHandler;
class WXDLLIMPEXP_FWD_CORE wxIcon;
class WXDLLIMPEXP_FWD_CORE wxImage;
class WXDLLIMPEXP_FWD_CORE wxMask;
class WXDLLIMPEXP_FWD_CORE wxPalette;
@@ -168,6 +168,9 @@ public:
#if wxUSE_IMAGE
virtual wxImage ConvertToImage() const = 0;
// Convert to disabled (dimmed) bitmap.
wxBitmap ConvertToDisabled(unsigned char brightness = 255) const;
#endif // wxUSE_IMAGE
virtual wxMask *GetMask() const = 0;
@@ -175,9 +178,6 @@ public:
virtual wxBitmap GetSubBitmap(const wxRect& rect) const = 0;
// Convert to disabled (dimmed) bitmap.
wxBitmap ConvertToDisabled(unsigned char brightness = 255) const;
virtual bool SaveFile(const wxString &name, wxBitmapType type,
const wxPalette *palette = NULL) const = 0;
virtual bool LoadFile(const wxString &name, wxBitmapType type) = 0;
@@ -272,6 +272,20 @@ protected:
#include "wx/os2/bitmap.h"
#endif
#if wxUSE_IMAGE
inline
wxBitmap
#if wxUSE_BITMAP_BASE
wxBitmapBase::
#else
wxBitmap::
#endif
ConvertToDisabled(unsigned char brightness) const
{
return ConvertToImage().ConvertToDisabled(brightness);
}
#endif // wxUSE_IMAGE
// we must include generic mask.h after wxBitmap definition
#if defined(__WXMGL__) || defined(__WXDFB__)
#define wxUSE_GENERIC_MASK 1

View File

@@ -25,7 +25,6 @@ class WXDLLIMPEXP_FWD_CORE wxDC;
class WXDLLIMPEXP_FWD_CORE wxDIB;
#endif
class WXDLLIMPEXP_FWD_CORE wxIcon;
class WXDLLIMPEXP_FWD_CORE wxImage;
class WXDLLIMPEXP_FWD_CORE wxMask;
class WXDLLIMPEXP_FWD_CORE wxPalette;
class WXDLLIMPEXP_FWD_CORE wxPixelDataBase;
@@ -115,6 +114,7 @@ public:
#if wxUSE_IMAGE
wxImage ConvertToImage() const;
wxBitmap ConvertToDisabled(unsigned char brightness = 255) const;
#endif // wxUSE_IMAGE
// get the given part of bitmap

View File

@@ -25,7 +25,6 @@ class WXDLLIMPEXP_FWD_CORE wxIcon;
class WXDLLIMPEXP_FWD_CORE wxMask;
class WXDLLIMPEXP_FWD_CORE wxCursor;
class WXDLLIMPEXP_FWD_CORE wxControl;
class WXDLLIMPEXP_FWD_CORE wxImage;
class WXDLLIMPEXP_FWD_CORE wxPixelDataBase;
// ----------------------------------------------------------------------------
@@ -149,6 +148,7 @@ public:
virtual ~wxBitmap();
wxImage ConvertToImage() const;
wxBitmap ConvertToDisabled(unsigned char brightness = 255) const;
// get the given part of bitmap
wxBitmap GetSubBitmap(const wxRect& rRect) const;

View File

@@ -96,6 +96,7 @@ public:
#if wxUSE_IMAGE && wxUSE_WXDIB
wxImage ConvertToImage() const;
wxBitmap ConvertToDisabled(unsigned char brightness = 255) const;
#endif // wxUSE_IMAGE
// get the given part of bitmap

View File

@@ -508,6 +508,9 @@ public:
/**
Returns disabled (dimmed) version of the bitmap.
This method is not available when <code>wxUSE_IMAGE == 0</code>.
@since 2.9.0
*/
wxBitmap ConvertToDisabled(unsigned char brightness = 255) const;

View File

@@ -135,16 +135,6 @@ public:
void OnExit() { wxBitmap::CleanUpHandlers(); }
};
wxBitmap wxBitmapBase::ConvertToDisabled(unsigned char brightness) const
{
wxBitmap bmp;
#if wxUSE_IMAGE
wxImage image = ConvertToImage();
bmp = wxBitmap(image.ConvertToDisabled(brightness));
#endif
return bmp;
}
IMPLEMENT_DYNAMIC_CLASS(wxBitmapBaseModule, wxModule)
#endif // wxUSE_BITMAP_BASE