]>
Commit | Line | Data |
---|---|---|
e9576ca5 SC |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: radiobut.cpp | |
3 | // Purpose: wxRadioButton | |
4 | // Author: AUTHOR | |
1dd52151 | 5 | // Modified by: JS Lair (99/11/15) adding the cyclic groupe notion for radiobox |
e9576ca5 SC |
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 | ||
e9576ca5 | 18 | IMPLEMENT_DYNAMIC_CLASS(wxRadioButton, wxControl) |
e9576ca5 | 19 | |
1dd52151 UJ |
20 | #include <wx/mac/uma.h> |
21 | ||
e9576ca5 SC |
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 | { | |
1dd52151 UJ |
29 | Rect bounds ; |
30 | Str255 title ; | |
31 | ||
32 | m_cycle=NULL; | |
33 | ||
34 | MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ; | |
e9576ca5 | 35 | |
1dd52151 UJ |
36 | m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , 1, |
37 | kControlRadioButtonProc , (long) this ) ; | |
38 | ||
39 | MacPostControlCreate() ; | |
e9576ca5 | 40 | |
1dd52151 | 41 | return TRUE; |
e9576ca5 SC |
42 | } |
43 | ||
1dd52151 | 44 | void wxRadioButton::SetValue(bool val) |
e9576ca5 | 45 | { |
1dd52151 UJ |
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 | } | |
e9576ca5 SC |
60 | } |
61 | ||
e9576ca5 SC |
62 | bool wxRadioButton::GetValue() const |
63 | { | |
1dd52151 | 64 | return ::GetControlValue( m_macControl ) ; |
e9576ca5 SC |
65 | } |
66 | ||
67 | void wxRadioButton::Command (wxCommandEvent & event) | |
68 | { | |
1dd52151 | 69 | SetValue ( (event.GetInt() != 0) ); |
e9576ca5 SC |
70 | ProcessCommand (event); |
71 | } | |
72 | ||
1dd52151 UJ |
73 | void wxRadioButton::MacHandleControlClick( ControlHandle control , SInt16 controlpart ) |
74 | { | |
75 | SetValue(true) ; | |
8208e181 SC |
76 | wxCommandEvent event(wxEVT_COMMAND_RADIOBUTTON_SELECTED, m_windowId ); |
77 | event.SetEventObject(this); | |
78 | ProcessCommand(event); | |
1dd52151 UJ |
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 | } | |
e9576ca5 | 97 |