]>
Commit | Line | Data |
---|---|---|
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 | } | |
77 | ||
78 | wxRadioButton *wxRadioButton::AddInCycle(wxRadioButton *cycle) | |
79 | { | |
80 | wxRadioButton *next,*current; | |
81 | ||
82 | if (cycle==NULL) { | |
83 | m_cycle=this; | |
84 | return(this); | |
85 | } | |
86 | else { | |
87 | current=cycle; | |
88 | while ((next=current->m_cycle)!=cycle) current=current->m_cycle; | |
89 | m_cycle=cycle; | |
90 | current->m_cycle=this; | |
91 | return(cycle); | |
92 | } | |
93 | } | |
94 |