From: Vadim Zeitlin <vadim@wxwidgets.org>
Date: Wed, 21 Apr 2010 14:40:28 +0000 (+0000)
Subject: Remove the extra margins when checking owner drawn menu icons size.
X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/c71238020c14b455f39bb23286b621d16f25a596

Remove the extra margins when checking owner drawn menu icons size.

The extra +4 in IsLessThanStdSize() functions resulted in assert failures
under Windows XP after the ownerdraw drawing changes so remove it as nobody
knew why was it there anyhow.

Also replace IsLessThanStdSize() with IsGreaterThanStdSize() to allow using it
directly instead of always testing for !IsLessThanStdSize().

See #11657.

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

diff --git a/src/msw/menu.cpp b/src/msw/menu.cpp
index 444a991ef8..ab1ada1220 100644
--- a/src/msw/menu.cpp
+++ b/src/msw/menu.cpp
@@ -149,13 +149,10 @@ UINT GetMenuState(HMENU hMenu, UINT id, UINT flags)
 }
 #endif // __WXWINCE__
 
-inline bool IsLessThanStdSize(const wxBitmap& bmp)
+inline bool IsGreaterThanStdSize(const wxBitmap& bmp)
 {
-    // FIXME: these +4 are chosen so that 16*16 bitmaps pass this test with
-    //        default SM_CXMENUCHECK value but I have no idea what do we really
-    //        need to use here
-    return bmp.GetWidth() < ::GetSystemMetrics(SM_CXMENUCHECK) + 4 &&
-            bmp.GetHeight() < ::GetSystemMetrics(SM_CYMENUCHECK) + 4;
+    return bmp.GetWidth() > ::GetSystemMetrics(SM_CXMENUCHECK) ||
+            bmp.GetHeight() > ::GetSystemMetrics(SM_CYMENUCHECK);
 }
 
 } // anonymous namespace
@@ -529,8 +526,8 @@ bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos)
                 const wxBitmap& bmpUnchecked = pItem->GetBitmap(false),
                                 bmpChecked   = pItem->GetBitmap(true);
 
-                if ( (bmpUnchecked.Ok() && !IsLessThanStdSize(bmpUnchecked)) ||
-                     (bmpChecked.Ok()   && !IsLessThanStdSize(bmpChecked)) )
+                if ( (bmpUnchecked.Ok() && IsGreaterThanStdSize(bmpUnchecked)) ||
+                     (bmpChecked.Ok()   && IsGreaterThanStdSize(bmpChecked)) )
                 {
                     mustUseOwnerDrawn = true;
                 }