X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5276b0a53cef4815230e39b54d2ecda14f72cbd1..07aaf32633ecf18ec3edfbb41793a112914792d0:/src/msw/cursor.cpp diff --git a/src/msw/cursor.cpp b/src/msw/cursor.cpp index a839795758..ec9b67c969 100644 --- a/src/msw/cursor.cpp +++ b/src/msw/cursor.cpp @@ -236,12 +236,13 @@ wxCursor::wxCursor(const wxString& filename, switch ( kind ) { case wxBITMAP_TYPE_CUR_RESOURCE: - hcursor = ::LoadCursor(wxGetInstance(), filename.fn_str()); + hcursor = ::LoadCursor(wxGetInstance(), filename.t_str()); break; #ifndef __WXWINCE__ + case wxBITMAP_TYPE_ANI: case wxBITMAP_TYPE_CUR: - hcursor = ::LoadCursorFromFile(filename.fn_str()); + hcursor = ::LoadCursorFromFile(filename.t_str()); break; #endif @@ -275,6 +276,45 @@ wxCursor::wxCursor(const wxString& filename, } } +namespace +{ + +void ReverseBitmap(HBITMAP bitmap, int width, int height) +{ + MemoryHDC hdc; + SelectInHDC selBitmap(hdc, bitmap); + ::StretchBlt(hdc, width - 1, 0, -width, height, + hdc, 0, 0, width, height, SRCCOPY); +} + +HCURSOR CreateReverseCursor(HCURSOR cursor) +{ + ICONINFO info; + if ( !::GetIconInfo(cursor, &info) ) + return NULL; + + HCURSOR cursorRev = NULL; + + BITMAP bmp; + if ( ::GetObject(info.hbmMask, sizeof(bmp), &bmp) ) + { + ReverseBitmap(info.hbmMask, bmp.bmWidth, bmp.bmHeight); + if ( info.hbmColor ) + ReverseBitmap(info.hbmColor, bmp.bmWidth, bmp.bmHeight); + info.xHotspot = (DWORD)bmp.bmWidth - 1 - info.xHotspot; + + cursorRev = ::CreateIconIndirect(&info); + } + + ::DeleteObject(info.hbmMask); + if ( info.hbmColor ) + ::DeleteObject(info.hbmColor); + + return cursorRev; +} + +} // anonymous namespace + // Cursors by stock number void wxCursor::InitFromStock(wxStockCursor idCursor) { @@ -293,15 +333,8 @@ void wxCursor::InitFromStock(wxStockCursor idCursor) { false, wxT("WXCURSOR_RIGHT_ARROW") }, // wxCURSOR_RIGHT_ARROW { false, wxT("WXCURSOR_BULLSEYE") }, // wxCURSOR_BULLSEYE { true, IDC_ARROW }, // WXCURSOR_CHAR - - // Displays as an I-beam on XP, so use a cursor file -// { true, IDC_CROSS }, // WXCURSOR_CROSS - { false, wxT("WXCURSOR_CROSS") }, // WXCURSOR_CROSS - - // See special handling below for wxCURSOR_HAND -// { false, wxT("WXCURSOR_HAND") }, // wxCURSOR_HAND + { true, IDC_CROSS }, // WXCURSOR_CROSS { true, IDC_HAND }, // wxCURSOR_HAND - { true, IDC_IBEAM }, // WXCURSOR_IBEAM { true, IDC_ARROW }, // WXCURSOR_LEFT_BUTTON { false, wxT("WXCURSOR_MAGNIFIER") }, // wxCURSOR_MAGNIFIER @@ -346,6 +379,16 @@ void wxCursor::InitFromStock(wxStockCursor idCursor) deleteLater = true; } + if ( !hcursor && idCursor == wxCURSOR_RIGHT_ARROW) + { + hcursor = ::LoadCursor(NULL, IDC_ARROW); + if ( hcursor ) + { + hcursor = CreateReverseCursor(hcursor); + deleteLater = true; + } + } + if ( !hcursor ) { if ( !stdCursor.isStd ) @@ -391,7 +434,7 @@ const wxCursor *wxGetGlobalCursor() void wxSetCursor(const wxCursor& cursor) { - if ( cursor.Ok() ) + if ( cursor.IsOk() ) { ::SetCursor(GetHcursorOf(cursor));