]> git.saurik.com Git - wxWidgets.git/blob - src/os2/radiobut.cpp
reverted change to the best checkbox size calculation
[wxWidgets.git] / src / os2 / radiobut.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: radiobut.cpp
3 // Purpose: wxRadioButton
4 // Author: David Webster
5 // Modified by:
6 // Created: 10/12/99
7 // RCS-ID: $Id$
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
14
15 #ifdef __BORLANDC__
16 #pragma hdrstop
17 #endif
18
19 #ifndef WX_PRECOMP
20 #include <stdio.h>
21 #include "wx/setup.h"
22 #include "wx/radiobut.h"
23 #include "wx/brush.h"
24 #endif
25
26 #include "wx/os2/private.h"
27
28 IMPLEMENT_DYNAMIC_CLASS(wxRadioButton, wxControl)
29
30 bool wxRadioButton::OS2Command(WXUINT param, WXWORD id)
31 {
32 if (param == BN_CLICKED)
33 {
34 wxCommandEvent event(wxEVT_COMMAND_RADIOBUTTON_SELECTED, m_windowId);
35 event.SetEventObject( this );
36 ProcessCommand(event);
37 return TRUE;
38 }
39 else return FALSE;
40 }
41
42 bool wxRadioButton::Create(wxWindow *parent, wxWindowID id,
43 const wxString& label,
44 const wxPoint& pos,
45 const wxSize& size, long style,
46 #if wxUSE_VALIDATORS
47 const wxValidator& validator,
48 #endif
49 const wxString& name)
50 {
51 SetName(name);
52 #if wxUSE_VALIDATORS
53 SetValidator(validator);
54 #endif
55
56 if (parent) parent->AddChild(this);
57
58 SetBackgroundColour(parent->GetBackgroundColour());
59 SetForegroundColour(parent->GetForegroundColour());
60
61 if ( id == -1 )
62 m_windowId = (int)NewControlId();
63 else
64 m_windowId = id;
65
66 int x = pos.x;
67 int y = pos.y;
68 int width = size.x;
69 int height = size.y;
70
71 m_windowStyle = style ;
72
73 // TODO create radiobutton
74 /*
75 long groupStyle = 0;
76 if (m_windowStyle & wxRB_GROUP)
77 groupStyle = WS_GROUP;
78
79 // long msStyle = groupStyle | RADIO_FLAGS;
80 long msStyle = groupStyle | BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE ;
81
82 bool want3D;
83 WXDWORD exStyle = Determine3DEffects(0, &want3D) ;
84
85 m_hWnd = (WXHWND) CreateWindowEx(exStyle, RADIO_CLASS, (const wxChar *)label,
86 msStyle,0,0,0,0,
87 (HWND) parent->GetHWND(), (HMENU)m_windowId, wxGetInstance(), NULL);
88
89 wxCHECK_MSG( m_hWnd, FALSE, wxT("Failed to create radiobutton") );
90
91
92 SetFont(parent->GetFont());
93
94 // Subclass again for purposes of dialog editing mode
95 SubclassWin((WXHWND)m_hWnd);
96
97 // SetValue(value);
98 */
99
100 // start GRW fix
101 if (label != wxT(""))
102 {
103 int label_width, label_height;
104 GetTextExtent(label, &label_width, &label_height, NULL, NULL, & this->GetFont());
105 if (width < 0)
106 width = (int)(label_width + RADIO_SIZE);
107 if (height<0)
108 {
109 height = (int)(label_height);
110 if (height < RADIO_SIZE)
111 height = RADIO_SIZE;
112 }
113 }
114 else
115 {
116 if (width < 0)
117 width = RADIO_SIZE;
118 if (height < 0)
119 height = RADIO_SIZE;
120 }
121 // end GRW fix
122
123 SetSize(x, y, width, height);
124 return FALSE;
125 }
126
127 void wxRadioButton::SetLabel(const wxString& label)
128 {
129 // TODO
130 }
131
132 void wxRadioButton::SetValue(bool value)
133 {
134 // TODO
135 }
136
137 // Get single selection, for single choice list items
138 bool wxRadioButton::GetValue() const
139 {
140 // TODO
141 return FALSE;
142 }
143
144 void wxRadioButton::Command (wxCommandEvent & event)
145 {
146 SetValue ( (event.m_commandInt != 0) );
147 ProcessCommand (event);
148 }
149
150 // Not implemented
151 #if 0
152
153 bool wxBitmapRadioButton::Create(wxWindow *parent, wxWindowID id,
154 const wxBitmap *bitmap,
155 const wxPoint& pos,
156 const wxSize& size, long style,
157 #if wxUSE_VALIDATORS
158 const wxValidator& validator,
159 #endif
160 const wxString& name)
161 {
162 SetName(name);
163 #if wxUSE_VALIDATORS
164 SetValidator(validator);
165 #endif
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 }
222
223 #endif