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