]>
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()
36 m_backgroundColour
= *wxWHITE
;
37 m_foregroundColour
= *wxBLACK
;
39 #if WXWIN_COMPATIBILITY
41 #endif // WXWIN_COMPATIBILITY
42 } // end of wxControl::wxControl
44 bool wxControl::Create(
51 , const wxValidator
& rValidator
53 , const wxString
& rsName
56 bool bRval
= wxWindow::Create( pParent
66 SetValidator(rValidator
);
70 } // end of wxControl::Create
72 wxControl::~wxControl()
74 m_isBeingDeleted
= TRUE
;
77 bool wxControl::OS2CreateControl(
84 , const wxValidator
& rValidator
86 , const wxString
& rsName
90 // Even if it's possible to create controls without parents in some port,
91 // it should surely be discouraged because it doesn't work at all under
94 if (!CreateBase( pParent
105 pParent
->AddChild(this);
107 } // end of wxControl::OS2CreateControl
109 bool wxControl::OS2CreateControl(
110 const wxChar
* zClassname
112 , const wxPoint
& rPos
113 , const wxSize
& rSize
114 , const wxString
& rsLabel
119 // Doesn't do anything at all under OS/2
121 if (dwExstyle
== (WXDWORD
)-1)
123 dwExstyle
= GetExStyle(dwStyle
);
129 wxLogError(wxT("Failed to create a control of class '%s'"), zClassname
);
137 if ((strcmp(zClassname
, "COMBOBOX")) == 0)
138 zClass
= WC_COMBOBOX
;
139 dwStyle
|= WS_VISIBLE
;
140 m_hWnd
= (WXHWND
)::WinCreateWindow( (HWND
)GetHwndOf(GetParent()) // Parent window handle
141 ,(PSZ
)zClassname
// Window class
142 ,(PSZ
)rsLabel
.c_str() // Initial Text
143 ,(ULONG
)dwStyle
// Style flags
144 ,(LONG
)rPos
.x
// X pos of origin
145 ,(LONG
)rPos
.y
// Y pos of origin
146 ,(LONG
)rSize
.x
// control width
147 ,(LONG
)rSize
.y
// control height
148 ,(HWND
)GetHwndOf(GetParent()) // owner window handle (same as parent
149 ,HWND_TOP
// initial z position
150 ,(ULONG
)GetId() // Window identifier
151 ,NULL
// no control data
152 ,NULL
// no Presentation parameters
156 // Subclass again for purposes of dialog editing mode
161 // Controls use the same font and colours as their parent dialog by default
165 } // end of wxControl::OS2CreateControl
167 wxSize
wxControl::DoGetBestSize() const
169 return wxSize(DEFAULT_ITEM_WIDTH
, DEFAULT_ITEM_HEIGHT
);
170 } // end of wxControl::DoGetBestSize
172 bool wxControl::ProcessCommand(wxCommandEvent
& event
)
174 #if WXWIN_COMPATIBILITY
177 (void)(*m_callback
)(this, event
);
182 #endif // WXWIN_COMPATIBILITY
184 return GetEventHandler()->ProcessEvent(event
);
187 WXHBRUSH
wxControl::OnCtlColor(
196 HPS hPS
= (HPS
)hWxDC
; // pass in a PS handle in OS/2
197 wxColour vColFore
= GetForegroundColour();
198 wxColour vColBack
= GetBackgroundColour();
200 if (GetParent()->GetTransparentBackground())
201 ::GpiSetBackMix(hPS
, BM_LEAVEALONE
);
203 ::GpiSetBackMix(hPS
, BM_OVERPAINT
);
205 ::GpiSetBackColor(hPS
, vColBack
.GetPixel());
206 ::GpiSetColor(hPS
, vColFore
.GetPixel());
208 wxBrush
* pBrush
= wxTheBrushList
->FindOrCreateBrush( vColBack
211 return (WXHBRUSH
)pBrush
->GetResourceHandle();
212 } // end of wxControl::OnCtlColor
214 void wxControl::OnEraseBackground(
219 HPS hPS
= rEvent
.GetDC()->GetHPS();
222 ::GpiSetPS(hPS
, &vSize
, PU_PELS
| GPIF_DEFAULT
);
223 ::WinQueryWindowRect((HWND
)GetHwnd(), &vRect
);
224 ::WinFillRect(hPS
, &vRect
, GetBackgroundColour().GetPixel());
225 } // end of wxControl::OnEraseBackground
227 WXDWORD
wxControl::GetExStyle(
232 // Meaningless under OS/2, just return what was sent
234 WXDWORD exStyle
= rStyle
;
237 } // end of wxControl::GetExStyle
239 // ---------------------------------------------------------------------------
241 // ---------------------------------------------------------------------------
243 // Call this repeatedly for several wnds to find the overall size
245 // Call it initially with -1 for all values in rect.
246 // Keep calling for other widgets, and rect will be modified
247 // to calculate largest bounding rectangle.
253 int nLeft
= pRect
->xLeft
;
254 int nRight
= pRect
->xRight
;
255 int nTop
= pRect
->yTop
;
256 int nBottom
= pRect
->yBottom
;
258 ::WinQueryWindowRect((HWND
)hWnd
, pRect
);
263 if (nLeft
< pRect
->xLeft
)
264 pRect
->xLeft
= nLeft
;
266 if (nRight
> pRect
->xRight
)
267 pRect
->xRight
= nRight
;
269 if (nTop
< pRect
->yTop
)
272 if (nBottom
> pRect
->yBottom
)
273 pRect
->yBottom
= nBottom
;
274 } // end of wxFindMaxSize