]> git.saurik.com Git - wxWidgets.git/blame - src/os2/radiobut.cpp
New .def file
[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 27
0e320a79 28IMPLEMENT_DYNAMIC_CLASS(wxRadioButton, wxControl)
0e320a79 29
cdf1e714
DW
30bool 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
0e320a79 42bool wxRadioButton::Create(wxWindow *parent, wxWindowID id,
cdf1e714 43 const wxString& label,
0e320a79
DW
44 const wxPoint& pos,
45 const wxSize& size, long style,
5d4b632b 46#if wxUSE_VALIDATORS
0e320a79 47 const wxValidator& validator,
5d4b632b 48#endif
0e320a79
DW
49 const wxString& name)
50{
51 SetName(name);
5d4b632b 52#if wxUSE_VALIDATORS
0e320a79 53 SetValidator(validator);
5d4b632b 54#endif
0e320a79
DW
55
56 if (parent) parent->AddChild(this);
57
cdf1e714
DW
58 SetBackgroundColour(parent->GetBackgroundColour());
59 SetForegroundColour(parent->GetForegroundColour());
60
0e320a79 61 if ( id == -1 )
cdf1e714 62 m_windowId = (int)NewControlId();
0e320a79 63 else
cdf1e714
DW
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;
0e320a79
DW
70
71 m_windowStyle = style ;
72
cdf1e714
DW
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;
0e320a79
DW
125}
126
127void wxRadioButton::SetLabel(const wxString& label)
128{
129 // TODO
130}
131
132void wxRadioButton::SetValue(bool value)
133{
134 // TODO
135}
136
137// Get single selection, for single choice list items
138bool wxRadioButton::GetValue() const
139{
140 // TODO
141 return FALSE;
142}
143
144void wxRadioButton::Command (wxCommandEvent & event)
145{
146 SetValue ( (event.m_commandInt != 0) );
147 ProcessCommand (event);
148}
149
0367c1c0
DW
150// Not implemented
151#if 0
152
cdf1e714
DW
153bool wxBitmapRadioButton::Create(wxWindow *parent, wxWindowID id,
154 const wxBitmap *bitmap,
155 const wxPoint& pos,
156 const wxSize& size, long style,
5d4b632b 157#if wxUSE_VALIDATORS
cdf1e714 158 const wxValidator& validator,
5d4b632b 159#endif
cdf1e714
DW
160 const wxString& name)
161{
162 SetName(name);
5d4b632b 163#if wxUSE_VALIDATORS
cdf1e714 164 SetValidator(validator);
5d4b632b 165#endif
cdf1e714
DW
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
206void wxBitmapRadioButton::SetLabel(const wxBitmap *bitmap)
207{
208}
209
210void 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
217bool wxBitmapRadioButton::GetValue(void) const
218{
219// return (bool)SendMessage((HWND) GetHWND(), BM_GETCHECK, 0, 0L);
220 return FALSE;
221}
0e320a79 222
0367c1c0 223#endif