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