]> git.saurik.com Git - wxWidgets.git/blob - src/mac/radiobut.cpp
adding the notion of cyclic group of radiobutton
[wxWidgets.git] / src / mac / radiobut.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: radiobut.cpp
3 // Purpose: wxRadioButton
4 // Author: AUTHOR
5 // Modified by: JS Lair (99/11/15) adding the cyclic groupe notion for radiobox
6 // Created: ??/??/98
7 // RCS-ID: $Id$
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation "radiobut.h"
14 #endif
15
16 #include "wx/radiobut.h"
17
18 #if !USE_SHARED_LIBRARY
19 IMPLEMENT_DYNAMIC_CLASS(wxRadioButton, wxControl)
20 #endif
21
22 #include <wx/mac/uma.h>
23
24 bool wxRadioButton::Create(wxWindow *parent, wxWindowID id,
25 const wxString& label,
26 const wxPoint& pos,
27 const wxSize& size, long style,
28 const wxValidator& validator,
29 const wxString& name)
30 {
31 Rect bounds ;
32 Str255 title ;
33
34 m_cycle=NULL;
35
36 MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ;
37
38 m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , 1,
39 kControlRadioButtonProc , (long) this ) ;
40
41 MacPostControlCreate() ;
42
43 return TRUE;
44 }
45
46 void wxRadioButton::SetValue(bool val)
47 {
48 int i;
49 wxRadioButton *cycle;
50
51 ::SetControlValue( m_macControl , val ) ;
52
53 if (val) {
54 cycle=this->NextInCycle();
55 if (cycle!=NULL) {
56 while (cycle!=this) {
57 cycle->SetValue(false);
58 cycle=cycle->NextInCycle();
59 }
60 }
61 }
62 }
63
64 bool wxRadioButton::GetValue() const
65 {
66 return ::GetControlValue( m_macControl ) ;
67 }
68
69 void wxRadioButton::Command (wxCommandEvent & event)
70 {
71 SetValue ( (event.GetInt() != 0) );
72 ProcessCommand (event);
73 }
74
75 void wxRadioButton::MacHandleControlClick( ControlHandle control , SInt16 controlpart )
76 {
77 SetValue(true) ;
78 }
79
80 wxRadioButton *wxRadioButton::AddInCycle(wxRadioButton *cycle)
81 {
82 wxRadioButton *next,*current;
83
84 if (cycle==NULL) {
85 m_cycle=this;
86 return(this);
87 }
88 else {
89 current=cycle;
90 while ((next=current->m_cycle)!=cycle) current=current->m_cycle;
91 m_cycle=cycle;
92 current->m_cycle=this;
93 return(cycle);
94 }
95 }
96