]>
git.saurik.com Git - wxWidgets.git/blob - src/os2/control.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxControl class
4 // Author: David Webster
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "control.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
22 #include "wx/dcclient.h"
24 #include "wx/os2/private.h"
25 #include "wx/control.h"
27 IMPLEMENT_ABSTRACT_CLASS(wxControl
, wxWindow
)
29 BEGIN_EVENT_TABLE(wxControl
, wxWindow
)
30 EVT_ERASE_BACKGROUND(wxControl::OnEraseBackground
)
34 wxControl::wxControl()
37 #if WXWIN_COMPATIBILITY
39 #endif // WXWIN_COMPATIBILITY
40 } // end of wxControl::wxControl
42 bool wxControl::Create(
49 , const wxValidator
& rValidator
51 , const wxString
& rsName
54 bool bRval
= wxWindow::Create( pParent
64 SetValidator(rValidator
);
68 } // end of wxControl::Create
70 wxControl::~wxControl()
72 m_isBeingDeleted
= TRUE
;
75 bool wxControl::OS2CreateControl(
82 , const wxValidator
& rValidator
84 , const wxString
& rsName
88 // Even if it's possible to create controls without parents in some port,
89 // it should surely be discouraged because it doesn't work at all under
92 if (!CreateBase( pParent
103 pParent
->AddChild(this);
105 } // end of wxControl::OS2CreateControl
107 bool wxControl::OS2CreateControl(
108 const wxChar
* zClassname
110 , const wxPoint
& rPos
111 , const wxSize
& rSize
112 , const wxString
& rsLabel
117 // Doesn't do anything at all under OS/2
119 if (dwExstyle
== (WXDWORD
)-1)
121 dwExstyle
= GetExStyle(dwStyle
);
127 wxLogError(wxT("Failed to create a control of class '%s'"), zClassname
);
135 if ((strcmp(zClassname
, "COMBOBOX")) == 0)
136 zClass
= WC_COMBOBOX
;
137 dwStyle
|= WS_VISIBLE
;
138 m_hWnd
= (WXHWND
)::WinCreateWindow( (HWND
)GetHwndOf(GetParent()) // Parent window handle
139 ,(PSZ
)zClassname
// Window class
140 ,(PSZ
)rsLabel
.c_str() // Initial Text
141 ,(ULONG
)dwStyle
// Style flags
142 ,(LONG
)rPos
.x
// X pos of origin
143 ,(LONG
)rPos
.y
// Y pos of origin
144 ,(LONG
)rSize
.x
// control width
145 ,(LONG
)rSize
.y
// control height
146 ,(HWND
)GetHwndOf(GetParent()) // owner window handle (same as parent
147 ,HWND_TOP
// initial z position
148 ,(ULONG
)GetId() // Window identifier
149 ,NULL
// no control data
150 ,NULL
// no Presentation parameters
154 // Subclass again for purposes of dialog editing mode
159 // Controls use the same font and colours as their parent dialog by default
163 } // end of wxControl::OS2CreateControl
165 wxSize
wxControl::DoGetBestSize() const
167 return wxSize(DEFAULT_ITEM_WIDTH
, DEFAULT_ITEM_HEIGHT
);
168 } // end of wxControl::DoGetBestSize
170 bool wxControl::ProcessCommand(wxCommandEvent
& event
)
172 #if WXWIN_COMPATIBILITY
175 (void)(*m_callback
)(this, event
);
180 #endif // WXWIN_COMPATIBILITY
182 return GetEventHandler()->ProcessEvent(event
);
185 WXHBRUSH
wxControl::OnCtlColor(
194 HPS hPS
= (HPS
)hWxDC
; // pass in a PS handle in OS/2
195 wxColour vColFore
= GetForegroundColour();
196 wxColour vColBack
= GetBackgroundColour();
198 if (GetParent()->GetTransparentBackground())
199 ::GpiSetBackMix(hPS
, BM_LEAVEALONE
);
201 ::GpiSetBackMix(hPS
, BM_OVERPAINT
);
203 ::GpiSetBackColor(hPS
, vColBack
.GetPixel());
204 ::GpiSetColor(hPS
, vColFore
.GetPixel());
206 wxBrush
* pBrush
= wxTheBrushList
->FindOrCreateBrush( vColBack
209 return (WXHBRUSH
)pBrush
->GetResourceHandle();
210 } // end of wxControl::OnCtlColor
212 void wxControl::OnEraseBackground(
217 HPS hPS
= rEvent
.GetDC()->GetHPS();
220 ::GpiSetPS(hPS
, &vSize
, PU_PELS
| GPIF_DEFAULT
);
221 ::WinQueryWindowRect((HWND
)GetHwnd(), &vRect
);
222 ::WinFillRect(hPS
, &vRect
, GetBackgroundColour().GetPixel());
223 } // end of wxControl::OnEraseBackground
225 WXDWORD
wxControl::GetExStyle(
230 // Meaningless under OS/2, just return what was sent
232 WXDWORD exStyle
= rStyle
;
235 } // end of wxControl::GetExStyle
237 // ---------------------------------------------------------------------------
239 // ---------------------------------------------------------------------------
241 // Call this repeatedly for several wnds to find the overall size
243 // Call it initially with -1 for all values in rect.
244 // Keep calling for other widgets, and rect will be modified
245 // to calculate largest bounding rectangle.
251 int nLeft
= pRect
->xLeft
;
252 int nRight
= pRect
->xRight
;
253 int nTop
= pRect
->yTop
;
254 int nBottom
= pRect
->yBottom
;
256 ::WinQueryWindowRect((HWND
)hWnd
, pRect
);
261 if (nLeft
< pRect
->xLeft
)
262 pRect
->xLeft
= nLeft
;
264 if (nRight
> pRect
->xRight
)
265 pRect
->xRight
= nRight
;
267 if (nTop
< pRect
->yTop
)
270 if (nBottom
> pRect
->yBottom
)
271 pRect
->yBottom
= nBottom
;
272 } // end of wxFindMaxSize