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"
18 #include "wx/radiobut.h"
20 #if !USE_SHARED_LIBRARY
21 IMPLEMENT_DYNAMIC_CLASS(wxRadioButton
, wxControl
)
24 #include "wx/mac/uma.h"
26 bool wxRadioButton::Create(wxWindow
*parent
, wxWindowID id
,
27 const wxString
& label
,
29 const wxSize
& size
, long style
,
30 const wxValidator
& validator
,
36 MacPreControlCreate( parent
, id
, label
, pos
, size
,style
, validator
, name
, &bounds
, title
) ;
38 m_macControl
= ::NewControl( MAC_WXHWND(parent
->MacGetRootWindow()) , &bounds
, title
, false , 0 , 0 , 1,
39 kControlRadioButtonProc
, (long) this ) ;
41 MacPostControlCreate() ;
45 if (HasFlag(wxRB_GROUP
))
51 /* search backward for last group start */
52 wxRadioButton
*chief
= (wxRadioButton
*) NULL
;
53 wxWindowList::Node
*node
= parent
->GetChildren().GetLast();
56 wxWindow
*child
= node
->GetData();
57 if (child
->IsKindOf( CLASSINFO( wxRadioButton
) ) )
59 chief
= (wxRadioButton
*) child
;
60 if (child
->HasFlag(wxRB_GROUP
)) break;
62 node
= node
->GetPrevious();
69 void wxRadioButton::SetValue(bool val
)
72 if ( GetControl32BitValue( (ControlHandle
) m_macControl
) == val
)
75 ::SetControl32BitValue( (ControlHandle
) m_macControl
, val
) ;
78 cycle
=this->NextInCycle();
81 cycle
->SetValue(false);
82 cycle
=cycle
->NextInCycle();
89 bool wxRadioButton::GetValue() const
91 return ::GetControl32BitValue( (ControlHandle
) m_macControl
) ;
94 void wxRadioButton::Command (wxCommandEvent
& event
)
96 SetValue ( (event
.GetInt() != 0) );
97 ProcessCommand (event
);
100 void wxRadioButton::MacHandleControlClick( WXWidget control
, wxInt16 controlpart
)
105 wxRadioButton
*cycle
, *old
= NULL
;
106 cycle
=this->NextInCycle();
108 while (cycle
!=this) {
109 if ( cycle
->GetValue() ) {
111 cycle
->SetValue(false);
113 cycle
=cycle
->NextInCycle();
120 wxCommandEvent
event(wxEVT_COMMAND_RADIOBUTTON_SELECTED
, old
->m_windowId
);
121 event
.SetEventObject(old
);
122 event
.SetInt( false );
123 old
->ProcessCommand(event
);
125 wxCommandEvent
event2(wxEVT_COMMAND_RADIOBUTTON_SELECTED
, m_windowId
);
126 event2
.SetEventObject(this);
127 event2
.SetInt( true );
128 ProcessCommand(event2
);
131 wxRadioButton
*wxRadioButton::AddInCycle(wxRadioButton
*cycle
)
133 wxRadioButton
*next
,*current
;
141 while ((next
=current
->m_cycle
)!=cycle
)
142 current
=current
->m_cycle
;
144 current
->m_cycle
=this;