X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ad81651f00edc6f489d9b6a0839d316a964fd521..0b7e6e7da208b6a95fb23cb50286a09dc90d96d2:/src/msw/cursor.cpp?ds=sidebyside diff --git a/src/msw/cursor.cpp b/src/msw/cursor.cpp index e914dff561..b715483ccb 100644 --- a/src/msw/cursor.cpp +++ b/src/msw/cursor.cpp @@ -37,6 +37,7 @@ #include "wx/cursor.h" #endif +#include "wx/module.h" #include "wx/msw/private.h" #include "wx/msw/dib.h" @@ -49,7 +50,40 @@ // wxWin macros // ---------------------------------------------------------------------------- - IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxCursorBase) +IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxCursorBase) + +// ---------------------------------------------------------------------------- +// globals +// ---------------------------------------------------------------------------- + +// Current cursor, in order to hang on to cursor handle when setting the cursor +// globally +static wxCursor *gs_globalCursor = NULL; + +// ---------------------------------------------------------------------------- +// private classes +// ---------------------------------------------------------------------------- + +class wxCursorModule : public wxModule +{ +public: + virtual bool OnInit() + { + gs_globalCursor = new wxCursor; + + return TRUE; + } + + virtual void OnExit() + { + delete gs_globalCursor; + gs_globalCursor = (wxCursor *)NULL; + } +}; + +// ============================================================================ +// implementation +// ============================================================================ // ---------------------------------------------------------------------------- // wxCursorRefData @@ -278,16 +312,19 @@ wxCursor::~wxCursor() // Global cursor setting // ---------------------------------------------------------------------------- -void wxSetCursor(const wxCursor& cursor) +const wxCursor *wxGetGlobalCursor() { - extern wxCursor *g_globalCursor; + return gs_globalCursor; +} - if ( cursor.Ok() && cursor.GetHCURSOR() ) +void wxSetCursor(const wxCursor& cursor) +{ + if ( cursor.Ok() ) { - ::SetCursor((HCURSOR) cursor.GetHCURSOR()); + ::SetCursor(GetHcursorOf(cursor)); - if ( g_globalCursor ) - (*g_globalCursor) = cursor; + if ( gs_globalCursor ) + *gs_globalCursor = cursor; } }