1 /////////////////////////////////////////////////////////////////////////////
4 // Author: David Webster
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
16 #include "wx/checkbox.h"
18 #include "wx/scrolwin.h"
19 #include "wx/dcscreen.h"
20 #include "wx/settings.h"
23 #include "wx/os2/private.h"
25 // ----------------------------------------------------------------------------
27 // ----------------------------------------------------------------------------
29 IMPLEMENT_DYNAMIC_CLASS(wxCheckBox
, wxControl
)
30 IMPLEMENT_DYNAMIC_CLASS(wxBitmapCheckBox
, wxCheckBox
)
32 // ============================================================================
34 // ============================================================================
36 // ----------------------------------------------------------------------------
38 // ----------------------------------------------------------------------------
40 bool wxCheckBox::OS2Command(
41 WXUINT
WXUNUSED(uParam
)
42 , WXWORD
WXUNUSED(wId
)
45 wxCommandEvent
rEvent( wxEVT_COMMAND_CHECKBOX_CLICKED
48 rEvent
.SetInt(GetValue());
49 rEvent
.SetEventObject(this);
50 ProcessCommand(rEvent
);
52 } // end of wxCheckBox::OS2Command
54 bool wxCheckBox::Create(
57 , const wxString
& rsLabel
62 , const wxValidator
& rValidator
64 , const wxString
& rsName
67 if (!CreateControl( pParent
79 long osStyle
= BS_AUTOCHECKBOX
|
83 return OS2CreateControl( wxT("BUTTON")
90 } // end of wxCheckBox::Create
92 void wxCheckBox::SetLabel(
93 const wxString
& rsLabel
96 ::WinSetWindowText(GetHwnd(), rsLabel
.c_str());
97 } // end of wxCheckBox::SetLabel
99 wxSize
wxCheckBox::DoGetBestSize() const
101 static int nCheckSize
= 0;
107 vDc
.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
));
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)
114 nCheckSize
= vDc
.GetCharHeight();
119 wxString sStr
= wxGetWindowText(GetHWND());
127 nWidthCheckbox
+= nCheckSize
+ GetCharWidth();
129 if (nHeightCheckbox
< nCheckSize
)
130 nHeightCheckbox
= nCheckSize
;
134 nWidthCheckbox
= nCheckSize
;
135 nHeightCheckbox
= nCheckSize
;
138 return wxSize( nWidthCheckbox
141 } // end of wxCheckBox::DoGetBestSize
143 void wxCheckBox::SetValue(
147 ::WinSendMsg(GetHwnd(), BM_SETCHECK
, (MPARAM
)bValue
, 0);
148 } // end of wxCheckBox::SetValue
151 #define BST_CHECKED 0x0001
154 bool wxCheckBox::GetValue() const
156 return((LONGFROMMR(::WinSendMsg(GetHwnd(), BM_QUERYCHECK
, (MPARAM
)0, (MPARAM
)0)) == 1L));
157 } // end of wxCheckBox::GetValue
159 void wxCheckBox::Command (
160 wxCommandEvent
& rEvent
163 SetValue((rEvent
.GetInt() != 0));
164 ProcessCommand(rEvent
);
165 } // end of wxCheckBox:: Command
167 // ----------------------------------------------------------------------------
169 // ----------------------------------------------------------------------------
171 bool wxBitmapCheckBox::Create(
174 , const wxBitmap
* pLabel
175 , const wxPoint
& rPos
176 , const wxSize
& rSize
179 , const wxValidator
& rValidator
181 , const wxString
& rsName
186 SetValidator(rValidator
);
189 pParent
->AddChild(this);
191 SetBackgroundColour(pParent
->GetBackgroundColour()) ;
192 SetForegroundColour(pParent
->GetForegroundColour()) ;
193 m_windowStyle
= lStyle
;
196 m_windowId
= NewControlId();
202 int nWidth
= rSize
.x
;
203 int nHeight
= rSize
.y
;
206 m_nCheckHeight
= -1 ;
207 // long msStyle = CHECK_FLAGS;
209 HWND hButton
= 0; // TODO: Create the bitmap checkbox
211 m_hWnd
= (WXHWND
)hButton
;
214 // Subclass again for purposes of dialog editing mode
216 SubclassWin((WXHWND
)hButton
);
224 ::WinShowWindow(hButton
, TRUE
);
226 } // end of wxBitmapCheckBox::Create
228 void wxBitmapCheckBox::SetLabel(
229 const wxBitmap
& rBitmap
232 wxFAIL_MSG(wxT("not implemented"));
233 } // end of wxBitmapCheckBox::SetLabel