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