X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d890beb9c873adf9f0be3521ef5ad98be51484c1..cdbd62d6ff290fd58acd1bc5574dfc79db3a6f70:/src/msw/cursor.cpp diff --git a/src/msw/cursor.cpp b/src/msw/cursor.cpp index bb932667b1..de73d96368 100644 --- a/src/msw/cursor.cpp +++ b/src/msw/cursor.cpp @@ -4,7 +4,6 @@ // Author: Julian Smart // Modified by: // Created: 01/02/97 -// RCS-ID: $Id$ // Copyright: (c) 1997-2003 Julian Smart and Vadim Zeitlin // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -240,6 +239,7 @@ wxCursor::wxCursor(const wxString& filename, break; #ifndef __WXWINCE__ + case wxBITMAP_TYPE_ANI: case wxBITMAP_TYPE_CUR: hcursor = ::LoadCursorFromFile(filename.t_str()); break; @@ -275,6 +275,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) { @@ -339,6 +378,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 )