]> git.saurik.com Git - wxWidgets.git/blame - src/os2/checkbox.cpp
Rework IE virtual file system support to use new syntax. Remove now unused code for...
[wxWidgets.git] / src / os2 / checkbox.cpp
CommitLineData
0e320a79 1/////////////////////////////////////////////////////////////////////////////
ab1ce969 2// Name: src/os2/checkbox.cpp
0e320a79 3// Purpose: wxCheckBox
37f214d5 4// Author: David Webster
0e320a79 5// Modified by:
37f214d5 6// Created: 10/13/99
0e320a79 7// RCS-ID: $Id$
37f214d5 8// Copyright: (c) David Webster
65571936 9// Licence: wxWindows licence
0e320a79
DW
10/////////////////////////////////////////////////////////////////////////////
11
37f214d5
DW
12// For compilers that support precompilation, includes "wx.h".
13#include "wx/wxprec.h"
14
ab1ce969
WS
15#include "wx/checkbox.h"
16
37f214d5 17#ifndef WX_PRECOMP
37f214d5 18 #include "wx/brush.h"
a4a16252
SN
19 #include "wx/scrolwin.h"
20 #include "wx/dcscreen.h"
21 #include "wx/settings.h"
0e320a79
DW
22#endif
23
37f214d5
DW
24#include "wx/os2/private.h"
25
26// ----------------------------------------------------------------------------
27// macros
28// ----------------------------------------------------------------------------
0e320a79 29
0e320a79 30IMPLEMENT_DYNAMIC_CLASS(wxBitmapCheckBox, wxCheckBox)
0e320a79 31
f289196b
DW
32extern void wxAssociateWinWithHandle( HWND hWnd
33 ,wxWindowOS2* pWin
34 );
35
37f214d5
DW
36// ============================================================================
37// implementation
38// ============================================================================
39
40// ----------------------------------------------------------------------------
41// wxCheckBox
42// ----------------------------------------------------------------------------
43
6670f564
WS
44bool wxCheckBox::OS2Command( WXUINT WXUNUSED(uParam),
45 WXWORD WXUNUSED(wId) )
37f214d5 46{
6670f564 47 wxCommandEvent rEvent( wxEVT_COMMAND_CHECKBOX_CLICKED, m_windowId );
5d44b24e
DW
48 rEvent.SetInt(GetValue());
49 rEvent.SetEventObject(this);
50 ProcessCommand(rEvent);
6670f564 51 return true;
5d44b24e
DW
52} // end of wxCheckBox::OS2Command
53
ab1ce969
WS
54bool wxCheckBox::Create(wxWindow* pParent,
55 wxWindowID vId,
56 const wxString& rsLabel,
57 const wxPoint& rPos,
58 const wxSize& rSize,
59 long lStyle,
60 const wxValidator& rValidator,
61 const wxString& rsName )
0e320a79 62{
a086de98
DW
63 if (!CreateControl( pParent
64 ,vId
65 ,rPos
66 ,rSize
67 ,lStyle
1d0edc0f 68 ,rValidator
a086de98
DW
69 ,rsName
70 ))
ab1ce969 71 return false;
a086de98 72
f289196b 73
ab1ce969 74 long osStyle = BS_AUTOCHECKBOX | WS_TABSTOP | WS_VISIBLE;
a086de98 75
ab1ce969 76 bool bOk = OS2CreateControl( wxT("BUTTON")
f289196b
DW
77 ,osStyle
78 ,rPos
79 ,rSize
80 ,rsLabel
81 ,0
82 );
83 m_backgroundColour = pParent->GetBackgroundColour();
ab1ce969
WS
84
85 LONG lColor = (LONG)m_backgroundColour.GetPixel();
f289196b
DW
86 ::WinSetPresParam( m_hWnd
87 ,PP_BACKGROUNDCOLOR
88 ,sizeof(LONG)
89 ,(PVOID)&lColor
90 );
91 wxAssociateWinWithHandle(m_hWnd, this);
92 return bOk;
5d44b24e 93} // end of wxCheckBox::Create
0e320a79 94
ab1ce969 95void wxCheckBox::SetLabel( const wxString& rsLabel )
0e320a79 96{
ab1ce969 97 wxString sLabel=::wxPMTextToLabel(rsLabel);
65f3f920 98 ::WinSetWindowText(GetHwnd(), sLabel.c_str());
5d44b24e 99} // end of wxCheckBox::SetLabel
0e320a79 100
e78c4d50 101wxSize wxCheckBox::DoGetBestSize() const
0e320a79 102{
c5f975dd
SN
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;
6670f564
WS
106 int nWidthCheckbox;
107 int nHeightCheckbox;
108 wxString sStr = wxGetWindowText(GetHWND());
37f214d5 109
6670f564 110 if (!sStr.empty())
37f214d5 111 {
5d44b24e
DW
112 GetTextExtent( sStr
113 ,&nWidthCheckbox
114 ,&nHeightCheckbox
115 );
c5f975dd 116 nWidthCheckbox += nCheckSize;
37f214d5 117
5d44b24e
DW
118 if (nHeightCheckbox < nCheckSize)
119 nHeightCheckbox = nCheckSize;
37f214d5
DW
120 }
121 else
122 {
5d44b24e
DW
123 nWidthCheckbox = nCheckSize;
124 nHeightCheckbox = nCheckSize;
37f214d5
DW
125 }
126
ab1ce969 127 return wxSize( nWidthCheckbox, nHeightCheckbox );
5d44b24e 128} // end of wxCheckBox::DoGetBestSize
0e320a79 129
ab1ce969 130void wxCheckBox::SetValue( bool bValue )
0e320a79 131{
5d44b24e
DW
132 ::WinSendMsg(GetHwnd(), BM_SETCHECK, (MPARAM)bValue, 0);
133} // end of wxCheckBox::SetValue
0e320a79 134
37f214d5
DW
135#ifndef BST_CHECKED
136#define BST_CHECKED 0x0001
137#endif
138
0e320a79
DW
139bool wxCheckBox::GetValue() const
140{
5d44b24e
DW
141 return((LONGFROMMR(::WinSendMsg(GetHwnd(), BM_QUERYCHECK, (MPARAM)0, (MPARAM)0)) == 1L));
142} // end of wxCheckBox::GetValue
0e320a79 143
ab1ce969 144void wxCheckBox::Command ( wxCommandEvent& rEvent )
37f214d5 145{
5d44b24e
DW
146 SetValue((rEvent.GetInt() != 0));
147 ProcessCommand(rEvent);
148} // end of wxCheckBox:: Command
0e320a79 149
37f214d5
DW
150// ----------------------------------------------------------------------------
151// wxBitmapCheckBox
152// ----------------------------------------------------------------------------
153
6670f564
WS
154bool wxBitmapCheckBox::Create( wxWindow* pParent,
155 wxWindowID vId,
156 const wxBitmap* WXUNUSED(pLabel),
157 const wxPoint& rPos,
158 const wxSize& rSize,
159 long lStyle,
160 const wxValidator& rValidator,
161 const wxString& rsName)
0e320a79 162{
5d44b24e 163 SetName(rsName);
5d4b632b 164#if wxUSE_VALIDATORS
5d44b24e 165 SetValidator(rValidator);
5d4b632b 166#endif
5d44b24e
DW
167 if (pParent)
168 pParent->AddChild(this);
0e320a79 169
5d44b24e
DW
170 SetBackgroundColour(pParent->GetBackgroundColour()) ;
171 SetForegroundColour(pParent->GetForegroundColour()) ;
172 m_windowStyle = lStyle;
37f214d5 173
5d44b24e 174 if (vId == -1)
0e320a79
DW
175 m_windowId = NewControlId();
176 else
5d44b24e 177 m_windowId = vId;
0e320a79 178
5d44b24e
DW
179 int nX = rPos.x;
180 int nY = rPos.y;
181 int nWidth = rSize.x;
182 int nHeight = rSize.y;
0e320a79 183
5d44b24e
DW
184 m_nCheckWidth = -1 ;
185 m_nCheckHeight = -1 ;
892b89f3 186// long msStyle = CHECK_FLAGS;
0e320a79 187
5d44b24e 188 HWND hButton = 0; // TODO: Create the bitmap checkbox
0e320a79 189
5d44b24e 190 m_hWnd = (WXHWND)hButton;
0e320a79 191
5d44b24e 192 //
37f214d5 193 // Subclass again for purposes of dialog editing mode
5d44b24e
DW
194 //
195 SubclassWin((WXHWND)hButton);
37f214d5 196
5d44b24e
DW
197 SetSize( nX
198 ,nY
199 ,nWidth
200 ,nHeight
201 );
37f214d5 202
5d44b24e 203 ::WinShowWindow(hButton, TRUE);
6670f564 204 return true;
5d44b24e 205} // end of wxBitmapCheckBox::Create
0e320a79 206
6670f564 207void wxBitmapCheckBox::SetLabel( const wxBitmap& WXUNUSED(rBitmap) )
0e320a79 208{
37f214d5 209 wxFAIL_MSG(wxT("not implemented"));
5d44b24e 210} // end of wxBitmapCheckBox::SetLabel