]> git.saurik.com Git - wxWidgets.git/blob - src/os2/radiobut.cpp
added missing casts after removal of dependancy on mac headers
[wxWidgets.git] / src / os2 / radiobut.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: radiobut.cpp
3 // Purpose: wxRadioButton
4 // Author: David Webster
5 // Modified by:
6 // Created: 10/12/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 #ifdef __BORLANDC__
16 #pragma hdrstop
17 #endif
18
19 #ifndef WX_PRECOMP
20 #include <stdio.h>
21 #include "wx/setup.h"
22 #include "wx/radiobut.h"
23 #include "wx/brush.h"
24 #endif
25
26 #include "wx/os2/private.h"
27
28 IMPLEMENT_DYNAMIC_CLASS(wxRadioButton, wxControl)
29
30 void wxRadioButton::Command (
31 wxCommandEvent& rEvent
32 )
33 {
34 SetValue ((rEvent.GetInt() != 0) );
35 ProcessCommand (rEvent);
36 } // end of wxRadioButton::Command
37
38 bool wxRadioButton::Create(
39 wxWindow* pParent
40 , wxWindowID vId
41 , const wxString& rsLabel
42 , const wxPoint& rPos
43 , const wxSize& rSize
44 , long lStyle
45 #if wxUSE_VALIDATORS
46 , const wxValidator& rValidator
47 #endif
48 , const wxString& rsName
49 )
50 {
51 int nX = rPos.x;
52 int nY = rPos.y;
53 int nWidth = rSize.x;
54 int nHeight = rSize.y;
55 long lsStyle = 0L;
56 long lGroupStyle = 0L;
57
58 SetName(rsName);
59 #if wxUSE_VALIDATORS
60 SetValidator(rValidator);
61 #endif
62
63 if (pParent)
64 pParent->AddChild(this);
65
66 SetBackgroundColour(pParent->GetBackgroundColour());
67 SetForegroundColour(pParent->GetForegroundColour());
68
69 if (vId == -1)
70 m_windowId = (int)NewControlId();
71 else
72 m_windowId = vId;
73
74
75 m_windowStyle = lStyle ;
76
77 if (m_windowStyle & wxRB_GROUP)
78 lGroupStyle = WS_GROUP;
79
80 lsStyle = lGroupStyle | BS_AUTORADIOBUTTON | WS_VISIBLE ;
81
82 if (m_windowStyle & wxCLIP_SIBLINGS )
83 lsStyle |= WS_CLIPSIBLINGS;
84 m_hWnd = (WXHWND)::WinCreateWindow ( GetHwndOf(pParent)
85 ,WC_BUTTON
86 ,rsLabel.c_str()
87 ,lsStyle
88 ,0, 0, 0, 0
89 ,GetWinHwnd(pParent)
90 ,HWND_TOP
91 ,(HMENU)m_windowId
92 ,NULL
93 ,NULL
94 );
95 wxCHECK_MSG(m_hWnd, FALSE, wxT("Failed to create radiobutton"));
96
97 if (rsLabel != wxT(""))
98 {
99 int nLabelWidth;
100 int nLabelHeight;
101
102 GetTextExtent( rsLabel
103 ,&nLabelWidth
104 ,&nLabelHeight
105 ,NULL
106 ,NULL
107 ,&this->GetFont()
108 );
109 if (nWidth < 0)
110 nWidth = (int)(nLabelWidth + RADIO_SIZE);
111 if (nHeight<0)
112 {
113 nHeight = (int)(nLabelHeight);
114 if (nHeight < RADIO_SIZE)
115 nHeight = RADIO_SIZE;
116 }
117 }
118 else
119 {
120 if (nWidth < 0)
121 nWidth = RADIO_SIZE;
122 if (nHeight < 0)
123 nHeight = RADIO_SIZE;
124 }
125
126 //
127 // Subclass again for purposes of dialog editing mode
128 //
129 SubclassWin((WXHWND)m_hWnd);
130 SetFont(pParent->GetFont());
131 SetSize( nX
132 ,nY
133 ,nWidth
134 ,nHeight
135 );
136 return FALSE;
137 } // end of wxRadioButton::Create
138
139 //
140 // Get single selection, for single choice list items
141 //
142 bool wxRadioButton::GetValue() const
143 {
144 return((::WinSendMsg((HWND) GetHWND(), BM_QUERYCHECK, (MPARAM)0L, (MPARAM)0L) != 0));
145 } // end of wxRadioButton::GetValue
146
147 bool wxRadioButton::OS2Command(
148 WXUINT wParam
149 , WXWORD wId
150 )
151 {
152 if (wParam == BN_CLICKED)
153 {
154 wxCommandEvent rEvent( wxEVT_COMMAND_RADIOBUTTON_SELECTED
155 ,m_windowId
156 );
157
158 rEvent.SetEventObject(this);
159 ProcessCommand(rEvent);
160 return TRUE;
161 }
162 else
163 return FALSE;
164 } // end of wxRadioButton::OS2Command
165
166 void wxRadioButton::SetLabel(
167 const wxString& rsLabel
168 )
169 {
170 ::WinSetWindowText((HWND)GetHWND(), (const char *)rsLabel.c_str());
171 } // end of wxRadioButton::SetLabel
172
173 void wxRadioButton::SetValue(
174 bool bValue
175 )
176 {
177 ::WinSendMsg((HWND)GetHWND(), BM_SETCHECK, (MPARAM)bValue, (MPARAM)0);
178 } // end of wxRadioButton::SetValue
179