]>
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 | 49 | #if wxUSE_VALIDATORS |
0e320a79 | 50 | const wxValidator& validator, |
5d4b632b | 51 | #endif |
0e320a79 DW |
52 | const wxString& name) |
53 | { | |
54 | SetName(name); | |
5d4b632b | 55 | #if wxUSE_VALIDATORS |
0e320a79 | 56 | SetValidator(validator); |
5d4b632b | 57 | #endif |
0e320a79 DW |
58 | |
59 | if (parent) parent->AddChild(this); | |
60 | ||
cdf1e714 DW |
61 | SetBackgroundColour(parent->GetBackgroundColour()); |
62 | SetForegroundColour(parent->GetForegroundColour()); | |
63 | ||
0e320a79 | 64 | if ( id == -1 ) |
cdf1e714 | 65 | m_windowId = (int)NewControlId(); |
0e320a79 | 66 | else |
cdf1e714 DW |
67 | m_windowId = id; |
68 | ||
69 | int x = pos.x; | |
70 | int y = pos.y; | |
71 | int width = size.x; | |
72 | int height = size.y; | |
0e320a79 DW |
73 | |
74 | m_windowStyle = style ; | |
75 | ||
cdf1e714 DW |
76 | // TODO create radiobutton |
77 | /* | |
78 | long groupStyle = 0; | |
79 | if (m_windowStyle & wxRB_GROUP) | |
80 | groupStyle = WS_GROUP; | |
81 | ||
82 | // long msStyle = groupStyle | RADIO_FLAGS; | |
83 | long msStyle = groupStyle | BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE ; | |
84 | ||
85 | bool want3D; | |
86 | WXDWORD exStyle = Determine3DEffects(0, &want3D) ; | |
87 | ||
88 | m_hWnd = (WXHWND) CreateWindowEx(exStyle, RADIO_CLASS, (const wxChar *)label, | |
89 | msStyle,0,0,0,0, | |
90 | (HWND) parent->GetHWND(), (HMENU)m_windowId, wxGetInstance(), NULL); | |
91 | ||
92 | wxCHECK_MSG( m_hWnd, FALSE, wxT("Failed to create radiobutton") ); | |
93 | ||
94 | ||
95 | SetFont(parent->GetFont()); | |
96 | ||
97 | // Subclass again for purposes of dialog editing mode | |
98 | SubclassWin((WXHWND)m_hWnd); | |
99 | ||
100 | // SetValue(value); | |
101 | */ | |
102 | ||
103 | // start GRW fix | |
104 | if (label != wxT("")) | |
105 | { | |
106 | int label_width, label_height; | |
107 | GetTextExtent(label, &label_width, &label_height, NULL, NULL, & this->GetFont()); | |
108 | if (width < 0) | |
109 | width = (int)(label_width + RADIO_SIZE); | |
110 | if (height<0) | |
111 | { | |
112 | height = (int)(label_height); | |
113 | if (height < RADIO_SIZE) | |
114 | height = RADIO_SIZE; | |
115 | } | |
116 | } | |
117 | else | |
118 | { | |
119 | if (width < 0) | |
120 | width = RADIO_SIZE; | |
121 | if (height < 0) | |
122 | height = RADIO_SIZE; | |
123 | } | |
124 | // end GRW fix | |
125 | ||
126 | SetSize(x, y, width, height); | |
127 | return FALSE; | |
0e320a79 DW |
128 | } |
129 | ||
130 | void wxRadioButton::SetLabel(const wxString& label) | |
131 | { | |
132 | // TODO | |
133 | } | |
134 | ||
135 | void wxRadioButton::SetValue(bool value) | |
136 | { | |
137 | // TODO | |
138 | } | |
139 | ||
140 | // Get single selection, for single choice list items | |
141 | bool wxRadioButton::GetValue() const | |
142 | { | |
143 | // TODO | |
144 | return FALSE; | |
145 | } | |
146 | ||
147 | void wxRadioButton::Command (wxCommandEvent & event) | |
148 | { | |
149 | SetValue ( (event.m_commandInt != 0) ); | |
150 | ProcessCommand (event); | |
151 | } | |
152 | ||
cdf1e714 DW |
153 | bool wxBitmapRadioButton::Create(wxWindow *parent, wxWindowID id, |
154 | const wxBitmap *bitmap, | |
155 | const wxPoint& pos, | |
156 | const wxSize& size, long style, | |
5d4b632b | 157 | #if wxUSE_VALIDATORS |
cdf1e714 | 158 | const wxValidator& validator, |
5d4b632b | 159 | #endif |
cdf1e714 DW |
160 | const wxString& name) |
161 | { | |
162 | SetName(name); | |
5d4b632b | 163 | #if wxUSE_VALIDATORS |
cdf1e714 | 164 | SetValidator(validator); |
5d4b632b | 165 | #endif |
cdf1e714 DW |
166 | |
167 | if (parent) parent->AddChild(this); | |
168 | SetBackgroundColour(parent->GetBackgroundColour()); | |
169 | SetForegroundColour(parent->GetForegroundColour()); | |
170 | ||
171 | if ( id == -1 ) | |
172 | m_windowId = (int)NewControlId(); | |
173 | else | |
174 | m_windowId = id; | |
175 | ||
176 | int x = pos.x; | |
177 | int y = pos.y; | |
178 | int width = size.x; | |
179 | int height = size.y; | |
180 | m_windowStyle = style ; | |
181 | ||
182 | long groupStyle = 0; | |
183 | if (m_windowStyle & wxRB_GROUP) | |
184 | groupStyle = WS_GROUP; | |
185 | ||
186 | // TODO: | |
187 | /* | |
188 | // long msStyle = groupStyle | RADIO_FLAGS; | |
189 | // long msStyle = groupStyle | BS_RADIOBUTTON | WS_CHILD | WS_VISIBLE ; | |
190 | ||
191 | m_hWnd = (WXHWND) CreateWindowEx(MakeExtendedStyle(m_windowStyle), RADIO_CLASS, "toggle", | |
192 | msStyle,0,0,0,0, | |
193 | (HWND) parent->GetHWND(), (HMENU)m_windowId, wxGetInstance(), NULL); | |
194 | ||
195 | wxCHECK_MSG( m_hWnd, "Failed to create radio button", FALSE ); | |
196 | ||
197 | */ | |
198 | // Subclass again for purposes of dialog editing mode | |
199 | SubclassWin(GetHWND()); | |
200 | ||
201 | SetSize(x, y, width, height); | |
202 | ||
203 | return TRUE; | |
204 | } | |
205 | ||
206 | void wxBitmapRadioButton::SetLabel(const wxBitmap *bitmap) | |
207 | { | |
208 | } | |
209 | ||
210 | void wxBitmapRadioButton::SetValue(bool value) | |
211 | { | |
212 | // Following necessary for Win32s, because Win32s translate BM_SETCHECK | |
213 | // SendMessage((HWND) GetHWND(), BM_SETCHECK, (WPARAM)value, 0L); | |
214 | } | |
215 | ||
216 | // Get single selection, for single choice list items | |
217 | bool wxBitmapRadioButton::GetValue(void) const | |
218 | { | |
219 | // return (bool)SendMessage((HWND) GetHWND(), BM_GETCHECK, 0, 0L); | |
220 | return FALSE; | |
221 | } | |
0e320a79 | 222 |