]>
Commit | Line | Data |
---|---|---|
0e320a79 DW |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: radiobut.cpp | |
3 | // Purpose: wxRadioButton | |
cdf1e714 | 4 | // Author: David Webster |
0e320a79 | 5 | // Modified by: |
cdf1e714 | 6 | // Created: 10/12/99 |
0e320a79 | 7 | // RCS-ID: $Id$ |
cdf1e714 DW |
8 | // Copyright: (c) David Webster |
9 | // Licence: wxWindows licence | |
0e320a79 DW |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
cdf1e714 DW |
12 | // For compilers that support precompilation, includes "wx.h". |
13 | #include "wx/wxprec.h" | |
14 | ||
15 | #ifdef __BORLANDC__ | |
16 | #pragma hdrstop | |
0e320a79 DW |
17 | #endif |
18 | ||
cdf1e714 DW |
19 | #ifndef WX_PRECOMP |
20 | #include <stdio.h> | |
21 | #include "wx/setup.h" | |
0e320a79 | 22 | #include "wx/radiobut.h" |
cdf1e714 DW |
23 | #include "wx/brush.h" |
24 | #endif | |
25 | ||
11e59d47 | 26 | #include "wx/os2/private.h" |
0e320a79 DW |
27 | |
28 | #if !USE_SHARED_LIBRARY | |
29 | IMPLEMENT_DYNAMIC_CLASS(wxRadioButton, wxControl) | |
004fd0c8 | 30 | IMPLEMENT_DYNAMIC_CLASS(wxBitmapRadioButton, wxRadioButton) |
0e320a79 DW |
31 | #endif |
32 | ||
cdf1e714 DW |
33 | bool wxRadioButton::OS2Command(WXUINT param, WXWORD id) |
34 | { | |
35 | if (param == BN_CLICKED) | |
36 | { | |
37 | wxCommandEvent event(wxEVT_COMMAND_RADIOBUTTON_SELECTED, m_windowId); | |
38 | event.SetEventObject( this ); | |
39 | ProcessCommand(event); | |
40 | return TRUE; | |
41 | } | |
42 | else return FALSE; | |
43 | } | |
44 | ||
0e320a79 | 45 | bool wxRadioButton::Create(wxWindow *parent, wxWindowID id, |
cdf1e714 | 46 | const wxString& label, |
0e320a79 DW |
47 | const wxPoint& pos, |
48 | const wxSize& size, long style, | |
5d4b632b DW |
49 | #if wxUSE_VALIDATORS |
50 | # if defined(__VISAGECPP__) | |
51 | const wxValidator* validator, | |
52 | # else | |
0e320a79 | 53 | const wxValidator& validator, |
5d4b632b DW |
54 | # endif |
55 | #endif | |
0e320a79 DW |
56 | const wxString& name) |
57 | { | |
58 | SetName(name); | |
5d4b632b | 59 | #if wxUSE_VALIDATORS |
0e320a79 | 60 | SetValidator(validator); |
5d4b632b | 61 | #endif |
0e320a79 DW |
62 | |
63 | if (parent) parent->AddChild(this); | |
64 | ||
cdf1e714 DW |
65 | SetBackgroundColour(parent->GetBackgroundColour()); |
66 | SetForegroundColour(parent->GetForegroundColour()); | |
67 | ||
0e320a79 | 68 | if ( id == -1 ) |
cdf1e714 | 69 | m_windowId = (int)NewControlId(); |
0e320a79 | 70 | else |
cdf1e714 DW |
71 | m_windowId = id; |
72 | ||
73 | int x = pos.x; | |
74 | int y = pos.y; | |
75 | int width = size.x; | |
76 | int height = size.y; | |
0e320a79 DW |
77 | |
78 | m_windowStyle = style ; | |
79 | ||
cdf1e714 DW |
80 | // TODO create radiobutton |
81 | /* | |
82 | long groupStyle = 0; | |
83 | if (m_windowStyle & wxRB_GROUP) | |
84 | groupStyle = WS_GROUP; | |
85 | ||
86 | // long msStyle = groupStyle | RADIO_FLAGS; | |
87 | long msStyle = groupStyle | BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE ; | |
88 | ||
89 | bool want3D; | |
90 | WXDWORD exStyle = Determine3DEffects(0, &want3D) ; | |
91 | ||
92 | m_hWnd = (WXHWND) CreateWindowEx(exStyle, RADIO_CLASS, (const wxChar *)label, | |
93 | msStyle,0,0,0,0, | |
94 | (HWND) parent->GetHWND(), (HMENU)m_windowId, wxGetInstance(), NULL); | |
95 | ||
96 | wxCHECK_MSG( m_hWnd, FALSE, wxT("Failed to create radiobutton") ); | |
97 | ||
98 | ||
99 | SetFont(parent->GetFont()); | |
100 | ||
101 | // Subclass again for purposes of dialog editing mode | |
102 | SubclassWin((WXHWND)m_hWnd); | |
103 | ||
104 | // SetValue(value); | |
105 | */ | |
106 | ||
107 | // start GRW fix | |
108 | if (label != wxT("")) | |
109 | { | |
110 | int label_width, label_height; | |
111 | GetTextExtent(label, &label_width, &label_height, NULL, NULL, & this->GetFont()); | |
112 | if (width < 0) | |
113 | width = (int)(label_width + RADIO_SIZE); | |
114 | if (height<0) | |
115 | { | |
116 | height = (int)(label_height); | |
117 | if (height < RADIO_SIZE) | |
118 | height = RADIO_SIZE; | |
119 | } | |
120 | } | |
121 | else | |
122 | { | |
123 | if (width < 0) | |
124 | width = RADIO_SIZE; | |
125 | if (height < 0) | |
126 | height = RADIO_SIZE; | |
127 | } | |
128 | // end GRW fix | |
129 | ||
130 | SetSize(x, y, width, height); | |
131 | return FALSE; | |
0e320a79 DW |
132 | } |
133 | ||
134 | void wxRadioButton::SetLabel(const wxString& label) | |
135 | { | |
136 | // TODO | |
137 | } | |
138 | ||
139 | void wxRadioButton::SetValue(bool value) | |
140 | { | |
141 | // TODO | |
142 | } | |
143 | ||
144 | // Get single selection, for single choice list items | |
145 | bool wxRadioButton::GetValue() const | |
146 | { | |
147 | // TODO | |
148 | return FALSE; | |
149 | } | |
150 | ||
151 | void wxRadioButton::Command (wxCommandEvent & event) | |
152 | { | |
153 | SetValue ( (event.m_commandInt != 0) ); | |
154 | ProcessCommand (event); | |
155 | } | |
156 | ||
cdf1e714 DW |
157 | bool wxBitmapRadioButton::Create(wxWindow *parent, wxWindowID id, |
158 | const wxBitmap *bitmap, | |
159 | const wxPoint& pos, | |
160 | const wxSize& size, long style, | |
5d4b632b DW |
161 | #if wxUSE_VALIDATORS |
162 | # if defined(__VISAGECPP__) | |
163 | const wxValidator* validator, | |
164 | # else | |
cdf1e714 | 165 | const wxValidator& validator, |
5d4b632b DW |
166 | # endif |
167 | #endif | |
cdf1e714 DW |
168 | const wxString& name) |
169 | { | |
170 | SetName(name); | |
5d4b632b | 171 | #if wxUSE_VALIDATORS |
cdf1e714 | 172 | SetValidator(validator); |
5d4b632b | 173 | #endif |
cdf1e714 DW |
174 | |
175 | if (parent) parent->AddChild(this); | |
176 | SetBackgroundColour(parent->GetBackgroundColour()); | |
177 | SetForegroundColour(parent->GetForegroundColour()); | |
178 | ||
179 | if ( id == -1 ) | |
180 | m_windowId = (int)NewControlId(); | |
181 | else | |
182 | m_windowId = id; | |
183 | ||
184 | int x = pos.x; | |
185 | int y = pos.y; | |
186 | int width = size.x; | |
187 | int height = size.y; | |
188 | m_windowStyle = style ; | |
189 | ||
190 | long groupStyle = 0; | |
191 | if (m_windowStyle & wxRB_GROUP) | |
192 | groupStyle = WS_GROUP; | |
193 | ||
194 | // TODO: | |
195 | /* | |
196 | // long msStyle = groupStyle | RADIO_FLAGS; | |
197 | // long msStyle = groupStyle | BS_RADIOBUTTON | WS_CHILD | WS_VISIBLE ; | |
198 | ||
199 | m_hWnd = (WXHWND) CreateWindowEx(MakeExtendedStyle(m_windowStyle), RADIO_CLASS, "toggle", | |
200 | msStyle,0,0,0,0, | |
201 | (HWND) parent->GetHWND(), (HMENU)m_windowId, wxGetInstance(), NULL); | |
202 | ||
203 | wxCHECK_MSG( m_hWnd, "Failed to create radio button", FALSE ); | |
204 | ||
205 | */ | |
206 | // Subclass again for purposes of dialog editing mode | |
207 | SubclassWin(GetHWND()); | |
208 | ||
209 | SetSize(x, y, width, height); | |
210 | ||
211 | return TRUE; | |
212 | } | |
213 | ||
214 | void wxBitmapRadioButton::SetLabel(const wxBitmap *bitmap) | |
215 | { | |
216 | } | |
217 | ||
218 | void wxBitmapRadioButton::SetValue(bool value) | |
219 | { | |
220 | // Following necessary for Win32s, because Win32s translate BM_SETCHECK | |
221 | // SendMessage((HWND) GetHWND(), BM_SETCHECK, (WPARAM)value, 0L); | |
222 | } | |
223 | ||
224 | // Get single selection, for single choice list items | |
225 | bool wxBitmapRadioButton::GetValue(void) const | |
226 | { | |
227 | // return (bool)SendMessage((HWND) GetHWND(), BM_GETCHECK, 0, 0L); | |
228 | return FALSE; | |
229 | } | |
0e320a79 | 230 |