Create wxCURSOR_RIGHT_ARROW on the fly from normal arrow cursor under MSW.
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
This commit is contained in:
@@ -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 )
|
||||
|
||||
Reference in New Issue
Block a user