]> git.saurik.com Git - wxWidgets.git/blob - src/os2/checkbox.cpp
add -pthread like options to the linker flags as well; also (finally!) fixed -g and...
[wxWidgets.git] / src / os2 / checkbox.cpp
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 #include "wx/scrolwin.h"
19 #include "wx/dcscreen.h"
20 #include "wx/settings.h"
21 #endif
22
23 #include "wx/os2/private.h"
24
25 // ----------------------------------------------------------------------------
26 // macros
27 // ----------------------------------------------------------------------------
28
29 IMPLEMENT_DYNAMIC_CLASS(wxCheckBox, wxControl)
30 IMPLEMENT_DYNAMIC_CLASS(wxBitmapCheckBox, wxCheckBox)
31
32 // ============================================================================
33 // implementation
34 // ============================================================================
35
36 // ----------------------------------------------------------------------------
37 // wxCheckBox
38 // ----------------------------------------------------------------------------
39
40 bool wxCheckBox::OS2Command(
41 WXUINT WXUNUSED(uParam)
42 , WXWORD WXUNUSED(wId)
43 )
44 {
45 wxCommandEvent rEvent( wxEVT_COMMAND_CHECKBOX_CLICKED
46 ,m_windowId
47 );
48 rEvent.SetInt(GetValue());
49 rEvent.SetEventObject(this);
50 ProcessCommand(rEvent);
51 return TRUE;
52 } // end of wxCheckBox::OS2Command
53
54 bool wxCheckBox::Create(
55 wxWindow* pParent
56 , wxWindowID vId
57 , const wxString& rsLabel
58 , const wxPoint& rPos
59 , const wxSize& rSize
60 , long lStyle
61 #if wxUSE_VALIDATORS
62 , const wxValidator& rValidator
63 #endif
64 , const wxString& rsName
65 )
66 {
67 if (!CreateControl( pParent
68 ,vId
69 ,rPos
70 ,rSize
71 ,lStyle
72 #if wxUSE_VALIDATORS
73 ,wxDefaultValidator
74 #endif
75 ,rsName
76 ))
77 return FALSE;
78
79 long osStyle = BS_AUTOCHECKBOX |
80 WS_TABSTOP |
81 WS_VISIBLE;
82
83 return OS2CreateControl( wxT("BUTTON")
84 ,osStyle
85 ,rPos
86 ,rSize
87 ,rsLabel
88 ,0
89 );
90 } // end of wxCheckBox::Create
91
92 void wxCheckBox::SetLabel(
93 const wxString& rsLabel
94 )
95 {
96 ::WinSetWindowText(GetHwnd(), rsLabel.c_str());
97 } // end of wxCheckBox::SetLabel
98
99 wxSize wxCheckBox::DoGetBestSize() const
100 {
101 static int nCheckSize = 0;
102
103 if (!nCheckSize)
104 {
105 wxScreenDC vDc;
106
107 vDc.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
108
109 //
110 // The height of a standard button in the dialog units is 8,
111 // translate this to pixels (as one dialog unit is precisely equal to
112 // 8 character heights, it's just the char height)
113 //
114 nCheckSize = vDc.GetCharHeight();
115 }
116
117 int nWidthCheckbox;
118 int nHeightCheckbox;
119 wxString sStr = wxGetWindowText(GetHWND());
120
121 if (!sStr.IsEmpty())
122 {
123 GetTextExtent( sStr
124 ,&nWidthCheckbox
125 ,&nHeightCheckbox
126 );
127 nWidthCheckbox += nCheckSize + GetCharWidth();
128
129 if (nHeightCheckbox < nCheckSize)
130 nHeightCheckbox = nCheckSize;
131 }
132 else
133 {
134 nWidthCheckbox = nCheckSize;
135 nHeightCheckbox = nCheckSize;
136 }
137
138 return wxSize( nWidthCheckbox
139 ,nHeightCheckbox
140 );
141 } // end of wxCheckBox::DoGetBestSize
142
143 void wxCheckBox::SetValue(
144 bool bValue
145 )
146 {
147 ::WinSendMsg(GetHwnd(), BM_SETCHECK, (MPARAM)bValue, 0);
148 } // end of wxCheckBox::SetValue
149
150 #ifndef BST_CHECKED
151 #define BST_CHECKED 0x0001
152 #endif
153
154 bool wxCheckBox::GetValue() const
155 {
156 return((LONGFROMMR(::WinSendMsg(GetHwnd(), BM_QUERYCHECK, (MPARAM)0, (MPARAM)0)) == 1L));
157 } // end of wxCheckBox::GetValue
158
159 void wxCheckBox::Command (
160 wxCommandEvent& rEvent
161 )
162 {
163 SetValue((rEvent.GetInt() != 0));
164 ProcessCommand(rEvent);
165 } // end of wxCheckBox:: Command
166
167 // ----------------------------------------------------------------------------
168 // wxBitmapCheckBox
169 // ----------------------------------------------------------------------------
170
171 bool wxBitmapCheckBox::Create(
172 wxWindow* pParent
173 , wxWindowID vId
174 , const wxBitmap* pLabel
175 , const wxPoint& rPos
176 , const wxSize& rSize
177 , long lStyle
178 #if wxUSE_VALIDATORS
179 , const wxValidator& rValidator
180 #endif
181 , const wxString& rsName
182 )
183 {
184 SetName(rsName);
185 #if wxUSE_VALIDATORS
186 SetValidator(rValidator);
187 #endif
188 if (pParent)
189 pParent->AddChild(this);
190
191 SetBackgroundColour(pParent->GetBackgroundColour()) ;
192 SetForegroundColour(pParent->GetForegroundColour()) ;
193 m_windowStyle = lStyle;
194
195 if (vId == -1)
196 m_windowId = NewControlId();
197 else
198 m_windowId = vId;
199
200 int nX = rPos.x;
201 int nY = rPos.y;
202 int nWidth = rSize.x;
203 int nHeight = rSize.y;
204
205 m_nCheckWidth = -1 ;
206 m_nCheckHeight = -1 ;
207 // long msStyle = CHECK_FLAGS;
208
209 HWND hButton = 0; // TODO: Create the bitmap checkbox
210
211 m_hWnd = (WXHWND)hButton;
212
213 //
214 // Subclass again for purposes of dialog editing mode
215 //
216 SubclassWin((WXHWND)hButton);
217
218 SetSize( nX
219 ,nY
220 ,nWidth
221 ,nHeight
222 );
223
224 ::WinShowWindow(hButton, TRUE);
225 return TRUE;
226 } // end of wxBitmapCheckBox::Create
227
228 void wxBitmapCheckBox::SetLabel(
229 const wxBitmap& rBitmap
230 )
231 {
232 wxFAIL_MSG(wxT("not implemented"));
233 } // end of wxBitmapCheckBox::SetLabel
234