1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/os2/checkbox.cpp
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"
15 #include "wx/checkbox.h"
19 #include "wx/scrolwin.h"
20 #include "wx/dcscreen.h"
21 #include "wx/settings.h"
24 #include "wx/os2/private.h"
26 // ----------------------------------------------------------------------------
28 // ----------------------------------------------------------------------------
30 IMPLEMENT_DYNAMIC_CLASS(wxBitmapCheckBox
, wxCheckBox
)
32 extern void wxAssociateWinWithHandle( HWND hWnd
36 // ============================================================================
38 // ============================================================================
40 // ----------------------------------------------------------------------------
42 // ----------------------------------------------------------------------------
44 bool wxCheckBox::OS2Command( WXUINT
WXUNUSED(uParam
),
45 WXWORD
WXUNUSED(wId
) )
47 wxCommandEvent
rEvent( wxEVT_COMMAND_CHECKBOX_CLICKED
, m_windowId
);
48 rEvent
.SetInt(GetValue());
49 rEvent
.SetEventObject(this);
50 ProcessCommand(rEvent
);
52 } // end of wxCheckBox::OS2Command
54 bool wxCheckBox::Create(wxWindow
* pParent
,
56 const wxString
& rsLabel
,
60 const wxValidator
& rValidator
,
61 const wxString
& rsName
)
63 if (!CreateControl( pParent
74 long osStyle
= BS_AUTOCHECKBOX
| WS_TABSTOP
| WS_VISIBLE
;
76 bool bOk
= OS2CreateControl( wxT("BUTTON")
83 m_backgroundColour
= pParent
->GetBackgroundColour();
85 LONG lColor
= (LONG
)m_backgroundColour
.GetPixel();
86 ::WinSetPresParam( m_hWnd
91 wxAssociateWinWithHandle(m_hWnd
, this);
93 } // end of wxCheckBox::Create
95 void wxCheckBox::SetLabel( const wxString
& rsLabel
)
97 wxString sLabel
=::wxPMTextToLabel(rsLabel
);
98 ::WinSetWindowText(GetHwnd(), sLabel
.c_str());
99 } // end of wxCheckBox::SetLabel
101 wxSize
wxCheckBox::DoGetBestSize() const
103 // We should probably compute nCheckSize but it seems to be a constant
104 // independent of its label's font size and not made available by OS/2.
105 int nCheckSize
= RADIO_SIZE
;
108 wxString sStr
= wxGetWindowText(GetHWND());
116 nWidthCheckbox
+= nCheckSize
;
118 if (nHeightCheckbox
< nCheckSize
)
119 nHeightCheckbox
= nCheckSize
;
123 nWidthCheckbox
= nCheckSize
;
124 nHeightCheckbox
= nCheckSize
;
127 return wxSize( nWidthCheckbox
, nHeightCheckbox
);
128 } // end of wxCheckBox::DoGetBestSize
130 void wxCheckBox::SetValue( bool bValue
)
132 ::WinSendMsg(GetHwnd(), BM_SETCHECK
, (MPARAM
)bValue
, 0);
133 } // end of wxCheckBox::SetValue
136 #define BST_CHECKED 0x0001
139 bool wxCheckBox::GetValue() const
141 return((LONGFROMMR(::WinSendMsg(GetHwnd(), BM_QUERYCHECK
, (MPARAM
)0, (MPARAM
)0)) == 1L));
142 } // end of wxCheckBox::GetValue
144 void wxCheckBox::Command ( wxCommandEvent
& rEvent
)
146 SetValue((rEvent
.GetInt() != 0));
147 ProcessCommand(rEvent
);
148 } // end of wxCheckBox:: Command
150 // ----------------------------------------------------------------------------
152 // ----------------------------------------------------------------------------
154 bool wxBitmapCheckBox::Create( wxWindow
* pParent
,
156 const wxBitmap
* WXUNUSED(pLabel
),
160 const wxValidator
& rValidator
,
161 const wxString
& rsName
)
165 SetValidator(rValidator
);
168 pParent
->AddChild(this);
170 SetBackgroundColour(pParent
->GetBackgroundColour()) ;
171 SetForegroundColour(pParent
->GetForegroundColour()) ;
172 m_windowStyle
= lStyle
;
175 m_windowId
= NewControlId();
181 int nWidth
= rSize
.x
;
182 int nHeight
= rSize
.y
;
185 m_nCheckHeight
= -1 ;
186 // long msStyle = CHECK_FLAGS;
188 HWND hButton
= 0; // TODO: Create the bitmap checkbox
190 m_hWnd
= (WXHWND
)hButton
;
193 // Subclass again for purposes of dialog editing mode
195 SubclassWin((WXHWND
)hButton
);
203 ::WinShowWindow(hButton
, TRUE
);
205 } // end of wxBitmapCheckBox::Create
207 void wxBitmapCheckBox::SetLabel( const wxBitmap
& WXUNUSED(rBitmap
) )
209 wxFAIL_MSG(wxT("not implemented"));
210 } // end of wxBitmapCheckBox::SetLabel