X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e9576ca53db96b462ed4c0b4bdf47d64c40203e4..2fe212b0336512aac9eace69fab09ce856b0bf4b:/src/mac/cursor.cpp diff --git a/src/mac/cursor.cpp b/src/mac/cursor.cpp index 4333364c93..fa0bbf76b2 100644 --- a/src/mac/cursor.cpp +++ b/src/mac/cursor.cpp @@ -20,18 +20,38 @@ IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxBitmap) #endif +const short kwxCursorHandId = 9 ; +const short kwxCursorSizeWEId = 10 ; +const short kwxCursorSizeNSId = 11 ; +#if !TARGET_CARBON +Cursor* MacArrowCursorPtr = &qd.arrow ; +CursHandle MacArrowCursor = &MacArrowCursorPtr ; +#else +bool MacArrowInstalled = false ; +Cursor MacArrow ; +Cursor* MacArrowCursorPtr = &MacArrow ; +CursHandle MacArrowCursor = &MacArrowCursorPtr ; +#endif +CursHandle gMacCurrentCursor = NULL ; + wxCursorRefData::wxCursorRefData() { - m_width = 32; m_height = 32; - -/* TODO - m_hCursor = 0 ; -*/ +#if TARGET_CARBON + if ( !MacArrowInstalled ) + { + MacArrowCursorPtr = GetQDGlobalsArrow( &MacArrow ) ; + MacArrowInstalled = true ; + } +#endif + m_width = 32; + m_height = 32; + m_hCursor = NULL ; } wxCursorRefData::~wxCursorRefData() { - // TODO: destroy cursor +// if ( m_hCursor && ( m_hCursor != MacArrowCursor ) ) +// ::ReleaseResource( (Handle) m_hCursor ) ; } // Cursors @@ -56,122 +76,133 @@ wxCursor::wxCursor(int cursor_type) { m_refData = new wxCursorRefData; -/* TODO switch (cursor_type) { case wxCURSOR_WAIT: - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_WAIT); + M_CURSORDATA->m_hCursor = ::GetCursor(watchCursor); break; case wxCURSOR_IBEAM: - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_IBEAM); + M_CURSORDATA->m_hCursor = ::GetCursor(iBeamCursor); break; case wxCURSOR_CROSS: - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_CROSS); + M_CURSORDATA->m_hCursor = ::GetCursor(crossCursor); break; case wxCURSOR_SIZENWSE: - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_SIZENWSE); + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorSizeWEId); break; case wxCURSOR_SIZENESW: - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_SIZENESW); + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorSizeWEId); break; case wxCURSOR_SIZEWE: - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_SIZEWE); + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorSizeWEId); break; case wxCURSOR_SIZENS: - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_SIZENS); + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorSizeNSId); break; case wxCURSOR_CHAR: { - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_ARROW); + M_CURSORDATA->m_hCursor = MacArrowCursor; break; } case wxCURSOR_HAND: { - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_HAND"); + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorHandId); break; } case wxCURSOR_BULLSEYE: { - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_BULLSEYE"); + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorHandId); break; } case wxCURSOR_PENCIL: { - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_PENCIL"); + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorHandId); break; } case wxCURSOR_MAGNIFIER: { - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_MAGNIFIER"); + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorHandId); break; } case wxCURSOR_NO_ENTRY: { - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_NO_ENTRY"); + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorHandId); break; } case wxCURSOR_LEFT_BUTTON: { - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_ARROW); + M_CURSORDATA->m_hCursor = MacArrowCursor; break; } case wxCURSOR_RIGHT_BUTTON: { - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_ARROW); + M_CURSORDATA->m_hCursor = MacArrowCursor; break; } case wxCURSOR_MIDDLE_BUTTON: { - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_ARROW); + M_CURSORDATA->m_hCursor = MacArrowCursor; break; } case wxCURSOR_SIZING: { - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_SIZING"); + M_CURSORDATA->m_hCursor = MacArrowCursor; break; } case wxCURSOR_WATCH: { - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_WATCH"); + M_CURSORDATA->m_hCursor = ::GetCursor(watchCursor); break; } case wxCURSOR_SPRAYCAN: { - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_ROLLER"); + M_CURSORDATA->m_hCursor = MacArrowCursor; break; } case wxCURSOR_PAINT_BRUSH: { - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_PBRUSH"); + M_CURSORDATA->m_hCursor = MacArrowCursor; break; } case wxCURSOR_POINT_LEFT: { - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_PLEFT"); + M_CURSORDATA->m_hCursor = MacArrowCursor; break; } case wxCURSOR_POINT_RIGHT: { - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_PRIGHT"); + M_CURSORDATA->m_hCursor = MacArrowCursor; break; } case wxCURSOR_QUESTION_ARROW: { - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_QARROW"); + M_CURSORDATA->m_hCursor = MacArrowCursor; break; } case wxCURSOR_BLANK: { - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_BLANK"); + M_CURSORDATA->m_hCursor = MacArrowCursor; break; } default: case wxCURSOR_ARROW: - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_ARROW); + M_CURSORDATA->m_hCursor = MacArrowCursor; break; - } -*/ + } +} +void wxCursor::MacInstall() const +{ + if ( m_refData && M_CURSORDATA->m_hCursor ) + { + ::SetCursor( *M_CURSORDATA->m_hCursor ) ; + gMacCurrentCursor = M_CURSORDATA->m_hCursor ; + } + else + { + ::SetCursor( *MacArrowCursor ) ; + gMacCurrentCursor = NULL ; + } } wxCursor::~wxCursor() @@ -181,7 +212,7 @@ wxCursor::~wxCursor() // Global cursor setting void wxSetCursor(const wxCursor& cursor) { - // TODO (optional on platforms with no global cursor) + cursor.MacInstall() ; }