]> git.saurik.com Git - wxWidgets.git/blob - src/os2/window.cpp
More wxWindow updates
[wxWidgets.git] / src / os2 / window.cpp
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 // ---------------------------------------------------------------------------
88 // global variables
89 // ---------------------------------------------------------------------------
90
91 //
92 // The last Windows message we got (MT-UNSAFE)
93 //
94 extern WXMSGID s_currentMsg;
95
96 wxMenu* wxCurrentPopupMenu = NULL;
97 extern wxList WXDLLEXPORT wxPendingDelete;
98 extern wxChar* wxCanvasClassName;
99 wxList* wxWinHandleList = NULL;
100
101 // ---------------------------------------------------------------------------
102 // private functions
103 // ---------------------------------------------------------------------------
104
105 //
106 // the window proc for all our windows; most gui's have something similar
107 //
108 MRESULT wxWndProc( HWND hWnd
109 ,ULONG message
110 ,MPARAM mp1
111 ,MPARAM mp2
112 );
113
114 #ifdef __WXDEBUG__
115 const char *wxGetMessageName(int message);
116 #endif //__WXDEBUG__
117
118 void wxRemoveHandleAssociation(wxWindow* pWin);
119 void wxAssociateWinWithHandle( HWND hWnd
120 ,wxWindow* pWin
121 );
122 wxWindow* wxFindWinFromHandle(WXHWND hWnd);
123
124 //
125 // This magical function is used to translate VK_APPS key presses to right
126 // mouse clicks
127 //
128 static void TranslateKbdEventToMouse( wxWindow* pWin
129 ,int* pX
130 ,int* pY
131 ,MPARAM* pFlags
132 );
133
134 //
135 // get the current state of SHIFT/CTRL keys
136 //
137 static inline bool IsShiftDown() { return (::WinGetKeyState(HWND_DESKTOP, VK_SHIFT) & 0x8000) != 0; }
138 static inline bool IsCtrlDown() { return (::WinGetKeyState(HWND_DESKTOP, VK_CTRL) & 0x8000) != 0; }
139 // ---------------------------------------------------------------------------
140 // event tables
141 // ---------------------------------------------------------------------------
142
143 IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxWindowBase)
144
145 BEGIN_EVENT_TABLE(wxWindow, wxWindowBase)
146 EVT_ERASE_BACKGROUND(wxWindow::OnEraseBackground)
147 EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged)
148 EVT_INIT_DIALOG(wxWindow::OnInitDialog)
149 EVT_IDLE(wxWindow::OnIdle)
150 END_EVENT_TABLE()
151
152 // ===========================================================================
153 // implementation
154 // ===========================================================================
155
156 //
157 // Find an item given the PM Window id
158 //
159 wxWindow* wxWindow::FindItem(
160 long lId
161 ) const
162 {
163 wxControl* pItem = wxDynamicCast( this
164 ,wxControl
165 );
166
167 if (pItem)
168 {
169 //
170 // I it we or one of our "internal" children?
171 //
172 if (pItem->GetId() == lId ||
173 (pItem->GetSubcontrols().Index(lId) != wxNOT_FOUND))
174 {
175 return pItem;
176 }
177 }
178
179 wxWindowList::Node* pCurrent = GetChildren().GetFirst();
180
181 while (pCurrent)
182 {
183 wxWindow* pChildWin = pCurrent->GetData();
184 wxWindow* pWnd = pChildWin->FindItem(lId);
185
186 if (pWnd)
187 return pWnd;
188
189 pCurrent = pCurrent->GetNext();
190 }
191 return(NULL);
192 } // end of wxWindow::FindItem
193
194 //
195 // Find an item given the PM Window handle
196 //
197 wxWindow* wxWindow::FindItemByHWND(
198 WXHWND hWnd
199 , bool bControlOnly
200 ) const
201 {
202 wxWindowList::Node* pCurrent = GetChildren().GetFirst();
203
204 while (pCurrent)
205 {
206 wxWindow* pParent = pCurrent->GetData();
207
208 //
209 // Do a recursive search.
210 //
211 wxWindow* pWnd = pParent->FindItemByHWND(hWnd);
212
213 if (pWnd)
214 return(pWnd);
215
216 if (!bControlOnly || pParent->IsKindOf(CLASSINFO(wxControl)))
217 {
218 wxWindow* pItem = pCurrent->GetData();
219
220 if (pItem->GetHWND() == hWnd)
221 return(pItem);
222 else
223 {
224 if (pItem->ContainsHWND(hWnd))
225 return(pItem);
226 }
227 }
228 pCurrent = pCurrent->GetNext();
229 }
230 return(NULL);
231 } // end of wxWindow::FindItemByHWND
232
233 //
234 // Default command handler
235 //
236 bool wxWindow::OS2Command(
237 WXUINT WXUNUSED(uParam)
238 , WXWORD WXUNUSED(uId)
239 )
240 {
241 return(FALSE);
242 }
243
244 // ----------------------------------------------------------------------------
245 // constructors and such
246 // ----------------------------------------------------------------------------
247
248 void wxWindow::Init()
249 {
250 //
251 // Generic
252 //
253 InitBase();
254
255 //
256 // PM specific
257 //
258 m_bDoubleClickAllowed = 0;
259 m_bWinCaptured = FALSE;
260
261 m_isBeingDeleted = FALSE;
262 m_fnOldWndProc = 0;
263 m_bUseCtl3D = FALSE;
264 m_bMouseInWindow = FALSE;
265
266 //
267 // wxWnd
268 //
269 m_hMenu = 0;
270 m_hWnd = 0;
271
272 //
273 // Pass WM_GETDLGCODE to DefWindowProc()
274 m_lDlgCode = 0;
275
276 m_nXThumbSize = 0;
277 m_nYThumbSize = 0;
278 m_bBackgroundTransparent = FALSE;
279
280 //
281 // As all windows are created with WS_VISIBLE style...
282 //
283 m_isShown = TRUE;
284
285 #if wxUSE_MOUSEEVENT_HACK
286 m_lLastMouseX =
287 m_lLastMouseY = -1;
288 m_nLastMouseEvent = -1;
289 #endif // wxUSE_MOUSEEVENT_HACK
290 } // wxWindow::Init
291
292 //
293 // Destructor
294 //
295 wxWindow::~wxWindow()
296 {
297 m_isBeingDeleted = TRUE;
298
299 OS2DetachWindowMenu();
300 if (m_parent)
301 m_parent->RemoveChild(this);
302 DestroyChildren();
303 if (m_hWnd)
304 {
305 if(!::WinDestroyWindow(GetHWND()))
306 wxLogLastError(wxT("DestroyWindow"));
307 //
308 // remove hWnd <-> wxWindow association
309 //
310 wxRemoveHandleAssociation(this);
311 }
312 } // end of wxWindow::~wxWindow
313
314 bool wxWindow::Create(
315 wxWindow* pParent
316 , wxWindowID vId
317 , const wxPoint& rPos
318 , const wxSize& rSize
319 , long lStyle
320 , const wxString& rName
321 )
322 {
323 wxCHECK_MSG(pParent, FALSE, wxT("can't create wxWindow without parent"));
324
325 if ( !CreateBase( pParent
326 ,vId
327 ,rPos
328 ,rSize
329 ,lStyle
330 ,wxDefaultValidator
331 ,rName
332 ))
333 return(FALSE);
334
335 pParent->AddChild(this);
336
337 ULONG ulFlags = 0L;
338
339 //
340 // Frame windows and their derivatives only
341 //
342 if (lStyle & wxBORDER)
343 ulFlags |= FCF_BORDER;
344 if (lStyle & wxTHICK_FRAME )
345 ulFlags |= FCF_SIZEBORDER;
346
347 //
348 // Some generic window styles
349 //
350 ulFlags |= WS_VISIBLE;
351 if (lStyle & wxCLIP_CHILDREN )
352 ulFlags |= WS_CLIPCHILDREN;
353
354 bool bWant3D;
355 WXDWORD dwExStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &bWant3D);
356
357 //
358 // OS/2 PM doesn't have "extended" styles but if the library specifies
359 // them and we are creating a frame window then at least give it a border
360 //
361 if ( bWant3D ||
362 (m_windowStyle & wxSIMPLE_BORDER) ||
363 (m_windowStyle & wxRAISED_BORDER ) ||
364 (m_windowStyle & wxSUNKEN_BORDER) ||
365 (m_windowStyle & wxDOUBLE_BORDER)
366 )
367 {
368 ulFlags |= FCF_BORDER;
369 }
370 OS2Create( m_windowId
371 ,pParent
372 ,wxCanvasClassName
373 ,this
374 ,NULL
375 ,rPos.x
376 ,rPos.y
377 ,WidthDefault(rSize.x)
378 ,HeightDefault(rSize.y)
379 ,ulFlags
380 ,NULL
381 ,dwExStyle
382 );
383 return(TRUE);
384 } // end of wxWindow::Create
385
386 // ---------------------------------------------------------------------------
387 // basic operations
388 // ---------------------------------------------------------------------------
389
390 void wxWindow::SetFocus()
391 {
392 HWND hWnd = GetHwnd();
393
394 if (hWnd)
395 ::WinSetFocus(HWND_DESKTOP, hWnd);
396 } // end of wxWindow::SetFocus
397
398 wxWindow* wxWindowBase::FindFocus()
399 {
400 HWND hWnd = ::WinQueryFocus(HWND_DESKTOP);
401
402 if (hWnd)
403 {
404 return wxFindWinFromHandle((WXHWND)hWnd);
405 }
406 return NULL;
407 } // wxWindowBase::FindFocus
408
409 bool wxWindow::Enable(
410 bool bEnable
411 )
412 {
413 if (!wxWindowBase::Enable(bEnable))
414 return(FALSE);
415
416 HWND hWnd = GetHwnd();
417
418 if ( hWnd )
419 ::WinEnableWindow(hWnd, (BOOL)bEnable);
420
421 wxWindowList::Node* pNode = GetChildren().GetFirst();
422
423 while (pNode)
424 {
425 wxWindow* pChild = pNode->GetData();
426
427 pChild->Enable(bEnable);
428 pNode = pNode->GetNext();
429 }
430 return(TRUE);
431 } // end of wxWindow::Enable
432
433 bool wxWindow::Show(
434 bool bShow
435 )
436 {
437 if (!wxWindowBase::Show(bShow))
438 return(FALSE);
439
440 HWND hWnd = GetHwnd();
441
442 ::WinShowWindow(hWnd, bShow);
443
444 if (bShow)
445 {
446 ::WinSetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE | SWP_ZORDER);
447 }
448 return(TRUE);
449 } // end of wxWindow::Show
450
451 void wxWindow::Raise()
452 {
453 ::WinSetWindowPos(GetHwnd(), HWND_TOP, 0, 0, 0, 0, SWP_ZORDER | SWP_ACTIVATE);
454 } // end of wxWindow::Raise
455
456 void wxWindow::Lower()
457 {
458 ::WinSetWindowPos(GetHwnd(), HWND_BOTTOM, 0, 0, 0, 0, SWP_ZORDER | SWP_DEACTIVATE);
459 } // end of wxWindow::Lower
460
461 void wxWindow::SetTitle(
462 const wxString& rTitle
463 )
464 {
465 ::WinSetWindowText(GetHwnd(), rTitle.c_str());
466 } // end of wxWindow::SetTitle
467
468 wxString wxWindow::GetTitle() const
469 {
470 return wxGetWindowText(GetHWND());
471 } // end of wxWindow::GetTitle
472
473 void wxWindow::CaptureMouse()
474 {
475 HWND hWnd = GetHwnd();
476
477 if (hWnd && !m_bWinCaptured)
478 {
479 ::WinSetCapture(HWND_DESKTOP, hWnd);
480 m_bWinCaptured = TRUE;
481 }
482 } // end of wxWindow::GetTitle
483
484 void wxWindow::ReleaseMouse()
485 {
486 if (m_bWinCaptured)
487 {
488 ::WinSetCapture(HWND_DESKTOP, NULLHANDLE);
489 m_bWinCaptured = FALSE;
490 }
491 } // end of wxWindow::ReleaseMouse
492
493 bool wxWindow::SetFont(
494 const wxFont& rFont
495 )
496 {
497 if (!wxWindowBase::SetFont(rFont))
498 {
499 // nothing to do
500 return(FALSE);
501 }
502
503 HWND hWnd = GetHwnd();
504
505 if (hWnd != 0)
506 {
507 wxChar zFont[128];
508
509 sprintf(zFont, "%d.%s", rFont.GetPointSize(), rFont.GetFaceName().c_str());
510 return(::WinSetPresParam(hWnd, PP_FONTNAMESIZE, strlen(zFont), (PVOID)zFont));
511 }
512 return(TRUE);
513 }
514
515 bool wxWindow::SetCursor(
516 const wxCursor& rCursor
517 ) // check if base implementation is OK
518 {
519 if ( !wxWindowBase::SetCursor(rCursor))
520 {
521 // no change
522 return FALSE;
523 }
524
525 wxASSERT_MSG( m_cursor.Ok(),
526 wxT("cursor must be valid after call to the base version"));
527
528 HWND hWnd = GetHwnd();
529 POINTL vPoint;
530 RECTL vRect;
531 HPS hPS;
532 HRGN hRGN;
533
534 hPS = ::WinGetPS(hWnd);
535
536 ::WinQueryPointerPos(HWND_DESKTOP, &vPoint);
537 ::WinQueryWindowRect(hWnd, &vRect);
538
539 hRGN = ::GpiCreateRegion(hPS, 1L, &vRect);
540
541 if ((::GpiPtInRegion(hPS, hRGN, &vPoint) == PRGN_INSIDE) && !wxIsBusy())
542 {
543 ::WinSetPointer(HWND_DESKTOP, (HPOINTER)m_cursor.GetHCURSOR());
544 }
545 return TRUE;
546 } // end of wxWindow::SetCursor
547
548 void wxWindow::WarpPointer(
549 int nXPos
550 , int nYPos
551 )
552 {
553 int nX = nXPos;
554 int nY = nYPos;
555 RECTL vRect;
556
557 ::WinQueryWindowRect(GetHwnd(), &vRect);
558 nX += vRect.xLeft;
559 nY += vRect.yBottom;
560
561 ::WinSetPointerPos(HWND_DESKTOP, (LONG)nX, (LONG)(nY));
562 } // end of wxWindow::WarpPointer
563
564 #if WXWIN_COMPATIBILITY
565 void wxWindow::OS2DeviceToLogical (float *x, float *y) const
566 {
567 }
568 #endif // WXWIN_COMPATIBILITY
569
570 // ---------------------------------------------------------------------------
571 // scrolling stuff
572 // ---------------------------------------------------------------------------
573
574 #if WXWIN_COMPATIBILITY
575 void wxWindow::SetScrollRange(
576 int nOrient
577 , int nRange
578 , bool bRefresh
579 )
580 {
581 ::WinSendMsg(GetHwnd(), SBM_SETSCROLLBAR, (MPARAM)0, MPFROM2SHORT(0, nRange));
582 } // end of wxWindow::SetScrollRange
583
584 void wxWindow::SetScrollPage(
585 int nOrient
586 , int nPage
587 , bool bRefresh
588 )
589 {
590 if ( orient == wxHORIZONTAL )
591 m_xThumbSize = page;
592 else
593 m_yThumbSize = page;
594 }
595
596 int wxWindow::OldGetScrollRange(
597 int nOrient
598 ) const
599 {
600 MRESULT mRc;
601 HWND hWnd = GetHwnd();
602
603 if (hWnd)
604 {
605 mRc = WinSendMsg(hWnd, SBM_QUERYRANGE, (MPARAM)0L, (MPARAM)0L);
606 return(SHORT2FROMMR(mRc));
607 }
608 return 0;
609 } // end of wxWindow::OldGetScrollRange
610
611 int wxWindow::GetScrollPage(
612 int nOrient
613 ) const
614 {
615 if (nOrient == wxHORIZONTAL)
616 return m_nXThumbSize;
617 else
618 return m_nYThumbSize;
619 } // end of wxWindow::GetScrollPage
620 #endif // WXWIN_COMPATIBILITY
621
622 int wxWindow::GetScrollPos(
623 int nOrient
624 ) const
625 {
626 return((int)::WinSendMsg(GetHwnd(), SBM_QUERYPOS, (MPARAM)NULL, (MPARAM)NULL));
627 } // end of wxWindow::GetScrollPos
628
629 int wxWindow::GetScrollRange(
630 int nOrient
631 ) const
632 {
633 MRESULT mr;
634
635 mr = ::WinSendMsg(GetHwnd(), SBM_QUERYRANGE, (MPARAM)NULL, (MPARAM)NULL);
636 return((int)SHORT2FROMMR(mr));
637 } // end of wxWindow::GetScrollRange
638
639 int wxWindow::GetScrollThumb(
640 int nOrient
641 ) const
642 {
643 WNDPARAMS vWndParams;
644 PSBCDATA pSbcd;
645
646 ::WinSendMsg(GetHwnd(), WM_QUERYWINDOWPARAMS, (MPARAM)&vWndParams, (MPARAM)NULL);
647 pSbcd = (PSBCDATA)vWndParams.pCtlData;
648 return((int)pSbcd->posThumb);
649 } // end of wxWindow::GetScrollThumb
650
651 void wxWindow::SetScrollPos(
652 int nOrient
653 , int nPos
654 , bool bRefresh
655 )
656 {
657 ::WinSendMsg(GetHwnd(), SBM_SETPOS, (MPARAM)nPos, (MPARAM)NULL);
658 } // end of wxWindow::SetScrollPos(
659
660 void wxWindow::SetScrollbar(
661 int nOrient
662 , int nPos
663 , int nThumbVisible
664 , int nRange
665 , bool bRefresh
666 )
667 {
668 ::WinSendMsg(GetHwnd(), SBM_SETSCROLLBAR, (MPARAM)nPos, MPFROM2SHORT(0, nRange));
669 if (nOrient == wxHORIZONTAL)
670 {
671 m_nXThumbSize = nThumbVisible;
672 }
673 else
674 {
675 m_nYThumbSize = nThumbVisible;
676 }
677 } // end of wxWindow::SetScrollbar
678
679 void wxWindow::ScrollWindow(
680 int nDx
681 , int nDy
682 , const wxRect* pRect
683 )
684 {
685 RECTL vRect2;
686
687 if (pRect)
688 {
689 vRect2.xLeft = pRect->x;
690 vRect2.yTop = pRect->y;
691 vRect2.xRight = pRect->x + pRect->width;
692 vRect2.yBottom = pRect->y + pRect->height;
693 }
694
695 if (pRect)
696 ::WinScrollWindow(GetHwnd(), (LONG)nDx, (LONG)nDy, &vRect2, NULL, NULLHANDLE, NULL, 0L);
697 else
698 ::WinScrollWindow(GetHwnd(), nDx, nDy, NULL, NULL, NULLHANDLE, NULL, 0L);
699 } // end of wxWindow::ScrollWindow
700
701 // ---------------------------------------------------------------------------
702 // subclassing
703 // ---------------------------------------------------------------------------
704
705 void wxWindow::SubclassWin(
706 WXHWND hWnd
707 )
708 {
709 HAB hab;
710 HWND hwnd = (HWND)hWnd;
711
712 wxASSERT_MSG( !m_fnOldWndProc, wxT("subclassing window twice?") );
713
714 wxCHECK_RET(::WinIsWindow(hab, hwnd), wxT("invalid HWND in SubclassWin") );
715
716 wxAssociateWinWithHandle(hwnd, this);
717
718 m_fnOldWndProc = (WXFARPROC) ::WinSubclassWindow(hwnd, wxWndProc);
719 ::WinSetWindowULong(hwnd, QWS_USER, wxWndProc);
720 } // end of wxWindow::SubclassWin
721
722 void wxWindow::UnsubclassWin()
723 {
724 HAB hab;
725
726 wxRemoveHandleAssociation(this);
727
728 //
729 // Restore old Window proc
730 //
731 HWND hwnd = GetHwnd();
732
733 if (hwnd)
734 {
735 m_hWnd = 0;
736
737 wxCHECK_RET( ::WinIsWindow(hab, hwnd), wxT("invalid HWND in UnsubclassWin") );
738
739 PFNWP fnProc = (PFNWP)::WinQueryWindowULong(hwnd, QWS_USER);
740 if ( (m_fnOldWndProc != 0) && (fnProc != (PFNWP) m_fnOldWndProc))
741 {
742 WinSubclassWindow(hwnd, (PFNWP)m_fnOldWndProc);
743 m_fnOldWndProc = 0;
744 }
745 }
746 } // end of wxWindow::UnsubclassWin
747
748 //
749 // Make a Windows extended style from the given wxWindows window style
750 //
751 WXDWORD wxWindow::MakeExtendedStyle(
752 long lStyle
753 , bool bEliminateBorders
754 )
755 {
756 //
757 // PM does not support extended style
758 //
759 WXDWORD exStyle = 0;
760 return exStyle;
761 } // end of wxWindow::MakeExtendedStyle
762
763 //
764 // Determines whether native 3D effects or CTL3D should be used,
765 // applying a default border style if required, and returning an extended
766 // style to pass to CreateWindowEx.
767 //
768 WXDWORD wxWindow::Determine3DEffects(
769 WXDWORD dwDefaultBorderStyle
770 , YBool* pbWant3D
771 ) const
772 {
773 WXDWORD dwStyle = 0L;
774
775 //
776 // Native PM does not have any specialize 3D effects like WIN32 does
777 //
778 *pbWant3D = FALSE;
779 return dwStyle;
780 } // end of wxWindow::Determine3DEffects
781
782 #if WXWIN_COMPATIBILITY
783 void wxWindow::OnCommand(
784 wxWindow& rWin
785 , wxCommandEvent& rEvent
786 )
787 {
788 if (GetEventHandler()->ProcessEvent(rEvent))
789 return;
790 if (m_parent)
791 m_parent->GetEventHandler()->OnCommand( rWin
792 ,rEvent
793 );
794 } // end of wxWindow::OnCommand
795
796 wxObject* wxWindow::GetChild(
797 int nNumber
798 ) const
799 {
800 //
801 // Return a pointer to the Nth object in the Panel
802 //
803 wxNode* pNode = GetChildren().First();
804 int n = nNumber;
805
806 while (pNode && n--)
807 pNode = pNode->Next();
808 if (pNode)
809 {
810 wxObject* pObj = (wxObject*)pNode->Data();
811 return(pObj);
812 }
813 else
814 return NULL;
815 } // end of wxWindow::GetChild
816
817 #endif // WXWIN_COMPATIBILITY
818
819 //
820 // Setup background and foreground colours correctly
821 //
822 void wxWindow::SetupColours()
823 {
824 if ( GetParent() )
825 SetBackgroundColour(GetParent()->GetBackgroundColour());
826 } // end of wxWindow::SetupColours
827
828 void wxWindow::OnIdle(
829 wxIdleEvent& rEvent
830 )
831 {
832 //
833 // Check if we need to send a LEAVE event
834 //
835 if (m_bMouseInWindow)
836 {
837 POINTL vPoint;
838
839 ::WinQueryPointerPos(HWND_DESKTOP, &vPoint);
840 if (::WinWindowFromPoint(HWND_DESKTOP, &vPoint, FALSE) != (HWND)GetHwnd())
841 {
842 //
843 // Generate a LEAVE event
844 //
845 m_bMouseInWindow = FALSE;
846
847 //
848 // Unfortunately the mouse button and keyboard state may have changed
849 // by the time the OnIdle function is called, so 'state' may be
850 // meaningless.
851 //
852 int nState = 0;
853
854 if (::WinGetKeyState(HWND_DESKTOP, VK_SHIFT) != 0)
855 nState |= VK_SHIFT;
856 if (::WinGetKeyState(HWND_DESKTOP, VK_CTRL) != 0;
857 nState |= VK_CTRL;
858
859 wxMouseEvent rEvent(wxEVT_LEAVE_WINDOW);
860
861 InitMouseEvent( rEvent
862 ,vPoint.x
863 ,vPoint.y
864 ,nState
865 );
866 (void)GetEventHandler()->ProcessEvent(event);
867 }
868 }
869 UpdateWindowUI();
870 } // end of wxWindow::OnIdle
871
872 //
873 // Set this window to be the child of 'parent'.
874 //
875 bool wxWindow::Reparent(
876 wxWindow* pParent
877 )
878 {
879 if (!wxWindowBase::Reparent(pParent))
880 return FALSE;
881
882 HWND hWndChild = GetHwnd();
883 HWND hWndParent = GetParent() ? GetWinHwnd(GetParent()) : (HWND)0;
884
885 ::WinSetParent(hWndChild, hWndParent, TRUE);
886 return TRUE;
887 } // end of wxWindow::Reparent
888
889 void wxWindow::Clear()
890 {
891 wxClientDC vDc(this);
892 wxBrush vBrush( GetBackgroundColour()
893 ,wxSOLID
894 );
895
896 vDc.SetBackground(vBrush);
897 vDc.Clear();
898 } // end of wxWindow::Clear
899
900 void wxWindow::Refresh(
901 bool bEraseBack
902 , const wxRect* pRect
903 )
904 {
905 HWND hWnd = GetHwnd();
906
907 if (hWnd)
908 {
909 if (pRect)
910 {
911 RECTL vOs2Rect;
912
913 vOs2Rect.xLeft = pRect->x;
914 vOS2Rect.yTop = pRect->y;
915 vOs2Rect.xRight = pRect->x + pRect->width;
916 vOs2Rect.yBottom = pRect->y + pRect->height;
917
918 ::WinInvalidateRect(hWnd, &vOs2Rect, bEraseBack);
919 }
920 else
921 ::WinInvalidateRect(hWnd, NULL, bEraseBack);
922 }
923 } // end of wxWindow::Refresh
924
925 // ---------------------------------------------------------------------------
926 // drag and drop
927 // ---------------------------------------------------------------------------
928
929 #if wxUSE_DRAG_AND_DROP
930 void wxWindow::SetDropTarget(
931 wxDropTarget* pDropTarget
932 )
933 {
934 if (m_dropTarget != 0)
935 {
936 m_dropTarget->Revoke(m_hWnd);
937 delete m_dropTarget;
938 }
939 m_dropTarget = pDropTarget;
940 if (m_dropTarget != 0)
941 m_dropTarget->Register(m_hWnd);
942 } // end of wxWindow::SetDropTarget
943 #endif
944
945 //
946 // old style file-manager drag&drop support: we retain the old-style
947 // DragAcceptFiles in parallel with SetDropTarget.
948 //
949 void wxWindow::DragAcceptFiles(
950 bool bAccept
951 )
952 {
953 HWND hWnd = GetHwnd();
954
955 if (hWnd && bAccept)
956 ::DragAcceptDroppedFiles(hWnd, NULL, NULL, DO_COPY, 0L);
957 } // end of wxWindow::DragAcceptFiles
958
959 // ----------------------------------------------------------------------------
960 // tooltips
961 // ----------------------------------------------------------------------------
962
963 #if wxUSE_TOOLTIPS
964
965 void wxWindow::DoSetToolTip(
966 wxToolTip* pTooltip
967 )
968 {
969 wxWindowBase::DoSetToolTip(pTooltip);
970
971 if (m_pTooltip)
972 m_tooltip->SetWindow(this);
973 } // end of wxWindow::DoSetToolTip
974
975 #endif // wxUSE_TOOLTIPS
976
977 // ---------------------------------------------------------------------------
978 // moving and resizing
979 // ---------------------------------------------------------------------------
980
981 // Get total size
982 void wxWindow::DoGetSize( int *width, int *height ) const
983 {
984 HWND hWnd = GetHwnd();
985 RECT rect;
986 GetWindowRect(hWnd, &rect);
987
988 if ( x )
989 *x = rect.right - rect.left;
990 if ( y )
991 *y = rect.bottom - rect.top;
992 }
993
994 void wxWindow::DoGetPosition( int *x, int *y ) const
995 {
996 HWND hWnd = GetHwnd();
997
998 RECT rect;
999 GetWindowRect(hWnd, &rect);
1000
1001 POINT point;
1002 point.x = rect.left;
1003 point.y = rect.top;
1004
1005 // we do the adjustments with respect to the parent only for the "real"
1006 // children, not for the dialogs/frames
1007 if ( !IsTopLevel() )
1008 {
1009 HWND hParentWnd = 0;
1010 wxWindow *parent = GetParent();
1011 if ( parent )
1012 hParentWnd = GetWinHwnd(parent);
1013
1014 // Since we now have the absolute screen coords, if there's a parent we
1015 // must subtract its top left corner
1016 if ( hParentWnd )
1017 {
1018 ::ScreenToClient(hParentWnd, &point);
1019 }
1020
1021 // We may be faking the client origin. So a window that's really at (0,
1022 // 30) may appear (to wxWin apps) to be at (0, 0).
1023 wxPoint pt(parent->GetClientAreaOrigin());
1024 point.x -= pt.x;
1025 point.y -= pt.y;
1026 }
1027
1028 if ( x )
1029 *x = point.x;
1030 if ( y )
1031 *y = point.y;
1032 }
1033
1034 void wxWindow::DoScreenToClient( int *x, int *y ) const
1035 {
1036 POINT pt;
1037 if ( x )
1038 pt.x = *x;
1039 if ( y )
1040 pt.y = *y;
1041
1042 HWND hWnd = GetHwnd();
1043 ::ScreenToClient(hWnd, &pt);
1044
1045 if ( x )
1046 *x = pt.x;
1047 if ( y )
1048 *y = pt.y;
1049 }
1050
1051 void wxWindow::DoClientToScreen( int *x, int *y ) const
1052 {
1053 POINT pt;
1054 if ( x )
1055 pt.x = *x;
1056 if ( y )
1057 pt.y = *y;
1058
1059 HWND hWnd = GetHwnd();
1060 ::ClientToScreen(hWnd, &pt);
1061
1062 if ( x )
1063 *x = pt.x;
1064 if ( y )
1065 *y = pt.y;
1066 }
1067
1068 // Get size *available for subwindows* i.e. excluding menu bar etc.
1069 void wxWindow::DoGetClientSize( int *width, int *height ) const
1070 {
1071 HWND hWnd = GetHwnd();
1072 RECT rect;
1073 ::GetClientRect(hWnd, &rect);
1074 if ( x )
1075 *x = rect.right;
1076 if ( y )
1077 *y = rect.bottom;
1078 }
1079
1080 void wxWindow::DoMoveWindow(int x, int y, int width, int height)
1081 {
1082 if ( !::MoveWindow(GetHwnd(), x, y, width, height, TRUE) )
1083 {
1084 wxLogLastError("MoveWindow");
1085 }
1086 }
1087
1088 //
1089 // Set the size of the window: if the dimensions are positive, just use them,
1090 // but if any of them is equal to -1, it means that we must find the value for
1091 // it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in
1092 // which case -1 is a valid value for x and y)
1093 //
1094 // If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate
1095 // the width/height to best suit our contents, otherwise we reuse the current
1096 // width/height
1097 //
1098 void wxWindow::DoSetSize(int x, int y,
1099 int width, int height,
1100 int sizeFlags)
1101 {
1102 // get the current size and position...
1103 int currentX, currentY;
1104 GetPosition(&currentX, &currentY);
1105 int currentW,currentH;
1106 GetSize(&currentW, &currentH);
1107
1108 // ... and don't do anything (avoiding flicker) if it's already ok
1109 if ( x == currentX && y == currentY &&
1110 width == currentW && height == currentH )
1111 {
1112 return;
1113 }
1114
1115 if ( x == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) )
1116 x = currentX;
1117 if ( y == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) )
1118 y = currentY;
1119
1120 AdjustForParentClientOrigin(x, y, sizeFlags);
1121
1122 wxSize size(-1, -1);
1123 if ( width == -1 )
1124 {
1125 if ( sizeFlags & wxSIZE_AUTO_WIDTH )
1126 {
1127 size = DoGetBestSize();
1128 width = size.x;
1129 }
1130 else
1131 {
1132 // just take the current one
1133 width = currentW;
1134 }
1135 }
1136
1137 if ( height == -1 )
1138 {
1139 if ( sizeFlags & wxSIZE_AUTO_HEIGHT )
1140 {
1141 if ( size.x == -1 )
1142 {
1143 size = DoGetBestSize();
1144 }
1145 //else: already called DoGetBestSize() above
1146
1147 height = size.y;
1148 }
1149 else
1150 {
1151 // just take the current one
1152 height = currentH;
1153 }
1154 }
1155
1156 DoMoveWindow(x, y, width, height);
1157 }
1158
1159 void wxWindow::DoSetClientSize(int width, int height)
1160 {
1161 wxWindow *parent = GetParent();
1162 HWND hWnd = GetHwnd();
1163 HWND hParentWnd = (HWND) 0;
1164 if ( parent )
1165 hParentWnd = (HWND) parent->GetHWND();
1166
1167 RECT rect;
1168 ::GetClientRect(hWnd, &rect);
1169
1170 RECT rect2;
1171 GetWindowRect(hWnd, &rect2);
1172
1173 // Find the difference between the entire window (title bar and all)
1174 // and the client area; add this to the new client size to move the
1175 // window
1176 int actual_width = rect2.right - rect2.left - rect.right + width;
1177 int actual_height = rect2.bottom - rect2.top - rect.bottom + height;
1178
1179 // If there's a parent, must subtract the parent's top left corner
1180 // since MoveWindow moves relative to the parent
1181
1182 POINT point;
1183 point.x = rect2.left;
1184 point.y = rect2.top;
1185 if ( parent )
1186 {
1187 ::ScreenToClient(hParentWnd, &point);
1188 }
1189
1190 DoMoveWindow(point.x, point.y, actual_width, actual_height);
1191
1192 wxSizeEvent event(wxSize(width, height), m_windowId);
1193 event.SetEventObject(this);
1194 GetEventHandler()->ProcessEvent(event);
1195 }
1196
1197 wxPoint wxWindow::GetClientAreaOrigin() const
1198 {
1199 return wxPoint(0, 0);
1200 }
1201
1202 void wxWindow::AdjustForParentClientOrigin(int& x, int& y, int sizeFlags)
1203 {
1204 // don't do it for the dialogs/frames - they float independently of their
1205 // parent
1206 if ( !IsTopLevel() )
1207 {
1208 wxWindow *parent = GetParent();
1209 if ( !(sizeFlags & wxSIZE_NO_ADJUSTMENTS) && parent )
1210 {
1211 wxPoint pt(parent->GetClientAreaOrigin());
1212 x += pt.x; y += pt.y;
1213 }
1214 }
1215 }
1216
1217 // ---------------------------------------------------------------------------
1218 // text metrics
1219 // ---------------------------------------------------------------------------
1220
1221 int wxWindow::GetCharHeight() const
1222 {
1223 // TODO:
1224 return(1);
1225 }
1226
1227 int wxWindow::GetCharWidth() const
1228 {
1229 // TODO:
1230 return(1);
1231 }
1232
1233 void wxWindow::GetTextExtent( const wxString& string
1234 ,int* x
1235 ,int* y
1236 ,int* descent
1237 ,int* externalLeading
1238 ,const wxFont* theFont
1239 ) const
1240 {
1241 // TODO:
1242 }
1243
1244 #if wxUSE_CARET && WXWIN_COMPATIBILITY
1245 // ---------------------------------------------------------------------------
1246 // Caret manipulation
1247 // ---------------------------------------------------------------------------
1248
1249 void wxWindow::CreateCaret(int w, int h)
1250 {
1251 // TODO:
1252 }
1253
1254 void wxWindow::CreateCaret(const wxBitmap *bitmap)
1255 {
1256 // TODO:
1257 }
1258
1259 void wxWindow::ShowCaret(bool show)
1260 {
1261 // TODO:
1262 }
1263
1264 void wxWindow::DestroyCaret()
1265 {
1266 // TODO:
1267 }
1268
1269 void wxWindow::SetCaretPos(int x, int y)
1270 {
1271 // TODO:
1272 }
1273
1274 void wxWindow::GetCaretPos(int *x, int *y) const
1275 {
1276 // TODO:
1277 }
1278
1279 #endif //wxUSE_CARET
1280
1281 // ---------------------------------------------------------------------------
1282 // popup menu
1283 // ---------------------------------------------------------------------------
1284
1285 bool wxWindow::DoPopupMenu( wxMenu *menu, int x, int y )
1286 {
1287 // TODO:
1288 return(TRUE);
1289 }
1290
1291 // ===========================================================================
1292 // pre/post message processing
1293 // ===========================================================================
1294
1295 MRESULT wxWindow::OS2DefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
1296 {
1297 // TODO:
1298 return (MRESULT)0;
1299 }
1300
1301 bool wxWindow::OS2ProcessMessage(WXMSG* pMsg)
1302 {
1303 // TODO:
1304 return FALSE;
1305 }
1306
1307 bool wxWindow::OS2TranslateMessage(WXMSG* pMsg)
1308 {
1309 return m_acceleratorTable.Translate(this, pMsg);
1310 }
1311
1312 // ---------------------------------------------------------------------------
1313 // message params unpackers (different for Win16 and Win32)
1314 // ---------------------------------------------------------------------------
1315
1316 void wxWindow::UnpackCommand(WXWPARAM wParam, WXLPARAM lParam,
1317 WORD *id, WXHWND *hwnd, WORD *cmd)
1318 {
1319 *id = LOWORD(wParam);
1320 *hwnd = (WXHWND)lParam;
1321 *cmd = HIWORD(wParam);
1322 }
1323
1324 void wxWindow::UnpackActivate(WXWPARAM wParam, WXLPARAM lParam,
1325 WXWORD *state, WXWORD *minimized, WXHWND *hwnd)
1326 {
1327 *state = LOWORD(wParam);
1328 *minimized = HIWORD(wParam);
1329 *hwnd = (WXHWND)lParam;
1330 }
1331
1332 void wxWindow::UnpackScroll(WXWPARAM wParam, WXLPARAM lParam,
1333 WXWORD *code, WXWORD *pos, WXHWND *hwnd)
1334 {
1335 *code = LOWORD(wParam);
1336 *pos = HIWORD(wParam);
1337 *hwnd = (WXHWND)lParam;
1338 }
1339
1340 void wxWindow::UnpackCtlColor(WXWPARAM wParam, WXLPARAM lParam,
1341 WXWORD *nCtlColor, WXHDC *hdc, WXHWND *hwnd)
1342 {
1343 *nCtlColor = 0; // TODO: CTLCOLOR_BTN;
1344 *hwnd = (WXHWND)lParam;
1345 *hdc = (WXHDC)wParam;
1346 }
1347
1348 void wxWindow::UnpackMenuSelect(WXWPARAM wParam, WXLPARAM lParam,
1349 WXWORD *item, WXWORD *flags, WXHMENU *hmenu)
1350 {
1351 *item = (WXWORD)LOWORD(wParam);
1352 *flags = HIWORD(wParam);
1353 *hmenu = (WXHMENU)lParam;
1354 }
1355
1356 // ---------------------------------------------------------------------------
1357 // Main wxWindows window proc and the window proc for wxWindow
1358 // ---------------------------------------------------------------------------
1359
1360 // Hook for new window just as it's being created, when the window isn't yet
1361 // associated with the handle
1362 wxWindow *wxWndHook = NULL;
1363
1364 // Main window proc
1365 MRESULT wxWndProc(HWND hWnd, ULONG message, MPARAM wParam, MPARAM lParam)
1366 {
1367 // trace all messages - useful for the debugging
1368 #ifdef __WXDEBUG__
1369 wxLogTrace(wxTraceMessages, wxT("Processing %s(wParam=%8lx, lParam=%8lx)"),
1370 wxGetMessageName(message), wParam, lParam);
1371 #endif // __WXDEBUG__
1372
1373 wxWindow *wnd = wxFindWinFromHandle((WXHWND) hWnd);
1374
1375 // when we get the first message for the HWND we just created, we associate
1376 // it with wxWindow stored in wxWndHook
1377 if ( !wnd && wxWndHook )
1378 {
1379 #if 0 // def __WXDEBUG__
1380 char buf[512];
1381 ::GetClassNameA((HWND) hWnd, buf, 512);
1382 wxString className(buf);
1383 #endif
1384
1385 wxAssociateWinWithHandle(hWnd, wxWndHook);
1386 wnd = wxWndHook;
1387 wxWndHook = NULL;
1388 wnd->SetHWND((WXHWND)hWnd);
1389 }
1390
1391 MRESULT rc;
1392
1393 // Stop right here if we don't have a valid handle in our wxWindow object.
1394 if ( wnd && !wnd->GetHWND() )
1395 {
1396 // FIXME: why do we do this?
1397 wnd->SetHWND((WXHWND) hWnd);
1398 rc = wnd->OS2DefWindowProc(message, wParam, lParam );
1399 wnd->SetHWND(0);
1400 }
1401 else
1402 {
1403 if ( wnd )
1404 rc = wnd->OS2WindowProc(message, wParam, lParam);
1405 else
1406 rc = 0; //TODO: DefWindowProc( hWnd, message, wParam, lParam );
1407 }
1408
1409 return rc;
1410 }
1411
1412 MRESULT wxWindow::OS2WindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
1413 {
1414 // did we process the message?
1415 bool processed = FALSE;
1416
1417 // the return value
1418 union
1419 {
1420 bool allow;
1421 long result;
1422 WXHICON hIcon;
1423 WXHBRUSH hBrush;
1424 } rc;
1425
1426 // for most messages we should return 0 when we do process the message
1427 rc.result = 0;
1428 // TODO:
1429 /*
1430 switch ( message )
1431 {
1432 case WM_CREATE:
1433 {
1434 bool mayCreate;
1435 processed = HandleCreate((WXLPCREATESTRUCT)lParam, &mayCreate);
1436 if ( processed )
1437 {
1438 // return 0 to allow window creation
1439 rc.result = mayCreate ? 0 : -1;
1440 }
1441 }
1442 break;
1443
1444 case WM_DESTROY:
1445 processed = HandleDestroy();
1446 break;
1447
1448 case WM_MOVE:
1449 processed = HandleMove(LOWORD(lParam), HIWORD(lParam));
1450 break;
1451
1452 case WM_SIZE:
1453 processed = HandleSize(LOWORD(lParam), HIWORD(lParam), wParam);
1454 break;
1455
1456 case WM_ACTIVATE:
1457 {
1458 WXWORD state, minimized;
1459 WXHWND hwnd;
1460 UnpackActivate(wParam, lParam, &state, &minimized, &hwnd);
1461
1462 processed = HandleActivate(state, minimized != 0, (WXHWND)hwnd);
1463 }
1464 break;
1465
1466 case WM_SETFOCUS:
1467 processed = HandleSetFocus((WXHWND)(HWND)wParam);
1468 break;
1469
1470 case WM_KILLFOCUS:
1471 processed = HandleKillFocus((WXHWND)(HWND)wParam);
1472 break;
1473
1474 case WM_PAINT:
1475 processed = HandlePaint();
1476 break;
1477
1478 case WM_CLOSE:
1479 // don't let the DefWindowProc() destroy our window - we'll do it
1480 // ourselves in ~wxWindow
1481 processed = TRUE;
1482 rc.result = TRUE;
1483 break;
1484
1485 case WM_SHOWWINDOW:
1486 processed = HandleShow(wParam != 0, (int)lParam);
1487 break;
1488
1489 case WM_MOUSEMOVE:
1490 case WM_LBUTTONDOWN:
1491 case WM_LBUTTONUP:
1492 case WM_LBUTTONDBLCLK:
1493 case WM_RBUTTONDOWN:
1494 case WM_RBUTTONUP:
1495 case WM_RBUTTONDBLCLK:
1496 case WM_MBUTTONDOWN:
1497 case WM_MBUTTONUP:
1498 case WM_MBUTTONDBLCLK:
1499 {
1500 short x = LOWORD(lParam);
1501 short y = HIWORD(lParam);
1502
1503 processed = HandleMouseEvent(message, x, y, wParam);
1504 }
1505 break;
1506
1507 case MM_JOY1MOVE:
1508 case MM_JOY2MOVE:
1509 case MM_JOY1ZMOVE:
1510 case MM_JOY2ZMOVE:
1511 case MM_JOY1BUTTONDOWN:
1512 case MM_JOY2BUTTONDOWN:
1513 case MM_JOY1BUTTONUP:
1514 case MM_JOY2BUTTONUP:
1515 {
1516 int x = LOWORD(lParam);
1517 int y = HIWORD(lParam);
1518
1519 processed = HandleJoystickEvent(message, x, y, wParam);
1520 }
1521 break;
1522
1523 case WM_SYSCOMMAND:
1524 processed = HandleSysCommand(wParam, lParam);
1525 break;
1526
1527 case WM_COMMAND:
1528 {
1529 WORD id, cmd;
1530 WXHWND hwnd;
1531 UnpackCommand(wParam, lParam, &id, &hwnd, &cmd);
1532
1533 processed = HandleCommand(id, cmd, hwnd);
1534 }
1535 break;
1536
1537 #ifdef __WIN95__
1538 case WM_NOTIFY:
1539 processed = HandleNotify((int)wParam, lParam, &rc.result);
1540 break;
1541 #endif // Win95
1542
1543 // for these messages we must return TRUE if process the message
1544 case WM_DRAWITEM:
1545 case WM_MEASUREITEM:
1546 {
1547 int idCtrl = (UINT)wParam;
1548 if ( message == WM_DRAWITEM )
1549 {
1550 processed = MSWOnDrawItem(idCtrl,
1551 (WXDRAWITEMSTRUCT *)lParam);
1552 }
1553 else
1554 {
1555 processed = MSWOnMeasureItem(idCtrl,
1556 (WXMEASUREITEMSTRUCT *)lParam);
1557 }
1558
1559 if ( processed )
1560 rc.result = TRUE;
1561 }
1562 break;
1563
1564 case WM_GETDLGCODE:
1565 if ( m_lDlgCode )
1566 {
1567 rc.result = m_lDlgCode;
1568 processed = TRUE;
1569 }
1570 //else: get the dlg code from the DefWindowProc()
1571 break;
1572
1573 case WM_KEYDOWN:
1574 // If this has been processed by an event handler,
1575 // return 0 now (we've handled it).
1576 if ( HandleKeyDown((WORD) wParam, lParam) )
1577 {
1578 processed = TRUE;
1579
1580 break;
1581 }
1582
1583 // we consider these message "not interesting" to OnChar
1584 if ( wParam == VK_SHIFT || wParam == VK_CONTROL )
1585 {
1586 processed = TRUE;
1587
1588 break;
1589 }
1590
1591 switch ( wParam )
1592 {
1593 // avoid duplicate messages to OnChar for these ASCII keys: they
1594 // will be translated by TranslateMessage() and received in WM_CHAR
1595 case VK_ESCAPE:
1596 case VK_SPACE:
1597 case VK_RETURN:
1598 case VK_BACK:
1599 case VK_TAB:
1600 // but set processed to FALSE, not TRUE to still pass them to
1601 // the control's default window proc - otherwise built-in
1602 // keyboard handling won't work
1603 processed = FALSE;
1604
1605 break;
1606
1607 #ifdef VK_APPS
1608 // special case of VK_APPS: treat it the same as right mouse
1609 // click because both usually pop up a context menu
1610 case VK_APPS:
1611 {
1612 // construct the key mask
1613 WPARAM fwKeys = MK_RBUTTON;
1614 if ( (::GetKeyState(VK_CONTROL) & 0x100) != 0 )
1615 fwKeys |= MK_CONTROL;
1616 if ( (::GetKeyState(VK_SHIFT) & 0x100) != 0 )
1617 fwKeys |= MK_SHIFT;
1618
1619 // simulate right mouse button click
1620 DWORD dwPos = ::GetMessagePos();
1621 int x = GET_X_LPARAM(dwPos),
1622 y = GET_Y_LPARAM(dwPos);
1623
1624 ScreenToClient(&x, &y);
1625 processed = HandleMouseEvent(WM_RBUTTONDOWN, x, y, fwKeys);
1626 }
1627 break;
1628 #endif // VK_APPS
1629
1630 case VK_LEFT:
1631 case VK_RIGHT:
1632 case VK_DOWN:
1633 case VK_UP:
1634 default:
1635 processed = HandleChar((WORD)wParam, lParam);
1636 }
1637 break;
1638
1639 case WM_KEYUP:
1640 processed = HandleKeyUp((WORD) wParam, lParam);
1641 break;
1642
1643 case WM_CHAR: // Always an ASCII character
1644 processed = HandleChar((WORD)wParam, lParam, TRUE);
1645 break;
1646
1647 case WM_HSCROLL:
1648 case WM_VSCROLL:
1649 {
1650 WXWORD code, pos;
1651 WXHWND hwnd;
1652 UnpackScroll(wParam, lParam, &code, &pos, &hwnd);
1653
1654 processed = MSWOnScroll(message == WM_HSCROLL ? wxHORIZONTAL
1655 : wxVERTICAL,
1656 code, pos, hwnd);
1657 }
1658 break;
1659
1660 // CTLCOLOR messages are sent by children to query the parent for their
1661 // colors
1662 #ifdef __WIN32__
1663 case WM_CTLCOLORMSGBOX:
1664 case WM_CTLCOLOREDIT:
1665 case WM_CTLCOLORLISTBOX:
1666 case WM_CTLCOLORBTN:
1667 case WM_CTLCOLORDLG:
1668 case WM_CTLCOLORSCROLLBAR:
1669 case WM_CTLCOLORSTATIC:
1670 #else // Win16
1671 case WM_CTLCOLOR:
1672 #endif // Win32/16
1673 {
1674 WXWORD nCtlColor;
1675 WXHDC hdc;
1676 WXHWND hwnd;
1677 UnpackCtlColor(wParam, lParam, &nCtlColor, &hdc, &hwnd);
1678
1679 processed = HandleCtlColor(&rc.hBrush,
1680 (WXHDC)hdc,
1681 (WXHWND)hwnd,
1682 nCtlColor,
1683 message,
1684 wParam,
1685 lParam);
1686 }
1687 break;
1688
1689 // the return value for this message is ignored
1690 case WM_SYSCOLORCHANGE:
1691 processed = HandleSysColorChange();
1692 break;
1693
1694 case WM_PALETTECHANGED:
1695 processed = HandlePaletteChanged((WXHWND) (HWND) wParam);
1696 break;
1697
1698 case WM_QUERYNEWPALETTE:
1699 processed = HandleQueryNewPalette();
1700 break;
1701
1702 case WM_ERASEBKGND:
1703 processed = HandleEraseBkgnd((WXHDC)(HDC)wParam);
1704 if ( processed )
1705 {
1706 // we processed the message, i.e. erased the background
1707 rc.result = TRUE;
1708 }
1709 break;
1710
1711 case WM_DROPFILES:
1712 processed = HandleDropFiles(wParam);
1713 break;
1714
1715 case WM_INITDIALOG:
1716 processed = HandleInitDialog((WXHWND)(HWND)wParam);
1717
1718 if ( processed )
1719 {
1720 // we never set focus from here
1721 rc.result = FALSE;
1722 }
1723 break;
1724
1725 case WM_QUERYENDSESSION:
1726 processed = HandleQueryEndSession(lParam, &rc.allow);
1727 break;
1728
1729 case WM_ENDSESSION:
1730 processed = HandleEndSession(wParam != 0, lParam);
1731 break;
1732
1733 case WM_GETMINMAXINFO:
1734 processed = HandleGetMinMaxInfo((MINMAXINFO*)lParam);
1735 break;
1736
1737 case WM_SETCURSOR:
1738 processed = HandleSetCursor((WXHWND)(HWND)wParam,
1739 LOWORD(lParam), // hit test
1740 HIWORD(lParam)); // mouse msg
1741
1742 if ( processed )
1743 {
1744 // returning TRUE stops the DefWindowProc() from further
1745 // processing this message - exactly what we need because we've
1746 // just set the cursor.
1747 rc.result = TRUE;
1748 }
1749 break;
1750 }
1751
1752 if ( !processed )
1753 {
1754 #ifdef __WXDEBUG__
1755 wxLogTrace(wxTraceMessages, wxT("Forwarding %s to DefWindowProc."),
1756 wxGetMessageName(message));
1757 #endif // __WXDEBUG__
1758 rc.result = MSWDefWindowProc(message, wParam, lParam);
1759 }
1760 */
1761 return (MRESULT)0;
1762 }
1763
1764 // Dialog window proc
1765 MRESULT wxDlgProc(HWND hWnd, UINT message, MPARAM wParam, MPARAM lParam)
1766 {
1767 // TODO:
1768 /*
1769 if ( message == WM_INITDIALOG )
1770 {
1771 // for this message, returning TRUE tells system to set focus to the
1772 // first control in the dialog box
1773 return TRUE;
1774 }
1775 else
1776 {
1777 // for all the other ones, FALSE means that we didn't process the
1778 // message
1779 return 0;
1780 }
1781 */
1782 return (MRESULT)0;
1783 }
1784
1785 wxWindow *wxFindWinFromHandle(WXHWND hWnd)
1786 {
1787 wxNode *node = wxWinHandleList->Find((long)hWnd);
1788 if ( !node )
1789 return NULL;
1790 return (wxWindow *)node->Data();
1791 }
1792
1793 void wxAssociateWinWithHandle(HWND hWnd, wxWindow *win)
1794 {
1795 // adding NULL hWnd is (first) surely a result of an error and
1796 // (secondly) breaks menu command processing
1797 wxCHECK_RET( hWnd != (HWND)NULL,
1798 wxT("attempt to add a NULL hWnd to window list ignored") );
1799
1800
1801 wxWindow *oldWin = wxFindWinFromHandle((WXHWND) hWnd);
1802 if ( oldWin && (oldWin != win) )
1803 {
1804 wxString str(win->GetClassInfo()->GetClassName());
1805 wxLogError("Bug! Found existing HWND %X for new window of class %s", (int) hWnd, (const char*) str);
1806 }
1807 else if (!oldWin)
1808 {
1809 wxWinHandleList->Append((long)hWnd, win);
1810 }
1811 }
1812
1813 void wxRemoveHandleAssociation(wxWindow *win)
1814 {
1815 wxWinHandleList->DeleteObject(win);
1816 }
1817
1818 // Default destroyer - override if you destroy it in some other way
1819 // (e.g. with MDI child windows)
1820 void wxWindow::OS2DestroyWindow()
1821 {
1822 }
1823
1824 void wxWindow::OS2DetachWindowMenu()
1825 {
1826 if ( m_hMenu )
1827 {
1828 HMENU hMenu = (HMENU)m_hMenu;
1829
1830 int N = (int)WinSendMsg(hMenu, MM_QUERYITEMCOUNT, 0, 0);
1831 int i;
1832 for (i = 0; i < N; i++)
1833 {
1834 wxChar buf[100];
1835 int chars = (int)WinSendMsg(hMenu, MM_QUERYITEMTEXT, MPFROM2SHORT(i, N), buf);
1836 if ( !chars )
1837 {
1838 wxLogLastError(wxT("GetMenuString"));
1839
1840 continue;
1841 }
1842
1843 if ( wxStrcmp(buf, wxT("&Window")) == 0 )
1844 {
1845 WinSendMsg(hMenu, MM_DELETEITEM, MPFROM2SHORT(i, TRUE), 0);
1846 break;
1847 }
1848 }
1849 }
1850 }
1851
1852 bool wxWindow::OS2Create(int id,
1853 wxWindow *parent,
1854 const wxChar *wclass,
1855 wxWindow *wx_win,
1856 const wxChar *title,
1857 int x,
1858 int y,
1859 int width,
1860 int height,
1861 WXDWORD style,
1862 const wxChar *dialog_template,
1863 WXDWORD extendedStyle)
1864 {
1865 // TODO:
1866 /*
1867 int x1 = CW_USEDEFAULT;
1868 int y1 = 0;
1869 int width1 = CW_USEDEFAULT;
1870 int height1 = 100;
1871
1872 // Find parent's size, if it exists, to set up a possible default
1873 // panel size the size of the parent window
1874 RECT parent_rect;
1875 if ( parent )
1876 {
1877 ::GetClientRect((HWND) parent->GetHWND(), &parent_rect);
1878
1879 width1 = parent_rect.right - parent_rect.left;
1880 height1 = parent_rect.bottom - parent_rect.top;
1881 }
1882
1883 if ( x > -1 ) x1 = x;
1884 if ( y > -1 ) y1 = y;
1885 if ( width > -1 ) width1 = width;
1886 if ( height > -1 ) height1 = height;
1887
1888 HWND hParent = (HWND)NULL;
1889 if ( parent )
1890 hParent = (HWND) parent->GetHWND();
1891
1892 wxWndHook = this;
1893
1894 if ( dialog_template )
1895 {
1896 m_hWnd = (WXHWND)::CreateDialog(wxGetInstance(),
1897 dialog_template,
1898 hParent,
1899 (DLGPROC)wxDlgProc);
1900
1901 if ( m_hWnd == 0 )
1902 {
1903 wxLogError(_("Can't find dummy dialog template!\n"
1904 "Check resource include path for finding wx.rc."));
1905
1906 return FALSE;
1907 }
1908
1909 // ::SetWindowLong(GWL_EXSTYLE) doesn't work for the dialogs, so try
1910 // to take care of (at least some) extended style flags ourselves
1911 if ( extendedStyle & WS_EX_TOPMOST )
1912 {
1913 if ( !::SetWindowPos(GetHwnd(), HWND_TOPMOST, 0, 0, 0, 0,
1914 SWP_NOSIZE | SWP_NOMOVE) )
1915 {
1916 wxLogLastError(wxT("SetWindowPos"));
1917 }
1918 }
1919
1920 // move the dialog to its initial position without forcing repainting
1921 if ( !::MoveWindow(GetHwnd(), x1, y1, width1, height1, FALSE) )
1922 {
1923 wxLogLastError(wxT("MoveWindow"));
1924 }
1925 }
1926 else
1927 {
1928 int controlId = 0;
1929 if ( style & WS_CHILD )
1930 controlId = id;
1931
1932 wxString className(wclass);
1933 if ( GetWindowStyleFlag() & wxNO_FULL_REPAINT_ON_RESIZE )
1934 {
1935 className += wxT("NR");
1936 }
1937
1938 m_hWnd = (WXHWND)CreateWindowEx(extendedStyle,
1939 className,
1940 title ? title : wxT(""),
1941 style,
1942 x1, y1,
1943 width1, height1,
1944 hParent, (HMENU)controlId,
1945 wxGetInstance(),
1946 NULL);
1947
1948 if ( !m_hWnd )
1949 {
1950 wxLogError(_("Can't create window of class %s!\n"
1951 "Possible Windows 3.x compatibility problem?"),
1952 wclass);
1953
1954 return FALSE;
1955 }
1956 }
1957
1958 wxWndHook = NULL;
1959 #ifdef __WXDEBUG__
1960 wxNode* node = wxWinHandleList->Member(this);
1961 if (node)
1962 {
1963 HWND hWnd = (HWND) node->GetKeyInteger();
1964 if (hWnd != (HWND) m_hWnd)
1965 {
1966 wxLogError("A second HWND association is being added for the same window!");
1967 }
1968 }
1969 #endif
1970 */
1971 wxAssociateWinWithHandle((HWND) m_hWnd, this);
1972
1973 return TRUE;
1974 }
1975
1976 // ===========================================================================
1977 // OS2 PM message handlers
1978 // ===========================================================================
1979
1980 // ---------------------------------------------------------------------------
1981 // WM_NOTIFY
1982 // ---------------------------------------------------------------------------
1983
1984 bool wxWindow::HandleNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
1985 {
1986 // TODO:
1987 return FALSE;
1988 }
1989
1990 bool wxWindow::OS2OnNotify(int WXUNUSED(idCtrl),
1991 WXLPARAM lParam,
1992 WXLPARAM* WXUNUSED(result))
1993 {
1994 // TODO:
1995 return FALSE;
1996 }
1997
1998 // ---------------------------------------------------------------------------
1999 // end session messages
2000 // ---------------------------------------------------------------------------
2001
2002 bool wxWindow::HandleQueryEndSession(long logOff, bool *mayEnd)
2003 {
2004 wxCloseEvent event(wxEVT_QUERY_END_SESSION, -1);
2005 event.SetEventObject(wxTheApp);
2006 event.SetCanVeto(TRUE);
2007 event.SetLoggingOff(logOff == ENDSESSION_LOGOFF);
2008
2009 bool rc = wxTheApp->ProcessEvent(event);
2010
2011 if ( rc )
2012 {
2013 // we may end only if the app didn't veto session closing (double
2014 // negation...)
2015 *mayEnd = !event.GetVeto();
2016 }
2017
2018 return rc;
2019 }
2020
2021 bool wxWindow::HandleEndSession(bool endSession, long logOff)
2022 {
2023 // do nothing if the session isn't ending
2024 if ( !endSession )
2025 return FALSE;
2026
2027 wxCloseEvent event(wxEVT_END_SESSION, -1);
2028 event.SetEventObject(wxTheApp);
2029 event.SetCanVeto(FALSE);
2030 event.SetLoggingOff( (logOff == ENDSESSION_LOGOFF) );
2031 if ( (this == wxTheApp->GetTopWindow()) && // Only send once
2032 wxTheApp->ProcessEvent(event))
2033 {
2034 }
2035 return TRUE;
2036 }
2037
2038 // ---------------------------------------------------------------------------
2039 // window creation/destruction
2040 // ---------------------------------------------------------------------------
2041
2042 bool wxWindow::HandleCreate(WXLPCREATESTRUCT cs, bool *mayCreate)
2043 {
2044 // TODO: should generate this event from WM_NCCREATE
2045 wxWindowCreateEvent event(this);
2046 (void)GetEventHandler()->ProcessEvent(event);
2047
2048 *mayCreate = TRUE;
2049
2050 return TRUE;
2051 }
2052
2053 bool wxWindow::HandleDestroy()
2054 {
2055 wxWindowDestroyEvent event(this);
2056 (void)GetEventHandler()->ProcessEvent(event);
2057
2058 // delete our drop target if we've got one
2059 #if wxUSE_DRAG_AND_DROP
2060 if ( m_dropTarget != NULL )
2061 {
2062 // m_dropTarget->Revoke(m_hWnd);
2063
2064 delete m_dropTarget;
2065 m_dropTarget = NULL;
2066 }
2067 #endif // wxUSE_DRAG_AND_DROP
2068
2069 // WM_DESTROY handled
2070 return TRUE;
2071 }
2072
2073 // ---------------------------------------------------------------------------
2074 // activation/focus
2075 // ---------------------------------------------------------------------------
2076
2077 bool wxWindow::HandleActivate(int state,
2078 bool WXUNUSED(minimized),
2079 WXHWND WXUNUSED(activate))
2080 {
2081 // TODO:
2082 /*
2083 wxActivateEvent event(wxEVT_ACTIVATE,
2084 (state == WA_ACTIVE) || (state == WA_CLICKACTIVE),
2085 m_windowId);
2086 event.SetEventObject(this);
2087
2088 return GetEventHandler()->ProcessEvent(event);
2089 */
2090 return FALSE;
2091 }
2092
2093 bool wxWindow::HandleSetFocus(WXHWND WXUNUSED(hwnd))
2094 {
2095 #if wxUSE_CARET
2096 // Deal with caret
2097 if ( m_caret )
2098 {
2099 m_caret->OnSetFocus();
2100 }
2101 #endif // wxUSE_CARET
2102
2103 // panel wants to track the window which was the last to have focus in it
2104 wxPanel *panel = wxDynamicCast(GetParent(), wxPanel);
2105 if ( panel )
2106 {
2107 panel->SetLastFocus(this);
2108 }
2109
2110 wxFocusEvent event(wxEVT_SET_FOCUS, m_windowId);
2111 event.SetEventObject(this);
2112
2113 return GetEventHandler()->ProcessEvent(event);
2114 }
2115
2116 bool wxWindow::HandleKillFocus(WXHWND WXUNUSED(hwnd))
2117 {
2118 #if wxUSE_CARET
2119 // Deal with caret
2120 if ( m_caret )
2121 {
2122 m_caret->OnKillFocus();
2123 }
2124 #endif // wxUSE_CARET
2125
2126 wxFocusEvent event(wxEVT_KILL_FOCUS, m_windowId);
2127 event.SetEventObject(this);
2128
2129 return GetEventHandler()->ProcessEvent(event);
2130 }
2131
2132 // ---------------------------------------------------------------------------
2133 // miscellaneous
2134 // ---------------------------------------------------------------------------
2135
2136 bool wxWindow::HandleShow(bool show, int status)
2137 {
2138 wxShowEvent event(GetId(), show);
2139 event.m_eventObject = this;
2140
2141 return GetEventHandler()->ProcessEvent(event);
2142 }
2143
2144 bool wxWindow::HandleInitDialog(WXHWND WXUNUSED(hWndFocus))
2145 {
2146 wxInitDialogEvent event(GetId());
2147 event.m_eventObject = this;
2148
2149 return GetEventHandler()->ProcessEvent(event);
2150 }
2151
2152 bool wxWindow::HandleDropFiles(WXWPARAM wParam)
2153 {
2154 // TODO:
2155 return FALSE;
2156 }
2157
2158 bool wxWindow::HandleSetCursor(WXHWND hWnd,
2159 short nHitTest,
2160 int WXUNUSED(mouseMsg))
2161 {
2162 // don't set cursor for other windows, only for this one: this prevents
2163 // children of this window from getting the same cursor as the parent has
2164 // (don't forget that this message is propagated by default up the window
2165 // parent-child hierarchy)
2166 if ( GetHWND() == hWnd )
2167 {
2168 // don't set cursor when the mouse is not in the client part
2169 // TODO
2170 /*
2171 if ( nHitTest == HTCLIENT || nHitTest == HTERROR )
2172 {
2173 HCURSOR hcursor = 0;
2174 if ( wxIsBusy() )
2175 {
2176 // from msw\utils.cpp
2177 extern HCURSOR gs_wxBusyCursor;
2178
2179 hcursor = gs_wxBusyCursor;
2180 }
2181 else
2182 {
2183 wxCursor *cursor = NULL;
2184
2185 if ( m_cursor.Ok() )
2186 {
2187 cursor = &m_cursor;
2188 }
2189 else
2190 {
2191 // from msw\data.cpp
2192 extern wxCursor *g_globalCursor;
2193
2194 if ( g_globalCursor && g_globalCursor->Ok() )
2195 cursor = g_globalCursor;
2196 }
2197
2198 if ( cursor )
2199 hcursor = (HCURSOR)cursor->GetHCURSOR();
2200 }
2201
2202 if ( hcursor )
2203 {
2204 // ::SetCursor(hcursor);
2205
2206 return TRUE;
2207 }
2208 }
2209 */
2210 }
2211
2212 return FALSE;
2213 }
2214
2215 // ---------------------------------------------------------------------------
2216 // owner drawn stuff
2217 // ---------------------------------------------------------------------------
2218
2219 bool wxWindow::OS2OnDrawItem(int id, WXDRAWITEMSTRUCT *itemStruct)
2220 {
2221 // TODO:
2222 /*
2223 #if wxUSE_OWNER_DRAWN
2224 // is it a menu item?
2225 if ( id == 0 )
2226 {
2227 DRAWITEMSTRUCT *pDrawStruct = (DRAWITEMSTRUCT *)itemStruct;
2228 wxMenuItem *pMenuItem = (wxMenuItem *)(pDrawStruct->itemData);
2229
2230 wxCHECK( pMenuItem->IsKindOf(CLASSINFO(wxMenuItem)), FALSE );
2231
2232 // prepare to call OnDrawItem()
2233 wxDC dc;
2234 dc.SetHDC((WXHDC)pDrawStruct->hDC, FALSE);
2235 wxRect rect(pDrawStruct->rcItem.left, pDrawStruct->rcItem.top,
2236 pDrawStruct->rcItem.right - pDrawStruct->rcItem.left,
2237 pDrawStruct->rcItem.bottom - pDrawStruct->rcItem.top);
2238
2239 return pMenuItem->OnDrawItem
2240 (
2241 dc, rect,
2242 (wxOwnerDrawn::wxODAction)pDrawStruct->itemAction,
2243 (wxOwnerDrawn::wxODStatus)pDrawStruct->itemState
2244 );
2245 }
2246
2247 wxWindow *item = FindItem(id);
2248 if ( item && item->IsKindOf(CLASSINFO(wxControl)) )
2249 {
2250 return ((wxControl *)item)->MSWOnDraw(itemStruct);
2251 }
2252 else
2253 #endif
2254 return FALSE;
2255 */
2256 return FALSE;
2257 }
2258
2259 bool wxWindow::OS2OnMeasureItem(int id, WXMEASUREITEMSTRUCT *itemStruct)
2260 {
2261 // TODO:
2262 /*
2263 #if wxUSE_OWNER_DRAWN
2264 // is it a menu item?
2265 if ( id == 0 )
2266 {
2267 MEASUREITEMSTRUCT *pMeasureStruct = (MEASUREITEMSTRUCT *)itemStruct;
2268 wxMenuItem *pMenuItem = (wxMenuItem *)(pMeasureStruct->itemData);
2269
2270 wxCHECK( pMenuItem->IsKindOf(CLASSINFO(wxMenuItem)), FALSE );
2271
2272 return pMenuItem->OnMeasureItem(&pMeasureStruct->itemWidth,
2273 &pMeasureStruct->itemHeight);
2274 }
2275
2276 wxWindow *item = FindItem(id);
2277 if ( item && item->IsKindOf(CLASSINFO(wxControl)) )
2278 {
2279 return ((wxControl *)item)->MSWOnMeasure(itemStruct);
2280 }
2281 #endif // owner-drawn menus
2282 */
2283 return FALSE;
2284 }
2285
2286 // ---------------------------------------------------------------------------
2287 // colours and palettes
2288 // ---------------------------------------------------------------------------
2289
2290 bool wxWindow::HandleSysColorChange()
2291 {
2292 wxSysColourChangedEvent event;
2293 event.SetEventObject(this);
2294
2295 return GetEventHandler()->ProcessEvent(event);
2296 }
2297
2298 bool wxWindow::HandleCtlColor(WXHBRUSH *brush,
2299 WXHDC pDC,
2300 WXHWND pWnd,
2301 WXUINT nCtlColor,
2302 WXUINT message,
2303 WXWPARAM wParam,
2304 WXLPARAM lParam)
2305 {
2306 WXHBRUSH hBrush = 0;
2307 // TODO:
2308 /*
2309 if ( nCtlColor == CTLCOLOR_DLG )
2310 {
2311 hBrush = OnCtlColor(pDC, pWnd, nCtlColor, message, wParam, lParam);
2312 }
2313 else
2314 {
2315 wxControl *item = (wxControl *)FindItemByHWND(pWnd, TRUE);
2316 if ( item )
2317 hBrush = item->OnCtlColor(pDC, pWnd, nCtlColor, message, wParam, lParam);
2318 }
2319
2320 if ( hBrush )
2321 *brush = hBrush;
2322
2323 return hBrush != 0;
2324 */
2325 return FALSE;
2326 }
2327
2328 // Define for each class of dialog and control
2329 WXHBRUSH wxWindow::OnCtlColor(WXHDC hDC,
2330 WXHWND hWnd,
2331 WXUINT nCtlColor,
2332 WXUINT message,
2333 WXWPARAM wParam,
2334 WXLPARAM lParam)
2335 {
2336 return (WXHBRUSH)0;
2337 }
2338
2339 bool wxWindow::HandlePaletteChanged(WXHWND hWndPalChange)
2340 {
2341 wxPaletteChangedEvent event(GetId());
2342 event.SetEventObject(this);
2343 event.SetChangedWindow(wxFindWinFromHandle(hWndPalChange));
2344
2345 return GetEventHandler()->ProcessEvent(event);
2346 }
2347
2348 bool wxWindow::HandleQueryNewPalette()
2349 {
2350 wxQueryNewPaletteEvent event(GetId());
2351 event.SetEventObject(this);
2352
2353 return GetEventHandler()->ProcessEvent(event) && event.GetPaletteRealized();
2354 }
2355
2356 // Responds to colour changes: passes event on to children.
2357 void wxWindow::OnSysColourChanged(wxSysColourChangedEvent& event)
2358 {
2359 wxNode *node = GetChildren().First();
2360 while ( node )
2361 {
2362 // Only propagate to non-top-level windows
2363 wxWindow *win = (wxWindow *)node->Data();
2364 if ( win->GetParent() )
2365 {
2366 wxSysColourChangedEvent event2;
2367 event.m_eventObject = win;
2368 win->GetEventHandler()->ProcessEvent(event2);
2369 }
2370
2371 node = node->Next();
2372 }
2373 }
2374
2375 // ---------------------------------------------------------------------------
2376 // painting
2377 // ---------------------------------------------------------------------------
2378
2379 bool wxWindow::HandlePaint()
2380 {
2381 // TODO:
2382 return FALSE;
2383 }
2384
2385 bool wxWindow::HandleEraseBkgnd(WXHDC hdc)
2386 {
2387 // Prevents flicker when dragging
2388 // if ( ::IsIconic(GetHwnd()) )
2389 // return TRUE;
2390
2391 wxDC dc;
2392
2393 dc.SetHDC(hdc);
2394 dc.SetWindow(this);
2395 dc.BeginDrawing();
2396
2397 wxEraseEvent event(m_windowId, &dc);
2398 event.SetEventObject(this);
2399 bool rc = GetEventHandler()->ProcessEvent(event);
2400
2401 dc.EndDrawing();
2402 dc.SelectOldObjects(hdc);
2403 dc.SetHDC((WXHDC) NULL);
2404
2405 return rc;
2406 }
2407
2408 void wxWindow::OnEraseBackground(wxEraseEvent& event)
2409 {
2410 // TODO:
2411 }
2412
2413 // ---------------------------------------------------------------------------
2414 // moving and resizing
2415 // ---------------------------------------------------------------------------
2416
2417 bool wxWindow::HandleMinimize()
2418 {
2419 wxIconizeEvent event(m_windowId);
2420 event.SetEventObject(this);
2421
2422 return GetEventHandler()->ProcessEvent(event);
2423 }
2424
2425 bool wxWindow::HandleMaximize()
2426 {
2427 wxMaximizeEvent event(m_windowId);
2428 event.SetEventObject(this);
2429
2430 return GetEventHandler()->ProcessEvent(event);
2431 }
2432
2433 bool wxWindow::HandleMove(int x, int y)
2434 {
2435 wxMoveEvent event(wxPoint(x, y), m_windowId);
2436 event.SetEventObject(this);
2437
2438 return GetEventHandler()->ProcessEvent(event);
2439 }
2440
2441 bool wxWindow::HandleSize(int w, int h, WXUINT WXUNUSED(flag))
2442 {
2443 wxSizeEvent event(wxSize(w, h), m_windowId);
2444 event.SetEventObject(this);
2445
2446 return GetEventHandler()->ProcessEvent(event);
2447 }
2448
2449 bool wxWindow::HandleGetMinMaxInfo(void *mmInfo)
2450 {
2451 // TODO:
2452 /*
2453 MINMAXINFO *info = (MINMAXINFO *)mmInfo;
2454
2455 bool rc = FALSE;
2456
2457 if ( m_minWidth != -1 )
2458 {
2459 info->ptMinTrackSize.x = m_minWidth;
2460 rc = TRUE;
2461 }
2462
2463 if ( m_minHeight != -1 )
2464 {
2465 info->ptMinTrackSize.y = m_minHeight;
2466 rc = TRUE;
2467 }
2468
2469 if ( m_maxWidth != -1 )
2470 {
2471 info->ptMaxTrackSize.x = m_maxWidth;
2472 rc = TRUE;
2473 }
2474
2475 if ( m_maxHeight != -1 )
2476 {
2477 info->ptMaxTrackSize.y = m_maxHeight;
2478 rc = TRUE;
2479 }
2480
2481 return rc;
2482 */
2483 return FALSE;
2484 }
2485
2486 // ---------------------------------------------------------------------------
2487 // command messages
2488 // ---------------------------------------------------------------------------
2489
2490 bool wxWindow::HandleCommand(WXWORD id, WXWORD cmd, WXHWND control)
2491 {
2492 if ( wxCurrentPopupMenu )
2493 {
2494 wxMenu *popupMenu = wxCurrentPopupMenu;
2495 wxCurrentPopupMenu = NULL;
2496
2497 return popupMenu->OS2Command(cmd, id);
2498 }
2499
2500 wxWindow *win = FindItem(id);
2501 if ( !win )
2502 {
2503 win = wxFindWinFromHandle(control);
2504 }
2505
2506 if ( win )
2507 return win->OS2Command(cmd, id);
2508
2509 return FALSE;
2510 }
2511
2512 bool wxWindow::HandleSysCommand(WXWPARAM wParam, WXLPARAM lParam)
2513 {
2514 // TODO:
2515 return FALSE;
2516 }
2517
2518 // ---------------------------------------------------------------------------
2519 // mouse events
2520 // ---------------------------------------------------------------------------
2521
2522 void wxWindow::InitMouseEvent(wxMouseEvent& event, int x, int y, WXUINT flags)
2523 {
2524 // TODO:
2525 /*
2526 event.m_x = x;
2527 event.m_y = y;
2528 event.m_shiftDown = ((flags & MK_SHIFT) != 0);
2529 event.m_controlDown = ((flags & MK_CONTROL) != 0);
2530 event.m_leftDown = ((flags & MK_LBUTTON) != 0);
2531 event.m_middleDown = ((flags & MK_MBUTTON) != 0);
2532 event.m_rightDown = ((flags & MK_RBUTTON) != 0);
2533 event.SetTimestamp(s_currentMsg.time);
2534 event.m_eventObject = this;
2535
2536 #if wxUSE_MOUSEEVENT_HACK
2537 m_lastMouseX = x;
2538 m_lastMouseY = y;
2539 m_lastMouseEvent = event.GetEventType();
2540 #endif // wxUSE_MOUSEEVENT_HACK
2541 */
2542 }
2543
2544 bool wxWindow::HandleMouseEvent(WXUINT msg, int x, int y, WXUINT flags)
2545 {
2546 // the mouse events take consecutive IDs from WM_MOUSEFIRST to
2547 // WM_MOUSELAST, so it's enough to substract WM_MOUSEMOVE == WM_MOUSEFIRST
2548 // from the message id and take the value in the table to get wxWin event
2549 // id
2550 static const wxEventType eventsMouse[] =
2551 {
2552 wxEVT_MOTION,
2553 wxEVT_LEFT_DOWN,
2554 wxEVT_LEFT_UP,
2555 wxEVT_LEFT_DCLICK,
2556 wxEVT_RIGHT_DOWN,
2557 wxEVT_RIGHT_UP,
2558 wxEVT_RIGHT_DCLICK,
2559 wxEVT_MIDDLE_DOWN,
2560 wxEVT_MIDDLE_UP,
2561 wxEVT_MIDDLE_DCLICK
2562 };
2563
2564 wxMouseEvent event(eventsMouse[msg - WM_MOUSEMOVE]);
2565 InitMouseEvent(event, x, y, flags);
2566
2567 return GetEventHandler()->ProcessEvent(event);
2568 }
2569
2570 bool wxWindow::HandleMouseMove(int x, int y, WXUINT flags)
2571 {
2572 if ( !m_bMouseInWindow )
2573 {
2574 // Generate an ENTER event
2575 m_bMouseInWindow = TRUE;
2576
2577 wxMouseEvent event(wxEVT_ENTER_WINDOW);
2578 InitMouseEvent(event, x, y, flags);
2579
2580 (void)GetEventHandler()->ProcessEvent(event);
2581 }
2582
2583 #if wxUSE_MOUSEEVENT_HACK
2584 // Window gets a click down message followed by a mouse move message even
2585 // if position isn't changed! We want to discard the trailing move event
2586 // if x and y are the same.
2587 if ( (m_lastMouseEvent == wxEVT_RIGHT_DOWN ||
2588 m_lastMouseEvent == wxEVT_LEFT_DOWN ||
2589 m_lastMouseEvent == wxEVT_MIDDLE_DOWN) &&
2590 (m_lastMouseX == event.m_x && m_lastMouseY == event.m_y) )
2591 {
2592 m_lastMouseEvent = wxEVT_MOTION;
2593
2594 return FALSE;
2595 }
2596 #endif // wxUSE_MOUSEEVENT_HACK
2597
2598 return HandleMouseEvent(WM_MOUSEMOVE, x, y, flags);
2599 }
2600
2601 // ---------------------------------------------------------------------------
2602 // keyboard handling
2603 // ---------------------------------------------------------------------------
2604
2605 // isASCII is TRUE only when we're called from WM_CHAR handler and not from
2606 // WM_KEYDOWN one
2607 bool wxWindow::HandleChar(WXWORD wParam, WXLPARAM lParam, bool isASCII)
2608 {
2609 // TODO:
2610 return FALSE;
2611 }
2612
2613 bool wxWindow::HandleKeyDown(WXWORD wParam, WXLPARAM lParam)
2614 {
2615 // TODO:
2616 return FALSE;
2617 }
2618
2619 bool wxWindow::HandleKeyUp(WXWORD wParam, WXLPARAM lParam)
2620 {
2621 // TODO:
2622 return FALSE;
2623 }
2624
2625 // ---------------------------------------------------------------------------
2626 // joystick
2627 // ---------------------------------------------------------------------------
2628
2629 bool wxWindow::HandleJoystickEvent(WXUINT msg, int x, int y, WXUINT flags)
2630 {
2631 // TODO:
2632 return FALSE;
2633 }
2634
2635 // ---------------------------------------------------------------------------
2636 // scrolling
2637 // ---------------------------------------------------------------------------
2638
2639 bool wxWindow::OS2OnScroll(int orientation, WXWORD wParam,
2640 WXWORD pos, WXHWND control)
2641 {
2642 if ( control )
2643 {
2644 wxWindow *child = wxFindWinFromHandle(control);
2645 if ( child )
2646 return child->OS2OnScroll(orientation, wParam, pos, control);
2647 }
2648
2649 wxScrollWinEvent event;
2650 event.SetPosition(pos);
2651 event.SetOrientation(orientation);
2652 event.m_eventObject = this;
2653 // TODO:
2654 return FALSE;
2655 }
2656
2657 // ===========================================================================
2658 // global functions
2659 // ===========================================================================
2660
2661 void wxGetCharSize(WXHWND wnd, int *x, int *y,wxFont *the_font)
2662 {
2663 // TODO:
2664 }
2665
2666 // Returns 0 if was a normal ASCII value, not a special key. This indicates that
2667 // the key should be ignored by WM_KEYDOWN and processed by WM_CHAR instead.
2668 int wxCharCodeOS2ToWX(int keySym)
2669 {
2670 int id = 0;
2671 // TODO:
2672 /*
2673 switch (keySym)
2674 {
2675 case VK_CANCEL: id = WXK_CANCEL; break;
2676 case VK_BACK: id = WXK_BACK; break;
2677 case VK_TAB: id = WXK_TAB; break;
2678 case VK_CLEAR: id = WXK_CLEAR; break;
2679 case VK_RETURN: id = WXK_RETURN; break;
2680 case VK_SHIFT: id = WXK_SHIFT; break;
2681 case VK_CONTROL: id = WXK_CONTROL; break;
2682 case VK_MENU : id = WXK_MENU; break;
2683 case VK_PAUSE: id = WXK_PAUSE; break;
2684 case VK_SPACE: id = WXK_SPACE; break;
2685 case VK_ESCAPE: id = WXK_ESCAPE; break;
2686 case VK_PRIOR: id = WXK_PRIOR; break;
2687 case VK_NEXT : id = WXK_NEXT; break;
2688 case VK_END: id = WXK_END; break;
2689 case VK_HOME : id = WXK_HOME; break;
2690 case VK_LEFT : id = WXK_LEFT; break;
2691 case VK_UP: id = WXK_UP; break;
2692 case VK_RIGHT: id = WXK_RIGHT; break;
2693 case VK_DOWN : id = WXK_DOWN; break;
2694 case VK_SELECT: id = WXK_SELECT; break;
2695 case VK_PRINT: id = WXK_PRINT; break;
2696 case VK_EXECUTE: id = WXK_EXECUTE; break;
2697 case VK_INSERT: id = WXK_INSERT; break;
2698 case VK_DELETE: id = WXK_DELETE; break;
2699 case VK_HELP : id = WXK_HELP; break;
2700 case VK_NUMPAD0: id = WXK_NUMPAD0; break;
2701 case VK_NUMPAD1: id = WXK_NUMPAD1; break;
2702 case VK_NUMPAD2: id = WXK_NUMPAD2; break;
2703 case VK_NUMPAD3: id = WXK_NUMPAD3; break;
2704 case VK_NUMPAD4: id = WXK_NUMPAD4; break;
2705 case VK_NUMPAD5: id = WXK_NUMPAD5; break;
2706 case VK_NUMPAD6: id = WXK_NUMPAD6; break;
2707 case VK_NUMPAD7: id = WXK_NUMPAD7; break;
2708 case VK_NUMPAD8: id = WXK_NUMPAD8; break;
2709 case VK_NUMPAD9: id = WXK_NUMPAD9; break;
2710 case VK_MULTIPLY: id = WXK_MULTIPLY; break;
2711 case VK_ADD: id = WXK_ADD; break;
2712 case VK_SUBTRACT: id = WXK_SUBTRACT; break;
2713 case VK_DECIMAL: id = WXK_DECIMAL; break;
2714 case VK_DIVIDE: id = WXK_DIVIDE; break;
2715 case VK_F1: id = WXK_F1; break;
2716 case VK_F2: id = WXK_F2; break;
2717 case VK_F3: id = WXK_F3; break;
2718 case VK_F4: id = WXK_F4; break;
2719 case VK_F5: id = WXK_F5; break;
2720 case VK_F6: id = WXK_F6; break;
2721 case VK_F7: id = WXK_F7; break;
2722 case VK_F8: id = WXK_F8; break;
2723 case VK_F9: id = WXK_F9; break;
2724 case VK_F10: id = WXK_F10; break;
2725 case VK_F11: id = WXK_F11; break;
2726 case VK_F12: id = WXK_F12; break;
2727 case VK_F13: id = WXK_F13; break;
2728 case VK_F14: id = WXK_F14; break;
2729 case VK_F15: id = WXK_F15; break;
2730 case VK_F16: id = WXK_F16; break;
2731 case VK_F17: id = WXK_F17; break;
2732 case VK_F18: id = WXK_F18; break;
2733 case VK_F19: id = WXK_F19; break;
2734 case VK_F20: id = WXK_F20; break;
2735 case VK_F21: id = WXK_F21; break;
2736 case VK_F22: id = WXK_F22; break;
2737 case VK_F23: id = WXK_F23; break;
2738 case VK_F24: id = WXK_F24; break;
2739 case VK_NUMLOCK: id = WXK_NUMLOCK; break;
2740 case VK_SCROLL: id = WXK_SCROLL; break;
2741 default:
2742 {
2743 return 0;
2744 }
2745 }
2746 */
2747 return id;
2748 }
2749
2750 int wxCharCodeWXToOS2(int id, bool *isVirtual)
2751 {
2752 *isVirtual = TRUE;
2753 int keySym = 0;
2754 // TODO
2755 /*
2756 switch (id)
2757 {
2758 case WXK_CANCEL: keySym = VK_CANCEL; break;
2759 case WXK_CLEAR: keySym = VK_CLEAR; break;
2760 case WXK_SHIFT: keySym = VK_SHIFT; break;
2761 case WXK_CONTROL: keySym = VK_CONTROL; break;
2762 case WXK_MENU : keySym = VK_MENU; break;
2763 case WXK_PAUSE: keySym = VK_PAUSE; break;
2764 case WXK_PRIOR: keySym = VK_PRIOR; break;
2765 case WXK_NEXT : keySym = VK_NEXT; break;
2766 case WXK_END: keySym = VK_END; break;
2767 case WXK_HOME : keySym = VK_HOME; break;
2768 case WXK_LEFT : keySym = VK_LEFT; break;
2769 case WXK_UP: keySym = VK_UP; break;
2770 case WXK_RIGHT: keySym = VK_RIGHT; break;
2771 case WXK_DOWN : keySym = VK_DOWN; break;
2772 case WXK_SELECT: keySym = VK_SELECT; break;
2773 case WXK_PRINT: keySym = VK_PRINT; break;
2774 case WXK_EXECUTE: keySym = VK_EXECUTE; break;
2775 case WXK_INSERT: keySym = VK_INSERT; break;
2776 case WXK_DELETE: keySym = VK_DELETE; break;
2777 case WXK_HELP : keySym = VK_HELP; break;
2778 case WXK_NUMPAD0: keySym = VK_NUMPAD0; break;
2779 case WXK_NUMPAD1: keySym = VK_NUMPAD1; break;
2780 case WXK_NUMPAD2: keySym = VK_NUMPAD2; break;
2781 case WXK_NUMPAD3: keySym = VK_NUMPAD3; break;
2782 case WXK_NUMPAD4: keySym = VK_NUMPAD4; break;
2783 case WXK_NUMPAD5: keySym = VK_NUMPAD5; break;
2784 case WXK_NUMPAD6: keySym = VK_NUMPAD6; break;
2785 case WXK_NUMPAD7: keySym = VK_NUMPAD7; break;
2786 case WXK_NUMPAD8: keySym = VK_NUMPAD8; break;
2787 case WXK_NUMPAD9: keySym = VK_NUMPAD9; break;
2788 case WXK_MULTIPLY: keySym = VK_MULTIPLY; break;
2789 case WXK_ADD: keySym = VK_ADD; break;
2790 case WXK_SUBTRACT: keySym = VK_SUBTRACT; break;
2791 case WXK_DECIMAL: keySym = VK_DECIMAL; break;
2792 case WXK_DIVIDE: keySym = VK_DIVIDE; break;
2793 case WXK_F1: keySym = VK_F1; break;
2794 case WXK_F2: keySym = VK_F2; break;
2795 case WXK_F3: keySym = VK_F3; break;
2796 case WXK_F4: keySym = VK_F4; break;
2797 case WXK_F5: keySym = VK_F5; break;
2798 case WXK_F6: keySym = VK_F6; break;
2799 case WXK_F7: keySym = VK_F7; break;
2800 case WXK_F8: keySym = VK_F8; break;
2801 case WXK_F9: keySym = VK_F9; break;
2802 case WXK_F10: keySym = VK_F10; break;
2803 case WXK_F11: keySym = VK_F11; break;
2804 case WXK_F12: keySym = VK_F12; break;
2805 case WXK_F13: keySym = VK_F13; break;
2806 case WXK_F14: keySym = VK_F14; break;
2807 case WXK_F15: keySym = VK_F15; break;
2808 case WXK_F16: keySym = VK_F16; break;
2809 case WXK_F17: keySym = VK_F17; break;
2810 case WXK_F18: keySym = VK_F18; break;
2811 case WXK_F19: keySym = VK_F19; break;
2812 case WXK_F20: keySym = VK_F20; break;
2813 case WXK_F21: keySym = VK_F21; break;
2814 case WXK_F22: keySym = VK_F22; break;
2815 case WXK_F23: keySym = VK_F23; break;
2816 case WXK_F24: keySym = VK_F24; break;
2817 case WXK_NUMLOCK: keySym = VK_NUMLOCK; break;
2818 case WXK_SCROLL: keySym = VK_SCROLL; break;
2819 default:
2820 {
2821 *isVirtual = FALSE;
2822 keySym = id;
2823 break;
2824 }
2825 }
2826 */
2827 return keySym;
2828 }
2829
2830 wxWindow *wxGetActiveWindow()
2831 {
2832 // TODO
2833 return NULL;
2834 }
2835
2836 // Windows keyboard hook. Allows interception of e.g. F1, ESCAPE
2837 // in active frames and dialogs, regardless of where the focus is.
2838 //static HHOOK wxTheKeyboardHook = 0;
2839 //static FARPROC wxTheKeyboardHookProc = 0;
2840 int wxKeyboardHook(int nCode, WORD wParam, DWORD lParam);
2841
2842 void wxSetKeyboardHook(bool doIt)
2843 {
2844 // TODO:
2845 }
2846
2847 int wxKeyboardHook(int nCode, WORD wParam, DWORD lParam)
2848 {
2849 // TODO:
2850
2851 return 0;
2852 }
2853
2854 #ifdef __WXDEBUG__
2855 const char *wxGetMessageName(int message)
2856 {
2857 // TODO
2858 /*
2859 switch ( message )
2860 {
2861 case 0x0000: return "WM_NULL";
2862 case 0x0001: return "WM_CREATE";
2863 case 0x0002: return "WM_DESTROY";
2864 case 0x0003: return "WM_MOVE";
2865 case 0x0005: return "WM_SIZE";
2866 case 0x0006: return "WM_ACTIVATE";
2867 case 0x0007: return "WM_SETFOCUS";
2868 case 0x0008: return "WM_KILLFOCUS";
2869 case 0x000A: return "WM_ENABLE";
2870 case 0x000B: return "WM_SETREDRAW";
2871 case 0x000C: return "WM_SETTEXT";
2872 case 0x000D: return "WM_GETTEXT";
2873 case 0x000E: return "WM_GETTEXTLENGTH";
2874 case 0x000F: return "WM_PAINT";
2875 case 0x0010: return "WM_CLOSE";
2876 case 0x0011: return "WM_QUERYENDSESSION";
2877 case 0x0012: return "WM_QUIT";
2878 case 0x0013: return "WM_QUERYOPEN";
2879 case 0x0014: return "WM_ERASEBKGND";
2880 case 0x0015: return "WM_SYSCOLORCHANGE";
2881 case 0x0016: return "WM_ENDSESSION";
2882 case 0x0017: return "WM_SYSTEMERROR";
2883 case 0x0018: return "WM_SHOWWINDOW";
2884 case 0x0019: return "WM_CTLCOLOR";
2885 case 0x001A: return "WM_WININICHANGE";
2886 case 0x001B: return "WM_DEVMODECHANGE";
2887 case 0x001C: return "WM_ACTIVATEAPP";
2888 case 0x001D: return "WM_FONTCHANGE";
2889 case 0x001E: return "WM_TIMECHANGE";
2890 case 0x001F: return "WM_CANCELMODE";
2891 case 0x0020: return "WM_SETCURSOR";
2892 case 0x0021: return "WM_MOUSEACTIVATE";
2893 case 0x0022: return "WM_CHILDACTIVATE";
2894 case 0x0023: return "WM_QUEUESYNC";
2895 case 0x0024: return "WM_GETMINMAXINFO";
2896 case 0x0026: return "WM_PAINTICON";
2897 case 0x0027: return "WM_ICONERASEBKGND";
2898 case 0x0028: return "WM_NEXTDLGCTL";
2899 case 0x002A: return "WM_SPOOLERSTATUS";
2900 case 0x002B: return "WM_DRAWITEM";
2901 case 0x002C: return "WM_MEASUREITEM";
2902 case 0x002D: return "WM_DELETEITEM";
2903 case 0x002E: return "WM_VKEYTOITEM";
2904 case 0x002F: return "WM_CHARTOITEM";
2905 case 0x0030: return "WM_SETFONT";
2906 case 0x0031: return "WM_GETFONT";
2907 case 0x0037: return "WM_QUERYDRAGICON";
2908 case 0x0039: return "WM_COMPAREITEM";
2909 case 0x0041: return "WM_COMPACTING";
2910 case 0x0044: return "WM_COMMNOTIFY";
2911 case 0x0046: return "WM_WINDOWPOSCHANGING";
2912 case 0x0047: return "WM_WINDOWPOSCHANGED";
2913 case 0x0048: return "WM_POWER";
2914
2915 #ifdef __WIN32__
2916 case 0x004A: return "WM_COPYDATA";
2917 case 0x004B: return "WM_CANCELJOURNAL";
2918 case 0x004E: return "WM_NOTIFY";
2919 case 0x0050: return "WM_INPUTLANGCHANGEREQUEST";
2920 case 0x0051: return "WM_INPUTLANGCHANGE";
2921 case 0x0052: return "WM_TCARD";
2922 case 0x0053: return "WM_HELP";
2923 case 0x0054: return "WM_USERCHANGED";
2924 case 0x0055: return "WM_NOTIFYFORMAT";
2925 case 0x007B: return "WM_CONTEXTMENU";
2926 case 0x007C: return "WM_STYLECHANGING";
2927 case 0x007D: return "WM_STYLECHANGED";
2928 case 0x007E: return "WM_DISPLAYCHANGE";
2929 case 0x007F: return "WM_GETICON";
2930 case 0x0080: return "WM_SETICON";
2931 #endif //WIN32
2932
2933 case 0x0081: return "WM_NCCREATE";
2934 case 0x0082: return "WM_NCDESTROY";
2935 case 0x0083: return "WM_NCCALCSIZE";
2936 case 0x0084: return "WM_NCHITTEST";
2937 case 0x0085: return "WM_NCPAINT";
2938 case 0x0086: return "WM_NCACTIVATE";
2939 case 0x0087: return "WM_GETDLGCODE";
2940 case 0x00A0: return "WM_NCMOUSEMOVE";
2941 case 0x00A1: return "WM_NCLBUTTONDOWN";
2942 case 0x00A2: return "WM_NCLBUTTONUP";
2943 case 0x00A3: return "WM_NCLBUTTONDBLCLK";
2944 case 0x00A4: return "WM_NCRBUTTONDOWN";
2945 case 0x00A5: return "WM_NCRBUTTONUP";
2946 case 0x00A6: return "WM_NCRBUTTONDBLCLK";
2947 case 0x00A7: return "WM_NCMBUTTONDOWN";
2948 case 0x00A8: return "WM_NCMBUTTONUP";
2949 case 0x00A9: return "WM_NCMBUTTONDBLCLK";
2950 case 0x0100: return "WM_KEYDOWN";
2951 case 0x0101: return "WM_KEYUP";
2952 case 0x0102: return "WM_CHAR";
2953 case 0x0103: return "WM_DEADCHAR";
2954 case 0x0104: return "WM_SYSKEYDOWN";
2955 case 0x0105: return "WM_SYSKEYUP";
2956 case 0x0106: return "WM_SYSCHAR";
2957 case 0x0107: return "WM_SYSDEADCHAR";
2958 case 0x0108: return "WM_KEYLAST";
2959
2960 #ifdef __WIN32__
2961 case 0x010D: return "WM_IME_STARTCOMPOSITION";
2962 case 0x010E: return "WM_IME_ENDCOMPOSITION";
2963 case 0x010F: return "WM_IME_COMPOSITION";
2964 #endif //WIN32
2965
2966 case 0x0110: return "WM_INITDIALOG";
2967 case 0x0111: return "WM_COMMAND";
2968 case 0x0112: return "WM_SYSCOMMAND";
2969 case 0x0113: return "WM_TIMER";
2970 case 0x0114: return "WM_HSCROLL";
2971 case 0x0115: return "WM_VSCROLL";
2972 case 0x0116: return "WM_INITMENU";
2973 case 0x0117: return "WM_INITMENUPOPUP";
2974 case 0x011F: return "WM_MENUSELECT";
2975 case 0x0120: return "WM_MENUCHAR";
2976 case 0x0121: return "WM_ENTERIDLE";
2977 case 0x0200: return "WM_MOUSEMOVE";
2978 case 0x0201: return "WM_LBUTTONDOWN";
2979 case 0x0202: return "WM_LBUTTONUP";
2980 case 0x0203: return "WM_LBUTTONDBLCLK";
2981 case 0x0204: return "WM_RBUTTONDOWN";
2982 case 0x0205: return "WM_RBUTTONUP";
2983 case 0x0206: return "WM_RBUTTONDBLCLK";
2984 case 0x0207: return "WM_MBUTTONDOWN";
2985 case 0x0208: return "WM_MBUTTONUP";
2986 case 0x0209: return "WM_MBUTTONDBLCLK";
2987 case 0x0210: return "WM_PARENTNOTIFY";
2988 case 0x0211: return "WM_ENTERMENULOOP";
2989 case 0x0212: return "WM_EXITMENULOOP";
2990
2991 #ifdef __WIN32__
2992 case 0x0213: return "WM_NEXTMENU";
2993 case 0x0214: return "WM_SIZING";
2994 case 0x0215: return "WM_CAPTURECHANGED";
2995 case 0x0216: return "WM_MOVING";
2996 case 0x0218: return "WM_POWERBROADCAST";
2997 case 0x0219: return "WM_DEVICECHANGE";
2998 #endif //WIN32
2999
3000 case 0x0220: return "WM_MDICREATE";
3001 case 0x0221: return "WM_MDIDESTROY";
3002 case 0x0222: return "WM_MDIACTIVATE";
3003 case 0x0223: return "WM_MDIRESTORE";
3004 case 0x0224: return "WM_MDINEXT";
3005 case 0x0225: return "WM_MDIMAXIMIZE";
3006 case 0x0226: return "WM_MDITILE";
3007 case 0x0227: return "WM_MDICASCADE";
3008 case 0x0228: return "WM_MDIICONARRANGE";
3009 case 0x0229: return "WM_MDIGETACTIVE";
3010 case 0x0230: return "WM_MDISETMENU";
3011 case 0x0233: return "WM_DROPFILES";
3012
3013 #ifdef __WIN32__
3014 case 0x0281: return "WM_IME_SETCONTEXT";
3015 case 0x0282: return "WM_IME_NOTIFY";
3016 case 0x0283: return "WM_IME_CONTROL";
3017 case 0x0284: return "WM_IME_COMPOSITIONFULL";
3018 case 0x0285: return "WM_IME_SELECT";
3019 case 0x0286: return "WM_IME_CHAR";
3020 case 0x0290: return "WM_IME_KEYDOWN";
3021 case 0x0291: return "WM_IME_KEYUP";
3022 #endif //WIN32
3023
3024 case 0x0300: return "WM_CUT";
3025 case 0x0301: return "WM_COPY";
3026 case 0x0302: return "WM_PASTE";
3027 case 0x0303: return "WM_CLEAR";
3028 case 0x0304: return "WM_UNDO";
3029 case 0x0305: return "WM_RENDERFORMAT";
3030 case 0x0306: return "WM_RENDERALLFORMATS";
3031 case 0x0307: return "WM_DESTROYCLIPBOARD";
3032 case 0x0308: return "WM_DRAWCLIPBOARD";
3033 case 0x0309: return "WM_PAINTCLIPBOARD";
3034 case 0x030A: return "WM_VSCROLLCLIPBOARD";
3035 case 0x030B: return "WM_SIZECLIPBOARD";
3036 case 0x030C: return "WM_ASKCBFORMATNAME";
3037 case 0x030D: return "WM_CHANGECBCHAIN";
3038 case 0x030E: return "WM_HSCROLLCLIPBOARD";
3039 case 0x030F: return "WM_QUERYNEWPALETTE";
3040 case 0x0310: return "WM_PALETTEISCHANGING";
3041 case 0x0311: return "WM_PALETTECHANGED";
3042
3043 #ifdef __WIN32__
3044 // common controls messages - although they're not strictly speaking
3045 // standard, it's nice to decode them nevertheless
3046
3047 // listview
3048 case 0x1000 + 0: return "LVM_GETBKCOLOR";
3049 case 0x1000 + 1: return "LVM_SETBKCOLOR";
3050 case 0x1000 + 2: return "LVM_GETIMAGELIST";
3051 case 0x1000 + 3: return "LVM_SETIMAGELIST";
3052 case 0x1000 + 4: return "LVM_GETITEMCOUNT";
3053 case 0x1000 + 5: return "LVM_GETITEMA";
3054 case 0x1000 + 75: return "LVM_GETITEMW";
3055 case 0x1000 + 6: return "LVM_SETITEMA";
3056 case 0x1000 + 76: return "LVM_SETITEMW";
3057 case 0x1000 + 7: return "LVM_INSERTITEMA";
3058 case 0x1000 + 77: return "LVM_INSERTITEMW";
3059 case 0x1000 + 8: return "LVM_DELETEITEM";
3060 case 0x1000 + 9: return "LVM_DELETEALLITEMS";
3061 case 0x1000 + 10: return "LVM_GETCALLBACKMASK";
3062 case 0x1000 + 11: return "LVM_SETCALLBACKMASK";
3063 case 0x1000 + 12: return "LVM_GETNEXTITEM";
3064 case 0x1000 + 13: return "LVM_FINDITEMA";
3065 case 0x1000 + 83: return "LVM_FINDITEMW";
3066 case 0x1000 + 14: return "LVM_GETITEMRECT";
3067 case 0x1000 + 15: return "LVM_SETITEMPOSITION";
3068 case 0x1000 + 16: return "LVM_GETITEMPOSITION";
3069 case 0x1000 + 17: return "LVM_GETSTRINGWIDTHA";
3070 case 0x1000 + 87: return "LVM_GETSTRINGWIDTHW";
3071 case 0x1000 + 18: return "LVM_HITTEST";
3072 case 0x1000 + 19: return "LVM_ENSUREVISIBLE";
3073 case 0x1000 + 20: return "LVM_SCROLL";
3074 case 0x1000 + 21: return "LVM_REDRAWITEMS";
3075 case 0x1000 + 22: return "LVM_ARRANGE";
3076 case 0x1000 + 23: return "LVM_EDITLABELA";
3077 case 0x1000 + 118: return "LVM_EDITLABELW";
3078 case 0x1000 + 24: return "LVM_GETEDITCONTROL";
3079 case 0x1000 + 25: return "LVM_GETCOLUMNA";
3080 case 0x1000 + 95: return "LVM_GETCOLUMNW";
3081 case 0x1000 + 26: return "LVM_SETCOLUMNA";
3082 case 0x1000 + 96: return "LVM_SETCOLUMNW";
3083 case 0x1000 + 27: return "LVM_INSERTCOLUMNA";
3084 case 0x1000 + 97: return "LVM_INSERTCOLUMNW";
3085 case 0x1000 + 28: return "LVM_DELETECOLUMN";
3086 case 0x1000 + 29: return "LVM_GETCOLUMNWIDTH";
3087 case 0x1000 + 30: return "LVM_SETCOLUMNWIDTH";
3088 case 0x1000 + 31: return "LVM_GETHEADER";
3089 case 0x1000 + 33: return "LVM_CREATEDRAGIMAGE";
3090 case 0x1000 + 34: return "LVM_GETVIEWRECT";
3091 case 0x1000 + 35: return "LVM_GETTEXTCOLOR";
3092 case 0x1000 + 36: return "LVM_SETTEXTCOLOR";
3093 case 0x1000 + 37: return "LVM_GETTEXTBKCOLOR";
3094 case 0x1000 + 38: return "LVM_SETTEXTBKCOLOR";
3095 case 0x1000 + 39: return "LVM_GETTOPINDEX";
3096 case 0x1000 + 40: return "LVM_GETCOUNTPERPAGE";
3097 case 0x1000 + 41: return "LVM_GETORIGIN";
3098 case 0x1000 + 42: return "LVM_UPDATE";
3099 case 0x1000 + 43: return "LVM_SETITEMSTATE";
3100 case 0x1000 + 44: return "LVM_GETITEMSTATE";
3101 case 0x1000 + 45: return "LVM_GETITEMTEXTA";
3102 case 0x1000 + 115: return "LVM_GETITEMTEXTW";
3103 case 0x1000 + 46: return "LVM_SETITEMTEXTA";
3104 case 0x1000 + 116: return "LVM_SETITEMTEXTW";
3105 case 0x1000 + 47: return "LVM_SETITEMCOUNT";
3106 case 0x1000 + 48: return "LVM_SORTITEMS";
3107 case 0x1000 + 49: return "LVM_SETITEMPOSITION32";
3108 case 0x1000 + 50: return "LVM_GETSELECTEDCOUNT";
3109 case 0x1000 + 51: return "LVM_GETITEMSPACING";
3110 case 0x1000 + 52: return "LVM_GETISEARCHSTRINGA";
3111 case 0x1000 + 117: return "LVM_GETISEARCHSTRINGW";
3112 case 0x1000 + 53: return "LVM_SETICONSPACING";
3113 case 0x1000 + 54: return "LVM_SETEXTENDEDLISTVIEWSTYLE";
3114 case 0x1000 + 55: return "LVM_GETEXTENDEDLISTVIEWSTYLE";
3115 case 0x1000 + 56: return "LVM_GETSUBITEMRECT";
3116 case 0x1000 + 57: return "LVM_SUBITEMHITTEST";
3117 case 0x1000 + 58: return "LVM_SETCOLUMNORDERARRAY";
3118 case 0x1000 + 59: return "LVM_GETCOLUMNORDERARRAY";
3119 case 0x1000 + 60: return "LVM_SETHOTITEM";
3120 case 0x1000 + 61: return "LVM_GETHOTITEM";
3121 case 0x1000 + 62: return "LVM_SETHOTCURSOR";
3122 case 0x1000 + 63: return "LVM_GETHOTCURSOR";
3123 case 0x1000 + 64: return "LVM_APPROXIMATEVIEWRECT";
3124 case 0x1000 + 65: return "LVM_SETWORKAREA";
3125
3126 // tree view
3127 case 0x1100 + 0: return "TVM_INSERTITEMA";
3128 case 0x1100 + 50: return "TVM_INSERTITEMW";
3129 case 0x1100 + 1: return "TVM_DELETEITEM";
3130 case 0x1100 + 2: return "TVM_EXPAND";
3131 case 0x1100 + 4: return "TVM_GETITEMRECT";
3132 case 0x1100 + 5: return "TVM_GETCOUNT";
3133 case 0x1100 + 6: return "TVM_GETINDENT";
3134 case 0x1100 + 7: return "TVM_SETINDENT";
3135 case 0x1100 + 8: return "TVM_GETIMAGELIST";
3136 case 0x1100 + 9: return "TVM_SETIMAGELIST";
3137 case 0x1100 + 10: return "TVM_GETNEXTITEM";
3138 case 0x1100 + 11: return "TVM_SELECTITEM";
3139 case 0x1100 + 12: return "TVM_GETITEMA";
3140 case 0x1100 + 62: return "TVM_GETITEMW";
3141 case 0x1100 + 13: return "TVM_SETITEMA";
3142 case 0x1100 + 63: return "TVM_SETITEMW";
3143 case 0x1100 + 14: return "TVM_EDITLABELA";
3144 case 0x1100 + 65: return "TVM_EDITLABELW";
3145 case 0x1100 + 15: return "TVM_GETEDITCONTROL";
3146 case 0x1100 + 16: return "TVM_GETVISIBLECOUNT";
3147 case 0x1100 + 17: return "TVM_HITTEST";
3148 case 0x1100 + 18: return "TVM_CREATEDRAGIMAGE";
3149 case 0x1100 + 19: return "TVM_SORTCHILDREN";
3150 case 0x1100 + 20: return "TVM_ENSUREVISIBLE";
3151 case 0x1100 + 21: return "TVM_SORTCHILDRENCB";
3152 case 0x1100 + 22: return "TVM_ENDEDITLABELNOW";
3153 case 0x1100 + 23: return "TVM_GETISEARCHSTRINGA";
3154 case 0x1100 + 64: return "TVM_GETISEARCHSTRINGW";
3155 case 0x1100 + 24: return "TVM_SETTOOLTIPS";
3156 case 0x1100 + 25: return "TVM_GETTOOLTIPS";
3157
3158 // header
3159 case 0x1200 + 0: return "HDM_GETITEMCOUNT";
3160 case 0x1200 + 1: return "HDM_INSERTITEMA";
3161 case 0x1200 + 10: return "HDM_INSERTITEMW";
3162 case 0x1200 + 2: return "HDM_DELETEITEM";
3163 case 0x1200 + 3: return "HDM_GETITEMA";
3164 case 0x1200 + 11: return "HDM_GETITEMW";
3165 case 0x1200 + 4: return "HDM_SETITEMA";
3166 case 0x1200 + 12: return "HDM_SETITEMW";
3167 case 0x1200 + 5: return "HDM_LAYOUT";
3168 case 0x1200 + 6: return "HDM_HITTEST";
3169 case 0x1200 + 7: return "HDM_GETITEMRECT";
3170 case 0x1200 + 8: return "HDM_SETIMAGELIST";
3171 case 0x1200 + 9: return "HDM_GETIMAGELIST";
3172 case 0x1200 + 15: return "HDM_ORDERTOINDEX";
3173 case 0x1200 + 16: return "HDM_CREATEDRAGIMAGE";
3174 case 0x1200 + 17: return "HDM_GETORDERARRAY";
3175 case 0x1200 + 18: return "HDM_SETORDERARRAY";
3176 case 0x1200 + 19: return "HDM_SETHOTDIVIDER";
3177
3178 // tab control
3179 case 0x1300 + 2: return "TCM_GETIMAGELIST";
3180 case 0x1300 + 3: return "TCM_SETIMAGELIST";
3181 case 0x1300 + 4: return "TCM_GETITEMCOUNT";
3182 case 0x1300 + 5: return "TCM_GETITEMA";
3183 case 0x1300 + 60: return "TCM_GETITEMW";
3184 case 0x1300 + 6: return "TCM_SETITEMA";
3185 case 0x1300 + 61: return "TCM_SETITEMW";
3186 case 0x1300 + 7: return "TCM_INSERTITEMA";
3187 case 0x1300 + 62: return "TCM_INSERTITEMW";
3188 case 0x1300 + 8: return "TCM_DELETEITEM";
3189 case 0x1300 + 9: return "TCM_DELETEALLITEMS";
3190 case 0x1300 + 10: return "TCM_GETITEMRECT";
3191 case 0x1300 + 11: return "TCM_GETCURSEL";
3192 case 0x1300 + 12: return "TCM_SETCURSEL";
3193 case 0x1300 + 13: return "TCM_HITTEST";
3194 case 0x1300 + 14: return "TCM_SETITEMEXTRA";
3195 case 0x1300 + 40: return "TCM_ADJUSTRECT";
3196 case 0x1300 + 41: return "TCM_SETITEMSIZE";
3197 case 0x1300 + 42: return "TCM_REMOVEIMAGE";
3198 case 0x1300 + 43: return "TCM_SETPADDING";
3199 case 0x1300 + 44: return "TCM_GETROWCOUNT";
3200 case 0x1300 + 45: return "TCM_GETTOOLTIPS";
3201 case 0x1300 + 46: return "TCM_SETTOOLTIPS";
3202 case 0x1300 + 47: return "TCM_GETCURFOCUS";
3203 case 0x1300 + 48: return "TCM_SETCURFOCUS";
3204 case 0x1300 + 49: return "TCM_SETMINTABWIDTH";
3205 case 0x1300 + 50: return "TCM_DESELECTALL";
3206
3207 // toolbar
3208 case WM_USER+1: return "TB_ENABLEBUTTON";
3209 case WM_USER+2: return "TB_CHECKBUTTON";
3210 case WM_USER+3: return "TB_PRESSBUTTON";
3211 case WM_USER+4: return "TB_HIDEBUTTON";
3212 case WM_USER+5: return "TB_INDETERMINATE";
3213 case WM_USER+9: return "TB_ISBUTTONENABLED";
3214 case WM_USER+10: return "TB_ISBUTTONCHECKED";
3215 case WM_USER+11: return "TB_ISBUTTONPRESSED";
3216 case WM_USER+12: return "TB_ISBUTTONHIDDEN";
3217 case WM_USER+13: return "TB_ISBUTTONINDETERMINATE";
3218 case WM_USER+17: return "TB_SETSTATE";
3219 case WM_USER+18: return "TB_GETSTATE";
3220 case WM_USER+19: return "TB_ADDBITMAP";
3221 case WM_USER+20: return "TB_ADDBUTTONS";
3222 case WM_USER+21: return "TB_INSERTBUTTON";
3223 case WM_USER+22: return "TB_DELETEBUTTON";
3224 case WM_USER+23: return "TB_GETBUTTON";
3225 case WM_USER+24: return "TB_BUTTONCOUNT";
3226 case WM_USER+25: return "TB_COMMANDTOINDEX";
3227 case WM_USER+26: return "TB_SAVERESTOREA";
3228 case WM_USER+76: return "TB_SAVERESTOREW";
3229 case WM_USER+27: return "TB_CUSTOMIZE";
3230 case WM_USER+28: return "TB_ADDSTRINGA";
3231 case WM_USER+77: return "TB_ADDSTRINGW";
3232 case WM_USER+29: return "TB_GETITEMRECT";
3233 case WM_USER+30: return "TB_BUTTONSTRUCTSIZE";
3234 case WM_USER+31: return "TB_SETBUTTONSIZE";
3235 case WM_USER+32: return "TB_SETBITMAPSIZE";
3236 case WM_USER+33: return "TB_AUTOSIZE";
3237 case WM_USER+35: return "TB_GETTOOLTIPS";
3238 case WM_USER+36: return "TB_SETTOOLTIPS";
3239 case WM_USER+37: return "TB_SETPARENT";
3240 case WM_USER+39: return "TB_SETROWS";
3241 case WM_USER+40: return "TB_GETROWS";
3242 case WM_USER+42: return "TB_SETCMDID";
3243 case WM_USER+43: return "TB_CHANGEBITMAP";
3244 case WM_USER+44: return "TB_GETBITMAP";
3245 case WM_USER+45: return "TB_GETBUTTONTEXTA";
3246 case WM_USER+75: return "TB_GETBUTTONTEXTW";
3247 case WM_USER+46: return "TB_REPLACEBITMAP";
3248 case WM_USER+47: return "TB_SETINDENT";
3249 case WM_USER+48: return "TB_SETIMAGELIST";
3250 case WM_USER+49: return "TB_GETIMAGELIST";
3251 case WM_USER+50: return "TB_LOADIMAGES";
3252 case WM_USER+51: return "TB_GETRECT";
3253 case WM_USER+52: return "TB_SETHOTIMAGELIST";
3254 case WM_USER+53: return "TB_GETHOTIMAGELIST";
3255 case WM_USER+54: return "TB_SETDISABLEDIMAGELIST";
3256 case WM_USER+55: return "TB_GETDISABLEDIMAGELIST";
3257 case WM_USER+56: return "TB_SETSTYLE";
3258 case WM_USER+57: return "TB_GETSTYLE";
3259 case WM_USER+58: return "TB_GETBUTTONSIZE";
3260 case WM_USER+59: return "TB_SETBUTTONWIDTH";
3261 case WM_USER+60: return "TB_SETMAXTEXTROWS";
3262 case WM_USER+61: return "TB_GETTEXTROWS";
3263 case WM_USER+41: return "TB_GETBITMAPFLAGS";
3264
3265 #endif //WIN32
3266
3267 default:
3268 static char s_szBuf[128];
3269 sprintf(s_szBuf, "<unknown message = %d>", message);
3270 return s_szBuf;
3271 }
3272 */
3273 return NULL;
3274 }
3275
3276 #endif // __WXDEBUG__
3277