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