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