1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxRadioButton
5 // Modified by: JS Lair (99/11/15) adding the cyclic groupe notion for radiobox
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "radiobut.h"
16 #include "wx/radiobut.h"
19 IMPLEMENT_DYNAMIC_CLASS(wxRadioButton
, wxControl
)
21 #include <wx/mac/uma.h>
23 bool wxRadioButton::Create(wxWindow
*parent
, wxWindowID id
,
24 const wxString
& label
,
26 const wxSize
& size
, long style
,
27 const wxValidator
& validator
,
33 MacPreControlCreate( parent
, id
, label
, pos
, size
,style
, validator
, name
, &bounds
, title
) ;
35 m_macControl
= UMANewControl( parent
->GetMacRootWindow() , &bounds
, title
, false , 0 , 0 , 1,
36 kControlRadioButtonProc
, (long) this ) ;
38 MacPostControlCreate() ;
42 if (HasFlag(wxRB_GROUP
))
48 /* search backward for last group start */
49 wxRadioButton
*chief
= (wxRadioButton
*) NULL
;
50 wxWindowList::Node
*node
= parent
->GetChildren().GetLast();
53 wxWindow
*child
= node
->GetData();
54 if (child
->IsKindOf( CLASSINFO( wxRadioButton
) ) )
56 chief
= (wxRadioButton
*) child
;
57 if (child
->HasFlag(wxRB_GROUP
)) break;
59 node
= node
->GetPrevious();
66 void wxRadioButton::SetValue(bool val
)
70 if ( GetControlValue( m_macControl
) == val
)
73 ::SetControlValue( m_macControl
, val
) ;
76 cycle
=this->NextInCycle();
79 cycle
->SetValue(false);
80 cycle
=cycle
->NextInCycle();
84 wxCommandEvent
event(wxEVT_COMMAND_RADIOBUTTON_SELECTED
, m_windowId
);
85 event
.SetEventObject(this);
86 event
.SetInt( GetValue() );
87 ProcessCommand(event
);
90 bool wxRadioButton::GetValue() const
92 return ::GetControlValue( m_macControl
) ;
95 void wxRadioButton::Command (wxCommandEvent
& event
)
97 SetValue ( (event
.GetInt() != 0) );
98 ProcessCommand (event
);
101 void wxRadioButton::MacHandleControlClick( ControlHandle control
, SInt16 controlpart
)
106 wxRadioButton
*wxRadioButton::AddInCycle(wxRadioButton
*cycle
)
108 wxRadioButton
*next
,*current
;
116 while ((next
=current
->m_cycle
)!=cycle
)
117 current
=current
->m_cycle
;
119 current
->m_cycle
=this;