]>
git.saurik.com Git - wxWidgets.git/blob - src/os2/checkbox.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/os2/checkbox.cpp
4 // Author: David Webster
7 // Copyright: (c) David Webster
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
14 #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(wxBitmapCheckBox
, wxCheckBox
)
31 extern void wxAssociateWinWithHandle( HWND hWnd
35 // ============================================================================
37 // ============================================================================
39 // ----------------------------------------------------------------------------
41 // ----------------------------------------------------------------------------
43 bool wxCheckBox::OS2Command( WXUINT
WXUNUSED(uParam
),
44 WXWORD
WXUNUSED(wId
) )
46 wxCommandEvent
rEvent( wxEVT_CHECKBOX
, m_windowId
);
47 rEvent
.SetInt(GetValue());
48 rEvent
.SetEventObject(this);
49 ProcessCommand(rEvent
);
51 } // end of wxCheckBox::OS2Command
53 bool wxCheckBox::Create(wxWindow
* pParent
,
55 const wxString
& rsLabel
,
59 const wxValidator
& rValidator
,
60 const wxString
& rsName
)
62 if (!CreateControl( pParent
73 long osStyle
= BS_AUTOCHECKBOX
| WS_TABSTOP
| WS_VISIBLE
;
75 bool bOk
= OS2CreateControl( wxT("BUTTON")
82 m_backgroundColour
= pParent
->GetBackgroundColour();
84 LONG lColor
= (LONG
)m_backgroundColour
.GetPixel();
85 ::WinSetPresParam( m_hWnd
90 wxAssociateWinWithHandle(m_hWnd
, this);
92 } // end of wxCheckBox::Create
94 void wxCheckBox::SetLabel( const wxString
& rsLabel
)
96 wxString sLabel
=::wxPMTextToLabel(rsLabel
);
97 ::WinSetWindowText(GetHwnd(), sLabel
.c_str());
98 } // end of wxCheckBox::SetLabel
100 wxSize
wxCheckBox::DoGetBestSize() const
102 // We should probably compute nCheckSize but it seems to be a constant
103 // independent of its label's font size and not made available by OS/2.
104 int nCheckSize
= RADIO_SIZE
;
107 wxString sStr
= wxGetWindowText(GetHWND());
115 nWidthCheckbox
+= nCheckSize
;
117 if (nHeightCheckbox
< nCheckSize
)
118 nHeightCheckbox
= nCheckSize
;
122 nWidthCheckbox
= nCheckSize
;
123 nHeightCheckbox
= nCheckSize
;
126 return wxSize( nWidthCheckbox
, nHeightCheckbox
);
127 } // end of wxCheckBox::DoGetBestSize
129 void wxCheckBox::SetValue( bool bValue
)
131 ::WinSendMsg(GetHwnd(), BM_SETCHECK
, (MPARAM
)bValue
, 0);
132 } // end of wxCheckBox::SetValue
135 #define BST_CHECKED 0x0001
138 bool wxCheckBox::GetValue() const
140 return((LONGFROMMR(::WinSendMsg(GetHwnd(), BM_QUERYCHECK
, (MPARAM
)0, (MPARAM
)0)) == 1L));
141 } // end of wxCheckBox::GetValue
143 void wxCheckBox::Command ( wxCommandEvent
& rEvent
)
145 SetValue((rEvent
.GetInt() != 0));
146 ProcessCommand(rEvent
);
147 } // end of wxCheckBox:: Command
149 // ----------------------------------------------------------------------------
151 // ----------------------------------------------------------------------------
153 bool wxBitmapCheckBox::Create( wxWindow
* pParent
,
155 const wxBitmap
* WXUNUSED(pLabel
),
159 const wxValidator
& rValidator
,
160 const wxString
& rsName
)
164 SetValidator(rValidator
);
167 pParent
->AddChild(this);
169 SetBackgroundColour(pParent
->GetBackgroundColour()) ;
170 SetForegroundColour(pParent
->GetForegroundColour()) ;
171 m_windowStyle
= lStyle
;
174 m_windowId
= NewControlId();
180 int nWidth
= rSize
.x
;
181 int nHeight
= rSize
.y
;
184 m_nCheckHeight
= -1 ;
185 // long msStyle = CHECK_FLAGS;
187 HWND hButton
= 0; // TODO: Create the bitmap checkbox
189 m_hWnd
= (WXHWND
)hButton
;
192 // Subclass again for purposes of dialog editing mode
194 SubclassWin((WXHWND
)hButton
);
202 ::WinShowWindow(hButton
, TRUE
);
204 } // end of wxBitmapCheckBox::Create
206 void wxBitmapCheckBox::SetLabel( const wxBitmap
& WXUNUSED(rBitmap
) )
208 wxFAIL_MSG(wxT("not implemented"));
209 } // end of wxBitmapCheckBox::SetLabel