]> git.saurik.com Git - wxWidgets.git/commitdiff
Create wxCURSOR_RIGHT_ARROW on the fly from normal arrow cursor under MSW.
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 10 Feb 2013 16:13:46 +0000 (16:13 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 10 Feb 2013 16:13:46 +0000 (16:13 +0000)
This allows to avoid having another cursor resource and also makes this cursor
nicer as rightarr.cur looks rather out of place under modern Windows systems.

Closes #14991.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73491 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
include/wx/msw/rightarr.cur [deleted file]
include/wx/msw/wx.rc
src/msw/cursor.cpp

index 2d107a109c6553596db3124a1672b56747651d18..63ea382529e2ceee8641a7bb0a589e211f6ae264 100644 (file)
@@ -648,6 +648,7 @@ wxMSW:
 - Fix appearance of multiline coloured wxCheckBox (Catalin Raceanu).
 - Allow creating wxCursor from ANI files (Catalin Raceanu).
 - Add wxIcon::CreateFromHICON() (troelsk).
+- Improve wxCURSOR_RIGHT_ARROW appearance (DoltAlya).
 
 wxOSX/Cocoa:
 
diff --git a/include/wx/msw/rightarr.cur b/include/wx/msw/rightarr.cur
deleted file mode 100644 (file)
index c54c3ac..0000000
Binary files a/include/wx/msw/rightarr.cur and /dev/null differ
index 771779f4475e8c3894a3f41c71cf0bbb29d37d86..c6f941fb7c9cba559d86ba6647c771c395843d3f 100644 (file)
@@ -50,7 +50,6 @@ WXCURSOR_PBRUSH         CURSOR  DISCARDABLE     "wx/msw/pbrush.cur"
 WXCURSOR_PLEFT          CURSOR  DISCARDABLE     "wx/msw/pntleft.cur"
 WXCURSOR_PRIGHT         CURSOR  DISCARDABLE     "wx/msw/pntright.cur"
 WXCURSOR_BLANK          CURSOR  DISCARDABLE     "wx/msw/blank.cur"
-WXCURSOR_RIGHT_ARROW    CURSOR  DISCARDABLE     "wx/msw/rightarr.cur"
 WXCURSOR_CROSS          CURSOR  DISCARDABLE     "wx/msw/cross.cur"
 
 
index 6ffb9e6401014c55c5ebb7cc21770cae0626ded3..ec9b67c9690cbf01d3a48be504bcb679c05eb30c 100644 (file)
@@ -276,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)
 {
@@ -340,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 )