Improve wxQT cursor implementation, thanks @seandepagnier
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77911 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -19,14 +19,16 @@ class WXDLLIMPEXP_CORE wxCursor : public wxGDIObject
|
|||||||
public:
|
public:
|
||||||
wxCursor() { }
|
wxCursor() { }
|
||||||
wxCursor( const 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); }
|
wxCursor(wxStockCursor id) { InitFromStock(id); }
|
||||||
#if WXWIN_COMPATIBILITY_2_8
|
#if WXWIN_COMPATIBILITY_2_8
|
||||||
wxCursor(int id) { InitFromStock((wxStockCursor)id); }
|
wxCursor(int id) { InitFromStock((wxStockCursor)id); }
|
||||||
#endif
|
#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;
|
QCursor m_qtCursor;
|
||||||
|
|
||||||
|
@@ -8,6 +8,7 @@
|
|||||||
#ifndef _WX_QT_FONT_H_
|
#ifndef _WX_QT_FONT_H_
|
||||||
#define _WX_QT_FONT_H_
|
#define _WX_QT_FONT_H_
|
||||||
|
|
||||||
|
class QFont;
|
||||||
class WXDLLIMPEXP_CORE wxFont : public wxFontBase
|
class WXDLLIMPEXP_CORE wxFont : public wxFontBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@@ -43,27 +43,29 @@ wxCursor::wxCursor( const wxCursor &cursor )
|
|||||||
m_qtCursor = cursor.m_qtCursor;
|
m_qtCursor = cursor.m_qtCursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxCursor::wxCursor(const wxString& filename,
|
#if wxUSE_IMAGE
|
||||||
wxBitmapType kind,
|
wxCursor::wxCursor(const wxString& cursor_file,
|
||||||
int hotSpotX,
|
wxBitmapType type,
|
||||||
int hotSpotY)
|
int hotSpotX, int hotSpotY)
|
||||||
{
|
{
|
||||||
switch ( 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)
|
||||||
{
|
{
|
||||||
case wxBITMAP_TYPE_ICO:
|
InitFromImage(img);
|
||||||
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 );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void wxCursor::InitFromStock( wxStockCursor cursorId )
|
void wxCursor::InitFromStock( wxStockCursor cursorId )
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user