+ // Is BMP height larger than text height?
+ if ( *height < heightBmp )
+ *height = heightBmp;
+ }
+
+ // make sure that this item is at least as tall as the system menu height
+ const size_t menuHeight = data->CheckMargin.GetTotalY()
+ + data->CheckSize.cy;
+ if (*height < menuHeight)
+ *height = menuHeight;
+
+ return true;
+}
+
+bool wxMenuItem::OnDrawItem(wxDC& dc, const wxRect& rc,
+ wxODAction WXUNUSED(act), wxODStatus stat)
+{
+ const MenuDrawData* data = MenuDrawData::Get();
+
+ wxMSWDCImpl *impl = (wxMSWDCImpl*) dc.GetImpl();
+ HDC hdc = GetHdcOf(*impl);
+
+ RECT rect;
+ wxCopyRectToRECT(rc, rect);
+
+ int imgWidth = wxMax(GetMarginWidth(), data->CheckSize.cx);
+
+ if ( IsOwnerDrawn() )
+ {
+ // font and colors to use
+ wxFont font;
+ GetFontToUse(font);
+
+ wxColour colText, colBack;
+ GetColourToUse(stat, colText, colBack);
+
+ // calculate metrics of item parts
+ RECT rcSelection = rect;
+ data->ItemMargin.ApplyTo(rcSelection);
+
+ RECT rcSeparator = rcSelection;
+ data->SeparatorMargin.ApplyTo(rcSeparator);
+
+ RECT rcGutter = rcSelection;
+ rcGutter.right = data->ItemMargin.cxLeftWidth
+ + data->CheckBgMargin.cxLeftWidth
+ + data->CheckMargin.cxLeftWidth
+ + imgWidth
+ + data->CheckMargin.cxRightWidth
+ + data->CheckBgMargin.cxRightWidth;
+
+ RECT rcText = rcSelection;
+ rcText.left = rcGutter.right + data->TextBorder;
+
+ // we draw the text label vertically centered, but this results in it
+ // being 1px too low compared to native menus for some reason, fix it
+ if ( data->MenuLayout() != MenuDrawData::FullTheme )
+ rcText.top--;
+
+#if wxUSE_UXTHEME
+ // If a custom background colour is explicitly specified, we should use
+ // it instead of the default theme background.
+ wxUxThemeEngine* const theme = GetBackgroundColour().IsOk()
+ ? NULL
+ : MenuDrawData::GetUxThemeEngine();
+ if ( theme )
+ {
+ POPUPITEMSTATES state;
+ if ( stat & wxODDisabled )
+ {
+ state = (stat & wxODSelected) ? MPI_DISABLEDHOT
+ : MPI_DISABLED;
+ }
+ else if ( stat & wxODSelected )
+ {
+ state = MPI_HOT;
+ }
+ else
+ {
+ state = MPI_NORMAL;
+ }
+
+ wxUxThemeHandle hTheme(GetMenu()->GetWindow(), L"MENU");
+
+ if ( theme->IsThemeBackgroundPartiallyTransparent(hTheme,
+ MENU_POPUPITEM, state) )
+ {
+ theme->DrawThemeBackground(hTheme, hdc,
+ MENU_POPUPBACKGROUND,
+ 0, &rect, NULL);
+ }
+
+ theme->DrawThemeBackground(hTheme, hdc, MENU_POPUPGUTTER,
+ 0, &rcGutter, NULL);
+
+ if ( IsSeparator() )
+ {
+ rcSeparator.left = rcGutter.right;
+ theme->DrawThemeBackground(hTheme, hdc, MENU_POPUPSEPARATOR,
+ 0, &rcSeparator, NULL);
+ return true;
+ }
+
+ theme->DrawThemeBackground(hTheme, hdc, MENU_POPUPITEM,
+ state, &rcSelection, NULL);
+
+ }
+ else
+#endif // wxUSE_UXTHEME