X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6239ee05567eac71754f56c2a154222d10b57ff1..bbd92d1dbea02db8c28e9c17bfacc0563d855b25:/src/mac/carbon/cursor.cpp diff --git a/src/mac/carbon/cursor.cpp b/src/mac/carbon/cursor.cpp index 2dab20662a..c48663d7fd 100644 --- a/src/mac/carbon/cursor.cpp +++ b/src/mac/carbon/cursor.cpp @@ -24,20 +24,28 @@ #include "wx/mac/private.h" -IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxBitmap) +IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxGDIObject) -class WXDLLEXPORT wxCursorRefData: public wxBitmapRefData +class WXDLLEXPORT wxCursorRefData: public wxGDIRefData { - DECLARE_NO_COPY_CLASS(wxCursorRefData) - - friend class wxBitmap; - friend class wxCursor; - public: wxCursorRefData(); + wxCursorRefData(const wxCursorRefData& cursor); virtual ~wxCursorRefData(); + virtual bool IsOk() const + { + if ( m_hCursor != NULL ) + return true; +#if !wxMAC_USE_COCOA + if ( m_themeCursor != -1 ) + return true; +#endif + + return false; + } + protected: #if wxMAC_USE_COCOA WX_NSCursor m_hCursor; @@ -48,6 +56,10 @@ protected: bool m_isColorCursor; long m_themeCursor; #endif + + friend class wxCursor; + + DECLARE_NO_ASSIGN_CLASS(wxCursorRefData) }; #define M_CURSORDATA wx_static_cast(wxCursorRefData*, m_refData) @@ -199,8 +211,6 @@ CursHandle wxGetStockCursor( int number ) wxCursorRefData::wxCursorRefData() { - SetWidth( 16 ); - SetHeight( 16 ); m_hCursor = NULL; #if wxMAC_USE_COCOA #else @@ -211,6 +221,21 @@ wxCursorRefData::wxCursorRefData() #endif } +wxCursorRefData::wxCursorRefData(const wxCursorRefData& cursor) +{ + // FIXME: need to copy the cursor + m_hCursor = NULL; + +#if wxMAC_USE_COCOA + wxUnusedVar(cursor); +#else + m_disposeHandle = false; + m_releaseHandle = false; + m_isColorCursor = cursor.m_isColorCursor; + m_themeCursor = cursor.m_themeCursor; +#endif +} + wxCursorRefData::~wxCursorRefData() { #if wxMAC_USE_COCOA @@ -251,17 +276,22 @@ wxCursor::wxCursor( const wxImage &image ) #endif } -wxCursor::wxCursor(const char **bits) +wxCursor::wxCursor(const char* const* bits) { (void) CreateFromXpm(bits); } -wxCursor::wxCursor(char **bits) +wxGDIRefData *wxCursor::CreateGDIRefData() const { - (void) CreateFromXpm((const char **)bits); + return new wxCursorRefData; } -bool wxCursor::CreateFromXpm(const char **bits) +wxGDIRefData *wxCursor::CloneGDIRefData(const wxGDIRefData *data) const +{ + return new wxCursorRefData(*wx_static_cast(const wxCursorRefData *, data)); +} + +bool wxCursor::CreateFromXpm(const char* const* bits) { #if wxUSE_IMAGE wxCHECK_MSG( bits != NULL, false, wxT("invalid cursor data") ); @@ -280,15 +310,6 @@ WXHCURSOR wxCursor::GetHCURSOR() const return (M_CURSORDATA ? M_CURSORDATA->m_hCursor : 0); } -bool wxCursor::IsOk() const -{ -#if wxMAC_USE_COCOA - return GetHCURSOR() != NULL; -#else - return (m_refData != NULL && ( M_CURSORDATA->m_hCursor != NULL || M_CURSORDATA->m_themeCursor != -1 ) ) ; -#endif -} - #if !wxMAC_USE_COCOA short GetCTabIndex( CTabHandle colors , RGBColor *col ) { @@ -668,7 +689,9 @@ wxCursor::~wxCursor() } // Global cursor setting +wxCursor gGlobalCursor; void wxSetCursor(const wxCursor& cursor) { cursor.MacInstall() ; + gGlobalCursor = cursor; }