]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: windows.cpp | |
3 | // Purpose: wxWindow | |
4 | // Author: David Webster | |
5 | // Modified by: | |
6 | // Created: 10/12/99 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) David Webster | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | // | |
13 | // For compilers that support precompilation, includes "wx.h". | |
14 | // | |
15 | #include "wx/wxprec.h" | |
16 | ||
17 | #ifndef WX_PRECOMP | |
18 | #define INCL_DOS | |
19 | #define INCL_PM | |
20 | #include <os2.h> | |
21 | #include "wx/window.h" | |
22 | #include "wx/accel.h" | |
23 | #include "wx/setup.h" | |
24 | #include "wx/menu.h" | |
25 | #include "wx/dc.h" | |
26 | #include "wx/dcclient.h" | |
27 | #include "wx/utils.h" | |
28 | #include "wx/app.h" | |
29 | #include "wx/panel.h" | |
30 | #include "wx/layout.h" | |
31 | #include "wx/dialog.h" | |
32 | #include "wx/frame.h" | |
33 | #include "wx/listbox.h" | |
34 | #include "wx/button.h" | |
35 | #include "wx/msgdlg.h" | |
36 | ||
37 | #include <stdio.h> | |
38 | #endif | |
39 | ||
40 | #define DEBUG_PRINTF(NAME) { static int raz=0; \ | |
41 | printf( #NAME " %i\n",raz); fflush(stdout); \ | |
42 | raz++; \ | |
43 | } | |
44 | ||
45 | #if wxUSE_OWNER_DRAWN | |
46 | #include "wx/ownerdrw.h" | |
47 | #endif | |
48 | ||
49 | #if wxUSE_DRAG_AND_DROP | |
50 | #include "wx/dnd.h" | |
51 | #endif | |
52 | ||
53 | #include "wx/menuitem.h" | |
54 | #include "wx/log.h" | |
55 | ||
56 | #include "wx/os2/private.h" | |
57 | ||
58 | #if wxUSE_TOOLTIPS | |
59 | #include "wx/tooltip.h" | |
60 | #endif | |
61 | ||
62 | #if wxUSE_CARET | |
63 | #include "wx/caret.h" | |
64 | #endif // wxUSE_CARET | |
65 | ||
66 | #include "wx/intl.h" | |
67 | #include "wx/log.h" | |
68 | ||
69 | ||
70 | #include "wx/textctrl.h" | |
71 | ||
72 | #include <string.h> | |
73 | ||
74 | // | |
75 | // Place compiler, OS specific includes here | |
76 | // | |
77 | ||
78 | // | |
79 | // Standard macros -- these are for OS/2 PM, but most GUI's have something similar | |
80 | // | |
81 | #ifndef GET_X_LPARAM | |
82 | // | |
83 | // SHORT1FROMMP -- LOWORD | |
84 | // | |
85 | #define GET_X_LPARAM(mp) ((unsigned short)(unsigned long)(mp)) | |
86 | // | |
87 | // SHORT2FROMMP -- HIWORD | |
88 | // | |
89 | #define GET_Y_LPARAM(mp) ((unsigned short)(unsigned long)(mp >> 16)) | |
90 | #endif // GET_X_LPARAM | |
91 | ||
92 | #ifndef CW_USEDEFAULT | |
93 | # define CW_USEDEFAULT ((int)0x80000000) | |
94 | #endif | |
95 | ||
96 | // --------------------------------------------------------------------------- | |
97 | // global variables | |
98 | // --------------------------------------------------------------------------- | |
99 | ||
100 | // | |
101 | // The last Windows message we got (MT-UNSAFE) | |
102 | // | |
103 | QMSG s_currentMsg; | |
104 | ||
105 | wxMenu* wxCurrentPopupMenu = NULL; | |
106 | extern wxList WXDLLEXPORT wxPendingDelete; | |
107 | #if !defined(__VISAGECPP__) || (__IBMCPP__ < 400) | |
108 | extern wxChar wxCanvasClassName[]; | |
109 | #endif | |
110 | wxList* wxWinHandleList = NULL; | |
111 | ||
112 | // --------------------------------------------------------------------------- | |
113 | // private functions | |
114 | // --------------------------------------------------------------------------- | |
115 | ||
116 | // | |
117 | // the window proc for all our windows; most gui's have something similar | |
118 | // | |
119 | MRESULT EXPENTRY wxWndProc( HWND hWnd | |
120 | ,ULONG message | |
121 | ,MPARAM mp1 | |
122 | ,MPARAM mp2 | |
123 | ); | |
124 | ||
125 | #ifdef __WXDEBUG__ | |
126 | const char *wxGetMessageName(int message); | |
127 | #endif //__WXDEBUG__ | |
128 | ||
129 | void wxRemoveHandleAssociation(wxWindow* pWin); | |
130 | void wxAssociateWinWithHandle( HWND hWnd | |
131 | ,wxWindow* pWin | |
132 | ); | |
133 | wxWindow* wxFindWinFromHandle(WXHWND hWnd); | |
134 | ||
135 | // | |
136 | // This magical function is used to translate VK_APPS key presses to right | |
137 | // mouse clicks | |
138 | // | |
139 | static void TranslateKbdEventToMouse( wxWindow* pWin | |
140 | ,int* pX | |
141 | ,int* pY | |
142 | ,MPARAM* pFlags | |
143 | ); | |
144 | ||
145 | // | |
146 | // get the current state of SHIFT/CTRL keys | |
147 | // | |
148 | static inline bool IsShiftDown() { return (::WinGetKeyState(HWND_DESKTOP, VK_SHIFT) & 0x8000) != 0; } | |
149 | static inline bool IsCtrlDown() { return (::WinGetKeyState(HWND_DESKTOP, VK_CTRL) & 0x8000) != 0; } | |
150 | // --------------------------------------------------------------------------- | |
151 | // event tables | |
152 | // --------------------------------------------------------------------------- | |
153 | ||
154 | IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxWindowBase) | |
155 | ||
156 | BEGIN_EVENT_TABLE(wxWindow, wxWindowBase) | |
157 | EVT_ERASE_BACKGROUND(wxWindow::OnEraseBackground) | |
158 | EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged) | |
159 | EVT_INIT_DIALOG(wxWindow::OnInitDialog) | |
160 | EVT_IDLE(wxWindow::OnIdle) | |
161 | END_EVENT_TABLE() | |
162 | ||
163 | // =========================================================================== | |
164 | // implementation | |
165 | // =========================================================================== | |
166 | ||
167 | // | |
168 | // Find an item given the PM Window id | |
169 | // | |
170 | wxWindow* wxWindow::FindItem( | |
171 | long lId | |
172 | ) const | |
173 | { | |
174 | wxControl* pItem = wxDynamicCast( this | |
175 | ,wxControl | |
176 | ); | |
177 | ||
178 | if (pItem) | |
179 | { | |
180 | // | |
181 | // I it we or one of our "internal" children? | |
182 | // | |
183 | if (pItem->GetId() == lId || | |
184 | (pItem->GetSubcontrols().Index(lId) != wxNOT_FOUND)) | |
185 | { | |
186 | return pItem; | |
187 | } | |
188 | } | |
189 | ||
190 | wxWindowList::Node* pCurrent = GetChildren().GetFirst(); | |
191 | ||
192 | while (pCurrent) | |
193 | { | |
194 | wxWindow* pChildWin = pCurrent->GetData(); | |
195 | wxWindow* pWnd = pChildWin->FindItem(lId); | |
196 | ||
197 | if (pWnd) | |
198 | return pWnd; | |
199 | ||
200 | pCurrent = pCurrent->GetNext(); | |
201 | } | |
202 | return(NULL); | |
203 | } // end of wxWindow::FindItem | |
204 | ||
205 | // | |
206 | // Find an item given the PM Window handle | |
207 | // | |
208 | wxWindow* wxWindow::FindItemByHWND( | |
209 | WXHWND hWnd | |
210 | , bool bControlOnly | |
211 | ) const | |
212 | { | |
213 | wxWindowList::Node* pCurrent = GetChildren().GetFirst(); | |
214 | ||
215 | while (pCurrent) | |
216 | { | |
217 | wxWindow* pParent = pCurrent->GetData(); | |
218 | ||
219 | // | |
220 | // Do a recursive search. | |
221 | // | |
222 | wxWindow* pWnd = pParent->FindItemByHWND(hWnd); | |
223 | ||
224 | if (pWnd) | |
225 | return(pWnd); | |
226 | ||
227 | if (!bControlOnly || pParent->IsKindOf(CLASSINFO(wxControl))) | |
228 | { | |
229 | wxWindow* pItem = pCurrent->GetData(); | |
230 | ||
231 | if (pItem->GetHWND() == hWnd) | |
232 | return(pItem); | |
233 | else | |
234 | { | |
235 | if (pItem->ContainsHWND(hWnd)) | |
236 | return(pItem); | |
237 | } | |
238 | } | |
239 | pCurrent = pCurrent->GetNext(); | |
240 | } | |
241 | return(NULL); | |
242 | } // end of wxWindow::FindItemByHWND | |
243 | ||
244 | // | |
245 | // Default command handler | |
246 | // | |
247 | bool wxWindow::OS2Command( | |
248 | WXUINT WXUNUSED(uParam) | |
249 | , WXWORD WXUNUSED(uId) | |
250 | ) | |
251 | { | |
252 | ||
253 | DEBUG_PRINTF(wxWindow::OS2Command); | |
254 | ||
255 | return(FALSE); | |
256 | } | |
257 | ||
258 | // ---------------------------------------------------------------------------- | |
259 | // constructors and such | |
260 | // ---------------------------------------------------------------------------- | |
261 | ||
262 | void wxWindow::Init() | |
263 | { | |
264 | // | |
265 | // Generic | |
266 | // | |
267 | InitBase(); | |
268 | ||
269 | // | |
270 | // PM specific | |
271 | // | |
272 | m_bDoubleClickAllowed = 0; | |
273 | m_bWinCaptured = FALSE; | |
274 | ||
275 | m_isBeingDeleted = FALSE; | |
276 | m_fnOldWndProc = 0; | |
277 | m_bUseCtl3D = FALSE; | |
278 | m_bMouseInWindow = FALSE; | |
279 | ||
280 | // | |
281 | // wxWnd | |
282 | // | |
283 | m_hMenu = 0; | |
284 | m_hWnd = 0; | |
285 | ||
286 | // | |
287 | // Pass WM_GETDLGCODE to DefWindowProc() | |
288 | m_lDlgCode = 0; | |
289 | ||
290 | m_nXThumbSize = 0; | |
291 | m_nYThumbSize = 0; | |
292 | m_bBackgroundTransparent = FALSE; | |
293 | ||
294 | // | |
295 | // As all windows are created with WS_VISIBLE style... | |
296 | // | |
297 | m_isShown = TRUE; | |
298 | ||
299 | #if wxUSE_MOUSEEVENT_HACK | |
300 | m_lLastMouseX = | |
301 | m_lLastMouseY = -1; | |
302 | m_nLastMouseEvent = -1; | |
303 | #endif // wxUSE_MOUSEEVENT_HACK | |
304 | ||
305 | DEBUG_PRINTF(wxWindow::Init-End); | |
306 | ||
307 | } // wxWindow::Init | |
308 | ||
309 | // | |
310 | // Destructor | |
311 | // | |
312 | wxWindow::~wxWindow() | |
313 | { | |
314 | DEBUG_PRINTF(wxWindow::~wxWindow-Start); | |
315 | m_isBeingDeleted = TRUE; | |
316 | ||
317 | OS2DetachWindowMenu(); | |
318 | if (m_parent) | |
319 | m_parent->RemoveChild(this); | |
320 | DestroyChildren(); | |
321 | ||
322 | if (m_hWnd) | |
323 | { | |
324 | // UnsubclassWin(); | |
325 | ||
326 | if(!::WinDestroyWindow(GetHWND())) | |
327 | wxLogLastError(wxT("DestroyWindow")); | |
328 | // | |
329 | // remove hWnd <-> wxWindow association | |
330 | // | |
331 | wxRemoveHandleAssociation(this); | |
332 | } | |
333 | DEBUG_PRINTF(wxWindow::~wxWindow-End); | |
334 | } // end of wxWindow::~wxWindow | |
335 | ||
336 | bool wxWindow::Create( | |
337 | wxWindow* pParent | |
338 | , wxWindowID vId | |
339 | , const wxPoint& rPos | |
340 | , const wxSize& rSize | |
341 | , long lStyle | |
342 | , const wxString& rName | |
343 | ) | |
344 | { | |
345 | HWND hParent = NULLHANDLE; | |
346 | ||
347 | wxCHECK_MSG(pParent, FALSE, wxT("can't create wxWindow without parent")); | |
348 | ||
349 | if ( !CreateBase( pParent | |
350 | ,vId | |
351 | ,rPos | |
352 | ,rSize | |
353 | ,lStyle | |
354 | ,wxDefaultValidator | |
355 | ,rName | |
356 | )) | |
357 | return(FALSE); | |
358 | ||
359 | if (pParent) | |
360 | { | |
361 | pParent->AddChild(this); | |
362 | hParent = GetWinHwnd(pParent); | |
363 | } | |
364 | else | |
365 | hParent = HWND_DESKTOP; | |
366 | ||
367 | ULONG ulCreateFlags = 0L; | |
368 | ||
369 | ||
370 | // | |
371 | // Most wxSTYLES are really PM Class specific styles and will be | |
372 | // set in those class create procs. PM's basic windows styles are | |
373 | // very limited. | |
374 | // | |
375 | if (lStyle & wxCLIP_CHILDREN ) | |
376 | ulCreateFlags |= WS_CLIPCHILDREN; | |
377 | ||
378 | // | |
379 | // Empty stuff for now since PM has no custome 3D effects | |
380 | // Doesn't mean someone cannot make some up though | |
381 | // | |
382 | bool bWant3D; | |
383 | WXDWORD dwExStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &bWant3D); | |
384 | ||
385 | // | |
386 | // Generic OS/2 Windows are created with no owner, no Z Order, no Control data, | |
387 | // and no presentation parameters | |
388 | // | |
389 | OS2Create( hParent | |
390 | ,(PSZ)wxCanvasClassName | |
391 | ,rName.c_str() | |
392 | ,ulCreateFlags | |
393 | ,rPos.x | |
394 | ,rPos.y | |
395 | ,WidthDefault(rSize.x) | |
396 | ,HeightDefault(rSize.y) | |
397 | ,NULLHANDLE | |
398 | ,NULLHANDLE | |
399 | ,m_windowId | |
400 | ); | |
401 | ||
402 | return(TRUE); | |
403 | } // end of wxWindow::Create | |
404 | ||
405 | // --------------------------------------------------------------------------- | |
406 | // basic operations | |
407 | // --------------------------------------------------------------------------- | |
408 | ||
409 | void wxWindow::SetFocus() | |
410 | { | |
411 | HWND hWnd = GetHwnd(); | |
412 | ||
413 | if (hWnd) | |
414 | ::WinSetFocus(HWND_DESKTOP, hWnd); | |
415 | } // end of wxWindow::SetFocus | |
416 | ||
417 | wxWindow* wxWindowBase::FindFocus() | |
418 | { | |
419 | HWND hWnd = ::WinQueryFocus(HWND_DESKTOP); | |
420 | ||
421 | if (hWnd) | |
422 | { | |
423 | return wxFindWinFromHandle((WXHWND)hWnd); | |
424 | } | |
425 | return NULL; | |
426 | } // wxWindowBase::FindFocus | |
427 | ||
428 | bool wxWindow::Enable( | |
429 | bool bEnable | |
430 | ) | |
431 | { | |
432 | if (!wxWindowBase::Enable(bEnable)) | |
433 | return(FALSE); | |
434 | ||
435 | HWND hWnd = GetHwnd(); | |
436 | ||
437 | if ( hWnd ) | |
438 | ::WinEnableWindow(hWnd, (BOOL)bEnable); | |
439 | ||
440 | wxWindowList::Node* pNode = GetChildren().GetFirst(); | |
441 | ||
442 | while (pNode) | |
443 | { | |
444 | wxWindow* pChild = pNode->GetData(); | |
445 | ||
446 | pChild->Enable(bEnable); | |
447 | pNode = pNode->GetNext(); | |
448 | } | |
449 | return(TRUE); | |
450 | } // end of wxWindow::Enable | |
451 | ||
452 | bool wxWindow::Show( | |
453 | bool bShow | |
454 | ) | |
455 | { | |
456 | if (!wxWindowBase::Show(bShow)) | |
457 | return(FALSE); | |
458 | ||
459 | HWND hWnd = GetHwnd(); | |
460 | ||
461 | ::WinShowWindow(hWnd, bShow); | |
462 | ||
463 | if (bShow) | |
464 | { | |
465 | ::WinSetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE | SWP_ZORDER); | |
466 | } | |
467 | return(TRUE); | |
468 | } // end of wxWindow::Show | |
469 | ||
470 | void wxWindow::Raise() | |
471 | { | |
472 | ::WinSetWindowPos(GetHwnd(), HWND_TOP, 0, 0, 0, 0, SWP_ZORDER | SWP_ACTIVATE); | |
473 | } // end of wxWindow::Raise | |
474 | ||
475 | void wxWindow::Lower() | |
476 | { | |
477 | ::WinSetWindowPos(GetHwnd(), HWND_BOTTOM, 0, 0, 0, 0, SWP_ZORDER | SWP_DEACTIVATE); | |
478 | } // end of wxWindow::Lower | |
479 | ||
480 | void wxWindow::SetTitle( | |
481 | const wxString& rTitle | |
482 | ) | |
483 | { | |
484 | ::WinSetWindowText(GetHwnd(), rTitle.c_str()); | |
485 | } // end of wxWindow::SetTitle | |
486 | ||
487 | wxString wxWindow::GetTitle() const | |
488 | { | |
489 | return wxGetWindowText(GetHWND()); | |
490 | } // end of wxWindow::GetTitle | |
491 | ||
492 | void wxWindow::CaptureMouse() | |
493 | { | |
494 | HWND hWnd = GetHwnd(); | |
495 | ||
496 | if (hWnd && !m_bWinCaptured) | |
497 | { | |
498 | ::WinSetCapture(HWND_DESKTOP, hWnd); | |
499 | m_bWinCaptured = TRUE; | |
500 | } | |
501 | } // end of wxWindow::GetTitle | |
502 | ||
503 | void wxWindow::ReleaseMouse() | |
504 | { | |
505 | if (m_bWinCaptured) | |
506 | { | |
507 | ::WinSetCapture(HWND_DESKTOP, NULLHANDLE); | |
508 | m_bWinCaptured = FALSE; | |
509 | } | |
510 | } // end of wxWindow::ReleaseMouse | |
511 | ||
512 | bool wxWindow::SetFont( | |
513 | const wxFont& rFont | |
514 | ) | |
515 | { | |
516 | DEBUG_PRINTF(wxWindow::SetFont); | |
517 | if (!wxWindowBase::SetFont(rFont)) | |
518 | { | |
519 | // nothing to do | |
520 | return(FALSE); | |
521 | } | |
522 | ||
523 | HWND hWnd = GetHwnd(); | |
524 | ||
525 | if (hWnd != 0) | |
526 | { | |
527 | wxChar zFont[128]; | |
528 | ||
529 | sprintf(zFont, "%d.%s", rFont.GetPointSize(), rFont.GetFaceName().c_str()); | |
530 | return(::WinSetPresParam(hWnd, PP_FONTNAMESIZE, strlen(zFont), (PVOID)zFont)); | |
531 | } | |
532 | return(TRUE); | |
533 | } | |
534 | ||
535 | bool wxWindow::SetCursor( | |
536 | const wxCursor& rCursor | |
537 | ) // check if base implementation is OK | |
538 | { | |
539 | if ( !wxWindowBase::SetCursor(rCursor)) | |
540 | { | |
541 | // no change | |
542 | return FALSE; | |
543 | } | |
544 | ||
545 | wxASSERT_MSG( m_cursor.Ok(), | |
546 | wxT("cursor must be valid after call to the base version")); | |
547 | ||
548 | HWND hWnd = GetHwnd(); | |
549 | POINTL vPoint; | |
550 | RECTL vRect; | |
551 | HPS hPS; | |
552 | HRGN hRGN; | |
553 | ||
554 | hPS = ::WinGetPS(hWnd); | |
555 | ||
556 | ::WinQueryPointerPos(HWND_DESKTOP, &vPoint); | |
557 | ::WinQueryWindowRect(hWnd, &vRect); | |
558 | ||
559 | hRGN = ::GpiCreateRegion(hPS, 1L, &vRect); | |
560 | ||
561 | if ((::GpiPtInRegion(hPS, hRGN, &vPoint) == PRGN_INSIDE) && !wxIsBusy()) | |
562 | { | |
563 | ::WinSetPointer(HWND_DESKTOP, (HPOINTER)m_cursor.GetHCURSOR()); | |
564 | } | |
565 | return TRUE; | |
566 | } // end of wxWindow::SetCursor | |
567 | ||
568 | void wxWindow::WarpPointer( | |
569 | int nXPos | |
570 | , int nYPos | |
571 | ) | |
572 | { | |
573 | int nX = nXPos; | |
574 | int nY = nYPos; | |
575 | RECTL vRect; | |
576 | ||
577 | ::WinQueryWindowRect(GetHwnd(), &vRect); | |
578 | nX += vRect.xLeft; | |
579 | nY += vRect.yBottom; | |
580 | ||
581 | ::WinSetPointerPos(HWND_DESKTOP, (LONG)nX, (LONG)(nY)); | |
582 | } // end of wxWindow::WarpPointer | |
583 | ||
584 | #if WXWIN_COMPATIBILITY | |
585 | void wxWindow::OS2DeviceToLogical (float *x, float *y) const | |
586 | { | |
587 | } | |
588 | #endif // WXWIN_COMPATIBILITY | |
589 | ||
590 | // --------------------------------------------------------------------------- | |
591 | // scrolling stuff | |
592 | // --------------------------------------------------------------------------- | |
593 | ||
594 | #if WXWIN_COMPATIBILITY | |
595 | void wxWindow::SetScrollRange( | |
596 | int nOrient | |
597 | , int nRange | |
598 | , bool bRefresh | |
599 | ) | |
600 | { | |
601 | ::WinSendMsg(GetHwnd(), SBM_SETSCROLLBAR, (MPARAM)0, MPFROM2SHORT(0, nRange)); | |
602 | } // end of wxWindow::SetScrollRange | |
603 | ||
604 | void wxWindow::SetScrollPage( | |
605 | int nOrient | |
606 | , int nPage | |
607 | , bool bRefresh | |
608 | ) | |
609 | { | |
610 | if ( orient == wxHORIZONTAL ) | |
611 | m_xThumbSize = page; | |
612 | else | |
613 | m_yThumbSize = page; | |
614 | } | |
615 | ||
616 | int wxWindow::OldGetScrollRange( | |
617 | int nOrient | |
618 | ) const | |
619 | { | |
620 | MRESULT mRc; | |
621 | HWND hWnd = GetHwnd(); | |
622 | ||
623 | if (hWnd) | |
624 | { | |
625 | mRc = WinSendMsg(hWnd, SBM_QUERYRANGE, (MPARAM)0L, (MPARAM)0L); | |
626 | return(SHORT2FROMMR(mRc)); | |
627 | } | |
628 | return 0; | |
629 | } // end of wxWindow::OldGetScrollRange | |
630 | ||
631 | int wxWindow::GetScrollPage( | |
632 | int nOrient | |
633 | ) const | |
634 | { | |
635 | if (nOrient == wxHORIZONTAL) | |
636 | return m_nXThumbSize; | |
637 | else | |
638 | return m_nYThumbSize; | |
639 | } // end of wxWindow::GetScrollPage | |
640 | #endif // WXWIN_COMPATIBILITY | |
641 | ||
642 | int wxWindow::GetScrollPos( | |
643 | int nOrient | |
644 | ) const | |
645 | { | |
646 | return((int)::WinSendMsg(GetHwnd(), SBM_QUERYPOS, (MPARAM)NULL, (MPARAM)NULL)); | |
647 | } // end of wxWindow::GetScrollPos | |
648 | ||
649 | int wxWindow::GetScrollRange( | |
650 | int nOrient | |
651 | ) const | |
652 | { | |
653 | MRESULT mr; | |
654 | ||
655 | mr = ::WinSendMsg(GetHwnd(), SBM_QUERYRANGE, (MPARAM)NULL, (MPARAM)NULL); | |
656 | return((int)SHORT2FROMMR(mr)); | |
657 | } // end of wxWindow::GetScrollRange | |
658 | ||
659 | int wxWindow::GetScrollThumb( | |
660 | int nOrient | |
661 | ) const | |
662 | { | |
663 | WNDPARAMS vWndParams; | |
664 | PSBCDATA pSbcd; | |
665 | ||
666 | ::WinSendMsg(GetHwnd(), WM_QUERYWINDOWPARAMS, (MPARAM)&vWndParams, (MPARAM)NULL); | |
667 | pSbcd = (PSBCDATA)vWndParams.pCtlData; | |
668 | return((int)pSbcd->posThumb); | |
669 | } // end of wxWindow::GetScrollThumb | |
670 | ||
671 | void wxWindow::SetScrollPos( | |
672 | int nOrient | |
673 | , int nPos | |
674 | , bool bRefresh | |
675 | ) | |
676 | { | |
677 | ::WinSendMsg(GetHwnd(), SBM_SETPOS, (MPARAM)nPos, (MPARAM)NULL); | |
678 | } // end of wxWindow::SetScrollPos( | |
679 | ||
680 | void wxWindow::SetScrollbar( | |
681 | int nOrient | |
682 | , int nPos | |
683 | , int nThumbVisible | |
684 | , int nRange | |
685 | , bool bRefresh | |
686 | ) | |
687 | { | |
688 | ::WinSendMsg(GetHwnd(), SBM_SETSCROLLBAR, (MPARAM)nPos, MPFROM2SHORT(0, nRange)); | |
689 | if (nOrient == wxHORIZONTAL) | |
690 | { | |
691 | m_nXThumbSize = nThumbVisible; | |
692 | } | |
693 | else | |
694 | { | |
695 | m_nYThumbSize = nThumbVisible; | |
696 | } | |
697 | } // end of wxWindow::SetScrollbar | |
698 | ||
699 | void wxWindow::ScrollWindow( | |
700 | int nDx | |
701 | , int nDy | |
702 | , const wxRect* pRect | |
703 | ) | |
704 | { | |
705 | RECTL vRect2; | |
706 | ||
707 | if (pRect) | |
708 | { | |
709 | vRect2.xLeft = pRect->x; | |
710 | vRect2.yTop = pRect->y; | |
711 | vRect2.xRight = pRect->x + pRect->width; | |
712 | vRect2.yBottom = pRect->y + pRect->height; | |
713 | } | |
714 | ||
715 | if (pRect) | |
716 | ::WinScrollWindow(GetHwnd(), (LONG)nDx, (LONG)nDy, &vRect2, NULL, NULLHANDLE, NULL, 0L); | |
717 | else | |
718 | ::WinScrollWindow(GetHwnd(), nDx, nDy, NULL, NULL, NULLHANDLE, NULL, 0L); | |
719 | } // end of wxWindow::ScrollWindow | |
720 | ||
721 | // --------------------------------------------------------------------------- | |
722 | // subclassing | |
723 | // --------------------------------------------------------------------------- | |
724 | ||
725 | void wxWindow::SubclassWin( | |
726 | WXHWND hWnd | |
727 | ) | |
728 | { | |
729 | HWND hwnd = (HWND)hWnd; | |
730 | ||
731 | wxASSERT_MSG( !m_fnOldWndProc, wxT("subclassing window twice?") ); | |
732 | ||
733 | wxCHECK_RET(::WinIsWindow(vHabmain, hwnd), wxT("invalid HWND in SubclassWin") ); | |
734 | ||
735 | // wxAssociateWinWithHandle(hwnd, this); | |
736 | ||
737 | m_fnOldWndProc = (WXFARPROC) ::WinSubclassWindow(hwnd, (PFNWP)wxWndProc); | |
738 | // ::WinSetWindowULong(hwnd, QWL_USER, (ULONG)wxWndProc); | |
739 | } // end of wxWindow::SubclassWin | |
740 | ||
741 | void wxWindow::UnsubclassWin() | |
742 | { | |
743 | // wxRemoveHandleAssociation(this); | |
744 | ||
745 | // | |
746 | // Restore old Window proc | |
747 | // | |
748 | HWND hwnd = GetHWND(); | |
749 | ||
750 | if (m_hWnd) | |
751 | { | |
752 | // m_hWnd = 0; | |
753 | ||
754 | wxCHECK_RET( ::WinIsWindow(vHabmain, hwnd), wxT("invalid HWND in UnsubclassWin") ); | |
755 | ||
756 | PFNWP fnProc = (PFNWP)::WinQueryWindowPtr(hwnd, QWP_PFNWP); | |
757 | if ( (m_fnOldWndProc != 0) && (fnProc != (PFNWP) m_fnOldWndProc)) | |
758 | { | |
759 | WinSubclassWindow(hwnd, (PFNWP)m_fnOldWndProc); | |
760 | m_fnOldWndProc = 0; | |
761 | } | |
762 | } | |
763 | } // end of wxWindow::UnsubclassWin | |
764 | ||
765 | // | |
766 | // Make a Windows extended style from the given wxWindows window style | |
767 | // | |
768 | WXDWORD wxWindow::MakeExtendedStyle( | |
769 | long lStyle | |
770 | , bool bEliminateBorders | |
771 | ) | |
772 | { | |
773 | // | |
774 | // PM does not support extended style | |
775 | // | |
776 | WXDWORD exStyle = 0; | |
777 | return exStyle; | |
778 | } // end of wxWindow::MakeExtendedStyle | |
779 | ||
780 | // | |
781 | // Determines whether native 3D effects or CTL3D should be used, | |
782 | // applying a default border style if required, and returning an extended | |
783 | // style to pass to CreateWindowEx. | |
784 | // | |
785 | WXDWORD wxWindow::Determine3DEffects( | |
786 | WXDWORD dwDefaultBorderStyle | |
787 | , bool* pbWant3D | |
788 | ) const | |
789 | { | |
790 | WXDWORD dwStyle = 0L; | |
791 | ||
792 | // | |
793 | // Native PM does not have any specialize 3D effects like WIN32 does | |
794 | // | |
795 | *pbWant3D = FALSE; | |
796 | return dwStyle; | |
797 | } // end of wxWindow::Determine3DEffects | |
798 | ||
799 | #if WXWIN_COMPATIBILITY | |
800 | void wxWindow::OnCommand( | |
801 | wxWindow& rWin | |
802 | , wxCommandEvent& rEvent | |
803 | ) | |
804 | { | |
805 | if (GetEventHandler()->ProcessEvent(rEvent)) | |
806 | return; | |
807 | if (m_parent) | |
808 | m_parent->GetEventHandler()->OnCommand( rWin | |
809 | ,rEvent | |
810 | ); | |
811 | } // end of wxWindow::OnCommand | |
812 | ||
813 | wxObject* wxWindow::GetChild( | |
814 | int nNumber | |
815 | ) const | |
816 | { | |
817 | // | |
818 | // Return a pointer to the Nth object in the Panel | |
819 | // | |
820 | wxNode* pNode = GetChildren().First(); | |
821 | int n = nNumber; | |
822 | ||
823 | while (pNode && n--) | |
824 | pNode = pNode->Next(); | |
825 | if (pNode) | |
826 | { | |
827 | wxObject* pObj = (wxObject*)pNode->Data(); | |
828 | return(pObj); | |
829 | } | |
830 | else | |
831 | return NULL; | |
832 | } // end of wxWindow::GetChild | |
833 | ||
834 | #endif // WXWIN_COMPATIBILITY | |
835 | ||
836 | // | |
837 | // Setup background and foreground colours correctly | |
838 | // | |
839 | void wxWindow::SetupColours() | |
840 | { | |
841 | if ( GetParent() ) | |
842 | SetBackgroundColour(GetParent()->GetBackgroundColour()); | |
843 | } // end of wxWindow::SetupColours | |
844 | ||
845 | void wxWindow::OnIdle( | |
846 | wxIdleEvent& rEvent | |
847 | ) | |
848 | { | |
849 | // | |
850 | // Check if we need to send a LEAVE event | |
851 | // | |
852 | if (m_bMouseInWindow) | |
853 | { | |
854 | POINTL vPoint; | |
855 | ||
856 | ::WinQueryPointerPos(HWND_DESKTOP, &vPoint); | |
857 | if (::WinWindowFromPoint(HWND_DESKTOP, &vPoint, FALSE) != (HWND)GetHwnd()) | |
858 | { | |
859 | // | |
860 | // Generate a LEAVE event | |
861 | // | |
862 | m_bMouseInWindow = FALSE; | |
863 | ||
864 | // | |
865 | // Unfortunately the mouse button and keyboard state may have changed | |
866 | // by the time the OnIdle function is called, so 'state' may be | |
867 | // meaningless. | |
868 | // | |
869 | int nState = 0; | |
870 | ||
871 | if (::WinGetKeyState(HWND_DESKTOP, VK_SHIFT) != 0) | |
872 | nState |= VK_SHIFT; | |
873 | if (::WinGetKeyState(HWND_DESKTOP, VK_CTRL) != 0); | |
874 | nState |= VK_CTRL; | |
875 | ||
876 | wxMouseEvent rEvent(wxEVT_LEAVE_WINDOW); | |
877 | ||
878 | InitMouseEvent( rEvent | |
879 | ,vPoint.x | |
880 | ,vPoint.y | |
881 | ,nState | |
882 | ); | |
883 | (void)GetEventHandler()->ProcessEvent(rEvent); | |
884 | } | |
885 | } | |
886 | UpdateWindowUI(); | |
887 | } // end of wxWindow::OnIdle | |
888 | ||
889 | // | |
890 | // Set this window to be the child of 'parent'. | |
891 | // | |
892 | bool wxWindow::Reparent( | |
893 | wxWindow* pParent | |
894 | ) | |
895 | { | |
896 | if (!wxWindowBase::Reparent(pParent)) | |
897 | return FALSE; | |
898 | ||
899 | HWND hWndChild = GetHwnd(); | |
900 | HWND hWndParent = GetParent() ? GetWinHwnd(GetParent()) : (HWND)0; | |
901 | ||
902 | ::WinSetParent(hWndChild, hWndParent, TRUE); | |
903 | return TRUE; | |
904 | } // end of wxWindow::Reparent | |
905 | ||
906 | void wxWindow::Clear() | |
907 | { | |
908 | wxClientDC vDc(this); | |
909 | wxBrush vBrush( GetBackgroundColour() | |
910 | ,wxSOLID | |
911 | ); | |
912 | ||
913 | vDc.SetBackground(vBrush); | |
914 | vDc.Clear(); | |
915 | } // end of wxWindow::Clear | |
916 | ||
917 | void wxWindow::Refresh( | |
918 | bool bEraseBack | |
919 | , const wxRect* pRect | |
920 | ) | |
921 | { | |
922 | HWND hWnd = GetHwnd(); | |
923 | ||
924 | if (hWnd) | |
925 | { | |
926 | if (pRect) | |
927 | { | |
928 | RECTL vOs2Rect; | |
929 | ||
930 | vOs2Rect.xLeft = pRect->x; | |
931 | vOs2Rect.yTop = pRect->y; | |
932 | vOs2Rect.xRight = pRect->x + pRect->width; | |
933 | vOs2Rect.yBottom = pRect->y + pRect->height; | |
934 | ||
935 | ::WinInvalidateRect(hWnd, &vOs2Rect, bEraseBack); | |
936 | } | |
937 | else | |
938 | ::WinInvalidateRect(hWnd, NULL, bEraseBack); | |
939 | } | |
940 | } // end of wxWindow::Refresh | |
941 | ||
942 | // --------------------------------------------------------------------------- | |
943 | // drag and drop | |
944 | // --------------------------------------------------------------------------- | |
945 | ||
946 | #if wxUSE_DRAG_AND_DROP | |
947 | void wxWindow::SetDropTarget( | |
948 | wxDropTarget* pDropTarget | |
949 | ) | |
950 | { | |
951 | if (m_dropTarget != 0) | |
952 | { | |
953 | m_dropTarget->Revoke(m_hWnd); | |
954 | delete m_dropTarget; | |
955 | } | |
956 | m_dropTarget = pDropTarget; | |
957 | if (m_dropTarget != 0) | |
958 | m_dropTarget->Register(m_hWnd); | |
959 | } // end of wxWindow::SetDropTarget | |
960 | #endif | |
961 | ||
962 | // | |
963 | // old style file-manager drag&drop support: we retain the old-style | |
964 | // DragAcceptFiles in parallel with SetDropTarget. | |
965 | // | |
966 | void wxWindow::DragAcceptFiles( | |
967 | bool bAccept | |
968 | ) | |
969 | { | |
970 | HWND hWnd = GetHwnd(); | |
971 | ||
972 | if (hWnd && bAccept) | |
973 | ::DrgAcceptDroppedFiles(hWnd, NULL, NULL, DO_COPY, 0L); | |
974 | } // end of wxWindow::DragAcceptFiles | |
975 | ||
976 | // ---------------------------------------------------------------------------- | |
977 | // tooltips | |
978 | // ---------------------------------------------------------------------------- | |
979 | ||
980 | #if wxUSE_TOOLTIPS | |
981 | ||
982 | void wxWindow::DoSetToolTip( | |
983 | wxToolTip* pTooltip | |
984 | ) | |
985 | { | |
986 | wxWindowBase::DoSetToolTip(pTooltip); | |
987 | ||
988 | if (m_tooltip) | |
989 | m_tooltip->SetWindow(this); | |
990 | } // end of wxWindow::DoSetToolTip | |
991 | ||
992 | #endif // wxUSE_TOOLTIPS | |
993 | ||
994 | // --------------------------------------------------------------------------- | |
995 | // moving and resizing | |
996 | // --------------------------------------------------------------------------- | |
997 | ||
998 | // Get total size | |
999 | void wxWindow::DoGetSize( | |
1000 | int* pWidth | |
1001 | , int* pHeight | |
1002 | ) const | |
1003 | { | |
1004 | HWND hWnd = GetHwnd(); | |
1005 | RECTL vRect; | |
1006 | ||
1007 | ::WinQueryWindowRect(hWnd, &vRect); | |
1008 | ||
1009 | if (pWidth) | |
1010 | *pWidth = vRect.xRight - vRect.xLeft; | |
1011 | if (pHeight ) | |
1012 | // OS/2 PM is backwards from windows | |
1013 | *pHeight = vRect.yTop - vRect.yBottom; | |
1014 | } // end of wxWindow::DoGetSize | |
1015 | ||
1016 | void wxWindow::DoGetPosition( | |
1017 | int* pX | |
1018 | , int* pY | |
1019 | ) const | |
1020 | { | |
1021 | HWND hWnd = GetHwnd(); | |
1022 | RECT vRect; | |
1023 | POINTL vPoint; | |
1024 | ||
1025 | ::WinQueryWindowRect(hWnd, &vRect); | |
1026 | ||
1027 | vPoint.x = vRect.xLeft; | |
1028 | vPoint.y = vRect.yBottom; | |
1029 | ||
1030 | // | |
1031 | // We do the adjustments with respect to the parent only for the "real" | |
1032 | // children, not for the dialogs/frames | |
1033 | // | |
1034 | if (!IsTopLevel()) | |
1035 | { | |
1036 | HWND hParentWnd = 0; | |
1037 | wxWindow* pParent = GetParent(); | |
1038 | ||
1039 | if (pParent) | |
1040 | hParentWnd = GetWinHwnd(pParent); | |
1041 | ||
1042 | // | |
1043 | // Since we now have the absolute screen coords, if there's a parent we | |
1044 | // must subtract its bottom left corner | |
1045 | // | |
1046 | if (hParentWnd) | |
1047 | { | |
1048 | RECTL vRect2; | |
1049 | ||
1050 | ::WinQueryWindowRect(hParentWnd, &vRect2); | |
1051 | vPoint.x -= vRect.xLeft; | |
1052 | vPoint.y -= vRect.yBottom; | |
1053 | } | |
1054 | ||
1055 | // | |
1056 | // We may be faking the client origin. So a window that's really at (0, | |
1057 | // 30) may appear (to wxWin apps) to be at (0, 0). | |
1058 | // | |
1059 | wxPoint vPt(pParent->GetClientAreaOrigin()); | |
1060 | ||
1061 | vPoint.x -= vPt.x; | |
1062 | vPoint.y -= vPt.y; | |
1063 | } | |
1064 | ||
1065 | if (pX) | |
1066 | *pX = vPoint.x; | |
1067 | if (pY) | |
1068 | *pY = vPoint.y; | |
1069 | } // end of wxWindow::DoGetPosition | |
1070 | ||
1071 | void wxWindow::DoScreenToClient( | |
1072 | int* pX | |
1073 | , int* pY | |
1074 | ) const | |
1075 | { | |
1076 | HWND hWnd = GetHwnd(); | |
1077 | SWP vSwp; | |
1078 | ||
1079 | ::WinQueryWindowPos(hWnd, &vSwp); | |
1080 | ||
1081 | if (pX) | |
1082 | *pX -= vSwp.x; | |
1083 | if (pY) | |
1084 | *pY -= vSwp.y; | |
1085 | } // end of wxWindow::DoScreenToClient | |
1086 | ||
1087 | void wxWindow::DoClientToScreen( | |
1088 | int* pX | |
1089 | , int* pY | |
1090 | ) const | |
1091 | { | |
1092 | HWND hWnd = GetHwnd(); | |
1093 | SWP vSwp; | |
1094 | ||
1095 | ::WinQueryWindowPos(hWnd, &vSwp); | |
1096 | ||
1097 | if (pX) | |
1098 | *pX += vSwp.x; | |
1099 | if (pY) | |
1100 | *pY += vSwp.y; | |
1101 | } // end of wxWindow::DoClientToScreen | |
1102 | ||
1103 | // | |
1104 | // Get size *available for subwindows* i.e. excluding menu bar etc. | |
1105 | // Must be a frame type window | |
1106 | // | |
1107 | void wxWindow::DoGetClientSize( | |
1108 | int* pWidth | |
1109 | , int* pHeight | |
1110 | ) const | |
1111 | { | |
1112 | HWND hWnd = GetHwnd(); | |
1113 | HWND hWndClient; | |
1114 | RECTL vRect; | |
1115 | ||
1116 | hWndClient = ::WinWindowFromID(GetHwnd(), FID_CLIENT); | |
1117 | ::WinQueryWindowRect(hWndClient, &vRect); | |
1118 | ||
1119 | if (pWidth) | |
1120 | *pWidth = vRect.xRight; | |
1121 | if (pHeight) | |
1122 | *pHeight = vRect.yTop; | |
1123 | } // end of wxWindow::DoGetClientSize | |
1124 | ||
1125 | void wxWindow::DoMoveWindow( | |
1126 | int nX | |
1127 | , int nY | |
1128 | , int nWidth | |
1129 | , int nHeight | |
1130 | ) | |
1131 | { | |
1132 | if ( !::WinSetWindowPos( GetHwnd() | |
1133 | ,HWND_TOP | |
1134 | ,(LONG)nX | |
1135 | ,(LONG)nY | |
1136 | ,(LONG)nWidth | |
1137 | ,(LONG)nHeight | |
1138 | ,SWP_SIZE | SWP_MOVE | |
1139 | )) | |
1140 | { | |
1141 | wxLogLastError("MoveWindow"); | |
1142 | } | |
1143 | } // end of wxWindow::DoMoveWindow | |
1144 | ||
1145 | // | |
1146 | // Set the size of the window: if the dimensions are positive, just use them, | |
1147 | // but if any of them is equal to -1, it means that we must find the value for | |
1148 | // it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in | |
1149 | // which case -1 is a valid value for x and y) | |
1150 | // | |
1151 | // If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate | |
1152 | // the width/height to best suit our contents, otherwise we reuse the current | |
1153 | // width/height | |
1154 | // | |
1155 | void wxWindow::DoSetSize( | |
1156 | int nX | |
1157 | , int nY | |
1158 | , int nWidth | |
1159 | , int nHeight | |
1160 | , int nSizeFlags | |
1161 | ) | |
1162 | { | |
1163 | // | |
1164 | // Get the current size and position... | |
1165 | // | |
1166 | int nCurrentX; | |
1167 | int nCurrentY; | |
1168 | int nCurrentWidth; | |
1169 | int nCurrentHeight; | |
1170 | wxSize vSize(-1, -1); | |
1171 | ||
1172 | GetPosition( &nCurrentX | |
1173 | ,&nCurrentY | |
1174 | ); | |
1175 | GetSize( &nCurrentWidth | |
1176 | ,&nCurrentHeight | |
1177 | ); | |
1178 | ||
1179 | // | |
1180 | // ... and don't do anything (avoiding flicker) if it's already ok | |
1181 | // | |
1182 | if ( nX == nCurrentX && | |
1183 | nY == nCurrentY && | |
1184 | nWidth == nCurrentWidth && | |
1185 | nHeight == nCurrentHeight | |
1186 | ) | |
1187 | { | |
1188 | return; | |
1189 | } | |
1190 | ||
1191 | if (nX == -1 && !(nSizeFlags & wxSIZE_ALLOW_MINUS_ONE)) | |
1192 | nX = nCurrentX; | |
1193 | if (nY == -1 && !(nSizeFlags & wxSIZE_ALLOW_MINUS_ONE)) | |
1194 | nY = nCurrentY; | |
1195 | ||
1196 | AdjustForParentClientOrigin( nX | |
1197 | ,nY | |
1198 | ,nSizeFlags | |
1199 | ); | |
1200 | ||
1201 | if (nWidth == -1) | |
1202 | { | |
1203 | if (nSizeFlags & wxSIZE_AUTO_WIDTH) | |
1204 | { | |
1205 | vSize = DoGetBestSize(); | |
1206 | nWidth = vSize.x; | |
1207 | } | |
1208 | else | |
1209 | { | |
1210 | // | |
1211 | // Just take the current one | |
1212 | // | |
1213 | nWidth = nCurrentWidth; | |
1214 | } | |
1215 | } | |
1216 | ||
1217 | if (nHeight == -1) | |
1218 | { | |
1219 | if (nSizeFlags & wxSIZE_AUTO_HEIGHT) | |
1220 | { | |
1221 | if (vSize.x == -1) | |
1222 | { | |
1223 | vSize = DoGetBestSize(); | |
1224 | } | |
1225 | nHeight = vSize.y; | |
1226 | } | |
1227 | else | |
1228 | { | |
1229 | // just take the current one | |
1230 | nHeight = nCurrentHeight; | |
1231 | } | |
1232 | } | |
1233 | ||
1234 | DoMoveWindow( nX | |
1235 | ,nY | |
1236 | ,nWidth | |
1237 | ,nHeight | |
1238 | ); | |
1239 | } // end of wxWindow::DoSetSize | |
1240 | ||
1241 | void wxWindow::DoSetClientSize( | |
1242 | int nWidth | |
1243 | , int nHeight | |
1244 | ) | |
1245 | { | |
1246 | wxWindow* pParent = GetParent(); | |
1247 | HWND hWnd = GetHwnd(); | |
1248 | HWND hParentWnd = (HWND)0; | |
1249 | HWND hClientWnd = (HWND)0; | |
1250 | RECTL vRect; | |
1251 | RECT vRect2; | |
1252 | RECT vRect3; | |
1253 | ||
1254 | hClientWnd = ::WinWindowFromID(GetHwnd(), FID_CLIENT); | |
1255 | ::WinQueryWindowRect(hClientWnd, &vRect2); | |
1256 | ||
1257 | if (pParent) | |
1258 | hParentWnd = (HWND) pParent->GetHWND(); | |
1259 | ||
1260 | ::WinQueryWindowRect(hWnd, &vRect); | |
1261 | ::WinQueryWindowRect(hParentWnd, &vRect3); | |
1262 | // | |
1263 | // Find the difference between the entire window (title bar and all) | |
1264 | // and the client area; add this to the new client size to move the | |
1265 | // window. OS/2 is backward from windows on height | |
1266 | // | |
1267 | int nActualWidth = vRect2.xRight - vRect2.xLeft - vRect.xRight + nWidth; | |
1268 | int nActualHeight = vRect2.yTop - vRect2.yBottom - vRect.yTop + nHeight; | |
1269 | ||
1270 | // | |
1271 | // If there's a parent, must subtract the parent's bottom left corner | |
1272 | // since MoveWindow moves relative to the parent | |
1273 | // | |
1274 | POINTL vPoint; | |
1275 | ||
1276 | vPoint.x = vRect2.xLeft; | |
1277 | vPoint.y = vRect2.yBottom; | |
1278 | if (pParent) | |
1279 | { | |
1280 | vPoint.x -= vRect3.xLeft; | |
1281 | vPoint.y -= vRect3.yBottom; | |
1282 | } | |
1283 | ||
1284 | DoMoveWindow( vPoint.x | |
1285 | ,vPoint.y | |
1286 | ,nActualWidth | |
1287 | ,nActualHeight | |
1288 | ); | |
1289 | ||
1290 | wxSizeEvent vEvent( wxSize( nWidth | |
1291 | ,nHeight | |
1292 | ) | |
1293 | ,m_windowId | |
1294 | ); | |
1295 | ||
1296 | vEvent.SetEventObject(this); | |
1297 | GetEventHandler()->ProcessEvent(vEvent); | |
1298 | } // end of wxWindow::DoSetClientSize | |
1299 | ||
1300 | wxPoint wxWindow::GetClientAreaOrigin() const | |
1301 | { | |
1302 | return wxPoint(0, 0); | |
1303 | } // end of wxWindow::GetClientAreaOrigin | |
1304 | ||
1305 | void wxWindow::AdjustForParentClientOrigin( | |
1306 | int& rX | |
1307 | , int& rY | |
1308 | , int nSizeFlags | |
1309 | ) | |
1310 | { | |
1311 | // | |
1312 | // Don't do it for the dialogs/frames - they float independently of their | |
1313 | // parent | |
1314 | // | |
1315 | if (!IsTopLevel()) | |
1316 | { | |
1317 | wxWindow* pParent = GetParent(); | |
1318 | ||
1319 | if (!(nSizeFlags & wxSIZE_NO_ADJUSTMENTS) && pParent) | |
1320 | { | |
1321 | wxPoint vPoint(pParent->GetClientAreaOrigin()); | |
1322 | rX += vPoint.x; | |
1323 | rY += vPoint.y; | |
1324 | } | |
1325 | } | |
1326 | } // end of wxWindow::AdjustForParentClientOrigin | |
1327 | ||
1328 | // --------------------------------------------------------------------------- | |
1329 | // text metrics | |
1330 | // --------------------------------------------------------------------------- | |
1331 | ||
1332 | int wxWindow::GetCharHeight() const | |
1333 | { | |
1334 | HPS hPs; | |
1335 | FONTMETRICS vFontMetrics; | |
1336 | BOOL bRc; | |
1337 | ||
1338 | hPs = ::WinGetPS(GetHwnd()); | |
1339 | ||
1340 | if(!GpiQueryFontMetrics(hPs, sizeof(FONTMETRICS), &vFontMetrics)) | |
1341 | return (0); | |
1342 | else | |
1343 | return(vFontMetrics.lMaxAscender + vFontMetrics.lMaxDescender); | |
1344 | ::WinReleasePS(hPs); | |
1345 | } // end of wxWindow::GetCharHeight | |
1346 | ||
1347 | int wxWindow::GetCharWidth() const | |
1348 | { | |
1349 | HPS hPs; | |
1350 | FONTMETRICS vFontMetrics; | |
1351 | ||
1352 | hPs = ::WinGetPS(GetHwnd()); | |
1353 | ||
1354 | if(!GpiQueryFontMetrics(hPs, sizeof(FONTMETRICS), &vFontMetrics)) | |
1355 | return (0); | |
1356 | else | |
1357 | return(vFontMetrics.lAveCharWidth); | |
1358 | ::WinReleasePS(hPs); | |
1359 | } // end of wxWindow::GetCharWidth | |
1360 | ||
1361 | void wxWindow::GetTextExtent( | |
1362 | const wxString& rString | |
1363 | , int* pX | |
1364 | , int* pY | |
1365 | , int* pDescent | |
1366 | , int* pExternalLeading | |
1367 | , const wxFont* pTheFont | |
1368 | ) const | |
1369 | { | |
1370 | const wxFont* pFontToUse = pTheFont; | |
1371 | HPS hPs; | |
1372 | ||
1373 | hPs = ::WinGetPS(GetHwnd()); | |
1374 | /* | |
1375 | // TODO: Will have to play with fonts later | |
1376 | ||
1377 | if (!pFontToUse) | |
1378 | pFontToUse = &m_font; | |
1379 | ||
1380 | HFONT hFnt = 0; | |
1381 | HFONT hFfontOld = 0; | |
1382 | ||
1383 | if (pFontToUse && pFontToUse->Ok()) | |
1384 | { | |
1385 | ::GpiCreateLog | |
1386 | hFnt = (HFONT)((wxFont *)pFontToUse)->GetResourceHandle(); // const_cast | |
1387 | if (hFnt) | |
1388 | hFontOld = (HFONT)SelectObject(dc,fnt); | |
1389 | } | |
1390 | ||
1391 | SIZE sizeRect; | |
1392 | TEXTMETRIC tm; | |
1393 | GetTextExtentPoint(dc, string, (int)string.Length(), &sizeRect); | |
1394 | GetTextMetrics(dc, &tm); | |
1395 | ||
1396 | if ( fontToUse && fnt && hfontOld ) | |
1397 | SelectObject(dc, hfontOld); | |
1398 | ||
1399 | ReleaseDC(hWnd, dc); | |
1400 | ||
1401 | if ( x ) | |
1402 | *x = sizeRect.cx; | |
1403 | if ( y ) | |
1404 | *y = sizeRect.cy; | |
1405 | if ( descent ) | |
1406 | *descent = tm.tmDescent; | |
1407 | if ( externalLeading ) | |
1408 | *externalLeading = tm.tmExternalLeading; | |
1409 | */ | |
1410 | ::WinReleasePS(hPs); | |
1411 | } | |
1412 | ||
1413 | #if wxUSE_CARET && WXWIN_COMPATIBILITY | |
1414 | // --------------------------------------------------------------------------- | |
1415 | // Caret manipulation | |
1416 | // --------------------------------------------------------------------------- | |
1417 | ||
1418 | void wxWindow::CreateCaret( | |
1419 | int nWidth | |
1420 | , int nHeight | |
1421 | ) | |
1422 | { | |
1423 | SetCaret(new wxCaret( this | |
1424 | ,nWidth | |
1425 | ,nHeight | |
1426 | )); | |
1427 | } // end of wxWindow::CreateCaret | |
1428 | ||
1429 | void wxWindow::CreateCaret( | |
1430 | const wxBitmap* pBitmap | |
1431 | ) | |
1432 | { | |
1433 | wxFAIL_MSG("not implemented"); | |
1434 | } // end of wxWindow::CreateCaret | |
1435 | ||
1436 | void wxWindow::ShowCaret( | |
1437 | bool bShow | |
1438 | ) | |
1439 | { | |
1440 | wxCHECK_RET( m_caret, "no caret to show" ); | |
1441 | ||
1442 | m_caret->Show(bShow); | |
1443 | } // end of wxWindow::ShowCaret | |
1444 | ||
1445 | void wxWindow::DestroyCaret() | |
1446 | { | |
1447 | SetCaret(NULL); | |
1448 | } // end of wxWindow::DestroyCaret | |
1449 | ||
1450 | void wxWindow::SetCaretPos( | |
1451 | int nX | |
1452 | , int nY) | |
1453 | { | |
1454 | wxCHECK_RET( m_caret, "no caret to move" ); | |
1455 | ||
1456 | m_caret->Move( nX | |
1457 | ,nY | |
1458 | ); | |
1459 | } // end of wxWindow::SetCaretPos | |
1460 | ||
1461 | void wxWindow::GetCaretPos( | |
1462 | int* pX | |
1463 | , int* pY | |
1464 | ) const | |
1465 | { | |
1466 | wxCHECK_RET( m_caret, "no caret to get position of" ); | |
1467 | ||
1468 | m_caret->GetPosition( pX | |
1469 | ,pY | |
1470 | ); | |
1471 | } // end of wxWindow::GetCaretPos | |
1472 | ||
1473 | #endif //wxUSE_CARET | |
1474 | ||
1475 | // --------------------------------------------------------------------------- | |
1476 | // popup menu | |
1477 | // --------------------------------------------------------------------------- | |
1478 | ||
1479 | bool wxWindow::DoPopupMenu( | |
1480 | wxMenu* pMenu | |
1481 | , int nX | |
1482 | , int nY | |
1483 | ) | |
1484 | { | |
1485 | HWND hWnd = GetHwnd(); | |
1486 | HWND hWndParent = GetParent() ? GetWinHwnd(GetParent()) : (HWND)0; | |
1487 | HWND hMenu = GetHmenuOf(pMenu); | |
1488 | ||
1489 | pMenu->SetInvokingWindow(this); | |
1490 | pMenu->UpdateUI(); | |
1491 | ||
1492 | DoClientToScreen( &nX | |
1493 | ,&nY | |
1494 | ); | |
1495 | wxCurrentPopupMenu = pMenu; | |
1496 | ||
1497 | ::WinPopupMenu( hWndParent | |
1498 | ,hWnd | |
1499 | ,hMenu | |
1500 | ,nX | |
1501 | ,nY | |
1502 | ,0L | |
1503 | ,PU_MOUSEBUTTON2DOWN | PU_MOUSEBUTTON2 | PU_KEYBOARD | |
1504 | ); | |
1505 | wxYield(); | |
1506 | wxCurrentPopupMenu = NULL; | |
1507 | ||
1508 | pMenu->SetInvokingWindow(NULL); | |
1509 | return TRUE; | |
1510 | } // end of wxWindow::DoPopupMenu | |
1511 | ||
1512 | // =========================================================================== | |
1513 | // pre/post message processing | |
1514 | // =========================================================================== | |
1515 | ||
1516 | MRESULT wxWindow::OS2DefWindowProc( | |
1517 | WXUINT uMsg | |
1518 | , WXWPARAM wParam | |
1519 | , WXLPARAM lParam | |
1520 | ) | |
1521 | { | |
1522 | DEBUG_PRINTF(wxWindow::OS2DefWindowProc); | |
1523 | ||
1524 | if (m_fnOldWndProc) | |
1525 | return (MRESULT)m_fnOldWndProc(GetHWND(), (ULONG)uMsg, (MPARAM)wParam, (MPARAM)lParam); | |
1526 | else | |
1527 | return ::WinDefWindowProc(GetHWND(), (ULONG)uMsg, (MPARAM)wParam, (MPARAM)lParam); | |
1528 | } // end of wxWindow::OS2DefWindowProc | |
1529 | ||
1530 | bool wxWindow::OS2ProcessMessage( | |
1531 | WXMSG* pMsg | |
1532 | ) | |
1533 | { | |
1534 | QMSG* pQMsg = (QMSG*)pMsg; | |
1535 | ||
1536 | DEBUG_PRINTF(OS2ProcessMessage); | |
1537 | ||
1538 | if (m_hWnd != 0 && (GetWindowStyleFlag() & wxTAB_TRAVERSAL)) | |
1539 | { | |
1540 | // | |
1541 | // Intercept dialog navigation keys | |
1542 | // | |
1543 | bool bProcess = TRUE; | |
1544 | USHORT uKeyFlags = SHORT1FROMMP(pQMsg->mp1); | |
1545 | ||
1546 | if (uKeyFlags & KC_KEYUP) | |
1547 | bProcess = FALSE; | |
1548 | ||
1549 | if (uKeyFlags & KC_ALT) | |
1550 | bProcess = FALSE; | |
1551 | ||
1552 | if (!(uKeyFlags & KC_VIRTUALKEY)) | |
1553 | bProcess = FALSE; | |
1554 | ||
1555 | if (bProcess) | |
1556 | { | |
1557 | bool bCtrlDown = IsCtrlDown(); | |
1558 | bool bShiftDown = IsShiftDown(); | |
1559 | ||
1560 | // | |
1561 | // WM_QUERYDLGCODE: ask the control if it wants the key for itself, | |
1562 | // don't process it if it's the case (except for Ctrl-Tab/Enter | |
1563 | // combinations which are always processed) | |
1564 | // | |
1565 | ULONG ulDlgCode = 0; | |
1566 | ||
1567 | if (!bCtrlDown) | |
1568 | { | |
1569 | ulDlgCode = (ULONG)::WinSendMsg(pQMsg->hwnd, WM_QUERYDLGCODE, pQMsg, 0); | |
1570 | } | |
1571 | ||
1572 | bool bForward = TRUE; | |
1573 | bool bWindowChange = FALSE; | |
1574 | ||
1575 | switch (SHORT2FROMMP(pQMsg->mp2)) | |
1576 | { | |
1577 | // | |
1578 | // Going to make certain assumptions about specific types of controls | |
1579 | // here, so we may have to alter some things later if they prove invalid | |
1580 | // | |
1581 | case VK_TAB: | |
1582 | // | |
1583 | // Shift tabl will always be a nav-key but tabs may be wanted | |
1584 | // | |
1585 | if (!bShiftDown) | |
1586 | { | |
1587 | bProcess = FALSE; | |
1588 | } | |
1589 | else | |
1590 | { | |
1591 | // | |
1592 | // Entry Fields want tabs for themselve usually | |
1593 | // | |
1594 | switch (ulDlgCode) | |
1595 | { | |
1596 | case DLGC_ENTRYFIELD: | |
1597 | case DLGC_MLE: | |
1598 | bProcess = TRUE; | |
1599 | break; | |
1600 | ||
1601 | default: | |
1602 | bProcess = FALSE; | |
1603 | } | |
1604 | ||
1605 | // | |
1606 | // Ctrl-Tab cycles thru notebook pages | |
1607 | // | |
1608 | bWindowChange = bCtrlDown; | |
1609 | bForward = !bShiftDown; | |
1610 | } | |
1611 | break; | |
1612 | ||
1613 | case VK_UP: | |
1614 | case VK_LEFT: | |
1615 | if (bCtrlDown) | |
1616 | bProcess = FALSE; | |
1617 | else | |
1618 | bForward = FALSE; | |
1619 | break; | |
1620 | ||
1621 | case VK_DOWN: | |
1622 | case VK_RIGHT: | |
1623 | if (bCtrlDown) | |
1624 | bProcess = FALSE; | |
1625 | break; | |
1626 | ||
1627 | case VK_ENTER: | |
1628 | { | |
1629 | if (bCtrlDown) | |
1630 | { | |
1631 | // | |
1632 | // ctrl-enter is not processed | |
1633 | // | |
1634 | return FALSE; | |
1635 | } | |
1636 | else if (ulDlgCode & DLGC_BUTTON) | |
1637 | { | |
1638 | // | |
1639 | // buttons want process Enter themselevs | |
1640 | // | |
1641 | bProcess = FALSE; | |
1642 | } | |
1643 | else | |
1644 | { | |
1645 | wxPanel* pPanel = wxDynamicCast(this, wxPanel); | |
1646 | wxButton* pBtn = NULL; | |
1647 | ||
1648 | if (pPanel) | |
1649 | { | |
1650 | // | |
1651 | // Panel may have a default button which should | |
1652 | // be activated by Enter | |
1653 | // | |
1654 | pBtn = pPanel->GetDefaultItem(); | |
1655 | } | |
1656 | ||
1657 | if (pBtn && pBtn->IsEnabled()) | |
1658 | { | |
1659 | // | |
1660 | // If we do have a default button, do press it | |
1661 | // | |
1662 | pBtn->OS2Command(BN_CLICKED, 0 /* unused */); | |
1663 | return TRUE; | |
1664 | } | |
1665 | // else: but if it does not it makes sense to make | |
1666 | // it work like a TAB - and that's what we do. | |
1667 | // Note that Ctrl-Enter always works this way. | |
1668 | } | |
1669 | } | |
1670 | break; | |
1671 | ||
1672 | default: | |
1673 | bProcess = FALSE; | |
1674 | } | |
1675 | ||
1676 | if (bProcess) | |
1677 | { | |
1678 | wxNavigationKeyEvent vEvent; | |
1679 | ||
1680 | vEvent.SetDirection(bForward); | |
1681 | vEvent.SetWindowChange(bWindowChange); | |
1682 | vEvent.SetEventObject(this); | |
1683 | ||
1684 | if (GetEventHandler()->ProcessEvent(vEvent)) | |
1685 | { | |
1686 | wxButton* pBtn = wxDynamicCast(FindFocus(), wxButton); | |
1687 | ||
1688 | if (pBtn) | |
1689 | { | |
1690 | // | |
1691 | // The button which has focus should be default | |
1692 | // | |
1693 | pBtn->SetDefault(); | |
1694 | } | |
1695 | return TRUE; | |
1696 | } | |
1697 | } | |
1698 | } | |
1699 | // | |
1700 | // Let Dialogs process | |
1701 | // | |
1702 | if (::WinSendMsg(pQMsg->hwnd, WM_QUERYDLGCODE, pQMsg, 0)); | |
1703 | return TRUE; | |
1704 | } | |
1705 | ||
1706 | #if wxUSE_TOOLTIPS | |
1707 | if ( m_tooltip ) | |
1708 | { | |
1709 | // relay mouse move events to the tooltip control | |
1710 | QMSG* pQMsg = (QMSG*)pMsg; | |
1711 | ||
1712 | if (pQMsg->msg == WM_MOUSEMOVE ) | |
1713 | m_tooltip->RelayEvent(pMsg); | |
1714 | } | |
1715 | #endif // wxUSE_TOOLTIPS | |
1716 | ||
1717 | return FALSE; | |
1718 | } // end of wxWindow::OS2ProcessMessage | |
1719 | ||
1720 | bool wxWindow::OS2TranslateMessage( | |
1721 | WXMSG* pMsg | |
1722 | ) | |
1723 | { | |
1724 | #if wxUSE_ACCEL | |
1725 | return m_acceleratorTable.Translate(m_hWnd, pMsg); | |
1726 | #else | |
1727 | return FALSE; | |
1728 | #endif //wxUSE_ACCEL | |
1729 | } // end of wxWindow::OS2TranslateMessage | |
1730 | ||
1731 | // --------------------------------------------------------------------------- | |
1732 | // message params unpackers | |
1733 | // --------------------------------------------------------------------------- | |
1734 | ||
1735 | void wxWindow::UnpackCommand( | |
1736 | WXWPARAM wParam | |
1737 | , WXLPARAM lParam | |
1738 | , WORD* pId | |
1739 | , WXHWND* phWnd | |
1740 | , WORD* pCmd | |
1741 | ) | |
1742 | { | |
1743 | /* | |
1744 | *pId = LOWORD(wParam); | |
1745 | *phWnd = (WXHWND)lParam; | |
1746 | *pCmd = HIWORD(wParam); | |
1747 | */ | |
1748 | *pId = LOWORD(wParam); | |
1749 | *phWnd = NULL; // or may be GetHWND() ? | |
1750 | *pCmd = LOWORD(lParam); | |
1751 | } // end of wxWindow::UnpackCommand | |
1752 | ||
1753 | void wxWindow::UnpackActivate( | |
1754 | WXWPARAM wParam | |
1755 | , WXLPARAM lParam | |
1756 | , WXWORD* pState | |
1757 | , WXHWND* phWnd | |
1758 | ) | |
1759 | { | |
1760 | *pState = LOWORD(wParam); | |
1761 | *phWnd = (WXHWND)lParam; | |
1762 | } // end of wxWindow::UnpackActivate | |
1763 | ||
1764 | void wxWindow::UnpackScroll( | |
1765 | WXWPARAM wParam | |
1766 | , WXLPARAM lParam | |
1767 | , WXWORD* pCode | |
1768 | , WXWORD* pPos | |
1769 | , WXHWND* phWnd | |
1770 | ) | |
1771 | { | |
1772 | *pCode = LOWORD(wParam); | |
1773 | *pPos = HIWORD(wParam); | |
1774 | *phWnd = (WXHWND)lParam; | |
1775 | } // end of wxWindow::UnpackScroll | |
1776 | ||
1777 | void wxWindow::UnpackMenuSelect( | |
1778 | WXWPARAM wParam | |
1779 | , WXLPARAM lParam | |
1780 | , WXWORD* pItem | |
1781 | , WXWORD* pFlags | |
1782 | , WXHMENU* phMenu | |
1783 | ) | |
1784 | { | |
1785 | *pItem = (WXWORD)LOWORD(wParam); | |
1786 | *pFlags = HIWORD(wParam); | |
1787 | *phMenu = (WXHMENU)lParam; | |
1788 | } // end of wxWindow::UnpackMenuSelect | |
1789 | ||
1790 | // --------------------------------------------------------------------------- | |
1791 | // Main wxWindows window proc and the window proc for wxWindow | |
1792 | // --------------------------------------------------------------------------- | |
1793 | ||
1794 | // | |
1795 | // Hook for new window just as it's being created, when the window isn't yet | |
1796 | // associated with the handle | |
1797 | // | |
1798 | wxWindow* wxWndHook = NULL; | |
1799 | ||
1800 | // | |
1801 | // Main window proc | |
1802 | // | |
1803 | MRESULT EXPENTRY wxWndProc( | |
1804 | HWND hWnd | |
1805 | , ULONG ulMsg | |
1806 | , MPARAM wParam | |
1807 | , MPARAM lParam | |
1808 | ) | |
1809 | { | |
1810 | // | |
1811 | // Trace all ulMsgs - useful for the debugging | |
1812 | // | |
1813 | #ifdef __WXDEBUG__ | |
1814 | DEBUG_PRINTF(__WXDEBUG__wxWndProc); | |
1815 | wxLogTrace(wxTraceMessages, wxT("Processing %s(wParam=%8lx, lParam=%8lx)"), | |
1816 | wxGetMessageName(ulMsg), wParam, lParam); | |
1817 | #endif // __WXDEBUG__ | |
1818 | ||
1819 | wxWindow* pWnd = wxFindWinFromHandle((WXHWND)hWnd); | |
1820 | ||
1821 | // | |
1822 | // When we get the first message for the HWND we just created, we associate | |
1823 | // it with wxWindow stored in wxWndHook | |
1824 | // | |
1825 | if (!pWnd && wxWndHook) | |
1826 | { | |
1827 | wxAssociateWinWithHandle(hWnd, wxWndHook); | |
1828 | pWnd = wxWndHook; | |
1829 | wxWndHook = NULL; | |
1830 | pWnd->SetHWND((WXHWND)hWnd); | |
1831 | } | |
1832 | ||
1833 | MRESULT rc = (MRESULT)0; | |
1834 | ||
1835 | ||
1836 | // | |
1837 | // Stop right here if we don't have a valid handle in our wxWindow object. | |
1838 | // | |
1839 | if (pWnd && !pWnd->GetHWND()) | |
1840 | { | |
1841 | pWnd->SetHWND((WXHWND) hWnd); | |
1842 | rc = pWnd->OS2DefWindowProc(ulMsg, wParam, lParam ); | |
1843 | pWnd->SetHWND(0); | |
1844 | } | |
1845 | else | |
1846 | { | |
1847 | if (pWnd) | |
1848 | rc = pWnd->OS2WindowProc(ulMsg, wParam, lParam); | |
1849 | else | |
1850 | rc = ::WinDefWindowProc(hWnd, ulMsg, wParam, lParam); | |
1851 | } | |
1852 | ||
1853 | return rc; | |
1854 | } // end of wxWndProc | |
1855 | ||
1856 | // | |
1857 | // We will add (or delete) messages we need to handle at this default | |
1858 | // level as we go | |
1859 | // | |
1860 | MRESULT wxWindow::OS2WindowProc( | |
1861 | WXUINT uMsg | |
1862 | , WXWPARAM wParam | |
1863 | , WXLPARAM lParam | |
1864 | ) | |
1865 | { | |
1866 | // | |
1867 | // Did we process the uMsg? | |
1868 | // | |
1869 | bool bProcessed = FALSE; | |
1870 | bool bAllow; | |
1871 | MRESULT mResult; | |
1872 | WXHICON hIcon; | |
1873 | WXHBRUSH hBrush; | |
1874 | ||
1875 | // | |
1876 | // The return value | |
1877 | // | |
1878 | // union | |
1879 | // { | |
1880 | // bool bAllow; | |
1881 | // MRESULT mResult; | |
1882 | // WXHICON hIcon; | |
1883 | // WXHBRUSH hBrush; | |
1884 | // } vRc; | |
1885 | ||
1886 | // | |
1887 | // For most messages we should return 0 when we do process the message | |
1888 | // | |
1889 | mResult = (MRESULT)0; | |
1890 | ||
1891 | switch (uMsg) | |
1892 | { | |
1893 | case WM_CREATE: | |
1894 | { | |
1895 | bool bMayCreate; | |
1896 | ||
1897 | bProcessed = HandleCreate( (WXLPCREATESTRUCT)lParam | |
1898 | ,&bMayCreate | |
1899 | ); | |
1900 | if (bProcessed) | |
1901 | { | |
1902 | // | |
1903 | // Return 0 to bAllow window creation | |
1904 | // | |
1905 | mResult = (MRESULT)(bMayCreate ? 0 : -1); | |
1906 | } | |
1907 | } | |
1908 | break; | |
1909 | ||
1910 | case WM_DESTROY: | |
1911 | HandleDestroy(); | |
1912 | bProcessed = TRUE; | |
1913 | break; | |
1914 | ||
1915 | case WM_MOVE: | |
1916 | bProcessed = HandleMove( LOWORD(lParam) | |
1917 | ,HIWORD(lParam) | |
1918 | ); | |
1919 | break; | |
1920 | ||
1921 | case WM_SIZE: | |
1922 | bProcessed = HandleSize( LOWORD(lParam) | |
1923 | ,HIWORD(lParam) | |
1924 | ,(WXUINT)wParam | |
1925 | ); | |
1926 | break; | |
1927 | ||
1928 | case WM_ACTIVATE: | |
1929 | { | |
1930 | WXWORD wState; | |
1931 | WXHWND hWnd; | |
1932 | ||
1933 | UnpackActivate( wParam | |
1934 | ,lParam | |
1935 | ,&wState | |
1936 | ,&hWnd | |
1937 | ); | |
1938 | ||
1939 | bProcessed = HandleActivate( wState | |
1940 | ,(WXHWND)hWnd | |
1941 | ); | |
1942 | bProcessed = FALSE; | |
1943 | } | |
1944 | break; | |
1945 | ||
1946 | case WM_SETFOCUS: | |
1947 | if (SHORT1FROMMP((MPARAM)lParam) == TRUE) | |
1948 | bProcessed = HandleSetFocus((WXHWND)(HWND)wParam); | |
1949 | else | |
1950 | bProcessed = HandleKillFocus((WXHWND)(HWND)wParam); | |
1951 | break; | |
1952 | ||
1953 | case WM_PAINT: | |
1954 | DEBUG_PRINTF(WM_PAINT) | |
1955 | bProcessed = HandlePaint(); | |
1956 | break; | |
1957 | ||
1958 | case WM_CLOSE: | |
1959 | // | |
1960 | // Don't let the DefWindowProc() destroy our window - we'll do it | |
1961 | // ourselves in ~wxWindow | |
1962 | // | |
1963 | bProcessed = TRUE; | |
1964 | mResult = (MRESULT)TRUE; | |
1965 | DEBUG_PRINTF(WM_CLOSE) | |
1966 | break; | |
1967 | ||
1968 | case WM_SHOW: | |
1969 | DEBUG_PRINTF(WM_SHOW) | |
1970 | bProcessed = HandleShow(wParam != 0, (int)lParam); | |
1971 | break; | |
1972 | ||
1973 | // | |
1974 | // Under OS2 PM Joysticks are treated just like mouse events | |
1975 | // The "Motion" events will be prevelent in joysticks | |
1976 | // | |
1977 | case WM_MOUSEMOVE: | |
1978 | case WM_BUTTON1DOWN: | |
1979 | case WM_BUTTON1UP: | |
1980 | case WM_BUTTON1DBLCLK: | |
1981 | case WM_BUTTON1MOTIONEND: | |
1982 | case WM_BUTTON1MOTIONSTART: | |
1983 | case WM_BUTTON2DOWN: | |
1984 | case WM_BUTTON2UP: | |
1985 | case WM_BUTTON2DBLCLK: | |
1986 | case WM_BUTTON2MOTIONEND: | |
1987 | case WM_BUTTON2MOTIONSTART: | |
1988 | case WM_BUTTON3DOWN: | |
1989 | case WM_BUTTON3UP: | |
1990 | case WM_BUTTON3DBLCLK: | |
1991 | case WM_BUTTON3MOTIONEND: | |
1992 | case WM_BUTTON3MOTIONSTART: | |
1993 | { | |
1994 | short x = LOWORD(lParam); | |
1995 | short y = HIWORD(lParam); | |
1996 | ||
1997 | bProcessed = HandleMouseEvent(uMsg, x, y, (WXUINT)wParam); | |
1998 | } | |
1999 | break; | |
2000 | case WM_SYSCOMMAND: | |
2001 | bProcessed = HandleSysCommand(wParam, lParam); | |
2002 | break; | |
2003 | ||
2004 | case WM_COMMAND: | |
2005 | { | |
2006 | WORD id, cmd; | |
2007 | WXHWND hwnd; | |
2008 | DEBUG_PRINTF(WM_COMMAND-in) | |
2009 | UnpackCommand(wParam, lParam, &id, &hwnd, &cmd); | |
2010 | ||
2011 | bProcessed = HandleCommand(id, cmd, hwnd); | |
2012 | DEBUG_PRINTF(WM_COMMAND-out) | |
2013 | } | |
2014 | break; | |
2015 | ||
2016 | // | |
2017 | // For these messages we must return TRUE if process the message | |
2018 | // | |
2019 | case WM_DRAWITEM: | |
2020 | case WM_MEASUREITEM: | |
2021 | { | |
2022 | int idCtrl = (UINT)wParam; | |
2023 | if ( uMsg == WM_DRAWITEM ) | |
2024 | { | |
2025 | bProcessed = OS2OnDrawItem(idCtrl, | |
2026 | (WXDRAWITEMSTRUCT *)lParam); | |
2027 | } | |
2028 | else | |
2029 | { | |
2030 | bProcessed = OS2OnMeasureItem(idCtrl, | |
2031 | (WXMEASUREITEMSTRUCT *)lParam); | |
2032 | } | |
2033 | ||
2034 | if ( bProcessed ) | |
2035 | mResult = (MRESULT)TRUE; | |
2036 | } | |
2037 | break; | |
2038 | ||
2039 | case WM_QUERYDLGCODE: | |
2040 | if ( m_lDlgCode ) | |
2041 | { | |
2042 | mResult = (MRESULT)m_lDlgCode; | |
2043 | bProcessed = TRUE; | |
2044 | } | |
2045 | // | |
2046 | //else: get the dlg code from the DefWindowProc() | |
2047 | // | |
2048 | break; | |
2049 | ||
2050 | // | |
2051 | // In OS/2 PM all keyboard events are of the WM_CHAR type. Virtual key and key-up | |
2052 | // and key-down events are obtained from the WM_CHAR params. | |
2053 | // | |
2054 | case WM_CHAR: | |
2055 | { | |
2056 | USHORT uKeyFlags = SHORT1FROMMP((MPARAM)wParam); | |
2057 | ||
2058 | if (uKeyFlags & KC_KEYUP) | |
2059 | { | |
2060 | bProcessed = HandleKeyUp((WXDWORD)wParam, lParam); | |
2061 | break; | |
2062 | } | |
2063 | else // keydown event | |
2064 | { | |
2065 | // | |
2066 | // If this has been processed by an event handler, | |
2067 | // return 0 now (we've handled it). DON't RETURN | |
2068 | // we still need to process further | |
2069 | // | |
2070 | HandleKeyDown((WXDWORD)wParam, lParam); | |
2071 | if (uKeyFlags & KC_VIRTUALKEY) | |
2072 | { | |
2073 | USHORT uVk = SHORT2FROMMP((MPARAM)lParam); | |
2074 | ||
2075 | // | |
2076 | // We consider these message "not interesting" to OnChar | |
2077 | // | |
2078 | if (uVk == VK_SHIFT || uVk == VK_CTRL ) | |
2079 | { | |
2080 | bProcessed = TRUE; | |
2081 | break; | |
2082 | } | |
2083 | switch(uVk) | |
2084 | { | |
2085 | // | |
2086 | // Avoid duplicate messages to OnChar for these ASCII keys: they | |
2087 | // will be translated by TranslateMessage() and received in WM_CHAR | |
2088 | case VK_ESC: | |
2089 | case VK_SPACE: | |
2090 | case VK_ENTER: | |
2091 | case VK_BACKSPACE: | |
2092 | case VK_TAB: | |
2093 | // But set processed to FALSE, not TRUE to still pass them to | |
2094 | // the control's default window proc - otherwise built-in | |
2095 | // keyboard handling won't work | |
2096 | bProcessed = FALSE; | |
2097 | break; | |
2098 | ||
2099 | case VK_LEFT: | |
2100 | case VK_RIGHT: | |
2101 | case VK_DOWN: | |
2102 | case VK_UP: | |
2103 | default: | |
2104 | bProcessed = HandleChar((WXDWORD)wParam, lParam); | |
2105 | } | |
2106 | break; | |
2107 | } | |
2108 | else // WM_CHAR -- Always an ASCII character | |
2109 | { | |
2110 | bProcessed = HandleChar((WXDWORD)wParam, lParam, TRUE); | |
2111 | break; | |
2112 | } | |
2113 | } | |
2114 | } | |
2115 | ||
2116 | case WM_HSCROLL: | |
2117 | case WM_VSCROLL: | |
2118 | { | |
2119 | WXWORD wCode; | |
2120 | WXWORD wPos; | |
2121 | WXHWND hWnd; | |
2122 | UnpackScroll( wParam | |
2123 | ,lParam | |
2124 | ,&wCode | |
2125 | ,&wPos | |
2126 | ,&hWnd | |
2127 | ); | |
2128 | ||
2129 | bProcessed = OS2OnScroll( uMsg == WM_HSCROLL ? wxHORIZONTAL | |
2130 | : wxVERTICAL | |
2131 | ,wCode | |
2132 | ,wPos | |
2133 | ,hWnd | |
2134 | ); | |
2135 | } | |
2136 | break; | |
2137 | ||
2138 | #if defined(__VISAGECPP__) && (__IBMCPP__ >= 400) | |
2139 | case WM_CTLCOLORCHANGE: | |
2140 | { | |
2141 | bProcessed = HandleCtlColor(&hBrush); | |
2142 | } | |
2143 | break; | |
2144 | #endif | |
2145 | // | |
2146 | // Instead of CTLCOLOR messages PM sends QUERYWINDOWPARAMS to | |
2147 | // things such as colors and fonts and such | |
2148 | // | |
2149 | case WM_QUERYWINDOWPARAMS: | |
2150 | { | |
2151 | PWNDPARAMS pWndParams = (PWNDPARAMS)wParam; | |
2152 | ||
2153 | bProcessed = HandleWindowParams( pWndParams | |
2154 | ,lParam | |
2155 | ); | |
2156 | } | |
2157 | break; | |
2158 | ||
2159 | // the return value for this message is ignored | |
2160 | case WM_SYSCOLORCHANGE: | |
2161 | bProcessed = HandleSysColorChange(); | |
2162 | break; | |
2163 | ||
2164 | case WM_REALIZEPALETTE: | |
2165 | bProcessed = HandlePaletteChanged(); | |
2166 | break; | |
2167 | ||
2168 | case WM_PRESPARAMCHANGED: | |
2169 | bProcessed = HandlePresParamChanged(wParam); | |
2170 | break; | |
2171 | ||
2172 | // move this to wxFrame | |
2173 | case WM_ERASEBACKGROUND: | |
2174 | bProcessed = HandleEraseBkgnd((WXHDC)(HDC)wParam); | |
2175 | if (bProcessed) | |
2176 | { | |
2177 | // | |
2178 | // We processed the message, i.e. erased the background | |
2179 | // | |
2180 | mResult = (MRESULT)TRUE; | |
2181 | } | |
2182 | break; | |
2183 | ||
2184 | // move all drag and drops to wxDrg | |
2185 | case WM_ENDDRAG: | |
2186 | bProcessed = HandleEndDrag(wParam); | |
2187 | break; | |
2188 | ||
2189 | case WM_INITDLG: | |
2190 | bProcessed = HandleInitDialog((WXHWND)(HWND)wParam); | |
2191 | ||
2192 | if ( bProcessed ) | |
2193 | { | |
2194 | // we never set focus from here | |
2195 | mResult = FALSE; | |
2196 | } | |
2197 | break; | |
2198 | ||
2199 | // wxFrame specific message | |
2200 | case WM_MINMAXFRAME: | |
2201 | bProcessed = HandleGetMinMaxInfo((PSWP)wParam); | |
2202 | break; | |
2203 | ||
2204 | case WM_SYSVALUECHANGED: | |
2205 | // TODO: do something | |
2206 | mResult = (MRESULT)TRUE; | |
2207 | break; | |
2208 | ||
2209 | // | |
2210 | // Comparable to WM_SETPOINTER for windows, only for just controls | |
2211 | // | |
2212 | case WM_CONTROLPOINTER: | |
2213 | bProcessed = HandleSetCursor( SHORT1FROMMP(wParam) // Control ID | |
2214 | ,(HWND)lParam // Cursor Handle | |
2215 | ); | |
2216 | if (bProcessed ) | |
2217 | { | |
2218 | // | |
2219 | // Returning TRUE stops the DefWindowProc() from further | |
2220 | // processing this message - exactly what we need because we've | |
2221 | // just set the cursor. | |
2222 | // | |
2223 | mResult = (MRESULT)TRUE; | |
2224 | } | |
2225 | break; | |
2226 | } | |
2227 | ||
2228 | if (!bProcessed) | |
2229 | { | |
2230 | #ifdef __WXDEBUG__ | |
2231 | wxLogTrace(wxTraceMessages, wxT("Forwarding %s to DefWindowProc."), | |
2232 | wxGetMessageName(uMsg)); | |
2233 | #endif // __WXDEBUG__ | |
2234 | mResult = OS2DefWindowProc(uMsg, wParam, lParam); | |
2235 | } | |
2236 | return mResult; | |
2237 | } // end of wxWindow::OS2WindowProc | |
2238 | ||
2239 | // | |
2240 | // Dialog window proc | |
2241 | // | |
2242 | MRESULT wxDlgProc( | |
2243 | HWND hWnd | |
2244 | , UINT uMsg | |
2245 | , MPARAM wParam | |
2246 | , MPARAM lParam) | |
2247 | { | |
2248 | if (uMsg == WM_INITDLG) | |
2249 | { | |
2250 | // | |
2251 | // For this message, returning TRUE tells system to set focus to the | |
2252 | // first control in the dialog box | |
2253 | // | |
2254 | return (MRESULT)TRUE; | |
2255 | } | |
2256 | else | |
2257 | { | |
2258 | // | |
2259 | // For all the other ones, FALSE means that we didn't process the | |
2260 | // message | |
2261 | // | |
2262 | return (MRESULT)0; | |
2263 | } | |
2264 | } // end of wxDlgProc | |
2265 | ||
2266 | wxWindow* wxFindWinFromHandle( | |
2267 | WXHWND hWnd | |
2268 | ) | |
2269 | { | |
2270 | wxNode* pNode = wxWinHandleList->Find((long)hWnd); | |
2271 | ||
2272 | if (!pNode) | |
2273 | return NULL; | |
2274 | return (wxWindow *)pNode->Data(); | |
2275 | } // end of wxFindWinFromHandle | |
2276 | ||
2277 | void wxAssociateWinWithHandle( | |
2278 | HWND hWnd | |
2279 | , wxWindow* pWin | |
2280 | ) | |
2281 | { | |
2282 | // | |
2283 | // Adding NULL hWnd is (first) surely a result of an error and | |
2284 | // (secondly) breaks menu command processing | |
2285 | // | |
2286 | wxCHECK_RET( hWnd != (HWND)NULL, | |
2287 | wxT("attempt to add a NULL hWnd to window list ignored") ); | |
2288 | ||
2289 | ||
2290 | wxWindow* pOldWin = wxFindWinFromHandle((WXHWND) hWnd); | |
2291 | ||
2292 | if (pOldWin && (pOldWin != pWin)) | |
2293 | { | |
2294 | wxString str(pWin->GetClassInfo()->GetClassName()); | |
2295 | wxLogError( "Bug! Found existing HWND %X for new window of class %s" | |
2296 | ,(int)hWnd | |
2297 | ,(const char*)str | |
2298 | ); | |
2299 | } | |
2300 | else if (!pOldWin) | |
2301 | { | |
2302 | wxWinHandleList->Append( (long)hWnd | |
2303 | ,pWin | |
2304 | ); | |
2305 | } | |
2306 | } // end of wxAssociateWinWithHandle | |
2307 | ||
2308 | void wxRemoveHandleAssociation( | |
2309 | wxWindow* pWin | |
2310 | ) | |
2311 | { | |
2312 | wxWinHandleList->DeleteObject(pWin); | |
2313 | } // end of wxRemoveHandleAssociation | |
2314 | ||
2315 | // | |
2316 | // Default destroyer - override if you destroy it in some other way | |
2317 | // (e.g. with MDI child windows) | |
2318 | // | |
2319 | void wxWindow::OS2DestroyWindow() | |
2320 | { | |
2321 | } | |
2322 | ||
2323 | void wxWindow::OS2DetachWindowMenu() | |
2324 | { | |
2325 | if (m_hMenu) | |
2326 | { | |
2327 | HMENU hMenu = (HMENU)m_hMenu; | |
2328 | ||
2329 | int nN = (int)::WinSendMsg(hMenu, MM_QUERYITEMCOUNT, 0, 0); | |
2330 | int i; | |
2331 | ||
2332 | for (i = 0; i < nN; i++) | |
2333 | { | |
2334 | wxChar zBuf[100]; | |
2335 | int nChars = (int)::WinSendMsg( hMenu | |
2336 | ,MM_QUERYITEMTEXT | |
2337 | ,MPFROM2SHORT(i, nN) | |
2338 | ,zBuf | |
2339 | ); | |
2340 | if (!nChars) | |
2341 | { | |
2342 | wxLogLastError(wxT("GetMenuString")); | |
2343 | continue; | |
2344 | } | |
2345 | ||
2346 | if (wxStrcmp(zBuf, wxT("&Window")) == 0) | |
2347 | { | |
2348 | ::WinSendMsg(hMenu, MM_DELETEITEM, MPFROM2SHORT(i, TRUE), 0); | |
2349 | break; | |
2350 | } | |
2351 | } | |
2352 | } | |
2353 | } // end of wxWindow::OS2DetachWindowMenu | |
2354 | ||
2355 | bool wxWindow::OS2Create( | |
2356 | WXHWND hParent | |
2357 | , PSZ zClass | |
2358 | , const wxChar* zTitle | |
2359 | , WXDWORD dwStyle | |
2360 | , long lX | |
2361 | , long lY | |
2362 | , long lWidth | |
2363 | , long lHeight | |
2364 | , WXHWND hOwner | |
2365 | , WXHWND hZOrder | |
2366 | , unsigned long ulId | |
2367 | , void* pCtlData | |
2368 | , void* pPresParams | |
2369 | ) | |
2370 | { | |
2371 | ERRORID vError; | |
2372 | wxString sError; | |
2373 | long lX1 = 0L; | |
2374 | long lY1 = 0L; | |
2375 | long lWidth1 = 20L; | |
2376 | long lHeight1 = 20L; | |
2377 | int nControlId = 0; | |
2378 | ||
2379 | // | |
2380 | // Find parent's size, if it exists, to set up a possible default | |
2381 | // panel size the size of the parent window | |
2382 | // | |
2383 | RECTL vParentRect; | |
2384 | HWND hWndClient; | |
2385 | ||
2386 | if (lX > -1L) | |
2387 | lX1 = lX; | |
2388 | if (lY > -1L) | |
2389 | lY1 = lY; | |
2390 | if (lWidth > -1L) | |
2391 | lWidth1 = lWidth; | |
2392 | if (lHeight > -1L) | |
2393 | lHeight1 = lHeight; | |
2394 | ||
2395 | wxWndHook = this; | |
2396 | ||
2397 | // | |
2398 | // check to see if the new window is a standard control | |
2399 | // | |
2400 | if ((ULONG)zClass == (ULONG)WC_BUTTON || | |
2401 | (ULONG)zClass == (ULONG)WC_COMBOBOX || | |
2402 | (ULONG)zClass == (ULONG)WC_CONTAINER || | |
2403 | (ULONG)zClass == (ULONG)WC_ENTRYFIELD || | |
2404 | (ULONG)zClass == (ULONG)WC_FRAME || | |
2405 | (ULONG)zClass == (ULONG)WC_LISTBOX || | |
2406 | (ULONG)zClass == (ULONG)WC_MENU || | |
2407 | (ULONG)zClass == (ULONG)WC_NOTEBOOK || | |
2408 | (ULONG)zClass == (ULONG)WC_SCROLLBAR || | |
2409 | (ULONG)zClass == (ULONG)WC_SPINBUTTON || | |
2410 | (ULONG)zClass == (ULONG)WC_STATIC || | |
2411 | (ULONG)zClass == (ULONG)WC_TITLEBAR || | |
2412 | (ULONG)zClass == (ULONG)WC_VALUESET | |
2413 | ) | |
2414 | { | |
2415 | nControlId = ulId; | |
2416 | } | |
2417 | ||
2418 | // | |
2419 | // We will either have a registered class via string name or a standard PM Class via a long | |
2420 | // | |
2421 | m_hWnd = (WXHWND)::WinCreateWindow( (HWND)hParent | |
2422 | ,zClass | |
2423 | ,(PSZ)zTitle ? zTitle : wxT("") | |
2424 | ,(ULONG)dwStyle | |
2425 | ,(LONG)lX1 | |
2426 | ,(LONG)lY1 | |
2427 | ,(LONG)lWidth | |
2428 | ,(LONG)lHeight | |
2429 | ,NULLHANDLE | |
2430 | ,HWND_TOP | |
2431 | ,(ULONG)ulId | |
2432 | ,pCtlData | |
2433 | ,pPresParams | |
2434 | ); | |
2435 | if (!m_hWnd) | |
2436 | { | |
2437 | vError = ::WinGetLastError(vHabmain); | |
2438 | sError = wxPMErrorToStr(vError); | |
2439 | wxLogError("Can't create window of class %s!. Error: %s\n", zClass, sError); | |
2440 | return FALSE; | |
2441 | } | |
2442 | ::WinSetWindowULong(m_hWnd, QWL_USER, (ULONG) this); | |
2443 | wxWndHook = NULL; | |
2444 | ||
2445 | #ifdef __WXDEBUG__ | |
2446 | wxNode* pNode = wxWinHandleList->Member(this); | |
2447 | ||
2448 | if (pNode) | |
2449 | { | |
2450 | HWND hWnd = (HWND)pNode->GetKeyInteger(); | |
2451 | ||
2452 | if (hWnd != (HWND)m_hWnd) | |
2453 | ||
2454 | { | |
2455 | wxLogError("A second HWND association is being added for the same window!"); | |
2456 | } | |
2457 | } | |
2458 | #endif | |
2459 | wxAssociateWinWithHandle((HWND)m_hWnd | |
2460 | ,this | |
2461 | ); | |
2462 | // | |
2463 | // Now need to subclass window. | |
2464 | // | |
2465 | ||
2466 | SubclassWin(GetHWND()); | |
2467 | ||
2468 | return TRUE; | |
2469 | } // end of wxWindow::OS2Create | |
2470 | ||
2471 | // =========================================================================== | |
2472 | // OS2 PM message handlers | |
2473 | // =========================================================================== | |
2474 | ||
2475 | // --------------------------------------------------------------------------- | |
2476 | // window creation/destruction | |
2477 | // --------------------------------------------------------------------------- | |
2478 | ||
2479 | bool wxWindow::HandleCreate( | |
2480 | WXLPCREATESTRUCT vCs | |
2481 | , bool* pbMayCreate | |
2482 | ) | |
2483 | { | |
2484 | wxWindowCreateEvent vEvent(this); | |
2485 | ||
2486 | (void)GetEventHandler()->ProcessEvent(vEvent); | |
2487 | *pbMayCreate = TRUE; | |
2488 | return TRUE; | |
2489 | } // end of wxWindow::HandleCreate | |
2490 | ||
2491 | bool wxWindow::HandleDestroy() | |
2492 | { | |
2493 | wxWindowDestroyEvent vEvent(this); | |
2494 | ||
2495 | (void)GetEventHandler()->ProcessEvent(vEvent); | |
2496 | ||
2497 | // | |
2498 | // Delete our drop target if we've got one | |
2499 | // | |
2500 | #if wxUSE_DRAG_AND_DROP | |
2501 | if (m_dropTarget != NULL) | |
2502 | { | |
2503 | m_dropTarget->Revoke(m_hWnd); | |
2504 | delete m_dropTarget; | |
2505 | m_dropTarget = NULL; | |
2506 | } | |
2507 | #endif // wxUSE_DRAG_AND_DROP | |
2508 | ||
2509 | // | |
2510 | // WM_DESTROY handled | |
2511 | // | |
2512 | return TRUE; | |
2513 | } // end of wxWindow::HandleDestroy | |
2514 | ||
2515 | // --------------------------------------------------------------------------- | |
2516 | // activation/focus | |
2517 | // --------------------------------------------------------------------------- | |
2518 | void wxWindow::OnSetFocus( | |
2519 | wxFocusEvent& rEvent | |
2520 | ) | |
2521 | { | |
2522 | // | |
2523 | // Panel wants to track the window which was the last to have focus in it, | |
2524 | // so we want to set ourselves as the window which last had focus | |
2525 | // | |
2526 | // Notice that it's also important to do it upwards the tree becaus | |
2527 | // otherwise when the top level panel gets focus, it won't set it back to | |
2528 | // us, but to some other sibling | |
2529 | // | |
2530 | wxWindow* pWin = this; | |
2531 | ||
2532 | while (pWin) | |
2533 | { | |
2534 | wxWindow* pParent = pWin->GetParent(); | |
2535 | wxPanel* pPanel = wxDynamicCast( pParent | |
2536 | ,wxPanel | |
2537 | ); | |
2538 | if (pPanel) | |
2539 | { | |
2540 | pPanel->SetLastFocus(pWin); | |
2541 | } | |
2542 | pWin = pParent; | |
2543 | } | |
2544 | ||
2545 | wxLogTrace(_T("focus"), _T("%s (0x%08x) gets focus"), | |
2546 | GetClassInfo()->GetClassName(), GetHandle()); | |
2547 | ||
2548 | rEvent.Skip(); | |
2549 | } // end of wxWindow::OnSetFocus | |
2550 | ||
2551 | bool wxWindow::HandleActivate( | |
2552 | int nState | |
2553 | , WXHWND WXUNUSED(hActivate) | |
2554 | ) | |
2555 | { | |
2556 | wxActivateEvent vEvent( wxEVT_ACTIVATE | |
2557 | ,(bool)nState | |
2558 | ,m_windowId | |
2559 | ); | |
2560 | vEvent.SetEventObject(this); | |
2561 | return GetEventHandler()->ProcessEvent(vEvent); | |
2562 | } // end of wxWindow::HandleActivate | |
2563 | ||
2564 | bool wxWindow::HandleSetFocus( | |
2565 | WXHWND WXUNUSED(hWnd) | |
2566 | ) | |
2567 | { | |
2568 | #if wxUSE_CARET | |
2569 | // | |
2570 | // Deal with caret | |
2571 | // | |
2572 | if (m_caret) | |
2573 | { | |
2574 | m_caret->OnSetFocus(); | |
2575 | } | |
2576 | #endif // wxUSE_CARET | |
2577 | ||
2578 | // | |
2579 | // Panel wants to track the window which was the last to have focus in it | |
2580 | // | |
2581 | wxPanel* pPanel = wxDynamicCast( GetParent() | |
2582 | ,wxPanel | |
2583 | ); | |
2584 | if (pPanel) | |
2585 | { | |
2586 | pPanel->SetLastFocus(this); | |
2587 | } | |
2588 | ||
2589 | wxFocusEvent vEvent(wxEVT_SET_FOCUS, m_windowId); | |
2590 | ||
2591 | vEvent.SetEventObject(this); | |
2592 | return GetEventHandler()->ProcessEvent(vEvent); | |
2593 | } // end of wxWindow::HandleSetFocus | |
2594 | ||
2595 | bool wxWindow::HandleKillFocus( | |
2596 | WXHWND WXUNUSED(hWnd) | |
2597 | ) | |
2598 | { | |
2599 | #if wxUSE_CARET | |
2600 | // | |
2601 | // Deal with caret | |
2602 | // | |
2603 | if (m_caret) | |
2604 | { | |
2605 | m_caret->OnKillFocus(); | |
2606 | } | |
2607 | #endif // wxUSE_CARET | |
2608 | ||
2609 | wxFocusEvent vEvent( wxEVT_KILL_FOCUS | |
2610 | ,m_windowId | |
2611 | ); | |
2612 | ||
2613 | vEvent.SetEventObject(this); | |
2614 | return GetEventHandler()->ProcessEvent(vEvent); | |
2615 | } // end of wxWindow::HandleKillFocus | |
2616 | ||
2617 | // --------------------------------------------------------------------------- | |
2618 | // miscellaneous | |
2619 | // --------------------------------------------------------------------------- | |
2620 | ||
2621 | bool wxWindow::HandleShow( | |
2622 | bool bShow | |
2623 | , int nStatus | |
2624 | ) | |
2625 | { | |
2626 | wxShowEvent vEvent( GetId() | |
2627 | ,bShow | |
2628 | ); | |
2629 | ||
2630 | vEvent.m_eventObject = this; | |
2631 | return GetEventHandler()->ProcessEvent(vEvent); | |
2632 | } // end of wxWindow::HandleShow | |
2633 | ||
2634 | bool wxWindow::HandleInitDialog( | |
2635 | WXHWND WXUNUSED(hWndFocus) | |
2636 | ) | |
2637 | { | |
2638 | wxInitDialogEvent vEvent(GetId()); | |
2639 | ||
2640 | vEvent.m_eventObject = this; | |
2641 | return GetEventHandler()->ProcessEvent(vEvent); | |
2642 | } // end of wxWindow::HandleInitDialog | |
2643 | ||
2644 | bool wxWindow::HandleEndDrag(WXWPARAM wParam) | |
2645 | { | |
2646 | // TODO: We'll handle drag and drop later | |
2647 | return FALSE; | |
2648 | } | |
2649 | ||
2650 | bool wxWindow::HandleSetCursor( | |
2651 | USHORT vId | |
2652 | , WXHWND hPointer | |
2653 | ) | |
2654 | { | |
2655 | // | |
2656 | // Under OS/2 PM this allows the pointer to be changed | |
2657 | // as it passes over a control | |
2658 | // | |
2659 | ::WinSetPointer(HWND_DESKTOP, (HPOINTER)hPointer); | |
2660 | return TRUE; | |
2661 | } // end of wxWindow::HandleSetCursor | |
2662 | ||
2663 | // --------------------------------------------------------------------------- | |
2664 | // owner drawn stuff | |
2665 | // --------------------------------------------------------------------------- | |
2666 | bool wxWindow::OS2OnDrawItem( | |
2667 | int vId | |
2668 | , WXDRAWITEMSTRUCT* pItemStruct | |
2669 | ) | |
2670 | { | |
2671 | // | |
2672 | // I'll get to owner drawn stuff later | |
2673 | // | |
2674 | ||
2675 | // | |
2676 | // is it a menu item or control? | |
2677 | // | |
2678 | wxWindow* pItem = FindItem(vId); | |
2679 | ||
2680 | #if wxUSE_OWNER_DRAWN | |
2681 | if (pItem && pItem->IsKindOf(CLASSINFO(wxControl))) | |
2682 | { | |
2683 | return ((wxControl *)pItem)->OS2OnDraw(pItemStruct); | |
2684 | } | |
2685 | else if (pItem && pItem->IsKindOf(CLASSINFO(wxMenu))) | |
2686 | { | |
2687 | /* | |
2688 | // TODO: draw a menu item | |
2689 | // | |
2690 | POWNERITEM pDrawStruct = (OWNERITEM *)pItemStruct; | |
2691 | wxMenuItem* pMenuItem = (wxMenuItem *)(pDrawStruct->pItemData); | |
2692 | ||
2693 | wxCHECK(pMenuItem->IsKindOf(CLASSINFO(wxMenuItem)), FALSE); | |
2694 | ||
2695 | // | |
2696 | // Prepare to call OnDrawItem() | |
2697 | // | |
2698 | HPSdc; | |
2699 | dc.SetHDC((WXHDC)pDrawStruct->hDC, FALSE); | |
2700 | wxRect rect(pDrawStruct->rcItem.left, pDrawStruct->rcItem.top, | |
2701 | pDrawStruct->rcItem.right - pDrawStruct->rcItem.left, | |
2702 | pDrawStruct->rcItem.bottom - pDrawStruct->rcItem.top); | |
2703 | ||
2704 | return pMenuItem->OnDrawItem | |
2705 | ( | |
2706 | dc, rect, | |
2707 | (wxOwnerDrawn::wxODAction)pDrawStruct->itemAction, | |
2708 | (wxOwnerDrawn::wxODStatus)pDrawStruct->itemState | |
2709 | ); | |
2710 | */ | |
2711 | } | |
2712 | ||
2713 | else | |
2714 | return FALSE; | |
2715 | #endif | |
2716 | return TRUE; | |
2717 | } // end of wxWindow::OS2OnDrawItem | |
2718 | ||
2719 | bool wxWindow::OS2OnMeasureItem(int id, WXMEASUREITEMSTRUCT *itemStruct) | |
2720 | { | |
2721 | // TODO: more owner drawn menu related stuff, get to it later | |
2722 | /* | |
2723 | #if wxUSE_OWNER_DRAWN | |
2724 | // is it a menu item? | |
2725 | if ( id == 0 ) | |
2726 | { | |
2727 | MEASUREITEMSTRUCT *pMeasureStruct = (MEASUREITEMSTRUCT *)itemStruct; | |
2728 | wxMenuItem *pMenuItem = (wxMenuItem *)(pMeasureStruct->itemData); | |
2729 | ||
2730 | wxCHECK( pMenuItem->IsKindOf(CLASSINFO(wxMenuItem)), FALSE ); | |
2731 | ||
2732 | return pMenuItem->OnMeasureItem(&pMeasureStruct->itemWidth, | |
2733 | &pMeasureStruct->itemHeight); | |
2734 | } | |
2735 | ||
2736 | wxWindow *item = FindItem(id); | |
2737 | if ( item && item->IsKindOf(CLASSINFO(wxControl)) ) | |
2738 | { | |
2739 | return ((wxControl *)item)->MSWOnMeasure(itemStruct); | |
2740 | } | |
2741 | #endif // owner-drawn menus | |
2742 | */ | |
2743 | return FALSE; | |
2744 | } | |
2745 | ||
2746 | // --------------------------------------------------------------------------- | |
2747 | // colours and palettes | |
2748 | // --------------------------------------------------------------------------- | |
2749 | ||
2750 | bool wxWindow::HandleSysColorChange() | |
2751 | { | |
2752 | wxSysColourChangedEvent vEvent; | |
2753 | ||
2754 | vEvent.SetEventObject(this); | |
2755 | return GetEventHandler()->ProcessEvent(vEvent); | |
2756 | } // end of wxWindow::HandleSysColorChange | |
2757 | ||
2758 | bool wxWindow::HandleCtlColor( | |
2759 | WXHBRUSH* phBrush | |
2760 | ) | |
2761 | { | |
2762 | // | |
2763 | // Not much provided with message. So not sure I can do anything with it | |
2764 | // | |
2765 | return TRUE; | |
2766 | } // end of wxWindow::HandleCtlColor | |
2767 | ||
2768 | bool wxWindow::HandleWindowParams( | |
2769 | PWNDPARAMS pWndParams | |
2770 | , WXLPARAM lParam | |
2771 | ) | |
2772 | { | |
2773 | // TODO: I'll do something here, just not sure what yet | |
2774 | return TRUE; | |
2775 | } | |
2776 | ||
2777 | // Define for each class of dialog and control | |
2778 | WXHBRUSH wxWindow::OnCtlColor(WXHDC hDC, | |
2779 | WXHWND hWnd, | |
2780 | WXUINT nCtlColor, | |
2781 | WXUINT message, | |
2782 | WXWPARAM wParam, | |
2783 | WXLPARAM lParam) | |
2784 | { | |
2785 | return (WXHBRUSH)0; | |
2786 | } | |
2787 | ||
2788 | bool wxWindow::HandlePaletteChanged() | |
2789 | { | |
2790 | // need to set this to something first | |
2791 | WXHWND hWndPalChange = NULLHANDLE; | |
2792 | ||
2793 | wxPaletteChangedEvent vEvent(GetId()); | |
2794 | ||
2795 | vEvent.SetEventObject(this); | |
2796 | vEvent.SetChangedWindow(wxFindWinFromHandle(hWndPalChange)); | |
2797 | ||
2798 | return GetEventHandler()->ProcessEvent(vEvent); | |
2799 | } // end of wxWindow::HandlePaletteChanged | |
2800 | ||
2801 | bool wxWindow::HandlePresParamChanged( | |
2802 | WXWPARAM wParam | |
2803 | ) | |
2804 | { | |
2805 | // | |
2806 | // TODO: Once again I'll do something here when I need it | |
2807 | // | |
2808 | //wxQueryNewPaletteEvent event(GetId()); | |
2809 | //event.SetEventObject(this); | |
2810 | // if the background is erased | |
2811 | // bProcessed = HandleEraseBkgnd((WXHDC)(HDC)wParam); | |
2812 | ||
2813 | return FALSE; //GetEventHandler()->ProcessEvent(event) && event.GetPaletteRealized(); | |
2814 | } | |
2815 | ||
2816 | // | |
2817 | // Responds to colour changes: passes event on to children. | |
2818 | // | |
2819 | void wxWindow::OnSysColourChanged( | |
2820 | wxSysColourChangedEvent& rEvent | |
2821 | ) | |
2822 | { | |
2823 | wxNode* pNode = GetChildren().First(); | |
2824 | ||
2825 | while (pNode) | |
2826 | { | |
2827 | // | |
2828 | // Only propagate to non-top-level windows | |
2829 | // | |
2830 | wxWindow* pWin = (wxWindow *)pNode->Data(); | |
2831 | ||
2832 | if (pWin->GetParent()) | |
2833 | { | |
2834 | wxSysColourChangedEvent vEvent; | |
2835 | ||
2836 | rEvent.m_eventObject = pWin; | |
2837 | pWin->GetEventHandler()->ProcessEvent(vEvent); | |
2838 | } | |
2839 | pNode = pNode->Next(); | |
2840 | } | |
2841 | } // end of wxWindow::OnSysColourChanged | |
2842 | ||
2843 | // --------------------------------------------------------------------------- | |
2844 | // painting | |
2845 | // --------------------------------------------------------------------------- | |
2846 | ||
2847 | bool wxWindow::HandlePaint() | |
2848 | { | |
2849 | HRGN hRgn = NULLHANDLE; | |
2850 | wxPaintEvent vEvent; | |
2851 | HPS hPS; | |
2852 | RECTL vRect; | |
2853 | ||
2854 | if (::WinQueryUpdateRegion(GetHwnd(), hRgn) == RGN_NULL) | |
2855 | { | |
2856 | wxLogLastError("CreateRectRgn"); | |
2857 | return FALSE; | |
2858 | } | |
2859 | // | |
2860 | // Debug code | |
2861 | // | |
2862 | #ifdef __WXDEBUG__ | |
2863 | { | |
2864 | HWND hWnd; | |
2865 | HWND hWnd0 = NULLHANDLE; | |
2866 | ||
2867 | hWnd = GetHwnd(); | |
2868 | if(hWnd != hWnd0) | |
2869 | printf("HandlePaint hWnd=%x ",hWnd); | |
2870 | } | |
2871 | #endif | |
2872 | ||
2873 | m_updateRegion = wxRegion(hRgn); | |
2874 | vEvent.SetEventObject(this); | |
2875 | return (GetEventHandler()->ProcessEvent(vEvent)); | |
2876 | } // end of wxWindow::HandlePaint | |
2877 | ||
2878 | bool wxWindow::HandleEraseBkgnd(WXHDC hdc) | |
2879 | { | |
2880 | // TODO: will have to worry about this later as part of | |
2881 | // the handling of changed presentation parameters | |
2882 | /* | |
2883 | if ( ::IsIconic(GetHwnd()) ) | |
2884 | return TRUE; | |
2885 | ||
2886 | wxDC dc; | |
2887 | ||
2888 | dc.SetHDC(hdc); | |
2889 | dc.SetWindow(this); | |
2890 | dc.BeginDrawing(); | |
2891 | ||
2892 | wxEraseEvent event(m_windowId, &dc); | |
2893 | event.SetEventObject(this); | |
2894 | bool rc = GetEventHandler()->ProcessEvent(event); | |
2895 | ||
2896 | dc.EndDrawing(); | |
2897 | dc.SelectOldObjects(hdc); | |
2898 | dc.SetHDC((WXHDC) NULL); | |
2899 | */ | |
2900 | return TRUE; | |
2901 | } // end of wxWindow::HandleEraseBkgnd | |
2902 | ||
2903 | void wxWindow::OnEraseBackground( | |
2904 | wxEraseEvent& rEvent | |
2905 | ) | |
2906 | { | |
2907 | // TODO: | |
2908 | } // end of wxWindow::OnEraseBackground | |
2909 | ||
2910 | // --------------------------------------------------------------------------- | |
2911 | // moving and resizing | |
2912 | // --------------------------------------------------------------------------- | |
2913 | ||
2914 | bool wxWindow::HandleMinimize() | |
2915 | { | |
2916 | wxIconizeEvent vEvent(m_windowId); | |
2917 | ||
2918 | vEvent.SetEventObject(this); | |
2919 | return GetEventHandler()->ProcessEvent(vEvent); | |
2920 | } // end of wxWindow::HandleMinimize | |
2921 | ||
2922 | bool wxWindow::HandleMaximize() | |
2923 | { | |
2924 | wxMaximizeEvent vEvent(m_windowId); | |
2925 | ||
2926 | vEvent.SetEventObject(this); | |
2927 | return GetEventHandler()->ProcessEvent(vEvent); | |
2928 | } // end of wxWindow::HandleMaximize | |
2929 | ||
2930 | bool wxWindow::HandleMove( | |
2931 | int nX | |
2932 | , int nY | |
2933 | ) | |
2934 | { | |
2935 | wxMoveEvent vEvent( wxPoint( nX | |
2936 | ,nY | |
2937 | ) | |
2938 | ,m_windowId | |
2939 | ); | |
2940 | ||
2941 | vEvent.SetEventObject(this); | |
2942 | return GetEventHandler()->ProcessEvent(vEvent); | |
2943 | } // end of wxWindow::HandleMove | |
2944 | ||
2945 | bool wxWindow::HandleSize( | |
2946 | int nWidth | |
2947 | , int nHeight | |
2948 | , WXUINT WXUNUSED(nFlag) | |
2949 | ) | |
2950 | { | |
2951 | wxSizeEvent vEvent( wxSize( nWidth | |
2952 | ,nHeight | |
2953 | ) | |
2954 | ,m_windowId | |
2955 | ); | |
2956 | ||
2957 | vEvent.SetEventObject(this); | |
2958 | return GetEventHandler()->ProcessEvent(vEvent); | |
2959 | } // end of wxWindow::HandleSize | |
2960 | ||
2961 | bool wxWindow::HandleGetMinMaxInfo( | |
2962 | PSWP pSwp | |
2963 | ) | |
2964 | { | |
2965 | bool bRc = FALSE; | |
2966 | POINTL vPoint; | |
2967 | ||
2968 | switch(pSwp->fl) | |
2969 | { | |
2970 | case SWP_MAXIMIZE: | |
2971 | ::WinGetMaxPosition(GetHwnd(), pSwp); | |
2972 | m_maxWidth = pSwp->cx; | |
2973 | m_maxHeight = pSwp->cy; | |
2974 | break; | |
2975 | ||
2976 | case SWP_MINIMIZE: | |
2977 | ::WinGetMinPosition(GetHwnd(), pSwp, &vPoint); | |
2978 | m_minWidth = pSwp->cx; | |
2979 | m_minHeight = pSwp->cy; | |
2980 | break; | |
2981 | ||
2982 | default: | |
2983 | return FALSE; | |
2984 | } | |
2985 | return TRUE; | |
2986 | } // end of wxWindow::HandleGetMinMaxInfo | |
2987 | ||
2988 | // --------------------------------------------------------------------------- | |
2989 | // command messages | |
2990 | // --------------------------------------------------------------------------- | |
2991 | bool wxWindow::HandleCommand( | |
2992 | WXWORD wId | |
2993 | , WXWORD wCmd | |
2994 | , WXHWND hControl | |
2995 | ) | |
2996 | { | |
2997 | if (wxCurrentPopupMenu) | |
2998 | { | |
2999 | wxMenu* pPopupMenu = wxCurrentPopupMenu; | |
3000 | ||
3001 | wxCurrentPopupMenu = NULL; | |
3002 | return pPopupMenu->OS2Command(wCmd, wId); | |
3003 | } | |
3004 | ||
3005 | wxWindow* pWin = FindItem(wId); | |
3006 | ||
3007 | if (!pWin) | |
3008 | { | |
3009 | pWin = wxFindWinFromHandle(hControl); | |
3010 | } | |
3011 | ||
3012 | if (pWin) | |
3013 | return pWin->OS2Command( wCmd | |
3014 | ,wId | |
3015 | ); | |
3016 | return FALSE; | |
3017 | } // end of wxWindow::HandleCommand | |
3018 | ||
3019 | bool wxWindow::HandleSysCommand( | |
3020 | WXWPARAM wParam | |
3021 | , WXLPARAM lParam | |
3022 | ) | |
3023 | { | |
3024 | // | |
3025 | // 4 bits are reserved | |
3026 | // | |
3027 | switch (SHORT1FROMMP(wParam)) | |
3028 | { | |
3029 | case SC_MAXIMIZE: | |
3030 | return HandleMaximize(); | |
3031 | ||
3032 | case SC_MINIMIZE: | |
3033 | return HandleMinimize(); | |
3034 | } | |
3035 | return FALSE; | |
3036 | } // end of wxWindow::HandleSysCommand | |
3037 | ||
3038 | // --------------------------------------------------------------------------- | |
3039 | // mouse events | |
3040 | // --------------------------------------------------------------------------- | |
3041 | ||
3042 | void wxWindow::InitMouseEvent( | |
3043 | wxMouseEvent& rEvent | |
3044 | , int nX | |
3045 | , int nY | |
3046 | , WXUINT uFlags | |
3047 | ) | |
3048 | { | |
3049 | rEvent.m_x = nX; | |
3050 | rEvent.m_y = nY; | |
3051 | rEvent.m_shiftDown = ((uFlags & VK_SHIFT) != 0); | |
3052 | rEvent.m_controlDown = ((uFlags & VK_CTRL) != 0); | |
3053 | rEvent.m_leftDown = ((uFlags & VK_BUTTON1) != 0); | |
3054 | rEvent.m_middleDown = ((uFlags & VK_BUTTON3) != 0); | |
3055 | rEvent.m_rightDown = ((uFlags & VK_BUTTON2) != 0); | |
3056 | rEvent.SetTimestamp(s_currentMsg.time); | |
3057 | rEvent.m_eventObject = this; | |
3058 | ||
3059 | #if wxUSE_MOUSEEVENT_HACK | |
3060 | m_lastMouseX = nX; | |
3061 | m_lastMouseY = nY; | |
3062 | m_lastMouseEvent = rEvent.GetEventType(); | |
3063 | #endif // wxUSE_MOUSEEVENT_HACK | |
3064 | } // end of wxWindow::InitMouseEvent | |
3065 | ||
3066 | bool wxWindow::HandleMouseEvent( | |
3067 | WXUINT uMsg | |
3068 | , int nX | |
3069 | , int nY | |
3070 | , WXUINT uFlags | |
3071 | ) | |
3072 | { | |
3073 | // | |
3074 | // The mouse events take consecutive IDs from WM_MOUSEFIRST to | |
3075 | // WM_MOUSELAST, so it's enough to substract WM_MOUSEMOVE == WM_MOUSEFIRST | |
3076 | // from the message id and take the value in the table to get wxWin event | |
3077 | // id | |
3078 | // | |
3079 | static const wxEventType eventsMouse[] = | |
3080 | { | |
3081 | wxEVT_MOTION, | |
3082 | wxEVT_LEFT_DOWN, | |
3083 | wxEVT_LEFT_UP, | |
3084 | wxEVT_LEFT_DCLICK, | |
3085 | wxEVT_RIGHT_DOWN, | |
3086 | wxEVT_RIGHT_UP, | |
3087 | wxEVT_RIGHT_DCLICK, | |
3088 | wxEVT_MIDDLE_DOWN, | |
3089 | wxEVT_MIDDLE_UP, | |
3090 | wxEVT_MIDDLE_DCLICK | |
3091 | }; | |
3092 | ||
3093 | wxMouseEvent vEvent(eventsMouse[uMsg - WM_MOUSEMOVE]); | |
3094 | ||
3095 | InitMouseEvent( vEvent | |
3096 | ,nX | |
3097 | ,nY | |
3098 | ,uFlags | |
3099 | ); | |
3100 | ||
3101 | return GetEventHandler()->ProcessEvent(vEvent); | |
3102 | } // end of wxWindow::HandleMouseEvent | |
3103 | ||
3104 | bool wxWindow::HandleMouseMove( | |
3105 | int nX | |
3106 | , int nY | |
3107 | , WXUINT uFlags | |
3108 | ) | |
3109 | { | |
3110 | if (!m_bMouseInWindow) | |
3111 | { | |
3112 | // | |
3113 | // Generate an ENTER event | |
3114 | // | |
3115 | m_bMouseInWindow = TRUE; | |
3116 | ||
3117 | wxMouseEvent vEvent(wxEVT_ENTER_WINDOW); | |
3118 | ||
3119 | InitMouseEvent( vEvent | |
3120 | ,nX | |
3121 | ,nY | |
3122 | ,uFlags | |
3123 | ); | |
3124 | ||
3125 | (void)GetEventHandler()->ProcessEvent(vEvent); | |
3126 | } | |
3127 | return HandleMouseEvent( WM_MOUSEMOVE | |
3128 | ,nX | |
3129 | ,nY | |
3130 | ,uFlags | |
3131 | ); | |
3132 | } // end of wxWindow::HandleMouseMove | |
3133 | ||
3134 | // --------------------------------------------------------------------------- | |
3135 | // keyboard handling | |
3136 | // --------------------------------------------------------------------------- | |
3137 | ||
3138 | // | |
3139 | // Create the key event of the given type for the given key - used by | |
3140 | // HandleChar and HandleKeyDown/Up | |
3141 | // | |
3142 | wxKeyEvent wxWindow::CreateKeyEvent( | |
3143 | wxEventType eType | |
3144 | , int nId | |
3145 | , WXLPARAM lParam | |
3146 | ) const | |
3147 | { | |
3148 | wxKeyEvent vEvent(eType); | |
3149 | ||
3150 | vEvent.SetId(GetId()); | |
3151 | vEvent.m_shiftDown = IsShiftDown(); | |
3152 | vEvent.m_controlDown = IsCtrlDown(); | |
3153 | vEvent.m_altDown = (HIWORD(lParam) & KC_ALT) == KC_ALT; | |
3154 | ||
3155 | vEvent.m_eventObject = (wxWindow *)this; // const_cast | |
3156 | vEvent.m_keyCode = nId; | |
3157 | vEvent.SetTimestamp(s_currentMsg.time); | |
3158 | ||
3159 | // | |
3160 | // Translate the position to client coords | |
3161 | // | |
3162 | POINTL vPoint; | |
3163 | RECTL vRect; | |
3164 | ||
3165 | ::WinQueryPointerPos(HWND_DESKTOP, &vPoint); | |
3166 | ::WinQueryWindowRect( GetHwnd() | |
3167 | ,&vRect | |
3168 | ); | |
3169 | ||
3170 | vPoint.x -= vRect.xLeft; | |
3171 | vPoint.y -= vRect.yBottom; | |
3172 | ||
3173 | vEvent.m_x = vPoint.x; | |
3174 | vEvent.m_y = vPoint.y; | |
3175 | ||
3176 | return vEvent; | |
3177 | } // end of wxWindow::CreateKeyEvent | |
3178 | ||
3179 | // | |
3180 | // isASCII is TRUE only when we're called from WM_CHAR handler and not from | |
3181 | // WM_KEYDOWN one | |
3182 | // | |
3183 | bool wxWindow::HandleChar( | |
3184 | WXWORD wParam | |
3185 | , WXLPARAM lParam | |
3186 | , bool isASCII | |
3187 | ) | |
3188 | { | |
3189 | bool bCtrlDown = FALSE; | |
3190 | int vId; | |
3191 | ||
3192 | if (isASCII) | |
3193 | { | |
3194 | // | |
3195 | // If 1 -> 26, translate to CTRL plus a letter. | |
3196 | // | |
3197 | vId = wParam; | |
3198 | if ((vId > 0) && (vId < 27)) | |
3199 | { | |
3200 | switch (vId) | |
3201 | { | |
3202 | case 13: | |
3203 | vId = WXK_RETURN; | |
3204 | break; | |
3205 | ||
3206 | case 8: | |
3207 | vId = WXK_BACK; | |
3208 | break; | |
3209 | ||
3210 | case 9: | |
3211 | vId = WXK_TAB; | |
3212 | break; | |
3213 | ||
3214 | default: | |
3215 | bCtrlDown = TRUE; | |
3216 | vId = vId + 96; | |
3217 | } | |
3218 | } | |
3219 | } | |
3220 | else if ( (vId = wxCharCodeOS2ToWX(wParam)) == 0) | |
3221 | { | |
3222 | // | |
3223 | // It's ASCII and will be processed here only when called from | |
3224 | // WM_CHAR (i.e. when isASCII = TRUE), don't process it now | |
3225 | // | |
3226 | vId = -1; | |
3227 | } | |
3228 | ||
3229 | if (vId != -1) | |
3230 | { | |
3231 | wxKeyEvent vEvent(CreateKeyEvent( wxEVT_CHAR | |
3232 | ,vId | |
3233 | ,lParam | |
3234 | )); | |
3235 | ||
3236 | if (bCtrlDown) | |
3237 | { | |
3238 | vEvent.m_controlDown = TRUE; | |
3239 | } | |
3240 | ||
3241 | if (GetEventHandler()->ProcessEvent(vEvent)) | |
3242 | return TRUE; | |
3243 | } | |
3244 | return FALSE; | |
3245 | } | |
3246 | ||
3247 | bool wxWindow::HandleKeyDown( | |
3248 | WXWORD wParam | |
3249 | , WXLPARAM lParam | |
3250 | ) | |
3251 | { | |
3252 | int nId = wxCharCodeOS2ToWX(wParam); | |
3253 | ||
3254 | if (!nId) | |
3255 | { | |
3256 | // | |
3257 | // Normal ASCII char | |
3258 | // | |
3259 | nId = wParam; | |
3260 | } | |
3261 | ||
3262 | if (nId != -1) | |
3263 | { | |
3264 | wxKeyEvent vEvent(CreateKeyEvent( wxEVT_KEY_DOWN | |
3265 | ,nId | |
3266 | ,lParam | |
3267 | )); | |
3268 | ||
3269 | if (GetEventHandler()->ProcessEvent(vEvent)) | |
3270 | { | |
3271 | return TRUE; | |
3272 | } | |
3273 | } | |
3274 | return FALSE; | |
3275 | } // end of wxWindow::HandleKeyDown | |
3276 | ||
3277 | bool wxWindow::HandleKeyUp( | |
3278 | WXWORD wParam | |
3279 | , WXLPARAM lParam | |
3280 | ) | |
3281 | { | |
3282 | int nId = wxCharCodeOS2ToWX(wParam); | |
3283 | ||
3284 | if (!nId) | |
3285 | { | |
3286 | // | |
3287 | // Normal ASCII char | |
3288 | // | |
3289 | nId = wParam; | |
3290 | } | |
3291 | ||
3292 | if (nId != -1) | |
3293 | { | |
3294 | wxKeyEvent vEvent(CreateKeyEvent( wxEVT_KEY_UP | |
3295 | ,nId | |
3296 | ,lParam | |
3297 | )); | |
3298 | ||
3299 | if (GetEventHandler()->ProcessEvent(vEvent)) | |
3300 | return TRUE; | |
3301 | } | |
3302 | return FALSE; | |
3303 | } // end of wxWindow::HandleKeyUp | |
3304 | ||
3305 | // --------------------------------------------------------------------------- | |
3306 | // joystick | |
3307 | // --------------------------------------------------------------------------- | |
3308 | ||
3309 | // --------------------------------------------------------------------------- | |
3310 | // scrolling | |
3311 | // --------------------------------------------------------------------------- | |
3312 | ||
3313 | bool wxWindow::OS2OnScroll( | |
3314 | int nOrientation | |
3315 | , WXWORD wParam | |
3316 | , WXWORD wPos | |
3317 | , WXHWND hControl | |
3318 | ) | |
3319 | { | |
3320 | if (hControl) | |
3321 | { | |
3322 | wxWindow* pChild = wxFindWinFromHandle(hControl); | |
3323 | ||
3324 | if (pChild ) | |
3325 | return pChild->OS2OnScroll( nOrientation | |
3326 | ,wParam | |
3327 | ,wPos | |
3328 | ,hControl | |
3329 | ); | |
3330 | } | |
3331 | ||
3332 | wxScrollWinEvent vEvent; | |
3333 | ||
3334 | vEvent.SetPosition(wPos); | |
3335 | vEvent.SetOrientation(nOrientation); | |
3336 | vEvent.m_eventObject = this; | |
3337 | ||
3338 | switch (wParam) | |
3339 | { | |
3340 | case SB_LINEUP: | |
3341 | vEvent.m_eventType = wxEVT_SCROLLWIN_LINEUP; | |
3342 | break; | |
3343 | ||
3344 | case SB_LINEDOWN: | |
3345 | vEvent.m_eventType = wxEVT_SCROLLWIN_LINEDOWN; | |
3346 | break; | |
3347 | ||
3348 | case SB_PAGEUP: | |
3349 | vEvent.m_eventType = wxEVT_SCROLLWIN_PAGEUP; | |
3350 | break; | |
3351 | ||
3352 | case SB_PAGEDOWN: | |
3353 | vEvent.m_eventType = wxEVT_SCROLLWIN_PAGEDOWN; | |
3354 | break; | |
3355 | ||
3356 | case SB_SLIDERPOSITION: | |
3357 | vEvent.m_eventType = wxEVT_SCROLLWIN_THUMBRELEASE; | |
3358 | break; | |
3359 | ||
3360 | case SB_SLIDERTRACK: | |
3361 | vEvent.m_eventType = wxEVT_SCROLLWIN_THUMBTRACK; | |
3362 | break; | |
3363 | ||
3364 | default: | |
3365 | return FALSE; | |
3366 | } | |
3367 | return GetEventHandler()->ProcessEvent(vEvent); | |
3368 | } // end of wxWindow::OS2OnScroll | |
3369 | ||
3370 | // =========================================================================== | |
3371 | // global functions | |
3372 | // =========================================================================== | |
3373 | ||
3374 | void wxGetCharSize( | |
3375 | WXHWND hWnd | |
3376 | , int* pX | |
3377 | , int* pY | |
3378 | ,wxFont* pTheFont | |
3379 | ) | |
3380 | { | |
3381 | // TODO: we'll do this later | |
3382 | } // end of wxGetCharSize | |
3383 | ||
3384 | // | |
3385 | // Returns 0 if was a normal ASCII value, not a special key. This indicates that | |
3386 | // the key should be ignored by WM_KEYDOWN and processed by WM_CHAR instead. | |
3387 | // | |
3388 | int wxCharCodeOS2ToWX( | |
3389 | int nKeySym | |
3390 | ) | |
3391 | { | |
3392 | int nId = 0; | |
3393 | ||
3394 | switch (nKeySym) | |
3395 | { | |
3396 | case VK_BACKTAB: nId = WXK_BACK; break; | |
3397 | case VK_TAB: nId = WXK_TAB; break; | |
3398 | case VK_CLEAR: nId = WXK_CLEAR; break; | |
3399 | case VK_ENTER: nId = WXK_RETURN; break; | |
3400 | case VK_SHIFT: nId = WXK_SHIFT; break; | |
3401 | case VK_CTRL: nId = WXK_CONTROL; break; | |
3402 | case VK_PAUSE: nId = WXK_PAUSE; break; | |
3403 | case VK_SPACE: nId = WXK_SPACE; break; | |
3404 | case VK_ESC: nId = WXK_ESCAPE; break; | |
3405 | case VK_END: nId = WXK_END; break; | |
3406 | case VK_HOME : nId = WXK_HOME; break; | |
3407 | case VK_LEFT : nId = WXK_LEFT; break; | |
3408 | case VK_UP: nId = WXK_UP; break; | |
3409 | case VK_RIGHT: nId = WXK_RIGHT; break; | |
3410 | case VK_DOWN : nId = WXK_DOWN; break; | |
3411 | case VK_PRINTSCRN: nId = WXK_PRINT; break; | |
3412 | case VK_INSERT: nId = WXK_INSERT; break; | |
3413 | case VK_DELETE: nId = WXK_DELETE; break; | |
3414 | case VK_F1: nId = WXK_F1; break; | |
3415 | case VK_F2: nId = WXK_F2; break; | |
3416 | case VK_F3: nId = WXK_F3; break; | |
3417 | case VK_F4: nId = WXK_F4; break; | |
3418 | case VK_F5: nId = WXK_F5; break; | |
3419 | case VK_F6: nId = WXK_F6; break; | |
3420 | case VK_F7: nId = WXK_F7; break; | |
3421 | case VK_F8: nId = WXK_F8; break; | |
3422 | case VK_F9: nId = WXK_F9; break; | |
3423 | case VK_F10: nId = WXK_F10; break; | |
3424 | case VK_F11: nId = WXK_F11; break; | |
3425 | case VK_F12: nId = WXK_F12; break; | |
3426 | case VK_F13: nId = WXK_F13; break; | |
3427 | case VK_F14: nId = WXK_F14; break; | |
3428 | case VK_F15: nId = WXK_F15; break; | |
3429 | case VK_F16: nId = WXK_F16; break; | |
3430 | case VK_F17: nId = WXK_F17; break; | |
3431 | case VK_F18: nId = WXK_F18; break; | |
3432 | case VK_F19: nId = WXK_F19; break; | |
3433 | case VK_F20: nId = WXK_F20; break; | |
3434 | case VK_F21: nId = WXK_F21; break; | |
3435 | case VK_F22: nId = WXK_F22; break; | |
3436 | case VK_F23: nId = WXK_F23; break; | |
3437 | case VK_F24: nId = WXK_F24; break; | |
3438 | case VK_NUMLOCK: nId = WXK_NUMLOCK; break; | |
3439 | case VK_SCRLLOCK: nId = WXK_SCROLL; break; | |
3440 | default: | |
3441 | { | |
3442 | return 0; | |
3443 | } | |
3444 | } | |
3445 | return nId; | |
3446 | } // end of wxCharCodeOS2ToWX | |
3447 | ||
3448 | int wxCharCodeWXToOS2( | |
3449 | int nId | |
3450 | , bool* bIsVirtual | |
3451 | ) | |
3452 | { | |
3453 | int nKeySym = 0; | |
3454 | ||
3455 | *bIsVirtual = TRUE; | |
3456 | switch (nId) | |
3457 | { | |
3458 | case WXK_CLEAR: nKeySym = VK_CLEAR; break; | |
3459 | case WXK_SHIFT: nKeySym = VK_SHIFT; break; | |
3460 | case WXK_CONTROL: nKeySym = VK_CTRL; break; | |
3461 | case WXK_PAUSE: nKeySym = VK_PAUSE; break; | |
3462 | case WXK_END: nKeySym = VK_END; break; | |
3463 | case WXK_HOME : nKeySym = VK_HOME; break; | |
3464 | case WXK_LEFT : nKeySym = VK_LEFT; break; | |
3465 | case WXK_UP: nKeySym = VK_UP; break; | |
3466 | case WXK_RIGHT: nKeySym = VK_RIGHT; break; | |
3467 | case WXK_DOWN : nKeySym = VK_DOWN; break; | |
3468 | case WXK_PRINT: nKeySym = VK_PRINTSCRN; break; | |
3469 | case WXK_INSERT: nKeySym = VK_INSERT; break; | |
3470 | case WXK_DELETE: nKeySym = VK_DELETE; break; | |
3471 | case WXK_F1: nKeySym = VK_F1; break; | |
3472 | case WXK_F2: nKeySym = VK_F2; break; | |
3473 | case WXK_F3: nKeySym = VK_F3; break; | |
3474 | case WXK_F4: nKeySym = VK_F4; break; | |
3475 | case WXK_F5: nKeySym = VK_F5; break; | |
3476 | case WXK_F6: nKeySym = VK_F6; break; | |
3477 | case WXK_F7: nKeySym = VK_F7; break; | |
3478 | case WXK_F8: nKeySym = VK_F8; break; | |
3479 | case WXK_F9: nKeySym = VK_F9; break; | |
3480 | case WXK_F10: nKeySym = VK_F10; break; | |
3481 | case WXK_F11: nKeySym = VK_F11; break; | |
3482 | case WXK_F12: nKeySym = VK_F12; break; | |
3483 | case WXK_F13: nKeySym = VK_F13; break; | |
3484 | case WXK_F14: nKeySym = VK_F14; break; | |
3485 | case WXK_F15: nKeySym = VK_F15; break; | |
3486 | case WXK_F16: nKeySym = VK_F16; break; | |
3487 | case WXK_F17: nKeySym = VK_F17; break; | |
3488 | case WXK_F18: nKeySym = VK_F18; break; | |
3489 | case WXK_F19: nKeySym = VK_F19; break; | |
3490 | case WXK_F20: nKeySym = VK_F20; break; | |
3491 | case WXK_F21: nKeySym = VK_F21; break; | |
3492 | case WXK_F22: nKeySym = VK_F22; break; | |
3493 | case WXK_F23: nKeySym = VK_F23; break; | |
3494 | case WXK_F24: nKeySym = VK_F24; break; | |
3495 | case WXK_NUMLOCK: nKeySym = VK_NUMLOCK; break; | |
3496 | case WXK_SCROLL: nKeySym = VK_SCRLLOCK; break; | |
3497 | default: | |
3498 | { | |
3499 | *bIsVirtual = FALSE; | |
3500 | nKeySym = nId; | |
3501 | break; | |
3502 | } | |
3503 | } | |
3504 | return nKeySym; | |
3505 | } // end of wxCharCodeWXToOS2 | |
3506 | ||
3507 | wxWindow* wxGetActiveWindow() | |
3508 | { | |
3509 | HWND hWnd = ::WinQueryActiveWindow(HWND_DESKTOP); | |
3510 | ||
3511 | if (hWnd != 0) | |
3512 | { | |
3513 | return wxFindWinFromHandle((WXHWND)hWnd); | |
3514 | } | |
3515 | return NULL; | |
3516 | } // end of wxGetActiveWindow | |
3517 | ||
3518 | #ifdef __WXDEBUG__ | |
3519 | const char* wxGetMessageName( | |
3520 | int nMessage) | |
3521 | { | |
3522 | switch (nMessage) | |
3523 | { | |
3524 | case 0x0000: return "WM_NULL"; | |
3525 | case 0x0001: return "WM_CREATE"; | |
3526 | case 0x0002: return "WM_DESTROY"; | |
3527 | case 0x0004: return "WM_ENABLE"; | |
3528 | case 0x0005: return "WM_SHOW"; | |
3529 | case 0x0006: return "WM_MOVE"; | |
3530 | case 0x0007: return "WM_SIZE"; | |
3531 | case 0x0008: return "WM_ADJUSTWINDOWPOS"; | |
3532 | case 0x0009: return "WM_CALCVALIDRECTS"; | |
3533 | case 0x000A: return "WM_SETWINDOWPARAMS"; | |
3534 | case 0x000B: return "WM_QUERYWINDOWPARAMS"; | |
3535 | case 0x000C: return "WM_HITTEST"; | |
3536 | case 0x000D: return "WM_ACTIVATE"; | |
3537 | case 0x000F: return "WM_SETFOCUS"; | |
3538 | case 0x0010: return "WM_SETSELECTION"; | |
3539 | case 0x0011: return "WM_PPAINT"; | |
3540 | case 0x0012: return "WM_PSETFOCUS"; | |
3541 | case 0x0013: return "WM_PSYSCOLORCHANGE"; | |
3542 | case 0x0014: return "WM_PSIZE"; | |
3543 | case 0x0015: return "WM_PACTIVATE"; | |
3544 | case 0x0016: return "WM_PCONTROL"; | |
3545 | case 0x0020: return "WM_COMMAND"; | |
3546 | case 0x0021: return "WM_SYSCOMMAND"; | |
3547 | case 0x0022: return "WM_HELP"; | |
3548 | case 0x0023: return "WM_PAINT"; | |
3549 | case 0x0024: return "WM_TIMER"; | |
3550 | case 0x0025: return "WM_SEM1"; | |
3551 | case 0x0026: return "WM_SEM2"; | |
3552 | case 0x0027: return "WM_SEM3"; | |
3553 | case 0x0028: return "WM_SEM4"; | |
3554 | case 0x0029: return "WM_CLOSE"; | |
3555 | case 0x002A: return "WM_QUIT"; | |
3556 | case 0x002B: return "WM_SYSCOLORCHANGE"; | |
3557 | case 0x002D: return "WM_SYSVALUECHANGE"; | |
3558 | case 0x002E: return "WM_APPTERMINATENOTIFY"; | |
3559 | case 0x002F: return "WM_PRESPARAMCHANGED"; | |
3560 | // Control notification messages | |
3561 | case 0x0030: return "WM_CONTROL"; | |
3562 | case 0x0031: return "WM_VSCROLL"; | |
3563 | case 0x0032: return "WM_HSCROLL"; | |
3564 | case 0x0033: return "WM_INITMENU"; | |
3565 | case 0x0034: return "WM_MENUSELECT"; | |
3566 | case 0x0035: return "WM_MENUSEND"; | |
3567 | case 0x0036: return "WM_DRAWITEM"; | |
3568 | case 0x0037: return "WM_MEASUREITEM"; | |
3569 | case 0x0038: return "WM_CONTROLPOINTER"; | |
3570 | case 0x003A: return "WM_QUERYDLGCODE"; | |
3571 | case 0x003B: return "WM_INITDLG"; | |
3572 | case 0x003C: return "WM_SUBSTITUTESTRING"; | |
3573 | case 0x003D: return "WM_MATCHMNEMONIC"; | |
3574 | case 0x003E: return "WM_SAVEAPPLICATION"; | |
3575 | case 0x0129: return "WM_CTLCOLORCHANGE"; | |
3576 | case 0x0130: return "WM_QUERYCTLTYPE"; | |
3577 | // Frame messages | |
3578 | case 0x0040: return "WM_FLASHWINDOW"; | |
3579 | case 0x0041: return "WM_FORMATFRAME"; | |
3580 | case 0x0042: return "WM_UPDATEFRAME"; | |
3581 | case 0x0043: return "WM_FOCUSCHANGE"; | |
3582 | case 0x0044: return "WM_SETBORDERSIZE"; | |
3583 | case 0x0045: return "WM_TRACKFRAME"; | |
3584 | case 0x0046: return "WM_MINMAXFRAME"; | |
3585 | case 0x0047: return "WM_SETICON"; | |
3586 | case 0x0048: return "WM_QUERYICON"; | |
3587 | case 0x0049: return "WM_SETACCELTABLE"; | |
3588 | case 0x004A: return "WM_QUERYACCELTABLE"; | |
3589 | case 0x004B: return "WM_TRANSLATEACCEL"; | |
3590 | case 0x004C: return "WM_QUERYTRACKINFO"; | |
3591 | case 0x004D: return "WM_QUERYBORDERSIZE"; | |
3592 | case 0x004E: return "WM_NEXTMENU"; | |
3593 | case 0x004F: return "WM_ERASEBACKGROUND"; | |
3594 | case 0x0050: return "WM_QUERYFRAMEINFO"; | |
3595 | case 0x0051: return "WM_QUERYFOCUSCHAIN"; | |
3596 | case 0x0052: return "WM_OWNERPOSCHANGE"; | |
3597 | case 0x0053: return "WM_CACLFRAMERECT"; | |
3598 | case 0x0055: return "WM_WINDOWPOSCHANGED"; | |
3599 | case 0x0056: return "WM_ADJUSTFRAMEPOS"; | |
3600 | case 0x0059: return "WM_QUERYFRAMECTLCOUNT"; | |
3601 | case 0x005B: return "WM_QUERYHELPINFO"; | |
3602 | case 0x005C: return "WM_SETHELPINFO"; | |
3603 | case 0x005D: return "WM_ERROR"; | |
3604 | case 0x005E: return "WM_REALIZEPALETTE"; | |
3605 | // Clipboard messages | |
3606 | case 0x0060: return "WM_RENDERFMT"; | |
3607 | case 0x0061: return "WM_RENDERALLFMTS"; | |
3608 | case 0x0062: return "WM_DESTROYCLIPBOARD"; | |
3609 | case 0x0063: return "WM_PAINTCLIPBOARD"; | |
3610 | case 0x0064: return "WM_SIZECLIPBOARD"; | |
3611 | case 0x0065: return "WM_HSCROLLCLIPBOARD"; | |
3612 | case 0x0066: return "WM_VSCROLLCLIPBOARD"; | |
3613 | case 0x0067: return "WM_DRAWCLIPBOARD"; | |
3614 | // mouse messages | |
3615 | case 0x0070: return "WM_MOUSEMOVE"; | |
3616 | case 0x0071: return "WM_BUTTON1DOWN"; | |
3617 | case 0x0072: return "WM_BUTTON1UP"; | |
3618 | case 0x0073: return "WM_BUTTON1DBLCLK"; | |
3619 | case 0x0074: return "WM_BUTTON2DOWN"; | |
3620 | case 0x0075: return "WM_BUTTON2UP"; | |
3621 | case 0x0076: return "WM_BUTTON2DBLCLK"; | |
3622 | case 0x0077: return "WM_BUTTON3DOWN"; | |
3623 | case 0x0078: return "WM_BUTTON3UP"; | |
3624 | case 0x0079: return "WM_BUTTON3DBLCLK"; | |
3625 | case 0x007D: return "WM_MOUSEMAP"; | |
3626 | case 0x007E: return "WM_VRNDISABLED"; | |
3627 | case 0x007F: return "WM_VRNENABLED"; | |
3628 | case 0x0410: return "WM_CHORD"; | |
3629 | case 0x0411: return "WM_BUTTON1MOTIONSTART"; | |
3630 | case 0x0412: return "WM_BUTTON1MOTIONEND"; | |
3631 | case 0x0413: return "WM_BUTTON1CLICK"; | |
3632 | case 0x0414: return "WM_BUTTON2MOTIONSTART"; | |
3633 | case 0x0415: return "WM_BUTTON2MOTIONEND"; | |
3634 | case 0x0416: return "WM_BUTTON2CLICK"; | |
3635 | case 0x0417: return "WM_BUTTON3MOTIONSTART"; | |
3636 | case 0x0418: return "WM_BUTTON3MOTIONEND"; | |
3637 | case 0x0419: return "WM_BUTTON3CLICK"; | |
3638 | case 0x0420: return "WM_BEGINDRAG"; | |
3639 | case 0x0421: return "WM_ENDDRAG"; | |
3640 | case 0x0422: return "WM_SINGLESELECT"; | |
3641 | case 0x0423: return "WM_OPEN"; | |
3642 | case 0x0424: return "WM_CONTEXTMENU"; | |
3643 | case 0x0425: return "WM_CONTEXTHELP"; | |
3644 | case 0x0426: return "WM_TEXTEDIT"; | |
3645 | case 0x0427: return "WM_BEGINSELECT"; | |
3646 | case 0x0228: return "WM_ENDSELECT"; | |
3647 | case 0x0429: return "WM_PICKUP"; | |
3648 | case 0x04C0: return "WM_PENFIRST"; | |
3649 | case 0x04FF: return "WM_PENLAST"; | |
3650 | case 0x0500: return "WM_MMPMFIRST"; | |
3651 | case 0x05FF: return "WM_MMPMLAST"; | |
3652 | case 0x0600: return "WM_STDDLGFIRST"; | |
3653 | case 0x06FF: return "WM_STDDLGLAST"; | |
3654 | case 0x0BD0: return "WM_BIDI_FIRST"; | |
3655 | case 0x0BFF: return "WM_BIDI_LAST"; | |
3656 | // keyboard input | |
3657 | case 0x007A: return "WM_CHAR"; | |
3658 | case 0x007B: return "WM_VIOCHAR"; | |
3659 | // DDE messages | |
3660 | case 0x00A0: return "WM_DDE_INITIATE"; | |
3661 | case 0x00A1: return "WM_DDE_REQUEST"; | |
3662 | case 0x00A2: return "WM_DDE_ACK"; | |
3663 | case 0x00A3: return "WM_DDE_DATA"; | |
3664 | case 0x00A4: return "WM_DDE_ADVISE"; | |
3665 | case 0x00A5: return "WM_DDE_UNADVISE"; | |
3666 | case 0x00A6: return "WM_DDE_POKE"; | |
3667 | case 0x00A7: return "WM_DDE_EXECUTE"; | |
3668 | case 0x00A8: return "WM_DDE_TERMINATE"; | |
3669 | case 0x00A9: return "WM_DDE_INITIATEACK"; | |
3670 | case 0x00AF: return "WM_DDE_LAST"; | |
3671 | // Buttons | |
3672 | case 0x0120: return "BM_CLICK"; | |
3673 | case 0x0121: return "BM_QUERYCHECKINDEX"; | |
3674 | case 0x0122: return "BM_QUERYHILITE"; | |
3675 | case 0x0123: return "BM_SETHILITE"; | |
3676 | case 0x0124: return "BM_QUERYCHECK"; | |
3677 | case 0x0125: return "BM_SETCHECK"; | |
3678 | case 0x0126: return "BM_SETDEFAULT"; | |
3679 | case 0x0128: return "BM_AUTOSIZE"; | |
3680 | // Combo boxes | |
3681 | case 0x029A: return "CBID_LIST"; | |
3682 | case 0x029B: return "CBID_EDIT"; | |
3683 | case 0x0170: return "CBM_SHOWLIST"; | |
3684 | case 0x0171: return "CBM_HILITE"; | |
3685 | case 0x0172: return "CBM_ISLISTSHOWING"; | |
3686 | // Edit fields | |
3687 | case 0x0140: return "EM_QUERYCHANGED"; | |
3688 | case 0x0141: return "EM_QUERYSEL"; | |
3689 | case 0x0142: return "EM_SETSEL"; | |
3690 | case 0x0143: return "EM_SETTEXTLIMIT"; | |
3691 | case 0x0144: return "EM_CUT"; | |
3692 | case 0x0145: return "EM_COPY"; | |
3693 | case 0x0146: return "EM_CLEAR"; | |
3694 | case 0x0147: return "EM_PASTE"; | |
3695 | case 0x0148: return "EM_QUERYFIRSTCHAR"; | |
3696 | case 0x0149: return "EM_SETFIRSTCHAR"; | |
3697 | case 0x014A: return "EM_QUERYREADONLY"; | |
3698 | case 0x014B: return "EM_SETREADONLY"; | |
3699 | case 0x014C: return "EM_SETINSERTMODE"; | |
3700 | // Listboxes | |
3701 | case 0x0160: return "LM_QUERYITEMCOUNT"; | |
3702 | case 0x0161: return "LM_INSERTITEM"; | |
3703 | case 0x0162: return "LM_SETOPENINDEX"; | |
3704 | case 0x0163: return "LM_DELETEITEM"; | |
3705 | case 0x0164: return "LM_SELECTITEM"; | |
3706 | case 0x0165: return "LM_QUERYSELECTION"; | |
3707 | case 0x0166: return "LM_SETITEMTEXT"; | |
3708 | case 0x0167: return "LM_QUERYITEMTEXTLENGTH"; | |
3709 | case 0x0168: return "LM_QUERYITEMTEXT"; | |
3710 | case 0x0169: return "LM_SETITEMHANDLE"; | |
3711 | case 0x016A: return "LM_QUERYITEMHANDLE"; | |
3712 | case 0x016B: return "LM_SEARCHSTRING"; | |
3713 | case 0x016C: return "LM_SETITEMHEIGHT"; | |
3714 | case 0x016D: return "LM_QUERYTOPINDEX"; | |
3715 | case 0x016E: return "LM_DELETEALL"; | |
3716 | case 0x016F: return "LM_INSERTMULITEMS"; | |
3717 | case 0x0660: return "LM_SETITEMWIDTH"; | |
3718 | // Menus | |
3719 | case 0x0180: return "MM_INSERTITEM"; | |
3720 | case 0x0181: return "MM_DELETEITEM"; | |
3721 | case 0x0182: return "MM_QUERYITEM"; | |
3722 | case 0x0183: return "MM_SETITEM"; | |
3723 | case 0x0184: return "MM_QUERYITEMCOUNT"; | |
3724 | case 0x0185: return "MM_STARTMENUMODE"; | |
3725 | case 0x0186: return "MM_ENDMENUMODE"; | |
3726 | case 0x0188: return "MM_REMOVEITEM"; | |
3727 | case 0x0189: return "MM_SELECTITEM"; | |
3728 | case 0x018A: return "MM_QUERYSELITEMID"; | |
3729 | case 0x018B: return "MM_QUERYITEMTEXT"; | |
3730 | case 0x018C: return "MM_QUERYITEMTEXTLENGTH"; | |
3731 | case 0x018D: return "MM_SETITEMHANDLE"; | |
3732 | case 0x018E: return "MM_SETITEMTEXT"; | |
3733 | case 0x018F: return "MM_ITEMPOSITIONFROMID"; | |
3734 | case 0x0190: return "MM_ITEMIDFROMPOSITION"; | |
3735 | case 0x0191: return "MM_QUERYITEMATTR"; | |
3736 | case 0x0192: return "MM_SETITEMATTR"; | |
3737 | case 0x0193: return "MM_ISITEMVALID"; | |
3738 | case 0x0194: return "MM_QUERYITEMRECT"; | |
3739 | case 0x0431: return "MM_QUERYDEFAULTITEMID"; | |
3740 | case 0x0432: return "MM_SETDEFAULTITEMID"; | |
3741 | // Scrollbars | |
3742 | case 0x01A0: return "SBM_SETSCROLLBAR"; | |
3743 | case 0x01A1: return "SBM_SETPOS"; | |
3744 | case 0x01A2: return "SBM_QUERYPOS"; | |
3745 | case 0x01A3: return "SBM_QUERYRANGE"; | |
3746 | case 0x01A6: return "SBM_SETTHUMBSIZE"; | |
3747 | ||
3748 | // Help messages | |
3749 | case 0x0F00: return "WM_HELPBASE"; | |
3750 | case 0x0FFF: return "WM_HELPTOP"; | |
3751 | // Beginning of user defined messages | |
3752 | case 0x1000: return "WM_USER"; | |
3753 | ||
3754 | // wxWindows user defined types | |
3755 | ||
3756 | // listview | |
3757 | // case 0x1000 + 0: return "LVM_GETBKCOLOR"; | |
3758 | case 0x1000 + 1: return "LVM_SETBKCOLOR"; | |
3759 | case 0x1000 + 2: return "LVM_GETIMAGELIST"; | |
3760 | case 0x1000 + 3: return "LVM_SETIMAGELIST"; | |
3761 | case 0x1000 + 4: return "LVM_GETITEMCOUNT"; | |
3762 | case 0x1000 + 5: return "LVM_GETITEMA"; | |
3763 | case 0x1000 + 75: return "LVM_GETITEMW"; | |
3764 | case 0x1000 + 6: return "LVM_SETITEMA"; | |
3765 | case 0x1000 + 76: return "LVM_SETITEMW"; | |
3766 | case 0x1000 + 7: return "LVM_INSERTITEMA"; | |
3767 | case 0x1000 + 77: return "LVM_INSERTITEMW"; | |
3768 | case 0x1000 + 8: return "LVM_DELETEITEM"; | |
3769 | case 0x1000 + 9: return "LVM_DELETEALLITEMS"; | |
3770 | case 0x1000 + 10: return "LVM_GETCALLBACKMASK"; | |
3771 | case 0x1000 + 11: return "LVM_SETCALLBACKMASK"; | |
3772 | case 0x1000 + 12: return "LVM_GETNEXTITEM"; | |
3773 | case 0x1000 + 13: return "LVM_FINDITEMA"; | |
3774 | case 0x1000 + 83: return "LVM_FINDITEMW"; | |
3775 | case 0x1000 + 14: return "LVM_GETITEMRECT"; | |
3776 | case 0x1000 + 15: return "LVM_SETITEMPOSITION"; | |
3777 | case 0x1000 + 16: return "LVM_GETITEMPOSITION"; | |
3778 | case 0x1000 + 17: return "LVM_GETSTRINGWIDTHA"; | |
3779 | case 0x1000 + 87: return "LVM_GETSTRINGWIDTHW"; | |
3780 | case 0x1000 + 18: return "LVM_HITTEST"; | |
3781 | case 0x1000 + 19: return "LVM_ENSUREVISIBLE"; | |
3782 | case 0x1000 + 20: return "LVM_SCROLL"; | |
3783 | case 0x1000 + 21: return "LVM_REDRAWITEMS"; | |
3784 | case 0x1000 + 22: return "LVM_ARRANGE"; | |
3785 | case 0x1000 + 23: return "LVM_EDITLABELA"; | |
3786 | case 0x1000 + 118: return "LVM_EDITLABELW"; | |
3787 | case 0x1000 + 24: return "LVM_GETEDITCONTROL"; | |
3788 | case 0x1000 + 25: return "LVM_GETCOLUMNA"; | |
3789 | case 0x1000 + 95: return "LVM_GETCOLUMNW"; | |
3790 | case 0x1000 + 26: return "LVM_SETCOLUMNA"; | |
3791 | case 0x1000 + 96: return "LVM_SETCOLUMNW"; | |
3792 | case 0x1000 + 27: return "LVM_INSERTCOLUMNA"; | |
3793 | case 0x1000 + 97: return "LVM_INSERTCOLUMNW"; | |
3794 | case 0x1000 + 28: return "LVM_DELETECOLUMN"; | |
3795 | case 0x1000 + 29: return "LVM_GETCOLUMNWIDTH"; | |
3796 | case 0x1000 + 30: return "LVM_SETCOLUMNWIDTH"; | |
3797 | case 0x1000 + 31: return "LVM_GETHEADER"; | |
3798 | case 0x1000 + 33: return "LVM_CREATEDRAGIMAGE"; | |
3799 | case 0x1000 + 34: return "LVM_GETVIEWRECT"; | |
3800 | case 0x1000 + 35: return "LVM_GETTEXTCOLOR"; | |
3801 | case 0x1000 + 36: return "LVM_SETTEXTCOLOR"; | |
3802 | case 0x1000 + 37: return "LVM_GETTEXTBKCOLOR"; | |
3803 | case 0x1000 + 38: return "LVM_SETTEXTBKCOLOR"; | |
3804 | case 0x1000 + 39: return "LVM_GETTOPINDEX"; | |
3805 | case 0x1000 + 40: return "LVM_GETCOUNTPERPAGE"; | |
3806 | case 0x1000 + 41: return "LVM_GETORIGIN"; | |
3807 | case 0x1000 + 42: return "LVM_UPDATE"; | |
3808 | case 0x1000 + 43: return "LVM_SETITEMSTATE"; | |
3809 | case 0x1000 + 44: return "LVM_GETITEMSTATE"; | |
3810 | case 0x1000 + 45: return "LVM_GETITEMTEXTA"; | |
3811 | case 0x1000 + 115: return "LVM_GETITEMTEXTW"; | |
3812 | case 0x1000 + 46: return "LVM_SETITEMTEXTA"; | |
3813 | case 0x1000 + 116: return "LVM_SETITEMTEXTW"; | |
3814 | case 0x1000 + 47: return "LVM_SETITEMCOUNT"; | |
3815 | case 0x1000 + 48: return "LVM_SORTITEMS"; | |
3816 | case 0x1000 + 49: return "LVM_SETITEMPOSITION32"; | |
3817 | case 0x1000 + 50: return "LVM_GETSELECTEDCOUNT"; | |
3818 | case 0x1000 + 51: return "LVM_GETITEMSPACING"; | |
3819 | case 0x1000 + 52: return "LVM_GETISEARCHSTRINGA"; | |
3820 | case 0x1000 + 117: return "LVM_GETISEARCHSTRINGW"; | |
3821 | case 0x1000 + 53: return "LVM_SETICONSPACING"; | |
3822 | case 0x1000 + 54: return "LVM_SETEXTENDEDLISTVIEWSTYLE"; | |
3823 | case 0x1000 + 55: return "LVM_GETEXTENDEDLISTVIEWSTYLE"; | |
3824 | case 0x1000 + 56: return "LVM_GETSUBITEMRECT"; | |
3825 | case 0x1000 + 57: return "LVM_SUBITEMHITTEST"; | |
3826 | case 0x1000 + 58: return "LVM_SETCOLUMNORDERARRAY"; | |
3827 | case 0x1000 + 59: return "LVM_GETCOLUMNORDERARRAY"; | |
3828 | case 0x1000 + 60: return "LVM_SETHOTITEM"; | |
3829 | case 0x1000 + 61: return "LVM_GETHOTITEM"; | |
3830 | case 0x1000 + 62: return "LVM_SETHOTCURSOR"; | |
3831 | case 0x1000 + 63: return "LVM_GETHOTCURSOR"; | |
3832 | case 0x1000 + 64: return "LVM_APPROXIMATEVIEWRECT"; | |
3833 | case 0x1000 + 65: return "LVM_SETWORKAREA"; | |
3834 | ||
3835 | // tree view | |
3836 | case 0x1100 + 0: return "TVM_INSERTITEMA"; | |
3837 | case 0x1100 + 50: return "TVM_INSERTITEMW"; | |
3838 | case 0x1100 + 1: return "TVM_DELETEITEM"; | |
3839 | case 0x1100 + 2: return "TVM_EXPAND"; | |
3840 | case 0x1100 + 4: return "TVM_GETITEMRECT"; | |
3841 | case 0x1100 + 5: return "TVM_GETCOUNT"; | |
3842 | case 0x1100 + 6: return "TVM_GETINDENT"; | |
3843 | case 0x1100 + 7: return "TVM_SETINDENT"; | |
3844 | case 0x1100 + 8: return "TVM_GETIMAGELIST"; | |
3845 | case 0x1100 + 9: return "TVM_SETIMAGELIST"; | |
3846 | case 0x1100 + 10: return "TVM_GETNEXTITEM"; | |
3847 | case 0x1100 + 11: return "TVM_SELECTITEM"; | |
3848 | case 0x1100 + 12: return "TVM_GETITEMA"; | |
3849 | case 0x1100 + 62: return "TVM_GETITEMW"; | |
3850 | case 0x1100 + 13: return "TVM_SETITEMA"; | |
3851 | case 0x1100 + 63: return "TVM_SETITEMW"; | |
3852 | case 0x1100 + 14: return "TVM_EDITLABELA"; | |
3853 | case 0x1100 + 65: return "TVM_EDITLABELW"; | |
3854 | case 0x1100 + 15: return "TVM_GETEDITCONTROL"; | |
3855 | case 0x1100 + 16: return "TVM_GETVISIBLECOUNT"; | |
3856 | case 0x1100 + 17: return "TVM_HITTEST"; | |
3857 | case 0x1100 + 18: return "TVM_CREATEDRAGIMAGE"; | |
3858 | case 0x1100 + 19: return "TVM_SORTCHILDREN"; | |
3859 | case 0x1100 + 20: return "TVM_ENSUREVISIBLE"; | |
3860 | case 0x1100 + 21: return "TVM_SORTCHILDRENCB"; | |
3861 | case 0x1100 + 22: return "TVM_ENDEDITLABELNOW"; | |
3862 | case 0x1100 + 23: return "TVM_GETISEARCHSTRINGA"; | |
3863 | case 0x1100 + 64: return "TVM_GETISEARCHSTRINGW"; | |
3864 | case 0x1100 + 24: return "TVM_SETTOOLTIPS"; | |
3865 | case 0x1100 + 25: return "TVM_GETTOOLTIPS"; | |
3866 | ||
3867 | // header | |
3868 | case 0x1200 + 0: return "HDM_GETITEMCOUNT"; | |
3869 | case 0x1200 + 1: return "HDM_INSERTITEMA"; | |
3870 | case 0x1200 + 10: return "HDM_INSERTITEMW"; | |
3871 | case 0x1200 + 2: return "HDM_DELETEITEM"; | |
3872 | case 0x1200 + 3: return "HDM_GETITEMA"; | |
3873 | case 0x1200 + 11: return "HDM_GETITEMW"; | |
3874 | case 0x1200 + 4: return "HDM_SETITEMA"; | |
3875 | case 0x1200 + 12: return "HDM_SETITEMW"; | |
3876 | case 0x1200 + 5: return "HDM_LAYOUT"; | |
3877 | case 0x1200 + 6: return "HDM_HITTEST"; | |
3878 | case 0x1200 + 7: return "HDM_GETITEMRECT"; | |
3879 | case 0x1200 + 8: return "HDM_SETIMAGELIST"; | |
3880 | case 0x1200 + 9: return "HDM_GETIMAGELIST"; | |
3881 | case 0x1200 + 15: return "HDM_ORDERTOINDEX"; | |
3882 | case 0x1200 + 16: return "HDM_CREATEDRAGIMAGE"; | |
3883 | case 0x1200 + 17: return "HDM_GETORDERARRAY"; | |
3884 | case 0x1200 + 18: return "HDM_SETORDERARRAY"; | |
3885 | case 0x1200 + 19: return "HDM_SETHOTDIVIDER"; | |
3886 | ||
3887 | // tab control | |
3888 | case 0x1300 + 2: return "TCM_GETIMAGELIST"; | |
3889 | case 0x1300 + 3: return "TCM_SETIMAGELIST"; | |
3890 | case 0x1300 + 4: return "TCM_GETITEMCOUNT"; | |
3891 | case 0x1300 + 5: return "TCM_GETITEMA"; | |
3892 | case 0x1300 + 60: return "TCM_GETITEMW"; | |
3893 | case 0x1300 + 6: return "TCM_SETITEMA"; | |
3894 | case 0x1300 + 61: return "TCM_SETITEMW"; | |
3895 | case 0x1300 + 7: return "TCM_INSERTITEMA"; | |
3896 | case 0x1300 + 62: return "TCM_INSERTITEMW"; | |
3897 | case 0x1300 + 8: return "TCM_DELETEITEM"; | |
3898 | case 0x1300 + 9: return "TCM_DELETEALLITEMS"; | |
3899 | case 0x1300 + 10: return "TCM_GETITEMRECT"; | |
3900 | case 0x1300 + 11: return "TCM_GETCURSEL"; | |
3901 | case 0x1300 + 12: return "TCM_SETCURSEL"; | |
3902 | case 0x1300 + 13: return "TCM_HITTEST"; | |
3903 | case 0x1300 + 14: return "TCM_SETITEMEXTRA"; | |
3904 | case 0x1300 + 40: return "TCM_ADJUSTRECT"; | |
3905 | case 0x1300 + 41: return "TCM_SETITEMSIZE"; | |
3906 | case 0x1300 + 42: return "TCM_REMOVEIMAGE"; | |
3907 | case 0x1300 + 43: return "TCM_SETPADDING"; | |
3908 | case 0x1300 + 44: return "TCM_GETROWCOUNT"; | |
3909 | case 0x1300 + 45: return "TCM_GETTOOLTIPS"; | |
3910 | case 0x1300 + 46: return "TCM_SETTOOLTIPS"; | |
3911 | case 0x1300 + 47: return "TCM_GETCURFOCUS"; | |
3912 | case 0x1300 + 48: return "TCM_SETCURFOCUS"; | |
3913 | case 0x1300 + 49: return "TCM_SETMINTABWIDTH"; | |
3914 | case 0x1300 + 50: return "TCM_DESELECTALL"; | |
3915 | ||
3916 | // toolbar | |
3917 | case WM_USER+1000+1: return "TB_ENABLEBUTTON"; | |
3918 | case WM_USER+1000+2: return "TB_CHECKBUTTON"; | |
3919 | case WM_USER+1000+3: return "TB_PRESSBUTTON"; | |
3920 | case WM_USER+1000+4: return "TB_HIDEBUTTON"; | |
3921 | case WM_USER+1000+5: return "TB_INDETERMINATE"; | |
3922 | case WM_USER+1000+9: return "TB_ISBUTTONENABLED"; | |
3923 | case WM_USER+1000+10: return "TB_ISBUTTONCHECKED"; | |
3924 | case WM_USER+1000+11: return "TB_ISBUTTONPRESSED"; | |
3925 | case WM_USER+1000+12: return "TB_ISBUTTONHIDDEN"; | |
3926 | case WM_USER+1000+13: return "TB_ISBUTTONINDETERMINATE"; | |
3927 | case WM_USER+1000+17: return "TB_SETSTATE"; | |
3928 | case WM_USER+1000+18: return "TB_GETSTATE"; | |
3929 | case WM_USER+1000+19: return "TB_ADDBITMAP"; | |
3930 | case WM_USER+1000+20: return "TB_ADDBUTTONS"; | |
3931 | case WM_USER+1000+21: return "TB_INSERTBUTTON"; | |
3932 | case WM_USER+1000+22: return "TB_DELETEBUTTON"; | |
3933 | case WM_USER+1000+23: return "TB_GETBUTTON"; | |
3934 | case WM_USER+1000+24: return "TB_BUTTONCOUNT"; | |
3935 | case WM_USER+1000+25: return "TB_COMMANDTOINDEX"; | |
3936 | case WM_USER+1000+26: return "TB_SAVERESTOREA"; | |
3937 | case WM_USER+1000+76: return "TB_SAVERESTOREW"; | |
3938 | case WM_USER+1000+27: return "TB_CUSTOMIZE"; | |
3939 | case WM_USER+1000+28: return "TB_ADDSTRINGA"; | |
3940 | case WM_USER+1000+77: return "TB_ADDSTRINGW"; | |
3941 | case WM_USER+1000+29: return "TB_GETITEMRECT"; | |
3942 | case WM_USER+1000+30: return "TB_BUTTONSTRUCTSIZE"; | |
3943 | case WM_USER+1000+31: return "TB_SETBUTTONSIZE"; | |
3944 | case WM_USER+1000+32: return "TB_SETBITMAPSIZE"; | |
3945 | case WM_USER+1000+33: return "TB_AUTOSIZE"; | |
3946 | case WM_USER+1000+35: return "TB_GETTOOLTIPS"; | |
3947 | case WM_USER+1000+36: return "TB_SETTOOLTIPS"; | |
3948 | case WM_USER+1000+37: return "TB_SETPARENT"; | |
3949 | case WM_USER+1000+39: return "TB_SETROWS"; | |
3950 | case WM_USER+1000+40: return "TB_GETROWS"; | |
3951 | case WM_USER+1000+42: return "TB_SETCMDID"; | |
3952 | case WM_USER+1000+43: return "TB_CHANGEBITMAP"; | |
3953 | case WM_USER+1000+44: return "TB_GETBITMAP"; | |
3954 | case WM_USER+1000+45: return "TB_GETBUTTONTEXTA"; | |
3955 | case WM_USER+1000+75: return "TB_GETBUTTONTEXTW"; | |
3956 | case WM_USER+1000+46: return "TB_REPLACEBITMAP"; | |
3957 | case WM_USER+1000+47: return "TB_SETINDENT"; | |
3958 | case WM_USER+1000+48: return "TB_SETIMAGELIST"; | |
3959 | case WM_USER+1000+49: return "TB_GETIMAGELIST"; | |
3960 | case WM_USER+1000+50: return "TB_LOADIMAGES"; | |
3961 | case WM_USER+1000+51: return "TB_GETRECT"; | |
3962 | case WM_USER+1000+52: return "TB_SETHOTIMAGELIST"; | |
3963 | case WM_USER+1000+53: return "TB_GETHOTIMAGELIST"; | |
3964 | case WM_USER+1000+54: return "TB_SETDISABLEDIMAGELIST"; | |
3965 | case WM_USER+1000+55: return "TB_GETDISABLEDIMAGELIST"; | |
3966 | case WM_USER+1000+56: return "TB_SETSTYLE"; | |
3967 | case WM_USER+1000+57: return "TB_GETSTYLE"; | |
3968 | case WM_USER+1000+58: return "TB_GETBUTTONSIZE"; | |
3969 | case WM_USER+1000+59: return "TB_SETBUTTONWIDTH"; | |
3970 | case WM_USER+1000+60: return "TB_SETMAXTEXTROWS"; | |
3971 | case WM_USER+1000+61: return "TB_GETTEXTROWS"; | |
3972 | case WM_USER+1000+41: return "TB_GETBITMAPFLAGS"; | |
3973 | ||
3974 | default: | |
3975 | static char s_szBuf[128]; | |
3976 | sprintf(s_szBuf, "<unknown message = %d>", nMessage); | |
3977 | return s_szBuf; | |
3978 | } | |
3979 | return NULL; | |
3980 | } // end of wxGetMessageName | |
3981 | ||
3982 | #endif // __WXDEBUG__ | |
3983 | ||
3984 | static void TranslateKbdEventToMouse( | |
3985 | wxWindow* pWin | |
3986 | , int* pX | |
3987 | , int* pY | |
3988 | , ULONG* pFlags | |
3989 | ) | |
3990 | { | |
3991 | // | |
3992 | // Construct the key mask | |
3993 | ULONG& fwKeys = *pFlags; | |
3994 | ||
3995 | fwKeys = VK_BUTTON2; | |
3996 | if ((::WinGetKeyState(HWND_DESKTOP, VK_CTRL) & 0x100) != 0) | |
3997 | fwKeys |= VK_CTRL; | |
3998 | if ((::WinGetKeyState(HWND_DESKTOP, VK_SHIFT) & 0x100) != 0) | |
3999 | fwKeys |= VK_SHIFT; | |
4000 | ||
4001 | // | |
4002 | // Simulate right mouse button click | |
4003 | // | |
4004 | POINTL vPoint; | |
4005 | ||
4006 | ::WinQueryMsgPos(vHabmain, &vPoint); | |
4007 | *pX = vPoint.x; | |
4008 | *pY = vPoint.y; | |
4009 | ||
4010 | pWin->ScreenToClient(pX, pY); | |
4011 | } // end of TranslateKbdEventToMouse | |
4012 | ||
4013 | // Find the wxWindow at the current mouse position, returning the mouse | |
4014 | // position. | |
4015 | wxWindow* wxFindWindowAtPointer( | |
4016 | wxPoint& rPt | |
4017 | ) | |
4018 | { | |
4019 | return wxFindWindowAtPoint(wxGetMousePosition()); | |
4020 | } | |
4021 | ||
4022 | wxWindow* wxFindWindowAtPoint( | |
4023 | const wxPoint& rPt | |
4024 | ) | |
4025 | { | |
4026 | POINTL vPt2; | |
4027 | ||
4028 | vPt2.x = rPt.x; | |
4029 | vPt2.y = rPt.y; | |
4030 | ||
4031 | HWND hWndHit = ::WinWindowFromPoint(HWND_DESKTOP, &vPt2, FALSE); | |
4032 | wxWindow* pWin = wxFindWinFromHandle((WXHWND)hWndHit) ; | |
4033 | HWND hWnd = hWndHit; | |
4034 | ||
4035 | // | |
4036 | // Try to find a window with a wxWindow associated with it | |
4037 | // | |
4038 | while (!pWin && (hWnd != 0)) | |
4039 | { | |
4040 | hWnd = ::WinQueryWindow(hWnd, QW_PARENT); | |
4041 | pWin = wxFindWinFromHandle((WXHWND)hWnd) ; | |
4042 | } | |
4043 | return pWin; | |
4044 | } | |
4045 | ||
4046 | // Get the current mouse position. | |
4047 | wxPoint wxGetMousePosition() | |
4048 | { | |
4049 | POINTL vPt; | |
4050 | ||
4051 | ::WinQueryPointerPos(HWND_DESKTOP, &vPt); | |
4052 | return wxPoint(vPt.x, vPt.y); | |
4053 | } | |
4054 |