]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/os2/checkbox.cpp
added default ctor for wxDirDialog
[wxWidgets.git] / src / os2 / checkbox.cpp
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: checkbox.cpp
3// Purpose: wxCheckBox
4// Author: David Webster
5// Modified by:
6// Created: 10/13/99
7// RCS-ID: $Id$
8// Copyright: (c) David Webster
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
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"
18#endif
19
20#include "wx/os2/private.h"
21
22// ----------------------------------------------------------------------------
23// macros
24// ----------------------------------------------------------------------------
25
26#if !USE_SHARED_LIBRARY
27IMPLEMENT_DYNAMIC_CLASS(wxCheckBox, wxControl)
28IMPLEMENT_DYNAMIC_CLASS(wxBitmapCheckBox, wxCheckBox)
29#endif
30
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
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,
52#if wxUSE_VALIDATORS
53 const wxValidator& validator,
54#endif
55 const wxString& name)
56{
57 SetName(name);
58#if wxUSE_VALIDATORS
59 SetValidator(validator);
60#endif
61 if (parent) parent->AddChild(this);
62
63 SetBackgroundColour(parent->GetBackgroundColour()) ;
64 SetForegroundColour(parent->GetForegroundColour()) ;
65
66 m_windowStyle = style;
67
68 wxString Label = label;
69 if (Label == wxT(""))
70 Label = wxT(" "); // Apparently needed or checkbox won't show
71
72 if ( id == -1 )
73 m_windowId = NewControlId();
74 else
75 m_windowId = id;
76
77 int x = pos.x;
78 int y = pos.y;
79 int width = size.x;
80 int height = size.y;
81
82 // TODO: create checkbox
83
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
91 return FALSE;
92}
93
94void wxCheckBox::SetLabel(const wxString& label)
95{
96 // TODO
97}
98
99wxSize wxCheckBox::DoGetBestSize() const
100{
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);
120}
121
122void wxCheckBox::SetValue(bool val)
123{
124 // TODO
125}
126
127#ifndef BST_CHECKED
128#define BST_CHECKED 0x0001
129#endif
130
131bool wxCheckBox::GetValue() const
132{
133 // TODO
134 return FALSE;
135}
136
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
170void wxCheckBox::Command (wxCommandEvent & event)
171{
172 SetValue ((event.GetInt() != 0));
173 ProcessCommand (event);
174}
175
176// ----------------------------------------------------------------------------
177// wxBitmapCheckBox
178// ----------------------------------------------------------------------------
179
180bool wxBitmapCheckBox::Create(wxWindow *parent, wxWindowID id, const wxBitmap *label,
181 const wxPoint& pos,
182 const wxSize& size, long style,
183#if wxUSE_VALIDATORS
184 const wxValidator& validator,
185#endif
186 const wxString& name)
187{
188 SetName(name);
189#if wxUSE_VALIDATORS
190 SetValidator(validator);
191#endif
192 if (parent) parent->AddChild(this);
193
194 SetBackgroundColour(parent->GetBackgroundColour()) ;
195 SetForegroundColour(parent->GetForegroundColour()) ;
196 m_windowStyle = style;
197
198 if ( id == -1 )
199 m_windowId = NewControlId();
200 else
201 m_windowId = id;
202
203 int x = pos.x;
204 int y = pos.y;
205 int width = size.x;
206 int height = size.y;
207
208 checkWidth = -1 ;
209 checkHeight = -1 ;
210// long msStyle = CHECK_FLAGS;
211
212 HWND wx_button = 0; // TODO: Create the bitmap checkbox
213
214 m_hWnd = (WXHWND)wx_button;
215
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;
224}
225
226void wxBitmapCheckBox::SetLabel(const wxBitmap& bitmap)
227{
228 wxFAIL_MSG(wxT("not implemented"));
229}
230