]>
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
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(
50 , 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(
76 const wxChar
* zClassname
77 , const wxString
& rsLabel
84 WXDWORD dwStyle
= OS2GetStyle( lStyle
88 return OS2CreateControl( zClassname
95 } // end of wxControl::OS2CreateControl
97 bool wxControl::OS2CreateControl(
98 const wxChar
* zClassname
100 , const wxPoint
& rPos
101 , const wxSize
& rSize
102 , const wxString
& rsLabel
106 bool bWant3D
= FALSE
;
109 // Doesn't do anything at all under OS/2
111 if (dwExstyle
== (WXDWORD
)-1)
113 dwExstyle
= Determine3DEffects(WS_EX_CLIENTEDGE
, &bWant3D
);
116 // All controls should have these styles (wxWindows creates all controls
117 // visible by default)
120 dwStyle
|= WS_VISIBLE
;
122 wxWindow
* pParent
= GetParent();
128 if ((strcmp(zClassname
, "COMBOBOX")) == 0)
129 zClass
= WC_COMBOBOX
;
130 else if ((strcmp(zClassname
, "STATIC")) == 0)
132 else if ((strcmp(zClassname
, "BUTTON")) == 0)
134 else if ((strcmp(zClassname
, "NOTEBOOK")) == 0)
135 zClass
= WC_NOTEBOOK
;
136 else if ((strcmp(zClassname
, "CONTAINER")) == 0)
137 zClass
= WC_CONTAINER
;
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