X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/95908499c536ae0db50e17b868aa6e22fb53bb57..645f9bd3772a7a4ca3687553e1af53e5a0bb51c1:/src/msw/menuitem.cpp diff --git a/src/msw/menuitem.cpp b/src/msw/menuitem.cpp index f897ef67fe..94d963d4ac 100644 --- a/src/msw/menuitem.cpp +++ b/src/msw/menuitem.cpp @@ -207,49 +207,6 @@ const int TMT_SIZINGMARGINS = 3601; // dynamic classes implementation // ---------------------------------------------------------------------------- -#if wxUSE_EXTENDED_RTTI - -bool wxMenuItemStreamingCallback( const wxObject *object, wxWriter * , wxPersister * , wxxVariantArray & ) -{ - const wxMenuItem * mitem = dynamic_cast(object) ; - if ( mitem->GetMenu() && !mitem->GetMenu()->GetTitle().empty() ) - { - // we don't stream out the first two items for menus with a title, they will be reconstructed - if ( mitem->GetMenu()->FindItemByPosition(0) == mitem || mitem->GetMenu()->FindItemByPosition(1) == mitem ) - return false ; - } - return true ; -} - -wxBEGIN_ENUM( wxItemKind ) - wxENUM_MEMBER( wxITEM_SEPARATOR ) - wxENUM_MEMBER( wxITEM_NORMAL ) - wxENUM_MEMBER( wxITEM_CHECK ) - wxENUM_MEMBER( wxITEM_RADIO ) -wxEND_ENUM( wxItemKind ) - -IMPLEMENT_DYNAMIC_CLASS_XTI_CALLBACK(wxMenuItem, wxObject,"wx/menuitem.h",wxMenuItemStreamingCallback) - -wxBEGIN_PROPERTIES_TABLE(wxMenuItem) - wxPROPERTY( Parent,wxMenu*, SetMenu, GetMenu, EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group") ) - wxPROPERTY( Id,int, SetId, GetId, EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group") ) - wxPROPERTY( Text, wxString , SetText, GetText, wxString(), 0 /*flags*/ , wxT("Helpstring") , wxT("group") ) - wxPROPERTY( Help, wxString , SetHelp, GetHelp, wxString(), 0 /*flags*/ , wxT("Helpstring") , wxT("group") ) - wxREADONLY_PROPERTY( Kind, wxItemKind , GetKind , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group") ) - wxPROPERTY( SubMenu,wxMenu*, SetSubMenu, GetSubMenu, EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group") ) - wxPROPERTY( Enabled , bool , Enable , IsEnabled , wxxVariant((bool)true) , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) - wxPROPERTY( Checked , bool , Check , IsChecked , wxxVariant((bool)false) , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) - wxPROPERTY( Checkable , bool , SetCheckable , IsCheckable , wxxVariant((bool)false) , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) -wxEND_PROPERTIES_TABLE() - -wxBEGIN_HANDLERS_TABLE(wxMenuItem) -wxEND_HANDLERS_TABLE() - -wxDIRECT_CONSTRUCTOR_6( wxMenuItem , wxMenu* , Parent , int , Id , wxString , Text , wxString , Help , wxItemKind , Kind , wxMenu* , SubMenu ) -#else -IMPLEMENT_DYNAMIC_CLASS(wxMenuItem, wxObject) -#endif - // ---------------------------------------------------------------------------- // wxMenuItem // ---------------------------------------------------------------------------- @@ -537,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. @@ -600,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 // ----------------- @@ -677,17 +607,10 @@ void wxMenuItem::Check(bool check) int start, end; - if ( m_isRadioGroupStart ) + if ( !m_parentMenu->MSWGetRadioGroupRange(pos, &start, &end) ) { - // we already have all information we need - start = pos; - end = m_radioGroup.end; - } - else // next radio group item - { - // 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__ @@ -882,7 +805,7 @@ bool wxMenuItem::OnMeasureItem(size_t *width, size_t *height) *width += imgWidth + data->CheckBgMargin.GetTotalX(); } - if ( m_bmpChecked.IsOk() || m_bmpChecked.IsOk() ) + if ( m_bmpChecked.IsOk() || m_bmpUnchecked.IsOk() ) { // get size of bitmap always return valid value (0 for invalid bitmap), // so we don't needed check if bitmap is valid ;) @@ -1106,7 +1029,7 @@ bool wxMenuItem::OnDrawItem(wxDC& dc, const wxRect& rc, - data->CheckBgMargin.cyBottomHeight - data->CheckMargin.cyBottomHeight); - if ( IsCheckable() && !m_bmpChecked.Ok() ) + if ( IsCheckable() && !m_bmpChecked.IsOk() ) { if ( stat & wxODChecked ) { @@ -1122,25 +1045,25 @@ bool wxMenuItem::OnDrawItem(wxDC& dc, const wxRect& rc, bmp = GetDisabledBitmap(); } - if ( !bmp.Ok() ) + if ( !bmp.IsOk() ) { // for not checkable bitmaps we should always use unchecked one // because their checked bitmap is not set bmp = GetBitmap(!IsCheckable() || (stat & wxODChecked)); #if wxUSE_IMAGE - if ( bmp.Ok() && stat & wxODDisabled ) + if ( bmp.IsOk() && stat & wxODDisabled ) { // we need to grey out the bitmap as we don't have any specific // disabled bitmap wxImage imgGrey = bmp.ConvertToImage().ConvertToGreyscale(); - if ( imgGrey.Ok() ) + if ( imgGrey.IsOk() ) bmp = wxBitmap(imgGrey); } #endif // wxUSE_IMAGE } - if ( bmp.Ok() ) + if ( bmp.IsOk() ) { wxMemoryDC dcMem(&dc); dcMem.SelectObjectAsSource(bmp);