Consistently declare wxCursor(wxImage) ctor when wxUSE_IMAGE==1

wxGTK already did it like this, but also only declared ctor not taking
wxImage in this case, while wxMSW and wxMac declared this ctor in any
case, even when wxUSE_IMAGE==0, but didn't define it then.

This doesn't matter much anyhow, as the build with wxUSE_IMAGE==0 is
clearly broken and these changes are not enough to fix it, but be at
least somewhat consistent and:

1. Don't declare methods using a class which is not available at all.
2. Do define methods using wxImage only internally, even if they do
   nothing when it's not available.

No real changes.
This commit is contained in:
Vadim Zeitlin
2021-04-17 19:24:51 +01:00
parent b889f6897b
commit b26fd44c77
7 changed files with 15 additions and 8 deletions

View File

@@ -25,10 +25,10 @@ public:
#endif #endif
#if wxUSE_IMAGE #if wxUSE_IMAGE
wxCursor( const wxImage & image ); wxCursor( const wxImage & image );
#endif // wxUSE_IMAGE
wxCursor(const wxString& name, wxCursor(const wxString& name,
wxBitmapType type = wxCURSOR_DEFAULT_TYPE, wxBitmapType type = wxCURSOR_DEFAULT_TYPE,
int hotSpotX = 0, int hotSpotY = 0); int hotSpotX = 0, int hotSpotY = 0);
#endif
wxCursor( const char bits[], int width, int height, wxCursor( const char bits[], int width, int height,
int hotSpotX = -1, int hotSpotY = -1, int hotSpotX = -1, int hotSpotY = -1,
const char maskBits[] = NULL, const char maskBits[] = NULL,

View File

@@ -19,7 +19,9 @@ class WXDLLIMPEXP_CORE wxCursor : public wxCursorBase
public: public:
// constructors // constructors
wxCursor(); wxCursor();
#if wxUSE_IMAGE
wxCursor(const wxImage& image); wxCursor(const wxImage& image);
#endif // wxUSE_IMAGE
wxCursor(const wxString& name, wxCursor(const wxString& name,
wxBitmapType type = wxCURSOR_DEFAULT_TYPE, wxBitmapType type = wxCURSOR_DEFAULT_TYPE,
int hotSpotX = 0, int hotSpotY = 0); int hotSpotX = 0, int hotSpotY = 0);

View File

@@ -19,7 +19,9 @@ class WXDLLIMPEXP_CORE wxCursor : public wxCursorBase
public: public:
wxCursor(); wxCursor();
#if wxUSE_IMAGE
wxCursor(const wxImage & image) ; wxCursor(const wxImage & image) ;
#endif // wxUSE_IMAGE
wxCursor(const wxString& name, wxCursor(const wxString& name,
wxBitmapType type = wxCURSOR_DEFAULT_TYPE, wxBitmapType type = wxCURSOR_DEFAULT_TYPE,
int hotSpotX = 0, int hotSpotY = 0); int hotSpotX = 0, int hotSpotY = 0);

View File

@@ -22,10 +22,10 @@ public:
#endif #endif
#if wxUSE_IMAGE #if wxUSE_IMAGE
wxCursor( const wxImage & image ); wxCursor( const wxImage & image );
#endif // wxUSE_IMAGE
wxCursor(const wxString& name, wxCursor(const wxString& name,
wxBitmapType type = wxCURSOR_DEFAULT_TYPE, wxBitmapType type = wxCURSOR_DEFAULT_TYPE,
int hotSpotX = 0, int hotSpotY = 0); int hotSpotX = 0, int hotSpotY = 0);
#endif
virtual wxPoint GetHotSpot() const wxOVERRIDE; virtual wxPoint GetHotSpot() const wxOVERRIDE;
QCursor &GetHandle() const; QCursor &GetHandle() const;

View File

@@ -72,7 +72,6 @@ wxCursor::wxCursor()
{ {
} }
#if wxUSE_IMAGE
wxCursor::wxCursor(const wxString& cursor_file, wxCursor::wxCursor(const wxString& cursor_file,
wxBitmapType type, wxBitmapType type,
int hotSpotX, int hotSpotY) int hotSpotX, int hotSpotY)
@@ -88,13 +87,15 @@ wxCursor::wxCursor(const wxString& cursor_file,
img.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_Y, hotSpotY); img.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_Y, hotSpotY);
InitFromImage(img); InitFromImage(img);
#endif // wxUSE_IMAGE
} }
#if wxUSE_IMAGE
wxCursor::wxCursor(const wxImage& img) wxCursor::wxCursor(const wxImage& img)
{ {
InitFromImage(img); InitFromImage(img);
} }
#endif #endif // wxUSE_IMAGE
wxCursor::wxCursor(const char bits[], int width, int height, wxCursor::wxCursor(const char bits[], int width, int height,
int hotSpotX, int hotSpotY, int hotSpotX, int hotSpotY,

View File

@@ -225,12 +225,12 @@ wxCursor::wxCursor()
{ {
} }
#if wxUSE_IMAGE
wxCursor::wxCursor( const wxImage &image ) wxCursor::wxCursor( const wxImage &image )
{ {
#if wxUSE_IMAGE
CreateFromImage( image ) ; CreateFromImage( image ) ;
#endif
} }
#endif // wxUSE_IMAGE
wxGDIRefData *wxCursor::CreateGDIRefData() const wxGDIRefData *wxCursor::CreateGDIRefData() const
{ {

View File

@@ -59,11 +59,11 @@ public:
wxIMPLEMENT_DYNAMIC_CLASS(wxCursor, wxGDIObject); wxIMPLEMENT_DYNAMIC_CLASS(wxCursor, wxGDIObject);
#if wxUSE_IMAGE
wxCursor::wxCursor(const wxString& cursor_file, wxCursor::wxCursor(const wxString& cursor_file,
wxBitmapType type, wxBitmapType type,
int hotSpotX, int hotSpotY) int hotSpotX, int hotSpotY)
{ {
#if wxUSE_IMAGE
wxImage img; wxImage img;
if (!img.LoadFile(cursor_file, type)) if (!img.LoadFile(cursor_file, type))
return; return;
@@ -75,13 +75,15 @@ wxCursor::wxCursor(const wxString& cursor_file,
img.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_Y, hotSpotY); img.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_Y, hotSpotY);
InitFromImage(img); InitFromImage(img);
#endif // wxUSE_IMAGE
} }
#if wxUSE_IMAGE
wxCursor::wxCursor(const wxImage& img) wxCursor::wxCursor(const wxImage& img)
{ {
InitFromImage(img); InitFromImage(img);
} }
#endif #endif // wxUSE_IMAGE
wxPoint wxCursor::GetHotSpot() const wxPoint wxCursor::GetHotSpot() const
{ {