use margin width after updating it in OnMeasureItem() (see #10452)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58558 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2009-01-31 18:20:58 +00:00
parent 37ddd6ea64
commit 29cd57f79b

View File

@@ -240,10 +240,6 @@ bool wxOwnerDrawn::OnMeasureItem(size_t *pwidth, size_t *pheight)
dc.GetTextExtent(str, &w, &h);
*pwidth = w;
*pheight = h;
// add space at the end of the menu for the submenu expansion arrow
// this will also allow offsetting the accel string from the right edge
*pwidth += GetMarginWidth() + 16;
}
else // don't draw the text, just the bitmap (if any)
{
@@ -259,11 +255,11 @@ bool wxOwnerDrawn::OnMeasureItem(size_t *pwidth, size_t *pheight)
if ( *pheight < adjustedHeight )
*pheight = adjustedHeight;
const size_t widthBmp = m_bmpChecked.GetWidth();
const int widthBmp = m_bmpChecked.GetWidth();
if ( IsOwnerDrawn() )
{
// widen the margin to fit the bitmap if necessary
if ((size_t)GetMarginWidth() < widthBmp)
if ( GetMarginWidth() < widthBmp )
SetMarginWidth(widthBmp);
}
else // we must allocate enough space for the bitmap
@@ -275,6 +271,15 @@ bool wxOwnerDrawn::OnMeasureItem(size_t *pwidth, size_t *pheight)
// add a 4-pixel separator, otherwise menus look cluttered
*pwidth += 4;
// notice that this adjustment must be done after (possibly) changing the
// margin width above
if ( IsOwnerDrawn() )
{
// add space at the end of the menu for the submenu expansion arrow
// this will also allow offsetting the accel string from the right edge
*pwidth += GetMarginWidth() + 16;
}
// make sure that this item is at least as tall as the system menu height
const size_t heightStd = wxMSWSystemMenuFontModule::GetSystemMenuHeight();
if ( *pheight < heightStd )