]>
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"
26 #include "wx/os2/private.h"
27 #include "wx/control.h"
29 IMPLEMENT_ABSTRACT_CLASS(wxControl
, wxWindow
)
31 BEGIN_EVENT_TABLE(wxControl
, wxWindow
)
32 EVT_ERASE_BACKGROUND(wxControl::OnEraseBackground
)
36 wxControl::wxControl()
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(
78 const wxChar
* zClassname
79 , const wxString
& rsLabel
86 WXDWORD dwStyle
= OS2GetStyle( lStyle
90 return OS2CreateControl( zClassname
97 } // end of wxControl::OS2CreateControl
99 bool wxControl::OS2CreateControl(
100 const wxChar
* zClassname
102 , const wxPoint
& rPos
103 , const wxSize
& rSize
104 , const wxString
& rsLabel
108 bool bWant3D
= FALSE
;
111 // Doesn't do anything at all under OS/2
113 if (dwExstyle
== (WXDWORD
)-1)
115 dwExstyle
= Determine3DEffects(WS_EX_CLIENTEDGE
, &bWant3D
);
118 // All controls should have these styles (wxWindows creates all controls
119 // visible by default)
122 dwStyle
|= WS_VISIBLE
;
124 wxWindow
* pParent
= GetParent();
130 if ((strcmp(zClassname
, "COMBOBOX")) == 0)
131 zClass
= WC_COMBOBOX
;
132 else if ((strcmp(zClassname
, "STATIC")) == 0)
134 else if ((strcmp(zClassname
, "BUTTON")) == 0)
136 else if ((strcmp(zClassname
, "NOTEBOOK")) == 0)
137 zClass
= WC_NOTEBOOK
;
138 dwStyle
|= WS_VISIBLE
;
140 m_hWnd
= (WXHWND
)::WinCreateWindow( (HWND
)GetHwndOf(pParent
) // Parent window handle
141 ,(PSZ
)zClass
// Window class
142 ,(PSZ
)rsLabel
.c_str() // Initial Text
143 ,(ULONG
)dwStyle
// Style flags
144 ,(LONG
)0 // X pos of origin
145 ,(LONG
)0 // Y pos of origin
146 ,(LONG
)0 // control width
147 ,(LONG
)0 // control height
148 ,(HWND
)GetHwndOf(pParent
) // 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
158 wxLogError(wxT("Failed to create a control of class '%s'"), zClassname
);
164 // Subclass again for purposes of dialog editing mode
169 // Controls use the same font and colours as their parent dialog by default
180 } // end of wxControl::OS2CreateControl
182 wxSize
wxControl::DoGetBestSize() const
184 return wxSize(DEFAULT_ITEM_WIDTH
, DEFAULT_ITEM_HEIGHT
);
185 } // end of wxControl::DoGetBestSize
187 bool wxControl::ProcessCommand(wxCommandEvent
& event
)
189 #if WXWIN_COMPATIBILITY
192 (void)(*m_callback
)(this, event
);
197 #endif // WXWIN_COMPATIBILITY
199 return GetEventHandler()->ProcessEvent(event
);
202 WXHBRUSH
wxControl::OnCtlColor(
211 HPS hPS
= (HPS
)hWxDC
; // pass in a PS handle in OS/2
212 wxColour vColFore
= GetForegroundColour();
213 wxColour vColBack
= GetBackgroundColour();
215 if (GetParent()->GetTransparentBackground())
216 ::GpiSetBackMix(hPS
, BM_LEAVEALONE
);
218 ::GpiSetBackMix(hPS
, BM_OVERPAINT
);
220 ::GpiSetBackColor(hPS
, vColBack
.GetPixel());
221 ::GpiSetColor(hPS
, vColFore
.GetPixel());
223 wxBrush
* pBrush
= wxTheBrushList
->FindOrCreateBrush( vColBack
226 return (WXHBRUSH
)pBrush
->GetResourceHandle();
227 } // end of wxControl::OnCtlColor
229 void wxControl::OnEraseBackground(
234 HPS hPS
= rEvent
.GetDC()->GetHPS();
237 ::GpiSetPS(hPS
, &vSize
, PU_PELS
| GPIF_DEFAULT
);
238 ::WinQueryWindowRect((HWND
)GetHwnd(), &vRect
);
239 ::WinFillRect(hPS
, &vRect
, GetBackgroundColour().GetPixel());
240 } // end of wxControl::OnEraseBackground
242 WXDWORD
wxControl::OS2GetStyle(
244 , WXDWORD
* pdwExstyle
247 long dwStyle
= wxWindow::OS2GetStyle( lStyle
253 dwStyle
|= WS_TABSTOP
;
256 } // end of wxControl::OS2GetStyle
258 // ---------------------------------------------------------------------------
260 // ---------------------------------------------------------------------------
262 // Call this repeatedly for several wnds to find the overall size
264 // Call it initially with -1 for all values in rect.
265 // Keep calling for other widgets, and rect will be modified
266 // to calculate largest bounding rectangle.
272 int nLeft
= pRect
->xLeft
;
273 int nRight
= pRect
->xRight
;
274 int nTop
= pRect
->yTop
;
275 int nBottom
= pRect
->yBottom
;
277 ::WinQueryWindowRect((HWND
)hWnd
, pRect
);
282 if (nLeft
< pRect
->xLeft
)
283 pRect
->xLeft
= nLeft
;
285 if (nRight
> pRect
->xRight
)
286 pRect
->xRight
= nRight
;
288 if (nTop
< pRect
->yTop
)
291 if (nBottom
> pRect
->yBottom
)
292 pRect
->yBottom
= nBottom
;
293 } // end of wxFindMaxSize