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