]> git.saurik.com Git - wxWidgets.git/blob - src/mac/radiobut.cpp
Fixed compilation in release mode
[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 IMPLEMENT_DYNAMIC_CLASS(wxRadioButton, wxControl)
19
20 #include <wx/mac/uma.h>
21
22 bool wxRadioButton::Create(wxWindow *parent, wxWindowID id,
23 const wxString& label,
24 const wxPoint& pos,
25 const wxSize& size, long style,
26 const wxValidator& validator,
27 const wxString& name)
28 {
29 Rect bounds ;
30 Str255 title ;
31
32 m_cycle=NULL;
33
34 MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ;
35
36 m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , 1,
37 kControlRadioButtonProc , (long) this ) ;
38
39 MacPostControlCreate() ;
40
41 return TRUE;
42 }
43
44 void wxRadioButton::SetValue(bool val)
45 {
46 int i;
47 wxRadioButton *cycle;
48
49 ::SetControlValue( m_macControl , val ) ;
50
51 if (val) {
52 cycle=this->NextInCycle();
53 if (cycle!=NULL) {
54 while (cycle!=this) {
55 cycle->SetValue(false);
56 cycle=cycle->NextInCycle();
57 }
58 }
59 }
60 }
61
62 bool wxRadioButton::GetValue() const
63 {
64 return ::GetControlValue( m_macControl ) ;
65 }
66
67 void wxRadioButton::Command (wxCommandEvent & event)
68 {
69 SetValue ( (event.GetInt() != 0) );
70 ProcessCommand (event);
71 }
72
73 void wxRadioButton::MacHandleControlClick( ControlHandle control , SInt16 controlpart )
74 {
75 SetValue(true) ;
76 wxCommandEvent event(wxEVT_COMMAND_RADIOBUTTON_SELECTED, m_windowId );
77 event.SetEventObject(this);
78 ProcessCommand(event);
79 }
80
81 wxRadioButton *wxRadioButton::AddInCycle(wxRadioButton *cycle)
82 {
83 wxRadioButton *next,*current;
84
85 if (cycle==NULL) {
86 m_cycle=this;
87 return(this);
88 }
89 else {
90 current=cycle;
91 while ((next=current->m_cycle)!=cycle) current=current->m_cycle;
92 m_cycle=cycle;
93 current->m_cycle=this;
94 return(cycle);
95 }
96 }
97