]> git.saurik.com Git - wxWidgets.git/blame - src/os2/checkbox.cpp
removed obsolete files and added missing ones
[wxWidgets.git] / src / os2 / checkbox.cpp
CommitLineData
0e320a79
DW
1/////////////////////////////////////////////////////////////////////////////
2// Name: checkbox.cpp
3// Purpose: wxCheckBox
37f214d5 4// Author: David Webster
0e320a79 5// Modified by:
37f214d5 6// Created: 10/13/99
0e320a79 7// RCS-ID: $Id$
37f214d5
DW
8// Copyright: (c) David Webster
9// Licence: wxWindows licence
0e320a79
DW
10/////////////////////////////////////////////////////////////////////////////
11
37f214d5
DW
12// For compilers that support precompilation, includes "wx.h".
13#include "wx/wxprec.h"
14
15#ifndef WX_PRECOMP
16 #include "wx/checkbox.h"
17 #include "wx/brush.h"
0e320a79
DW
18#endif
19
37f214d5
DW
20#include "wx/os2/private.h"
21
22// ----------------------------------------------------------------------------
23// macros
24// ----------------------------------------------------------------------------
0e320a79 25
0e320a79
DW
26IMPLEMENT_DYNAMIC_CLASS(wxCheckBox, wxControl)
27IMPLEMENT_DYNAMIC_CLASS(wxBitmapCheckBox, wxCheckBox)
0e320a79 28
37f214d5
DW
29// ============================================================================
30// implementation
31// ============================================================================
32
33// ----------------------------------------------------------------------------
34// wxCheckBox
35// ----------------------------------------------------------------------------
36
37bool wxCheckBox::OS2Command(WXUINT WXUNUSED(param), WXWORD WXUNUSED(id))
38{
39 wxCommandEvent event(wxEVT_COMMAND_CHECKBOX_CLICKED, m_windowId);
40 event.SetInt(GetValue());
41 event.SetEventObject(this);
42 ProcessCommand(event);
43 return TRUE;
44}
45
0e320a79
DW
46// Single check box item
47bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
48 const wxPoint& pos,
49 const wxSize& size, long style,
5d4b632b 50#if wxUSE_VALIDATORS
0e320a79 51 const wxValidator& validator,
5d4b632b 52#endif
0e320a79
DW
53 const wxString& name)
54{
55 SetName(name);
5d4b632b 56#if wxUSE_VALIDATORS
0e320a79 57 SetValidator(validator);
5d4b632b 58#endif
37f214d5
DW
59 if (parent) parent->AddChild(this);
60
61 SetBackgroundColour(parent->GetBackgroundColour()) ;
62 SetForegroundColour(parent->GetForegroundColour()) ;
63
0e320a79
DW
64 m_windowStyle = style;
65
37f214d5
DW
66 wxString Label = label;
67 if (Label == wxT(""))
68 Label = wxT(" "); // Apparently needed or checkbox won't show
0e320a79
DW
69
70 if ( id == -1 )
71 m_windowId = NewControlId();
72 else
73 m_windowId = id;
74
37f214d5
DW
75 int x = pos.x;
76 int y = pos.y;
77 int width = size.x;
78 int height = size.y;
79
0e320a79
DW
80 // TODO: create checkbox
81
37f214d5
DW
82 // Subclass again for purposes of dialog editing mode
83 SubclassWin(m_hWnd);
84
7993e67c
DW
85 LONG lColor = (LONG)m_backgroundColour.GetPixel();
86
87 ::WinSetPresParam( m_hWnd
88 ,PP_BACKGROUNDCOLOR
89 ,sizeof(LONG)
90 ,(PVOID)&lColor
91 );
92
37f214d5
DW
93 SetFont(parent->GetFont());
94
95 SetSize(x, y, width, height);
96
0e320a79
DW
97 return FALSE;
98}
99
100void wxCheckBox::SetLabel(const wxString& label)
101{
102 // TODO
103}
104
e78c4d50 105wxSize wxCheckBox::DoGetBestSize() const
0e320a79 106{
37f214d5
DW
107 int wCheckbox, hCheckbox;
108
109 wxString str = wxGetWindowText(GetHWND());
110
111 if ( !str.IsEmpty() )
112 {
113 GetTextExtent(str, &wCheckbox, &hCheckbox);
114 wCheckbox += RADIO_SIZE;
115
116 if ( hCheckbox < RADIO_SIZE )
117 hCheckbox = RADIO_SIZE;
118 }
119 else
120 {
121 wCheckbox = RADIO_SIZE;
122 hCheckbox = RADIO_SIZE;
123 }
124
125 return wxSize(wCheckbox, hCheckbox);
0e320a79
DW
126}
127
128void wxCheckBox::SetValue(bool val)
129{
130 // TODO
131}
132
37f214d5
DW
133#ifndef BST_CHECKED
134#define BST_CHECKED 0x0001
135#endif
136
0e320a79
DW
137bool wxCheckBox::GetValue() const
138{
139 // TODO
140 return FALSE;
141}
142
37f214d5
DW
143WXHBRUSH wxCheckBox::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
144 WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
145{
146 // TODO:
147 /*
148#if wxUSE_CTL3D
149 if ( m_useCtl3D )
150 {
151 HBRUSH hbrush = Ctl3dCtlColorEx(message, wParam, lParam);
152
153 return (WXHBRUSH) hbrush;
154 }
155#endif
156
157 if (GetParent()->GetTransparentBackground())
158 SetBkMode((HDC) pDC, TRANSPARENT);
159 else
160 SetBkMode((HDC) pDC, OPAQUE);
161
162 ::SetBkColor((HDC) pDC, RGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
163 ::SetTextColor((HDC) pDC, RGB(GetForegroundColour().Red(), GetForegroundColour().Green(), GetForegroundColour().Blue()));
164
165*/
166
167 wxBrush *backgroundBrush = wxTheBrushList->FindOrCreateBrush(GetBackgroundColour(), wxSOLID);
168
169
170 // Note that this will be cleaned up in wxApp::OnIdle, if backgroundBrush
171 // has a zero usage count.
172// backgroundBrush->RealizeResource();
173 return (WXHBRUSH) backgroundBrush->GetResourceHandle();
174}
175
0e320a79
DW
176void wxCheckBox::Command (wxCommandEvent & event)
177{
178 SetValue ((event.GetInt() != 0));
179 ProcessCommand (event);
180}
181
37f214d5
DW
182// ----------------------------------------------------------------------------
183// wxBitmapCheckBox
184// ----------------------------------------------------------------------------
185
0e320a79
DW
186bool wxBitmapCheckBox::Create(wxWindow *parent, wxWindowID id, const wxBitmap *label,
187 const wxPoint& pos,
188 const wxSize& size, long style,
5d4b632b 189#if wxUSE_VALIDATORS
0e320a79 190 const wxValidator& validator,
5d4b632b 191#endif
0e320a79
DW
192 const wxString& name)
193{
194 SetName(name);
5d4b632b 195#if wxUSE_VALIDATORS
0e320a79 196 SetValidator(validator);
5d4b632b 197#endif
0e320a79
DW
198 if (parent) parent->AddChild(this);
199
37f214d5
DW
200 SetBackgroundColour(parent->GetBackgroundColour()) ;
201 SetForegroundColour(parent->GetForegroundColour()) ;
202 m_windowStyle = style;
203
0e320a79
DW
204 if ( id == -1 )
205 m_windowId = NewControlId();
206 else
207 m_windowId = id;
208
37f214d5
DW
209 int x = pos.x;
210 int y = pos.y;
211 int width = size.x;
212 int height = size.y;
0e320a79 213
37f214d5
DW
214 checkWidth = -1 ;
215 checkHeight = -1 ;
892b89f3 216// long msStyle = CHECK_FLAGS;
0e320a79 217
37f214d5 218 HWND wx_button = 0; // TODO: Create the bitmap checkbox
0e320a79 219
37f214d5 220 m_hWnd = (WXHWND)wx_button;
0e320a79 221
37f214d5
DW
222 // Subclass again for purposes of dialog editing mode
223 SubclassWin((WXHWND)wx_button);
224
225 SetSize(x, y, width, height);
226
227// TODO: ShowWindow(wx_button, SW_SHOW);
228
229 return TRUE;
0e320a79
DW
230}
231
37f214d5 232void wxBitmapCheckBox::SetLabel(const wxBitmap& bitmap)
0e320a79 233{
37f214d5 234 wxFAIL_MSG(wxT("not implemented"));
0e320a79
DW
235}
236