]>
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(
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 dwStyle
|= WS_VISIBLE
;
138 m_hWnd
= (WXHWND
)::WinCreateWindow( (HWND
)GetHwndOf(pParent
) // Parent window handle
139 ,(PSZ
)zClass
// Window class
140 ,(PSZ
)rsLabel
.c_str() // Initial Text
141 ,(ULONG
)dwStyle
// Style flags
142 ,(LONG
)0 // X pos of origin
143 ,(LONG
)0 // Y pos of origin
144 ,(LONG
)0 // control width
145 ,(LONG
)0 // control height
146 ,(HWND
)GetHwndOf(pParent
) // 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
156 wxLogError(wxT("Failed to create a control of class '%s'"), zClassname
);
162 // Subclass again for purposes of dialog editing mode
167 // Controls use the same font and colours as their parent dialog by default
178 } // end of wxControl::OS2CreateControl
180 wxSize
wxControl::DoGetBestSize() const
182 return wxSize(DEFAULT_ITEM_WIDTH
, DEFAULT_ITEM_HEIGHT
);
183 } // end of wxControl::DoGetBestSize
185 bool wxControl::ProcessCommand(wxCommandEvent
& event
)
187 #if WXWIN_COMPATIBILITY
190 (void)(*m_callback
)(this, event
);
195 #endif // WXWIN_COMPATIBILITY
197 return GetEventHandler()->ProcessEvent(event
);
200 WXHBRUSH
wxControl::OnCtlColor(
209 HPS hPS
= (HPS
)hWxDC
; // pass in a PS handle in OS/2
210 wxColour vColFore
= GetForegroundColour();
211 wxColour vColBack
= GetBackgroundColour();
213 if (GetParent()->GetTransparentBackground())
214 ::GpiSetBackMix(hPS
, BM_LEAVEALONE
);
216 ::GpiSetBackMix(hPS
, BM_OVERPAINT
);
218 ::GpiSetBackColor(hPS
, vColBack
.GetPixel());
219 ::GpiSetColor(hPS
, vColFore
.GetPixel());
221 wxBrush
* pBrush
= wxTheBrushList
->FindOrCreateBrush( vColBack
224 return (WXHBRUSH
)pBrush
->GetResourceHandle();
225 } // end of wxControl::OnCtlColor
227 void wxControl::OnEraseBackground(
232 HPS hPS
= rEvent
.GetDC()->GetHPS();
235 ::GpiSetPS(hPS
, &vSize
, PU_PELS
| GPIF_DEFAULT
);
236 ::WinQueryWindowRect((HWND
)GetHwnd(), &vRect
);
237 ::WinFillRect(hPS
, &vRect
, GetBackgroundColour().GetPixel());
238 } // end of wxControl::OnEraseBackground
240 WXDWORD
wxControl::OS2GetStyle(
242 , WXDWORD
* pdwExstyle
245 long dwStyle
= wxWindow::OS2GetStyle( lStyle
251 dwStyle
|= WS_TABSTOP
;
254 } // end of wxControl::OS2GetStyle
256 // ---------------------------------------------------------------------------
258 // ---------------------------------------------------------------------------
260 // Call this repeatedly for several wnds to find the overall size
262 // Call it initially with -1 for all values in rect.
263 // Keep calling for other widgets, and rect will be modified
264 // to calculate largest bounding rectangle.
270 int nLeft
= pRect
->xLeft
;
271 int nRight
= pRect
->xRight
;
272 int nTop
= pRect
->yTop
;
273 int nBottom
= pRect
->yBottom
;
275 ::WinQueryWindowRect((HWND
)hWnd
, pRect
);
280 if (nLeft
< pRect
->xLeft
)
281 pRect
->xLeft
= nLeft
;
283 if (nRight
> pRect
->xRight
)
284 pRect
->xRight
= nRight
;
286 if (nTop
< pRect
->yTop
)
289 if (nBottom
> pRect
->yBottom
)
290 pRect
->yBottom
= nBottom
;
291 } // end of wxFindMaxSize