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
, true , 0 , 0 , 1,
36 kControlRadioButtonProc
, (long) this ) ;
38 MacPostControlCreate() ;
40 if (HasFlag(wxRB_GROUP
))
46 /* search backward for last group start */
47 wxRadioButton
*chief
= (wxRadioButton
*) NULL
;
48 wxWindowList::Node
*node
= parent
->GetChildren().GetLast();
51 wxWindow
*child
= node
->GetData();
52 if (child
->IsKindOf( CLASSINFO( wxRadioButton
) ) )
54 chief
= (wxRadioButton
*) child
;
55 if (child
->HasFlag(wxRB_GROUP
)) break;
57 node
= node
->GetPrevious();
64 void wxRadioButton::SetValue(bool val
)
69 ::SetControlValue( m_macControl
, val
) ;
73 cycle
=this->NextInCycle();
76 cycle
->SetValue(false);
77 cycle
=cycle
->NextInCycle();
83 bool wxRadioButton::GetValue() const
85 return ::GetControlValue( m_macControl
) ;
88 void wxRadioButton::Command (wxCommandEvent
& event
)
90 SetValue ( (event
.GetInt() != 0) );
91 ProcessCommand (event
);
94 void wxRadioButton::MacHandleControlClick( ControlHandle control
, SInt16 controlpart
)
97 wxCommandEvent
event(wxEVT_COMMAND_RADIOBUTTON_SELECTED
, m_windowId
);
98 event
.SetEventObject(this);
99 event
.SetInt( GetValue() );
100 ProcessCommand(event
);
103 wxRadioButton
*wxRadioButton::AddInCycle(wxRadioButton
*cycle
)
105 wxRadioButton
*next
,*current
;
113 while ((next
=current
->m_cycle
)!=cycle
)
114 current
=current
->m_cycle
;
116 current
->m_cycle
=this;