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