X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1dd521517c6a7047dce77302cd35a7f07ee2f595..d2c6d54928e7ba32b2bf6ddf0ca5f3dd4339758b:/src/mac/carbon/radiobut.cpp?ds=inline diff --git a/src/mac/carbon/radiobut.cpp b/src/mac/carbon/radiobut.cpp index 0c712b61f9..1f5bb9c67a 100644 --- a/src/mac/carbon/radiobut.cpp +++ b/src/mac/carbon/radiobut.cpp @@ -15,9 +15,12 @@ #include "wx/radiobut.h" -#if !USE_SHARED_LIBRARY + IMPLEMENT_DYNAMIC_CLASS(wxRadioButton, wxControl) -#endif + +BEGIN_EVENT_TABLE(wxRadioButton, wxControl) + EVT_IDLE( wxRadioButton::OnIdle ) +END_EVENT_TABLE() #include @@ -40,7 +43,53 @@ bool wxRadioButton::Create(wxWindow *parent, wxWindowID id, MacPostControlCreate() ; - return TRUE; + return TRUE; +} + +void wxRadioButton::OnIdle( wxIdleEvent &event ) +{ + if (!m_cycle && HasFlag(wxRB_GROUP)) + { + // we are a stand-alone radiobutton and have + // the group flag indicating we have to collect + // the other radiobuttons belonging to this one + + bool reached_this = FALSE; + wxRadioButton *m_radioButtonCycle = NULL; + m_radioButtonCycle = AddInCycle( m_radioButtonCycle ); + + wxWindow *parent = GetParent(); + wxNode *node = parent->GetChildren().First(); + while (node) + { + wxWindow *child = (wxWindow*) node->Data(); + + node = node->Next(); + + // start searching behind current radiobutton + if (!reached_this) + { + reached_this = (this == child); + continue; + } + + if (child->IsKindOf( CLASSINFO ( wxRadioButton ) )) + { + wxRadioButton *rb = (wxRadioButton*) child; + + // already reached next group + if (rb->HasFlag(wxRB_GROUP)) break; + + // part of a radiobox + if (rb->NextInCycle()) break; + + m_radioButtonCycle = rb->AddInCycle( m_radioButtonCycle ); + } + } + + } + + event.Skip( TRUE ); } void wxRadioButton::SetValue(bool val) @@ -50,7 +99,8 @@ void wxRadioButton::SetValue(bool val) ::SetControlValue( m_macControl , val ) ; - if (val) { + if (val) + { cycle=this->NextInCycle(); if (cycle!=NULL) { while (cycle!=this) { @@ -75,6 +125,9 @@ void wxRadioButton::Command (wxCommandEvent & event) void wxRadioButton::MacHandleControlClick( ControlHandle control , SInt16 controlpart ) { SetValue(true) ; + wxCommandEvent event(wxEVT_COMMAND_RADIOBUTTON_SELECTED, m_windowId ); + event.SetEventObject(this); + ProcessCommand(event); } wxRadioButton *wxRadioButton::AddInCycle(wxRadioButton *cycle) @@ -93,4 +146,3 @@ wxRadioButton *wxRadioButton::AddInCycle(wxRadioButton *cycle) return(cycle); } } -