]> git.saurik.com Git - wxWidgets.git/blob - src/mac/radiobut.cpp
wxMac:
[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 {
55 cycle=this->NextInCycle();
56 if (cycle!=NULL) {
57 while (cycle!=this) {
58 cycle->SetValue(false);
59 cycle=cycle->NextInCycle();
60 }
61 }
62 }
63 }
64
65 bool wxRadioButton::GetValue() const
66 {
67 return ::GetControlValue( m_macControl ) ;
68 }
69
70 void wxRadioButton::Command (wxCommandEvent & event)
71 {
72 SetValue ( (event.GetInt() != 0) );
73 ProcessCommand (event);
74 }
75
76 void wxRadioButton::MacHandleControlClick( ControlHandle control , SInt16 controlpart )
77 {
78 SetValue(true) ;
79 wxCommandEvent event(wxEVT_COMMAND_RADIOBUTTON_SELECTED, m_windowId );
80 event.SetEventObject(this);
81 ProcessCommand(event);
82 }
83
84 wxRadioButton *wxRadioButton::AddInCycle(wxRadioButton *cycle)
85 {
86 wxRadioButton *next,*current;
87
88 if (cycle==NULL) {
89 m_cycle=this;
90 return(this);
91 }
92 else {
93 current=cycle;
94 while ((next=current->m_cycle)!=cycle) current=current->m_cycle;
95 m_cycle=cycle;
96 current->m_cycle=this;
97 return(cycle);
98 }
99 }