X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a1b806b98241ab649c169aaa1f134df85e80fb8b..43c42c18d36c703a88b1b7b697bac27fe5608eca:/src/msw/menuitem.cpp?ds=sidebyside diff --git a/src/msw/menuitem.cpp b/src/msw/menuitem.cpp index f4f61e1321..02ea2a9e93 100644 --- a/src/msw/menuitem.cpp +++ b/src/msw/menuitem.cpp @@ -494,9 +494,6 @@ wxMenuItem::wxMenuItem(wxMenu *parentMenu, void wxMenuItem::Init() { - m_radioGroup.start = -1; - m_isRadioGroupStart = false; - #if wxUSE_OWNER_DRAWN // when the color is not valid, wxOwnerDraw takes the default ones. @@ -557,30 +554,6 @@ bool wxMenuItem::IsChecked() const return (flag & MF_CHECKED) != 0; } -// radio group stuff -// ----------------- - -void wxMenuItem::SetAsRadioGroupStart() -{ - m_isRadioGroupStart = true; -} - -void wxMenuItem::SetRadioGroupStart(int start) -{ - wxASSERT_MSG( !m_isRadioGroupStart, - wxT("should only be called for the next radio items") ); - - m_radioGroup.start = start; -} - -void wxMenuItem::SetRadioGroupEnd(int end) -{ - wxASSERT_MSG( m_isRadioGroupStart, - wxT("should only be called for the first radio item") ); - - m_radioGroup.end = end; -} - // change item state // ----------------- @@ -634,17 +607,10 @@ void wxMenuItem::Check(bool check) int start, end; - if ( m_isRadioGroupStart ) - { - // we already have all information we need - start = pos; - end = m_radioGroup.end; - } - else // next radio group item + if ( !m_parentMenu->MSWGetRadioGroupRange(pos, &start, &end) ) { - // get the radio group end from the start item - start = m_radioGroup.start; - end = items.Item(start)->GetData()->m_radioGroup.end; + wxFAIL_MSG( wxT("Menu radio item not part of radio group?") ); + return; } #ifdef __WIN32__ @@ -715,15 +681,6 @@ void wxMenuItem::SetItemLabel(const wxString& txt) if ( !hMenu || ::GetMenuState(hMenu, id, MF_BYCOMMAND) == (UINT)-1 ) return; -#if wxUSE_OWNER_DRAWN - if ( IsOwnerDrawn() ) - { - // we don't need to do anything for owner drawn items, they will redraw - // themselves using the new text the next time they're displayed - return; - } -#endif // owner drawn - // update the text of the native menu item WinStruct info; @@ -746,11 +703,26 @@ void wxMenuItem::SetItemLabel(const wxString& txt) return; } - if ( isLaterThanWin95 ) - info.fMask |= MIIM_STRING; - //else: MIIM_TYPE already specified - info.dwTypeData = (LPTSTR)m_text.wx_str(); - info.cch = m_text.length(); +#if wxUSE_OWNER_DRAWN + // Don't set the text for the owner drawn items, they don't use it and even + // though setting it doesn't seem to actually do any harm under Windows 7, + // avoid doing this relatively nonsensical operation just in case it does + // break something on other, past or future, Windows versions. + // + // Notice that we do need to call SetMenuItemInfo() even for the ownerdrawn + // items however as otherwise their size wouldn't be recalculated as + // WM_MEASUREITEM wouldn't be sent and this could result in display + // problems if the length of the menu item changed significantly. + if ( !IsOwnerDrawn() ) +#endif // wxUSE_OWNER_DRAWN + { + if ( isLaterThanWin95 ) + info.fMask |= MIIM_STRING; + //else: MIIM_TYPE already specified + info.dwTypeData = wxMSW_CONV_LPTSTR(m_text); + info.cch = m_text.length(); + } + if ( !::SetMenuItemInfo(hMenu, id, FALSE, &info) ) { wxLogLastError(wxT("SetMenuItemInfo")); @@ -1009,7 +981,7 @@ bool wxMenuItem::OnDrawItem(wxDC& dc, const wxRect& rc, int x = rcText.left; int y = rcText.top + (rcText.bottom - rcText.top - textSize.cy) / 2; - ::DrawState(hdc, NULL, NULL, (LPARAM)text.wx_str(), + ::DrawState(hdc, NULL, NULL, wxMSW_CONV_LPARAM(text), text.length(), x, y, 0, 0, flags); // ::SetTextAlign(hdc, TA_RIGHT) doesn't work with DSS_DISABLED or DSS_MONO @@ -1039,7 +1011,7 @@ bool wxMenuItem::OnDrawItem(wxDC& dc, const wxRect& rc, int y = rcText.top + (rcText.bottom - rcText.top - accelSize.cy) / 2; - ::DrawState(hdc, NULL, NULL, (LPARAM)accel.wx_str(), + ::DrawState(hdc, NULL, NULL, wxMSW_CONV_LPARAM(accel), accel.length(), x, y, 0, 0, flags); } } @@ -1106,9 +1078,6 @@ bool wxMenuItem::OnDrawItem(wxDC& dc, const wxRect& rc, int nBmpWidth = bmp.GetWidth(), nBmpHeight = bmp.GetHeight(); - // there should be enough space! - wxASSERT( nBmpWidth <= imgWidth && nBmpHeight <= (rcImg.bottom - rcImg.top) ); - int x = rcImg.left + (imgWidth - nBmpWidth) / 2; int y = rcImg.top + (rcImg.bottom - rcImg.top - nBmpHeight) / 2; dc.Blit(x, y, nBmpWidth, nBmpHeight, &dcMem, 0, 0, wxCOPY, true);