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() ;
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
)
71 ::SetControlValue( m_macControl
, val
) ;
75 cycle
=this->NextInCycle();
78 cycle
->SetValue(false);
79 cycle
=cycle
->NextInCycle();
85 bool wxRadioButton::GetValue() const
87 return ::GetControlValue( m_macControl
) ;
90 void wxRadioButton::Command (wxCommandEvent
& event
)
92 SetValue ( (event
.GetInt() != 0) );
93 ProcessCommand (event
);
96 void wxRadioButton::MacHandleControlClick( ControlHandle control
, SInt16 controlpart
)
99 wxCommandEvent
event(wxEVT_COMMAND_RADIOBUTTON_SELECTED
, m_windowId
);
100 event
.SetEventObject(this);
101 event
.SetInt( GetValue() );
102 ProcessCommand(event
);
105 wxRadioButton
*wxRadioButton::AddInCycle(wxRadioButton
*cycle
)
107 wxRadioButton
*next
,*current
;
115 while ((next
=current
->m_cycle
)!=cycle
)
116 current
=current
->m_cycle
;
118 current
->m_cycle
=this;