Reimplement adding items to radio groups in wxMenu (wxOSX)
Rewrote wxOSX radio groups-related code reusing the code which works on
wxMSW and which seems to provide more rich functionality (supports adding
radio as well as no-radio items) and to have known bugs fixed.
The ranges of all radio groups are stored in wxMenu itself instead of
storing the information about the radio group an item belongs to in
the item itself - see 89511b4268
.
Closes #14213.
Closes #17568.
This commit is contained in:
@@ -44,9 +44,6 @@ wxMenuItem::wxMenuItem(wxMenu *pParentMenu,
|
||||
if ( wxStripMenuCodes(m_text).Upper() == wxT("EXIT") )
|
||||
m_text = wxT("Quit\tCtrl+Q") ;
|
||||
|
||||
m_radioGroup.start = -1;
|
||||
m_isRadioGroupStart = false;
|
||||
|
||||
wxString text = wxStripMenuCodes(m_text, (pParentMenu != NULL && pParentMenu->GetNoEventsMode()) ? wxStrip_Accel : wxStrip_All);
|
||||
if (text.IsEmpty() && !IsSeparator())
|
||||
{
|
||||
@@ -122,18 +119,9 @@ void wxMenuItem::Check(bool bDoCheck)
|
||||
|
||||
// get the radio group range
|
||||
int start, end;
|
||||
|
||||
if ( m_isRadioGroupStart )
|
||||
if ( !m_parentMenu->OSXGetRadioGroupRange(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( wxS("Menu radio item not part of radio group?") );
|
||||
}
|
||||
|
||||
// also uncheck all the other items in this radio group
|
||||
@@ -211,51 +199,6 @@ void wxMenuItem::UpdateItemText()
|
||||
delete entry ;
|
||||
}
|
||||
|
||||
// radio group stuff
|
||||
// -----------------
|
||||
|
||||
void wxMenuItem::SetAsRadioGroupStart(bool start)
|
||||
{
|
||||
m_isRadioGroupStart = start;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
bool wxMenuItem::IsRadioGroupStart() const
|
||||
{
|
||||
return m_isRadioGroupStart;
|
||||
}
|
||||
|
||||
int wxMenuItem::GetRadioGroupStart() const
|
||||
{
|
||||
wxASSERT_MSG( !m_isRadioGroupStart,
|
||||
wxS("shouldn't be called for the first radio item") );
|
||||
|
||||
return m_radioGroup.start;
|
||||
}
|
||||
|
||||
int wxMenuItem::GetRadioGroupEnd() const
|
||||
{
|
||||
wxASSERT_MSG( m_isRadioGroupStart,
|
||||
wxS("shouldn't be called for the first radio item") );
|
||||
|
||||
return m_radioGroup.end;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxMenuItemBase
|
||||
// ----------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user