From: Julian Smart Date: Thu, 28 Dec 2006 13:52:58 +0000 (+0000) Subject: Temporary fix for inconsistent menu item margins (see Quit item in ownerdraw sample) X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/99a7bebb651e9ba427d1211a9855d58d7ae2fbf7 Temporary fix for inconsistent menu item margins (see Quit item in ownerdraw sample) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44068 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/msw/menu.cpp b/src/msw/menu.cpp index 65affb6e59..316f1a9ce9 100644 --- a/src/msw/menu.cpp +++ b/src/msw/menu.cpp @@ -400,6 +400,28 @@ bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos) pos += 2; // for the title itself and its separator BOOL ok = false; + +#if wxUSE_OWNER_DRAWN + // Currently, mixing owner-drawn and non-owner-drawn items results in + // inconsistent margins, so we force this to be owner-drawn if any other + // items already are. Later we might want to use a boolean in the wxMenu + // to avoid search. Also we might make this fix unnecessary by getting the correct + // margin using NONCLIENTMETRICS. + if ( !pItem->IsOwnerDrawn() ) + { + // Check if any other items are ownerdrawn, and make ownerdrawn if so + wxMenuItemList::compatibility_iterator node = GetMenuItems().GetFirst(); + while (node) + { + if (node->GetData()->IsOwnerDrawn()) + { + pItem->SetOwnerDrawn(true); + break; + } + node = node->GetNext(); + } + } +#endif // check if we have something more than a simple text item #if wxUSE_OWNER_DRAWN