]>
Commit | Line | Data |
---|---|---|
0e320a79 DW |
1 | // Name: windows.cpp |
2 | // Purpose: wxWindow | |
cdf1e714 | 3 | // Author: David Webster |
0e320a79 | 4 | // Modified by: |
cdf1e714 | 5 | // Created: 10/12/99 |
0e320a79 | 6 | // RCS-ID: $Id$ |
cdf1e714 DW |
7 | // Copyright: (c) David Webster |
8 | // Licence: wxWindows licence | |
0e320a79 DW |
9 | ///////////////////////////////////////////////////////////////////////////// |
10 | ||
a885d89a | 11 | // |
cdf1e714 | 12 | // For compilers that support precompilation, includes "wx.h". |
a885d89a | 13 | // |
cdf1e714 | 14 | #include "wx/wxprec.h" |
0e320a79 | 15 | |
849949b1 DW |
16 | #ifndef WX_PRECOMP |
17 | #define INCL_DOS | |
18 | #define INCL_PM | |
19 | #include <os2.h> | |
20 | #include "wx/window.h" | |
21 | #include "wx/accel.h" | |
22 | #include "wx/setup.h" | |
23 | #include "wx/menu.h" | |
24 | #include "wx/dc.h" | |
25 | #include "wx/dcclient.h" | |
26 | #include "wx/utils.h" | |
27 | #include "wx/app.h" | |
28 | #include "wx/panel.h" | |
29 | #include "wx/layout.h" | |
1a75e76f SN |
30 | #include "wx/checkbox.h" |
31 | #include "wx/combobox.h" | |
849949b1 DW |
32 | #include "wx/dialog.h" |
33 | #include "wx/frame.h" | |
34 | #include "wx/listbox.h" | |
35 | #include "wx/button.h" | |
376ef4a1 | 36 | #include "wx/bmpbuttn.h" |
849949b1 | 37 | #include "wx/msgdlg.h" |
19193a2c | 38 | #include "wx/scrolwin.h" |
a4a16252 | 39 | #include "wx/radiobox.h" |
1a75e76f | 40 | #include "wx/radiobut.h" |
a4a16252 | 41 | #include "wx/slider.h" |
272ebf16 | 42 | #include "wx/statbox.h" |
a4a16252 SN |
43 | #include "wx/statusbr.h" |
44 | #include "wx/toolbar.h" | |
45 | #include "wx/settings.h" | |
849949b1 DW |
46 | #include <stdio.h> |
47 | #endif | |
48 | ||
49 | #if wxUSE_OWNER_DRAWN | |
50 | #include "wx/ownerdrw.h" | |
51 | #endif | |
52 | ||
53 | #if wxUSE_DRAG_AND_DROP | |
54 | #include "wx/dnd.h" | |
55 | #endif | |
0e320a79 DW |
56 | |
57 | #include "wx/menuitem.h" | |
58 | #include "wx/log.h" | |
59 | ||
cdf1e714 DW |
60 | #include "wx/os2/private.h" |
61 | ||
849949b1 DW |
62 | #if wxUSE_TOOLTIPS |
63 | #include "wx/tooltip.h" | |
0e320a79 DW |
64 | #endif |
65 | ||
1de4baa3 DW |
66 | #if wxUSE_NOTEBOOK |
67 | #include "wx/notebook.h" | |
68 | #endif | |
69 | ||
849949b1 DW |
70 | #if wxUSE_CARET |
71 | #include "wx/caret.h" | |
72 | #endif // wxUSE_CARET | |
73 | ||
74 | #include "wx/intl.h" | |
75 | #include "wx/log.h" | |
76 | ||
77 | ||
78 | #include "wx/textctrl.h" | |
79 | ||
0e320a79 DW |
80 | #include <string.h> |
81 | ||
a885d89a DW |
82 | // |
83 | // Place compiler, OS specific includes here | |
84 | // | |
849949b1 | 85 | |
a885d89a DW |
86 | // |
87 | // Standard macros -- these are for OS/2 PM, but most GUI's have something similar | |
88 | // | |
849949b1 | 89 | #ifndef GET_X_LPARAM |
a885d89a | 90 | // |
849949b1 | 91 | // SHORT1FROMMP -- LOWORD |
a885d89a | 92 | // |
849949b1 | 93 | #define GET_X_LPARAM(mp) ((unsigned short)(unsigned long)(mp)) |
a885d89a | 94 | // |
849949b1 | 95 | // SHORT2FROMMP -- HIWORD |
a885d89a | 96 | // |
849949b1 DW |
97 | #define GET_Y_LPARAM(mp) ((unsigned short)(unsigned long)(mp >> 16)) |
98 | #endif // GET_X_LPARAM | |
99 | ||
29a99be3 DW |
100 | #ifndef CW_USEDEFAULT |
101 | # define CW_USEDEFAULT ((int)0x80000000) | |
102 | #endif | |
103 | ||
a086de98 DW |
104 | #ifndef VK_OEM_1 |
105 | #define VK_OEM_1 0xBA | |
106 | #define VK_OEM_PLUS 0xBB | |
107 | #define VK_OEM_COMMA 0xBC | |
108 | #define VK_OEM_MINUS 0xBD | |
109 | #define VK_OEM_PERIOD 0xBE | |
110 | #define VK_OEM_2 0xBF | |
111 | #define VK_OEM_3 0xC0 | |
112 | #define VK_OEM_4 0xDB | |
113 | #define VK_OEM_5 0xDC | |
114 | #define VK_OEM_6 0xDD | |
115 | #define VK_OEM_7 0xDE | |
116 | #endif | |
117 | ||
849949b1 DW |
118 | // --------------------------------------------------------------------------- |
119 | // global variables | |
120 | // --------------------------------------------------------------------------- | |
121 | ||
a885d89a | 122 | // |
19193a2c | 123 | // The last PM message we got (MT-UNSAFE) |
a885d89a | 124 | // |
61243a51 | 125 | QMSG s_currentMsg; |
849949b1 | 126 | |
19193a2c | 127 | #if wxUSE_MENUS_NATIVE |
a885d89a | 128 | wxMenu* wxCurrentPopupMenu = NULL; |
19193a2c KB |
129 | #endif // wxUSE_MENUS_NATIVE |
130 | ||
a885d89a | 131 | wxList* wxWinHandleList = NULL; |
849949b1 DW |
132 | |
133 | // --------------------------------------------------------------------------- | |
134 | // private functions | |
135 | // --------------------------------------------------------------------------- | |
a885d89a DW |
136 | |
137 | // | |
849949b1 | 138 | // the window proc for all our windows; most gui's have something similar |
a885d89a | 139 | // |
f23208ca DW |
140 | MRESULT EXPENTRY wxWndProc( HWND hWnd |
141 | ,ULONG message | |
142 | ,MPARAM mp1 | |
143 | ,MPARAM mp2 | |
144 | ); | |
11e59d47 DW |
145 | |
146 | #ifdef __WXDEBUG__ | |
147 | const char *wxGetMessageName(int message); | |
148 | #endif //__WXDEBUG__ | |
149 | ||
430974f8 DW |
150 | wxWindowOS2* FindWindowForMouseEvent( wxWindow* pWin |
151 | ,short* pnX | |
152 | ,short* pnY | |
153 | ); | |
154 | void wxRemoveHandleAssociation(wxWindowOS2* pWin); | |
155 | void wxAssociateWinWithHandle( HWND hWnd | |
156 | ,wxWindowOS2* pWin | |
157 | ); | |
a885d89a | 158 | wxWindow* wxFindWinFromHandle(WXHWND hWnd); |
849949b1 | 159 | |
a885d89a DW |
160 | // |
161 | // get the current state of SHIFT/CTRL keys | |
162 | // | |
163 | static inline bool IsShiftDown() { return (::WinGetKeyState(HWND_DESKTOP, VK_SHIFT) & 0x8000) != 0; } | |
164 | static inline bool IsCtrlDown() { return (::WinGetKeyState(HWND_DESKTOP, VK_CTRL) & 0x8000) != 0; } | |
06519806 DW |
165 | |
166 | static wxWindow* gpWinBeingCreated = NULL; | |
167 | ||
849949b1 DW |
168 | // --------------------------------------------------------------------------- |
169 | // event tables | |
170 | // --------------------------------------------------------------------------- | |
0e320a79 | 171 | |
19193a2c KB |
172 | // in wxUniv-OS/2 this class is abstract because it doesn't have DoPopupMenu() |
173 | // method | |
174 | #ifdef __WXUNIVERSAL__ | |
175 | IMPLEMENT_ABSTRACT_CLASS(wxWindowOS2, wxWindowBase) | |
176 | #else // __WXPM__ | |
849949b1 | 177 | IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxWindowBase) |
19193a2c | 178 | #endif // __WXUNIVERSAL__/__WXPM__ |
0e320a79 | 179 | |
19193a2c | 180 | BEGIN_EVENT_TABLE(wxWindowOS2, wxWindowBase) |
0367c1c0 DW |
181 | EVT_ERASE_BACKGROUND(wxWindowOS2::OnEraseBackground) |
182 | EVT_SYS_COLOUR_CHANGED(wxWindowOS2::OnSysColourChanged) | |
183 | EVT_INIT_DIALOG(wxWindowOS2::OnInitDialog) | |
184 | EVT_IDLE(wxWindowOS2::OnIdle) | |
185 | EVT_SET_FOCUS(wxWindowOS2::OnSetFocus) | |
849949b1 | 186 | END_EVENT_TABLE() |
0e320a79 | 187 | |
849949b1 DW |
188 | // =========================================================================== |
189 | // implementation | |
190 | // =========================================================================== | |
0e320a79 | 191 | |
19193a2c KB |
192 | // --------------------------------------------------------------------------- |
193 | // wxWindow utility functions | |
194 | // --------------------------------------------------------------------------- | |
195 | ||
a885d89a | 196 | // |
776d87d5 | 197 | // Find an item given the PM Window id |
a885d89a | 198 | // |
0367c1c0 | 199 | wxWindow* wxWindowOS2::FindItem( |
a885d89a | 200 | long lId |
776d87d5 | 201 | ) const |
cdf1e714 | 202 | { |
19193a2c KB |
203 | #if wxUSE_CONTROLS |
204 | wxControl* pItem = wxDynamicCast(this, wxControl); | |
a885d89a DW |
205 | |
206 | if (pItem) | |
207 | { | |
208 | // | |
209 | // I it we or one of our "internal" children? | |
210 | // | |
19193a2c KB |
211 | if (pItem->GetId() == lId |
212 | #ifndef __WXUNIVERSAL__ | |
213 | || (pItem->GetSubcontrols().Index(lId) != wxNOT_FOUND) | |
214 | #endif | |
215 | ) | |
a885d89a DW |
216 | { |
217 | return pItem; | |
218 | } | |
219 | } | |
19193a2c | 220 | #endif // wxUSE_CONTROLS |
a885d89a | 221 | |
776d87d5 DW |
222 | wxWindowList::Node* pCurrent = GetChildren().GetFirst(); |
223 | ||
224 | while (pCurrent) | |
cdf1e714 | 225 | { |
776d87d5 | 226 | wxWindow* pChildWin = pCurrent->GetData(); |
a885d89a | 227 | wxWindow* pWnd = pChildWin->FindItem(lId); |
cdf1e714 | 228 | |
776d87d5 DW |
229 | if (pWnd) |
230 | return pWnd; | |
cdf1e714 | 231 | |
776d87d5 | 232 | pCurrent = pCurrent->GetNext(); |
cdf1e714 | 233 | } |
776d87d5 | 234 | return(NULL); |
0367c1c0 | 235 | } // end of wxWindowOS2::FindItem |
cdf1e714 | 236 | |
a885d89a | 237 | // |
776d87d5 | 238 | // Find an item given the PM Window handle |
a885d89a | 239 | // |
0367c1c0 | 240 | wxWindow* wxWindowOS2::FindItemByHWND( |
776d87d5 DW |
241 | WXHWND hWnd |
242 | , bool bControlOnly | |
243 | ) const | |
cdf1e714 | 244 | { |
776d87d5 DW |
245 | wxWindowList::Node* pCurrent = GetChildren().GetFirst(); |
246 | ||
247 | while (pCurrent) | |
cdf1e714 | 248 | { |
776d87d5 | 249 | wxWindow* pParent = pCurrent->GetData(); |
cdf1e714 | 250 | |
a885d89a | 251 | // |
cdf1e714 | 252 | // Do a recursive search. |
a885d89a | 253 | // |
776d87d5 DW |
254 | wxWindow* pWnd = pParent->FindItemByHWND(hWnd); |
255 | ||
256 | if (pWnd) | |
257 | return(pWnd); | |
cdf1e714 | 258 | |
19193a2c KB |
259 | if (!bControlOnly |
260 | #if wxUSE_CONTROLS | |
261 | || pParent->IsKindOf(CLASSINFO(wxControl)) | |
262 | #endif // wxUSE_CONTROLS | |
263 | ) | |
cdf1e714 | 264 | { |
776d87d5 DW |
265 | wxWindow* pItem = pCurrent->GetData(); |
266 | ||
267 | if (pItem->GetHWND() == hWnd) | |
268 | return(pItem); | |
cdf1e714 DW |
269 | else |
270 | { | |
776d87d5 DW |
271 | if (pItem->ContainsHWND(hWnd)) |
272 | return(pItem); | |
cdf1e714 DW |
273 | } |
274 | } | |
776d87d5 | 275 | pCurrent = pCurrent->GetNext(); |
cdf1e714 | 276 | } |
776d87d5 | 277 | return(NULL); |
0367c1c0 | 278 | } // end of wxWindowOS2::FindItemByHWND |
cdf1e714 | 279 | |
a885d89a | 280 | // |
cdf1e714 | 281 | // Default command handler |
a885d89a | 282 | // |
0367c1c0 | 283 | bool wxWindowOS2::OS2Command( |
776d87d5 DW |
284 | WXUINT WXUNUSED(uParam) |
285 | , WXWORD WXUNUSED(uId) | |
286 | ) | |
cdf1e714 | 287 | { |
776d87d5 | 288 | return(FALSE); |
cdf1e714 DW |
289 | } |
290 | ||
291 | // ---------------------------------------------------------------------------- | |
292 | // constructors and such | |
293 | // ---------------------------------------------------------------------------- | |
294 | ||
0367c1c0 | 295 | void wxWindowOS2::Init() |
0e320a79 | 296 | { |
a885d89a DW |
297 | // |
298 | // Generic | |
299 | // | |
849949b1 | 300 | InitBase(); |
0e320a79 | 301 | |
a885d89a | 302 | // |
849949b1 | 303 | // PM specific |
a885d89a | 304 | // |
776d87d5 | 305 | m_bWinCaptured = FALSE; |
cdf1e714 | 306 | |
3437f881 | 307 | m_isBeingDeleted = FALSE; |
47df2b8c | 308 | m_fnOldWndProc = NULL; |
3437f881 DW |
309 | m_bUseCtl3D = FALSE; |
310 | m_bMouseInWindow = FALSE; | |
311 | m_bLastKeydownProcessed = FALSE; | |
cfcebdb1 | 312 | m_pChildrenDisabled = NULL; |
0e320a79 | 313 | |
a885d89a | 314 | // |
849949b1 | 315 | // wxWnd |
a885d89a | 316 | // |
c8b5f745 DW |
317 | m_hMenu = 0L; |
318 | m_hWnd = 0L; | |
319 | m_hWndScrollBarHorz = 0L; | |
320 | m_hWndScrollBarVert = 0L; | |
0e320a79 | 321 | |
4a46a5df DW |
322 | memset(&m_vWinSwp, '\0', sizeof (SWP)); |
323 | ||
a885d89a DW |
324 | // |
325 | // Pass WM_GETDLGCODE to DefWindowProc() | |
4a46a5df | 326 | // |
849949b1 | 327 | m_lDlgCode = 0; |
0e320a79 | 328 | |
776d87d5 DW |
329 | m_nXThumbSize = 0; |
330 | m_nYThumbSize = 0; | |
331 | m_bBackgroundTransparent = FALSE; | |
0e320a79 | 332 | |
a885d89a DW |
333 | // |
334 | // As all windows are created with WS_VISIBLE style... | |
335 | // | |
849949b1 | 336 | m_isShown = TRUE; |
0e320a79 | 337 | |
cdf1e714 | 338 | #if wxUSE_MOUSEEVENT_HACK |
776d87d5 DW |
339 | m_lLastMouseX = |
340 | m_lLastMouseY = -1; | |
341 | m_nLastMouseEvent = -1; | |
cdf1e714 | 342 | #endif // wxUSE_MOUSEEVENT_HACK |
0367c1c0 | 343 | } // wxWindowOS2::Init |
0e320a79 | 344 | |
a885d89a | 345 | // |
849949b1 | 346 | // Destructor |
a885d89a | 347 | // |
0367c1c0 | 348 | wxWindowOS2::~wxWindowOS2() |
0e320a79 | 349 | { |
849949b1 | 350 | m_isBeingDeleted = TRUE; |
0e320a79 | 351 | |
1ec46a5b DW |
352 | for (wxWindow* pWin = GetParent(); pWin; pWin = pWin->GetParent()) |
353 | { | |
47df2b8c | 354 | wxTopLevelWindow* pFrame = wxDynamicCast(pWin, wxTopLevelWindow); |
1ec46a5b DW |
355 | |
356 | if (pFrame) | |
357 | { | |
358 | if (pFrame->GetLastFocus() == this) | |
47df2b8c | 359 | pFrame->SetLastFocus(NULL); |
1ec46a5b DW |
360 | } |
361 | } | |
19193a2c KB |
362 | |
363 | DestroyChildren(); | |
364 | ||
849949b1 DW |
365 | if (m_parent) |
366 | m_parent->RemoveChild(this); | |
e604d44b | 367 | |
849949b1 DW |
368 | if (m_hWnd) |
369 | { | |
a885d89a | 370 | if(!::WinDestroyWindow(GetHWND())) |
223d09f6 | 371 | wxLogLastError(wxT("DestroyWindow")); |
a885d89a | 372 | // |
849949b1 | 373 | // remove hWnd <-> wxWindow association |
a885d89a | 374 | // |
849949b1 DW |
375 | wxRemoveHandleAssociation(this); |
376 | } | |
cfcebdb1 | 377 | delete m_pChildrenDisabled; |
0367c1c0 | 378 | } // end of wxWindowOS2::~wxWindowOS2 |
0e320a79 | 379 | |
19193a2c | 380 | // real construction (Init() must have been called before!) |
0367c1c0 | 381 | bool wxWindowOS2::Create( |
776d87d5 DW |
382 | wxWindow* pParent |
383 | , wxWindowID vId | |
384 | , const wxPoint& rPos | |
385 | , const wxSize& rSize | |
386 | , long lStyle | |
387 | , const wxString& rName | |
388 | ) | |
389 | { | |
f23208ca | 390 | HWND hParent = NULLHANDLE; |
19193a2c KB |
391 | ULONG ulCreateFlags = 0; |
392 | WXDWORD dwExStyle = 0; | |
f23208ca | 393 | |
776d87d5 DW |
394 | wxCHECK_MSG(pParent, FALSE, wxT("can't create wxWindow without parent")); |
395 | ||
b9b1d6c8 DW |
396 | #if wxUSE_STATBOX |
397 | // | |
398 | // wxGTK doesn't allow to create controls with static box as the parent so | |
399 | // this will result in a crash when the program is ported to wxGTK - warn | |
400 | // about it | |
401 | // | |
402 | // the correct solution is to create the controls as siblings of the | |
403 | // static box | |
404 | // | |
405 | wxASSERT_MSG( !wxDynamicCast(pParent, wxStaticBox), | |
406 | _T("wxStaticBox can't be used as a window parent!") ); | |
407 | #endif // wxUSE_STATBOX | |
408 | ||
776d87d5 DW |
409 | if ( !CreateBase( pParent |
410 | ,vId | |
411 | ,rPos | |
412 | ,rSize | |
413 | ,lStyle | |
414 | ,wxDefaultValidator | |
415 | ,rName | |
416 | )) | |
417 | return(FALSE); | |
418 | ||
f23208ca DW |
419 | if (pParent) |
420 | { | |
b7d8f285 DW |
421 | int nTempy; |
422 | ||
f23208ca DW |
423 | pParent->AddChild(this); |
424 | hParent = GetWinHwnd(pParent); | |
cb71578c | 425 | |
cb71578c DW |
426 | if ( pParent->IsKindOf(CLASSINFO(wxGenericScrolledWindow)) || |
427 | pParent->IsKindOf(CLASSINFO(wxScrolledWindow)) | |
428 | ) | |
429 | ulCreateFlags |= WS_CLIPSIBLINGS; | |
f23208ca | 430 | } |
776d87d5 | 431 | |
a885d89a | 432 | // |
f23208ca DW |
433 | // Most wxSTYLES are really PM Class specific styles and will be |
434 | // set in those class create procs. PM's basic windows styles are | |
435 | // very limited. | |
a885d89a | 436 | // |
cfcebdb1 | 437 | ulCreateFlags |= OS2GetCreateWindowFlags(&dwExStyle); |
51c1d535 DW |
438 | |
439 | ||
19193a2c KB |
440 | #ifdef __WXUNIVERSAL__ |
441 | // no 3d effects, we draw them ourselves | |
442 | WXDWORD exStyle = 0; | |
b9b1d6c8 | 443 | #endif // !wxUniversal |
19193a2c KB |
444 | if (lStyle & wxPOPUP_WINDOW) |
445 | { | |
19193a2c KB |
446 | ulCreateFlags &= ~WS_VISIBLE; |
447 | m_isShown = FALSE; | |
448 | } | |
cfcebdb1 DW |
449 | else |
450 | { | |
451 | ulCreateFlags |= WS_VISIBLE; | |
452 | } | |
19193a2c | 453 | |
a885d89a | 454 | // |
5d44b24e DW |
455 | // Generic OS/2 Windows have no Control Data but other classes |
456 | // that call OS2Create may have some. | |
a885d89a | 457 | // |
a23692f0 DW |
458 | return(OS2Create( (PSZ)wxCanvasClassName |
459 | ,rName.c_str() | |
460 | ,ulCreateFlags | |
461 | ,rPos | |
462 | ,rSize | |
463 | ,NULL // Control Data | |
464 | ,dwExStyle | |
465 | ,TRUE // Child | |
466 | )); | |
0367c1c0 | 467 | } // end of wxWindowOS2::Create |
0e320a79 | 468 | |
cdf1e714 DW |
469 | // --------------------------------------------------------------------------- |
470 | // basic operations | |
471 | // --------------------------------------------------------------------------- | |
0e320a79 | 472 | |
0367c1c0 | 473 | void wxWindowOS2::SetFocus() |
0e320a79 | 474 | { |
bbdc9a87 | 475 | HWND hWnd = GetHwnd(); |
19193a2c | 476 | wxCHECK_RET( hWnd, _T("can't set focus to invalid window") ); |
bbdc9a87 DW |
477 | |
478 | if (hWnd) | |
479 | ::WinSetFocus(HWND_DESKTOP, hWnd); | |
0367c1c0 | 480 | } // end of wxWindowOS2::SetFocus |
0e320a79 | 481 | |
1cee3f60 DW |
482 | void wxWindowOS2::SetFocusFromKbd() |
483 | { | |
484 | // | |
485 | // Nothing else to do under OS/2 | |
486 | // | |
487 | wxWindowBase::SetFocusFromKbd(); | |
488 | } // end of wxWindowOS2::SetFocus | |
489 | ||
11e59d47 | 490 | wxWindow* wxWindowBase::FindFocus() |
0e320a79 | 491 | { |
bbdc9a87 DW |
492 | HWND hWnd = ::WinQueryFocus(HWND_DESKTOP); |
493 | ||
494 | if (hWnd) | |
495 | { | |
496 | return wxFindWinFromHandle((WXHWND)hWnd); | |
497 | } | |
498 | return NULL; | |
a885d89a | 499 | } // wxWindowBase::FindFocus |
0e320a79 | 500 | |
0367c1c0 | 501 | bool wxWindowOS2::Enable( |
bbdc9a87 DW |
502 | bool bEnable |
503 | ) | |
0e320a79 | 504 | { |
bbdc9a87 DW |
505 | if (!wxWindowBase::Enable(bEnable)) |
506 | return(FALSE); | |
507 | ||
508 | HWND hWnd = GetHwnd(); | |
509 | ||
510 | if ( hWnd ) | |
511 | ::WinEnableWindow(hWnd, (BOOL)bEnable); | |
512 | ||
774468bd DW |
513 | // |
514 | // The logic below doesn't apply to the top level windows -- otherwise | |
515 | // showing a modal dialog would result in total greying out (and ungreying | |
516 | // out later) of everything which would be really ugly | |
517 | // | |
518 | if (IsTopLevel()) | |
519 | return TRUE; | |
520 | ||
bbdc9a87 DW |
521 | wxWindowList::Node* pNode = GetChildren().GetFirst(); |
522 | ||
523 | while (pNode) | |
524 | { | |
525 | wxWindow* pChild = pNode->GetData(); | |
526 | ||
cfcebdb1 DW |
527 | if (bEnable) |
528 | { | |
529 | // | |
530 | // Enable the child back unless it had been disabled before us | |
531 | // | |
532 | if (!m_pChildrenDisabled || !m_pChildrenDisabled->Find(pChild)) | |
533 | pChild->Enable(); | |
534 | } | |
535 | else // we're being disabled | |
536 | { | |
537 | if (pChild->IsEnabled()) | |
538 | { | |
539 | // | |
540 | // Disable it as children shouldn't stay enabled while the | |
541 | // parent is not | |
542 | // | |
543 | pChild->Disable(); | |
544 | } | |
545 | else // child already disabled, remember it | |
546 | { | |
547 | // | |
548 | // Have we created the list of disabled children already? | |
549 | // | |
550 | if (!m_pChildrenDisabled) | |
551 | m_pChildrenDisabled = new wxWindowList; | |
552 | m_pChildrenDisabled->Append(pChild); | |
553 | } | |
554 | } | |
bbdc9a87 DW |
555 | pNode = pNode->GetNext(); |
556 | } | |
cfcebdb1 DW |
557 | if (bEnable && m_pChildrenDisabled) |
558 | { | |
559 | // | |
560 | // We don't need this list any more, don't keep unused memory | |
561 | // | |
562 | delete m_pChildrenDisabled; | |
563 | m_pChildrenDisabled = NULL; | |
564 | } | |
19193a2c | 565 | return TRUE; |
0367c1c0 | 566 | } // end of wxWindowOS2::Enable |
0e320a79 | 567 | |
0367c1c0 | 568 | bool wxWindowOS2::Show( |
bbdc9a87 DW |
569 | bool bShow |
570 | ) | |
0e320a79 | 571 | { |
bbdc9a87 DW |
572 | if (!wxWindowBase::Show(bShow)) |
573 | return(FALSE); | |
574 | ||
575 | HWND hWnd = GetHwnd(); | |
576 | ||
577 | ::WinShowWindow(hWnd, bShow); | |
578 | ||
579 | if (bShow) | |
580 | { | |
a885d89a | 581 | ::WinSetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE | SWP_ZORDER); |
bbdc9a87 | 582 | } |
19193a2c | 583 | return TRUE; |
0367c1c0 | 584 | } // end of wxWindowOS2::Show |
0e320a79 | 585 | |
0367c1c0 | 586 | void wxWindowOS2::Raise() |
0e320a79 | 587 | { |
a885d89a | 588 | ::WinSetWindowPos(GetHwnd(), HWND_TOP, 0, 0, 0, 0, SWP_ZORDER | SWP_ACTIVATE); |
0367c1c0 | 589 | } // end of wxWindowOS2::Raise |
0e320a79 | 590 | |
0367c1c0 | 591 | void wxWindowOS2::Lower() |
0e320a79 | 592 | { |
a885d89a | 593 | ::WinSetWindowPos(GetHwnd(), HWND_BOTTOM, 0, 0, 0, 0, SWP_ZORDER | SWP_DEACTIVATE); |
0367c1c0 | 594 | } // end of wxWindowOS2::Lower |
0e320a79 | 595 | |
0367c1c0 | 596 | void wxWindowOS2::SetTitle( |
bbdc9a87 DW |
597 | const wxString& rTitle |
598 | ) | |
0e320a79 | 599 | { |
f38374d0 | 600 | ::WinSetWindowText(GetHwnd(), rTitle.c_str()); |
0367c1c0 | 601 | } // end of wxWindowOS2::SetTitle |
0e320a79 | 602 | |
0367c1c0 | 603 | wxString wxWindowOS2::GetTitle() const |
0e320a79 | 604 | { |
cdf1e714 | 605 | return wxGetWindowText(GetHWND()); |
0367c1c0 | 606 | } // end of wxWindowOS2::GetTitle |
0e320a79 | 607 | |
4116c221 | 608 | void wxWindowOS2::DoCaptureMouse() |
0e320a79 | 609 | { |
f38374d0 DW |
610 | HWND hWnd = GetHwnd(); |
611 | ||
612 | if (hWnd && !m_bWinCaptured) | |
613 | { | |
614 | ::WinSetCapture(HWND_DESKTOP, hWnd); | |
615 | m_bWinCaptured = TRUE; | |
616 | } | |
0367c1c0 | 617 | } // end of wxWindowOS2::GetTitle |
0e320a79 | 618 | |
4116c221 | 619 | void wxWindowOS2::DoReleaseMouse() |
0e320a79 | 620 | { |
a885d89a | 621 | if (m_bWinCaptured) |
f38374d0 DW |
622 | { |
623 | ::WinSetCapture(HWND_DESKTOP, NULLHANDLE); | |
624 | m_bWinCaptured = FALSE; | |
625 | } | |
0367c1c0 | 626 | } // end of wxWindowOS2::ReleaseMouse |
0e320a79 | 627 | |
0367c1c0 DW |
628 | /* static */ wxWindow* wxWindowBase::GetCapture() |
629 | { | |
630 | HWND hwnd = ::WinQueryCapture(HWND_DESKTOP); | |
631 | return hwnd ? wxFindWinFromHandle((WXHWND)hwnd) : (wxWindow *)NULL; | |
632 | } // end of wxWindowBase::GetCapture | |
633 | ||
634 | bool wxWindowOS2::SetFont( | |
f38374d0 DW |
635 | const wxFont& rFont |
636 | ) | |
0e320a79 | 637 | { |
f38374d0 DW |
638 | if (!wxWindowBase::SetFont(rFont)) |
639 | { | |
640 | // nothing to do | |
641 | return(FALSE); | |
642 | } | |
643 | ||
644 | HWND hWnd = GetHwnd(); | |
645 | ||
e3bfcacf DW |
646 | wxOS2SetFont( hWnd |
647 | ,rFont | |
648 | ); | |
cdf1e714 | 649 | return(TRUE); |
e3bfcacf | 650 | } // end of wxWindowOS2::SetFont |
0e320a79 | 651 | |
0367c1c0 | 652 | bool wxWindowOS2::SetCursor( |
f38374d0 DW |
653 | const wxCursor& rCursor |
654 | ) // check if base implementation is OK | |
0e320a79 | 655 | { |
f38374d0 DW |
656 | if ( !wxWindowBase::SetCursor(rCursor)) |
657 | { | |
658 | // no change | |
659 | return FALSE; | |
660 | } | |
661 | ||
19193a2c KB |
662 | if ( m_cursor.Ok() ) { |
663 | HWND hWnd = GetHwnd(); | |
664 | POINTL vPoint; | |
665 | RECTL vRect; | |
f38374d0 | 666 | |
19193a2c KB |
667 | ::WinQueryPointerPos(HWND_DESKTOP, &vPoint); |
668 | ::WinQueryWindowRect(hWnd, &vRect); | |
f38374d0 | 669 | |
19193a2c KB |
670 | if (::WinPtInRect(vHabmain, &vRect, &vPoint) && !wxIsBusy()) |
671 | { | |
672 | ::WinSetPointer(HWND_DESKTOP, (HPOINTER)m_cursor.GetHCURSOR()); | |
673 | } | |
f38374d0 DW |
674 | } |
675 | return TRUE; | |
0367c1c0 | 676 | } // end of wxWindowOS2::SetCursor |
0e320a79 | 677 | |
0367c1c0 | 678 | void wxWindowOS2::WarpPointer( |
a885d89a DW |
679 | int nXPos |
680 | , int nYPos | |
681 | ) | |
0e320a79 | 682 | { |
a885d89a DW |
683 | int nX = nXPos; |
684 | int nY = nYPos; | |
685 | RECTL vRect; | |
686 | ||
687 | ::WinQueryWindowRect(GetHwnd(), &vRect); | |
688 | nX += vRect.xLeft; | |
689 | nY += vRect.yBottom; | |
690 | ||
691 | ::WinSetPointerPos(HWND_DESKTOP, (LONG)nX, (LONG)(nY)); | |
0367c1c0 | 692 | } // end of wxWindowOS2::WarpPointer |
0e320a79 | 693 | |
0e320a79 | 694 | |
cdf1e714 DW |
695 | // --------------------------------------------------------------------------- |
696 | // scrolling stuff | |
697 | // --------------------------------------------------------------------------- | |
0e320a79 | 698 | |
0367c1c0 | 699 | int wxWindowOS2::GetScrollPos( |
05fc6c0a DW |
700 | int nOrient |
701 | ) const | |
0e320a79 | 702 | { |
b7d8f285 DW |
703 | if (nOrient == wxHORIZONTAL) |
704 | return((int)::WinSendMsg(m_hWndScrollBarHorz, SBM_QUERYPOS, (MPARAM)NULL, (MPARAM)NULL)); | |
705 | else | |
706 | return((int)::WinSendMsg(m_hWndScrollBarVert, SBM_QUERYPOS, (MPARAM)NULL, (MPARAM)NULL)); | |
0367c1c0 | 707 | } // end of wxWindowOS2::GetScrollPos |
0e320a79 | 708 | |
0367c1c0 | 709 | int wxWindowOS2::GetScrollRange( |
05fc6c0a DW |
710 | int nOrient |
711 | ) const | |
0e320a79 | 712 | { |
05fc6c0a | 713 | MRESULT mr; |
0e320a79 | 714 | |
b7d8f285 DW |
715 | if (nOrient == wxHORIZONTAL) |
716 | mr = ::WinSendMsg(m_hWndScrollBarHorz, SBM_QUERYRANGE, (MPARAM)NULL, (MPARAM)NULL); | |
717 | else | |
718 | mr = ::WinSendMsg(m_hWndScrollBarVert, SBM_QUERYRANGE, (MPARAM)NULL, (MPARAM)NULL); | |
05fc6c0a | 719 | return((int)SHORT2FROMMR(mr)); |
0367c1c0 | 720 | } // end of wxWindowOS2::GetScrollRange |
05fc6c0a | 721 | |
0367c1c0 | 722 | int wxWindowOS2::GetScrollThumb( |
05fc6c0a DW |
723 | int nOrient |
724 | ) const | |
0e320a79 | 725 | { |
b7d8f285 DW |
726 | if (nOrient == wxHORIZONTAL ) |
727 | return m_nXThumbSize; | |
728 | else | |
729 | return m_nYThumbSize; | |
0367c1c0 | 730 | } // end of wxWindowOS2::GetScrollThumb |
0e320a79 | 731 | |
0367c1c0 | 732 | void wxWindowOS2::SetScrollPos( |
05fc6c0a DW |
733 | int nOrient |
734 | , int nPos | |
19193a2c | 735 | , bool WXUNUSED(bRefresh) |
05fc6c0a | 736 | ) |
0e320a79 | 737 | { |
b7d8f285 DW |
738 | if (nOrient == wxHORIZONTAL ) |
739 | ::WinSendMsg(m_hWndScrollBarHorz, SBM_SETPOS, (MPARAM)nPos, (MPARAM)NULL); | |
740 | else | |
741 | ::WinSendMsg(m_hWndScrollBarVert, SBM_SETPOS, (MPARAM)nPos, (MPARAM)NULL); | |
19193a2c | 742 | } // end of wxWindowOS2::SetScrollPos |
0e320a79 | 743 | |
0367c1c0 | 744 | void wxWindowOS2::SetScrollbar( |
05fc6c0a DW |
745 | int nOrient |
746 | , int nPos | |
747 | , int nThumbVisible | |
748 | , int nRange | |
19193a2c | 749 | , bool WXUNUSED(bRefresh) |
05fc6c0a | 750 | ) |
0e320a79 | 751 | { |
45e0dc94 | 752 | HWND hWnd = GetHwnd(); |
1c84ee88 DW |
753 | int nOldRange = nRange - nThumbVisible; |
754 | int nRange1 = nOldRange; | |
755 | int nPageSize = nThumbVisible; | |
45e0dc94 | 756 | |
1c84ee88 | 757 | SBCDATA vInfo; |
45e0dc94 | 758 | ULONG ulStyle = WS_VISIBLE | WS_SYNCPAINT; |
b3260bce | 759 | SWP vSwp; |
859e65de | 760 | SWP vSwpOwner; |
45e0dc94 DW |
761 | RECTL vRect; |
762 | HWND hWndParent; | |
763 | HWND hWndClient; | |
764 | wxWindow* pParent = GetParent(); | |
765 | ||
766 | if (pParent && pParent->IsKindOf(CLASSINFO(wxFrame))) | |
767 | { | |
768 | wxFrame* pFrame; | |
769 | ||
770 | pFrame = wxDynamicCast(pParent, wxFrame); | |
771 | hWndParent = pFrame->GetFrame(); | |
772 | hWndClient = GetHwndOf(pParent); | |
773 | } | |
774 | else | |
775 | { | |
776 | if (pParent) | |
777 | hWndParent = GetHwndOf(pParent); | |
778 | else | |
779 | hWndParent = GetHwnd(); | |
780 | hWndClient = hWndParent; | |
781 | } | |
782 | ::WinQueryWindowPos(hWndClient, &vSwp); | |
859e65de | 783 | ::WinQueryWindowPos(hWnd, &vSwpOwner); |
1c84ee88 | 784 | |
1c84ee88 | 785 | if (nPageSize > 1 && nRange > 0) |
05fc6c0a | 786 | { |
1c84ee88 DW |
787 | nRange1 += (nPageSize - 1); |
788 | } | |
789 | ||
790 | vInfo.cb = sizeof(SBCDATA); | |
791 | vInfo.posFirst = 0; | |
792 | vInfo.posLast = (SHORT)nRange1; | |
793 | vInfo.posThumb = nPos; | |
794 | ||
795 | if (nOrient == wxHORIZONTAL ) | |
796 | { | |
797 | ulStyle |= SBS_HORZ; | |
c8b5f745 | 798 | if (m_hWndScrollBarHorz == 0L) |
1c84ee88 | 799 | { |
859e65de DW |
800 | // |
801 | // Since the scrollbars are usually created before the owner is | |
802 | // sized either via an OnSize event directly or via sizers or | |
803 | // layout constraints, we will initially just use the coords of | |
804 | // the parent window (this is usually a frame client window). But | |
805 | // the bars themselves, are children of the parent frame (i.e | |
806 | // siblings of the frame client. The owner, however is the actual | |
807 | // window being scrolled (or at least the one responsible for | |
808 | // handling the scroll events). The owner will be resized later, | |
809 | // as it is usually a child of a top level window, and when that | |
810 | // is done its scrollbars will be resized and repositioned as well. | |
811 | // | |
45e0dc94 | 812 | m_hWndScrollBarHorz = ::WinCreateWindow( hWndParent |
c8b5f745 DW |
813 | ,WC_SCROLLBAR |
814 | ,(PSZ)NULL | |
815 | ,ulStyle | |
45e0dc94 DW |
816 | ,vSwp.x |
817 | ,vSwp.y | |
818 | ,vSwp.cx - 20 | |
c8b5f745 DW |
819 | ,20 |
820 | ,hWnd | |
821 | ,HWND_TOP | |
626af800 | 822 | ,60000 |
c8b5f745 DW |
823 | ,&vInfo |
824 | ,NULL | |
825 | ); | |
1c84ee88 DW |
826 | } |
827 | else | |
828 | { | |
859e65de DW |
829 | // |
830 | // The owner (the scrolled window) is a child of the Frame's | |
831 | // client window, usually. The scrollbars are children of the | |
832 | // frame, itself, and thus are positioned relative to the frame's | |
833 | // origin, not the frame's client window origin. | |
834 | // The starting x position is the same as the starting x position | |
835 | // of the owner, but in terms of the parent frame. | |
836 | // The starting y position is 20 pels below the origin of the | |
837 | // owner in terms of the parent frame. | |
838 | // The horz bar is the same width as the owner and 20 pels high. | |
839 | // | |
524d72c4 DW |
840 | if (nRange1 >= nThumbVisible) |
841 | { | |
842 | ::WinSetWindowPos( m_hWndScrollBarHorz | |
843 | ,HWND_TOP | |
844 | ,vSwp.x + vSwpOwner.x | |
845 | ,(vSwp.y + vSwpOwner.y) - 20 | |
846 | ,vSwpOwner.cx | |
847 | ,20 | |
848 | ,SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ACTIVATE | SWP_ZORDER | |
849 | ); | |
850 | ::WinSendMsg( m_hWndScrollBarHorz | |
851 | ,SBM_SETSCROLLBAR | |
852 | ,(MPARAM)nPos | |
853 | ,MPFROM2SHORT(0, (SHORT)nRange1) | |
854 | ); | |
855 | ::WinSendMsg( m_hWndScrollBarHorz | |
856 | ,SBM_SETTHUMBSIZE | |
857 | ,MPFROM2SHORT( (SHORT)nThumbVisible | |
858 | ,(SHORT)nRange1 | |
859 | ) | |
860 | ,(MPARAM)0 | |
861 | ); | |
862 | } | |
863 | else | |
864 | ::WinShowWindow(m_hWndScrollBarHorz, FALSE); | |
1c84ee88 | 865 | } |
05fc6c0a DW |
866 | } |
867 | else | |
868 | { | |
1c84ee88 | 869 | ulStyle |= SBS_VERT; |
c8b5f745 | 870 | if (m_hWndScrollBarVert == 0L) |
1c84ee88 | 871 | { |
859e65de DW |
872 | // |
873 | // Since the scrollbars are usually created before the owner is | |
874 | // sized either via an OnSize event directly or via sizers or | |
875 | // layout constraints, we will initially just use the coords of | |
876 | // the parent window (this is usually a frame client window). But | |
877 | // the bars themselves, are children of the parent frame (i.e | |
878 | // siblings of the frame client. The owner, however is the actual | |
879 | // window being scrolled (or at least the one responsible for | |
880 | // handling the scroll events). The owner will be resized later, | |
881 | // as it is usually a child of a top level window, and when that | |
882 | // is done its scrollbars will be resized and repositioned as well. | |
883 | // | |
45e0dc94 | 884 | m_hWndScrollBarVert = ::WinCreateWindow( hWndParent |
c8b5f745 DW |
885 | ,WC_SCROLLBAR |
886 | ,(PSZ)NULL | |
887 | ,ulStyle | |
45e0dc94 DW |
888 | ,vSwp.x + vSwp.cx - 20 |
889 | ,vSwp.y + 20 | |
c8b5f745 | 890 | ,20 |
45e0dc94 | 891 | ,vSwp.cy - 20 |
c8b5f745 DW |
892 | ,hWnd |
893 | ,HWND_TOP | |
626af800 | 894 | ,60001 |
c8b5f745 DW |
895 | ,&vInfo |
896 | ,NULL | |
897 | ); | |
1c84ee88 DW |
898 | } |
899 | else | |
900 | { | |
859e65de DW |
901 | // |
902 | // The owner (the scrolled window) is a child of the Frame's | |
903 | // client window, usually. The scrollbars are children of the | |
904 | // frame, itself and thus are positioned relative to the frame's | |
905 | // origin, not the frame's client window's origin. | |
906 | // Thus, the x position will be frame client's x (usually a few | |
907 | // pels inside the parent frame, plus the width of the owner. | |
908 | // Since we may be using sizers or layout constraints for multiple | |
909 | // child scrolled windows, the y position will be the frame client's | |
910 | // y pos plus the scrolled windows y position, yielding the y | |
911 | // position of the scrollbar relative to the parent frame (the vert | |
912 | // scrollbar is on the right and starts at the bottom of the | |
913 | // owner window). | |
914 | // It is 20 pels wide and the same height as the owner. | |
915 | // | |
524d72c4 DW |
916 | if (nRange1 >= nThumbVisible) |
917 | { | |
918 | ::WinSetWindowPos( m_hWndScrollBarVert | |
919 | ,HWND_TOP | |
920 | ,vSwp.x + vSwpOwner.x + vSwpOwner.cx | |
921 | ,vSwp.y + vSwpOwner.y | |
922 | ,20 | |
923 | ,vSwpOwner.cy | |
924 | ,SWP_ACTIVATE | SWP_MOVE | SWP_SIZE | SWP_SHOW | |
925 | ); | |
926 | ::WinSendMsg( m_hWndScrollBarVert | |
927 | ,SBM_SETSCROLLBAR | |
928 | ,(MPARAM)nPos | |
929 | ,MPFROM2SHORT(0, (SHORT)nRange1) | |
930 | ); | |
931 | ::WinSendMsg( m_hWndScrollBarVert | |
932 | ,SBM_SETTHUMBSIZE | |
933 | ,MPFROM2SHORT( (SHORT)nThumbVisible | |
934 | ,(SHORT)nRange1 | |
935 | ) | |
936 | ,(MPARAM)0 | |
937 | ); | |
938 | } | |
939 | else | |
940 | ::WinShowWindow(m_hWndScrollBarVert, FALSE); | |
1c84ee88 | 941 | } |
05fc6c0a DW |
942 | m_nYThumbSize = nThumbVisible; |
943 | } | |
0367c1c0 | 944 | } // end of wxWindowOS2::SetScrollbar |
0e320a79 | 945 | |
0367c1c0 | 946 | void wxWindowOS2::ScrollWindow( |
05fc6c0a DW |
947 | int nDx |
948 | , int nDy | |
949 | , const wxRect* pRect | |
950 | ) | |
0e320a79 | 951 | { |
b7d8f285 | 952 | RECTL vRect; |
626af800 DW |
953 | RECTL vRectHorz; |
954 | RECTL vRectVert; | |
955 | RECTL vRectChild; | |
05fc6c0a DW |
956 | |
957 | if (pRect) | |
958 | { | |
b3260bce DW |
959 | vRect.xLeft = pRect->x; |
960 | vRect.yTop = pRect->y + pRect->height; | |
961 | vRect.xRight = pRect->x + pRect->width; | |
962 | vRect.yBottom = pRect->y; | |
05fc6c0a | 963 | } |
e661fcd7 DW |
964 | else |
965 | { | |
626af800 | 966 | ::WinQueryWindowRect(GetHwnd(), &vRect); |
e661fcd7 | 967 | } |
45e0dc94 | 968 | nDy *= -1; // flip the sign of Dy as OS/2 is opposite Windows. |
626af800 DW |
969 | ::WinScrollWindow( GetHwnd() |
970 | ,(LONG)nDx | |
971 | ,(LONG)nDy | |
972 | ,&vRect | |
45e0dc94 | 973 | ,&vRect |
626af800 DW |
974 | ,NULLHANDLE |
975 | ,NULL | |
45e0dc94 | 976 | ,SW_SCROLLCHILDREN | SW_INVALIDATERGN |
626af800 | 977 | ); |
4a46a5df | 978 | Refresh(); |
0367c1c0 | 979 | } // end of wxWindowOS2::ScrollWindow |
0e320a79 | 980 | |
cdf1e714 DW |
981 | // --------------------------------------------------------------------------- |
982 | // subclassing | |
983 | // --------------------------------------------------------------------------- | |
0e320a79 | 984 | |
0367c1c0 | 985 | void wxWindowOS2::SubclassWin( |
c86c44a0 DW |
986 | WXHWND hWnd |
987 | ) | |
0e320a79 | 988 | { |
05fc6c0a DW |
989 | HWND hwnd = (HWND)hWnd; |
990 | ||
61243a51 | 991 | wxCHECK_RET(::WinIsWindow(vHabmain, hwnd), wxT("invalid HWND in SubclassWin") ); |
e58dab20 DW |
992 | wxAssociateWinWithHandle( hWnd |
993 | ,(wxWindow*)this | |
994 | ); | |
995 | if (!wxCheckWindowWndProc( hWnd | |
996 | ,(WXFARPROC)wxWndProc | |
997 | )) | |
998 | { | |
999 | m_fnOldWndProc = (WXFARPROC) ::WinSubclassWindow(hwnd, (PFNWP)wxWndProc); | |
1000 | } | |
1001 | else | |
1002 | { | |
1003 | m_fnOldWndProc = (WXFARPROC)NULL; | |
1004 | } | |
0367c1c0 | 1005 | } // end of wxWindowOS2::SubclassWin |
0e320a79 | 1006 | |
0367c1c0 | 1007 | void wxWindowOS2::UnsubclassWin() |
0e320a79 | 1008 | { |
c86c44a0 | 1009 | // |
cdf1e714 | 1010 | // Restore old Window proc |
c86c44a0 | 1011 | // |
e604d44b | 1012 | HWND hwnd = GetHWND(); |
c86c44a0 | 1013 | |
e604d44b | 1014 | if (m_hWnd) |
cdf1e714 | 1015 | { |
61243a51 | 1016 | wxCHECK_RET( ::WinIsWindow(vHabmain, hwnd), wxT("invalid HWND in UnsubclassWin") ); |
0e320a79 | 1017 | |
e604d44b | 1018 | PFNWP fnProc = (PFNWP)::WinQueryWindowPtr(hwnd, QWP_PFNWP); |
51c1d535 | 1019 | |
c86c44a0 | 1020 | if ( (m_fnOldWndProc != 0) && (fnProc != (PFNWP) m_fnOldWndProc)) |
cdf1e714 | 1021 | { |
c86c44a0 DW |
1022 | WinSubclassWindow(hwnd, (PFNWP)m_fnOldWndProc); |
1023 | m_fnOldWndProc = 0; | |
cdf1e714 DW |
1024 | } |
1025 | } | |
0367c1c0 | 1026 | } // end of wxWindowOS2::UnsubclassWin |
0e320a79 | 1027 | |
5d44b24e DW |
1028 | bool wxCheckWindowWndProc( |
1029 | WXHWND hWnd | |
1030 | , WXFARPROC fnWndProc | |
1031 | ) | |
1032 | { | |
1033 | static char zBuffer[512]; | |
1034 | CLASSINFO vCls; | |
1035 | ||
1036 | ::WinQueryClassName((HWND)hWnd, (LONG)512, (PCH)zBuffer); | |
1037 | ::WinQueryClassInfo(wxGetInstance(), (PSZ)zBuffer, &vCls); | |
1038 | return(fnWndProc == (WXFARPROC)vCls.pfnWindowProc); | |
1039 | } // end of WinGuiBase_CheckWindowWndProc | |
1040 | ||
b9b1d6c8 DW |
1041 | void wxWindowOS2::SetWindowStyleFlag( |
1042 | long lFlags | |
1043 | ) | |
1044 | { | |
1045 | long lFlagsOld = GetWindowStyleFlag(); | |
1046 | ||
1047 | if (lFlags == lFlagsOld) | |
1048 | return; | |
1049 | ||
1050 | // | |
1051 | // Update the internal variable | |
1052 | // | |
1053 | wxWindowBase::SetWindowStyleFlag(lFlags); | |
1054 | ||
1055 | // | |
1056 | // Now update the Windows style as well if needed - and if the window had | |
1057 | // been already created | |
1058 | // | |
1059 | if (!GetHwnd()) | |
1060 | return; | |
1061 | ||
1062 | WXDWORD dwExstyle; | |
1063 | WXDWORD dwExstyleOld; | |
1064 | long lStyle = OS2GetStyle( lFlags | |
1065 | ,&dwExstyle | |
1066 | ); | |
1067 | long lStyleOld = OS2GetStyle( lFlagsOld | |
1068 | ,&dwExstyleOld | |
1069 | ); | |
1070 | ||
1071 | if (lStyle != lStyleOld) | |
1072 | { | |
1073 | // | |
1074 | // Some flags (e.g. WS_VISIBLE or WS_DISABLED) should not be changed by | |
1075 | // this function so instead of simply setting the style to the new | |
1076 | // value we clear the bits which were set in styleOld but are set in | |
1077 | // the new one and set the ones which were not set before | |
1078 | // | |
1079 | long lStyleReal = ::WinQueryWindowULong(GetHwnd(), QWL_STYLE); | |
1080 | ||
1081 | lStyleReal &= ~lStyleOld; | |
1082 | lStyleReal |= lStyle; | |
1083 | ||
1084 | ::WinSetWindowULong(GetHwnd(), QWL_STYLE, lStyleReal); | |
1085 | } | |
1086 | } // end of wxWindowOS2::SetWindowStyleFlag | |
1087 | ||
1088 | WXDWORD wxWindowOS2::OS2GetStyle( | |
1089 | long lFlags | |
1090 | , WXDWORD* pdwExstyle | |
1091 | ) const | |
1092 | { | |
1093 | WXDWORD dwStyle = 0L; | |
1094 | ||
1095 | if (lFlags & wxCLIP_CHILDREN ) | |
1096 | dwStyle |= WS_CLIPCHILDREN; | |
1097 | ||
1098 | if (lFlags & wxCLIP_SIBLINGS ) | |
1099 | dwStyle |= WS_CLIPSIBLINGS; | |
1100 | ||
1101 | return dwStyle; | |
1102 | } // end of wxWindowMSW::MSWGetStyle | |
1103 | ||
05fc6c0a | 1104 | // |
cdf1e714 | 1105 | // Make a Windows extended style from the given wxWindows window style |
05fc6c0a | 1106 | // |
0367c1c0 | 1107 | WXDWORD wxWindowOS2::MakeExtendedStyle( |
05fc6c0a DW |
1108 | long lStyle |
1109 | , bool bEliminateBorders | |
1110 | ) | |
0e320a79 | 1111 | { |
05fc6c0a | 1112 | // |
008089f6 DW |
1113 | // Simply fill out with wxWindow extended styles. We'll conjure |
1114 | // something up in OS2Create and all window redrawing pieces later | |
05fc6c0a | 1115 | // |
008089f6 DW |
1116 | WXDWORD dwStyle = 0; |
1117 | ||
1118 | if (lStyle & wxTRANSPARENT_WINDOW ) | |
1119 | dwStyle |= wxTRANSPARENT_WINDOW; | |
1120 | ||
1121 | if (!bEliminateBorders) | |
1122 | { | |
1123 | if (lStyle & wxSUNKEN_BORDER) | |
1124 | dwStyle |= wxSUNKEN_BORDER; | |
1125 | if (lStyle & wxDOUBLE_BORDER) | |
1126 | dwStyle |= wxDOUBLE_BORDER; | |
1127 | if (lStyle & wxRAISED_BORDER ) | |
1128 | dwStyle |= wxRAISED_BORDER; | |
1129 | if (lStyle & wxSTATIC_BORDER) | |
1130 | dwStyle |= wxSTATIC_BORDER; | |
1131 | } | |
1132 | return dwStyle; | |
0367c1c0 | 1133 | } // end of wxWindowOS2::MakeExtendedStyle |
cdf1e714 | 1134 | |
c86c44a0 | 1135 | // |
008089f6 | 1136 | // Determines whether simulated 3D effects or CTL3D should be used, |
cdf1e714 | 1137 | // applying a default border style if required, and returning an extended |
008089f6 | 1138 | // style to pass to OS2Create. |
c86c44a0 | 1139 | // |
0367c1c0 | 1140 | WXDWORD wxWindowOS2::Determine3DEffects( |
c86c44a0 | 1141 | WXDWORD dwDefaultBorderStyle |
542875a8 | 1142 | , bool* pbWant3D |
c86c44a0 DW |
1143 | ) const |
1144 | { | |
542875a8 DW |
1145 | WXDWORD dwStyle = 0L; |
1146 | ||
c86c44a0 | 1147 | // |
008089f6 DW |
1148 | // Native PM does not have any specialize 3D effects like WIN32 does, |
1149 | // so we have to try and invent them. | |
1150 | // | |
1151 | ||
1152 | // | |
1153 | // If matches certain criteria, then assume no 3D effects | |
1154 | // unless specifically requested (dealt with in MakeExtendedStyle) | |
1155 | // | |
1156 | if (!GetParent() || | |
1157 | !IsKindOf(CLASSINFO(wxControl)) || | |
1158 | (m_windowStyle & wxNO_BORDER) | |
1159 | ) | |
1160 | { | |
1161 | *pbWant3D = FALSE; | |
1162 | return MakeExtendedStyle(m_windowStyle, FALSE); | |
1163 | } | |
1164 | ||
1165 | // | |
1166 | // 1) App can specify global 3D effects | |
c86c44a0 | 1167 | // |
008089f6 DW |
1168 | *pbWant3D = wxTheApp->GetAuto3D(); |
1169 | ||
1170 | // | |
1171 | // 2) If the parent is being drawn with user colours, or simple border | |
1172 | // specified, switch effects off. | |
1173 | // | |
1174 | if (GetParent() && | |
1175 | (GetParent()->GetWindowStyleFlag() & wxUSER_COLOURS) || | |
1176 | (m_windowStyle & wxSIMPLE_BORDER) | |
1177 | ) | |
1178 | *pbWant3D = FALSE; | |
1179 | ||
1180 | // | |
1181 | // 3) Control can override this global setting by defining | |
1182 | // a border style, e.g. wxSUNKEN_BORDER | |
1183 | // | |
1184 | if ((m_windowStyle & wxDOUBLE_BORDER) || | |
1185 | (m_windowStyle & wxRAISED_BORDER) || | |
1186 | (m_windowStyle & wxSTATIC_BORDER) || | |
1187 | (m_windowStyle & wxSUNKEN_BORDER) | |
1188 | ) | |
1189 | *pbWant3D = TRUE; | |
1190 | ||
1191 | dwStyle = MakeExtendedStyle( m_windowStyle | |
1192 | ,FALSE | |
1193 | ); | |
1194 | ||
1195 | // | |
1196 | // If we want 3D, but haven't specified a border here, | |
1197 | // apply the default border style specified. | |
1198 | // | |
1199 | if (dwDefaultBorderStyle && (*pbWant3D) && | |
1200 | !((m_windowStyle & wxDOUBLE_BORDER) || | |
1201 | (m_windowStyle & wxRAISED_BORDER) || | |
1202 | (m_windowStyle & wxSTATIC_BORDER) || | |
1203 | (m_windowStyle & wxSIMPLE_BORDER) | |
1204 | ) | |
1205 | ) | |
1206 | dwStyle |= dwDefaultBorderStyle; | |
c86c44a0 | 1207 | return dwStyle; |
0367c1c0 | 1208 | } // end of wxWindowOS2::Determine3DEffects |
cdf1e714 | 1209 | |
c86c44a0 | 1210 | // |
cdf1e714 | 1211 | // Setup background and foreground colours correctly |
c86c44a0 | 1212 | // |
0367c1c0 | 1213 | void wxWindowOS2::SetupColours() |
cdf1e714 DW |
1214 | { |
1215 | if ( GetParent() ) | |
1216 | SetBackgroundColour(GetParent()->GetBackgroundColour()); | |
0367c1c0 | 1217 | } // end of wxWindowOS2::SetupColours |
cdf1e714 | 1218 | |
0367c1c0 | 1219 | void wxWindowOS2::OnIdle( |
19193a2c | 1220 | wxIdleEvent& WXUNUSED(rEvent) |
c86c44a0 | 1221 | ) |
cdf1e714 | 1222 | { |
c86c44a0 DW |
1223 | // |
1224 | // Check if we need to send a LEAVE event | |
1225 | // | |
1226 | if (m_bMouseInWindow) | |
1227 | { | |
1228 | POINTL vPoint; | |
cdf1e714 | 1229 | |
c86c44a0 DW |
1230 | ::WinQueryPointerPos(HWND_DESKTOP, &vPoint); |
1231 | if (::WinWindowFromPoint(HWND_DESKTOP, &vPoint, FALSE) != (HWND)GetHwnd()) | |
1232 | { | |
1233 | // | |
1234 | // Generate a LEAVE event | |
1235 | // | |
1236 | m_bMouseInWindow = FALSE; | |
1237 | ||
1238 | // | |
1239 | // Unfortunately the mouse button and keyboard state may have changed | |
1240 | // by the time the OnIdle function is called, so 'state' may be | |
1241 | // meaningless. | |
1242 | // | |
1243 | int nState = 0; | |
1244 | ||
1245 | if (::WinGetKeyState(HWND_DESKTOP, VK_SHIFT) != 0) | |
1246 | nState |= VK_SHIFT; | |
542875a8 | 1247 | if (::WinGetKeyState(HWND_DESKTOP, VK_CTRL) != 0); |
c86c44a0 DW |
1248 | nState |= VK_CTRL; |
1249 | ||
1250 | wxMouseEvent rEvent(wxEVT_LEAVE_WINDOW); | |
1251 | ||
1252 | InitMouseEvent( rEvent | |
1253 | ,vPoint.x | |
1254 | ,vPoint.y | |
1255 | ,nState | |
1256 | ); | |
542875a8 | 1257 | (void)GetEventHandler()->ProcessEvent(rEvent); |
c86c44a0 DW |
1258 | } |
1259 | } | |
e39af974 JS |
1260 | if (wxUpdateUIEvent::CanUpdate(this)) |
1261 | UpdateWindowUI(wxUPDATE_UI_FROMIDLE); | |
0367c1c0 | 1262 | } // end of wxWindowOS2::OnIdle |
c86c44a0 DW |
1263 | |
1264 | // | |
cdf1e714 | 1265 | // Set this window to be the child of 'parent'. |
c86c44a0 | 1266 | // |
0367c1c0 | 1267 | bool wxWindowOS2::Reparent( |
c86c44a0 DW |
1268 | wxWindow* pParent |
1269 | ) | |
cdf1e714 | 1270 | { |
c86c44a0 | 1271 | if (!wxWindowBase::Reparent(pParent)) |
cdf1e714 | 1272 | return FALSE; |
c86c44a0 DW |
1273 | |
1274 | HWND hWndChild = GetHwnd(); | |
1275 | HWND hWndParent = GetParent() ? GetWinHwnd(GetParent()) : (HWND)0; | |
1276 | ||
1277 | ::WinSetParent(hWndChild, hWndParent, TRUE); | |
1278 | return TRUE; | |
0367c1c0 | 1279 | } // end of wxWindowOS2::Reparent |
cdf1e714 | 1280 | |
06519806 DW |
1281 | void wxWindowOS2::Update() |
1282 | { | |
1283 | ::WinUpdateWindow(GetHwnd()); | |
1284 | } // end of wxWindowOS2::Update | |
1285 | ||
1286 | void wxWindowOS2::Freeze() | |
1287 | { | |
1288 | ::WinSendMsg(GetHwnd(), WM_VRNDISABLED, (MPARAM)0, (MPARAM)0); | |
1289 | } // end of wxWindowOS2::Freeze | |
1290 | ||
1291 | void wxWindowOS2::Thaw() | |
1292 | { | |
1293 | ::WinSendMsg(GetHwnd(), WM_VRNENABLED, (MPARAM)TRUE, (MPARAM)0); | |
1294 | ||
1295 | // | |
1296 | // We need to refresh everything or otherwise he invalidated area is not | |
1297 | // repainted. | |
1298 | // | |
1299 | Refresh(); | |
1300 | } // end of wxWindowOS2::Thaw | |
1301 | ||
0367c1c0 | 1302 | void wxWindowOS2::Refresh( |
c86c44a0 DW |
1303 | bool bEraseBack |
1304 | , const wxRect* pRect | |
1305 | ) | |
cdf1e714 | 1306 | { |
c86c44a0 DW |
1307 | HWND hWnd = GetHwnd(); |
1308 | ||
1309 | if (hWnd) | |
1310 | { | |
1311 | if (pRect) | |
1312 | { | |
1313 | RECTL vOs2Rect; | |
1314 | ||
1315 | vOs2Rect.xLeft = pRect->x; | |
542875a8 | 1316 | vOs2Rect.yTop = pRect->y; |
c86c44a0 DW |
1317 | vOs2Rect.xRight = pRect->x + pRect->width; |
1318 | vOs2Rect.yBottom = pRect->y + pRect->height; | |
1319 | ||
1320 | ::WinInvalidateRect(hWnd, &vOs2Rect, bEraseBack); | |
1321 | } | |
1322 | else | |
1323 | ::WinInvalidateRect(hWnd, NULL, bEraseBack); | |
45e0dc94 DW |
1324 | if (m_hWndScrollBarHorz != NULLHANDLE) |
1325 | ::WinInvalidateRect(m_hWndScrollBarHorz, NULL, TRUE); | |
1326 | if (m_hWndScrollBarVert != NULLHANDLE) | |
1327 | ::WinInvalidateRect(m_hWndScrollBarVert, NULL, TRUE); | |
c86c44a0 | 1328 | } |
0367c1c0 | 1329 | } // end of wxWindowOS2::Refresh |
cdf1e714 DW |
1330 | |
1331 | // --------------------------------------------------------------------------- | |
1332 | // drag and drop | |
1333 | // --------------------------------------------------------------------------- | |
1334 | ||
1335 | #if wxUSE_DRAG_AND_DROP | |
0367c1c0 | 1336 | void wxWindowOS2::SetDropTarget( |
c86c44a0 DW |
1337 | wxDropTarget* pDropTarget |
1338 | ) | |
cdf1e714 | 1339 | { |
c86c44a0 | 1340 | m_dropTarget = pDropTarget; |
0367c1c0 | 1341 | } // end of wxWindowOS2::SetDropTarget |
cdf1e714 DW |
1342 | #endif |
1343 | ||
c86c44a0 | 1344 | // |
cdf1e714 DW |
1345 | // old style file-manager drag&drop support: we retain the old-style |
1346 | // DragAcceptFiles in parallel with SetDropTarget. | |
c86c44a0 | 1347 | // |
0367c1c0 | 1348 | void wxWindowOS2::DragAcceptFiles( |
c86c44a0 DW |
1349 | bool bAccept |
1350 | ) | |
cdf1e714 | 1351 | { |
c86c44a0 DW |
1352 | HWND hWnd = GetHwnd(); |
1353 | ||
1354 | if (hWnd && bAccept) | |
542875a8 | 1355 | ::DrgAcceptDroppedFiles(hWnd, NULL, NULL, DO_COPY, 0L); |
0367c1c0 | 1356 | } // end of wxWindowOS2::DragAcceptFiles |
cdf1e714 DW |
1357 | |
1358 | // ---------------------------------------------------------------------------- | |
1359 | // tooltips | |
1360 | // ---------------------------------------------------------------------------- | |
1361 | ||
1362 | #if wxUSE_TOOLTIPS | |
1363 | ||
0367c1c0 | 1364 | void wxWindowOS2::DoSetToolTip( |
c86c44a0 DW |
1365 | wxToolTip* pTooltip |
1366 | ) | |
cdf1e714 | 1367 | { |
c86c44a0 | 1368 | wxWindowBase::DoSetToolTip(pTooltip); |
cdf1e714 | 1369 | |
542875a8 | 1370 | if (m_tooltip) |
cdf1e714 | 1371 | m_tooltip->SetWindow(this); |
0367c1c0 | 1372 | } // end of wxWindowOS2::DoSetToolTip |
cdf1e714 DW |
1373 | |
1374 | #endif // wxUSE_TOOLTIPS | |
1375 | ||
1376 | // --------------------------------------------------------------------------- | |
1377 | // moving and resizing | |
1378 | // --------------------------------------------------------------------------- | |
1379 | ||
1380 | // Get total size | |
0367c1c0 | 1381 | void wxWindowOS2::DoGetSize( |
a7ef993c DW |
1382 | int* pWidth |
1383 | , int* pHeight | |
1384 | ) const | |
cdf1e714 | 1385 | { |
5d44b24e | 1386 | HWND hWnd; |
a7ef993c | 1387 | RECTL vRect; |
c86c44a0 | 1388 | |
5d44b24e DW |
1389 | if (IsKindOf(CLASSINFO(wxFrame))) |
1390 | { | |
1391 | wxFrame* pFrame = wxDynamicCast(this, wxFrame); | |
1392 | hWnd = pFrame->GetFrame(); | |
1393 | } | |
1394 | else | |
1395 | hWnd = GetHwnd(); | |
1396 | ||
a7ef993c DW |
1397 | ::WinQueryWindowRect(hWnd, &vRect); |
1398 | ||
1399 | if (pWidth) | |
1400 | *pWidth = vRect.xRight - vRect.xLeft; | |
1401 | if (pHeight ) | |
1402 | // OS/2 PM is backwards from windows | |
1403 | *pHeight = vRect.yTop - vRect.yBottom; | |
0367c1c0 | 1404 | } // end of wxWindowOS2::DoGetSize |
cdf1e714 | 1405 | |
0367c1c0 | 1406 | void wxWindowOS2::DoGetPosition( |
a7ef993c DW |
1407 | int* pX |
1408 | , int* pY | |
1409 | ) const | |
cdf1e714 | 1410 | { |
a7ef993c | 1411 | HWND hWnd = GetHwnd(); |
8330166c | 1412 | SWP vSwp; |
a7ef993c | 1413 | POINTL vPoint; |
8330166c | 1414 | wxWindow* pParent = GetParent(); |
c86c44a0 | 1415 | |
8330166c DW |
1416 | // |
1417 | // It would seem that WinQueryWindowRect would be the correlary to | |
1418 | // the WIN32 WinGetRect, but unlike WinGetRect which returns the window | |
1419 | // origin position in screen coordinates, WinQueryWindowRect returns it | |
1420 | // relative to itself, i.e. (0,0). To get the same under PM we must | |
1421 | // us WinQueryWindowPos. This call, unlike the WIN32 call, however, | |
1422 | // returns a position relative to it's parent, so no parent adujstments | |
1423 | // are needed under OS/2. Also, windows should be created using | |
1424 | // wxWindow coordinates, i.e 0,0 is the TOP left so vSwp will already | |
1425 | // reflect that. | |
1426 | // | |
1427 | ::WinQueryWindowPos(hWnd, &vSwp); | |
c86c44a0 | 1428 | |
8330166c DW |
1429 | vPoint.x = vSwp.x; |
1430 | vPoint.y = vSwp.y; | |
c86c44a0 | 1431 | |
a7ef993c | 1432 | // |
8330166c DW |
1433 | // We may be faking the client origin. So a window that's really at (0, |
1434 | // 30) may appear (to wxWin apps) to be at (0, 0). | |
a7ef993c | 1435 | // |
8330166c | 1436 | if (pParent) |
c86c44a0 | 1437 | { |
8330166c | 1438 | wxPoint vPt(pParent->GetClientAreaOrigin()); |
a7ef993c | 1439 | |
8330166c DW |
1440 | vPoint.x -= vPt.x; |
1441 | vPoint.y -= vPt.y; | |
c86c44a0 DW |
1442 | } |
1443 | ||
a7ef993c DW |
1444 | if (pX) |
1445 | *pX = vPoint.x; | |
542875a8 | 1446 | if (pY) |
a7ef993c | 1447 | *pY = vPoint.y; |
0367c1c0 | 1448 | } // end of wxWindowOS2::DoGetPosition |
cdf1e714 | 1449 | |
0367c1c0 | 1450 | void wxWindowOS2::DoScreenToClient( |
a7ef993c DW |
1451 | int* pX |
1452 | , int* pY | |
1453 | ) const | |
cdf1e714 | 1454 | { |
a7ef993c | 1455 | HWND hWnd = GetHwnd(); |
8330166c | 1456 | SWP vSwp; |
542875a8 | 1457 | |
8330166c | 1458 | ::WinQueryWindowPos(hWnd, &vSwp); |
cdf1e714 | 1459 | |
a7ef993c | 1460 | if (pX) |
8330166c | 1461 | *pX += vSwp.x; |
a7ef993c | 1462 | if (pY) |
8330166c | 1463 | *pY += vSwp.y; |
0367c1c0 | 1464 | } // end of wxWindowOS2::DoScreenToClient |
a7ef993c | 1465 | |
0367c1c0 | 1466 | void wxWindowOS2::DoClientToScreen( |
a7ef993c DW |
1467 | int* pX |
1468 | , int* pY | |
1469 | ) const | |
cdf1e714 | 1470 | { |
a7ef993c | 1471 | HWND hWnd = GetHwnd(); |
8330166c | 1472 | SWP vSwp; |
19193a2c | 1473 | |
8330166c | 1474 | ::WinQueryWindowPos(hWnd, &vSwp); |
c86c44a0 | 1475 | |
a7ef993c | 1476 | if (pX) |
8330166c | 1477 | *pX += vSwp.x; |
a7ef993c | 1478 | if (pY) |
8330166c | 1479 | *pY += vSwp.y; |
0367c1c0 | 1480 | } // end of wxWindowOS2::DoClientToScreen |
cdf1e714 | 1481 | |
a7ef993c | 1482 | // |
cdf1e714 | 1483 | // Get size *available for subwindows* i.e. excluding menu bar etc. |
a7ef993c DW |
1484 | // Must be a frame type window |
1485 | // | |
0367c1c0 | 1486 | void wxWindowOS2::DoGetClientSize( |
a7ef993c DW |
1487 | int* pWidth |
1488 | , int* pHeight | |
1489 | ) const | |
cdf1e714 | 1490 | { |
a7ef993c | 1491 | HWND hWnd = GetHwnd(); |
a7ef993c DW |
1492 | RECTL vRect; |
1493 | ||
5d44b24e | 1494 | ::WinQueryWindowRect(hWnd, &vRect); |
e37db699 DW |
1495 | if (IsKindOf(CLASSINFO(wxDialog))) |
1496 | { | |
1497 | RECTL vTitle; | |
1498 | HWND hWndTitle; | |
1499 | // | |
1500 | // For a Dialog we have to explicitly request the client portion. | |
1501 | // For a Frame the hWnd IS the client window | |
1502 | // | |
1503 | hWndTitle = ::WinWindowFromID(hWnd, FID_TITLEBAR); | |
1504 | if (::WinQueryWindowRect(hWndTitle, &vTitle)) | |
1505 | { | |
1506 | if (vTitle.yTop - vTitle.yBottom == 0) | |
1507 | { | |
1508 | // | |
1509 | // Dialog has not been created yet, use a default | |
1510 | // | |
1511 | vTitle.yTop = 20; | |
1512 | } | |
1513 | vRect.yTop -= (vTitle.yTop - vTitle.yBottom); | |
1514 | } | |
1515 | ||
1516 | ULONG uStyle = ::WinQueryWindowULong(hWnd, QWL_STYLE); | |
1517 | ||
1518 | // | |
1519 | // Deal with borders | |
1520 | // | |
1521 | if (uStyle & FCF_DLGBORDER) | |
1522 | { | |
1523 | vRect.xLeft += 4; | |
1524 | vRect.xRight -= 4; | |
1525 | vRect.yTop -= 4; | |
1526 | vRect.yBottom += 4; | |
1527 | } | |
1528 | else if (uStyle & FCF_SIZEBORDER) | |
1529 | { | |
1530 | vRect.xLeft += 4; | |
1531 | vRect.xRight -= 4; | |
1532 | vRect.yTop -= 4; | |
1533 | vRect.yBottom += 4; | |
1534 | } | |
1535 | else if (uStyle & FCF_BORDER) | |
1536 | { | |
1537 | vRect.xLeft += 2; | |
1538 | vRect.xRight -= 2; | |
1539 | vRect.yTop -= 2; | |
1540 | vRect.yBottom += 2; | |
1541 | } | |
1542 | else // make some kind of adjustment or top sizers ram into the titlebar! | |
1543 | { | |
1544 | vRect.xLeft += 3; | |
1545 | vRect.xRight -= 3; | |
1546 | vRect.yTop -= 3; | |
1547 | vRect.yBottom += 3; | |
1548 | } | |
1549 | } | |
542875a8 | 1550 | if (pWidth) |
e37db699 | 1551 | *pWidth = vRect.xRight - vRect.xLeft; |
542875a8 | 1552 | if (pHeight) |
e37db699 | 1553 | *pHeight = vRect.yTop - vRect.yBottom; |
0367c1c0 | 1554 | } // end of wxWindowOS2::DoGetClientSize |
cdf1e714 | 1555 | |
0367c1c0 | 1556 | void wxWindowOS2::DoMoveWindow( |
a7ef993c DW |
1557 | int nX |
1558 | , int nY | |
1559 | , int nWidth | |
1560 | , int nHeight | |
1561 | ) | |
cdf1e714 | 1562 | { |
39c26ef2 DW |
1563 | RECTL vRect; |
1564 | HWND hParent; | |
1565 | wxWindow* pParent = GetParent(); | |
1566 | ||
1b086de1 | 1567 | if (pParent && !IsKindOf(CLASSINFO(wxDialog))) |
987da0d4 | 1568 | { |
d8a3f66c DW |
1569 | int nOS2Height = GetOS2ParentHeight(pParent); |
1570 | ||
1571 | nY = nOS2Height - (nY + nHeight); | |
987da0d4 | 1572 | } |
39c26ef2 | 1573 | else |
c86c44a0 | 1574 | { |
987da0d4 DW |
1575 | RECTL vRect; |
1576 | ||
1577 | ::WinQueryWindowRect(HWND_DESKTOP, &vRect); | |
1578 | nY = vRect.yTop - (nY + nHeight); | |
1579 | } | |
f289196b DW |
1580 | |
1581 | // | |
1582 | // In the case of a frame whose client is sized, the client cannot be | |
1583 | // large than its parent frame minus its borders! This usually happens | |
1584 | // when using an autosizer to size a frame to precisely hold client | |
1585 | // controls as in the notebook sample. | |
1586 | // | |
1587 | // In this case, we may need to resize both a frame and its client so we | |
1588 | // need a quick calc of the frame border size, then if the frame | |
1589 | // (less its borders) is smaller than the client, size the frame to | |
1590 | // encompass the client with the appropriate border size. | |
1591 | // | |
1592 | if (IsKindOf(CLASSINFO(wxFrame))) | |
1593 | { | |
1594 | RECTL vFRect; | |
1595 | HWND hWndFrame; | |
1596 | int nWidthFrameDelta = 0; | |
1597 | int nHeightFrameDelta = 0; | |
1598 | int nHeightFrame = 0; | |
1599 | int nWidthFrame = 0; | |
1600 | ULONG ulFLag = SWP_MOVE; | |
1601 | wxFrame* pFrame; | |
1602 | ||
1603 | pFrame = wxDynamicCast(this, wxFrame); | |
1604 | hWndFrame = pFrame->GetFrame(); | |
1605 | ::WinQueryWindowRect(hWndFrame, &vRect); | |
1606 | ::WinMapWindowPoints(hWndFrame, HWND_DESKTOP, (PPOINTL)&vRect, 2); | |
1607 | vFRect = vRect; | |
1608 | ::WinCalcFrameRect(hWndFrame, &vRect, TRUE); | |
1609 | nWidthFrameDelta = ((vRect.xLeft - vFRect.xLeft) + (vFRect.xRight - vRect.xRight)); | |
1610 | nHeightFrameDelta = ((vRect.yBottom - vFRect.yBottom) + (vFRect.yTop - vRect.yTop)); | |
1611 | nWidthFrame = vFRect.xRight - vFRect.xLeft; | |
1612 | nHeightFrame = vFRect.yTop - vFRect.yBottom; | |
1613 | ||
1614 | if (nWidth == vFRect.xRight - vFRect.xLeft && | |
1615 | nHeight == vFRect.yTop - vFRect.yBottom) | |
1616 | { | |
1617 | // | |
1618 | // In this case the caller is not aware of OS/2's need to size both | |
1619 | // the frame and it's client and is really only moving the window, | |
1620 | // not resizeing it. So move the frame, and back off the sizes | |
1621 | // for a proper client fit. | |
1622 | // | |
1623 | ::WinSetWindowPos( hWndFrame | |
1624 | ,HWND_TOP | |
1625 | ,(LONG)nX - (vRect.xLeft - vFRect.xLeft) | |
1626 | ,(LONG)nY - (vRect.yBottom - vFRect.yBottom) | |
1627 | ,(LONG)0 | |
1628 | ,(LONG)0 | |
1629 | ,SWP_MOVE | |
1630 | ); | |
1631 | nX += (vRect.xLeft - vFRect.xLeft); | |
1632 | nY += (vRect.yBottom - vFRect.yBottom); | |
1633 | nWidth -= nWidthFrameDelta; | |
1634 | nHeight -= nHeightFrameDelta; | |
1635 | } | |
1636 | else | |
1637 | { | |
1638 | if (nWidth > nWidthFrame - nHeightFrameDelta || | |
1639 | nHeight > nHeightFrame - nHeightFrameDelta) | |
1640 | { | |
1641 | ::WinSetWindowPos( hWndFrame | |
1642 | ,HWND_TOP | |
1643 | ,(LONG)nX - (vRect.xLeft - vFRect.xLeft) | |
1644 | ,(LONG)nY - (vRect.yBottom - vFRect.yBottom) | |
1645 | ,(LONG)nWidth + nWidthFrameDelta | |
1646 | ,(LONG)nHeight + nHeightFrameDelta | |
1647 | ,SWP_MOVE | SWP_SIZE | |
1648 | ); | |
1649 | } | |
1650 | } | |
1651 | } | |
1652 | ||
987da0d4 DW |
1653 | ::WinSetWindowPos( GetHwnd() |
1654 | ,HWND_TOP | |
1655 | ,(LONG)nX | |
1656 | ,(LONG)nY | |
1657 | ,(LONG)nWidth | |
1658 | ,(LONG)nHeight | |
f289196b | 1659 | ,SWP_SIZE | SWP_MOVE |
987da0d4 | 1660 | ); |
859e65de DW |
1661 | if (m_vWinSwp.cx == 0 && m_vWinSwp.cy == 0 && m_vWinSwp.fl == 0) |
1662 | // | |
1663 | // Uninitialized | |
1664 | // | |
1665 | ::WinQueryWindowPos(GetHwnd(), &m_vWinSwp); | |
1666 | else | |
1667 | { | |
1668 | int nYDiff = m_vWinSwp.cy - nHeight; | |
1669 | ||
1670 | // | |
1671 | // Handle resizing of scrolled windows. The target or window to | |
1672 | // be scrolled is the owner (gets the scroll notificaitons). The | |
1673 | // parent is usually the parent frame of the scrolled panel window. | |
1674 | // In order to show the scrollbars the target window will be shrunk | |
1675 | // by the size of the scroll bar widths (20) and moved in the X and Y | |
1676 | // directon. That value will be computed as part of the diff for | |
1677 | // moving the children. Everytime the window is sized the | |
1678 | // toplevel OnSize is going to resize the panel to fit the client | |
1679 | // or the whole sizer and will need to me resized. This will send | |
1680 | // a WM_SIZE out which will be intercepted by the ScrollHelper | |
1681 | // which will cause the scrollbars to be displayed via the SetScrollbar | |
1682 | // call in CWindow. | |
1683 | // | |
4a46a5df DW |
1684 | if ( IsKindOf(CLASSINFO(wxGenericScrolledWindow)) || |
1685 | IsKindOf(CLASSINFO(wxScrolledWindow)) | |
859e65de DW |
1686 | ) |
1687 | { | |
1688 | int nAdjustWidth = 0; | |
1689 | int nAdjustHeight = 0; | |
1690 | SWP vSwpScroll; | |
1691 | ||
524d72c4 DW |
1692 | if (GetScrollBarHorz() == NULLHANDLE || |
1693 | !WinIsWindowShowing(GetScrollBarHorz())) | |
1694 | nAdjustHeight = 0L; | |
1695 | else | |
859e65de | 1696 | nAdjustHeight = 20L; |
524d72c4 DW |
1697 | if (GetScrollBarVert() == NULLHANDLE || |
1698 | !WinIsWindowShowing(GetScrollBarVert())) | |
1699 | nAdjustWidth = 0L; | |
1700 | else | |
859e65de DW |
1701 | nAdjustWidth = 20L; |
1702 | ::WinQueryWindowPos(GetHWND(), &vSwpScroll); | |
1703 | ::WinSetWindowPos( GetHWND() | |
1704 | ,HWND_TOP | |
1705 | ,vSwpScroll.x | |
1706 | ,vSwpScroll.y + nAdjustHeight | |
1707 | ,vSwpScroll.cx - nAdjustWidth | |
1708 | ,vSwpScroll.cy - nAdjustHeight | |
1709 | ,SWP_MOVE | SWP_SIZE | |
1710 | ); | |
524d72c4 | 1711 | nYDiff += nAdjustHeight; |
859e65de DW |
1712 | } |
1713 | MoveChildren(nYDiff); | |
1714 | ::WinQueryWindowPos(GetHwnd(), &m_vWinSwp); | |
1715 | } | |
0367c1c0 | 1716 | } // end of wxWindowOS2::DoMoveWindow |
cdf1e714 | 1717 | |
c86c44a0 DW |
1718 | // |
1719 | // Set the size of the window: if the dimensions are positive, just use them, | |
cdf1e714 DW |
1720 | // but if any of them is equal to -1, it means that we must find the value for |
1721 | // it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in | |
1722 | // which case -1 is a valid value for x and y) | |
1723 | // | |
1724 | // If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate | |
1725 | // the width/height to best suit our contents, otherwise we reuse the current | |
1726 | // width/height | |
c86c44a0 | 1727 | // |
0367c1c0 | 1728 | void wxWindowOS2::DoSetSize( |
a7ef993c DW |
1729 | int nX |
1730 | , int nY | |
1731 | , int nWidth | |
1732 | , int nHeight | |
1733 | , int nSizeFlags | |
1734 | ) | |
cdf1e714 | 1735 | { |
a7ef993c DW |
1736 | // |
1737 | // Get the current size and position... | |
1738 | // | |
1739 | int nCurrentX; | |
1740 | int nCurrentY; | |
1741 | int nCurrentWidth; | |
1742 | int nCurrentHeight; | |
542875a8 | 1743 | wxSize vSize(-1, -1); |
a7ef993c | 1744 | |
19193a2c KB |
1745 | GetPosition(&nCurrentX, &nCurrentY); |
1746 | GetSize(&nCurrentWidth, &nCurrentHeight); | |
c86c44a0 | 1747 | |
5d44b24e | 1748 | // |
c86c44a0 | 1749 | // ... and don't do anything (avoiding flicker) if it's already ok |
5d44b24e DW |
1750 | // |
1751 | // | |
1752 | // Must convert Y coords to test for equality under OS/2 | |
1753 | // | |
1754 | int nY2 = nY; | |
1755 | wxWindow* pParent = (wxWindow*)GetParent(); | |
1756 | ||
5d44b24e | 1757 | if (nX == nCurrentX && nY2 == nCurrentY && |
19193a2c | 1758 | nWidth == nCurrentWidth && nHeight == nCurrentHeight) |
c86c44a0 DW |
1759 | { |
1760 | return; | |
1761 | } | |
1762 | ||
a7ef993c DW |
1763 | if (nX == -1 && !(nSizeFlags & wxSIZE_ALLOW_MINUS_ONE)) |
1764 | nX = nCurrentX; | |
542875a8 | 1765 | if (nY == -1 && !(nSizeFlags & wxSIZE_ALLOW_MINUS_ONE)) |
a7ef993c | 1766 | nY = nCurrentY; |
c86c44a0 | 1767 | |
19193a2c | 1768 | AdjustForParentClientOrigin(nX, nY, nSizeFlags); |
c86c44a0 | 1769 | |
a7ef993c | 1770 | if (nWidth == -1) |
c86c44a0 | 1771 | { |
a7ef993c | 1772 | if (nSizeFlags & wxSIZE_AUTO_WIDTH) |
c86c44a0 | 1773 | { |
a7ef993c DW |
1774 | vSize = DoGetBestSize(); |
1775 | nWidth = vSize.x; | |
c86c44a0 DW |
1776 | } |
1777 | else | |
1778 | { | |
a7ef993c DW |
1779 | // |
1780 | // Just take the current one | |
1781 | // | |
1782 | nWidth = nCurrentWidth; | |
c86c44a0 DW |
1783 | } |
1784 | } | |
1785 | ||
a7ef993c | 1786 | if (nHeight == -1) |
c86c44a0 | 1787 | { |
a7ef993c | 1788 | if (nSizeFlags & wxSIZE_AUTO_HEIGHT) |
c86c44a0 | 1789 | { |
a7ef993c | 1790 | if (vSize.x == -1) |
c86c44a0 | 1791 | { |
a7ef993c | 1792 | vSize = DoGetBestSize(); |
c86c44a0 | 1793 | } |
a7ef993c | 1794 | nHeight = vSize.y; |
c86c44a0 DW |
1795 | } |
1796 | else | |
1797 | { | |
1798 | // just take the current one | |
a7ef993c | 1799 | nHeight = nCurrentHeight; |
c86c44a0 DW |
1800 | } |
1801 | } | |
1802 | ||
a7ef993c DW |
1803 | DoMoveWindow( nX |
1804 | ,nY | |
1805 | ,nWidth | |
1806 | ,nHeight | |
1807 | ); | |
0367c1c0 | 1808 | } // end of wxWindowOS2::DoSetSize |
cdf1e714 | 1809 | |
0367c1c0 | 1810 | void wxWindowOS2::DoSetClientSize( |
a7ef993c DW |
1811 | int nWidth |
1812 | , int nHeight | |
1813 | ) | |
cdf1e714 | 1814 | { |
8330166c | 1815 | POINTL vPoint; |
b720b24d DW |
1816 | int nActualWidth; |
1817 | int nActualHeight; | |
1818 | wxWindow* pParent = (wxWindow*)GetParent(); | |
1819 | HWND hParentWnd = (HWND)0; | |
c86c44a0 | 1820 | |
b720b24d DW |
1821 | if (pParent) |
1822 | hParentWnd = (HWND)pParent->GetHWND(); | |
8330166c | 1823 | |
b720b24d DW |
1824 | if (IsKindOf(CLASSINFO(wxFrame))) |
1825 | { | |
1826 | wxFrame* pFrame = wxDynamicCast(this, wxFrame); | |
1827 | HWND hFrame = pFrame->GetFrame(); | |
1828 | RECTL vRect; | |
1829 | RECTL vRect2; | |
1830 | RECTL vRect3; | |
c86c44a0 | 1831 | |
b720b24d DW |
1832 | ::WinQueryWindowRect(GetHwnd(), &vRect2); |
1833 | ::WinQueryWindowRect(hFrame, &vRect); | |
1834 | ::WinQueryWindowRect(hParentWnd, &vRect3); | |
1835 | nActualWidth = vRect2.xRight - vRect2.xLeft - vRect.xRight + nWidth; | |
1836 | nActualHeight = vRect2.yTop - vRect2.yBottom - vRect.yTop + nHeight; | |
1837 | ||
1838 | vPoint.x = vRect2.xLeft; | |
1839 | vPoint.y = vRect2.yBottom; | |
1840 | if (pParent) | |
1841 | { | |
1842 | vPoint.x -= vRect3.xLeft; | |
1843 | vPoint.y -= vRect3.yBottom; | |
1844 | } | |
1845 | } | |
1846 | else | |
8330166c | 1847 | { |
b720b24d DW |
1848 | int nX; |
1849 | int nY; | |
1850 | ||
1851 | GetPosition(&nX, &nY); | |
1852 | nActualWidth = nWidth; | |
1853 | nActualHeight = nHeight; | |
1854 | ||
1855 | vPoint.x = nX; | |
1856 | vPoint.y = nY; | |
c86c44a0 | 1857 | } |
b720b24d DW |
1858 | DoMoveWindow( vPoint.x |
1859 | ,vPoint.y | |
1860 | ,nActualWidth | |
1861 | ,nActualHeight | |
1862 | ); | |
19193a2c | 1863 | |
b720b24d DW |
1864 | wxSizeEvent vEvent( wxSize( nWidth |
1865 | ,nHeight | |
1866 | ) | |
1867 | ,m_windowId | |
1868 | ); | |
19193a2c | 1869 | |
a7ef993c DW |
1870 | vEvent.SetEventObject(this); |
1871 | GetEventHandler()->ProcessEvent(vEvent); | |
0367c1c0 | 1872 | } // end of wxWindowOS2::DoSetClientSize |
cdf1e714 | 1873 | |
0367c1c0 | 1874 | wxPoint wxWindowOS2::GetClientAreaOrigin() const |
cdf1e714 DW |
1875 | { |
1876 | return wxPoint(0, 0); | |
0367c1c0 | 1877 | } // end of wxWindowOS2::GetClientAreaOrigin |
cdf1e714 | 1878 | |
cdf1e714 DW |
1879 | // --------------------------------------------------------------------------- |
1880 | // text metrics | |
1881 | // --------------------------------------------------------------------------- | |
1882 | ||
0367c1c0 | 1883 | int wxWindowOS2::GetCharHeight() const |
cdf1e714 | 1884 | { |
a7ef993c DW |
1885 | HPS hPs; |
1886 | FONTMETRICS vFontMetrics; | |
cdf1e714 | 1887 | |
a7ef993c DW |
1888 | hPs = ::WinGetPS(GetHwnd()); |
1889 | ||
542875a8 | 1890 | if(!GpiQueryFontMetrics(hPs, sizeof(FONTMETRICS), &vFontMetrics)) |
b7084589 DW |
1891 | { |
1892 | ::WinReleasePS(hPs); | |
a7ef993c | 1893 | return (0); |
b7084589 | 1894 | } |
a7ef993c | 1895 | ::WinReleasePS(hPs); |
b7084589 | 1896 | return(vFontMetrics.lMaxAscender + vFontMetrics.lMaxDescender); |
0367c1c0 | 1897 | } // end of wxWindowOS2::GetCharHeight |
a7ef993c | 1898 | |
0367c1c0 | 1899 | int wxWindowOS2::GetCharWidth() const |
cdf1e714 | 1900 | { |
542875a8 DW |
1901 | HPS hPs; |
1902 | FONTMETRICS vFontMetrics; | |
1903 | ||
a7ef993c | 1904 | hPs = ::WinGetPS(GetHwnd()); |
cdf1e714 | 1905 | |
542875a8 | 1906 | if(!GpiQueryFontMetrics(hPs, sizeof(FONTMETRICS), &vFontMetrics)) |
b7084589 DW |
1907 | { |
1908 | ::WinReleasePS(hPs); | |
a7ef993c | 1909 | return (0); |
b7084589 | 1910 | } |
a7ef993c | 1911 | ::WinReleasePS(hPs); |
b7084589 | 1912 | return(vFontMetrics.lAveCharWidth); |
0367c1c0 | 1913 | } // end of wxWindowOS2::GetCharWidth |
a7ef993c | 1914 | |
0367c1c0 | 1915 | void wxWindowOS2::GetTextExtent( |
a7ef993c DW |
1916 | const wxString& rString |
1917 | , int* pX | |
1918 | , int* pY | |
1919 | , int* pDescent | |
1920 | , int* pExternalLeading | |
1921 | , const wxFont* pTheFont | |
1922 | ) const | |
cdf1e714 | 1923 | { |
987da0d4 DW |
1924 | POINTL avPoint[TXTBOX_COUNT]; |
1925 | POINTL vPtMin; | |
1926 | POINTL vPtMax; | |
1927 | int i; | |
1928 | int l; | |
1929 | FONTMETRICS vFM; // metrics structure | |
1930 | BOOL bRc; | |
1931 | char* pStr; | |
1932 | ERRORID vErrorCode; // last error id code | |
1933 | HPS hPS; | |
19193a2c | 1934 | |
a7ef993c | 1935 | |
987da0d4 | 1936 | hPS = ::WinGetPS(GetHwnd()); |
a7ef993c | 1937 | |
987da0d4 DW |
1938 | l = rString.Length(); |
1939 | if (l > 0L) | |
1940 | { | |
1941 | pStr = (PCH)rString.c_str(); | |
a7ef993c | 1942 | |
987da0d4 DW |
1943 | // |
1944 | // In world coordinates. | |
1945 | // | |
1946 | bRc = ::GpiQueryTextBox( hPS | |
1947 | ,l | |
1948 | ,pStr | |
1949 | ,TXTBOX_COUNT // return maximum information | |
1950 | ,avPoint // array of coordinates points | |
1951 | ); | |
1952 | if (bRc) | |
1953 | { | |
1954 | vPtMin.x = avPoint[0].x; | |
1955 | vPtMax.x = avPoint[0].x; | |
1956 | vPtMin.y = avPoint[0].y; | |
1957 | vPtMax.y = avPoint[0].y; | |
1958 | for (i = 1; i < 4; i++) | |
1959 | { | |
1960 | if(vPtMin.x > avPoint[i].x) vPtMin.x = avPoint[i].x; | |
1961 | if(vPtMin.y > avPoint[i].y) vPtMin.y = avPoint[i].y; | |
1962 | if(vPtMax.x < avPoint[i].x) vPtMax.x = avPoint[i].x; | |
1963 | if(vPtMax.y < avPoint[i].y) vPtMax.y = avPoint[i].y; | |
1964 | } | |
1965 | bRc = ::GpiQueryFontMetrics( hPS | |
1966 | ,sizeof(FONTMETRICS) | |
1967 | ,&vFM | |
1968 | ); | |
1969 | if (!bRc) | |
1970 | { | |
1971 | vPtMin.x = 0; | |
1972 | vPtMin.y = 0; | |
1973 | vPtMax.x = 0; | |
1974 | vPtMax.y = 0; | |
1975 | } | |
1976 | } | |
1977 | else | |
1978 | { | |
1979 | vPtMin.x = 0; | |
1980 | vPtMin.y = 0; | |
1981 | vPtMax.x = 0; | |
1982 | vPtMax.y = 0; | |
1983 | } | |
1984 | } | |
1985 | else | |
a7ef993c | 1986 | { |
987da0d4 DW |
1987 | vPtMin.x = 0; |
1988 | vPtMin.y = 0; | |
1989 | vPtMax.x = 0; | |
1990 | vPtMax.y = 0; | |
a7ef993c | 1991 | } |
987da0d4 DW |
1992 | if (pX) |
1993 | *pX = (vPtMax.x - vPtMin.x + 1); | |
1994 | if (pY) | |
1995 | *pY = (vPtMax.y - vPtMin.y + 1); | |
1996 | if (pDescent) | |
1997 | { | |
1998 | if (bRc) | |
1999 | *pDescent = vFM.lMaxDescender; | |
2000 | else | |
2001 | *pDescent = 0; | |
2002 | } | |
2003 | if (pExternalLeading) | |
2004 | { | |
2005 | if (bRc) | |
2006 | *pExternalLeading = vFM.lExternalLeading; | |
2007 | else | |
2008 | *pExternalLeading = 0; | |
2009 | } | |
2010 | ::WinReleasePS(hPS); | |
2011 | } // end of wxWindow::GetTextExtent | |
cdf1e714 | 2012 | |
f9efbe3a DW |
2013 | bool wxWindowOS2::IsMouseInWindow() const |
2014 | { | |
2015 | // | |
2016 | // Get the mouse position | |
2017 | POINTL vPt; | |
2018 | ||
2019 | ::WinQueryPointerPos(HWND_DESKTOP, &vPt); | |
2020 | ||
2021 | // | |
2022 | // Find the window which currently has the cursor and go up the window | |
2023 | // chain until we find this window - or exhaust it | |
2024 | // | |
2025 | HWND hWnd = ::WinWindowFromPoint(HWND_DESKTOP, &vPt, TRUE); | |
2026 | ||
2027 | while (hWnd && (hWnd != GetHwnd())) | |
2028 | hWnd = ::WinQueryWindow(hWnd, QW_PARENT); | |
2029 | ||
2030 | return hWnd != NULL; | |
2031 | } // end of wxWindowOS2::IsMouseInWindow | |
2032 | ||
cdf1e714 DW |
2033 | |
2034 | // --------------------------------------------------------------------------- | |
2035 | // popup menu | |
2036 | // --------------------------------------------------------------------------- | |
19193a2c KB |
2037 | // |
2038 | #if wxUSE_MENUS_NATIVE | |
3febf684 DW |
2039 | static void wxYieldForCommandsOnly() |
2040 | { | |
2041 | // | |
2042 | // Peek all WM_COMMANDs (it will always return WM_QUIT too but we don't | |
2043 | // want to process it here) | |
2044 | // | |
2045 | QMSG vMsg; | |
2046 | ||
239c2e96 DW |
2047 | while (::WinPeekMsg(vHabmain, &vMsg, (HWND)0, WM_COMMAND, WM_COMMAND, PM_REMOVE) |
2048 | && vMsg.msg != WM_QUIT) | |
3febf684 DW |
2049 | { |
2050 | wxTheApp->DoMessage((WXMSG*)&vMsg); | |
2051 | } | |
57ff8a87 DW |
2052 | if (vMsg.msg == WM_QUIT) |
2053 | ::WinPostMsg(NULL, WM_QUIT, 0, 0); | |
3febf684 | 2054 | } |
19193a2c | 2055 | #endif // wxUSE_MENUS_NATIVE |
3febf684 | 2056 | |
19193a2c | 2057 | #if wxUSE_MENUS_NATIVE |
0367c1c0 | 2058 | bool wxWindowOS2::DoPopupMenu( |
61243a51 DW |
2059 | wxMenu* pMenu |
2060 | , int nX | |
2061 | , int nY | |
2062 | ) | |
cdf1e714 | 2063 | { |
239c2e96 DW |
2064 | HWND hWndOwner = GetHwnd(); |
2065 | HWND hWndParent = GetHwnd(); | |
61243a51 | 2066 | HWND hMenu = GetHmenuOf(pMenu); |
239c2e96 | 2067 | bool bIsWaiting = TRUE; |
61243a51 DW |
2068 | |
2069 | pMenu->SetInvokingWindow(this); | |
2070 | pMenu->UpdateUI(); | |
2071 | ||
2072 | DoClientToScreen( &nX | |
2073 | ,&nY | |
2074 | ); | |
2075 | wxCurrentPopupMenu = pMenu; | |
2076 | ||
2077 | ::WinPopupMenu( hWndParent | |
239c2e96 | 2078 | ,hWndOwner |
61243a51 DW |
2079 | ,hMenu |
2080 | ,nX | |
2081 | ,nY | |
2082 | ,0L | |
bdfd8d77 | 2083 | ,PU_HCONSTRAIN | PU_VCONSTRAIN | PU_MOUSEBUTTON1 | PU_KEYBOARD |
61243a51 | 2084 | ); |
bdfd8d77 | 2085 | |
239c2e96 DW |
2086 | while(bIsWaiting) |
2087 | { | |
bdfd8d77 DW |
2088 | QMSG vMsg; |
2089 | BOOL bRc = ::WinGetMsg(vHabmain, &vMsg, HWND(NULL), 0, 0); | |
239c2e96 | 2090 | |
bdfd8d77 | 2091 | if (vMsg.msg == WM_MENUEND || vMsg.msg == WM_COMMAND) |
239c2e96 | 2092 | { |
bdfd8d77 | 2093 | bIsWaiting = FALSE; |
239c2e96 | 2094 | } |
bdfd8d77 DW |
2095 | ::WinDispatchMsg(vHabmain, (PQMSG)&vMsg); |
2096 | ||
239c2e96 | 2097 | } |
61243a51 | 2098 | wxCurrentPopupMenu = NULL; |
61243a51 DW |
2099 | pMenu->SetInvokingWindow(NULL); |
2100 | return TRUE; | |
0367c1c0 | 2101 | } // end of wxWindowOS2::DoPopupMenu |
19193a2c | 2102 | #endif // wxUSE_MENUS_NATIVE |
cdf1e714 DW |
2103 | |
2104 | // =========================================================================== | |
2105 | // pre/post message processing | |
2106 | // =========================================================================== | |
2107 | ||
0367c1c0 | 2108 | MRESULT wxWindowOS2::OS2DefWindowProc( |
61243a51 DW |
2109 | WXUINT uMsg |
2110 | , WXWPARAM wParam | |
2111 | , WXLPARAM lParam | |
2112 | ) | |
cdf1e714 | 2113 | { |
61243a51 | 2114 | if (m_fnOldWndProc) |
19193a2c | 2115 | return (MRESULT)m_fnOldWndProc(GetHWND(), uMsg, (MPARAM)wParam, (MPARAM)lParam); |
61243a51 | 2116 | else |
19193a2c | 2117 | return ::WinDefWindowProc(GetHWND(), uMsg, (MPARAM)wParam, (MPARAM)lParam); |
0367c1c0 | 2118 | } // end of wxWindowOS2::OS2DefWindowProc |
cdf1e714 | 2119 | |
0367c1c0 | 2120 | bool wxWindowOS2::OS2ProcessMessage( |
61243a51 DW |
2121 | WXMSG* pMsg |
2122 | ) | |
cdf1e714 | 2123 | { |
19193a2c KB |
2124 | // wxUniversal implements tab traversal itself |
2125 | #ifndef __WXUNIVERSAL__ | |
61243a51 DW |
2126 | QMSG* pQMsg = (QMSG*)pMsg; |
2127 | ||
2128 | if (m_hWnd != 0 && (GetWindowStyleFlag() & wxTAB_TRAVERSAL)) | |
2129 | { | |
2130 | // | |
2131 | // Intercept dialog navigation keys | |
2132 | // | |
2133 | bool bProcess = TRUE; | |
2134 | USHORT uKeyFlags = SHORT1FROMMP(pQMsg->mp1); | |
2135 | ||
2136 | if (uKeyFlags & KC_KEYUP) | |
2137 | bProcess = FALSE; | |
2138 | ||
2139 | if (uKeyFlags & KC_ALT) | |
2140 | bProcess = FALSE; | |
2141 | ||
2142 | if (!(uKeyFlags & KC_VIRTUALKEY)) | |
2143 | bProcess = FALSE; | |
2144 | ||
2145 | if (bProcess) | |
2146 | { | |
2147 | bool bCtrlDown = IsCtrlDown(); | |
2148 | bool bShiftDown = IsShiftDown(); | |
2149 | ||
2150 | // | |
2151 | // WM_QUERYDLGCODE: ask the control if it wants the key for itself, | |
2152 | // don't process it if it's the case (except for Ctrl-Tab/Enter | |
2153 | // combinations which are always processed) | |
2154 | // | |
2155 | ULONG ulDlgCode = 0; | |
2156 | ||
2157 | if (!bCtrlDown) | |
2158 | { | |
2159 | ulDlgCode = (ULONG)::WinSendMsg(pQMsg->hwnd, WM_QUERYDLGCODE, pQMsg, 0); | |
2160 | } | |
2161 | ||
2162 | bool bForward = TRUE; | |
2163 | bool bWindowChange = FALSE; | |
2164 | ||
2165 | switch (SHORT2FROMMP(pQMsg->mp2)) | |
2166 | { | |
2167 | // | |
2168 | // Going to make certain assumptions about specific types of controls | |
2169 | // here, so we may have to alter some things later if they prove invalid | |
2170 | // | |
2171 | case VK_TAB: | |
2172 | // | |
2173 | // Shift tabl will always be a nav-key but tabs may be wanted | |
2174 | // | |
2175 | if (!bShiftDown) | |
2176 | { | |
2177 | bProcess = FALSE; | |
2178 | } | |
2179 | else | |
2180 | { | |
2181 | // | |
2182 | // Entry Fields want tabs for themselve usually | |
2183 | // | |
2184 | switch (ulDlgCode) | |
2185 | { | |
2186 | case DLGC_ENTRYFIELD: | |
2187 | case DLGC_MLE: | |
2188 | bProcess = TRUE; | |
2189 | break; | |
2190 | ||
2191 | default: | |
2192 | bProcess = FALSE; | |
2193 | } | |
2194 | ||
2195 | // | |
2196 | // Ctrl-Tab cycles thru notebook pages | |
2197 | // | |
2198 | bWindowChange = bCtrlDown; | |
2199 | bForward = !bShiftDown; | |
2200 | } | |
2201 | break; | |
2202 | ||
2203 | case VK_UP: | |
2204 | case VK_LEFT: | |
2205 | if (bCtrlDown) | |
2206 | bProcess = FALSE; | |
2207 | else | |
2208 | bForward = FALSE; | |
2209 | break; | |
2210 | ||
2211 | case VK_DOWN: | |
2212 | case VK_RIGHT: | |
2213 | if (bCtrlDown) | |
2214 | bProcess = FALSE; | |
2215 | break; | |
2216 | ||
2217 | case VK_ENTER: | |
2218 | { | |
2219 | if (bCtrlDown) | |
2220 | { | |
2221 | // | |
2222 | // ctrl-enter is not processed | |
2223 | // | |
2224 | return FALSE; | |
2225 | } | |
2226 | else if (ulDlgCode & DLGC_BUTTON) | |
2227 | { | |
2228 | // | |
2229 | // buttons want process Enter themselevs | |
2230 | // | |
2231 | bProcess = FALSE; | |
2232 | } | |
2233 | else | |
2234 | { | |
1bcfc0e1 DW |
2235 | wxButton* pBtn = wxDynamicCast( GetDefaultItem() |
2236 | ,wxButton | |
2237 | ); | |
61243a51 DW |
2238 | |
2239 | if (pBtn && pBtn->IsEnabled()) | |
2240 | { | |
2241 | // | |
2242 | // If we do have a default button, do press it | |
2243 | // | |
2244 | pBtn->OS2Command(BN_CLICKED, 0 /* unused */); | |
2245 | return TRUE; | |
2246 | } | |
2b5f62a0 VZ |
2247 | else if (!IsTopLevel()) |
2248 | { | |
2249 | // | |
2250 | // if not a top level window, let parent | |
2251 | // handle it | |
2252 | // | |
2253 | return FALSE; | |
2254 | } | |
61243a51 DW |
2255 | // else: but if it does not it makes sense to make |
2256 | // it work like a TAB - and that's what we do. | |
2257 | // Note that Ctrl-Enter always works this way. | |
2258 | } | |
2259 | } | |
2260 | break; | |
2261 | ||
2262 | default: | |
2263 | bProcess = FALSE; | |
2264 | } | |
2265 | ||
2266 | if (bProcess) | |
2267 | { | |
2268 | wxNavigationKeyEvent vEvent; | |
2269 | ||
2270 | vEvent.SetDirection(bForward); | |
2271 | vEvent.SetWindowChange(bWindowChange); | |
2272 | vEvent.SetEventObject(this); | |
2273 | ||
2274 | if (GetEventHandler()->ProcessEvent(vEvent)) | |
2275 | { | |
2276 | wxButton* pBtn = wxDynamicCast(FindFocus(), wxButton); | |
2277 | ||
2278 | if (pBtn) | |
2279 | { | |
2280 | // | |
2281 | // The button which has focus should be default | |
2282 | // | |
2283 | pBtn->SetDefault(); | |
2284 | } | |
2285 | return TRUE; | |
2286 | } | |
2287 | } | |
2288 | } | |
dae16775 DW |
2289 | // |
2290 | // Let Dialogs process | |
2291 | // | |
2292 | if (::WinSendMsg(pQMsg->hwnd, WM_QUERYDLGCODE, pQMsg, 0)); | |
2293 | return TRUE; | |
61243a51 | 2294 | } |
19193a2c KB |
2295 | #else |
2296 | pMsg = pMsg; // just shut up the compiler | |
2297 | #endif // __WXUNIVERSAL__ | |
61243a51 | 2298 | |
cdf1e714 | 2299 | return FALSE; |
0367c1c0 | 2300 | } // end of wxWindowOS2::OS2ProcessMessage |
cdf1e714 | 2301 | |
0367c1c0 | 2302 | bool wxWindowOS2::OS2TranslateMessage( |
61243a51 DW |
2303 | WXMSG* pMsg |
2304 | ) | |
cdf1e714 | 2305 | { |
19193a2c | 2306 | #if wxUSE_ACCEL && !defined(__WXUNIVERSAL__) |
7e99520b DW |
2307 | return m_acceleratorTable.Translate(m_hWnd, pMsg); |
2308 | #else | |
19193a2c | 2309 | pMsg = pMsg; |
7e99520b DW |
2310 | return FALSE; |
2311 | #endif //wxUSE_ACCEL | |
0367c1c0 | 2312 | } // end of wxWindowOS2::OS2TranslateMessage |
cdf1e714 | 2313 | |
54ffa107 DW |
2314 | bool wxWindowOS2::OS2ShouldPreProcessMessage( |
2315 | WXMSG* pMsg | |
2316 | ) | |
2317 | { | |
2318 | // preprocess all messages by default | |
2319 | return TRUE; | |
2320 | } // end of wxWindowOS2::OS2ShouldPreProcessMessage | |
2321 | ||
cdf1e714 | 2322 | // --------------------------------------------------------------------------- |
61243a51 | 2323 | // message params unpackers |
cdf1e714 DW |
2324 | // --------------------------------------------------------------------------- |
2325 | ||
0367c1c0 | 2326 | void wxWindowOS2::UnpackCommand( |
61243a51 DW |
2327 | WXWPARAM wParam |
2328 | , WXLPARAM lParam | |
2329 | , WORD* pId | |
2330 | , WXHWND* phWnd | |
2331 | , WORD* pCmd | |
2332 | ) | |
cdf1e714 | 2333 | { |
5b3ed311 DW |
2334 | *pId = LOWORD(wParam); |
2335 | *phWnd = NULL; // or may be GetHWND() ? | |
2336 | *pCmd = LOWORD(lParam); | |
0367c1c0 | 2337 | } // end of wxWindowOS2::UnpackCommand |
cdf1e714 | 2338 | |
0367c1c0 | 2339 | void wxWindowOS2::UnpackActivate( |
61243a51 DW |
2340 | WXWPARAM wParam |
2341 | , WXLPARAM lParam | |
2342 | , WXWORD* pState | |
2343 | , WXHWND* phWnd | |
2344 | ) | |
cdf1e714 | 2345 | { |
61243a51 DW |
2346 | *pState = LOWORD(wParam); |
2347 | *phWnd = (WXHWND)lParam; | |
0367c1c0 | 2348 | } // end of wxWindowOS2::UnpackActivate |
cdf1e714 | 2349 | |
0367c1c0 | 2350 | void wxWindowOS2::UnpackScroll( |
61243a51 DW |
2351 | WXWPARAM wParam |
2352 | , WXLPARAM lParam | |
2353 | , WXWORD* pCode | |
2354 | , WXWORD* pPos | |
2355 | , WXHWND* phWnd | |
2356 | ) | |
cdf1e714 | 2357 | { |
b7d8f285 DW |
2358 | ULONG ulId; |
2359 | HWND hWnd; | |
2360 | ||
2361 | ulId = (ULONG)LONGFROMMP(wParam); | |
2362 | hWnd = ::WinWindowFromID(GetHwnd(), ulId); | |
2363 | if (hWnd == m_hWndScrollBarHorz || hWnd == m_hWndScrollBarVert) | |
2364 | *phWnd = NULLHANDLE; | |
2365 | else | |
2366 | *phWnd = hWnd; | |
2367 | ||
2368 | *pPos = SHORT1FROMMP(lParam); | |
2369 | *pCode = SHORT2FROMMP(lParam); | |
0367c1c0 | 2370 | } // end of wxWindowOS2::UnpackScroll |
61243a51 | 2371 | |
0367c1c0 | 2372 | void wxWindowOS2::UnpackMenuSelect( |
61243a51 DW |
2373 | WXWPARAM wParam |
2374 | , WXLPARAM lParam | |
2375 | , WXWORD* pItem | |
2376 | , WXWORD* pFlags | |
2377 | , WXHMENU* phMenu | |
2378 | ) | |
cdf1e714 | 2379 | { |
61243a51 DW |
2380 | *pItem = (WXWORD)LOWORD(wParam); |
2381 | *pFlags = HIWORD(wParam); | |
2382 | *phMenu = (WXHMENU)lParam; | |
0367c1c0 | 2383 | } // end of wxWindowOS2::UnpackMenuSelect |
cdf1e714 DW |
2384 | |
2385 | // --------------------------------------------------------------------------- | |
2386 | // Main wxWindows window proc and the window proc for wxWindow | |
2387 | // --------------------------------------------------------------------------- | |
2388 | ||
61243a51 | 2389 | // |
cdf1e714 DW |
2390 | // Hook for new window just as it's being created, when the window isn't yet |
2391 | // associated with the handle | |
61243a51 | 2392 | // |
19193a2c | 2393 | wxWindowOS2* wxWndHook = NULL; |
cdf1e714 | 2394 | |
61243a51 | 2395 | // |
cdf1e714 | 2396 | // Main window proc |
61243a51 | 2397 | // |
f23208ca | 2398 | MRESULT EXPENTRY wxWndProc( |
61243a51 DW |
2399 | HWND hWnd |
2400 | , ULONG ulMsg | |
2401 | , MPARAM wParam | |
2402 | , MPARAM lParam | |
2403 | ) | |
cdf1e714 | 2404 | { |
61243a51 DW |
2405 | // |
2406 | // Trace all ulMsgs - useful for the debugging | |
2407 | // | |
cdf1e714 DW |
2408 | #ifdef __WXDEBUG__ |
2409 | wxLogTrace(wxTraceMessages, wxT("Processing %s(wParam=%8lx, lParam=%8lx)"), | |
61243a51 | 2410 | wxGetMessageName(ulMsg), wParam, lParam); |
cdf1e714 DW |
2411 | #endif // __WXDEBUG__ |
2412 | ||
19193a2c | 2413 | wxWindowOS2* pWnd = wxFindWinFromHandle((WXHWND)hWnd); |
cdf1e714 | 2414 | |
61243a51 DW |
2415 | // |
2416 | // When we get the first message for the HWND we just created, we associate | |
cdf1e714 | 2417 | // it with wxWindow stored in wxWndHook |
61243a51 DW |
2418 | // |
2419 | if (!pWnd && wxWndHook) | |
cdf1e714 | 2420 | { |
cdf1e714 | 2421 | wxAssociateWinWithHandle(hWnd, wxWndHook); |
61243a51 | 2422 | pWnd = wxWndHook; |
cdf1e714 | 2423 | wxWndHook = NULL; |
61243a51 | 2424 | pWnd->SetHWND((WXHWND)hWnd); |
cdf1e714 DW |
2425 | } |
2426 | ||
5b3ed311 | 2427 | MRESULT rc = (MRESULT)0; |
e604d44b | 2428 | |
cdf1e714 | 2429 | |
61243a51 | 2430 | // |
cdf1e714 | 2431 | // Stop right here if we don't have a valid handle in our wxWindow object. |
61243a51 DW |
2432 | // |
2433 | if (pWnd && !pWnd->GetHWND()) | |
cdf1e714 | 2434 | { |
61243a51 DW |
2435 | pWnd->SetHWND((WXHWND) hWnd); |
2436 | rc = pWnd->OS2DefWindowProc(ulMsg, wParam, lParam ); | |
2437 | pWnd->SetHWND(0); | |
cdf1e714 DW |
2438 | } |
2439 | else | |
2440 | { | |
61243a51 | 2441 | if (pWnd) |
45e0dc94 | 2442 | { |
61243a51 | 2443 | rc = pWnd->OS2WindowProc(ulMsg, wParam, lParam); |
45e0dc94 DW |
2444 | if ( (pWnd->GetScrollBarHorz() != NULLHANDLE || |
2445 | pWnd->GetScrollBarVert() != NULLHANDLE) && | |
2446 | ulMsg == WM_PAINT) | |
2447 | { | |
2448 | if (pWnd->GetScrollBarHorz() != NULLHANDLE) | |
2449 | ::WinInvalidateRect(pWnd->GetScrollBarHorz(), NULL, TRUE); | |
2450 | if (pWnd->GetScrollBarVert() != NULLHANDLE) | |
2451 | ::WinInvalidateRect(pWnd->GetScrollBarVert(), NULL, TRUE); | |
2452 | } | |
2453 | } | |
e604d44b | 2454 | else |
61243a51 | 2455 | rc = ::WinDefWindowProc(hWnd, ulMsg, wParam, lParam); |
cdf1e714 | 2456 | } |
5b3ed311 | 2457 | |
cdf1e714 | 2458 | return rc; |
61243a51 | 2459 | } // end of wxWndProc |
cdf1e714 | 2460 | |
61243a51 DW |
2461 | // |
2462 | // We will add (or delete) messages we need to handle at this default | |
2463 | // level as we go | |
2464 | // | |
0367c1c0 | 2465 | MRESULT wxWindowOS2::OS2WindowProc( |
61243a51 DW |
2466 | WXUINT uMsg |
2467 | , WXWPARAM wParam | |
2468 | , WXLPARAM lParam | |
2469 | ) | |
cdf1e714 | 2470 | { |
61243a51 DW |
2471 | // |
2472 | // Did we process the uMsg? | |
2473 | // | |
2474 | bool bProcessed = FALSE; | |
e604d44b | 2475 | MRESULT mResult; |
cdf1e714 | 2476 | |
61243a51 DW |
2477 | // |
2478 | // For most messages we should return 0 when we do process the message | |
2479 | // | |
e604d44b | 2480 | mResult = (MRESULT)0; |
61243a51 DW |
2481 | |
2482 | switch (uMsg) | |
cdf1e714 DW |
2483 | { |
2484 | case WM_CREATE: | |
2485 | { | |
61243a51 DW |
2486 | bool bMayCreate; |
2487 | ||
2488 | bProcessed = HandleCreate( (WXLPCREATESTRUCT)lParam | |
2489 | ,&bMayCreate | |
2490 | ); | |
2491 | if (bProcessed) | |
cdf1e714 | 2492 | { |
61243a51 DW |
2493 | // |
2494 | // Return 0 to bAllow window creation | |
2495 | // | |
e604d44b | 2496 | mResult = (MRESULT)(bMayCreate ? 0 : -1); |
cdf1e714 DW |
2497 | } |
2498 | } | |
2499 | break; | |
2500 | ||
2501 | case WM_DESTROY: | |
e604d44b DW |
2502 | HandleDestroy(); |
2503 | bProcessed = TRUE; | |
e604d44b | 2504 | break; |
cdf1e714 DW |
2505 | |
2506 | case WM_MOVE: | |
61243a51 DW |
2507 | bProcessed = HandleMove( LOWORD(lParam) |
2508 | ,HIWORD(lParam) | |
2509 | ); | |
cdf1e714 DW |
2510 | break; |
2511 | ||
2512 | case WM_SIZE: | |
61243a51 DW |
2513 | bProcessed = HandleSize( LOWORD(lParam) |
2514 | ,HIWORD(lParam) | |
2515 | ,(WXUINT)wParam | |
2516 | ); | |
cdf1e714 DW |
2517 | break; |
2518 | ||
e37db699 DW |
2519 | case WM_WINDOWPOSCHANGED: |
2520 | ||
2521 | // | |
2522 | // Dialogs under OS/2 do not get WM_SIZE events at all. | |
2523 | // Instead they get this, which can function much like WM_SIZE | |
2524 | // PSWP contains the new sizes and positioning, PSWP+1 the old | |
2525 | // We use this because ADJUSTWINDOWPOS comes BEFORE the new | |
2526 | // position is added and our auto layout does a WinQueryWindowRect | |
2527 | // to get the CURRENT client size. That is the size used to position | |
2528 | // child controls, so we need to already be sized | |
2529 | // in order to get the child controls positoned properly. | |
2530 | // | |
626af800 | 2531 | if (IsKindOf(CLASSINFO(wxDialog)) || IsKindOf(CLASSINFO(wxFrame))) |
e37db699 DW |
2532 | { |
2533 | PSWP pSwp = (PSWP)PVOIDFROMMP(wParam); | |
f3e4a2a4 DW |
2534 | PSWP pSwp2 = pSwp++; |
2535 | ||
2536 | if (!(pSwp->cx == pSwp2->cx && | |
2537 | pSwp->cy == pSwp2->cy)) | |
2538 | bProcessed = HandleSize( pSwp->cx | |
2539 | ,pSwp->cy | |
2540 | ,(WXUINT)lParam | |
2541 | ); | |
626af800 DW |
2542 | if (IsKindOf(CLASSINFO(wxFrame))) |
2543 | { | |
2544 | wxFrame* pFrame = wxDynamicCast(this, wxFrame); | |
2545 | ||
2546 | if (pFrame) | |
2547 | { | |
2548 | if (pFrame->GetStatusBar()) | |
2549 | pFrame->PositionStatusBar(); | |
2590f154 DW |
2550 | if (pFrame->GetToolBar()) |
2551 | pFrame->PositionToolBar(); | |
626af800 DW |
2552 | } |
2553 | } | |
e37db699 DW |
2554 | } |
2555 | break; | |
2556 | ||
cdf1e714 DW |
2557 | case WM_ACTIVATE: |
2558 | { | |
61243a51 DW |
2559 | WXWORD wState; |
2560 | WXHWND hWnd; | |
2561 | ||
2562 | UnpackActivate( wParam | |
2563 | ,lParam | |
2564 | ,&wState | |
2565 | ,&hWnd | |
2566 | ); | |
2567 | ||
2568 | bProcessed = HandleActivate( wState | |
2569 | ,(WXHWND)hWnd | |
2570 | ); | |
e604d44b | 2571 | bProcessed = FALSE; |
cdf1e714 DW |
2572 | } |
2573 | break; | |
2574 | ||
2575 | case WM_SETFOCUS: | |
61243a51 DW |
2576 | if (SHORT1FROMMP((MPARAM)lParam) == TRUE) |
2577 | bProcessed = HandleSetFocus((WXHWND)(HWND)wParam); | |
2578 | else | |
2579 | bProcessed = HandleKillFocus((WXHWND)(HWND)wParam); | |
cdf1e714 DW |
2580 | break; |
2581 | ||
2582 | case WM_PAINT: | |
61243a51 | 2583 | bProcessed = HandlePaint(); |
cdf1e714 DW |
2584 | break; |
2585 | ||
2586 | case WM_CLOSE: | |
61243a51 DW |
2587 | // |
2588 | // Don't let the DefWindowProc() destroy our window - we'll do it | |
cdf1e714 | 2589 | // ourselves in ~wxWindow |
61243a51 DW |
2590 | // |
2591 | bProcessed = TRUE; | |
e604d44b | 2592 | mResult = (MRESULT)TRUE; |
cdf1e714 DW |
2593 | break; |
2594 | ||
61243a51 DW |
2595 | case WM_SHOW: |
2596 | bProcessed = HandleShow(wParam != 0, (int)lParam); | |
cdf1e714 DW |
2597 | break; |
2598 | ||
61243a51 DW |
2599 | // |
2600 | // Under OS2 PM Joysticks are treated just like mouse events | |
2601 | // The "Motion" events will be prevelent in joysticks | |
2602 | // | |
cdf1e714 | 2603 | case WM_MOUSEMOVE: |
61243a51 DW |
2604 | case WM_BUTTON1DOWN: |
2605 | case WM_BUTTON1UP: | |
2606 | case WM_BUTTON1DBLCLK: | |
2607 | case WM_BUTTON1MOTIONEND: | |
2608 | case WM_BUTTON1MOTIONSTART: | |
2609 | case WM_BUTTON2DOWN: | |
2610 | case WM_BUTTON2UP: | |
2611 | case WM_BUTTON2DBLCLK: | |
2612 | case WM_BUTTON2MOTIONEND: | |
2613 | case WM_BUTTON2MOTIONSTART: | |
2614 | case WM_BUTTON3DOWN: | |
2615 | case WM_BUTTON3UP: | |
2616 | case WM_BUTTON3DBLCLK: | |
2617 | case WM_BUTTON3MOTIONEND: | |
2618 | case WM_BUTTON3MOTIONSTART: | |
cdf1e714 | 2619 | { |
430974f8 DW |
2620 | if (uMsg == WM_BUTTON1DOWN && AcceptsFocus()) |
2621 | SetFocus(); | |
2622 | ||
2623 | short nX = LOWORD(wParam); | |
2624 | short nY = HIWORD(wParam); | |
cdf1e714 | 2625 | |
430974f8 DW |
2626 | // |
2627 | // Redirect the event to a static control if necessary | |
2628 | // | |
2629 | if (this == GetCapture()) | |
2630 | { | |
2631 | bProcessed = HandleMouseEvent( uMsg | |
2632 | ,nX | |
2633 | ,nY | |
2634 | ,(WXUINT)SHORT1FROMMP(wParam) | |
2635 | ); | |
2636 | } | |
2637 | else | |
2638 | { | |
2639 | wxWindow* pWin = FindWindowForMouseEvent( this | |
2640 | ,&nX | |
2641 | ,&nY | |
2642 | ); | |
376ef4a1 DW |
2643 | if (!pWin->IsOfStandardClass()) |
2644 | { | |
2645 | if (uMsg == WM_BUTTON1DOWN && pWin->AcceptsFocus() ) | |
2646 | pWin->SetFocus(); | |
2647 | } | |
430974f8 DW |
2648 | bProcessed = pWin->HandleMouseEvent( uMsg |
2649 | ,nX | |
2650 | ,nY | |
2651 | ,(WXUINT)SHORT1FROMMP(wParam) | |
2652 | ); | |
2653 | } | |
cdf1e714 DW |
2654 | } |
2655 | break; | |
430974f8 | 2656 | |
cdf1e714 | 2657 | case WM_SYSCOMMAND: |
61243a51 | 2658 | bProcessed = HandleSysCommand(wParam, lParam); |
cdf1e714 DW |
2659 | break; |
2660 | ||
2661 | case WM_COMMAND: | |
2662 | { | |
2663 | WORD id, cmd; | |
2664 | WXHWND hwnd; | |
2665 | UnpackCommand(wParam, lParam, &id, &hwnd, &cmd); | |
2666 | ||
61243a51 | 2667 | bProcessed = HandleCommand(id, cmd, hwnd); |
cdf1e714 DW |
2668 | } |
2669 | break; | |
2670 | ||
61243a51 DW |
2671 | // |
2672 | // For these messages we must return TRUE if process the message | |
2673 | // | |
cdf1e714 DW |
2674 | case WM_DRAWITEM: |
2675 | case WM_MEASUREITEM: | |
2676 | { | |
45bedfdd | 2677 | int nIdCtrl = (UINT)wParam; |
45bedfdd | 2678 | |
61243a51 | 2679 | if ( uMsg == WM_DRAWITEM ) |
cdf1e714 | 2680 | { |
45bedfdd | 2681 | bProcessed = OS2OnDrawItem(nIdCtrl, |
cdf1e714 DW |
2682 | (WXDRAWITEMSTRUCT *)lParam); |
2683 | } | |
2684 | else | |
2685 | { | |
f5ea767e DW |
2686 | return MRFROMLONG(OS2OnMeasureItem( nIdCtrl |
2687 | ,(WXMEASUREITEMSTRUCT *)lParam | |
2688 | )); | |
cdf1e714 DW |
2689 | } |
2690 | ||
61243a51 | 2691 | if ( bProcessed ) |
e604d44b | 2692 | mResult = (MRESULT)TRUE; |
cdf1e714 DW |
2693 | } |
2694 | break; | |
2695 | ||
61243a51 | 2696 | case WM_QUERYDLGCODE: |
47df2b8c | 2697 | if (!IsOfStandardClass()) |
cdf1e714 | 2698 | { |
47df2b8c DW |
2699 | if ( m_lDlgCode ) |
2700 | { | |
2701 | mResult = (MRESULT)m_lDlgCode; | |
2702 | bProcessed = TRUE; | |
2703 | } | |
cdf1e714 | 2704 | } |
61243a51 | 2705 | // |
cdf1e714 | 2706 | //else: get the dlg code from the DefWindowProc() |
61243a51 | 2707 | // |
cdf1e714 DW |
2708 | break; |
2709 | ||
61243a51 DW |
2710 | // |
2711 | // In OS/2 PM all keyboard events are of the WM_CHAR type. Virtual key and key-up | |
2712 | // and key-down events are obtained from the WM_CHAR params. | |
2713 | // | |
2714 | case WM_CHAR: | |
cdf1e714 | 2715 | { |
61243a51 | 2716 | USHORT uKeyFlags = SHORT1FROMMP((MPARAM)wParam); |
cdf1e714 | 2717 | |
61243a51 DW |
2718 | if (uKeyFlags & KC_KEYUP) |
2719 | { | |
19193a2c | 2720 | //TODO: check if the cast to WXWORD isn't causing trouble |
a086de98 | 2721 | bProcessed = HandleKeyUp(wParam, lParam); |
cdf1e714 | 2722 | break; |
61243a51 DW |
2723 | } |
2724 | else // keydown event | |
2725 | { | |
3437f881 | 2726 | m_bLastKeydownProcessed = FALSE; |
61243a51 DW |
2727 | // |
2728 | // If this has been processed by an event handler, | |
2729 | // return 0 now (we've handled it). DON't RETURN | |
2730 | // we still need to process further | |
2731 | // | |
a086de98 | 2732 | m_bLastKeydownProcessed = HandleKeyDown(wParam, lParam); |
61243a51 | 2733 | if (uKeyFlags & KC_VIRTUALKEY) |
cdf1e714 | 2734 | { |
61243a51 DW |
2735 | USHORT uVk = SHORT2FROMMP((MPARAM)lParam); |
2736 | ||
2737 | // | |
2738 | // We consider these message "not interesting" to OnChar | |
2739 | // | |
61243a51 DW |
2740 | switch(uVk) |
2741 | { | |
a086de98 DW |
2742 | case VK_SHIFT: |
2743 | case VK_CTRL: | |
2744 | case VK_MENU: | |
2745 | case VK_CAPSLOCK: | |
2746 | case VK_NUMLOCK: | |
2747 | case VK_SCRLLOCK: | |
2748 | bProcessed = TRUE; | |
2749 | break; | |
2750 | ||
61243a51 DW |
2751 | // Avoid duplicate messages to OnChar for these ASCII keys: they |
2752 | // will be translated by TranslateMessage() and received in WM_CHAR | |
2753 | case VK_ESC: | |
61243a51 DW |
2754 | case VK_ENTER: |
2755 | case VK_BACKSPACE: | |
2756 | case VK_TAB: | |
2757 | // But set processed to FALSE, not TRUE to still pass them to | |
2758 | // the control's default window proc - otherwise built-in | |
2759 | // keyboard handling won't work | |
2760 | bProcessed = FALSE; | |
2761 | break; | |
2762 | ||
61243a51 | 2763 | default: |
598d8cac | 2764 | bProcessed = HandleChar(wParam, lParam); |
61243a51 DW |
2765 | } |
2766 | break; | |
cdf1e714 | 2767 | } |
61243a51 DW |
2768 | else // WM_CHAR -- Always an ASCII character |
2769 | { | |
a086de98 DW |
2770 | if (m_bLastKeydownProcessed) |
2771 | { | |
2772 | // | |
2773 | // The key was handled in the EVT_KEY_DOWN and handling | |
2774 | // a key in an EVT_KEY_DOWN handler is meant, by | |
2775 | // design, to prevent EVT_CHARs from happening | |
2776 | // | |
2777 | m_bLastKeydownProcessed = FALSE; | |
2778 | bProcessed = TRUE; | |
2779 | } | |
2780 | else // do generate a CHAR event | |
2781 | { | |
598d8cac | 2782 | bProcessed = HandleChar(wParam, lParam, TRUE); |
a086de98 DW |
2783 | break; |
2784 | } | |
61243a51 DW |
2785 | } |
2786 | } | |
cdf1e714 | 2787 | } |
cdf1e714 DW |
2788 | |
2789 | case WM_HSCROLL: | |
2790 | case WM_VSCROLL: | |
2791 | { | |
61243a51 DW |
2792 | WXWORD wCode; |
2793 | WXWORD wPos; | |
2794 | WXHWND hWnd; | |
2795 | UnpackScroll( wParam | |
2796 | ,lParam | |
2797 | ,&wCode | |
2798 | ,&wPos | |
2799 | ,&hWnd | |
2800 | ); | |
2801 | ||
2802 | bProcessed = OS2OnScroll( uMsg == WM_HSCROLL ? wxHORIZONTAL | |
2803 | : wxVERTICAL | |
2804 | ,wCode | |
2805 | ,wPos | |
2806 | ,hWnd | |
2807 | ); | |
cdf1e714 DW |
2808 | } |
2809 | break; | |
2810 | ||
3c299c3a DW |
2811 | case WM_CONTROL: |
2812 | switch(SHORT2FROMMP(wParam)) | |
2813 | { | |
a5799260 DW |
2814 | case BN_PAINT: |
2815 | { | |
2816 | HWND hWnd = ::WinWindowFromID((HWND)GetHwnd(), SHORT1FROMMP(wParam)); | |
2817 | wxWindowOS2* pWin = wxFindWinFromHandle(hWnd); | |
2818 | ||
2819 | if (!pWin) | |
2820 | { | |
2821 | bProcessed = FALSE; | |
2822 | break; | |
2823 | } | |
2824 | if (pWin->IsKindOf(CLASSINFO(wxBitmapButton))) | |
2825 | { | |
2826 | wxBitmapButton* pBitmapButton = wxDynamicCast(pWin, wxBitmapButton); | |
2827 | ||
2828 | pBitmapButton->OS2OnDraw((WXDRAWITEMSTRUCT *)lParam); | |
2829 | } | |
2830 | return 0; | |
2831 | } | |
2832 | break; | |
2833 | ||
1de4baa3 DW |
2834 | case BKN_PAGESELECTEDPENDING: |
2835 | { | |
2836 | PPAGESELECTNOTIFY pPage = (PPAGESELECTNOTIFY)lParam; | |
2837 | ||
2838 | if ((pPage->ulPageIdNew != pPage->ulPageIdCur) && | |
2839 | (pPage->ulPageIdNew > 0L && pPage->ulPageIdCur > 0L)) | |
2840 | { | |
2841 | wxWindowOS2* pWin = wxFindWinFromHandle(pPage->hwndBook); | |
2842 | wxNotebookEvent vEvent( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED | |
2843 | ,(int)SHORT1FROMMP(wParam) | |
2844 | ,(int)pPage->ulPageIdNew | |
2845 | ,(int)pPage->ulPageIdCur | |
2846 | ); | |
2847 | if (!pWin) | |
2848 | { | |
2849 | bProcessed = FALSE; | |
2850 | break; | |
2851 | } | |
2852 | if (pWin->IsKindOf(CLASSINFO(wxNotebook))) | |
2853 | { | |
2854 | wxNotebook* pNotebook = wxDynamicCast(pWin, wxNotebook); | |
2855 | ||
2856 | vEvent.SetEventObject(pWin); | |
2857 | pNotebook->OnSelChange(vEvent); | |
2858 | bProcessed = TRUE; | |
2859 | } | |
2860 | else | |
2861 | bProcessed = FALSE; | |
2862 | } | |
2863 | else | |
2864 | bProcessed = FALSE; | |
2865 | } | |
2866 | break; | |
2867 | ||
2868 | case BN_CLICKED: // Dups as LN_SELECT and CBN_LBSELECT | |
f289196b DW |
2869 | { |
2870 | HWND hWnd = ::WinWindowFromID((HWND)GetHwnd(), SHORT1FROMMP(wParam)); | |
2871 | wxWindowOS2* pWin = wxFindWinFromHandle(hWnd); | |
2872 | ||
2873 | if (!pWin) | |
2874 | { | |
2875 | bProcessed = FALSE; | |
2876 | break; | |
2877 | } | |
2878 | // | |
2879 | // Simulate a WM_COMMAND here, as wxWindows expects all control | |
2880 | // button clicks to generate WM_COMMAND msgs, not WM_CONTROL | |
2881 | // | |
2882 | if (pWin->IsKindOf(CLASSINFO(wxRadioBox))) | |
2883 | { | |
2884 | wxRadioBox* pRadioBox = wxDynamicCast(pWin, wxRadioBox); | |
2885 | ||
2886 | pRadioBox->OS2Command( (WXUINT)SHORT2FROMMP(wParam) | |
2887 | ,(WXUINT)SHORT1FROMMP(wParam) | |
2888 | ); | |
2889 | } | |
2890 | if (pWin->IsKindOf(CLASSINFO(wxRadioButton))) | |
2891 | { | |
2892 | wxRadioButton* pRadioButton = wxDynamicCast(pWin, wxRadioButton); | |
2893 | ||
2894 | pRadioButton->OS2Command( (WXUINT)SHORT2FROMMP(wParam) | |
2895 | ,(WXUINT)SHORT1FROMMP(wParam) | |
2896 | ); | |
2897 | } | |
2898 | if (pWin->IsKindOf(CLASSINFO(wxCheckBox))) | |
2899 | { | |
2900 | wxCheckBox* pCheckBox = wxDynamicCast(pWin, wxCheckBox); | |
2901 | ||
2902 | pCheckBox->OS2Command( (WXUINT)SHORT2FROMMP(wParam) | |
2903 | ,(WXUINT)SHORT1FROMMP(wParam) | |
2904 | ); | |
2905 | } | |
1de4baa3 DW |
2906 | if (pWin->IsKindOf(CLASSINFO(wxListBox))) |
2907 | { | |
2908 | wxListBox* pListBox = wxDynamicCast(pWin, wxListBox); | |
2909 | ||
2910 | pListBox->OS2Command( (WXUINT)SHORT2FROMMP(wParam) | |
2911 | ,(WXUINT)SHORT1FROMMP(wParam) | |
2912 | ); | |
2913 | if (pListBox->GetWindowStyle() & wxLB_OWNERDRAW) | |
2914 | Refresh(); | |
2915 | } | |
2916 | if (pWin->IsKindOf(CLASSINFO(wxComboBox))) | |
2917 | { | |
2918 | wxComboBox* pComboBox = wxDynamicCast(pWin, wxComboBox); | |
2919 | ||
2920 | pComboBox->OS2Command( (WXUINT)SHORT2FROMMP(wParam) | |
2921 | ,(WXUINT)SHORT1FROMMP(wParam) | |
2922 | ); | |
2923 | } | |
2924 | return 0; | |
2925 | } | |
2926 | break; | |
2927 | ||
2928 | case LN_ENTER: /* dups as CBN_EFCHANGE */ | |
2929 | { | |
2930 | HWND hWnd = HWNDFROMMP(lParam); | |
2931 | wxWindowOS2* pWin = wxFindWinFromHandle(hWnd); | |
2932 | ||
2933 | if (!pWin) | |
2934 | { | |
2935 | bProcessed = FALSE; | |
2936 | break; | |
2937 | } | |
2938 | // | |
2939 | // Simulate a WM_COMMAND here, as wxWindows expects all control | |
2940 | // button clicks to generate WM_COMMAND msgs, not WM_CONTROL | |
2941 | // | |
2942 | if (pWin->IsKindOf(CLASSINFO(wxListBox))) | |
2943 | { | |
2944 | wxListBox* pListBox = wxDynamicCast(pWin, wxListBox); | |
2945 | ||
2946 | pListBox->OS2Command( (WXUINT)SHORT2FROMMP(wParam) | |
2947 | ,(WXUINT)SHORT1FROMMP(wParam) | |
2948 | ); | |
2949 | if (pListBox->GetWindowStyle() & wxLB_OWNERDRAW) | |
2950 | Refresh(); | |
2951 | ||
2952 | } | |
2953 | if (pWin->IsKindOf(CLASSINFO(wxComboBox))) | |
2954 | { | |
2955 | wxComboBox* pComboBox = wxDynamicCast(pWin, wxComboBox); | |
2956 | ||
2957 | pComboBox->OS2Command( (WXUINT)SHORT2FROMMP(wParam) | |
2958 | ,(WXUINT)SHORT1FROMMP(wParam) | |
2959 | ); | |
2960 | } | |
f289196b DW |
2961 | return 0; |
2962 | } | |
2963 | break; | |
2964 | ||
3c299c3a DW |
2965 | case SPBN_UPARROW: |
2966 | case SPBN_DOWNARROW: | |
2967 | case SPBN_CHANGE: | |
2968 | { | |
2969 | char zVal[10]; | |
2970 | long lVal; | |
2971 | ||
2972 | ::WinSendMsg( HWNDFROMMP(lParam) | |
2973 | ,SPBM_QUERYVALUE | |
2974 | ,&zVal | |
2975 | ,MPFROM2SHORT( (USHORT)10 | |
2976 | ,(USHORT)SPBQ_UPDATEIFVALID | |
2977 | ) | |
2978 | ); | |
2979 | lVal = atol(zVal); | |
2980 | bProcessed = OS2OnScroll( wxVERTICAL | |
2981 | ,(int)SHORT2FROMMP(wParam) | |
2982 | ,(int)lVal | |
2983 | ,HWNDFROMMP(lParam) | |
2984 | ); | |
2985 | } | |
2986 | break; | |
2987 | ||
2988 | case SLN_SLIDERTRACK: | |
2989 | { | |
2990 | HWND hWnd = ::WinWindowFromID(GetHWND(), SHORT1FROMMP(wParam)); | |
2991 | wxWindowOS2* pChild = wxFindWinFromHandle(hWnd); | |
2992 | ||
b389a12d DW |
2993 | if (!pChild) |
2994 | { | |
2995 | bProcessed = FALSE; | |
2996 | break; | |
2997 | } | |
3c299c3a DW |
2998 | if (pChild->IsKindOf(CLASSINFO(wxSlider))) |
2999 | bProcessed = OS2OnScroll( wxVERTICAL | |
3000 | ,(int)SHORT2FROMMP(wParam) | |
3001 | ,(int)LONGFROMMP(lParam) | |
3002 | ,hWnd | |
3003 | ); | |
3004 | } | |
3005 | break; | |
3006 | } | |
3007 | break; | |
3008 | ||
61243a51 DW |
3009 | #if defined(__VISAGECPP__) && (__IBMCPP__ >= 400) |
3010 | case WM_CTLCOLORCHANGE: | |
cdf1e714 | 3011 | { |
e604d44b | 3012 | bProcessed = HandleCtlColor(&hBrush); |
61243a51 DW |
3013 | } |
3014 | break; | |
3015 | #endif | |
8d854fa9 DW |
3016 | case WM_ERASEBACKGROUND: |
3017 | // | |
3018 | // Returning TRUE to requestw PM to paint the window background | |
3019 | // in SYSCLR_WINDOW. We don't really want that | |
3020 | // | |
3021 | bProcessed = HandleEraseBkgnd((WXHDC)(HPS)wParam); | |
3022 | mResult = (MRESULT)(FALSE); | |
3023 | break; | |
3024 | ||
cdf1e714 DW |
3025 | // the return value for this message is ignored |
3026 | case WM_SYSCOLORCHANGE: | |
61243a51 | 3027 | bProcessed = HandleSysColorChange(); |
cdf1e714 DW |
3028 | break; |
3029 | ||
61243a51 DW |
3030 | case WM_REALIZEPALETTE: |
3031 | bProcessed = HandlePaletteChanged(); | |
cdf1e714 DW |
3032 | break; |
3033 | ||
61243a51 DW |
3034 | // move all drag and drops to wxDrg |
3035 | case WM_ENDDRAG: | |
3036 | bProcessed = HandleEndDrag(wParam); | |
cdf1e714 DW |
3037 | break; |
3038 | ||
61243a51 DW |
3039 | case WM_INITDLG: |
3040 | bProcessed = HandleInitDialog((WXHWND)(HWND)wParam); | |
cdf1e714 | 3041 | |
61243a51 | 3042 | if ( bProcessed ) |
cdf1e714 DW |
3043 | { |
3044 | // we never set focus from here | |
272ebf16 | 3045 | mResult = (MRESULT)FALSE; |
cdf1e714 DW |
3046 | } |
3047 | break; | |
3048 | ||
61243a51 DW |
3049 | // wxFrame specific message |
3050 | case WM_MINMAXFRAME: | |
f6bcfd97 | 3051 | bProcessed = HandleGetMinMaxInfo((PSWP)wParam); |
cdf1e714 DW |
3052 | break; |
3053 | ||
61243a51 DW |
3054 | case WM_SYSVALUECHANGED: |
3055 | // TODO: do something | |
e604d44b | 3056 | mResult = (MRESULT)TRUE; |
cdf1e714 DW |
3057 | break; |
3058 | ||
61243a51 DW |
3059 | // |
3060 | // Comparable to WM_SETPOINTER for windows, only for just controls | |
3061 | // | |
3062 | case WM_CONTROLPOINTER: | |
3063 | bProcessed = HandleSetCursor( SHORT1FROMMP(wParam) // Control ID | |
3064 | ,(HWND)lParam // Cursor Handle | |
3065 | ); | |
3066 | if (bProcessed ) | |
cdf1e714 | 3067 | { |
61243a51 DW |
3068 | // |
3069 | // Returning TRUE stops the DefWindowProc() from further | |
cdf1e714 DW |
3070 | // processing this message - exactly what we need because we've |
3071 | // just set the cursor. | |
61243a51 | 3072 | // |
e604d44b | 3073 | mResult = (MRESULT)TRUE; |
cdf1e714 DW |
3074 | } |
3075 | break; | |
3076 | } | |
61243a51 | 3077 | if (!bProcessed) |
cdf1e714 DW |
3078 | { |
3079 | #ifdef __WXDEBUG__ | |
3080 | wxLogTrace(wxTraceMessages, wxT("Forwarding %s to DefWindowProc."), | |
61243a51 | 3081 | wxGetMessageName(uMsg)); |
cdf1e714 | 3082 | #endif // __WXDEBUG__ |
d08f23a7 DW |
3083 | if (IsKindOf(CLASSINFO(wxFrame))) |
3084 | mResult = ::WinDefWindowProc(m_hWnd, uMsg, wParam, lParam); | |
1b086de1 DW |
3085 | else if (IsKindOf(CLASSINFO(wxDialog))) |
3086 | mResult = ::WinDefDlgProc( m_hWnd, uMsg, wParam, lParam); | |
d08f23a7 DW |
3087 | else |
3088 | mResult = OS2DefWindowProc(uMsg, wParam, lParam); | |
cdf1e714 | 3089 | } |
e604d44b | 3090 | return mResult; |
0367c1c0 | 3091 | } // end of wxWindowOS2::OS2WindowProc |
cdf1e714 | 3092 | |
a4a16252 SN |
3093 | #ifndef __EMX__ |
3094 | // clashes with wxDlgProc in toplevel.cpp? | |
61243a51 | 3095 | // |
cdf1e714 | 3096 | // Dialog window proc |
61243a51 DW |
3097 | // |
3098 | MRESULT wxDlgProc( | |
19193a2c | 3099 | HWND WXUNUSED(hWnd) |
61243a51 | 3100 | , UINT uMsg |
19193a2c KB |
3101 | , MPARAM WXUNUSED(wParam) |
3102 | , MPARAM WXUNUSED(lParam)) | |
cdf1e714 | 3103 | { |
61243a51 | 3104 | if (uMsg == WM_INITDLG) |
cdf1e714 | 3105 | { |
61243a51 DW |
3106 | // |
3107 | // For this message, returning TRUE tells system to set focus to the | |
cdf1e714 | 3108 | // first control in the dialog box |
61243a51 DW |
3109 | // |
3110 | return (MRESULT)TRUE; | |
cdf1e714 DW |
3111 | } |
3112 | else | |
3113 | { | |
61243a51 DW |
3114 | // |
3115 | // For all the other ones, FALSE means that we didn't process the | |
cdf1e714 | 3116 | // message |
61243a51 DW |
3117 | // |
3118 | return (MRESULT)0; | |
cdf1e714 | 3119 | } |
61243a51 | 3120 | } // end of wxDlgProc |
a4a16252 | 3121 | #endif |
cdf1e714 | 3122 | |
61243a51 DW |
3123 | wxWindow* wxFindWinFromHandle( |
3124 | WXHWND hWnd | |
3125 | ) | |
cdf1e714 | 3126 | { |
61243a51 DW |
3127 | wxNode* pNode = wxWinHandleList->Find((long)hWnd); |
3128 | ||
3129 | if (!pNode) | |
cdf1e714 | 3130 | return NULL; |
61243a51 DW |
3131 | return (wxWindow *)pNode->Data(); |
3132 | } // end of wxFindWinFromHandle | |
cdf1e714 | 3133 | |
61243a51 DW |
3134 | void wxAssociateWinWithHandle( |
3135 | HWND hWnd | |
19193a2c | 3136 | , wxWindowOS2* pWin |
61243a51 | 3137 | ) |
cdf1e714 | 3138 | { |
61243a51 DW |
3139 | // |
3140 | // Adding NULL hWnd is (first) surely a result of an error and | |
cdf1e714 | 3141 | // (secondly) breaks menu command processing |
61243a51 | 3142 | // |
cdf1e714 DW |
3143 | wxCHECK_RET( hWnd != (HWND)NULL, |
3144 | wxT("attempt to add a NULL hWnd to window list ignored") ); | |
3145 | ||
3146 | ||
61243a51 DW |
3147 | wxWindow* pOldWin = wxFindWinFromHandle((WXHWND) hWnd); |
3148 | ||
3149 | if (pOldWin && (pOldWin != pWin)) | |
cdf1e714 | 3150 | { |
61243a51 DW |
3151 | wxString str(pWin->GetClassInfo()->GetClassName()); |
3152 | wxLogError( "Bug! Found existing HWND %X for new window of class %s" | |
3153 | ,(int)hWnd | |
3154 | ,(const char*)str | |
3155 | ); | |
cdf1e714 | 3156 | } |
61243a51 | 3157 | else if (!pOldWin) |
cdf1e714 | 3158 | { |
61243a51 DW |
3159 | wxWinHandleList->Append( (long)hWnd |
3160 | ,pWin | |
3161 | ); | |
cdf1e714 | 3162 | } |
61243a51 | 3163 | } // end of wxAssociateWinWithHandle |
cdf1e714 | 3164 | |
61243a51 | 3165 | void wxRemoveHandleAssociation( |
19193a2c | 3166 | wxWindowOS2* pWin |
61243a51 | 3167 | ) |
cdf1e714 | 3168 | { |
61243a51 DW |
3169 | wxWinHandleList->DeleteObject(pWin); |
3170 | } // end of wxRemoveHandleAssociation | |
cdf1e714 | 3171 | |
61243a51 | 3172 | // |
cdf1e714 DW |
3173 | // Default destroyer - override if you destroy it in some other way |
3174 | // (e.g. with MDI child windows) | |
61243a51 | 3175 | // |
0367c1c0 | 3176 | void wxWindowOS2::OS2DestroyWindow() |
cdf1e714 DW |
3177 | { |
3178 | } | |
3179 | ||
f9efbe3a DW |
3180 | bool wxWindowOS2::OS2GetCreateWindowCoords( |
3181 | const wxPoint& rPos | |
3182 | , const wxSize& rSize | |
3183 | , int& rnX | |
3184 | , int& rnY | |
3185 | , int& rnWidth | |
3186 | , int& rnHeight | |
3187 | ) const | |
3188 | { | |
3189 | bool bNonDefault = FALSE; | |
d697657f DW |
3190 | static const int DEFAULT_Y = 200; |
3191 | static const int DEFAULT_H = 250; | |
f9efbe3a DW |
3192 | |
3193 | if (rPos.x == -1) | |
3194 | { | |
f9efbe3a DW |
3195 | rnX = rnY = CW_USEDEFAULT; |
3196 | } | |
3197 | else | |
3198 | { | |
3199 | rnX = rPos.x; | |
d697657f | 3200 | rnY = rPos.y == -1 ? DEFAULT_Y : rPos.y; |
f9efbe3a DW |
3201 | bNonDefault = TRUE; |
3202 | } | |
3203 | if (rSize.x == -1) | |
3204 | { | |
f9efbe3a DW |
3205 | rnWidth = rnHeight = CW_USEDEFAULT; |
3206 | } | |
3207 | else | |
3208 | { | |
3209 | rnWidth = rSize.x; | |
d697657f | 3210 | rnHeight = rSize.y == -1 ? DEFAULT_H : rSize.y; |
f9efbe3a DW |
3211 | bNonDefault = TRUE; |
3212 | } | |
3213 | return bNonDefault; | |
3214 | } // end of wxWindowOS2::OS2GetCreateWindowCoords | |
3215 | ||
6ed98c6a DW |
3216 | WXHWND wxWindowOS2::OS2GetParent() const |
3217 | { | |
3218 | return m_parent ? m_parent->GetHWND() : NULL; | |
3219 | } | |
3220 | ||
0367c1c0 | 3221 | bool wxWindowOS2::OS2Create( |
5d44b24e DW |
3222 | PSZ zClass |
3223 | , const char* zTitle | |
61243a51 | 3224 | , WXDWORD dwStyle |
5d44b24e DW |
3225 | , const wxPoint& rPos |
3226 | , const wxSize& rSize | |
f23208ca | 3227 | , void* pCtlData |
008089f6 | 3228 | , WXDWORD dwExStyle |
5d44b24e | 3229 | , bool bIsChild |
61243a51 DW |
3230 | ) |
3231 | { | |
914589c2 DW |
3232 | ERRORID vError; |
3233 | wxString sError; | |
5d44b24e DW |
3234 | int nX = 0L; |
3235 | int nY = 0L; | |
3236 | int nWidth = 0L; | |
3237 | int nHeight = 0L; | |
3238 | wxWindow* pParent = GetParent(); | |
3239 | HWND hWnd = NULLHANDLE; | |
3240 | HWND hParent; | |
3241 | long lControlId = 0L; | |
3242 | wxWindowCreationHook vHook(this); | |
3243 | wxString sClassName((wxChar*)zClass); | |
3244 | ||
3245 | OS2GetCreateWindowCoords( rPos | |
3246 | ,rSize | |
3247 | ,nX | |
3248 | ,nY | |
3249 | ,nWidth | |
3250 | ,nHeight | |
3251 | ); | |
3252 | ||
5d44b24e | 3253 | if (bIsChild) |
cdf1e714 | 3254 | { |
5d44b24e DW |
3255 | lControlId = GetId(); |
3256 | if (GetWindowStyleFlag() & wxCLIP_SIBLINGS) | |
cdf1e714 | 3257 | { |
5d44b24e | 3258 | dwStyle |= WS_CLIPSIBLINGS; |
cdf1e714 DW |
3259 | } |
3260 | } | |
cd212ee4 | 3261 | // |
5d44b24e DW |
3262 | // For each class "Foo" we have we also have "FooNR" ("no repaint") class |
3263 | // which is the same but without CS_[HV]REDRAW class styles so using it | |
3264 | // ensures that the window is not fully repainted on each resize | |
e604d44b | 3265 | // |
5d44b24e | 3266 | if (GetWindowStyleFlag() & wxNO_FULL_REPAINT_ON_RESIZE) |
51c1d535 | 3267 | { |
5d44b24e DW |
3268 | sClassName += wxT("NR"); |
3269 | } | |
6ed98c6a DW |
3270 | m_hWnd = (WXHWND)::WinCreateWindow( (HWND)OS2GetParent() |
3271 | ,(PSZ)sClassName.c_str() | |
3272 | ,(PSZ)zTitle ? zTitle : "" | |
3273 | ,(ULONG)dwStyle | |
3274 | ,(LONG)0L | |
3275 | ,(LONG)0L | |
3276 | ,(LONG)0L | |
3277 | ,(LONG)0L | |
3278 | ,NULLHANDLE | |
3279 | ,HWND_TOP | |
3280 | ,(ULONG)lControlId | |
3281 | ,pCtlData | |
3282 | ,NULL | |
3283 | ); | |
5d44b24e DW |
3284 | if (!m_hWnd) |
3285 | { | |
3286 | vError = ::WinGetLastError(wxGetInstance()); | |
3287 | sError = wxPMErrorToStr(vError); | |
3288 | return FALSE; | |
51c1d535 | 3289 | } |
5d44b24e | 3290 | SubclassWin(m_hWnd); |
a756f210 | 3291 | SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); |
4a46a5df DW |
3292 | |
3293 | m_backgroundColour.Set(wxString("GREY")); | |
3294 | ||
3295 | LONG lColor = (LONG)m_backgroundColour.GetPixel(); | |
3296 | ||
3297 | if (!::WinSetPresParam( m_hWnd | |
3298 | ,PP_BACKGROUNDCOLOR | |
3299 | ,sizeof(LONG) | |
3300 | ,(PVOID)&lColor | |
3301 | )) | |
3302 | { | |
3303 | vError = ::WinGetLastError(vHabmain); | |
3304 | sError = wxPMErrorToStr(vError); | |
3305 | wxLogError("Error creating frame. Error: %s\n", sError); | |
3306 | return FALSE; | |
3307 | } | |
5d44b24e DW |
3308 | SetSize( nX |
3309 | ,nY | |
3310 | ,nWidth | |
3311 | ,nHeight | |
3312 | ); | |
cdf1e714 | 3313 | return TRUE; |
5d44b24e | 3314 | } // end of WinGuiBase_Window::OS2Create |
cdf1e714 DW |
3315 | |
3316 | // =========================================================================== | |
3317 | // OS2 PM message handlers | |
3318 | // =========================================================================== | |
3319 | ||
3320 | // --------------------------------------------------------------------------- | |
61243a51 | 3321 | // window creation/destruction |
cdf1e714 DW |
3322 | // --------------------------------------------------------------------------- |
3323 | ||
0367c1c0 | 3324 | bool wxWindowOS2::HandleCreate( |
19193a2c | 3325 | WXLPCREATESTRUCT WXUNUSED(vCs) |
61243a51 DW |
3326 | , bool* pbMayCreate |
3327 | ) | |
cdf1e714 | 3328 | { |
19193a2c | 3329 | wxWindowCreateEvent vEvent((wxWindow*)this); |
cdf1e714 | 3330 | |
61243a51 DW |
3331 | (void)GetEventHandler()->ProcessEvent(vEvent); |
3332 | *pbMayCreate = TRUE; | |
cdf1e714 | 3333 | return TRUE; |
0367c1c0 | 3334 | } // end of wxWindowOS2::HandleCreate |
cdf1e714 | 3335 | |
0367c1c0 | 3336 | bool wxWindowOS2::HandleDestroy() |
cdf1e714 | 3337 | { |
6e348b12 DW |
3338 | wxWindowDestroyEvent vEvent((wxWindow*)this); |
3339 | vEvent.SetId(GetId()); | |
3340 | (void)GetEventHandler()->ProcessEvent(vEvent); | |
61243a51 DW |
3341 | |
3342 | // | |
3343 | // Delete our drop target if we've got one | |
3344 | // | |
cdf1e714 | 3345 | #if wxUSE_DRAG_AND_DROP |
61243a51 | 3346 | if (m_dropTarget != NULL) |
cdf1e714 | 3347 | { |
cdf1e714 DW |
3348 | delete m_dropTarget; |
3349 | m_dropTarget = NULL; | |
3350 | } | |
3351 | #endif // wxUSE_DRAG_AND_DROP | |
3352 | ||
61243a51 | 3353 | // |
cdf1e714 | 3354 | // WM_DESTROY handled |
61243a51 | 3355 | // |
cdf1e714 | 3356 | return TRUE; |
0367c1c0 | 3357 | } // end of wxWindowOS2::HandleDestroy |
cdf1e714 DW |
3358 | |
3359 | // --------------------------------------------------------------------------- | |
3360 | // activation/focus | |
3361 | // --------------------------------------------------------------------------- | |
0367c1c0 | 3362 | void wxWindowOS2::OnSetFocus( |
61243a51 DW |
3363 | wxFocusEvent& rEvent |
3364 | ) | |
cdf1e714 | 3365 | { |
61243a51 | 3366 | rEvent.Skip(); |
0367c1c0 | 3367 | } // end of wxWindowOS2::OnSetFocus |
61243a51 | 3368 | |
0367c1c0 | 3369 | bool wxWindowOS2::HandleActivate( |
61243a51 DW |
3370 | int nState |
3371 | , WXHWND WXUNUSED(hActivate) | |
3372 | ) | |
3373 | { | |
3374 | wxActivateEvent vEvent( wxEVT_ACTIVATE | |
3375 | ,(bool)nState | |
3376 | ,m_windowId | |
3377 | ); | |
3378 | vEvent.SetEventObject(this); | |
3379 | return GetEventHandler()->ProcessEvent(vEvent); | |
0367c1c0 | 3380 | } // end of wxWindowOS2::HandleActivate |
61243a51 | 3381 | |
0367c1c0 | 3382 | bool wxWindowOS2::HandleSetFocus( |
61243a51 DW |
3383 | WXHWND WXUNUSED(hWnd) |
3384 | ) | |
cdf1e714 | 3385 | { |
54ffa107 DW |
3386 | // |
3387 | // Notify the parent keeping track of focus for the kbd navigation | |
3388 | // purposes that we got it | |
3389 | // | |
3390 | wxChildFocusEvent vEventFocus((wxWindow *)this); | |
3391 | (void)GetEventHandler()->ProcessEvent(vEventFocus); | |
3392 | ||
cdf1e714 | 3393 | #if wxUSE_CARET |
61243a51 | 3394 | // |
cdf1e714 | 3395 | // Deal with caret |
61243a51 DW |
3396 | // |
3397 | if (m_caret) | |
cdf1e714 DW |
3398 | { |
3399 | m_caret->OnSetFocus(); | |
3400 | } | |
3401 | #endif // wxUSE_CARET | |
3402 | ||
1bcfc0e1 DW |
3403 | #if wxUSE_TEXTCTRL |
3404 | // If it's a wxTextCtrl don't send the event as it will be done | |
3405 | // after the control gets to process it from EN_FOCUS handler | |
3406 | if ( wxDynamicCastThis(wxTextCtrl) ) | |
cdf1e714 | 3407 | { |
1bcfc0e1 | 3408 | return FALSE; |
cdf1e714 | 3409 | } |
1bcfc0e1 | 3410 | #endif // wxUSE_TEXTCTRL |
cdf1e714 | 3411 | |
61243a51 | 3412 | wxFocusEvent vEvent(wxEVT_SET_FOCUS, m_windowId); |
cdf1e714 | 3413 | |
61243a51 DW |
3414 | vEvent.SetEventObject(this); |
3415 | return GetEventHandler()->ProcessEvent(vEvent); | |
0367c1c0 | 3416 | } // end of wxWindowOS2::HandleSetFocus |
cdf1e714 | 3417 | |
0367c1c0 | 3418 | bool wxWindowOS2::HandleKillFocus( |
a23692f0 | 3419 | WXHWND hWnd |
61243a51 | 3420 | ) |
cdf1e714 DW |
3421 | { |
3422 | #if wxUSE_CARET | |
61243a51 | 3423 | // |
cdf1e714 | 3424 | // Deal with caret |
61243a51 DW |
3425 | // |
3426 | if (m_caret) | |
cdf1e714 DW |
3427 | { |
3428 | m_caret->OnKillFocus(); | |
3429 | } | |
3430 | #endif // wxUSE_CARET | |
3431 | ||
a23692f0 | 3432 | #if wxUSE_TEXTCTRL |
f289196b | 3433 | // |
a23692f0 DW |
3434 | // If it's a wxTextCtrl don't send the event as it will be done |
3435 | // after the control gets to process it. | |
3436 | // | |
3437 | wxTextCtrl* pCtrl = wxDynamicCastThis(wxTextCtrl); | |
3438 | ||
3439 | if (pCtrl) | |
3440 | { | |
3441 | return FALSE; | |
3442 | } | |
3443 | #endif | |
3444 | ||
f289196b | 3445 | // |
a23692f0 DW |
3446 | // Don't send the event when in the process of being deleted. This can |
3447 | // only cause problems if the event handler tries to access the object. | |
3448 | // | |
3449 | if ( m_isBeingDeleted ) | |
3450 | { | |
3451 | return FALSE; | |
3452 | } | |
3453 | ||
61243a51 DW |
3454 | wxFocusEvent vEvent( wxEVT_KILL_FOCUS |
3455 | ,m_windowId | |
3456 | ); | |
cdf1e714 | 3457 | |
61243a51 | 3458 | vEvent.SetEventObject(this); |
a23692f0 | 3459 | |
f289196b | 3460 | // |
a23692f0 DW |
3461 | // wxFindWinFromHandle() may return NULL, it is ok |
3462 | // | |
3463 | vEvent.SetWindow(wxFindWinFromHandle(hWnd)); | |
61243a51 | 3464 | return GetEventHandler()->ProcessEvent(vEvent); |
0367c1c0 | 3465 | } // end of wxWindowOS2::HandleKillFocus |
cdf1e714 DW |
3466 | |
3467 | // --------------------------------------------------------------------------- | |
3468 | // miscellaneous | |
3469 | // --------------------------------------------------------------------------- | |
3470 | ||
0367c1c0 | 3471 | bool wxWindowOS2::HandleShow( |
61243a51 | 3472 | bool bShow |
19193a2c | 3473 | , int WXUNUSED(nStatus) |
61243a51 | 3474 | ) |
cdf1e714 | 3475 | { |
19193a2c | 3476 | wxShowEvent vEvent(GetId(), bShow); |
cdf1e714 | 3477 | |
61243a51 DW |
3478 | vEvent.m_eventObject = this; |
3479 | return GetEventHandler()->ProcessEvent(vEvent); | |
0367c1c0 | 3480 | } // end of wxWindowOS2::HandleShow |
cdf1e714 | 3481 | |
0367c1c0 | 3482 | bool wxWindowOS2::HandleInitDialog( |
61243a51 DW |
3483 | WXHWND WXUNUSED(hWndFocus) |
3484 | ) | |
cdf1e714 | 3485 | { |
61243a51 | 3486 | wxInitDialogEvent vEvent(GetId()); |
cdf1e714 | 3487 | |
61243a51 DW |
3488 | vEvent.m_eventObject = this; |
3489 | return GetEventHandler()->ProcessEvent(vEvent); | |
0367c1c0 | 3490 | } // end of wxWindowOS2::HandleInitDialog |
cdf1e714 | 3491 | |
19193a2c | 3492 | bool wxWindowOS2::HandleEndDrag(WXWPARAM WXUNUSED(wParam)) |
cdf1e714 | 3493 | { |
61243a51 | 3494 | // TODO: We'll handle drag and drop later |
cdf1e714 DW |
3495 | return FALSE; |
3496 | } | |
3497 | ||
0367c1c0 | 3498 | bool wxWindowOS2::HandleSetCursor( |
19193a2c | 3499 | USHORT WXUNUSED(vId) |
61243a51 DW |
3500 | , WXHWND hPointer |
3501 | ) | |
cdf1e714 | 3502 | { |
61243a51 DW |
3503 | // |
3504 | // Under OS/2 PM this allows the pointer to be changed | |
3505 | // as it passes over a control | |
3506 | // | |
3507 | ::WinSetPointer(HWND_DESKTOP, (HPOINTER)hPointer); | |
3508 | return TRUE; | |
0367c1c0 | 3509 | } // end of wxWindowOS2::HandleSetCursor |
cdf1e714 DW |
3510 | |
3511 | // --------------------------------------------------------------------------- | |
3512 | // owner drawn stuff | |
3513 | // --------------------------------------------------------------------------- | |
0367c1c0 | 3514 | bool wxWindowOS2::OS2OnDrawItem( |
61243a51 DW |
3515 | int vId |
3516 | , WXDRAWITEMSTRUCT* pItemStruct | |
3517 | ) | |
cdf1e714 | 3518 | { |
19193a2c | 3519 | #if wxUSE_OWNER_DRAWN |
402e2f7c | 3520 | wxDC vDc; |
61243a51 | 3521 | |
19193a2c | 3522 | #if wxUSE_MENUS_NATIVE |
61243a51 | 3523 | // |
402e2f7c | 3524 | // Is it a menu item? |
61243a51 | 3525 | // |
402e2f7c DW |
3526 | if (vId == 0) |
3527 | { | |
5afb9458 DW |
3528 | ERRORID vError; |
3529 | wxString sError; | |
402e2f7c | 3530 | POWNERITEM pMeasureStruct = (POWNERITEM)pItemStruct; |
23122f8c DW |
3531 | wxFrame* pFrame = (wxFrame*)this; |
3532 | wxMenuItem* pMenuItem = pFrame->GetMenuBar()->FindItem(pMeasureStruct->idItem, pMeasureStruct->hItem); | |
402e2f7c | 3533 | HDC hDC = ::GpiQueryDevice(pMeasureStruct->hps); |
23122f8c DW |
3534 | wxRect vRect( pMeasureStruct->rclItem.xLeft |
3535 | ,pMeasureStruct->rclItem.yBottom | |
3536 | ,pMeasureStruct->rclItem.xRight - pMeasureStruct->rclItem.xLeft | |
3537 | ,pMeasureStruct->rclItem.yTop - pMeasureStruct->rclItem.yBottom | |
3538 | ); | |
402e2f7c DW |
3539 | vDc.SetHDC( hDC |
3540 | ,FALSE | |
3541 | ); | |
3542 | vDc.SetHPS(pMeasureStruct->hps); | |
5afb9458 DW |
3543 | // |
3544 | // Load the wxWindows Pallete and set to RGB mode | |
3545 | // | |
3546 | if (!::GpiCreateLogColorTable( pMeasureStruct->hps | |
3547 | ,0L | |
3548 | ,LCOLF_CONSECRGB | |
3549 | ,0L | |
3550 | ,(LONG)wxTheColourDatabase->m_nSize | |
3551 | ,(PLONG)wxTheColourDatabase->m_palTable | |
3552 | )) | |
3553 | { | |
3554 | vError = ::WinGetLastError(vHabmain); | |
3555 | sError = wxPMErrorToStr(vError); | |
3556 | wxLogError("Unable to set current color table. Error: %s\n", sError); | |
3557 | } | |
3558 | // | |
3559 | // Set the color table to RGB mode | |
3560 | // | |
3561 | if (!::GpiCreateLogColorTable( pMeasureStruct->hps | |
3562 | ,0L | |
3563 | ,LCOLF_RGB | |
3564 | ,0L | |
3565 | ,0L | |
3566 | ,NULL | |
3567 | )) | |
3568 | { | |
3569 | vError = ::WinGetLastError(vHabmain); | |
3570 | sError = wxPMErrorToStr(vError); | |
3571 | wxLogError("Unable to set current color table. Error: %s\n", sError); | |
3572 | } | |
cdf1e714 | 3573 | |
23122f8c DW |
3574 | wxCHECK( pMenuItem->IsKindOf(CLASSINFO(wxMenuItem)), FALSE ); |
3575 | ||
3576 | ||
3577 | int eAction = 0; | |
3578 | int eStatus = 0; | |
cdf1e714 | 3579 | |
402e2f7c | 3580 | if (pMeasureStruct->fsAttribute == pMeasureStruct->fsAttributeOld) |
23122f8c DW |
3581 | { |
3582 | // | |
3583 | // Entire Item needs to be redrawn (either it has reappeared from | |
3584 | // behind another window or is being displayed for the first time | |
3585 | // | |
402e2f7c | 3586 | eAction = wxOwnerDrawn::wxODDrawAll; |
23122f8c DW |
3587 | |
3588 | if (pMeasureStruct->fsAttribute & MIA_HILITED) | |
3589 | { | |
3590 | // | |
3591 | // If it is currently selected we let the system handle it | |
3592 | // | |
3593 | eStatus |= wxOwnerDrawn::wxODSelected; | |
3594 | } | |
3595 | if (pMeasureStruct->fsAttribute & MIA_CHECKED) | |
3596 | { | |
3597 | // | |
3598 | // If it is currently checked we draw our own | |
3599 | // | |
3600 | eStatus |= wxOwnerDrawn::wxODChecked; | |
3601 | pMeasureStruct->fsAttributeOld = pMeasureStruct->fsAttribute &= ~MIA_CHECKED; | |
3602 | } | |
3603 | if (pMeasureStruct->fsAttribute & MIA_DISABLED) | |
3604 | { | |
3605 | // | |
3606 | // If it is currently disabled we let the system handle it | |
3607 | // | |
3608 | eStatus |= wxOwnerDrawn::wxODDisabled; | |
3609 | } | |
3610 | // | |
3611 | // Don't really care about framed (indicationg focus) or NoDismiss | |
3612 | // | |
3613 | } | |
402e2f7c | 3614 | else |
23122f8c | 3615 | { |
5afb9458 DW |
3616 | if (pMeasureStruct->fsAttribute & MIA_HILITED) |
3617 | { | |
3618 | eAction = wxOwnerDrawn::wxODDrawAll; | |
3619 | eStatus |= wxOwnerDrawn::wxODSelected; | |
3620 | // | |
3621 | // Keep the system from trying to highlight with its bogus colors | |
3622 | // | |
3623 | pMeasureStruct->fsAttributeOld = pMeasureStruct->fsAttribute &= ~MIA_HILITED; | |
3624 | } | |
3625 | else if (!(pMeasureStruct->fsAttribute & MIA_HILITED)) | |
3626 | { | |
3627 | eAction = wxOwnerDrawn::wxODDrawAll; | |
3628 | eStatus = 0; | |
3629 | // | |
3630 | // Keep the system from trying to highlight with its bogus colors | |
3631 | // | |
3632 | pMeasureStruct->fsAttribute = pMeasureStruct->fsAttributeOld &= ~MIA_HILITED; | |
3633 | } | |
3634 | else | |
3635 | { | |
3636 | // | |
3637 | // For now we don't care about anything else | |
3638 | // just ignore the entire message! | |
3639 | // | |
3640 | return TRUE; | |
3641 | } | |
23122f8c DW |
3642 | } |
3643 | // | |
3644 | // Now redraw the item | |
3645 | // | |
45bedfdd DW |
3646 | return(pMenuItem->OnDrawItem( vDc |
3647 | ,vRect | |
23122f8c DW |
3648 | ,(wxOwnerDrawn::wxODAction)eAction |
3649 | ,(wxOwnerDrawn::wxODStatus)eStatus | |
45bedfdd | 3650 | )); |
402e2f7c DW |
3651 | // |
3652 | // leave the fsAttribute and fsOldAttribute unchanged. If different, | |
3653 | // the system will do the highlight or fraeming or disabling for us, | |
3654 | // otherwise, we'd have to do it ourselves. | |
61243a51 | 3655 | // |
cdf1e714 | 3656 | } |
19193a2c | 3657 | #endif // wxUSE_MENUS_NATIVE |
cdf1e714 | 3658 | |
402e2f7c DW |
3659 | wxWindow* pItem = FindItem(vId); |
3660 | ||
3661 | if (pItem && pItem->IsKindOf(CLASSINFO(wxControl))) | |
3662 | { | |
3663 | return ((wxControl *)pItem)->OS2OnDraw(pItemStruct); | |
3664 | } | |
19193a2c KB |
3665 | #else |
3666 | vId = vId; | |
3667 | pItemStruct = pItemStruct; | |
61243a51 | 3668 | #endif |
402e2f7c | 3669 | return FALSE; |
0367c1c0 | 3670 | } // end of wxWindowOS2::OS2OnDrawItem |
cdf1e714 | 3671 | |
f5ea767e | 3672 | long wxWindowOS2::OS2OnMeasureItem( |
402e2f7c DW |
3673 | int lId |
3674 | , WXMEASUREITEMSTRUCT* pItemStruct | |
3675 | ) | |
0e320a79 | 3676 | { |
19193a2c | 3677 | #if wxUSE_OWNER_DRAWN |
402e2f7c DW |
3678 | // |
3679 | // Is it a menu item? | |
3680 | // | |
45bedfdd | 3681 | if (lId == 65536) // I really don't like this...has to be a better indicator |
cdf1e714 | 3682 | { |
4049cc1c | 3683 | if (IsKindOf(CLASSINFO(wxFrame))) // we'll assume if Frame then a menu |
45bedfdd | 3684 | { |
4049cc1c DW |
3685 | size_t nWidth; |
3686 | size_t nHeight; | |
3687 | POWNERITEM pMeasureStruct = (POWNERITEM)pItemStruct; | |
45bedfdd DW |
3688 | wxFrame* pFrame = (wxFrame*)this; |
3689 | wxMenuItem* pMenuItem = pFrame->GetMenuBar()->FindItem(pMeasureStruct->idItem, pMeasureStruct->hItem); | |
cdf1e714 | 3690 | |
45bedfdd | 3691 | wxCHECK( pMenuItem->IsKindOf(CLASSINFO(wxMenuItem)), FALSE ); |
4049cc1c DW |
3692 | nWidth = 0L; |
3693 | nHeight = 0L; | |
3694 | if (pMenuItem->OnMeasureItem( &nWidth | |
3695 | ,&nHeight | |
3696 | )) | |
3697 | { | |
f5ea767e DW |
3698 | MRESULT mRc; |
3699 | ||
4049cc1c DW |
3700 | pMeasureStruct->rclItem.xRight = nWidth; |
3701 | pMeasureStruct->rclItem.xLeft = 0L; | |
3702 | pMeasureStruct->rclItem.yTop = nHeight; | |
3703 | pMeasureStruct->rclItem.yBottom = 0L; | |
f5ea767e DW |
3704 | mRc = MRFROM2SHORT(nHeight, nWidth); |
3705 | return LONGFROMMR(mRc); | |
4049cc1c | 3706 | } |
f5ea767e | 3707 | return 0L; |
45bedfdd | 3708 | } |
cdf1e714 | 3709 | } |
f15b4952 | 3710 | wxWindow* pItem = FindItem(lId); |
cdf1e714 | 3711 | |
402e2f7c | 3712 | if (pItem && pItem->IsKindOf(CLASSINFO(wxControl))) |
cdf1e714 | 3713 | { |
1de4baa3 DW |
3714 | OWNERITEM vItem; |
3715 | ||
3716 | vItem.idItem = (LONG)pItemStruct; | |
3717 | return ((wxControl *)pItem)->OS2OnMeasure((WXMEASUREITEMSTRUCT*)&vItem); | |
cdf1e714 | 3718 | } |
19193a2c KB |
3719 | #else |
3720 | lId = lId; | |
3721 | pItemStruct = pItemStruct; | |
3722 | #endif // wxUSE_OWNER_DRAWN | |
cdf1e714 | 3723 | return FALSE; |
0e320a79 DW |
3724 | } |
3725 | ||
cdf1e714 DW |
3726 | // --------------------------------------------------------------------------- |
3727 | // colours and palettes | |
3728 | // --------------------------------------------------------------------------- | |
849949b1 | 3729 | |
0367c1c0 | 3730 | bool wxWindowOS2::HandleSysColorChange() |
0e320a79 | 3731 | { |
61243a51 | 3732 | wxSysColourChangedEvent vEvent; |
cdf1e714 | 3733 | |
61243a51 DW |
3734 | vEvent.SetEventObject(this); |
3735 | return GetEventHandler()->ProcessEvent(vEvent); | |
0367c1c0 | 3736 | } // end of wxWindowOS2::HandleSysColorChange |
0e320a79 | 3737 | |
0367c1c0 | 3738 | bool wxWindowOS2::HandleCtlColor( |
19193a2c | 3739 | WXHBRUSH* WXUNUSED(phBrush) |
61243a51 | 3740 | ) |
0e320a79 | 3741 | { |
61243a51 DW |
3742 | // |
3743 | // Not much provided with message. So not sure I can do anything with it | |
3744 | // | |
3745 | return TRUE; | |
0367c1c0 | 3746 | } // end of wxWindowOS2::HandleCtlColor |
cdf1e714 | 3747 | |
0e320a79 | 3748 | |
cdf1e714 | 3749 | // Define for each class of dialog and control |
19193a2c KB |
3750 | WXHBRUSH wxWindowOS2::OnCtlColor(WXHDC WXUNUSED(hDC), |
3751 | WXHWND WXUNUSED(hWnd), | |
3752 | WXUINT WXUNUSED(nCtlColor), | |
3753 | WXUINT WXUNUSED(message), | |
3754 | WXWPARAM WXUNUSED(wParam), | |
3755 | WXLPARAM WXUNUSED(lParam)) | |
0e320a79 | 3756 | { |
cdf1e714 | 3757 | return (WXHBRUSH)0; |
0e320a79 DW |
3758 | } |
3759 | ||
0367c1c0 | 3760 | bool wxWindowOS2::HandlePaletteChanged() |
0e320a79 | 3761 | { |
61243a51 DW |
3762 | // need to set this to something first |
3763 | WXHWND hWndPalChange = NULLHANDLE; | |
cdf1e714 | 3764 | |
61243a51 DW |
3765 | wxPaletteChangedEvent vEvent(GetId()); |
3766 | ||
3767 | vEvent.SetEventObject(this); | |
3768 | vEvent.SetChangedWindow(wxFindWinFromHandle(hWndPalChange)); | |
0e320a79 | 3769 | |
61243a51 | 3770 | return GetEventHandler()->ProcessEvent(vEvent); |
0367c1c0 | 3771 | } // end of wxWindowOS2::HandlePaletteChanged |
61243a51 | 3772 | |
61243a51 | 3773 | // |
cdf1e714 | 3774 | // Responds to colour changes: passes event on to children. |
61243a51 | 3775 | // |
0367c1c0 | 3776 | void wxWindowOS2::OnSysColourChanged( |
61243a51 DW |
3777 | wxSysColourChangedEvent& rEvent |
3778 | ) | |
0e320a79 | 3779 | { |
61243a51 DW |
3780 | wxNode* pNode = GetChildren().First(); |
3781 | ||
3782 | while (pNode) | |
cdf1e714 | 3783 | { |
61243a51 | 3784 | // |
cdf1e714 | 3785 | // Only propagate to non-top-level windows |
61243a51 DW |
3786 | // |
3787 | wxWindow* pWin = (wxWindow *)pNode->Data(); | |
3788 | ||
3789 | if (pWin->GetParent()) | |
cdf1e714 | 3790 | { |
61243a51 | 3791 | wxSysColourChangedEvent vEvent; |
cdf1e714 | 3792 | |
61243a51 DW |
3793 | rEvent.m_eventObject = pWin; |
3794 | pWin->GetEventHandler()->ProcessEvent(vEvent); | |
3795 | } | |
3796 | pNode = pNode->Next(); | |
cdf1e714 | 3797 | } |
0367c1c0 | 3798 | } // end of wxWindowOS2::OnSysColourChanged |
0e320a79 | 3799 | |
cdf1e714 DW |
3800 | // --------------------------------------------------------------------------- |
3801 | // painting | |
3802 | // --------------------------------------------------------------------------- | |
3803 | ||
b45bca40 DW |
3804 | void wxWindow::OnPaint ( |
3805 | wxPaintEvent& rEvent | |
3806 | ) | |
3807 | { | |
3808 | HDC hDC = (HDC)wxPaintDC::FindDCInCache((wxWindow*) rEvent.GetEventObject()); | |
3809 | ||
3810 | if (hDC != 0) | |
3811 | { | |
3812 | OS2DefWindowProc( (WXUINT)WM_PAINT | |
3813 | ,(WXWPARAM)hDC | |
3814 | ,(WXLPARAM)0 | |
3815 | ); | |
3816 | } | |
3817 | } // end of wxWindow::OnPaint | |
3818 | ||
0367c1c0 | 3819 | bool wxWindowOS2::HandlePaint() |
0e320a79 | 3820 | { |
19193a2c KB |
3821 | HRGN hRgn; |
3822 | wxPaintEvent vEvent(m_windowId); | |
40bd6154 DW |
3823 | HPS hPS; |
3824 | RECTL vRect; | |
19193a2c KB |
3825 | bool bProcessed; |
3826 | ||
3827 | // Create empty region | |
3828 | // TODO: get HPS somewhere else if possible | |
3829 | hPS = ::WinGetPS(GetHwnd()); | |
3830 | hRgn = ::GpiCreateRegion(hPS, 0, NULL); | |
61243a51 | 3831 | |
19193a2c | 3832 | if (::WinQueryUpdateRegion(GetHwnd(), hRgn) == RGN_ERROR) |
61243a51 DW |
3833 | { |
3834 | wxLogLastError("CreateRectRgn"); | |
3835 | return FALSE; | |
3836 | } | |
7e99520b | 3837 | |
19193a2c KB |
3838 | m_updateRegion = wxRegion(hRgn, hPS); |
3839 | ||
61243a51 | 3840 | vEvent.SetEventObject(this); |
19193a2c KB |
3841 | bProcessed = GetEventHandler()->ProcessEvent(vEvent); |
3842 | ||
524d72c4 DW |
3843 | if (!bProcessed && |
3844 | IsKindOf(CLASSINFO(wxPanel)) && | |
3845 | GetChildren().GetCount() == 0 | |
3846 | ) | |
3847 | { | |
3848 | // | |
3849 | // OS/2 needs to process this right here, not by the default proc | |
f289196b DW |
3850 | // Window's default proc correctly paints everything, OS/2 does not. |
3851 | // For decorative panels that typically have no children, we draw | |
3852 | // borders. | |
524d72c4 DW |
3853 | // |
3854 | HPS hPS; | |
3855 | RECTL vRect; | |
3856 | wxFrame* pFrame; | |
3857 | wxWindow* pParent; | |
3858 | ||
3859 | hPS = ::WinBeginPaint( GetHwnd() | |
3860 | ,NULLHANDLE | |
3861 | ,&vRect | |
3862 | ); | |
3863 | if(hPS) | |
3864 | { | |
3865 | ::GpiCreateLogColorTable( hPS | |
3866 | ,0L | |
3867 | ,LCOLF_CONSECRGB | |
3868 | ,0L | |
3869 | ,(LONG)wxTheColourDatabase->m_nSize | |
3870 | ,(PLONG)wxTheColourDatabase->m_palTable | |
3871 | ); | |
3872 | ::GpiCreateLogColorTable( hPS | |
3873 | ,0L | |
3874 | ,LCOLF_RGB | |
3875 | ,0L | |
3876 | ,0L | |
3877 | ,NULL | |
3878 | ); | |
1de4baa3 | 3879 | if (::WinIsWindowVisible(GetHWND())) |
f289196b | 3880 | ::WinFillRect(hPS, &vRect, GetBackgroundColour().GetPixel()); |
1de4baa3 DW |
3881 | if (m_dwExStyle) |
3882 | { | |
3883 | LINEBUNDLE vLineBundle; | |
3884 | ||
3885 | vLineBundle.lColor = 0x00000000; // Black | |
3886 | vLineBundle.usMixMode = FM_OVERPAINT; | |
3887 | vLineBundle.fxWidth = 1; | |
3888 | vLineBundle.lGeomWidth = 1; | |
3889 | vLineBundle.usType = LINETYPE_SOLID; | |
3890 | vLineBundle.usEnd = 0; | |
3891 | vLineBundle.usJoin = 0; | |
3892 | ::GpiSetAttrs( hPS | |
3893 | ,PRIM_LINE | |
3894 | ,LBB_COLOR | LBB_MIX_MODE | LBB_WIDTH | LBB_GEOM_WIDTH | LBB_TYPE | |
3895 | ,0L | |
3896 | ,&vLineBundle | |
3897 | ); | |
3898 | ::WinQueryWindowRect(GetHwnd(), &vRect); | |
3899 | wxDrawBorder( hPS | |
3900 | ,vRect | |
3901 | ,m_dwExStyle | |
3902 | ); | |
524d72c4 | 3903 | } |
524d72c4 | 3904 | } |
f289196b | 3905 | ::WinEndPaint(hPS); |
524d72c4 DW |
3906 | bProcessed = TRUE; |
3907 | } | |
f289196b DW |
3908 | else if (!bProcessed && |
3909 | IsKindOf(CLASSINFO(wxPanel)) | |
3910 | ) | |
3911 | { | |
3912 | // | |
3913 | // Panel with children, usually fills a frame client so no borders. | |
3914 | // | |
3915 | HPS hPS; | |
3916 | RECTL vRect; | |
3917 | wxFrame* pFrame; | |
3918 | wxWindow* pParent; | |
524d72c4 | 3919 | |
f289196b DW |
3920 | hPS = ::WinBeginPaint( GetHwnd() |
3921 | ,NULLHANDLE | |
3922 | ,&vRect | |
3923 | ); | |
3924 | if(hPS) | |
3925 | { | |
3926 | ::GpiCreateLogColorTable( hPS | |
3927 | ,0L | |
3928 | ,LCOLF_CONSECRGB | |
3929 | ,0L | |
3930 | ,(LONG)wxTheColourDatabase->m_nSize | |
3931 | ,(PLONG)wxTheColourDatabase->m_palTable | |
3932 | ); | |
3933 | ::GpiCreateLogColorTable( hPS | |
3934 | ,0L | |
3935 | ,LCOLF_RGB | |
3936 | ,0L | |
3937 | ,0L | |
3938 | ,NULL | |
3939 | ); | |
3940 | ||
1de4baa3 | 3941 | if (::WinIsWindowVisible(GetHWND())) |
f289196b DW |
3942 | ::WinFillRect(hPS, &vRect, GetBackgroundColour().GetPixel()); |
3943 | } | |
3944 | ::WinEndPaint(hPS); | |
3945 | bProcessed = TRUE; | |
3946 | } | |
524d72c4 | 3947 | return bProcessed; |
0367c1c0 | 3948 | } // end of wxWindowOS2::HandlePaint |
0e320a79 | 3949 | |
0367c1c0 | 3950 | bool wxWindowOS2::HandleEraseBkgnd( |
8d854fa9 DW |
3951 | WXHDC hDC |
3952 | ) | |
0e320a79 | 3953 | { |
8d854fa9 | 3954 | SWP vSwp; |
19193a2c | 3955 | bool rc; |
8d854fa9 DW |
3956 | |
3957 | ::WinQueryWindowPos(GetHwnd(), &vSwp); | |
3958 | if (vSwp.fl & SWP_MINIMIZE) | |
61243a51 | 3959 | return TRUE; |
cdf1e714 | 3960 | |
8d854fa9 DW |
3961 | wxDC vDC; |
3962 | ||
3963 | vDC.m_hPS = (HPS)hDC; // this is really a PS | |
19193a2c | 3964 | vDC.SetWindow((wxWindow*)this); |
8d854fa9 | 3965 | vDC.BeginDrawing(); |
cdf1e714 | 3966 | |
8d854fa9 DW |
3967 | wxEraseEvent vEvent(m_windowId, &vDC); |
3968 | ||
3969 | vEvent.SetEventObject(this); | |
cdf1e714 | 3970 | |
19193a2c | 3971 | rc = GetEventHandler()->ProcessEvent(vEvent); |
cdf1e714 | 3972 | |
8d854fa9 DW |
3973 | vDC.EndDrawing(); |
3974 | vDC.m_hPS = NULLHANDLE; | |
61243a51 | 3975 | return TRUE; |
0367c1c0 | 3976 | } // end of wxWindowOS2::HandleEraseBkgnd |
cdf1e714 | 3977 | |
0367c1c0 | 3978 | void wxWindowOS2::OnEraseBackground( |
61243a51 DW |
3979 | wxEraseEvent& rEvent |
3980 | ) | |
0e320a79 | 3981 | { |
8d854fa9 DW |
3982 | RECTL vRect; |
3983 | HPS hPS = rEvent.m_dc->m_hPS; | |
19193a2c KB |
3984 | APIRET rc; |
3985 | LONG lColor = m_backgroundColour.GetPixel(); | |
8d854fa9 | 3986 | |
19193a2c KB |
3987 | rc = ::WinQueryWindowRect(GetHwnd(), &vRect); |
3988 | rc = ::WinFillRect(hPS, &vRect, lColor); | |
0367c1c0 | 3989 | } // end of wxWindowOS2::OnEraseBackground |
0e320a79 | 3990 | |
cdf1e714 DW |
3991 | // --------------------------------------------------------------------------- |
3992 | // moving and resizing | |
3993 | // --------------------------------------------------------------------------- | |
0e320a79 | 3994 | |
0367c1c0 | 3995 | bool wxWindowOS2::HandleMinimize() |
0e320a79 | 3996 | { |
61243a51 | 3997 | wxIconizeEvent vEvent(m_windowId); |
cdf1e714 | 3998 | |
61243a51 DW |
3999 | vEvent.SetEventObject(this); |
4000 | return GetEventHandler()->ProcessEvent(vEvent); | |
0367c1c0 | 4001 | } // end of wxWindowOS2::HandleMinimize |
0e320a79 | 4002 | |
0367c1c0 | 4003 | bool wxWindowOS2::HandleMaximize() |
0e320a79 | 4004 | { |
61243a51 | 4005 | wxMaximizeEvent vEvent(m_windowId); |
cdf1e714 | 4006 | |
61243a51 DW |
4007 | vEvent.SetEventObject(this); |
4008 | return GetEventHandler()->ProcessEvent(vEvent); | |
0367c1c0 | 4009 | } // end of wxWindowOS2::HandleMaximize |
0e320a79 | 4010 | |
0367c1c0 | 4011 | bool wxWindowOS2::HandleMove( |
61243a51 DW |
4012 | int nX |
4013 | , int nY | |
4014 | ) | |
0e320a79 | 4015 | { |
19193a2c | 4016 | wxMoveEvent vEvent(wxPoint(nX, nY), m_windowId); |
cdf1e714 | 4017 | |
61243a51 DW |
4018 | vEvent.SetEventObject(this); |
4019 | return GetEventHandler()->ProcessEvent(vEvent); | |
0367c1c0 | 4020 | } // end of wxWindowOS2::HandleMove |
0e320a79 | 4021 | |
0367c1c0 | 4022 | bool wxWindowOS2::HandleSize( |
61243a51 DW |
4023 | int nWidth |
4024 | , int nHeight | |
4025 | , WXUINT WXUNUSED(nFlag) | |
4026 | ) | |
0e320a79 | 4027 | { |
19193a2c | 4028 | wxSizeEvent vEvent(wxSize(nWidth, nHeight), m_windowId); |
cdf1e714 | 4029 | |
61243a51 DW |
4030 | vEvent.SetEventObject(this); |
4031 | return GetEventHandler()->ProcessEvent(vEvent); | |
0367c1c0 | 4032 | } // end of wxWindowOS2::HandleSize |
0e320a79 | 4033 | |
0367c1c0 | 4034 | bool wxWindowOS2::HandleGetMinMaxInfo( |
61243a51 DW |
4035 | PSWP pSwp |
4036 | ) | |
0e320a79 | 4037 | { |
61243a51 DW |
4038 | bool bRc = FALSE; |
4039 | POINTL vPoint; | |
cdf1e714 | 4040 | |
61243a51 | 4041 | switch(pSwp->fl) |
cdf1e714 | 4042 | { |
61243a51 DW |
4043 | case SWP_MAXIMIZE: |
4044 | ::WinGetMaxPosition(GetHwnd(), pSwp); | |
4045 | m_maxWidth = pSwp->cx; | |
4046 | m_maxHeight = pSwp->cy; | |
4047 | break; | |
cdf1e714 | 4048 | |
61243a51 DW |
4049 | case SWP_MINIMIZE: |
4050 | ::WinGetMinPosition(GetHwnd(), pSwp, &vPoint); | |
4051 | m_minWidth = pSwp->cx; | |
4052 | m_minHeight = pSwp->cy; | |
4053 | break; | |
cdf1e714 | 4054 | |
61243a51 DW |
4055 | default: |
4056 | return FALSE; | |
cdf1e714 | 4057 | } |
61243a51 | 4058 | return TRUE; |
0367c1c0 | 4059 | } // end of wxWindowOS2::HandleGetMinMaxInfo |
0e320a79 | 4060 | |
cdf1e714 DW |
4061 | // --------------------------------------------------------------------------- |
4062 | // command messages | |
4063 | // --------------------------------------------------------------------------- | |
0367c1c0 | 4064 | bool wxWindowOS2::HandleCommand( |
61243a51 DW |
4065 | WXWORD wId |
4066 | , WXWORD wCmd | |
4067 | , WXHWND hControl | |
4068 | ) | |
0e320a79 | 4069 | { |
19193a2c | 4070 | #if wxUSE_MENUS_NATIVE |
61243a51 | 4071 | if (wxCurrentPopupMenu) |
0e320a79 | 4072 | { |
61243a51 | 4073 | wxMenu* pPopupMenu = wxCurrentPopupMenu; |
0e320a79 | 4074 | |
61243a51 DW |
4075 | wxCurrentPopupMenu = NULL; |
4076 | return pPopupMenu->OS2Command(wCmd, wId); | |
cdf1e714 | 4077 | } |
19193a2c | 4078 | #endif // wxUSE_MENUS_NATIVE |
0e320a79 | 4079 | |
61243a51 DW |
4080 | wxWindow* pWin = FindItem(wId); |
4081 | ||
4082 | if (!pWin) | |
cdf1e714 | 4083 | { |
61243a51 | 4084 | pWin = wxFindWinFromHandle(hControl); |
0e320a79 | 4085 | } |
cdf1e714 | 4086 | |
61243a51 | 4087 | if (pWin) |
19193a2c KB |
4088 | return pWin->OS2Command(wCmd, wId); |
4089 | ||
cdf1e714 | 4090 | return FALSE; |
0367c1c0 | 4091 | } // end of wxWindowOS2::HandleCommand |
de44a9f0 | 4092 | |
0367c1c0 | 4093 | bool wxWindowOS2::HandleSysCommand( |
61243a51 | 4094 | WXWPARAM wParam |
19193a2c | 4095 | , WXLPARAM WXUNUSED(lParam) |
61243a51 | 4096 | ) |
0e320a79 | 4097 | { |
61243a51 DW |
4098 | // |
4099 | // 4 bits are reserved | |
4100 | // | |
4101 | switch (SHORT1FROMMP(wParam)) | |
4102 | { | |
4103 | case SC_MAXIMIZE: | |
4104 | return HandleMaximize(); | |
4105 | ||
4106 | case SC_MINIMIZE: | |
4107 | return HandleMinimize(); | |
4108 | } | |
cdf1e714 | 4109 | return FALSE; |
0367c1c0 | 4110 | } // end of wxWindowOS2::HandleSysCommand |
cdf1e714 DW |
4111 | |
4112 | // --------------------------------------------------------------------------- | |
4113 | // mouse events | |
4114 | // --------------------------------------------------------------------------- | |
19193a2c | 4115 | //TODO!!! check against MSW |
0367c1c0 | 4116 | void wxWindowOS2::InitMouseEvent( |
61243a51 DW |
4117 | wxMouseEvent& rEvent |
4118 | , int nX | |
4119 | , int nY | |
4120 | , WXUINT uFlags | |
4121 | ) | |
cdf1e714 | 4122 | { |
61243a51 DW |
4123 | rEvent.m_x = nX; |
4124 | rEvent.m_y = nY; | |
4125 | rEvent.m_shiftDown = ((uFlags & VK_SHIFT) != 0); | |
4126 | rEvent.m_controlDown = ((uFlags & VK_CTRL) != 0); | |
4127 | rEvent.m_leftDown = ((uFlags & VK_BUTTON1) != 0); | |
4128 | rEvent.m_middleDown = ((uFlags & VK_BUTTON3) != 0); | |
4129 | rEvent.m_rightDown = ((uFlags & VK_BUTTON2) != 0); | |
4130 | rEvent.SetTimestamp(s_currentMsg.time); | |
4131 | rEvent.m_eventObject = this; | |
6ed98c6a | 4132 | rEvent.SetId(GetId()); |
cdf1e714 DW |
4133 | |
4134 | #if wxUSE_MOUSEEVENT_HACK | |
61243a51 DW |
4135 | m_lastMouseX = nX; |
4136 | m_lastMouseY = nY; | |
4137 | m_lastMouseEvent = rEvent.GetEventType(); | |
cdf1e714 | 4138 | #endif // wxUSE_MOUSEEVENT_HACK |
0367c1c0 | 4139 | } // end of wxWindowOS2::InitMouseEvent |
0e320a79 | 4140 | |
0367c1c0 | 4141 | bool wxWindowOS2::HandleMouseEvent( |
61243a51 DW |
4142 | WXUINT uMsg |
4143 | , int nX | |
4144 | , int nY | |
4145 | , WXUINT uFlags | |
4146 | ) | |
0e320a79 | 4147 | { |
b389a12d DW |
4148 | bool bProcessed = FALSE; |
4149 | ||
61243a51 DW |
4150 | // |
4151 | // The mouse events take consecutive IDs from WM_MOUSEFIRST to | |
cdf1e714 DW |
4152 | // WM_MOUSELAST, so it's enough to substract WM_MOUSEMOVE == WM_MOUSEFIRST |
4153 | // from the message id and take the value in the table to get wxWin event | |
4154 | // id | |
61243a51 | 4155 | // |
cdf1e714 DW |
4156 | static const wxEventType eventsMouse[] = |
4157 | { | |
4158 | wxEVT_MOTION, | |
4159 | wxEVT_LEFT_DOWN, | |
4160 | wxEVT_LEFT_UP, | |
4161 | wxEVT_LEFT_DCLICK, | |
4162 | wxEVT_RIGHT_DOWN, | |
4163 | wxEVT_RIGHT_UP, | |
4164 | wxEVT_RIGHT_DCLICK, | |
4165 | wxEVT_MIDDLE_DOWN, | |
4166 | wxEVT_MIDDLE_UP, | |
4167 | wxEVT_MIDDLE_DCLICK | |
4168 | }; | |
4169 | ||
61243a51 | 4170 | wxMouseEvent vEvent(eventsMouse[uMsg - WM_MOUSEMOVE]); |
cdf1e714 | 4171 | |
61243a51 DW |
4172 | InitMouseEvent( vEvent |
4173 | ,nX | |
4174 | ,nY | |
4175 | ,uFlags | |
4176 | ); | |
0e320a79 | 4177 | |
b389a12d DW |
4178 | bProcessed = GetEventHandler()->ProcessEvent(vEvent); |
4179 | if (!bProcessed) | |
4180 | { | |
4181 | HPOINTER hPtr = ::WinQuerySysPointer(HWND_DESKTOP, SPTR_WAIT, FALSE); | |
4182 | HPOINTER hCursor = (HPOINTER)GetCursor().GetHCURSOR(); | |
4183 | ||
4184 | if (hCursor != NULLHANDLE) | |
4185 | { | |
4186 | ::WinSetPointer(HWND_DESKTOP, hCursor); | |
4187 | bProcessed = TRUE; | |
4188 | } | |
4189 | } | |
61243a51 | 4190 | return GetEventHandler()->ProcessEvent(vEvent); |
0367c1c0 | 4191 | } // end of wxWindowOS2::HandleMouseEvent |
61243a51 | 4192 | |
0367c1c0 | 4193 | bool wxWindowOS2::HandleMouseMove( |
61243a51 DW |
4194 | int nX |
4195 | , int nY | |
4196 | , WXUINT uFlags | |
4197 | ) | |
0e320a79 | 4198 | { |
61243a51 | 4199 | if (!m_bMouseInWindow) |
cdf1e714 | 4200 | { |
61243a51 | 4201 | // |
cdf1e714 | 4202 | // Generate an ENTER event |
61243a51 | 4203 | // |
776d87d5 | 4204 | m_bMouseInWindow = TRUE; |
cdf1e714 | 4205 | |
61243a51 | 4206 | wxMouseEvent vEvent(wxEVT_ENTER_WINDOW); |
cdf1e714 | 4207 | |
61243a51 DW |
4208 | InitMouseEvent( vEvent |
4209 | ,nX | |
4210 | ,nY | |
4211 | ,uFlags | |
4212 | ); | |
cdf1e714 | 4213 | |
61243a51 | 4214 | (void)GetEventHandler()->ProcessEvent(vEvent); |
cdf1e714 | 4215 | } |
61243a51 DW |
4216 | return HandleMouseEvent( WM_MOUSEMOVE |
4217 | ,nX | |
4218 | ,nY | |
4219 | ,uFlags | |
4220 | ); | |
0367c1c0 | 4221 | } // end of wxWindowOS2::HandleMouseMove |
0e320a79 | 4222 | |
cdf1e714 DW |
4223 | // --------------------------------------------------------------------------- |
4224 | // keyboard handling | |
4225 | // --------------------------------------------------------------------------- | |
4226 | ||
61243a51 DW |
4227 | // |
4228 | // Create the key event of the given type for the given key - used by | |
4229 | // HandleChar and HandleKeyDown/Up | |
4230 | // | |
0367c1c0 | 4231 | wxKeyEvent wxWindowOS2::CreateKeyEvent( |
61243a51 DW |
4232 | wxEventType eType |
4233 | , int nId | |
4234 | , WXLPARAM lParam | |
a086de98 | 4235 | , WXWPARAM wParam |
61243a51 DW |
4236 | ) const |
4237 | { | |
4238 | wxKeyEvent vEvent(eType); | |
4239 | ||
4240 | vEvent.SetId(GetId()); | |
4241 | vEvent.m_shiftDown = IsShiftDown(); | |
4242 | vEvent.m_controlDown = IsCtrlDown(); | |
4243 | vEvent.m_altDown = (HIWORD(lParam) & KC_ALT) == KC_ALT; | |
4244 | ||
4245 | vEvent.m_eventObject = (wxWindow *)this; // const_cast | |
4246 | vEvent.m_keyCode = nId; | |
a086de98 DW |
4247 | vEvent.m_rawCode = (wxUint32)wParam; |
4248 | vEvent.m_rawFlags = (wxUint32)lParam; | |
61243a51 DW |
4249 | vEvent.SetTimestamp(s_currentMsg.time); |
4250 | ||
4251 | // | |
4252 | // Translate the position to client coords | |
4253 | // | |
4254 | POINTL vPoint; | |
4255 | RECTL vRect; | |
4256 | ||
4257 | ::WinQueryPointerPos(HWND_DESKTOP, &vPoint); | |
4258 | ::WinQueryWindowRect( GetHwnd() | |
4259 | ,&vRect | |
4260 | ); | |
4261 | ||
4262 | vPoint.x -= vRect.xLeft; | |
4263 | vPoint.y -= vRect.yBottom; | |
4264 | ||
4265 | vEvent.m_x = vPoint.x; | |
4266 | vEvent.m_y = vPoint.y; | |
4267 | ||
4268 | return vEvent; | |
0367c1c0 | 4269 | } // end of wxWindowOS2::CreateKeyEvent |
61243a51 DW |
4270 | |
4271 | // | |
cdf1e714 DW |
4272 | // isASCII is TRUE only when we're called from WM_CHAR handler and not from |
4273 | // WM_KEYDOWN one | |
61243a51 | 4274 | // |
0367c1c0 | 4275 | bool wxWindowOS2::HandleChar( |
598d8cac | 4276 | WXWPARAM wParam |
61243a51 DW |
4277 | , WXLPARAM lParam |
4278 | , bool isASCII | |
4279 | ) | |
86de7616 | 4280 | { |
61243a51 DW |
4281 | bool bCtrlDown = FALSE; |
4282 | int vId; | |
4283 | ||
3437f881 DW |
4284 | if (m_bLastKeydownProcessed) |
4285 | { | |
4286 | // | |
4287 | // The key was handled in the EVT_KEY_DOWN. Handling a key in an | |
4288 | // EVT_KEY_DOWN handler is meant, by design, to prevent EVT_CHARs | |
4289 | // from happening, so just bail out at this point. | |
4290 | // | |
4291 | m_bLastKeydownProcessed = FALSE; | |
4292 | return TRUE; | |
4293 | } | |
61243a51 DW |
4294 | if (isASCII) |
4295 | { | |
4296 | // | |
a23692f0 DW |
4297 | // If 1 -> 26, translate to either special keycode or just set |
4298 | // ctrlDown. IOW, Ctrl-C should result in keycode == 3 and | |
4299 | // ControlDown() == TRUE. | |
61243a51 | 4300 | // |
1de4baa3 | 4301 | vId = SHORT1FROMMP(lParam); |
61243a51 DW |
4302 | if ((vId > 0) && (vId < 27)) |
4303 | { | |
4304 | switch (vId) | |
4305 | { | |
4306 | case 13: | |
4307 | vId = WXK_RETURN; | |
4308 | break; | |
4309 | ||
4310 | case 8: | |
4311 | vId = WXK_BACK; | |
4312 | break; | |
4313 | ||
4314 | case 9: | |
4315 | vId = WXK_TAB; | |
4316 | break; | |
4317 | ||
4318 | default: | |
4319 | bCtrlDown = TRUE; | |
a23692f0 | 4320 | break; |
61243a51 DW |
4321 | } |
4322 | } | |
4323 | } | |
a086de98 | 4324 | else // we're called from WM_KEYDOWN |
61243a51 | 4325 | { |
1de4baa3 | 4326 | vId = wxCharCodeOS2ToWX((int)SHORT2FROMMP(lParam)); |
a086de98 DW |
4327 | if (vId == 0) |
4328 | return FALSE; | |
61243a51 DW |
4329 | } |
4330 | ||
a086de98 | 4331 | wxKeyEvent vEvent(CreateKeyEvent( wxEVT_CHAR |
61243a51 DW |
4332 | ,vId |
4333 | ,lParam | |
4334 | )); | |
4335 | ||
a086de98 DW |
4336 | if (bCtrlDown) |
4337 | { | |
4338 | vEvent.m_controlDown = TRUE; | |
61243a51 | 4339 | } |
a086de98 | 4340 | return (GetEventHandler()->ProcessEvent(vEvent)); |
cdf1e714 | 4341 | } |
86de7616 | 4342 | |
0367c1c0 | 4343 | bool wxWindowOS2::HandleKeyDown( |
a086de98 | 4344 | WXWPARAM wParam |
61243a51 DW |
4345 | , WXLPARAM lParam |
4346 | ) | |
cdf1e714 | 4347 | { |
1de4baa3 | 4348 | int nId = wxCharCodeOS2ToWX((int)SHORT2FROMMP(lParam)); |
86de7616 | 4349 | |
61243a51 DW |
4350 | if (!nId) |
4351 | { | |
4352 | // | |
4353 | // Normal ASCII char | |
4354 | // | |
1de4baa3 | 4355 | nId = SHORT1FROMMP(lParam); |
61243a51 DW |
4356 | } |
4357 | ||
4358 | if (nId != -1) | |
4359 | { | |
4360 | wxKeyEvent vEvent(CreateKeyEvent( wxEVT_KEY_DOWN | |
4361 | ,nId | |
a086de98 DW |
4362 | ,(MPARAM)lParam |
4363 | ,(MPARAM)wParam | |
61243a51 DW |
4364 | )); |
4365 | ||
4366 | if (GetEventHandler()->ProcessEvent(vEvent)) | |
4367 | { | |
4368 | return TRUE; | |
4369 | } | |
4370 | } | |
4371 | return FALSE; | |
0367c1c0 | 4372 | } // end of wxWindowOS2::HandleKeyDown |
61243a51 | 4373 | |
0367c1c0 | 4374 | bool wxWindowOS2::HandleKeyUp( |
a086de98 | 4375 | WXWPARAM wParam |
61243a51 DW |
4376 | , WXLPARAM lParam |
4377 | ) | |
86de7616 | 4378 | { |
1de4baa3 | 4379 | int nId = wxCharCodeOS2ToWX((int)SHORT2FROMMP(lParam)); |
61243a51 DW |
4380 | |
4381 | if (!nId) | |
4382 | { | |
4383 | // | |
4384 | // Normal ASCII char | |
4385 | // | |
a086de98 | 4386 | nId = (int)wParam; |
61243a51 DW |
4387 | } |
4388 | ||
4389 | if (nId != -1) | |
4390 | { | |
4391 | wxKeyEvent vEvent(CreateKeyEvent( wxEVT_KEY_UP | |
4392 | ,nId | |
4393 | ,lParam | |
a086de98 | 4394 | ,wParam |
61243a51 DW |
4395 | )); |
4396 | ||
4397 | if (GetEventHandler()->ProcessEvent(vEvent)) | |
4398 | return TRUE; | |
4399 | } | |
4400 | return FALSE; | |
0367c1c0 | 4401 | } // end of wxWindowOS2::HandleKeyUp |
86de7616 | 4402 | |
cdf1e714 DW |
4403 | // --------------------------------------------------------------------------- |
4404 | // joystick | |
4405 | // --------------------------------------------------------------------------- | |
86de7616 | 4406 | |
cdf1e714 DW |
4407 | // --------------------------------------------------------------------------- |
4408 | // scrolling | |
4409 | // --------------------------------------------------------------------------- | |
4410 | ||
0367c1c0 | 4411 | bool wxWindowOS2::OS2OnScroll( |
61243a51 DW |
4412 | int nOrientation |
4413 | , WXWORD wParam | |
4414 | , WXWORD wPos | |
4415 | , WXHWND hControl | |
4416 | ) | |
cdf1e714 | 4417 | { |
61243a51 | 4418 | if (hControl) |
86de7616 | 4419 | { |
61243a51 DW |
4420 | wxWindow* pChild = wxFindWinFromHandle(hControl); |
4421 | ||
4422 | if (pChild ) | |
4423 | return pChild->OS2OnScroll( nOrientation | |
4424 | ,wParam | |
4425 | ,wPos | |
4426 | ,hControl | |
4427 | ); | |
cdf1e714 | 4428 | } |
86de7616 | 4429 | |
61243a51 DW |
4430 | wxScrollWinEvent vEvent; |
4431 | ||
4432 | vEvent.SetPosition(wPos); | |
4433 | vEvent.SetOrientation(nOrientation); | |
4434 | vEvent.m_eventObject = this; | |
4435 | ||
4436 | switch (wParam) | |
4437 | { | |
4438 | case SB_LINEUP: | |
4439 | vEvent.m_eventType = wxEVT_SCROLLWIN_LINEUP; | |
4440 | break; | |
4441 | ||
4442 | case SB_LINEDOWN: | |
4443 | vEvent.m_eventType = wxEVT_SCROLLWIN_LINEDOWN; | |
4444 | break; | |
4445 | ||
4446 | case SB_PAGEUP: | |
4447 | vEvent.m_eventType = wxEVT_SCROLLWIN_PAGEUP; | |
4448 | break; | |
4449 | ||
4450 | case SB_PAGEDOWN: | |
4451 | vEvent.m_eventType = wxEVT_SCROLLWIN_PAGEDOWN; | |
4452 | break; | |
4453 | ||
4454 | case SB_SLIDERPOSITION: | |
4455 | vEvent.m_eventType = wxEVT_SCROLLWIN_THUMBRELEASE; | |
4456 | break; | |
4457 | ||
4458 | case SB_SLIDERTRACK: | |
4459 | vEvent.m_eventType = wxEVT_SCROLLWIN_THUMBTRACK; | |
4460 | break; | |
4461 | ||
4462 | default: | |
4463 | return FALSE; | |
4464 | } | |
4465 | return GetEventHandler()->ProcessEvent(vEvent); | |
0367c1c0 | 4466 | } // end of wxWindowOS2::OS2OnScroll |
86de7616 | 4467 | |
d8a3f66c DW |
4468 | void wxWindowOS2::MoveChildren( |
4469 | int nDiff | |
4470 | ) | |
4471 | { | |
5efff147 DW |
4472 | // |
4473 | // We want to handle top levels ourself, manually | |
4474 | // | |
4475 | if (!IsTopLevel() && GetAutoLayout()) | |
d8a3f66c | 4476 | { |
f289196b DW |
4477 | Layout(); |
4478 | } | |
4479 | else | |
4480 | { | |
4481 | SWP vSwp; | |
d8a3f66c | 4482 | |
f289196b DW |
4483 | for (wxWindowList::Node* pNode = GetChildren().GetFirst(); |
4484 | pNode; | |
4485 | pNode = pNode->GetNext()) | |
d8a3f66c | 4486 | { |
f289196b | 4487 | wxWindow* pWin = pNode->GetData(); |
d8a3f66c | 4488 | |
f289196b DW |
4489 | ::WinQueryWindowPos( GetHwndOf(pWin) |
4490 | ,&vSwp | |
4491 | ); | |
4492 | if (pWin->IsKindOf(CLASSINFO(wxControl))) | |
4493 | { | |
4494 | wxControl* pCtrl; | |
4495 | ||
4496 | // | |
4497 | // Must deal with controls that have margins like ENTRYFIELD. The SWP | |
4498 | // struct of such a control will have and origin offset from its intended | |
4499 | // position by the width of the margins. | |
4500 | // | |
4501 | pCtrl = wxDynamicCast(pWin, wxControl); | |
4502 | vSwp.y -= pCtrl->GetYComp(); | |
4503 | vSwp.x -= pCtrl->GetXComp(); | |
4504 | } | |
4505 | ::WinSetWindowPos( GetHwndOf(pWin) | |
4506 | ,HWND_TOP | |
4507 | ,vSwp.x | |
4508 | ,vSwp.y - nDiff | |
4509 | ,vSwp.cx | |
4510 | ,vSwp.cy | |
4511 | ,SWP_MOVE | SWP_SHOW | SWP_ZORDER | |
4512 | ); | |
4513 | ::WinQueryWindowPos(GetHwndOf(pWin), pWin->GetSwp()); | |
4514 | if (pWin->IsKindOf(CLASSINFO(wxRadioBox))) | |
4515 | { | |
4516 | wxRadioBox* pRadioBox; | |
4517 | ||
4518 | pRadioBox = wxDynamicCast(pWin, wxRadioBox); | |
4519 | pRadioBox->AdjustButtons( (int)vSwp.x | |
4520 | ,(int)vSwp.y - nDiff | |
4521 | ,(int)vSwp.cx | |
4522 | ,(int)vSwp.cy | |
4523 | ,pRadioBox->GetSizeFlags() | |
4524 | ); | |
4525 | } | |
4526 | if (pWin->IsKindOf(CLASSINFO(wxSlider))) | |
4527 | { | |
4528 | wxSlider* pSlider; | |
4529 | ||
4530 | pSlider = wxDynamicCast(pWin, wxSlider); | |
4531 | pSlider->AdjustSubControls( (int)vSwp.x | |
4532 | ,(int)vSwp.y - nDiff | |
4533 | ,(int)vSwp.cx | |
4534 | ,(int)vSwp.cy | |
4535 | ,(int)pSlider->GetSizeFlags() | |
4536 | ); | |
4537 | } | |
d8a3f66c DW |
4538 | } |
4539 | } | |
4a46a5df | 4540 | Refresh(); |
d8a3f66c DW |
4541 | } // end of wxWindowOS2::MoveChildren |
4542 | ||
4543 | // | |
4544 | // Getting the Y position for a window, like a control, is a real | |
4545 | // pain. There are three sitatuions we must deal with in determining | |
4546 | // the OS2 to wxWindows Y coordinate. | |
4547 | // | |
4548 | // 1) The controls are created in a dialog. | |
4549 | // This is the easiest since a dialog is created with its original | |
4550 | // size so the standard: Y = ParentHeight - (Y + ControlHeight); | |
4551 | // | |
4552 | // 2) The controls are direct children of a frame | |
4553 | // In this instance the controls are actually children of the Frame's | |
4554 | // client. During creation the frame's client resizes several times | |
4555 | // during creation of the status bar and toolbars. The CFrame class | |
4556 | // will take care of this using its AlterChildPos proc. | |
4557 | // | |
4558 | // 3) The controls are children of a panel, which in turn is a child of | |
4559 | // a frame. | |
859e65de DW |
4560 | // The panel may be one of many, in which case the same treatment |
4561 | // as 1 applies. It may be the only child, though. | |
d8a3f66c DW |
4562 | // This is the nastiest case. A panel is created as the only child of |
4563 | // the frame and as such, when a frame has only one child, the child is | |
4564 | // expanded to fit the entire client area of the frame. Because the | |
4565 | // controls are created BEFORE this occurs their positions are totally | |
4566 | // whacked and any call to WinQueryWindowPos will return invalid | |
4567 | // coordinates. So for this situation we have to compare the size of | |
4568 | // the panel at control creation time with that of the frame client. If | |
4569 | // they are the same we can use the standard Y position equation. If | |
4570 | // not, then we must use the Frame Client's dimensions to position them | |
4571 | // as that will be the eventual size of the panel after the frame resizes | |
4572 | // it! | |
4573 | // | |
4574 | int wxWindowOS2::GetOS2ParentHeight( | |
4575 | wxWindowOS2* pParent | |
4576 | ) | |
4577 | { | |
4578 | wxWindowOS2* pGrandParent = NULL; | |
4579 | ||
4580 | // | |
4581 | // Case 1 | |
4582 | // | |
4583 | if (pParent->IsKindOf(CLASSINFO(wxDialog))) | |
e37db699 | 4584 | return(pParent->GetClientSize().y); |
d8a3f66c DW |
4585 | |
4586 | // | |
4587 | // Case 2 -- if we are one of the separately built standard Frame | |
4588 | // children, like a statusbar, menubar, or toolbar we want to | |
4589 | // use the frame, itself, for positioning. Otherwise we are | |
4590 | // child window and want to use the Frame's client. | |
4591 | // | |
4592 | else if (pParent->IsKindOf(CLASSINFO(wxFrame))) | |
4593 | { | |
4594 | if (IsKindOf(CLASSINFO(wxStatusBar)) || | |
4595 | IsKindOf(CLASSINFO(wxMenuBar)) || | |
4596 | IsKindOf(CLASSINFO(wxToolBar)) | |
4597 | ) | |
2590f154 DW |
4598 | { |
4599 | if (IsKindOf(CLASSINFO(wxToolBar))) | |
4600 | { | |
4601 | wxFrame* pFrame = wxDynamicCast(GetParent(), wxFrame); | |
4602 | ||
4603 | if (pFrame->GetToolBar() == this) | |
4604 | return(pParent->GetSize().y); | |
4605 | else | |
4606 | return(pParent->GetClientSize().y); | |
4607 | } | |
4608 | else | |
4609 | return(pParent->GetSize().y); | |
4610 | } | |
d8a3f66c DW |
4611 | else |
4612 | return(pParent->GetClientSize().y); | |
4613 | } | |
d8a3f66c | 4614 | // |
4a46a5df DW |
4615 | // Case -- this is for any window that is the sole child of a Frame. |
4616 | // The grandparent must exist and it must be of type CFrame | |
4617 | // and it's height must be different. Otherwise the standard | |
4618 | // applies. | |
d8a3f66c DW |
4619 | // |
4620 | else | |
4621 | { | |
4a46a5df | 4622 | return(pParent->GetClientSize().y); |
d8a3f66c DW |
4623 | } |
4624 | return(0L); | |
4625 | } // end of wxWindowOS2::GetOS2ParentHeight | |
4626 | ||
45e0dc94 DW |
4627 | // |
4628 | // OS/2 needs a lot extra manipulation to deal with layouts | |
4629 | // for canvas windows, particularly scrolled ones. | |
4630 | // | |
06519806 DW |
4631 | wxWindowCreationHook::wxWindowCreationHook( |
4632 | wxWindow* pWinBeingCreated | |
4633 | ) | |
4634 | { | |
4635 | gpWinBeingCreated = pWinBeingCreated; | |
4636 | } // end of wxWindowCreationHook::wxWindowCreationHook | |
4637 | ||
4638 | wxWindowCreationHook::~wxWindowCreationHook() | |
4639 | { | |
4640 | gpWinBeingCreated = NULL; | |
4641 | } // end of wxWindowCreationHook::~wxWindowCreationHook | |
4642 | ||
cdf1e714 DW |
4643 | // =========================================================================== |
4644 | // global functions | |
4645 | // =========================================================================== | |
4646 | ||
61243a51 | 4647 | void wxGetCharSize( |
987da0d4 DW |
4648 | WXHWND hWnd |
4649 | , int* pX | |
4650 | , int* pY | |
19193a2c | 4651 | ,wxFont* WXUNUSED(pTheFont) |
61243a51 | 4652 | ) |
cdf1e714 | 4653 | { |
987da0d4 DW |
4654 | FONTMETRICS vFM; |
4655 | HPS hPS; | |
4656 | BOOL rc; | |
4657 | ||
4658 | hPS =::WinGetPS(hWnd); | |
4659 | ||
4660 | rc = ::GpiQueryFontMetrics(hPS, sizeof(FONTMETRICS), &vFM); | |
4661 | if (rc) | |
4662 | { | |
4663 | if (pX) | |
4664 | *pX = vFM.lAveCharWidth; | |
4665 | if (pY) | |
4666 | *pY = vFM.lEmHeight + vFM.lExternalLeading; | |
4667 | } | |
4668 | else | |
4669 | { | |
4670 | if (pX) | |
4671 | *pX = 10; | |
4672 | if (pY) | |
4673 | *pY = 15; | |
4674 | } | |
4675 | ::WinReleasePS(hPS); | |
61243a51 | 4676 | } // end of wxGetCharSize |
cdf1e714 | 4677 | |
61243a51 | 4678 | // |
cdf1e714 DW |
4679 | // Returns 0 if was a normal ASCII value, not a special key. This indicates that |
4680 | // the key should be ignored by WM_KEYDOWN and processed by WM_CHAR instead. | |
61243a51 DW |
4681 | // |
4682 | int wxCharCodeOS2ToWX( | |
4683 | int nKeySym | |
4684 | ) | |
cdf1e714 | 4685 | { |
61243a51 DW |
4686 | int nId = 0; |
4687 | ||
4688 | switch (nKeySym) | |
4689 | { | |
4690 | case VK_BACKTAB: nId = WXK_BACK; break; | |
4691 | case VK_TAB: nId = WXK_TAB; break; | |
4692 | case VK_CLEAR: nId = WXK_CLEAR; break; | |
4693 | case VK_ENTER: nId = WXK_RETURN; break; | |
4694 | case VK_SHIFT: nId = WXK_SHIFT; break; | |
4695 | case VK_CTRL: nId = WXK_CONTROL; break; | |
4696 | case VK_PAUSE: nId = WXK_PAUSE; break; | |
4697 | case VK_SPACE: nId = WXK_SPACE; break; | |
4698 | case VK_ESC: nId = WXK_ESCAPE; break; | |
4699 | case VK_END: nId = WXK_END; break; | |
4700 | case VK_HOME : nId = WXK_HOME; break; | |
4701 | case VK_LEFT : nId = WXK_LEFT; break; | |
4702 | case VK_UP: nId = WXK_UP; break; | |
4703 | case VK_RIGHT: nId = WXK_RIGHT; break; | |
4704 | case VK_DOWN : nId = WXK_DOWN; break; | |
4705 | case VK_PRINTSCRN: nId = WXK_PRINT; break; | |
4706 | case VK_INSERT: nId = WXK_INSERT; break; | |
4707 | case VK_DELETE: nId = WXK_DELETE; break; | |
a086de98 | 4708 | case VK_CAPSLOCK: nId = WXK_CAPITAL; break; |
61243a51 DW |
4709 | case VK_F1: nId = WXK_F1; break; |
4710 | case VK_F2: nId = WXK_F2; break; | |
4711 | case VK_F3: nId = WXK_F3; break; | |
4712 | case VK_F4: nId = WXK_F4; break; | |
4713 | case VK_F5: nId = WXK_F5; break; | |
4714 | case VK_F6: nId = WXK_F6; break; | |
4715 | case VK_F7: nId = WXK_F7; break; | |
4716 | case VK_F8: nId = WXK_F8; break; | |
4717 | case VK_F9: nId = WXK_F9; break; | |
4718 | case VK_F10: nId = WXK_F10; break; | |
4719 | case VK_F11: nId = WXK_F11; break; | |
4720 | case VK_F12: nId = WXK_F12; break; | |
4721 | case VK_F13: nId = WXK_F13; break; | |
4722 | case VK_F14: nId = WXK_F14; break; | |
4723 | case VK_F15: nId = WXK_F15; break; | |
4724 | case VK_F16: nId = WXK_F16; break; | |
4725 | case VK_F17: nId = WXK_F17; break; | |
4726 | case VK_F18: nId = WXK_F18; break; | |
4727 | case VK_F19: nId = WXK_F19; break; | |
4728 | case VK_F20: nId = WXK_F20; break; | |
4729 | case VK_F21: nId = WXK_F21; break; | |
4730 | case VK_F22: nId = WXK_F22; break; | |
4731 | case VK_F23: nId = WXK_F23; break; | |
4732 | case VK_F24: nId = WXK_F24; break; | |
a086de98 DW |
4733 | case VK_OEM_1: nId = ';'; break; |
4734 | case VK_OEM_PLUS: nId = '+'; break; | |
4735 | case VK_OEM_COMMA: nId = ','; break; | |
4736 | case VK_OEM_MINUS: nId = '-'; break; | |
4737 | case VK_OEM_PERIOD: nId = '.'; break; | |
4738 | case VK_OEM_2: nId = '/'; break; | |
4739 | case VK_OEM_3: nId = '~'; break; | |
4740 | case VK_OEM_4: nId = '['; break; | |
4741 | case VK_OEM_5: nId = '\\'; break; | |
4742 | case VK_OEM_6: nId = ']'; break; | |
4743 | case VK_OEM_7: nId = '\''; break; | |
61243a51 DW |
4744 | case VK_NUMLOCK: nId = WXK_NUMLOCK; break; |
4745 | case VK_SCRLLOCK: nId = WXK_SCROLL; break; | |
4746 | default: | |
86de7616 | 4747 | { |
cdf1e714 | 4748 | return 0; |
86de7616 DW |
4749 | } |
4750 | } | |
61243a51 DW |
4751 | return nId; |
4752 | } // end of wxCharCodeOS2ToWX | |
86de7616 | 4753 | |
61243a51 DW |
4754 | int wxCharCodeWXToOS2( |
4755 | int nId | |
4756 | , bool* bIsVirtual | |
4757 | ) | |
86de7616 | 4758 | { |
61243a51 DW |
4759 | int nKeySym = 0; |
4760 | ||
4761 | *bIsVirtual = TRUE; | |
4762 | switch (nId) | |
4763 | { | |
4764 | case WXK_CLEAR: nKeySym = VK_CLEAR; break; | |
4765 | case WXK_SHIFT: nKeySym = VK_SHIFT; break; | |
4766 | case WXK_CONTROL: nKeySym = VK_CTRL; break; | |
4767 | case WXK_PAUSE: nKeySym = VK_PAUSE; break; | |
4768 | case WXK_END: nKeySym = VK_END; break; | |
4769 | case WXK_HOME : nKeySym = VK_HOME; break; | |
4770 | case WXK_LEFT : nKeySym = VK_LEFT; break; | |
4771 | case WXK_UP: nKeySym = VK_UP; break; | |
4772 | case WXK_RIGHT: nKeySym = VK_RIGHT; break; | |
4773 | case WXK_DOWN : nKeySym = VK_DOWN; break; | |
4774 | case WXK_PRINT: nKeySym = VK_PRINTSCRN; break; | |
4775 | case WXK_INSERT: nKeySym = VK_INSERT; break; | |
4776 | case WXK_DELETE: nKeySym = VK_DELETE; break; | |
4777 | case WXK_F1: nKeySym = VK_F1; break; | |
4778 | case WXK_F2: nKeySym = VK_F2; break; | |
4779 | case WXK_F3: nKeySym = VK_F3; break; | |
4780 | case WXK_F4: nKeySym = VK_F4; break; | |
4781 | case WXK_F5: nKeySym = VK_F5; break; | |
4782 | case WXK_F6: nKeySym = VK_F6; break; | |
4783 | case WXK_F7: nKeySym = VK_F7; break; | |
4784 | case WXK_F8: nKeySym = VK_F8; break; | |
4785 | case WXK_F9: nKeySym = VK_F9; break; | |
4786 | case WXK_F10: nKeySym = VK_F10; break; | |
4787 | case WXK_F11: nKeySym = VK_F11; break; | |
4788 | case WXK_F12: nKeySym = VK_F12; break; | |
4789 | case WXK_F13: nKeySym = VK_F13; break; | |
4790 | case WXK_F14: nKeySym = VK_F14; break; | |
4791 | case WXK_F15: nKeySym = VK_F15; break; | |
4792 | case WXK_F16: nKeySym = VK_F16; break; | |
4793 | case WXK_F17: nKeySym = VK_F17; break; | |
4794 | case WXK_F18: nKeySym = VK_F18; break; | |
4795 | case WXK_F19: nKeySym = VK_F19; break; | |
4796 | case WXK_F20: nKeySym = VK_F20; break; | |
4797 | case WXK_F21: nKeySym = VK_F21; break; | |
4798 | case WXK_F22: nKeySym = VK_F22; break; | |
4799 | case WXK_F23: nKeySym = VK_F23; break; | |
4800 | case WXK_F24: nKeySym = VK_F24; break; | |
4801 | case WXK_NUMLOCK: nKeySym = VK_NUMLOCK; break; | |
4802 | case WXK_SCROLL: nKeySym = VK_SCRLLOCK; break; | |
4803 | default: | |
cdf1e714 | 4804 | { |
61243a51 DW |
4805 | *bIsVirtual = FALSE; |
4806 | nKeySym = nId; | |
cdf1e714 DW |
4807 | break; |
4808 | } | |
86de7616 | 4809 | } |
61243a51 DW |
4810 | return nKeySym; |
4811 | } // end of wxCharCodeWXToOS2 | |
86de7616 | 4812 | |
61243a51 | 4813 | wxWindow* wxGetActiveWindow() |
cdf1e714 | 4814 | { |
61243a51 | 4815 | HWND hWnd = ::WinQueryActiveWindow(HWND_DESKTOP); |
86de7616 | 4816 | |
61243a51 DW |
4817 | if (hWnd != 0) |
4818 | { | |
4819 | return wxFindWinFromHandle((WXHWND)hWnd); | |
4820 | } | |
4821 | return NULL; | |
4822 | } // end of wxGetActiveWindow | |
cdf1e714 DW |
4823 | |
4824 | #ifdef __WXDEBUG__ | |
61243a51 DW |
4825 | const char* wxGetMessageName( |
4826 | int nMessage) | |
cdf1e714 | 4827 | { |
61243a51 | 4828 | switch (nMessage) |
86de7616 | 4829 | { |
cdf1e714 DW |
4830 | case 0x0000: return "WM_NULL"; |
4831 | case 0x0001: return "WM_CREATE"; | |
4832 | case 0x0002: return "WM_DESTROY"; | |
61243a51 DW |
4833 | case 0x0004: return "WM_ENABLE"; |
4834 | case 0x0005: return "WM_SHOW"; | |
4835 | case 0x0006: return "WM_MOVE"; | |
4836 | case 0x0007: return "WM_SIZE"; | |
4837 | case 0x0008: return "WM_ADJUSTWINDOWPOS"; | |
4838 | case 0x0009: return "WM_CALCVALIDRECTS"; | |
4839 | case 0x000A: return "WM_SETWINDOWPARAMS"; | |
4840 | case 0x000B: return "WM_QUERYWINDOWPARAMS"; | |
4841 | case 0x000C: return "WM_HITTEST"; | |
4842 | case 0x000D: return "WM_ACTIVATE"; | |
4843 | case 0x000F: return "WM_SETFOCUS"; | |
4844 | case 0x0010: return "WM_SETSELECTION"; | |
4845 | case 0x0011: return "WM_PPAINT"; | |
4846 | case 0x0012: return "WM_PSETFOCUS"; | |
4847 | case 0x0013: return "WM_PSYSCOLORCHANGE"; | |
4848 | case 0x0014: return "WM_PSIZE"; | |
4849 | case 0x0015: return "WM_PACTIVATE"; | |
4850 | case 0x0016: return "WM_PCONTROL"; | |
4851 | case 0x0020: return "WM_COMMAND"; | |
4852 | case 0x0021: return "WM_SYSCOMMAND"; | |
4853 | case 0x0022: return "WM_HELP"; | |
4854 | case 0x0023: return "WM_PAINT"; | |
4855 | case 0x0024: return "WM_TIMER"; | |
4856 | case 0x0025: return "WM_SEM1"; | |
4857 | case 0x0026: return "WM_SEM2"; | |
4858 | case 0x0027: return "WM_SEM3"; | |
4859 | case 0x0028: return "WM_SEM4"; | |
4860 | case 0x0029: return "WM_CLOSE"; | |
4861 | case 0x002A: return "WM_QUIT"; | |
4862 | case 0x002B: return "WM_SYSCOLORCHANGE"; | |
4863 | case 0x002D: return "WM_SYSVALUECHANGE"; | |
4864 | case 0x002E: return "WM_APPTERMINATENOTIFY"; | |
4865 | case 0x002F: return "WM_PRESPARAMCHANGED"; | |
4866 | // Control notification messages | |
4867 | case 0x0030: return "WM_CONTROL"; | |
4868 | case 0x0031: return "WM_VSCROLL"; | |
4869 | case 0x0032: return "WM_HSCROLL"; | |
4870 | case 0x0033: return "WM_INITMENU"; | |
4871 | case 0x0034: return "WM_MENUSELECT"; | |
4872 | case 0x0035: return "WM_MENUSEND"; | |
4873 | case 0x0036: return "WM_DRAWITEM"; | |
4874 | case 0x0037: return "WM_MEASUREITEM"; | |
4875 | case 0x0038: return "WM_CONTROLPOINTER"; | |
4876 | case 0x003A: return "WM_QUERYDLGCODE"; | |
4877 | case 0x003B: return "WM_INITDLG"; | |
4878 | case 0x003C: return "WM_SUBSTITUTESTRING"; | |
4879 | case 0x003D: return "WM_MATCHMNEMONIC"; | |
4880 | case 0x003E: return "WM_SAVEAPPLICATION"; | |
4881 | case 0x0129: return "WM_CTLCOLORCHANGE"; | |
4882 | case 0x0130: return "WM_QUERYCTLTYPE"; | |
4883 | // Frame messages | |
4884 | case 0x0040: return "WM_FLASHWINDOW"; | |
4885 | case 0x0041: return "WM_FORMATFRAME"; | |
4886 | case 0x0042: return "WM_UPDATEFRAME"; | |
4887 | case 0x0043: return "WM_FOCUSCHANGE"; | |
4888 | case 0x0044: return "WM_SETBORDERSIZE"; | |
4889 | case 0x0045: return "WM_TRACKFRAME"; | |
4890 | case 0x0046: return "WM_MINMAXFRAME"; | |
4891 | case 0x0047: return "WM_SETICON"; | |
4892 | case 0x0048: return "WM_QUERYICON"; | |
4893 | case 0x0049: return "WM_SETACCELTABLE"; | |
4894 | case 0x004A: return "WM_QUERYACCELTABLE"; | |
4895 | case 0x004B: return "WM_TRANSLATEACCEL"; | |
4896 | case 0x004C: return "WM_QUERYTRACKINFO"; | |
4897 | case 0x004D: return "WM_QUERYBORDERSIZE"; | |
4898 | case 0x004E: return "WM_NEXTMENU"; | |
4899 | case 0x004F: return "WM_ERASEBACKGROUND"; | |
4900 | case 0x0050: return "WM_QUERYFRAMEINFO"; | |
4901 | case 0x0051: return "WM_QUERYFOCUSCHAIN"; | |
4902 | case 0x0052: return "WM_OWNERPOSCHANGE"; | |
4903 | case 0x0053: return "WM_CACLFRAMERECT"; | |
4904 | case 0x0055: return "WM_WINDOWPOSCHANGED"; | |
4905 | case 0x0056: return "WM_ADJUSTFRAMEPOS"; | |
4906 | case 0x0059: return "WM_QUERYFRAMECTLCOUNT"; | |
4907 | case 0x005B: return "WM_QUERYHELPINFO"; | |
4908 | case 0x005C: return "WM_SETHELPINFO"; | |
4909 | case 0x005D: return "WM_ERROR"; | |
4910 | case 0x005E: return "WM_REALIZEPALETTE"; | |
4911 | // Clipboard messages | |
4912 | case 0x0060: return "WM_RENDERFMT"; | |
4913 | case 0x0061: return "WM_RENDERALLFMTS"; | |
4914 | case 0x0062: return "WM_DESTROYCLIPBOARD"; | |
4915 | case 0x0063: return "WM_PAINTCLIPBOARD"; | |
4916 | case 0x0064: return "WM_SIZECLIPBOARD"; | |
4917 | case 0x0065: return "WM_HSCROLLCLIPBOARD"; | |
4918 | case 0x0066: return "WM_VSCROLLCLIPBOARD"; | |
4919 | case 0x0067: return "WM_DRAWCLIPBOARD"; | |
4920 | // mouse messages | |
4921 | case 0x0070: return "WM_MOUSEMOVE"; | |
4922 | case 0x0071: return "WM_BUTTON1DOWN"; | |
4923 | case 0x0072: return "WM_BUTTON1UP"; | |
4924 | case 0x0073: return "WM_BUTTON1DBLCLK"; | |
4925 | case 0x0074: return "WM_BUTTON2DOWN"; | |
4926 | case 0x0075: return "WM_BUTTON2UP"; | |
4927 | case 0x0076: return "WM_BUTTON2DBLCLK"; | |
4928 | case 0x0077: return "WM_BUTTON3DOWN"; | |
4929 | case 0x0078: return "WM_BUTTON3UP"; | |
4930 | case 0x0079: return "WM_BUTTON3DBLCLK"; | |
4931 | case 0x007D: return "WM_MOUSEMAP"; | |
4932 | case 0x007E: return "WM_VRNDISABLED"; | |
4933 | case 0x007F: return "WM_VRNENABLED"; | |
4934 | case 0x0410: return "WM_CHORD"; | |
4935 | case 0x0411: return "WM_BUTTON1MOTIONSTART"; | |
4936 | case 0x0412: return "WM_BUTTON1MOTIONEND"; | |
4937 | case 0x0413: return "WM_BUTTON1CLICK"; | |
4938 | case 0x0414: return "WM_BUTTON2MOTIONSTART"; | |
4939 | case 0x0415: return "WM_BUTTON2MOTIONEND"; | |
4940 | case 0x0416: return "WM_BUTTON2CLICK"; | |
4941 | case 0x0417: return "WM_BUTTON3MOTIONSTART"; | |
4942 | case 0x0418: return "WM_BUTTON3MOTIONEND"; | |
4943 | case 0x0419: return "WM_BUTTON3CLICK"; | |
4944 | case 0x0420: return "WM_BEGINDRAG"; | |
4945 | case 0x0421: return "WM_ENDDRAG"; | |
4946 | case 0x0422: return "WM_SINGLESELECT"; | |
4947 | case 0x0423: return "WM_OPEN"; | |
4948 | case 0x0424: return "WM_CONTEXTMENU"; | |
4949 | case 0x0425: return "WM_CONTEXTHELP"; | |
4950 | case 0x0426: return "WM_TEXTEDIT"; | |
4951 | case 0x0427: return "WM_BEGINSELECT"; | |
4952 | case 0x0228: return "WM_ENDSELECT"; | |
4953 | case 0x0429: return "WM_PICKUP"; | |
4954 | case 0x04C0: return "WM_PENFIRST"; | |
4955 | case 0x04FF: return "WM_PENLAST"; | |
4956 | case 0x0500: return "WM_MMPMFIRST"; | |
4957 | case 0x05FF: return "WM_MMPMLAST"; | |
4958 | case 0x0600: return "WM_STDDLGFIRST"; | |
4959 | case 0x06FF: return "WM_STDDLGLAST"; | |
4960 | case 0x0BD0: return "WM_BIDI_FIRST"; | |
4961 | case 0x0BFF: return "WM_BIDI_LAST"; | |
4962 | // keyboard input | |
4963 | case 0x007A: return "WM_CHAR"; | |
4964 | case 0x007B: return "WM_VIOCHAR"; | |
4965 | // DDE messages | |
4966 | case 0x00A0: return "WM_DDE_INITIATE"; | |
4967 | case 0x00A1: return "WM_DDE_REQUEST"; | |
4968 | case 0x00A2: return "WM_DDE_ACK"; | |
4969 | case 0x00A3: return "WM_DDE_DATA"; | |
4970 | case 0x00A4: return "WM_DDE_ADVISE"; | |
4971 | case 0x00A5: return "WM_DDE_UNADVISE"; | |
4972 | case 0x00A6: return "WM_DDE_POKE"; | |
4973 | case 0x00A7: return "WM_DDE_EXECUTE"; | |
4974 | case 0x00A8: return "WM_DDE_TERMINATE"; | |
4975 | case 0x00A9: return "WM_DDE_INITIATEACK"; | |
4976 | case 0x00AF: return "WM_DDE_LAST"; | |
4977 | // Buttons | |
4978 | case 0x0120: return "BM_CLICK"; | |
4979 | case 0x0121: return "BM_QUERYCHECKINDEX"; | |
4980 | case 0x0122: return "BM_QUERYHILITE"; | |
4981 | case 0x0123: return "BM_SETHILITE"; | |
4982 | case 0x0124: return "BM_QUERYCHECK"; | |
4983 | case 0x0125: return "BM_SETCHECK"; | |
4984 | case 0x0126: return "BM_SETDEFAULT"; | |
4985 | case 0x0128: return "BM_AUTOSIZE"; | |
4986 | // Combo boxes | |
4987 | case 0x029A: return "CBID_LIST"; | |
4988 | case 0x029B: return "CBID_EDIT"; | |
4989 | case 0x0170: return "CBM_SHOWLIST"; | |
4990 | case 0x0171: return "CBM_HILITE"; | |
4991 | case 0x0172: return "CBM_ISLISTSHOWING"; | |
4992 | // Edit fields | |
4993 | case 0x0140: return "EM_QUERYCHANGED"; | |
4994 | case 0x0141: return "EM_QUERYSEL"; | |
4995 | case 0x0142: return "EM_SETSEL"; | |
4996 | case 0x0143: return "EM_SETTEXTLIMIT"; | |
4997 | case 0x0144: return "EM_CUT"; | |
4998 | case 0x0145: return "EM_COPY"; | |
4999 | case 0x0146: return "EM_CLEAR"; | |
5000 | case 0x0147: return "EM_PASTE"; | |
5001 | case 0x0148: return "EM_QUERYFIRSTCHAR"; | |
5002 | case 0x0149: return "EM_SETFIRSTCHAR"; | |
5003 | case 0x014A: return "EM_QUERYREADONLY"; | |
5004 | case 0x014B: return "EM_SETREADONLY"; | |
5005 | case 0x014C: return "EM_SETINSERTMODE"; | |
5006 | // Listboxes | |
5007 | case 0x0160: return "LM_QUERYITEMCOUNT"; | |
5008 | case 0x0161: return "LM_INSERTITEM"; | |
5009 | case 0x0162: return "LM_SETOPENINDEX"; | |
5010 | case 0x0163: return "LM_DELETEITEM"; | |
5011 | case 0x0164: return "LM_SELECTITEM"; | |
5012 | case 0x0165: return "LM_QUERYSELECTION"; | |
5013 | case 0x0166: return "LM_SETITEMTEXT"; | |
5014 | case 0x0167: return "LM_QUERYITEMTEXTLENGTH"; | |
5015 | case 0x0168: return "LM_QUERYITEMTEXT"; | |
5016 | case 0x0169: return "LM_SETITEMHANDLE"; | |
5017 | case 0x016A: return "LM_QUERYITEMHANDLE"; | |
5018 | case 0x016B: return "LM_SEARCHSTRING"; | |
5019 | case 0x016C: return "LM_SETITEMHEIGHT"; | |
5020 | case 0x016D: return "LM_QUERYTOPINDEX"; | |
5021 | case 0x016E: return "LM_DELETEALL"; | |
5022 | case 0x016F: return "LM_INSERTMULITEMS"; | |
5023 | case 0x0660: return "LM_SETITEMWIDTH"; | |
5024 | // Menus | |
5025 | case 0x0180: return "MM_INSERTITEM"; | |
5026 | case 0x0181: return "MM_DELETEITEM"; | |
5027 | case 0x0182: return "MM_QUERYITEM"; | |
5028 | case 0x0183: return "MM_SETITEM"; | |
5029 | case 0x0184: return "MM_QUERYITEMCOUNT"; | |
5030 | case 0x0185: return "MM_STARTMENUMODE"; | |
5031 | case 0x0186: return "MM_ENDMENUMODE"; | |
5032 | case 0x0188: return "MM_REMOVEITEM"; | |
5033 | case 0x0189: return "MM_SELECTITEM"; | |
5034 | case 0x018A: return "MM_QUERYSELITEMID"; | |
5035 | case 0x018B: return "MM_QUERYITEMTEXT"; | |
5036 | case 0x018C: return "MM_QUERYITEMTEXTLENGTH"; | |
5037 | case 0x018D: return "MM_SETITEMHANDLE"; | |
5038 | case 0x018E: return "MM_SETITEMTEXT"; | |
5039 | case 0x018F: return "MM_ITEMPOSITIONFROMID"; | |
5040 | case 0x0190: return "MM_ITEMIDFROMPOSITION"; | |
5041 | case 0x0191: return "MM_QUERYITEMATTR"; | |
5042 | case 0x0192: return "MM_SETITEMATTR"; | |
5043 | case 0x0193: return "MM_ISITEMVALID"; | |
5044 | case 0x0194: return "MM_QUERYITEMRECT"; | |
5045 | case 0x0431: return "MM_QUERYDEFAULTITEMID"; | |
5046 | case 0x0432: return "MM_SETDEFAULTITEMID"; | |
5047 | // Scrollbars | |
5048 | case 0x01A0: return "SBM_SETSCROLLBAR"; | |
5049 | case 0x01A1: return "SBM_SETPOS"; | |
5050 | case 0x01A2: return "SBM_QUERYPOS"; | |
5051 | case 0x01A3: return "SBM_QUERYRANGE"; | |
5052 | case 0x01A6: return "SBM_SETTHUMBSIZE"; | |
5053 | ||
5054 | // Help messages | |
5055 | case 0x0F00: return "WM_HELPBASE"; | |
5056 | case 0x0FFF: return "WM_HELPTOP"; | |
5057 | // Beginning of user defined messages | |
5058 | case 0x1000: return "WM_USER"; | |
5059 | ||
5060 | // wxWindows user defined types | |
cdf1e714 DW |
5061 | |
5062 | // listview | |
61243a51 | 5063 | // case 0x1000 + 0: return "LVM_GETBKCOLOR"; |
cdf1e714 DW |
5064 | case 0x1000 + 1: return "LVM_SETBKCOLOR"; |
5065 | case 0x1000 + 2: return "LVM_GETIMAGELIST"; | |
5066 | case 0x1000 + 3: return "LVM_SETIMAGELIST"; | |
5067 | case 0x1000 + 4: return "LVM_GETITEMCOUNT"; | |
5068 | case 0x1000 + 5: return "LVM_GETITEMA"; | |
5069 | case 0x1000 + 75: return "LVM_GETITEMW"; | |
5070 | case 0x1000 + 6: return "LVM_SETITEMA"; | |
5071 | case 0x1000 + 76: return "LVM_SETITEMW"; | |
5072 | case 0x1000 + 7: return "LVM_INSERTITEMA"; | |
5073 | case 0x1000 + 77: return "LVM_INSERTITEMW"; | |
5074 | case 0x1000 + 8: return "LVM_DELETEITEM"; | |
5075 | case 0x1000 + 9: return "LVM_DELETEALLITEMS"; | |
5076 | case 0x1000 + 10: return "LVM_GETCALLBACKMASK"; | |
5077 | case 0x1000 + 11: return "LVM_SETCALLBACKMASK"; | |
5078 | case 0x1000 + 12: return "LVM_GETNEXTITEM"; | |
5079 | case 0x1000 + 13: return "LVM_FINDITEMA"; | |
5080 | case 0x1000 + 83: return "LVM_FINDITEMW"; | |
5081 | case 0x1000 + 14: return "LVM_GETITEMRECT"; | |
5082 | case 0x1000 + 15: return "LVM_SETITEMPOSITION"; | |
5083 | case 0x1000 + 16: return "LVM_GETITEMPOSITION"; | |
5084 | case 0x1000 + 17: return "LVM_GETSTRINGWIDTHA"; | |
5085 | case 0x1000 + 87: return "LVM_GETSTRINGWIDTHW"; | |
5086 | case 0x1000 + 18: return "LVM_HITTEST"; | |
5087 | case 0x1000 + 19: return "LVM_ENSUREVISIBLE"; | |
5088 | case 0x1000 + 20: return "LVM_SCROLL"; | |
5089 | case 0x1000 + 21: return "LVM_REDRAWITEMS"; | |
5090 | case 0x1000 + 22: return "LVM_ARRANGE"; | |
5091 | case 0x1000 + 23: return "LVM_EDITLABELA"; | |
5092 | case 0x1000 + 118: return "LVM_EDITLABELW"; | |
5093 | case 0x1000 + 24: return "LVM_GETEDITCONTROL"; | |
5094 | case 0x1000 + 25: return "LVM_GETCOLUMNA"; | |
5095 | case 0x1000 + 95: return "LVM_GETCOLUMNW"; | |
5096 | case 0x1000 + 26: return "LVM_SETCOLUMNA"; | |
5097 | case 0x1000 + 96: return "LVM_SETCOLUMNW"; | |
5098 | case 0x1000 + 27: return "LVM_INSERTCOLUMNA"; | |
5099 | case 0x1000 + 97: return "LVM_INSERTCOLUMNW"; | |
5100 | case 0x1000 + 28: return "LVM_DELETECOLUMN"; | |
5101 | case 0x1000 + 29: return "LVM_GETCOLUMNWIDTH"; | |
5102 | case 0x1000 + 30: return "LVM_SETCOLUMNWIDTH"; | |
5103 | case 0x1000 + 31: return "LVM_GETHEADER"; | |
5104 | case 0x1000 + 33: return "LVM_CREATEDRAGIMAGE"; | |
5105 | case 0x1000 + 34: return "LVM_GETVIEWRECT"; | |
5106 | case 0x1000 + 35: return "LVM_GETTEXTCOLOR"; | |
5107 | case 0x1000 + 36: return "LVM_SETTEXTCOLOR"; | |
5108 | case 0x1000 + 37: return "LVM_GETTEXTBKCOLOR"; | |
5109 | case 0x1000 + 38: return "LVM_SETTEXTBKCOLOR"; | |
5110 | case 0x1000 + 39: return "LVM_GETTOPINDEX"; | |
5111 | case 0x1000 + 40: return "LVM_GETCOUNTPERPAGE"; | |
5112 | case 0x1000 + 41: return "LVM_GETORIGIN"; | |
5113 | case 0x1000 + 42: return "LVM_UPDATE"; | |
5114 | case 0x1000 + 43: return "LVM_SETITEMSTATE"; | |
5115 | case 0x1000 + 44: return "LVM_GETITEMSTATE"; | |
5116 | case 0x1000 + 45: return "LVM_GETITEMTEXTA"; | |
5117 | case 0x1000 + 115: return "LVM_GETITEMTEXTW"; | |
5118 | case 0x1000 + 46: return "LVM_SETITEMTEXTA"; | |
5119 | case 0x1000 + 116: return "LVM_SETITEMTEXTW"; | |
5120 | case 0x1000 + 47: return "LVM_SETITEMCOUNT"; | |
5121 | case 0x1000 + 48: return "LVM_SORTITEMS"; | |
5122 | case 0x1000 + 49: return "LVM_SETITEMPOSITION32"; | |
5123 | case 0x1000 + 50: return "LVM_GETSELECTEDCOUNT"; | |
5124 | case 0x1000 + 51: return "LVM_GETITEMSPACING"; | |
5125 | case 0x1000 + 52: return "LVM_GETISEARCHSTRINGA"; | |
5126 | case 0x1000 + 117: return "LVM_GETISEARCHSTRINGW"; | |
5127 | case 0x1000 + 53: return "LVM_SETICONSPACING"; | |
5128 | case 0x1000 + 54: return "LVM_SETEXTENDEDLISTVIEWSTYLE"; | |
5129 | case 0x1000 + 55: return "LVM_GETEXTENDEDLISTVIEWSTYLE"; | |
5130 | case 0x1000 + 56: return "LVM_GETSUBITEMRECT"; | |
5131 | case 0x1000 + 57: return "LVM_SUBITEMHITTEST"; | |
5132 | case 0x1000 + 58: return "LVM_SETCOLUMNORDERARRAY"; | |
5133 | case 0x1000 + 59: return "LVM_GETCOLUMNORDERARRAY"; | |
5134 | case 0x1000 + 60: return "LVM_SETHOTITEM"; | |
5135 | case 0x1000 + 61: return "LVM_GETHOTITEM"; | |
5136 | case 0x1000 + 62: return "LVM_SETHOTCURSOR"; | |
5137 | case 0x1000 + 63: return "LVM_GETHOTCURSOR"; | |
5138 | case 0x1000 + 64: return "LVM_APPROXIMATEVIEWRECT"; | |
5139 | case 0x1000 + 65: return "LVM_SETWORKAREA"; | |
5140 | ||
5141 | // tree view | |
5142 | case 0x1100 + 0: return "TVM_INSERTITEMA"; | |
5143 | case 0x1100 + 50: return "TVM_INSERTITEMW"; | |
5144 | case 0x1100 + 1: return "TVM_DELETEITEM"; | |
5145 | case 0x1100 + 2: return "TVM_EXPAND"; | |
5146 | case 0x1100 + 4: return "TVM_GETITEMRECT"; | |
5147 | case 0x1100 + 5: return "TVM_GETCOUNT"; | |
5148 | case 0x1100 + 6: return "TVM_GETINDENT"; | |
5149 | case 0x1100 + 7: return "TVM_SETINDENT"; | |
5150 | case 0x1100 + 8: return "TVM_GETIMAGELIST"; | |
5151 | case 0x1100 + 9: return "TVM_SETIMAGELIST"; | |
5152 | case 0x1100 + 10: return "TVM_GETNEXTITEM"; | |
5153 | case 0x1100 + 11: return "TVM_SELECTITEM"; | |
5154 | case 0x1100 + 12: return "TVM_GETITEMA"; | |
5155 | case 0x1100 + 62: return "TVM_GETITEMW"; | |
5156 | case 0x1100 + 13: return "TVM_SETITEMA"; | |
5157 | case 0x1100 + 63: return "TVM_SETITEMW"; | |
5158 | case 0x1100 + 14: return "TVM_EDITLABELA"; | |
5159 | case 0x1100 + 65: return "TVM_EDITLABELW"; | |
5160 | case 0x1100 + 15: return "TVM_GETEDITCONTROL"; | |
5161 | case 0x1100 + 16: return "TVM_GETVISIBLECOUNT"; | |
5162 | case 0x1100 + 17: return "TVM_HITTEST"; | |
5163 | case 0x1100 + 18: return "TVM_CREATEDRAGIMAGE"; | |
5164 | case 0x1100 + 19: return "TVM_SORTCHILDREN"; | |
5165 | case 0x1100 + 20: return "TVM_ENSUREVISIBLE"; | |
5166 | case 0x1100 + 21: return "TVM_SORTCHILDRENCB"; | |
5167 | case 0x1100 + 22: return "TVM_ENDEDITLABELNOW"; | |
5168 | case 0x1100 + 23: return "TVM_GETISEARCHSTRINGA"; | |
5169 | case 0x1100 + 64: return "TVM_GETISEARCHSTRINGW"; | |
5170 | case 0x1100 + 24: return "TVM_SETTOOLTIPS"; | |
5171 | case 0x1100 + 25: return "TVM_GETTOOLTIPS"; | |
5172 | ||
5173 | // header | |
5174 | case 0x1200 + 0: return "HDM_GETITEMCOUNT"; | |
5175 | case 0x1200 + 1: return "HDM_INSERTITEMA"; | |
5176 | case 0x1200 + 10: return "HDM_INSERTITEMW"; | |
5177 | case 0x1200 + 2: return "HDM_DELETEITEM"; | |
5178 | case 0x1200 + 3: return "HDM_GETITEMA"; | |
5179 | case 0x1200 + 11: return "HDM_GETITEMW"; | |
5180 | case 0x1200 + 4: return "HDM_SETITEMA"; | |
5181 | case 0x1200 + 12: return "HDM_SETITEMW"; | |
5182 | case 0x1200 + 5: return "HDM_LAYOUT"; | |
5183 | case 0x1200 + 6: return "HDM_HITTEST"; | |
5184 | case 0x1200 + 7: return "HDM_GETITEMRECT"; | |
5185 | case 0x1200 + 8: return "HDM_SETIMAGELIST"; | |
5186 | case 0x1200 + 9: return "HDM_GETIMAGELIST"; | |
5187 | case 0x1200 + 15: return "HDM_ORDERTOINDEX"; | |
5188 | case 0x1200 + 16: return "HDM_CREATEDRAGIMAGE"; | |
5189 | case 0x1200 + 17: return "HDM_GETORDERARRAY"; | |
5190 | case 0x1200 + 18: return "HDM_SETORDERARRAY"; | |
5191 | case 0x1200 + 19: return "HDM_SETHOTDIVIDER"; | |
5192 | ||
5193 | // tab control | |
5194 | case 0x1300 + 2: return "TCM_GETIMAGELIST"; | |
5195 | case 0x1300 + 3: return "TCM_SETIMAGELIST"; | |
5196 | case 0x1300 + 4: return "TCM_GETITEMCOUNT"; | |
5197 | case 0x1300 + 5: return "TCM_GETITEMA"; | |
5198 | case 0x1300 + 60: return "TCM_GETITEMW"; | |
5199 | case 0x1300 + 6: return "TCM_SETITEMA"; | |
5200 | case 0x1300 + 61: return "TCM_SETITEMW"; | |
5201 | case 0x1300 + 7: return "TCM_INSERTITEMA"; | |
5202 | case 0x1300 + 62: return "TCM_INSERTITEMW"; | |
5203 | case 0x1300 + 8: return "TCM_DELETEITEM"; | |
5204 | case 0x1300 + 9: return "TCM_DELETEALLITEMS"; | |
5205 | case 0x1300 + 10: return "TCM_GETITEMRECT"; | |
5206 | case 0x1300 + 11: return "TCM_GETCURSEL"; | |
5207 | case 0x1300 + 12: return "TCM_SETCURSEL"; | |
5208 | case 0x1300 + 13: return "TCM_HITTEST"; | |
5209 | case 0x1300 + 14: return "TCM_SETITEMEXTRA"; | |
5210 | case 0x1300 + 40: return "TCM_ADJUSTRECT"; | |
5211 | case 0x1300 + 41: return "TCM_SETITEMSIZE"; | |
5212 | case 0x1300 + 42: return "TCM_REMOVEIMAGE"; | |
5213 | case 0x1300 + 43: return "TCM_SETPADDING"; | |
5214 | case 0x1300 + 44: return "TCM_GETROWCOUNT"; | |
5215 | case 0x1300 + 45: return "TCM_GETTOOLTIPS"; | |
5216 | case 0x1300 + 46: return "TCM_SETTOOLTIPS"; | |
5217 | case 0x1300 + 47: return "TCM_GETCURFOCUS"; | |
5218 | case 0x1300 + 48: return "TCM_SETCURFOCUS"; | |
5219 | case 0x1300 + 49: return "TCM_SETMINTABWIDTH"; | |
5220 | case 0x1300 + 50: return "TCM_DESELECTALL"; | |
5221 | ||
5222 | // toolbar | |
61243a51 DW |
5223 | case WM_USER+1000+1: return "TB_ENABLEBUTTON"; |
5224 | case WM_USER+1000+2: return "TB_CHECKBUTTON"; | |
5225 | case WM_USER+1000+3: return "TB_PRESSBUTTON"; | |
5226 | case WM_USER+1000+4: return "TB_HIDEBUTTON"; | |
5227 | case WM_USER+1000+5: return "TB_INDETERMINATE"; | |
5228 | case WM_USER+1000+9: return "TB_ISBUTTONENABLED"; | |
5229 | case WM_USER+1000+10: return "TB_ISBUTTONCHECKED"; | |
5230 | case WM_USER+1000+11: return "TB_ISBUTTONPRESSED"; | |
5231 | case WM_USER+1000+12: return "TB_ISBUTTONHIDDEN"; | |
5232 | case WM_USER+1000+13: return "TB_ISBUTTONINDETERMINATE"; | |
5233 | case WM_USER+1000+17: return "TB_SETSTATE"; | |
5234 | case WM_USER+1000+18: return "TB_GETSTATE"; | |
5235 | case WM_USER+1000+19: return "TB_ADDBITMAP"; | |
5236 | case WM_USER+1000+20: return "TB_ADDBUTTONS"; | |
5237 | case WM_USER+1000+21: return "TB_INSERTBUTTON"; | |
5238 | case WM_USER+1000+22: return "TB_DELETEBUTTON"; | |
5239 | case WM_USER+1000+23: return "TB_GETBUTTON"; | |
5240 | case WM_USER+1000+24: return "TB_BUTTONCOUNT"; | |
5241 | case WM_USER+1000+25: return "TB_COMMANDTOINDEX"; | |
5242 | case WM_USER+1000+26: return "TB_SAVERESTOREA"; | |
5243 | case WM_USER+1000+76: return "TB_SAVERESTOREW"; | |
5244 | case WM_USER+1000+27: return "TB_CUSTOMIZE"; | |
5245 | case WM_USER+1000+28: return "TB_ADDSTRINGA"; | |
5246 | case WM_USER+1000+77: return "TB_ADDSTRINGW"; | |
5247 | case WM_USER+1000+29: return "TB_GETITEMRECT"; | |
5248 | case WM_USER+1000+30: return "TB_BUTTONSTRUCTSIZE"; | |
5249 | case WM_USER+1000+31: return "TB_SETBUTTONSIZE"; | |
5250 | case WM_USER+1000+32: return "TB_SETBITMAPSIZE"; | |
5251 | case WM_USER+1000+33: return "TB_AUTOSIZE"; | |
5252 | case WM_USER+1000+35: return "TB_GETTOOLTIPS"; | |
5253 | case WM_USER+1000+36: return "TB_SETTOOLTIPS"; | |
5254 | case WM_USER+1000+37: return "TB_SETPARENT"; | |
5255 | case WM_USER+1000+39: return "TB_SETROWS"; | |
5256 | case WM_USER+1000+40: return "TB_GETROWS"; | |
5257 | case WM_USER+1000+42: return "TB_SETCMDID"; | |
5258 | case WM_USER+1000+43: return "TB_CHANGEBITMAP"; | |
5259 | case WM_USER+1000+44: return "TB_GETBITMAP"; | |
5260 | case WM_USER+1000+45: return "TB_GETBUTTONTEXTA"; | |
5261 | case WM_USER+1000+75: return "TB_GETBUTTONTEXTW"; | |
5262 | case WM_USER+1000+46: return "TB_REPLACEBITMAP"; | |
5263 | case WM_USER+1000+47: return "TB_SETINDENT"; | |
5264 | case WM_USER+1000+48: return "TB_SETIMAGELIST"; | |
5265 | case WM_USER+1000+49: return "TB_GETIMAGELIST"; | |
5266 | case WM_USER+1000+50: return "TB_LOADIMAGES"; | |
5267 | case WM_USER+1000+51: return "TB_GETRECT"; | |
5268 | case WM_USER+1000+52: return "TB_SETHOTIMAGELIST"; | |
5269 | case WM_USER+1000+53: return "TB_GETHOTIMAGELIST"; | |
5270 | case WM_USER+1000+54: return "TB_SETDISABLEDIMAGELIST"; | |
5271 | case WM_USER+1000+55: return "TB_GETDISABLEDIMAGELIST"; | |
5272 | case WM_USER+1000+56: return "TB_SETSTYLE"; | |
5273 | case WM_USER+1000+57: return "TB_GETSTYLE"; | |
5274 | case WM_USER+1000+58: return "TB_GETBUTTONSIZE"; | |
5275 | case WM_USER+1000+59: return "TB_SETBUTTONWIDTH"; | |
5276 | case WM_USER+1000+60: return "TB_SETMAXTEXTROWS"; | |
5277 | case WM_USER+1000+61: return "TB_GETTEXTROWS"; | |
5278 | case WM_USER+1000+41: return "TB_GETBITMAPFLAGS"; | |
cdf1e714 DW |
5279 | |
5280 | default: | |
5281 | static char s_szBuf[128]; | |
61243a51 | 5282 | sprintf(s_szBuf, "<unknown message = %d>", nMessage); |
cdf1e714 | 5283 | return s_szBuf; |
86de7616 | 5284 | } |
cdf1e714 | 5285 | return NULL; |
61243a51 | 5286 | } // end of wxGetMessageName |
86de7616 | 5287 | |
11e59d47 DW |
5288 | #endif // __WXDEBUG__ |
5289 | ||
19193a2c KB |
5290 | // Unused? |
5291 | #if 0 | |
61243a51 DW |
5292 | static void TranslateKbdEventToMouse( |
5293 | wxWindow* pWin | |
5294 | , int* pX | |
5295 | , int* pY | |
5296 | , ULONG* pFlags | |
5297 | ) | |
5298 | { | |
5299 | // | |
5300 | // Construct the key mask | |
5301 | ULONG& fwKeys = *pFlags; | |
5302 | ||
5303 | fwKeys = VK_BUTTON2; | |
5304 | if ((::WinGetKeyState(HWND_DESKTOP, VK_CTRL) & 0x100) != 0) | |
5305 | fwKeys |= VK_CTRL; | |
5306 | if ((::WinGetKeyState(HWND_DESKTOP, VK_SHIFT) & 0x100) != 0) | |
5307 | fwKeys |= VK_SHIFT; | |
5308 | ||
5309 | // | |
5310 | // Simulate right mouse button click | |
5311 | // | |
5312 | POINTL vPoint; | |
5313 | ||
5314 | ::WinQueryMsgPos(vHabmain, &vPoint); | |
5315 | *pX = vPoint.x; | |
5316 | *pY = vPoint.y; | |
5317 | ||
5318 | pWin->ScreenToClient(pX, pY); | |
5319 | } // end of TranslateKbdEventToMouse | |
19193a2c | 5320 | #endif |
61243a51 | 5321 | |
cd212ee4 DW |
5322 | // Find the wxWindow at the current mouse position, returning the mouse |
5323 | // position. | |
f44fdfb0 | 5324 | wxWindow* wxFindWindowAtPointer( |
19193a2c | 5325 | wxPoint& WXUNUSED(rPt) |
f44fdfb0 | 5326 | ) |
cd212ee4 DW |
5327 | { |
5328 | return wxFindWindowAtPoint(wxGetMousePosition()); | |
5329 | } | |
5330 | ||
f44fdfb0 DW |
5331 | wxWindow* wxFindWindowAtPoint( |
5332 | const wxPoint& rPt | |
5333 | ) | |
cd212ee4 | 5334 | { |
f44fdfb0 | 5335 | POINTL vPt2; |
cd212ee4 | 5336 | |
f44fdfb0 DW |
5337 | vPt2.x = rPt.x; |
5338 | vPt2.y = rPt.y; | |
cd212ee4 | 5339 | |
f44fdfb0 DW |
5340 | HWND hWndHit = ::WinWindowFromPoint(HWND_DESKTOP, &vPt2, FALSE); |
5341 | wxWindow* pWin = wxFindWinFromHandle((WXHWND)hWndHit) ; | |
5342 | HWND hWnd = hWndHit; | |
5343 | ||
5344 | // | |
cd212ee4 | 5345 | // Try to find a window with a wxWindow associated with it |
f44fdfb0 DW |
5346 | // |
5347 | while (!pWin && (hWnd != 0)) | |
cd212ee4 | 5348 | { |
f44fdfb0 DW |
5349 | hWnd = ::WinQueryWindow(hWnd, QW_PARENT); |
5350 | pWin = wxFindWinFromHandle((WXHWND)hWnd) ; | |
cd212ee4 | 5351 | } |
f44fdfb0 | 5352 | return pWin; |
cd212ee4 DW |
5353 | } |
5354 | ||
f44fdfb0 DW |
5355 | // Get the current mouse position. |
5356 | wxPoint wxGetMousePosition() | |
5357 | { | |
5358 | POINTL vPt; | |
5359 | ||
5360 | ::WinQueryPointerPos(HWND_DESKTOP, &vPt); | |
5361 | return wxPoint(vPt.x, vPt.y); | |
5362 | } | |
cd212ee4 | 5363 | |
430974f8 DW |
5364 | wxWindowOS2* FindWindowForMouseEvent( |
5365 | wxWindow* pWin | |
5366 | , short* pnX | |
5367 | , short* pnY | |
5368 | ) | |
5369 | { | |
430974f8 DW |
5370 | HWND hWnd = GetHwndOf(pWin); |
5371 | HWND hWndUnderMouse; | |
b720b24d DW |
5372 | POINTL vPoint; |
5373 | BOOL rcEnabled = FALSE; | |
5374 | BOOL rcVisible = FALSE; | |
5375 | HWND hWndDesktop = HWND_DESKTOP; | |
430974f8 | 5376 | |
b720b24d DW |
5377 | ::WinQueryPointerPos(HWND_DESKTOP, &vPoint); |
5378 | hWndUnderMouse = ::WinWindowFromPoint(HWND_DESKTOP, &vPoint, TRUE); | |
5379 | if (hWndUnderMouse != HWND_DESKTOP) | |
430974f8 | 5380 | { |
b720b24d DW |
5381 | wxWindow* pWinUnderMouse = wxFindWinFromHandle((WXHWND)hWndUnderMouse); |
5382 | ||
5383 | if (pWinUnderMouse) | |
5384 | { | |
5385 | wxWindowList::Node* pCurrent = pWinUnderMouse->GetChildren().GetFirst(); | |
5386 | wxWindow* pChild = NULL; | |
5387 | wxWindow* pGrandChild = NULL; | |
5388 | RECTL vRect; | |
5389 | POINTL vPoint2; | |
5390 | ||
5391 | ::WinMapWindowPoints(HWND_DESKTOP, hWndUnderMouse, &vPoint, 1); | |
5392 | // | |
5393 | // Find a child window mouse might be under | |
5394 | // | |
5395 | while (pCurrent) | |
5396 | { | |
5397 | wxWindow* pChild = pCurrent->GetData(); | |
5398 | ||
5399 | vPoint2.x = vPoint.x; | |
5400 | vPoint2.y = vPoint.y; | |
5401 | ::WinMapWindowPoints(hWndUnderMouse, pChild->GetHWND(), &vPoint2, 1); | |
5402 | ::WinQueryWindowRect(pChild->GetHWND(), &vRect); | |
5403 | if (::WinPtInRect(vHabmain, &vRect, &vPoint2)) | |
5404 | { | |
5405 | if (pChild->IsTopLevel()) | |
5406 | { | |
5407 | POINTL vPoint3; | |
5408 | wxWindowList::Node* pCurrent2 =pChild->GetChildren().GetFirst(); | |
430974f8 | 5409 | |
b720b24d DW |
5410 | while (pCurrent2) |
5411 | { | |
5412 | wxWindow* pGrandChild = pCurrent2->GetData(); | |
5413 | ||
5414 | vPoint3.x = vPoint2.x; | |
5415 | vPoint3.y = vPoint2.y; | |
5416 | ::WinMapWindowPoints( pChild->GetHWND() | |
5417 | ,pGrandChild->GetHWND() | |
5418 | ,&vPoint3 | |
5419 | ,1 | |
5420 | ); | |
5421 | ::WinQueryWindowRect(pGrandChild->GetHWND(), &vRect); | |
5422 | if (::WinPtInRect(vHabmain, &vRect, &vPoint3)) | |
5423 | { | |
5424 | hWndUnderMouse = GetHwndOf(pGrandChild); | |
5425 | pWinUnderMouse = pGrandChild; | |
5426 | break; | |
5427 | } | |
5428 | pCurrent2 = pCurrent2->GetNext(); | |
5429 | } | |
5430 | if (pGrandChild) | |
5431 | break; | |
5432 | } | |
5433 | hWndUnderMouse = GetHwndOf(pChild); | |
5434 | pWinUnderMouse = pChild; | |
5435 | rcVisible = ::WinIsWindowVisible(hWndUnderMouse); | |
5436 | rcEnabled = ::WinIsWindowEnabled(hWndUnderMouse); | |
5437 | if (rcVisible && rcEnabled) | |
5438 | break; | |
5439 | } | |
5440 | pCurrent = pCurrent->GetNext(); | |
5441 | } | |
5442 | } | |
430974f8 | 5443 | } |
b720b24d DW |
5444 | rcVisible = ::WinIsWindowVisible(hWndUnderMouse); |
5445 | rcEnabled = ::WinIsWindowEnabled(hWndUnderMouse); | |
5446 | ||
430974f8 DW |
5447 | |
5448 | // | |
5449 | // Check that we have a child window which is susceptible to receive mouse | |
5450 | // events: for this it must be shown and enabled | |
b720b24d | 5451 | // |
430974f8 DW |
5452 | if ( hWndUnderMouse && |
5453 | hWndUnderMouse != hWnd && | |
b720b24d | 5454 | rcVisible && rcEnabled) |
430974f8 | 5455 | { |
b720b24d DW |
5456 | wxWindow* pWinUnderMouse = wxFindWinFromHandle((WXHWND)hWndUnderMouse); |
5457 | ||
430974f8 DW |
5458 | if (pWinUnderMouse) |
5459 | { | |
b720b24d DW |
5460 | // |
5461 | // Translate the mouse coords to the other window coords | |
5462 | // | |
430974f8 DW |
5463 | pWin = pWinUnderMouse; |
5464 | } | |
5465 | } | |
5466 | return pWin; | |
5467 | } // end of FindWindowForMouseEvent | |
5468 |