]>
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"
23 #include "wx/scrolwin.h"
25 #include "wx/os2/private.h"
26 #include "wx/control.h"
28 IMPLEMENT_ABSTRACT_CLASS(wxControl
, wxWindow
)
30 BEGIN_EVENT_TABLE(wxControl
, wxWindow
)
31 EVT_ERASE_BACKGROUND(wxControl::OnEraseBackground
)
35 wxControl::wxControl()
38 #if WXWIN_COMPATIBILITY
40 #endif // WXWIN_COMPATIBILITY
41 } // end of wxControl::wxControl
43 bool wxControl::Create(
50 , const wxValidator
& rValidator
52 , const wxString
& rsName
55 bool bRval
= wxWindow::Create( pParent
65 SetValidator(rValidator
);
69 } // end of wxControl::Create
71 wxControl::~wxControl()
73 m_isBeingDeleted
= TRUE
;
76 bool wxControl::OS2CreateControl(
77 const wxChar
* zClassname
78 , const wxString
& rsLabel
85 WXDWORD dwStyle
= OS2GetStyle( lStyle
89 return OS2CreateControl( zClassname
96 } // end of wxControl::OS2CreateControl
98 bool wxControl::OS2CreateControl(
99 const wxChar
* zClassname
101 , const wxPoint
& rPos
102 , const wxSize
& rSize
103 , const wxString
& rsLabel
107 bool bWant3D
= FALSE
;
110 // Doesn't do anything at all under OS/2
112 if (dwExstyle
== (WXDWORD
)-1)
114 dwExstyle
= Determine3DEffects(WS_EX_CLIENTEDGE
, &bWant3D
);
117 // All controls should have these styles (wxWindows creates all controls
118 // visible by default)
121 dwStyle
|= WS_VISIBLE
;
123 wxWindow
* pParent
= GetParent();
129 if ((strcmp(zClassname
, "COMBOBOX")) == 0)
130 zClass
= WC_COMBOBOX
;
131 else if ((strcmp(zClassname
, "STATIC")) == 0)
133 else if ((strcmp(zClassname
, "BUTTON")) == 0)
135 else if ((strcmp(zClassname
, "NOTEBOOK")) == 0)
136 zClass
= WC_NOTEBOOK
;
137 dwStyle
|= WS_VISIBLE
;
139 m_hWnd
= (WXHWND
)::WinCreateWindow( (HWND
)GetHwndOf(pParent
) // Parent window handle
140 ,(PSZ
)zClass
// Window class
141 ,(PSZ
)rsLabel
.c_str() // Initial Text
142 ,(ULONG
)dwStyle
// Style flags
143 ,(LONG
)0 // X pos of origin
144 ,(LONG
)0 // Y pos of origin
145 ,(LONG
)0 // control width
146 ,(LONG
)0 // control height
147 ,(HWND
)GetHwndOf(pParent
) // owner window handle (same as parent
148 ,HWND_TOP
// initial z position
149 ,(ULONG
)GetId() // Window identifier
150 ,NULL
// no control data
151 ,NULL
// no Presentation parameters
157 wxLogError(wxT("Failed to create a control of class '%s'"), zClassname
);
163 // Subclass again for purposes of dialog editing mode
168 // Controls use the same font and colours as their parent dialog by default
179 } // end of wxControl::OS2CreateControl
181 wxSize
wxControl::DoGetBestSize() const
183 return wxSize(DEFAULT_ITEM_WIDTH
, DEFAULT_ITEM_HEIGHT
);
184 } // end of wxControl::DoGetBestSize
186 bool wxControl::ProcessCommand(wxCommandEvent
& event
)
188 #if WXWIN_COMPATIBILITY
191 (void)(*m_callback
)(this, event
);
196 #endif // WXWIN_COMPATIBILITY
198 return GetEventHandler()->ProcessEvent(event
);
201 WXHBRUSH
wxControl::OnCtlColor(
210 HPS hPS
= (HPS
)hWxDC
; // pass in a PS handle in OS/2
211 wxColour vColFore
= GetForegroundColour();
212 wxColour vColBack
= GetBackgroundColour();
214 if (GetParent()->GetTransparentBackground())
215 ::GpiSetBackMix(hPS
, BM_LEAVEALONE
);
217 ::GpiSetBackMix(hPS
, BM_OVERPAINT
);
219 ::GpiSetBackColor(hPS
, vColBack
.GetPixel());
220 ::GpiSetColor(hPS
, vColFore
.GetPixel());
222 wxBrush
* pBrush
= wxTheBrushList
->FindOrCreateBrush( vColBack
225 return (WXHBRUSH
)pBrush
->GetResourceHandle();
226 } // end of wxControl::OnCtlColor
228 void wxControl::OnEraseBackground(
233 HPS hPS
= rEvent
.GetDC()->GetHPS();
236 ::GpiSetPS(hPS
, &vSize
, PU_PELS
| GPIF_DEFAULT
);
237 ::WinQueryWindowRect((HWND
)GetHwnd(), &vRect
);
238 ::WinFillRect(hPS
, &vRect
, GetBackgroundColour().GetPixel());
239 } // end of wxControl::OnEraseBackground
241 WXDWORD
wxControl::OS2GetStyle(
243 , WXDWORD
* pdwExstyle
246 long dwStyle
= wxWindow::OS2GetStyle( lStyle
252 dwStyle
|= WS_TABSTOP
;
255 } // end of wxControl::OS2GetStyle
257 // ---------------------------------------------------------------------------
259 // ---------------------------------------------------------------------------
261 // Call this repeatedly for several wnds to find the overall size
263 // Call it initially with -1 for all values in rect.
264 // Keep calling for other widgets, and rect will be modified
265 // to calculate largest bounding rectangle.
271 int nLeft
= pRect
->xLeft
;
272 int nRight
= pRect
->xRight
;
273 int nTop
= pRect
->yTop
;
274 int nBottom
= pRect
->yBottom
;
276 ::WinQueryWindowRect((HWND
)hWnd
, pRect
);
281 if (nLeft
< pRect
->xLeft
)
282 pRect
->xLeft
= nLeft
;
284 if (nRight
> pRect
->xRight
)
285 pRect
->xRight
= nRight
;
287 if (nTop
< pRect
->yTop
)
290 if (nBottom
> pRect
->yBottom
)
291 pRect
->yBottom
= nBottom
;
292 } // end of wxFindMaxSize