Add wxCursor::GetHotSpot() and implement it for wxMSW and wxGTK.
Allow retrieving the coordinates of the cursor hot spot, at least for the ports for which we know how to do it. Closes #16539. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78134 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
e737363e6b
commit
dec924cdf1
@ -60,6 +60,7 @@ All (GUI):
|
||||
- Allow customizing window shown by wxBusyInfo.
|
||||
- Make results of wxDC::DrawEllipticArc() consistent across all platforms.
|
||||
- XRC handler for wxAuiToolBar added (Kinaou Hervé, David Hart).
|
||||
- Add wxCursor::GetHotSpot().
|
||||
- Add wxFD_NO_FOLLOW style for wxFileDialog (Luca Bacci).
|
||||
- Add support for embedding bitmaps in generated SVG in wxSVGFileDC (iwbnwif).
|
||||
- Add support for sorting wxDataViewCtrl by multiple columns (Trigve).
|
||||
|
@ -39,6 +39,8 @@ public:
|
||||
wxCursor(int id) { InitFromStock((wxStockCursor)id); }
|
||||
#endif
|
||||
*/
|
||||
|
||||
virtual wxPoint GetHotSpot() const { return wxDefaultPosition; }
|
||||
};
|
||||
|
||||
#if defined(__WXMSW__)
|
||||
|
@ -36,6 +36,9 @@ public:
|
||||
int hotSpotX = -1, int hotSpotY = -1,
|
||||
const char maskBits[] = NULL,
|
||||
const wxColour* fg = NULL, const wxColour* bg = NULL);
|
||||
|
||||
virtual wxPoint GetHotSpot() const wxOVERRIDE;
|
||||
|
||||
virtual ~wxCursor();
|
||||
|
||||
// implementation
|
||||
|
@ -27,6 +27,9 @@ public:
|
||||
#if WXWIN_COMPATIBILITY_2_8
|
||||
wxCursor(int id) { InitFromStock((wxStockCursor)id); }
|
||||
#endif
|
||||
|
||||
virtual wxPoint GetHotSpot() const wxOVERRIDE;
|
||||
|
||||
virtual ~wxCursor();
|
||||
|
||||
// implementation only
|
||||
|
@ -214,6 +214,19 @@ public:
|
||||
*/
|
||||
virtual bool IsOk() const;
|
||||
|
||||
/**
|
||||
Returns the coordinates of the cursor hot spot.
|
||||
|
||||
The hot spot is the point at which the mouse is actually considered to
|
||||
be when this cursor is used.
|
||||
|
||||
This method is currently only implemented in wxMSW and wxGTK2+ and
|
||||
simply returns ::wxDefaultPosition in the other ports.
|
||||
|
||||
@since 3.1.0
|
||||
*/
|
||||
wxPoint GetHotSpot() const;
|
||||
|
||||
/**
|
||||
Assignment operator, using @ref overview_refcount "reference counting".
|
||||
*/
|
||||
|
@ -170,6 +170,35 @@ wxCursor::~wxCursor()
|
||||
{
|
||||
}
|
||||
|
||||
wxPoint wxCursor::GetHotSpot() const
|
||||
{
|
||||
#if GTK_CHECK_VERSION(2,8,0)
|
||||
if (GetCursor())
|
||||
{
|
||||
if (gtk_check_version(2,8,0) == NULL)
|
||||
{
|
||||
GdkPixbuf *pixbuf = gdk_cursor_get_image(GetCursor());
|
||||
if (pixbuf)
|
||||
{
|
||||
wxPoint hotSpot = wxDefaultPosition;
|
||||
const gchar* opt_xhot = gdk_pixbuf_get_option(pixbuf, "x_hot");
|
||||
const gchar* opt_yhot = gdk_pixbuf_get_option(pixbuf, "y_hot");
|
||||
if (opt_xhot && opt_yhot)
|
||||
{
|
||||
const int xhot = atoi(opt_xhot);
|
||||
const int yhot = atoi(opt_yhot);
|
||||
hotSpot = wxPoint(xhot, yhot);
|
||||
}
|
||||
g_object_unref(pixbuf);
|
||||
return hotSpot;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return wxDefaultPosition;
|
||||
}
|
||||
|
||||
void wxCursor::InitFromStock( wxStockCursor cursorId )
|
||||
{
|
||||
m_refData = new wxCursorRefData();
|
||||
|
@ -275,6 +275,18 @@ wxCursor::wxCursor(const wxString& filename,
|
||||
}
|
||||
}
|
||||
|
||||
wxPoint wxCursor::GetHotSpot() const
|
||||
{
|
||||
if ( !GetGDIImageData() )
|
||||
return wxDefaultPosition;
|
||||
|
||||
AutoIconInfo ii;
|
||||
if ( !ii.GetFrom((HICON)GetGDIImageData()->m_hCursor) )
|
||||
return wxDefaultPosition;
|
||||
|
||||
return wxPoint(ii.xHotspot, ii.yHotspot);
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user