diff --git a/include/wx/qt/cursor.h b/include/wx/qt/cursor.h index 6c35738fe3..26e3c0d93e 100644 --- a/include/wx/qt/cursor.h +++ b/include/wx/qt/cursor.h @@ -19,14 +19,16 @@ class WXDLLIMPEXP_CORE wxCursor : public wxGDIObject public: wxCursor() { } wxCursor( const wxCursor & ); - wxCursor( const wxImage& image ) { InitFromImage(image); } - wxCursor( const wxString& name, - wxBitmapType type = wxCURSOR_DEFAULT_TYPE, - int hotSpotX = 0, int hotSpotY = 0 ); wxCursor(wxStockCursor id) { InitFromStock(id); } #if WXWIN_COMPATIBILITY_2_8 wxCursor(int id) { InitFromStock((wxStockCursor)id); } #endif +#if wxUSE_IMAGE + wxCursor( const wxImage & image ); + wxCursor(const wxString& name, + wxBitmapType type = wxCURSOR_DEFAULT_TYPE, + int hotSpotX = 0, int hotSpotY = 0); +#endif QCursor m_qtCursor; diff --git a/include/wx/qt/font.h b/include/wx/qt/font.h index f47fe772d5..224468e8b4 100644 --- a/include/wx/qt/font.h +++ b/include/wx/qt/font.h @@ -8,6 +8,7 @@ #ifndef _WX_QT_FONT_H_ #define _WX_QT_FONT_H_ +class QFont; class WXDLLIMPEXP_CORE wxFont : public wxFontBase { public: diff --git a/src/qt/cursor.cpp b/src/qt/cursor.cpp index e015ee3ad4..edefb18d0b 100644 --- a/src/qt/cursor.cpp +++ b/src/qt/cursor.cpp @@ -43,28 +43,30 @@ wxCursor::wxCursor( const wxCursor &cursor ) m_qtCursor = cursor.m_qtCursor; } -wxCursor::wxCursor(const wxString& filename, - wxBitmapType kind, - int hotSpotX, - int hotSpotY) +#if wxUSE_IMAGE +wxCursor::wxCursor(const wxString& cursor_file, + wxBitmapType type, + int hotSpotX, int hotSpotY) { - switch ( kind ) - { - case wxBITMAP_TYPE_ICO: - m_qtCursor = QCursor( - *wxBitmap(filename, wxBITMAP_TYPE_ICO).GetHandle(), - hotSpotX, hotSpotY ); - break; - case wxBITMAP_TYPE_BMP: - m_qtCursor = QCursor( - *wxBitmap(filename, wxBITMAP_TYPE_ICO).GetHandle(), - hotSpotX, hotSpotY ); - break; - default: - wxLogError( wxT("unknown cursor resource type '%d'"), kind ); - } + wxImage img; + if (!img.LoadFile(cursor_file, type)) + return; + + // eventually set the hotspot: + if (!img.HasOption(wxIMAGE_OPTION_CUR_HOTSPOT_X)) + img.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_X, hotSpotX); + if (!img.HasOption(wxIMAGE_OPTION_CUR_HOTSPOT_Y)) + img.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_Y, hotSpotY); + + InitFromImage(img); } +wxCursor::wxCursor(const wxImage& img) +{ + InitFromImage(img); +} +#endif + void wxCursor::InitFromStock( wxStockCursor cursorId ) { Qt::CursorShape qt_cur;