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