]> git.saurik.com Git - wxWidgets.git/blob - src/os2/radiobut.cpp
<br><br><br> is now handled correctly, e.g. empty lines are inserted (unlike <p>...
[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 #if !USE_SHARED_LIBRARY
29 IMPLEMENT_DYNAMIC_CLASS(wxRadioButton, wxControl)
30 IMPLEMENT_DYNAMIC_CLASS(wxBitmapRadioButton, wxRadioButton)
31 #endif
32
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
45 bool wxRadioButton::Create(wxWindow *parent, wxWindowID id,
46 const wxString& label,
47 const wxPoint& pos,
48 const wxSize& size, long style,
49 #if wxUSE_VALIDATORS
50 # if defined(__VISAGECPP__)
51 const wxValidator* validator,
52 # else
53 const wxValidator& validator,
54 # endif
55 #endif
56 const wxString& name)
57 {
58 SetName(name);
59 #if wxUSE_VALIDATORS
60 SetValidator(validator);
61 #endif
62
63 if (parent) parent->AddChild(this);
64
65 SetBackgroundColour(parent->GetBackgroundColour());
66 SetForegroundColour(parent->GetForegroundColour());
67
68 if ( id == -1 )
69 m_windowId = (int)NewControlId();
70 else
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;
77
78 m_windowStyle = style ;
79
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;
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
157 bool wxBitmapRadioButton::Create(wxWindow *parent, wxWindowID id,
158 const wxBitmap *bitmap,
159 const wxPoint& pos,
160 const wxSize& size, long style,
161 #if wxUSE_VALIDATORS
162 # if defined(__VISAGECPP__)
163 const wxValidator* validator,
164 # else
165 const wxValidator& validator,
166 # endif
167 #endif
168 const wxString& name)
169 {
170 SetName(name);
171 #if wxUSE_VALIDATORS
172 SetValidator(validator);
173 #endif
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 }
230