]> git.saurik.com Git - wxWidgets.git/blob - src/os2/window.cpp
81250fb80f4d2284668e2f4e834c750632f4d0fc
[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(WXHWND hWnd)
706 {
707 HAB hab;
708 HWND hwnd = (HWND)hWnd;
709
710 wxASSERT_MSG( !m_fnOldWndProc, wxT("subclassing window twice?") );
711
712 /*
713 * TODO: implement something like this:
714 * wxCHECK_RET(::WinIsWindow(hab, hwnd), wxT("invalid HWND in SubclassWin") );
715 *
716 * wxAssociateWinWithHandle(hwnd, this);
717 *
718 * m_fnOldWndProc = (WXFARPROC) GetWindowLong(hwnd, GWL_WNDPROC);
719 * SetWindowLong(hwnd, GWL_WNDPROC, (LONG) wxWndProc);
720 */
721 }
722
723 void wxWindow::UnsubclassWin()
724 {
725 /*
726 * TODO:
727
728 wxRemoveHandleAssociation(this);
729
730 // Restore old Window proc
731 HWND hwnd = GetHwnd();
732 if ( hwnd )
733 {
734 m_hWnd = 0;
735
736 wxCHECK_RET( ::IsWindow(hwnd), wxT("invalid HWND in UnsubclassWin") );
737
738 FARPROC farProc = (FARPROC) GetWindowLong(hwnd, GWL_WNDPROC);
739 if ( (m_oldWndProc != 0) && (farProc != (FARPROC) m_oldWndProc) )
740 {
741 SetWindowLong(hwnd, GWL_WNDPROC, (LONG) m_oldWndProc);
742 m_oldWndProc = 0;
743 }
744 }
745 */
746 }
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 // Determines whether native 3D effects or CTL3D should be used,
764 // applying a default border style if required, and returning an extended
765 // style to pass to CreateWindowEx.
766 WXDWORD wxWindow::Determine3DEffects(WXDWORD defaultBorderStyle,
767 bool *want3D) const
768 {
769 DWORD exStyle = 0L; // remove after implementation doe
770 /* TODO: this ought to be fun
771 *
772 // If matches certain criteria, then assume no 3D effects
773 // unless specifically requested (dealt with in MakeExtendedStyle)
774 if ( !GetParent() || !IsKindOf(CLASSINFO(wxControl)) || (m_windowStyle & wxNO_BORDER) )
775 {
776 *want3D = FALSE;
777 return MakeExtendedStyle(m_windowStyle, FALSE);
778 }
779
780 // Determine whether we should be using 3D effects or not.
781 bool nativeBorder = FALSE; // by default, we don't want a Win95 effect
782
783 // 1) App can specify global 3D effects
784 *want3D = wxTheApp->GetAuto3D();
785
786 // 2) If the parent is being drawn with user colours, or simple border specified,
787 // switch effects off. TODO: replace wxUSER_COLOURS with wxNO_3D
788 if ( GetParent() && (GetParent()->GetWindowStyleFlag() & wxUSER_COLOURS) || (m_windowStyle & wxSIMPLE_BORDER) )
789 *want3D = FALSE;
790
791 // 3) Control can override this global setting by defining
792 // a border style, e.g. wxSUNKEN_BORDER
793 if ( m_windowStyle & wxSUNKEN_BORDER )
794 *want3D = TRUE;
795
796 // 4) If it's a special border, CTL3D can't cope so we want a native border
797 if ( (m_windowStyle & wxDOUBLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) ||
798 (m_windowStyle & wxSTATIC_BORDER) )
799 {
800 *want3D = TRUE;
801 nativeBorder = TRUE;
802 }
803
804 // 5) If this isn't a Win95 app, and we are using CTL3D, remove border
805 // effects from extended style
806 #if wxUSE_CTL3D
807 if ( *want3D )
808 nativeBorder = FALSE;
809 #endif
810
811 DWORD exStyle = MakeExtendedStyle(m_windowStyle, !nativeBorder);
812
813 // If we want 3D, but haven't specified a border here,
814 // apply the default border style specified.
815 // TODO what about non-Win95 WIN32? Does it have borders?
816 #if defined(__WIN95__) && !wxUSE_CTL3D
817 if ( defaultBorderStyle && (*want3D) && ! ((m_windowStyle & wxDOUBLE_BORDER) || (m_windowStyle & wxRAISED_BORDER ) ||
818 (m_windowStyle & wxSTATIC_BORDER) || (m_windowStyle & wxSIMPLE_BORDER) ))
819 exStyle |= defaultBorderStyle; // WS_EX_CLIENTEDGE;
820 #endif
821 */
822 return exStyle;
823 }
824
825 #if WXWIN_COMPATIBILITY
826 void wxWindow::OnCommand(wxWindow& win, wxCommandEvent& event)
827 {
828 // TODO:
829 }
830
831 wxObject* wxWindow::GetChild(int number) const
832 {
833 // TODO:
834 return((wxObject*)this);
835 }
836
837 void wxWindow::OnDefaultAction(wxControl *initiatingItem)
838 {
839 // TODO:
840 }
841
842 #endif // WXWIN_COMPATIBILITY
843
844 // Setup background and foreground colours correctly
845 void wxWindow::SetupColours()
846 {
847 if ( GetParent() )
848 SetBackgroundColour(GetParent()->GetBackgroundColour());
849 }
850
851 void wxWindow::OnIdle(wxIdleEvent& event)
852 {
853 // TODO:
854 }
855
856 // Set this window to be the child of 'parent'.
857 bool wxWindow::Reparent(wxWindow *parent)
858 {
859 if ( !wxWindowBase::Reparent(parent) )
860 return FALSE;
861 // TODO:
862 return FALSE;
863 }
864
865 void wxWindow::Clear()
866 {
867 // TODO:
868 }
869
870 void wxWindow::Refresh(bool eraseBack, const wxRect *rect)
871 {
872 // TODO:
873 }
874
875 // ---------------------------------------------------------------------------
876 // drag and drop
877 // ---------------------------------------------------------------------------
878
879 #if wxUSE_DRAG_AND_DROP
880 void wxWindow::SetDropTarget(wxDropTarget *pDropTarget)
881 {
882 // TODO:
883 }
884 #endif
885
886 // old style file-manager drag&drop support: we retain the old-style
887 // DragAcceptFiles in parallel with SetDropTarget.
888 void wxWindow::DragAcceptFiles(bool accept)
889 {
890 // TODO:
891 }
892
893 // ----------------------------------------------------------------------------
894 // tooltips
895 // ----------------------------------------------------------------------------
896
897 #if wxUSE_TOOLTIPS
898
899 void wxWindow::DoSetToolTip(wxToolTip *tooltip)
900 {
901 wxWindowBase::DoSetToolTip(tooltip);
902
903 if ( m_tooltip )
904 m_tooltip->SetWindow(this);
905 }
906
907 #endif // wxUSE_TOOLTIPS
908
909 // ---------------------------------------------------------------------------
910 // moving and resizing
911 // ---------------------------------------------------------------------------
912
913 // Get total size
914 void wxWindow::DoGetSize( int *width, int *height ) const
915 {
916 // TODO:
917 }
918
919 void wxWindow::DoGetPosition( int *x, int *y ) const
920 {
921 // TODO:
922 }
923
924 void wxWindow::DoScreenToClient( int *x, int *y ) const
925 {
926 // TODO:
927 }
928
929 void wxWindow::DoClientToScreen( int *x, int *y ) const
930 {
931 // TODO:
932 }
933
934 // Get size *available for subwindows* i.e. excluding menu bar etc.
935 void wxWindow::DoGetClientSize( int *width, int *height ) const
936 {
937 // TODO:
938 }
939
940 void wxWindow::DoMoveWindow(int x, int y, int width, int height)
941 {
942 // TODO:
943 }
944
945 // set the size of the window: if the dimensions are positive, just use them,
946 // but if any of them is equal to -1, it means that we must find the value for
947 // it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in
948 // which case -1 is a valid value for x and y)
949 //
950 // If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate
951 // the width/height to best suit our contents, otherwise we reuse the current
952 // width/height
953 void wxWindow::DoSetSize(int x, int y,
954 int width, int height,
955 int sizeFlags)
956 {
957 // TODO:
958 }
959
960 void wxWindow::DoSetClientSize(int width, int height)
961 {
962 // TODO:
963 }
964
965 wxPoint wxWindow::GetClientAreaOrigin() const
966 {
967 return wxPoint(0, 0);
968 }
969
970 void wxWindow::AdjustForParentClientOrigin(int& x, int& y, int sizeFlags)
971 {
972 // TODO:
973 }
974
975 // ---------------------------------------------------------------------------
976 // text metrics
977 // ---------------------------------------------------------------------------
978
979 int wxWindow::GetCharHeight() const
980 {
981 // TODO:
982 return(1);
983 }
984
985 int wxWindow::GetCharWidth() const
986 {
987 // TODO:
988 return(1);
989 }
990
991 void wxWindow::GetTextExtent( const wxString& string
992 ,int* x
993 ,int* y
994 ,int* descent
995 ,int* externalLeading
996 ,const wxFont* theFont
997 ) const
998 {
999 // TODO:
1000 }
1001
1002 #if wxUSE_CARET && WXWIN_COMPATIBILITY
1003 // ---------------------------------------------------------------------------
1004 // Caret manipulation
1005 // ---------------------------------------------------------------------------
1006
1007 void wxWindow::CreateCaret(int w, int h)
1008 {
1009 // TODO:
1010 }
1011
1012 void wxWindow::CreateCaret(const wxBitmap *bitmap)
1013 {
1014 // TODO:
1015 }
1016
1017 void wxWindow::ShowCaret(bool show)
1018 {
1019 // TODO:
1020 }
1021
1022 void wxWindow::DestroyCaret()
1023 {
1024 // TODO:
1025 }
1026
1027 void wxWindow::SetCaretPos(int x, int y)
1028 {
1029 // TODO:
1030 }
1031
1032 void wxWindow::GetCaretPos(int *x, int *y) const
1033 {
1034 // TODO:
1035 }
1036
1037 #endif //wxUSE_CARET
1038
1039 // ---------------------------------------------------------------------------
1040 // popup menu
1041 // ---------------------------------------------------------------------------
1042
1043 bool wxWindow::DoPopupMenu( wxMenu *menu, int x, int y )
1044 {
1045 // TODO:
1046 return(TRUE);
1047 }
1048
1049 // ===========================================================================
1050 // pre/post message processing
1051 // ===========================================================================
1052
1053 MRESULT wxWindow::OS2DefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
1054 {
1055 // TODO:
1056 return (MRESULT)0;
1057 }
1058
1059 bool wxWindow::OS2ProcessMessage(WXMSG* pMsg)
1060 {
1061 // TODO:
1062 return FALSE;
1063 }
1064
1065 bool wxWindow::OS2TranslateMessage(WXMSG* pMsg)
1066 {
1067 return m_acceleratorTable.Translate(this, pMsg);
1068 }
1069
1070 // ---------------------------------------------------------------------------
1071 // message params unpackers (different for Win16 and Win32)
1072 // ---------------------------------------------------------------------------
1073
1074 void wxWindow::UnpackCommand(WXWPARAM wParam, WXLPARAM lParam,
1075 WORD *id, WXHWND *hwnd, WORD *cmd)
1076 {
1077 *id = LOWORD(wParam);
1078 *hwnd = (WXHWND)lParam;
1079 *cmd = HIWORD(wParam);
1080 }
1081
1082 void wxWindow::UnpackActivate(WXWPARAM wParam, WXLPARAM lParam,
1083 WXWORD *state, WXWORD *minimized, WXHWND *hwnd)
1084 {
1085 *state = LOWORD(wParam);
1086 *minimized = HIWORD(wParam);
1087 *hwnd = (WXHWND)lParam;
1088 }
1089
1090 void wxWindow::UnpackScroll(WXWPARAM wParam, WXLPARAM lParam,
1091 WXWORD *code, WXWORD *pos, WXHWND *hwnd)
1092 {
1093 *code = LOWORD(wParam);
1094 *pos = HIWORD(wParam);
1095 *hwnd = (WXHWND)lParam;
1096 }
1097
1098 void wxWindow::UnpackCtlColor(WXWPARAM wParam, WXLPARAM lParam,
1099 WXWORD *nCtlColor, WXHDC *hdc, WXHWND *hwnd)
1100 {
1101 *nCtlColor = 0; // TODO: CTLCOLOR_BTN;
1102 *hwnd = (WXHWND)lParam;
1103 *hdc = (WXHDC)wParam;
1104 }
1105
1106 void wxWindow::UnpackMenuSelect(WXWPARAM wParam, WXLPARAM lParam,
1107 WXWORD *item, WXWORD *flags, WXHMENU *hmenu)
1108 {
1109 *item = (WXWORD)LOWORD(wParam);
1110 *flags = HIWORD(wParam);
1111 *hmenu = (WXHMENU)lParam;
1112 }
1113
1114 // ---------------------------------------------------------------------------
1115 // Main wxWindows window proc and the window proc for wxWindow
1116 // ---------------------------------------------------------------------------
1117
1118 // Hook for new window just as it's being created, when the window isn't yet
1119 // associated with the handle
1120 wxWindow *wxWndHook = NULL;
1121
1122 // Main window proc
1123 MRESULT wxWndProc(HWND hWnd, ULONG message, MPARAM wParam, MPARAM lParam)
1124 {
1125 // trace all messages - useful for the debugging
1126 #ifdef __WXDEBUG__
1127 wxLogTrace(wxTraceMessages, wxT("Processing %s(wParam=%8lx, lParam=%8lx)"),
1128 wxGetMessageName(message), wParam, lParam);
1129 #endif // __WXDEBUG__
1130
1131 wxWindow *wnd = wxFindWinFromHandle((WXHWND) hWnd);
1132
1133 // when we get the first message for the HWND we just created, we associate
1134 // it with wxWindow stored in wxWndHook
1135 if ( !wnd && wxWndHook )
1136 {
1137 #if 0 // def __WXDEBUG__
1138 char buf[512];
1139 ::GetClassNameA((HWND) hWnd, buf, 512);
1140 wxString className(buf);
1141 #endif
1142
1143 wxAssociateWinWithHandle(hWnd, wxWndHook);
1144 wnd = wxWndHook;
1145 wxWndHook = NULL;
1146 wnd->SetHWND((WXHWND)hWnd);
1147 }
1148
1149 MRESULT rc;
1150
1151 // Stop right here if we don't have a valid handle in our wxWindow object.
1152 if ( wnd && !wnd->GetHWND() )
1153 {
1154 // FIXME: why do we do this?
1155 wnd->SetHWND((WXHWND) hWnd);
1156 rc = wnd->OS2DefWindowProc(message, wParam, lParam );
1157 wnd->SetHWND(0);
1158 }
1159 else
1160 {
1161 if ( wnd )
1162 rc = wnd->OS2WindowProc(message, wParam, lParam);
1163 else
1164 rc = 0; //TODO: DefWindowProc( hWnd, message, wParam, lParam );
1165 }
1166
1167 return rc;
1168 }
1169
1170 MRESULT wxWindow::OS2WindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
1171 {
1172 // did we process the message?
1173 bool processed = FALSE;
1174
1175 // the return value
1176 union
1177 {
1178 bool allow;
1179 long result;
1180 WXHICON hIcon;
1181 WXHBRUSH hBrush;
1182 } rc;
1183
1184 // for most messages we should return 0 when we do process the message
1185 rc.result = 0;
1186 // TODO:
1187 /*
1188 switch ( message )
1189 {
1190 case WM_CREATE:
1191 {
1192 bool mayCreate;
1193 processed = HandleCreate((WXLPCREATESTRUCT)lParam, &mayCreate);
1194 if ( processed )
1195 {
1196 // return 0 to allow window creation
1197 rc.result = mayCreate ? 0 : -1;
1198 }
1199 }
1200 break;
1201
1202 case WM_DESTROY:
1203 processed = HandleDestroy();
1204 break;
1205
1206 case WM_MOVE:
1207 processed = HandleMove(LOWORD(lParam), HIWORD(lParam));
1208 break;
1209
1210 case WM_SIZE:
1211 processed = HandleSize(LOWORD(lParam), HIWORD(lParam), wParam);
1212 break;
1213
1214 case WM_ACTIVATE:
1215 {
1216 WXWORD state, minimized;
1217 WXHWND hwnd;
1218 UnpackActivate(wParam, lParam, &state, &minimized, &hwnd);
1219
1220 processed = HandleActivate(state, minimized != 0, (WXHWND)hwnd);
1221 }
1222 break;
1223
1224 case WM_SETFOCUS:
1225 processed = HandleSetFocus((WXHWND)(HWND)wParam);
1226 break;
1227
1228 case WM_KILLFOCUS:
1229 processed = HandleKillFocus((WXHWND)(HWND)wParam);
1230 break;
1231
1232 case WM_PAINT:
1233 processed = HandlePaint();
1234 break;
1235
1236 case WM_CLOSE:
1237 // don't let the DefWindowProc() destroy our window - we'll do it
1238 // ourselves in ~wxWindow
1239 processed = TRUE;
1240 rc.result = TRUE;
1241 break;
1242
1243 case WM_SHOWWINDOW:
1244 processed = HandleShow(wParam != 0, (int)lParam);
1245 break;
1246
1247 case WM_MOUSEMOVE:
1248 case WM_LBUTTONDOWN:
1249 case WM_LBUTTONUP:
1250 case WM_LBUTTONDBLCLK:
1251 case WM_RBUTTONDOWN:
1252 case WM_RBUTTONUP:
1253 case WM_RBUTTONDBLCLK:
1254 case WM_MBUTTONDOWN:
1255 case WM_MBUTTONUP:
1256 case WM_MBUTTONDBLCLK:
1257 {
1258 short x = LOWORD(lParam);
1259 short y = HIWORD(lParam);
1260
1261 processed = HandleMouseEvent(message, x, y, wParam);
1262 }
1263 break;
1264
1265 case MM_JOY1MOVE:
1266 case MM_JOY2MOVE:
1267 case MM_JOY1ZMOVE:
1268 case MM_JOY2ZMOVE:
1269 case MM_JOY1BUTTONDOWN:
1270 case MM_JOY2BUTTONDOWN:
1271 case MM_JOY1BUTTONUP:
1272 case MM_JOY2BUTTONUP:
1273 {
1274 int x = LOWORD(lParam);
1275 int y = HIWORD(lParam);
1276
1277 processed = HandleJoystickEvent(message, x, y, wParam);
1278 }
1279 break;
1280
1281 case WM_SYSCOMMAND:
1282 processed = HandleSysCommand(wParam, lParam);
1283 break;
1284
1285 case WM_COMMAND:
1286 {
1287 WORD id, cmd;
1288 WXHWND hwnd;
1289 UnpackCommand(wParam, lParam, &id, &hwnd, &cmd);
1290
1291 processed = HandleCommand(id, cmd, hwnd);
1292 }
1293 break;
1294
1295 #ifdef __WIN95__
1296 case WM_NOTIFY:
1297 processed = HandleNotify((int)wParam, lParam, &rc.result);
1298 break;
1299 #endif // Win95
1300
1301 // for these messages we must return TRUE if process the message
1302 case WM_DRAWITEM:
1303 case WM_MEASUREITEM:
1304 {
1305 int idCtrl = (UINT)wParam;
1306 if ( message == WM_DRAWITEM )
1307 {
1308 processed = MSWOnDrawItem(idCtrl,
1309 (WXDRAWITEMSTRUCT *)lParam);
1310 }
1311 else
1312 {
1313 processed = MSWOnMeasureItem(idCtrl,
1314 (WXMEASUREITEMSTRUCT *)lParam);
1315 }
1316
1317 if ( processed )
1318 rc.result = TRUE;
1319 }
1320 break;
1321
1322 case WM_GETDLGCODE:
1323 if ( m_lDlgCode )
1324 {
1325 rc.result = m_lDlgCode;
1326 processed = TRUE;
1327 }
1328 //else: get the dlg code from the DefWindowProc()
1329 break;
1330
1331 case WM_KEYDOWN:
1332 // If this has been processed by an event handler,
1333 // return 0 now (we've handled it).
1334 if ( HandleKeyDown((WORD) wParam, lParam) )
1335 {
1336 processed = TRUE;
1337
1338 break;
1339 }
1340
1341 // we consider these message "not interesting" to OnChar
1342 if ( wParam == VK_SHIFT || wParam == VK_CONTROL )
1343 {
1344 processed = TRUE;
1345
1346 break;
1347 }
1348
1349 switch ( wParam )
1350 {
1351 // avoid duplicate messages to OnChar for these ASCII keys: they
1352 // will be translated by TranslateMessage() and received in WM_CHAR
1353 case VK_ESCAPE:
1354 case VK_SPACE:
1355 case VK_RETURN:
1356 case VK_BACK:
1357 case VK_TAB:
1358 // but set processed to FALSE, not TRUE to still pass them to
1359 // the control's default window proc - otherwise built-in
1360 // keyboard handling won't work
1361 processed = FALSE;
1362
1363 break;
1364
1365 #ifdef VK_APPS
1366 // special case of VK_APPS: treat it the same as right mouse
1367 // click because both usually pop up a context menu
1368 case VK_APPS:
1369 {
1370 // construct the key mask
1371 WPARAM fwKeys = MK_RBUTTON;
1372 if ( (::GetKeyState(VK_CONTROL) & 0x100) != 0 )
1373 fwKeys |= MK_CONTROL;
1374 if ( (::GetKeyState(VK_SHIFT) & 0x100) != 0 )
1375 fwKeys |= MK_SHIFT;
1376
1377 // simulate right mouse button click
1378 DWORD dwPos = ::GetMessagePos();
1379 int x = GET_X_LPARAM(dwPos),
1380 y = GET_Y_LPARAM(dwPos);
1381
1382 ScreenToClient(&x, &y);
1383 processed = HandleMouseEvent(WM_RBUTTONDOWN, x, y, fwKeys);
1384 }
1385 break;
1386 #endif // VK_APPS
1387
1388 case VK_LEFT:
1389 case VK_RIGHT:
1390 case VK_DOWN:
1391 case VK_UP:
1392 default:
1393 processed = HandleChar((WORD)wParam, lParam);
1394 }
1395 break;
1396
1397 case WM_KEYUP:
1398 processed = HandleKeyUp((WORD) wParam, lParam);
1399 break;
1400
1401 case WM_CHAR: // Always an ASCII character
1402 processed = HandleChar((WORD)wParam, lParam, TRUE);
1403 break;
1404
1405 case WM_HSCROLL:
1406 case WM_VSCROLL:
1407 {
1408 WXWORD code, pos;
1409 WXHWND hwnd;
1410 UnpackScroll(wParam, lParam, &code, &pos, &hwnd);
1411
1412 processed = MSWOnScroll(message == WM_HSCROLL ? wxHORIZONTAL
1413 : wxVERTICAL,
1414 code, pos, hwnd);
1415 }
1416 break;
1417
1418 // CTLCOLOR messages are sent by children to query the parent for their
1419 // colors
1420 #ifdef __WIN32__
1421 case WM_CTLCOLORMSGBOX:
1422 case WM_CTLCOLOREDIT:
1423 case WM_CTLCOLORLISTBOX:
1424 case WM_CTLCOLORBTN:
1425 case WM_CTLCOLORDLG:
1426 case WM_CTLCOLORSCROLLBAR:
1427 case WM_CTLCOLORSTATIC:
1428 #else // Win16
1429 case WM_CTLCOLOR:
1430 #endif // Win32/16
1431 {
1432 WXWORD nCtlColor;
1433 WXHDC hdc;
1434 WXHWND hwnd;
1435 UnpackCtlColor(wParam, lParam, &nCtlColor, &hdc, &hwnd);
1436
1437 processed = HandleCtlColor(&rc.hBrush,
1438 (WXHDC)hdc,
1439 (WXHWND)hwnd,
1440 nCtlColor,
1441 message,
1442 wParam,
1443 lParam);
1444 }
1445 break;
1446
1447 // the return value for this message is ignored
1448 case WM_SYSCOLORCHANGE:
1449 processed = HandleSysColorChange();
1450 break;
1451
1452 case WM_PALETTECHANGED:
1453 processed = HandlePaletteChanged((WXHWND) (HWND) wParam);
1454 break;
1455
1456 case WM_QUERYNEWPALETTE:
1457 processed = HandleQueryNewPalette();
1458 break;
1459
1460 case WM_ERASEBKGND:
1461 processed = HandleEraseBkgnd((WXHDC)(HDC)wParam);
1462 if ( processed )
1463 {
1464 // we processed the message, i.e. erased the background
1465 rc.result = TRUE;
1466 }
1467 break;
1468
1469 case WM_DROPFILES:
1470 processed = HandleDropFiles(wParam);
1471 break;
1472
1473 case WM_INITDIALOG:
1474 processed = HandleInitDialog((WXHWND)(HWND)wParam);
1475
1476 if ( processed )
1477 {
1478 // we never set focus from here
1479 rc.result = FALSE;
1480 }
1481 break;
1482
1483 case WM_QUERYENDSESSION:
1484 processed = HandleQueryEndSession(lParam, &rc.allow);
1485 break;
1486
1487 case WM_ENDSESSION:
1488 processed = HandleEndSession(wParam != 0, lParam);
1489 break;
1490
1491 case WM_GETMINMAXINFO:
1492 processed = HandleGetMinMaxInfo((MINMAXINFO*)lParam);
1493 break;
1494
1495 case WM_SETCURSOR:
1496 processed = HandleSetCursor((WXHWND)(HWND)wParam,
1497 LOWORD(lParam), // hit test
1498 HIWORD(lParam)); // mouse msg
1499
1500 if ( processed )
1501 {
1502 // returning TRUE stops the DefWindowProc() from further
1503 // processing this message - exactly what we need because we've
1504 // just set the cursor.
1505 rc.result = TRUE;
1506 }
1507 break;
1508 }
1509
1510 if ( !processed )
1511 {
1512 #ifdef __WXDEBUG__
1513 wxLogTrace(wxTraceMessages, wxT("Forwarding %s to DefWindowProc."),
1514 wxGetMessageName(message));
1515 #endif // __WXDEBUG__
1516 rc.result = MSWDefWindowProc(message, wParam, lParam);
1517 }
1518 */
1519 return (MRESULT)0;
1520 }
1521
1522 // Dialog window proc
1523 MRESULT wxDlgProc(HWND hWnd, UINT message, MPARAM wParam, MPARAM lParam)
1524 {
1525 // TODO:
1526 /*
1527 if ( message == WM_INITDIALOG )
1528 {
1529 // for this message, returning TRUE tells system to set focus to the
1530 // first control in the dialog box
1531 return TRUE;
1532 }
1533 else
1534 {
1535 // for all the other ones, FALSE means that we didn't process the
1536 // message
1537 return 0;
1538 }
1539 */
1540 return (MRESULT)0;
1541 }
1542
1543 wxWindow *wxFindWinFromHandle(WXHWND hWnd)
1544 {
1545 wxNode *node = wxWinHandleList->Find((long)hWnd);
1546 if ( !node )
1547 return NULL;
1548 return (wxWindow *)node->Data();
1549 }
1550
1551 void wxAssociateWinWithHandle(HWND hWnd, wxWindow *win)
1552 {
1553 // adding NULL hWnd is (first) surely a result of an error and
1554 // (secondly) breaks menu command processing
1555 wxCHECK_RET( hWnd != (HWND)NULL,
1556 wxT("attempt to add a NULL hWnd to window list ignored") );
1557
1558
1559 wxWindow *oldWin = wxFindWinFromHandle((WXHWND) hWnd);
1560 if ( oldWin && (oldWin != win) )
1561 {
1562 wxString str(win->GetClassInfo()->GetClassName());
1563 wxLogError("Bug! Found existing HWND %X for new window of class %s", (int) hWnd, (const char*) str);
1564 }
1565 else if (!oldWin)
1566 {
1567 wxWinHandleList->Append((long)hWnd, win);
1568 }
1569 }
1570
1571 void wxRemoveHandleAssociation(wxWindow *win)
1572 {
1573 wxWinHandleList->DeleteObject(win);
1574 }
1575
1576 // Default destroyer - override if you destroy it in some other way
1577 // (e.g. with MDI child windows)
1578 void wxWindow::OS2DestroyWindow()
1579 {
1580 }
1581
1582 void wxWindow::OS2DetachWindowMenu()
1583 {
1584 if ( m_hMenu )
1585 {
1586 HMENU hMenu = (HMENU)m_hMenu;
1587
1588 int N = (int)WinSendMsg(hMenu, MM_QUERYITEMCOUNT, 0, 0);
1589 int i;
1590 for (i = 0; i < N; i++)
1591 {
1592 wxChar buf[100];
1593 int chars = (int)WinSendMsg(hMenu, MM_QUERYITEMTEXT, MPFROM2SHORT(i, N), buf);
1594 if ( !chars )
1595 {
1596 wxLogLastError(wxT("GetMenuString"));
1597
1598 continue;
1599 }
1600
1601 if ( wxStrcmp(buf, wxT("&Window")) == 0 )
1602 {
1603 WinSendMsg(hMenu, MM_DELETEITEM, MPFROM2SHORT(i, TRUE), 0);
1604 break;
1605 }
1606 }
1607 }
1608 }
1609
1610 bool wxWindow::OS2Create(int id,
1611 wxWindow *parent,
1612 const wxChar *wclass,
1613 wxWindow *wx_win,
1614 const wxChar *title,
1615 int x,
1616 int y,
1617 int width,
1618 int height,
1619 WXDWORD style,
1620 const wxChar *dialog_template,
1621 WXDWORD extendedStyle)
1622 {
1623 // TODO:
1624 /*
1625 int x1 = CW_USEDEFAULT;
1626 int y1 = 0;
1627 int width1 = CW_USEDEFAULT;
1628 int height1 = 100;
1629
1630 // Find parent's size, if it exists, to set up a possible default
1631 // panel size the size of the parent window
1632 RECT parent_rect;
1633 if ( parent )
1634 {
1635 ::GetClientRect((HWND) parent->GetHWND(), &parent_rect);
1636
1637 width1 = parent_rect.right - parent_rect.left;
1638 height1 = parent_rect.bottom - parent_rect.top;
1639 }
1640
1641 if ( x > -1 ) x1 = x;
1642 if ( y > -1 ) y1 = y;
1643 if ( width > -1 ) width1 = width;
1644 if ( height > -1 ) height1 = height;
1645
1646 HWND hParent = (HWND)NULL;
1647 if ( parent )
1648 hParent = (HWND) parent->GetHWND();
1649
1650 wxWndHook = this;
1651
1652 if ( dialog_template )
1653 {
1654 m_hWnd = (WXHWND)::CreateDialog(wxGetInstance(),
1655 dialog_template,
1656 hParent,
1657 (DLGPROC)wxDlgProc);
1658
1659 if ( m_hWnd == 0 )
1660 {
1661 wxLogError(_("Can't find dummy dialog template!\n"
1662 "Check resource include path for finding wx.rc."));
1663
1664 return FALSE;
1665 }
1666
1667 // ::SetWindowLong(GWL_EXSTYLE) doesn't work for the dialogs, so try
1668 // to take care of (at least some) extended style flags ourselves
1669 if ( extendedStyle & WS_EX_TOPMOST )
1670 {
1671 if ( !::SetWindowPos(GetHwnd(), HWND_TOPMOST, 0, 0, 0, 0,
1672 SWP_NOSIZE | SWP_NOMOVE) )
1673 {
1674 wxLogLastError(wxT("SetWindowPos"));
1675 }
1676 }
1677
1678 // move the dialog to its initial position without forcing repainting
1679 if ( !::MoveWindow(GetHwnd(), x1, y1, width1, height1, FALSE) )
1680 {
1681 wxLogLastError(wxT("MoveWindow"));
1682 }
1683 }
1684 else
1685 {
1686 int controlId = 0;
1687 if ( style & WS_CHILD )
1688 controlId = id;
1689
1690 wxString className(wclass);
1691 if ( GetWindowStyleFlag() & wxNO_FULL_REPAINT_ON_RESIZE )
1692 {
1693 className += wxT("NR");
1694 }
1695
1696 m_hWnd = (WXHWND)CreateWindowEx(extendedStyle,
1697 className,
1698 title ? title : wxT(""),
1699 style,
1700 x1, y1,
1701 width1, height1,
1702 hParent, (HMENU)controlId,
1703 wxGetInstance(),
1704 NULL);
1705
1706 if ( !m_hWnd )
1707 {
1708 wxLogError(_("Can't create window of class %s!\n"
1709 "Possible Windows 3.x compatibility problem?"),
1710 wclass);
1711
1712 return FALSE;
1713 }
1714 }
1715
1716 wxWndHook = NULL;
1717 #ifdef __WXDEBUG__
1718 wxNode* node = wxWinHandleList->Member(this);
1719 if (node)
1720 {
1721 HWND hWnd = (HWND) node->GetKeyInteger();
1722 if (hWnd != (HWND) m_hWnd)
1723 {
1724 wxLogError("A second HWND association is being added for the same window!");
1725 }
1726 }
1727 #endif
1728 */
1729 wxAssociateWinWithHandle((HWND) m_hWnd, this);
1730
1731 return TRUE;
1732 }
1733
1734 // ===========================================================================
1735 // OS2 PM message handlers
1736 // ===========================================================================
1737
1738 // ---------------------------------------------------------------------------
1739 // WM_NOTIFY
1740 // ---------------------------------------------------------------------------
1741
1742 bool wxWindow::HandleNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
1743 {
1744 // TODO:
1745 return FALSE;
1746 }
1747
1748 bool wxWindow::OS2OnNotify(int WXUNUSED(idCtrl),
1749 WXLPARAM lParam,
1750 WXLPARAM* WXUNUSED(result))
1751 {
1752 // TODO:
1753 return FALSE;
1754 }
1755
1756 // ---------------------------------------------------------------------------
1757 // end session messages
1758 // ---------------------------------------------------------------------------
1759
1760 bool wxWindow::HandleQueryEndSession(long logOff, bool *mayEnd)
1761 {
1762 wxCloseEvent event(wxEVT_QUERY_END_SESSION, -1);
1763 event.SetEventObject(wxTheApp);
1764 event.SetCanVeto(TRUE);
1765 event.SetLoggingOff(logOff == ENDSESSION_LOGOFF);
1766
1767 bool rc = wxTheApp->ProcessEvent(event);
1768
1769 if ( rc )
1770 {
1771 // we may end only if the app didn't veto session closing (double
1772 // negation...)
1773 *mayEnd = !event.GetVeto();
1774 }
1775
1776 return rc;
1777 }
1778
1779 bool wxWindow::HandleEndSession(bool endSession, long logOff)
1780 {
1781 // do nothing if the session isn't ending
1782 if ( !endSession )
1783 return FALSE;
1784
1785 wxCloseEvent event(wxEVT_END_SESSION, -1);
1786 event.SetEventObject(wxTheApp);
1787 event.SetCanVeto(FALSE);
1788 event.SetLoggingOff( (logOff == ENDSESSION_LOGOFF) );
1789 if ( (this == wxTheApp->GetTopWindow()) && // Only send once
1790 wxTheApp->ProcessEvent(event))
1791 {
1792 }
1793 return TRUE;
1794 }
1795
1796 // ---------------------------------------------------------------------------
1797 // window creation/destruction
1798 // ---------------------------------------------------------------------------
1799
1800 bool wxWindow::HandleCreate(WXLPCREATESTRUCT cs, bool *mayCreate)
1801 {
1802 // TODO: should generate this event from WM_NCCREATE
1803 wxWindowCreateEvent event(this);
1804 (void)GetEventHandler()->ProcessEvent(event);
1805
1806 *mayCreate = TRUE;
1807
1808 return TRUE;
1809 }
1810
1811 bool wxWindow::HandleDestroy()
1812 {
1813 wxWindowDestroyEvent event(this);
1814 (void)GetEventHandler()->ProcessEvent(event);
1815
1816 // delete our drop target if we've got one
1817 #if wxUSE_DRAG_AND_DROP
1818 if ( m_dropTarget != NULL )
1819 {
1820 // m_dropTarget->Revoke(m_hWnd);
1821
1822 delete m_dropTarget;
1823 m_dropTarget = NULL;
1824 }
1825 #endif // wxUSE_DRAG_AND_DROP
1826
1827 // WM_DESTROY handled
1828 return TRUE;
1829 }
1830
1831 // ---------------------------------------------------------------------------
1832 // activation/focus
1833 // ---------------------------------------------------------------------------
1834
1835 bool wxWindow::HandleActivate(int state,
1836 bool WXUNUSED(minimized),
1837 WXHWND WXUNUSED(activate))
1838 {
1839 // TODO:
1840 /*
1841 wxActivateEvent event(wxEVT_ACTIVATE,
1842 (state == WA_ACTIVE) || (state == WA_CLICKACTIVE),
1843 m_windowId);
1844 event.SetEventObject(this);
1845
1846 return GetEventHandler()->ProcessEvent(event);
1847 */
1848 return FALSE;
1849 }
1850
1851 bool wxWindow::HandleSetFocus(WXHWND WXUNUSED(hwnd))
1852 {
1853 #if wxUSE_CARET
1854 // Deal with caret
1855 if ( m_caret )
1856 {
1857 m_caret->OnSetFocus();
1858 }
1859 #endif // wxUSE_CARET
1860
1861 // panel wants to track the window which was the last to have focus in it
1862 wxPanel *panel = wxDynamicCast(GetParent(), wxPanel);
1863 if ( panel )
1864 {
1865 panel->SetLastFocus(this);
1866 }
1867
1868 wxFocusEvent event(wxEVT_SET_FOCUS, m_windowId);
1869 event.SetEventObject(this);
1870
1871 return GetEventHandler()->ProcessEvent(event);
1872 }
1873
1874 bool wxWindow::HandleKillFocus(WXHWND WXUNUSED(hwnd))
1875 {
1876 #if wxUSE_CARET
1877 // Deal with caret
1878 if ( m_caret )
1879 {
1880 m_caret->OnKillFocus();
1881 }
1882 #endif // wxUSE_CARET
1883
1884 wxFocusEvent event(wxEVT_KILL_FOCUS, m_windowId);
1885 event.SetEventObject(this);
1886
1887 return GetEventHandler()->ProcessEvent(event);
1888 }
1889
1890 // ---------------------------------------------------------------------------
1891 // miscellaneous
1892 // ---------------------------------------------------------------------------
1893
1894 bool wxWindow::HandleShow(bool show, int status)
1895 {
1896 wxShowEvent event(GetId(), show);
1897 event.m_eventObject = this;
1898
1899 return GetEventHandler()->ProcessEvent(event);
1900 }
1901
1902 bool wxWindow::HandleInitDialog(WXHWND WXUNUSED(hWndFocus))
1903 {
1904 wxInitDialogEvent event(GetId());
1905 event.m_eventObject = this;
1906
1907 return GetEventHandler()->ProcessEvent(event);
1908 }
1909
1910 bool wxWindow::HandleDropFiles(WXWPARAM wParam)
1911 {
1912 // TODO:
1913 return FALSE;
1914 }
1915
1916 bool wxWindow::HandleSetCursor(WXHWND hWnd,
1917 short nHitTest,
1918 int WXUNUSED(mouseMsg))
1919 {
1920 // don't set cursor for other windows, only for this one: this prevents
1921 // children of this window from getting the same cursor as the parent has
1922 // (don't forget that this message is propagated by default up the window
1923 // parent-child hierarchy)
1924 if ( GetHWND() == hWnd )
1925 {
1926 // don't set cursor when the mouse is not in the client part
1927 // TODO
1928 /*
1929 if ( nHitTest == HTCLIENT || nHitTest == HTERROR )
1930 {
1931 HCURSOR hcursor = 0;
1932 if ( wxIsBusy() )
1933 {
1934 // from msw\utils.cpp
1935 extern HCURSOR gs_wxBusyCursor;
1936
1937 hcursor = gs_wxBusyCursor;
1938 }
1939 else
1940 {
1941 wxCursor *cursor = NULL;
1942
1943 if ( m_cursor.Ok() )
1944 {
1945 cursor = &m_cursor;
1946 }
1947 else
1948 {
1949 // from msw\data.cpp
1950 extern wxCursor *g_globalCursor;
1951
1952 if ( g_globalCursor && g_globalCursor->Ok() )
1953 cursor = g_globalCursor;
1954 }
1955
1956 if ( cursor )
1957 hcursor = (HCURSOR)cursor->GetHCURSOR();
1958 }
1959
1960 if ( hcursor )
1961 {
1962 // ::SetCursor(hcursor);
1963
1964 return TRUE;
1965 }
1966 }
1967 */
1968 }
1969
1970 return FALSE;
1971 }
1972
1973 // ---------------------------------------------------------------------------
1974 // owner drawn stuff
1975 // ---------------------------------------------------------------------------
1976
1977 bool wxWindow::OS2OnDrawItem(int id, WXDRAWITEMSTRUCT *itemStruct)
1978 {
1979 // TODO:
1980 /*
1981 #if wxUSE_OWNER_DRAWN
1982 // is it a menu item?
1983 if ( id == 0 )
1984 {
1985 DRAWITEMSTRUCT *pDrawStruct = (DRAWITEMSTRUCT *)itemStruct;
1986 wxMenuItem *pMenuItem = (wxMenuItem *)(pDrawStruct->itemData);
1987
1988 wxCHECK( pMenuItem->IsKindOf(CLASSINFO(wxMenuItem)), FALSE );
1989
1990 // prepare to call OnDrawItem()
1991 wxDC dc;
1992 dc.SetHDC((WXHDC)pDrawStruct->hDC, FALSE);
1993 wxRect rect(pDrawStruct->rcItem.left, pDrawStruct->rcItem.top,
1994 pDrawStruct->rcItem.right - pDrawStruct->rcItem.left,
1995 pDrawStruct->rcItem.bottom - pDrawStruct->rcItem.top);
1996
1997 return pMenuItem->OnDrawItem
1998 (
1999 dc, rect,
2000 (wxOwnerDrawn::wxODAction)pDrawStruct->itemAction,
2001 (wxOwnerDrawn::wxODStatus)pDrawStruct->itemState
2002 );
2003 }
2004
2005 wxWindow *item = FindItem(id);
2006 if ( item && item->IsKindOf(CLASSINFO(wxControl)) )
2007 {
2008 return ((wxControl *)item)->MSWOnDraw(itemStruct);
2009 }
2010 else
2011 #endif
2012 return FALSE;
2013 */
2014 return FALSE;
2015 }
2016
2017 bool wxWindow::OS2OnMeasureItem(int id, WXMEASUREITEMSTRUCT *itemStruct)
2018 {
2019 // TODO:
2020 /*
2021 #if wxUSE_OWNER_DRAWN
2022 // is it a menu item?
2023 if ( id == 0 )
2024 {
2025 MEASUREITEMSTRUCT *pMeasureStruct = (MEASUREITEMSTRUCT *)itemStruct;
2026 wxMenuItem *pMenuItem = (wxMenuItem *)(pMeasureStruct->itemData);
2027
2028 wxCHECK( pMenuItem->IsKindOf(CLASSINFO(wxMenuItem)), FALSE );
2029
2030 return pMenuItem->OnMeasureItem(&pMeasureStruct->itemWidth,
2031 &pMeasureStruct->itemHeight);
2032 }
2033
2034 wxWindow *item = FindItem(id);
2035 if ( item && item->IsKindOf(CLASSINFO(wxControl)) )
2036 {
2037 return ((wxControl *)item)->MSWOnMeasure(itemStruct);
2038 }
2039 #endif // owner-drawn menus
2040 */
2041 return FALSE;
2042 }
2043
2044 // ---------------------------------------------------------------------------
2045 // colours and palettes
2046 // ---------------------------------------------------------------------------
2047
2048 bool wxWindow::HandleSysColorChange()
2049 {
2050 wxSysColourChangedEvent event;
2051 event.SetEventObject(this);
2052
2053 return GetEventHandler()->ProcessEvent(event);
2054 }
2055
2056 bool wxWindow::HandleCtlColor(WXHBRUSH *brush,
2057 WXHDC pDC,
2058 WXHWND pWnd,
2059 WXUINT nCtlColor,
2060 WXUINT message,
2061 WXWPARAM wParam,
2062 WXLPARAM lParam)
2063 {
2064 WXHBRUSH hBrush = 0;
2065 // TODO:
2066 /*
2067 if ( nCtlColor == CTLCOLOR_DLG )
2068 {
2069 hBrush = OnCtlColor(pDC, pWnd, nCtlColor, message, wParam, lParam);
2070 }
2071 else
2072 {
2073 wxControl *item = (wxControl *)FindItemByHWND(pWnd, TRUE);
2074 if ( item )
2075 hBrush = item->OnCtlColor(pDC, pWnd, nCtlColor, message, wParam, lParam);
2076 }
2077
2078 if ( hBrush )
2079 *brush = hBrush;
2080
2081 return hBrush != 0;
2082 */
2083 return FALSE;
2084 }
2085
2086 // Define for each class of dialog and control
2087 WXHBRUSH wxWindow::OnCtlColor(WXHDC hDC,
2088 WXHWND hWnd,
2089 WXUINT nCtlColor,
2090 WXUINT message,
2091 WXWPARAM wParam,
2092 WXLPARAM lParam)
2093 {
2094 return (WXHBRUSH)0;
2095 }
2096
2097 bool wxWindow::HandlePaletteChanged(WXHWND hWndPalChange)
2098 {
2099 wxPaletteChangedEvent event(GetId());
2100 event.SetEventObject(this);
2101 event.SetChangedWindow(wxFindWinFromHandle(hWndPalChange));
2102
2103 return GetEventHandler()->ProcessEvent(event);
2104 }
2105
2106 bool wxWindow::HandleQueryNewPalette()
2107 {
2108 wxQueryNewPaletteEvent event(GetId());
2109 event.SetEventObject(this);
2110
2111 return GetEventHandler()->ProcessEvent(event) && event.GetPaletteRealized();
2112 }
2113
2114 // Responds to colour changes: passes event on to children.
2115 void wxWindow::OnSysColourChanged(wxSysColourChangedEvent& event)
2116 {
2117 wxNode *node = GetChildren().First();
2118 while ( node )
2119 {
2120 // Only propagate to non-top-level windows
2121 wxWindow *win = (wxWindow *)node->Data();
2122 if ( win->GetParent() )
2123 {
2124 wxSysColourChangedEvent event2;
2125 event.m_eventObject = win;
2126 win->GetEventHandler()->ProcessEvent(event2);
2127 }
2128
2129 node = node->Next();
2130 }
2131 }
2132
2133 // ---------------------------------------------------------------------------
2134 // painting
2135 // ---------------------------------------------------------------------------
2136
2137 bool wxWindow::HandlePaint()
2138 {
2139 // TODO:
2140 return FALSE;
2141 }
2142
2143 bool wxWindow::HandleEraseBkgnd(WXHDC hdc)
2144 {
2145 // Prevents flicker when dragging
2146 // if ( ::IsIconic(GetHwnd()) )
2147 // return TRUE;
2148
2149 wxDC dc;
2150
2151 dc.SetHDC(hdc);
2152 dc.SetWindow(this);
2153 dc.BeginDrawing();
2154
2155 wxEraseEvent event(m_windowId, &dc);
2156 event.SetEventObject(this);
2157 bool rc = GetEventHandler()->ProcessEvent(event);
2158
2159 dc.EndDrawing();
2160 dc.SelectOldObjects(hdc);
2161 dc.SetHDC((WXHDC) NULL);
2162
2163 return rc;
2164 }
2165
2166 void wxWindow::OnEraseBackground(wxEraseEvent& event)
2167 {
2168 // TODO:
2169 }
2170
2171 // ---------------------------------------------------------------------------
2172 // moving and resizing
2173 // ---------------------------------------------------------------------------
2174
2175 bool wxWindow::HandleMinimize()
2176 {
2177 wxIconizeEvent event(m_windowId);
2178 event.SetEventObject(this);
2179
2180 return GetEventHandler()->ProcessEvent(event);
2181 }
2182
2183 bool wxWindow::HandleMaximize()
2184 {
2185 wxMaximizeEvent event(m_windowId);
2186 event.SetEventObject(this);
2187
2188 return GetEventHandler()->ProcessEvent(event);
2189 }
2190
2191 bool wxWindow::HandleMove(int x, int y)
2192 {
2193 wxMoveEvent event(wxPoint(x, y), m_windowId);
2194 event.SetEventObject(this);
2195
2196 return GetEventHandler()->ProcessEvent(event);
2197 }
2198
2199 bool wxWindow::HandleSize(int w, int h, WXUINT WXUNUSED(flag))
2200 {
2201 wxSizeEvent event(wxSize(w, h), m_windowId);
2202 event.SetEventObject(this);
2203
2204 return GetEventHandler()->ProcessEvent(event);
2205 }
2206
2207 bool wxWindow::HandleGetMinMaxInfo(void *mmInfo)
2208 {
2209 // TODO:
2210 /*
2211 MINMAXINFO *info = (MINMAXINFO *)mmInfo;
2212
2213 bool rc = FALSE;
2214
2215 if ( m_minWidth != -1 )
2216 {
2217 info->ptMinTrackSize.x = m_minWidth;
2218 rc = TRUE;
2219 }
2220
2221 if ( m_minHeight != -1 )
2222 {
2223 info->ptMinTrackSize.y = m_minHeight;
2224 rc = TRUE;
2225 }
2226
2227 if ( m_maxWidth != -1 )
2228 {
2229 info->ptMaxTrackSize.x = m_maxWidth;
2230 rc = TRUE;
2231 }
2232
2233 if ( m_maxHeight != -1 )
2234 {
2235 info->ptMaxTrackSize.y = m_maxHeight;
2236 rc = TRUE;
2237 }
2238
2239 return rc;
2240 */
2241 return FALSE;
2242 }
2243
2244 // ---------------------------------------------------------------------------
2245 // command messages
2246 // ---------------------------------------------------------------------------
2247
2248 bool wxWindow::HandleCommand(WXWORD id, WXWORD cmd, WXHWND control)
2249 {
2250 if ( wxCurrentPopupMenu )
2251 {
2252 wxMenu *popupMenu = wxCurrentPopupMenu;
2253 wxCurrentPopupMenu = NULL;
2254
2255 return popupMenu->OS2Command(cmd, id);
2256 }
2257
2258 wxWindow *win = FindItem(id);
2259 if ( !win )
2260 {
2261 win = wxFindWinFromHandle(control);
2262 }
2263
2264 if ( win )
2265 return win->OS2Command(cmd, id);
2266
2267 return FALSE;
2268 }
2269
2270 bool wxWindow::HandleSysCommand(WXWPARAM wParam, WXLPARAM lParam)
2271 {
2272 // TODO:
2273 return FALSE;
2274 }
2275
2276 // ---------------------------------------------------------------------------
2277 // mouse events
2278 // ---------------------------------------------------------------------------
2279
2280 void wxWindow::InitMouseEvent(wxMouseEvent& event, int x, int y, WXUINT flags)
2281 {
2282 // TODO:
2283 /*
2284 event.m_x = x;
2285 event.m_y = y;
2286 event.m_shiftDown = ((flags & MK_SHIFT) != 0);
2287 event.m_controlDown = ((flags & MK_CONTROL) != 0);
2288 event.m_leftDown = ((flags & MK_LBUTTON) != 0);
2289 event.m_middleDown = ((flags & MK_MBUTTON) != 0);
2290 event.m_rightDown = ((flags & MK_RBUTTON) != 0);
2291 event.SetTimestamp(s_currentMsg.time);
2292 event.m_eventObject = this;
2293
2294 #if wxUSE_MOUSEEVENT_HACK
2295 m_lastMouseX = x;
2296 m_lastMouseY = y;
2297 m_lastMouseEvent = event.GetEventType();
2298 #endif // wxUSE_MOUSEEVENT_HACK
2299 */
2300 }
2301
2302 bool wxWindow::HandleMouseEvent(WXUINT msg, int x, int y, WXUINT flags)
2303 {
2304 // the mouse events take consecutive IDs from WM_MOUSEFIRST to
2305 // WM_MOUSELAST, so it's enough to substract WM_MOUSEMOVE == WM_MOUSEFIRST
2306 // from the message id and take the value in the table to get wxWin event
2307 // id
2308 static const wxEventType eventsMouse[] =
2309 {
2310 wxEVT_MOTION,
2311 wxEVT_LEFT_DOWN,
2312 wxEVT_LEFT_UP,
2313 wxEVT_LEFT_DCLICK,
2314 wxEVT_RIGHT_DOWN,
2315 wxEVT_RIGHT_UP,
2316 wxEVT_RIGHT_DCLICK,
2317 wxEVT_MIDDLE_DOWN,
2318 wxEVT_MIDDLE_UP,
2319 wxEVT_MIDDLE_DCLICK
2320 };
2321
2322 wxMouseEvent event(eventsMouse[msg - WM_MOUSEMOVE]);
2323 InitMouseEvent(event, x, y, flags);
2324
2325 return GetEventHandler()->ProcessEvent(event);
2326 }
2327
2328 bool wxWindow::HandleMouseMove(int x, int y, WXUINT flags)
2329 {
2330 if ( !m_bMouseInWindow )
2331 {
2332 // Generate an ENTER event
2333 m_bMouseInWindow = TRUE;
2334
2335 wxMouseEvent event(wxEVT_ENTER_WINDOW);
2336 InitMouseEvent(event, x, y, flags);
2337
2338 (void)GetEventHandler()->ProcessEvent(event);
2339 }
2340
2341 #if wxUSE_MOUSEEVENT_HACK
2342 // Window gets a click down message followed by a mouse move message even
2343 // if position isn't changed! We want to discard the trailing move event
2344 // if x and y are the same.
2345 if ( (m_lastMouseEvent == wxEVT_RIGHT_DOWN ||
2346 m_lastMouseEvent == wxEVT_LEFT_DOWN ||
2347 m_lastMouseEvent == wxEVT_MIDDLE_DOWN) &&
2348 (m_lastMouseX == event.m_x && m_lastMouseY == event.m_y) )
2349 {
2350 m_lastMouseEvent = wxEVT_MOTION;
2351
2352 return FALSE;
2353 }
2354 #endif // wxUSE_MOUSEEVENT_HACK
2355
2356 return HandleMouseEvent(WM_MOUSEMOVE, x, y, flags);
2357 }
2358
2359 // ---------------------------------------------------------------------------
2360 // keyboard handling
2361 // ---------------------------------------------------------------------------
2362
2363 // isASCII is TRUE only when we're called from WM_CHAR handler and not from
2364 // WM_KEYDOWN one
2365 bool wxWindow::HandleChar(WXWORD wParam, WXLPARAM lParam, bool isASCII)
2366 {
2367 // TODO:
2368 return FALSE;
2369 }
2370
2371 bool wxWindow::HandleKeyDown(WXWORD wParam, WXLPARAM lParam)
2372 {
2373 // TODO:
2374 return FALSE;
2375 }
2376
2377 bool wxWindow::HandleKeyUp(WXWORD wParam, WXLPARAM lParam)
2378 {
2379 // TODO:
2380 return FALSE;
2381 }
2382
2383 // ---------------------------------------------------------------------------
2384 // joystick
2385 // ---------------------------------------------------------------------------
2386
2387 bool wxWindow::HandleJoystickEvent(WXUINT msg, int x, int y, WXUINT flags)
2388 {
2389 // TODO:
2390 return FALSE;
2391 }
2392
2393 // ---------------------------------------------------------------------------
2394 // scrolling
2395 // ---------------------------------------------------------------------------
2396
2397 bool wxWindow::OS2OnScroll(int orientation, WXWORD wParam,
2398 WXWORD pos, WXHWND control)
2399 {
2400 if ( control )
2401 {
2402 wxWindow *child = wxFindWinFromHandle(control);
2403 if ( child )
2404 return child->OS2OnScroll(orientation, wParam, pos, control);
2405 }
2406
2407 wxScrollWinEvent event;
2408 event.SetPosition(pos);
2409 event.SetOrientation(orientation);
2410 event.m_eventObject = this;
2411 // TODO:
2412 return FALSE;
2413 }
2414
2415 // ===========================================================================
2416 // global functions
2417 // ===========================================================================
2418
2419 void wxGetCharSize(WXHWND wnd, int *x, int *y,wxFont *the_font)
2420 {
2421 // TODO:
2422 }
2423
2424 // Returns 0 if was a normal ASCII value, not a special key. This indicates that
2425 // the key should be ignored by WM_KEYDOWN and processed by WM_CHAR instead.
2426 int wxCharCodeOS2ToWX(int keySym)
2427 {
2428 int id = 0;
2429 // TODO:
2430 /*
2431 switch (keySym)
2432 {
2433 case VK_CANCEL: id = WXK_CANCEL; break;
2434 case VK_BACK: id = WXK_BACK; break;
2435 case VK_TAB: id = WXK_TAB; break;
2436 case VK_CLEAR: id = WXK_CLEAR; break;
2437 case VK_RETURN: id = WXK_RETURN; break;
2438 case VK_SHIFT: id = WXK_SHIFT; break;
2439 case VK_CONTROL: id = WXK_CONTROL; break;
2440 case VK_MENU : id = WXK_MENU; break;
2441 case VK_PAUSE: id = WXK_PAUSE; break;
2442 case VK_SPACE: id = WXK_SPACE; break;
2443 case VK_ESCAPE: id = WXK_ESCAPE; break;
2444 case VK_PRIOR: id = WXK_PRIOR; break;
2445 case VK_NEXT : id = WXK_NEXT; break;
2446 case VK_END: id = WXK_END; break;
2447 case VK_HOME : id = WXK_HOME; break;
2448 case VK_LEFT : id = WXK_LEFT; break;
2449 case VK_UP: id = WXK_UP; break;
2450 case VK_RIGHT: id = WXK_RIGHT; break;
2451 case VK_DOWN : id = WXK_DOWN; break;
2452 case VK_SELECT: id = WXK_SELECT; break;
2453 case VK_PRINT: id = WXK_PRINT; break;
2454 case VK_EXECUTE: id = WXK_EXECUTE; break;
2455 case VK_INSERT: id = WXK_INSERT; break;
2456 case VK_DELETE: id = WXK_DELETE; break;
2457 case VK_HELP : id = WXK_HELP; break;
2458 case VK_NUMPAD0: id = WXK_NUMPAD0; break;
2459 case VK_NUMPAD1: id = WXK_NUMPAD1; break;
2460 case VK_NUMPAD2: id = WXK_NUMPAD2; break;
2461 case VK_NUMPAD3: id = WXK_NUMPAD3; break;
2462 case VK_NUMPAD4: id = WXK_NUMPAD4; break;
2463 case VK_NUMPAD5: id = WXK_NUMPAD5; break;
2464 case VK_NUMPAD6: id = WXK_NUMPAD6; break;
2465 case VK_NUMPAD7: id = WXK_NUMPAD7; break;
2466 case VK_NUMPAD8: id = WXK_NUMPAD8; break;
2467 case VK_NUMPAD9: id = WXK_NUMPAD9; break;
2468 case VK_MULTIPLY: id = WXK_MULTIPLY; break;
2469 case VK_ADD: id = WXK_ADD; break;
2470 case VK_SUBTRACT: id = WXK_SUBTRACT; break;
2471 case VK_DECIMAL: id = WXK_DECIMAL; break;
2472 case VK_DIVIDE: id = WXK_DIVIDE; break;
2473 case VK_F1: id = WXK_F1; break;
2474 case VK_F2: id = WXK_F2; break;
2475 case VK_F3: id = WXK_F3; break;
2476 case VK_F4: id = WXK_F4; break;
2477 case VK_F5: id = WXK_F5; break;
2478 case VK_F6: id = WXK_F6; break;
2479 case VK_F7: id = WXK_F7; break;
2480 case VK_F8: id = WXK_F8; break;
2481 case VK_F9: id = WXK_F9; break;
2482 case VK_F10: id = WXK_F10; break;
2483 case VK_F11: id = WXK_F11; break;
2484 case VK_F12: id = WXK_F12; break;
2485 case VK_F13: id = WXK_F13; break;
2486 case VK_F14: id = WXK_F14; break;
2487 case VK_F15: id = WXK_F15; break;
2488 case VK_F16: id = WXK_F16; break;
2489 case VK_F17: id = WXK_F17; break;
2490 case VK_F18: id = WXK_F18; break;
2491 case VK_F19: id = WXK_F19; break;
2492 case VK_F20: id = WXK_F20; break;
2493 case VK_F21: id = WXK_F21; break;
2494 case VK_F22: id = WXK_F22; break;
2495 case VK_F23: id = WXK_F23; break;
2496 case VK_F24: id = WXK_F24; break;
2497 case VK_NUMLOCK: id = WXK_NUMLOCK; break;
2498 case VK_SCROLL: id = WXK_SCROLL; break;
2499 default:
2500 {
2501 return 0;
2502 }
2503 }
2504 */
2505 return id;
2506 }
2507
2508 int wxCharCodeWXToOS2(int id, bool *isVirtual)
2509 {
2510 *isVirtual = TRUE;
2511 int keySym = 0;
2512 // TODO
2513 /*
2514 switch (id)
2515 {
2516 case WXK_CANCEL: keySym = VK_CANCEL; break;
2517 case WXK_CLEAR: keySym = VK_CLEAR; break;
2518 case WXK_SHIFT: keySym = VK_SHIFT; break;
2519 case WXK_CONTROL: keySym = VK_CONTROL; break;
2520 case WXK_MENU : keySym = VK_MENU; break;
2521 case WXK_PAUSE: keySym = VK_PAUSE; break;
2522 case WXK_PRIOR: keySym = VK_PRIOR; break;
2523 case WXK_NEXT : keySym = VK_NEXT; break;
2524 case WXK_END: keySym = VK_END; break;
2525 case WXK_HOME : keySym = VK_HOME; break;
2526 case WXK_LEFT : keySym = VK_LEFT; break;
2527 case WXK_UP: keySym = VK_UP; break;
2528 case WXK_RIGHT: keySym = VK_RIGHT; break;
2529 case WXK_DOWN : keySym = VK_DOWN; break;
2530 case WXK_SELECT: keySym = VK_SELECT; break;
2531 case WXK_PRINT: keySym = VK_PRINT; break;
2532 case WXK_EXECUTE: keySym = VK_EXECUTE; break;
2533 case WXK_INSERT: keySym = VK_INSERT; break;
2534 case WXK_DELETE: keySym = VK_DELETE; break;
2535 case WXK_HELP : keySym = VK_HELP; break;
2536 case WXK_NUMPAD0: keySym = VK_NUMPAD0; break;
2537 case WXK_NUMPAD1: keySym = VK_NUMPAD1; break;
2538 case WXK_NUMPAD2: keySym = VK_NUMPAD2; break;
2539 case WXK_NUMPAD3: keySym = VK_NUMPAD3; break;
2540 case WXK_NUMPAD4: keySym = VK_NUMPAD4; break;
2541 case WXK_NUMPAD5: keySym = VK_NUMPAD5; break;
2542 case WXK_NUMPAD6: keySym = VK_NUMPAD6; break;
2543 case WXK_NUMPAD7: keySym = VK_NUMPAD7; break;
2544 case WXK_NUMPAD8: keySym = VK_NUMPAD8; break;
2545 case WXK_NUMPAD9: keySym = VK_NUMPAD9; break;
2546 case WXK_MULTIPLY: keySym = VK_MULTIPLY; break;
2547 case WXK_ADD: keySym = VK_ADD; break;
2548 case WXK_SUBTRACT: keySym = VK_SUBTRACT; break;
2549 case WXK_DECIMAL: keySym = VK_DECIMAL; break;
2550 case WXK_DIVIDE: keySym = VK_DIVIDE; break;
2551 case WXK_F1: keySym = VK_F1; break;
2552 case WXK_F2: keySym = VK_F2; break;
2553 case WXK_F3: keySym = VK_F3; break;
2554 case WXK_F4: keySym = VK_F4; break;
2555 case WXK_F5: keySym = VK_F5; break;
2556 case WXK_F6: keySym = VK_F6; break;
2557 case WXK_F7: keySym = VK_F7; break;
2558 case WXK_F8: keySym = VK_F8; break;
2559 case WXK_F9: keySym = VK_F9; break;
2560 case WXK_F10: keySym = VK_F10; break;
2561 case WXK_F11: keySym = VK_F11; break;
2562 case WXK_F12: keySym = VK_F12; break;
2563 case WXK_F13: keySym = VK_F13; break;
2564 case WXK_F14: keySym = VK_F14; break;
2565 case WXK_F15: keySym = VK_F15; break;
2566 case WXK_F16: keySym = VK_F16; break;
2567 case WXK_F17: keySym = VK_F17; break;
2568 case WXK_F18: keySym = VK_F18; break;
2569 case WXK_F19: keySym = VK_F19; break;
2570 case WXK_F20: keySym = VK_F20; break;
2571 case WXK_F21: keySym = VK_F21; break;
2572 case WXK_F22: keySym = VK_F22; break;
2573 case WXK_F23: keySym = VK_F23; break;
2574 case WXK_F24: keySym = VK_F24; break;
2575 case WXK_NUMLOCK: keySym = VK_NUMLOCK; break;
2576 case WXK_SCROLL: keySym = VK_SCROLL; break;
2577 default:
2578 {
2579 *isVirtual = FALSE;
2580 keySym = id;
2581 break;
2582 }
2583 }
2584 */
2585 return keySym;
2586 }
2587
2588 wxWindow *wxGetActiveWindow()
2589 {
2590 // TODO
2591 return NULL;
2592 }
2593
2594 // Windows keyboard hook. Allows interception of e.g. F1, ESCAPE
2595 // in active frames and dialogs, regardless of where the focus is.
2596 //static HHOOK wxTheKeyboardHook = 0;
2597 //static FARPROC wxTheKeyboardHookProc = 0;
2598 int wxKeyboardHook(int nCode, WORD wParam, DWORD lParam);
2599
2600 void wxSetKeyboardHook(bool doIt)
2601 {
2602 // TODO:
2603 }
2604
2605 int wxKeyboardHook(int nCode, WORD wParam, DWORD lParam)
2606 {
2607 // TODO:
2608
2609 return 0;
2610 }
2611
2612 #ifdef __WXDEBUG__
2613 const char *wxGetMessageName(int message)
2614 {
2615 // TODO
2616 /*
2617 switch ( message )
2618 {
2619 case 0x0000: return "WM_NULL";
2620 case 0x0001: return "WM_CREATE";
2621 case 0x0002: return "WM_DESTROY";
2622 case 0x0003: return "WM_MOVE";
2623 case 0x0005: return "WM_SIZE";
2624 case 0x0006: return "WM_ACTIVATE";
2625 case 0x0007: return "WM_SETFOCUS";
2626 case 0x0008: return "WM_KILLFOCUS";
2627 case 0x000A: return "WM_ENABLE";
2628 case 0x000B: return "WM_SETREDRAW";
2629 case 0x000C: return "WM_SETTEXT";
2630 case 0x000D: return "WM_GETTEXT";
2631 case 0x000E: return "WM_GETTEXTLENGTH";
2632 case 0x000F: return "WM_PAINT";
2633 case 0x0010: return "WM_CLOSE";
2634 case 0x0011: return "WM_QUERYENDSESSION";
2635 case 0x0012: return "WM_QUIT";
2636 case 0x0013: return "WM_QUERYOPEN";
2637 case 0x0014: return "WM_ERASEBKGND";
2638 case 0x0015: return "WM_SYSCOLORCHANGE";
2639 case 0x0016: return "WM_ENDSESSION";
2640 case 0x0017: return "WM_SYSTEMERROR";
2641 case 0x0018: return "WM_SHOWWINDOW";
2642 case 0x0019: return "WM_CTLCOLOR";
2643 case 0x001A: return "WM_WININICHANGE";
2644 case 0x001B: return "WM_DEVMODECHANGE";
2645 case 0x001C: return "WM_ACTIVATEAPP";
2646 case 0x001D: return "WM_FONTCHANGE";
2647 case 0x001E: return "WM_TIMECHANGE";
2648 case 0x001F: return "WM_CANCELMODE";
2649 case 0x0020: return "WM_SETCURSOR";
2650 case 0x0021: return "WM_MOUSEACTIVATE";
2651 case 0x0022: return "WM_CHILDACTIVATE";
2652 case 0x0023: return "WM_QUEUESYNC";
2653 case 0x0024: return "WM_GETMINMAXINFO";
2654 case 0x0026: return "WM_PAINTICON";
2655 case 0x0027: return "WM_ICONERASEBKGND";
2656 case 0x0028: return "WM_NEXTDLGCTL";
2657 case 0x002A: return "WM_SPOOLERSTATUS";
2658 case 0x002B: return "WM_DRAWITEM";
2659 case 0x002C: return "WM_MEASUREITEM";
2660 case 0x002D: return "WM_DELETEITEM";
2661 case 0x002E: return "WM_VKEYTOITEM";
2662 case 0x002F: return "WM_CHARTOITEM";
2663 case 0x0030: return "WM_SETFONT";
2664 case 0x0031: return "WM_GETFONT";
2665 case 0x0037: return "WM_QUERYDRAGICON";
2666 case 0x0039: return "WM_COMPAREITEM";
2667 case 0x0041: return "WM_COMPACTING";
2668 case 0x0044: return "WM_COMMNOTIFY";
2669 case 0x0046: return "WM_WINDOWPOSCHANGING";
2670 case 0x0047: return "WM_WINDOWPOSCHANGED";
2671 case 0x0048: return "WM_POWER";
2672
2673 #ifdef __WIN32__
2674 case 0x004A: return "WM_COPYDATA";
2675 case 0x004B: return "WM_CANCELJOURNAL";
2676 case 0x004E: return "WM_NOTIFY";
2677 case 0x0050: return "WM_INPUTLANGCHANGEREQUEST";
2678 case 0x0051: return "WM_INPUTLANGCHANGE";
2679 case 0x0052: return "WM_TCARD";
2680 case 0x0053: return "WM_HELP";
2681 case 0x0054: return "WM_USERCHANGED";
2682 case 0x0055: return "WM_NOTIFYFORMAT";
2683 case 0x007B: return "WM_CONTEXTMENU";
2684 case 0x007C: return "WM_STYLECHANGING";
2685 case 0x007D: return "WM_STYLECHANGED";
2686 case 0x007E: return "WM_DISPLAYCHANGE";
2687 case 0x007F: return "WM_GETICON";
2688 case 0x0080: return "WM_SETICON";
2689 #endif //WIN32
2690
2691 case 0x0081: return "WM_NCCREATE";
2692 case 0x0082: return "WM_NCDESTROY";
2693 case 0x0083: return "WM_NCCALCSIZE";
2694 case 0x0084: return "WM_NCHITTEST";
2695 case 0x0085: return "WM_NCPAINT";
2696 case 0x0086: return "WM_NCACTIVATE";
2697 case 0x0087: return "WM_GETDLGCODE";
2698 case 0x00A0: return "WM_NCMOUSEMOVE";
2699 case 0x00A1: return "WM_NCLBUTTONDOWN";
2700 case 0x00A2: return "WM_NCLBUTTONUP";
2701 case 0x00A3: return "WM_NCLBUTTONDBLCLK";
2702 case 0x00A4: return "WM_NCRBUTTONDOWN";
2703 case 0x00A5: return "WM_NCRBUTTONUP";
2704 case 0x00A6: return "WM_NCRBUTTONDBLCLK";
2705 case 0x00A7: return "WM_NCMBUTTONDOWN";
2706 case 0x00A8: return "WM_NCMBUTTONUP";
2707 case 0x00A9: return "WM_NCMBUTTONDBLCLK";
2708 case 0x0100: return "WM_KEYDOWN";
2709 case 0x0101: return "WM_KEYUP";
2710 case 0x0102: return "WM_CHAR";
2711 case 0x0103: return "WM_DEADCHAR";
2712 case 0x0104: return "WM_SYSKEYDOWN";
2713 case 0x0105: return "WM_SYSKEYUP";
2714 case 0x0106: return "WM_SYSCHAR";
2715 case 0x0107: return "WM_SYSDEADCHAR";
2716 case 0x0108: return "WM_KEYLAST";
2717
2718 #ifdef __WIN32__
2719 case 0x010D: return "WM_IME_STARTCOMPOSITION";
2720 case 0x010E: return "WM_IME_ENDCOMPOSITION";
2721 case 0x010F: return "WM_IME_COMPOSITION";
2722 #endif //WIN32
2723
2724 case 0x0110: return "WM_INITDIALOG";
2725 case 0x0111: return "WM_COMMAND";
2726 case 0x0112: return "WM_SYSCOMMAND";
2727 case 0x0113: return "WM_TIMER";
2728 case 0x0114: return "WM_HSCROLL";
2729 case 0x0115: return "WM_VSCROLL";
2730 case 0x0116: return "WM_INITMENU";
2731 case 0x0117: return "WM_INITMENUPOPUP";
2732 case 0x011F: return "WM_MENUSELECT";
2733 case 0x0120: return "WM_MENUCHAR";
2734 case 0x0121: return "WM_ENTERIDLE";
2735 case 0x0200: return "WM_MOUSEMOVE";
2736 case 0x0201: return "WM_LBUTTONDOWN";
2737 case 0x0202: return "WM_LBUTTONUP";
2738 case 0x0203: return "WM_LBUTTONDBLCLK";
2739 case 0x0204: return "WM_RBUTTONDOWN";
2740 case 0x0205: return "WM_RBUTTONUP";
2741 case 0x0206: return "WM_RBUTTONDBLCLK";
2742 case 0x0207: return "WM_MBUTTONDOWN";
2743 case 0x0208: return "WM_MBUTTONUP";
2744 case 0x0209: return "WM_MBUTTONDBLCLK";
2745 case 0x0210: return "WM_PARENTNOTIFY";
2746 case 0x0211: return "WM_ENTERMENULOOP";
2747 case 0x0212: return "WM_EXITMENULOOP";
2748
2749 #ifdef __WIN32__
2750 case 0x0213: return "WM_NEXTMENU";
2751 case 0x0214: return "WM_SIZING";
2752 case 0x0215: return "WM_CAPTURECHANGED";
2753 case 0x0216: return "WM_MOVING";
2754 case 0x0218: return "WM_POWERBROADCAST";
2755 case 0x0219: return "WM_DEVICECHANGE";
2756 #endif //WIN32
2757
2758 case 0x0220: return "WM_MDICREATE";
2759 case 0x0221: return "WM_MDIDESTROY";
2760 case 0x0222: return "WM_MDIACTIVATE";
2761 case 0x0223: return "WM_MDIRESTORE";
2762 case 0x0224: return "WM_MDINEXT";
2763 case 0x0225: return "WM_MDIMAXIMIZE";
2764 case 0x0226: return "WM_MDITILE";
2765 case 0x0227: return "WM_MDICASCADE";
2766 case 0x0228: return "WM_MDIICONARRANGE";
2767 case 0x0229: return "WM_MDIGETACTIVE";
2768 case 0x0230: return "WM_MDISETMENU";
2769 case 0x0233: return "WM_DROPFILES";
2770
2771 #ifdef __WIN32__
2772 case 0x0281: return "WM_IME_SETCONTEXT";
2773 case 0x0282: return "WM_IME_NOTIFY";
2774 case 0x0283: return "WM_IME_CONTROL";
2775 case 0x0284: return "WM_IME_COMPOSITIONFULL";
2776 case 0x0285: return "WM_IME_SELECT";
2777 case 0x0286: return "WM_IME_CHAR";
2778 case 0x0290: return "WM_IME_KEYDOWN";
2779 case 0x0291: return "WM_IME_KEYUP";
2780 #endif //WIN32
2781
2782 case 0x0300: return "WM_CUT";
2783 case 0x0301: return "WM_COPY";
2784 case 0x0302: return "WM_PASTE";
2785 case 0x0303: return "WM_CLEAR";
2786 case 0x0304: return "WM_UNDO";
2787 case 0x0305: return "WM_RENDERFORMAT";
2788 case 0x0306: return "WM_RENDERALLFORMATS";
2789 case 0x0307: return "WM_DESTROYCLIPBOARD";
2790 case 0x0308: return "WM_DRAWCLIPBOARD";
2791 case 0x0309: return "WM_PAINTCLIPBOARD";
2792 case 0x030A: return "WM_VSCROLLCLIPBOARD";
2793 case 0x030B: return "WM_SIZECLIPBOARD";
2794 case 0x030C: return "WM_ASKCBFORMATNAME";
2795 case 0x030D: return "WM_CHANGECBCHAIN";
2796 case 0x030E: return "WM_HSCROLLCLIPBOARD";
2797 case 0x030F: return "WM_QUERYNEWPALETTE";
2798 case 0x0310: return "WM_PALETTEISCHANGING";
2799 case 0x0311: return "WM_PALETTECHANGED";
2800
2801 #ifdef __WIN32__
2802 // common controls messages - although they're not strictly speaking
2803 // standard, it's nice to decode them nevertheless
2804
2805 // listview
2806 case 0x1000 + 0: return "LVM_GETBKCOLOR";
2807 case 0x1000 + 1: return "LVM_SETBKCOLOR";
2808 case 0x1000 + 2: return "LVM_GETIMAGELIST";
2809 case 0x1000 + 3: return "LVM_SETIMAGELIST";
2810 case 0x1000 + 4: return "LVM_GETITEMCOUNT";
2811 case 0x1000 + 5: return "LVM_GETITEMA";
2812 case 0x1000 + 75: return "LVM_GETITEMW";
2813 case 0x1000 + 6: return "LVM_SETITEMA";
2814 case 0x1000 + 76: return "LVM_SETITEMW";
2815 case 0x1000 + 7: return "LVM_INSERTITEMA";
2816 case 0x1000 + 77: return "LVM_INSERTITEMW";
2817 case 0x1000 + 8: return "LVM_DELETEITEM";
2818 case 0x1000 + 9: return "LVM_DELETEALLITEMS";
2819 case 0x1000 + 10: return "LVM_GETCALLBACKMASK";
2820 case 0x1000 + 11: return "LVM_SETCALLBACKMASK";
2821 case 0x1000 + 12: return "LVM_GETNEXTITEM";
2822 case 0x1000 + 13: return "LVM_FINDITEMA";
2823 case 0x1000 + 83: return "LVM_FINDITEMW";
2824 case 0x1000 + 14: return "LVM_GETITEMRECT";
2825 case 0x1000 + 15: return "LVM_SETITEMPOSITION";
2826 case 0x1000 + 16: return "LVM_GETITEMPOSITION";
2827 case 0x1000 + 17: return "LVM_GETSTRINGWIDTHA";
2828 case 0x1000 + 87: return "LVM_GETSTRINGWIDTHW";
2829 case 0x1000 + 18: return "LVM_HITTEST";
2830 case 0x1000 + 19: return "LVM_ENSUREVISIBLE";
2831 case 0x1000 + 20: return "LVM_SCROLL";
2832 case 0x1000 + 21: return "LVM_REDRAWITEMS";
2833 case 0x1000 + 22: return "LVM_ARRANGE";
2834 case 0x1000 + 23: return "LVM_EDITLABELA";
2835 case 0x1000 + 118: return "LVM_EDITLABELW";
2836 case 0x1000 + 24: return "LVM_GETEDITCONTROL";
2837 case 0x1000 + 25: return "LVM_GETCOLUMNA";
2838 case 0x1000 + 95: return "LVM_GETCOLUMNW";
2839 case 0x1000 + 26: return "LVM_SETCOLUMNA";
2840 case 0x1000 + 96: return "LVM_SETCOLUMNW";
2841 case 0x1000 + 27: return "LVM_INSERTCOLUMNA";
2842 case 0x1000 + 97: return "LVM_INSERTCOLUMNW";
2843 case 0x1000 + 28: return "LVM_DELETECOLUMN";
2844 case 0x1000 + 29: return "LVM_GETCOLUMNWIDTH";
2845 case 0x1000 + 30: return "LVM_SETCOLUMNWIDTH";
2846 case 0x1000 + 31: return "LVM_GETHEADER";
2847 case 0x1000 + 33: return "LVM_CREATEDRAGIMAGE";
2848 case 0x1000 + 34: return "LVM_GETVIEWRECT";
2849 case 0x1000 + 35: return "LVM_GETTEXTCOLOR";
2850 case 0x1000 + 36: return "LVM_SETTEXTCOLOR";
2851 case 0x1000 + 37: return "LVM_GETTEXTBKCOLOR";
2852 case 0x1000 + 38: return "LVM_SETTEXTBKCOLOR";
2853 case 0x1000 + 39: return "LVM_GETTOPINDEX";
2854 case 0x1000 + 40: return "LVM_GETCOUNTPERPAGE";
2855 case 0x1000 + 41: return "LVM_GETORIGIN";
2856 case 0x1000 + 42: return "LVM_UPDATE";
2857 case 0x1000 + 43: return "LVM_SETITEMSTATE";
2858 case 0x1000 + 44: return "LVM_GETITEMSTATE";
2859 case 0x1000 + 45: return "LVM_GETITEMTEXTA";
2860 case 0x1000 + 115: return "LVM_GETITEMTEXTW";
2861 case 0x1000 + 46: return "LVM_SETITEMTEXTA";
2862 case 0x1000 + 116: return "LVM_SETITEMTEXTW";
2863 case 0x1000 + 47: return "LVM_SETITEMCOUNT";
2864 case 0x1000 + 48: return "LVM_SORTITEMS";
2865 case 0x1000 + 49: return "LVM_SETITEMPOSITION32";
2866 case 0x1000 + 50: return "LVM_GETSELECTEDCOUNT";
2867 case 0x1000 + 51: return "LVM_GETITEMSPACING";
2868 case 0x1000 + 52: return "LVM_GETISEARCHSTRINGA";
2869 case 0x1000 + 117: return "LVM_GETISEARCHSTRINGW";
2870 case 0x1000 + 53: return "LVM_SETICONSPACING";
2871 case 0x1000 + 54: return "LVM_SETEXTENDEDLISTVIEWSTYLE";
2872 case 0x1000 + 55: return "LVM_GETEXTENDEDLISTVIEWSTYLE";
2873 case 0x1000 + 56: return "LVM_GETSUBITEMRECT";
2874 case 0x1000 + 57: return "LVM_SUBITEMHITTEST";
2875 case 0x1000 + 58: return "LVM_SETCOLUMNORDERARRAY";
2876 case 0x1000 + 59: return "LVM_GETCOLUMNORDERARRAY";
2877 case 0x1000 + 60: return "LVM_SETHOTITEM";
2878 case 0x1000 + 61: return "LVM_GETHOTITEM";
2879 case 0x1000 + 62: return "LVM_SETHOTCURSOR";
2880 case 0x1000 + 63: return "LVM_GETHOTCURSOR";
2881 case 0x1000 + 64: return "LVM_APPROXIMATEVIEWRECT";
2882 case 0x1000 + 65: return "LVM_SETWORKAREA";
2883
2884 // tree view
2885 case 0x1100 + 0: return "TVM_INSERTITEMA";
2886 case 0x1100 + 50: return "TVM_INSERTITEMW";
2887 case 0x1100 + 1: return "TVM_DELETEITEM";
2888 case 0x1100 + 2: return "TVM_EXPAND";
2889 case 0x1100 + 4: return "TVM_GETITEMRECT";
2890 case 0x1100 + 5: return "TVM_GETCOUNT";
2891 case 0x1100 + 6: return "TVM_GETINDENT";
2892 case 0x1100 + 7: return "TVM_SETINDENT";
2893 case 0x1100 + 8: return "TVM_GETIMAGELIST";
2894 case 0x1100 + 9: return "TVM_SETIMAGELIST";
2895 case 0x1100 + 10: return "TVM_GETNEXTITEM";
2896 case 0x1100 + 11: return "TVM_SELECTITEM";
2897 case 0x1100 + 12: return "TVM_GETITEMA";
2898 case 0x1100 + 62: return "TVM_GETITEMW";
2899 case 0x1100 + 13: return "TVM_SETITEMA";
2900 case 0x1100 + 63: return "TVM_SETITEMW";
2901 case 0x1100 + 14: return "TVM_EDITLABELA";
2902 case 0x1100 + 65: return "TVM_EDITLABELW";
2903 case 0x1100 + 15: return "TVM_GETEDITCONTROL";
2904 case 0x1100 + 16: return "TVM_GETVISIBLECOUNT";
2905 case 0x1100 + 17: return "TVM_HITTEST";
2906 case 0x1100 + 18: return "TVM_CREATEDRAGIMAGE";
2907 case 0x1100 + 19: return "TVM_SORTCHILDREN";
2908 case 0x1100 + 20: return "TVM_ENSUREVISIBLE";
2909 case 0x1100 + 21: return "TVM_SORTCHILDRENCB";
2910 case 0x1100 + 22: return "TVM_ENDEDITLABELNOW";
2911 case 0x1100 + 23: return "TVM_GETISEARCHSTRINGA";
2912 case 0x1100 + 64: return "TVM_GETISEARCHSTRINGW";
2913 case 0x1100 + 24: return "TVM_SETTOOLTIPS";
2914 case 0x1100 + 25: return "TVM_GETTOOLTIPS";
2915
2916 // header
2917 case 0x1200 + 0: return "HDM_GETITEMCOUNT";
2918 case 0x1200 + 1: return "HDM_INSERTITEMA";
2919 case 0x1200 + 10: return "HDM_INSERTITEMW";
2920 case 0x1200 + 2: return "HDM_DELETEITEM";
2921 case 0x1200 + 3: return "HDM_GETITEMA";
2922 case 0x1200 + 11: return "HDM_GETITEMW";
2923 case 0x1200 + 4: return "HDM_SETITEMA";
2924 case 0x1200 + 12: return "HDM_SETITEMW";
2925 case 0x1200 + 5: return "HDM_LAYOUT";
2926 case 0x1200 + 6: return "HDM_HITTEST";
2927 case 0x1200 + 7: return "HDM_GETITEMRECT";
2928 case 0x1200 + 8: return "HDM_SETIMAGELIST";
2929 case 0x1200 + 9: return "HDM_GETIMAGELIST";
2930 case 0x1200 + 15: return "HDM_ORDERTOINDEX";
2931 case 0x1200 + 16: return "HDM_CREATEDRAGIMAGE";
2932 case 0x1200 + 17: return "HDM_GETORDERARRAY";
2933 case 0x1200 + 18: return "HDM_SETORDERARRAY";
2934 case 0x1200 + 19: return "HDM_SETHOTDIVIDER";
2935
2936 // tab control
2937 case 0x1300 + 2: return "TCM_GETIMAGELIST";
2938 case 0x1300 + 3: return "TCM_SETIMAGELIST";
2939 case 0x1300 + 4: return "TCM_GETITEMCOUNT";
2940 case 0x1300 + 5: return "TCM_GETITEMA";
2941 case 0x1300 + 60: return "TCM_GETITEMW";
2942 case 0x1300 + 6: return "TCM_SETITEMA";
2943 case 0x1300 + 61: return "TCM_SETITEMW";
2944 case 0x1300 + 7: return "TCM_INSERTITEMA";
2945 case 0x1300 + 62: return "TCM_INSERTITEMW";
2946 case 0x1300 + 8: return "TCM_DELETEITEM";
2947 case 0x1300 + 9: return "TCM_DELETEALLITEMS";
2948 case 0x1300 + 10: return "TCM_GETITEMRECT";
2949 case 0x1300 + 11: return "TCM_GETCURSEL";
2950 case 0x1300 + 12: return "TCM_SETCURSEL";
2951 case 0x1300 + 13: return "TCM_HITTEST";
2952 case 0x1300 + 14: return "TCM_SETITEMEXTRA";
2953 case 0x1300 + 40: return "TCM_ADJUSTRECT";
2954 case 0x1300 + 41: return "TCM_SETITEMSIZE";
2955 case 0x1300 + 42: return "TCM_REMOVEIMAGE";
2956 case 0x1300 + 43: return "TCM_SETPADDING";
2957 case 0x1300 + 44: return "TCM_GETROWCOUNT";
2958 case 0x1300 + 45: return "TCM_GETTOOLTIPS";
2959 case 0x1300 + 46: return "TCM_SETTOOLTIPS";
2960 case 0x1300 + 47: return "TCM_GETCURFOCUS";
2961 case 0x1300 + 48: return "TCM_SETCURFOCUS";
2962 case 0x1300 + 49: return "TCM_SETMINTABWIDTH";
2963 case 0x1300 + 50: return "TCM_DESELECTALL";
2964
2965 // toolbar
2966 case WM_USER+1: return "TB_ENABLEBUTTON";
2967 case WM_USER+2: return "TB_CHECKBUTTON";
2968 case WM_USER+3: return "TB_PRESSBUTTON";
2969 case WM_USER+4: return "TB_HIDEBUTTON";
2970 case WM_USER+5: return "TB_INDETERMINATE";
2971 case WM_USER+9: return "TB_ISBUTTONENABLED";
2972 case WM_USER+10: return "TB_ISBUTTONCHECKED";
2973 case WM_USER+11: return "TB_ISBUTTONPRESSED";
2974 case WM_USER+12: return "TB_ISBUTTONHIDDEN";
2975 case WM_USER+13: return "TB_ISBUTTONINDETERMINATE";
2976 case WM_USER+17: return "TB_SETSTATE";
2977 case WM_USER+18: return "TB_GETSTATE";
2978 case WM_USER+19: return "TB_ADDBITMAP";
2979 case WM_USER+20: return "TB_ADDBUTTONS";
2980 case WM_USER+21: return "TB_INSERTBUTTON";
2981 case WM_USER+22: return "TB_DELETEBUTTON";
2982 case WM_USER+23: return "TB_GETBUTTON";
2983 case WM_USER+24: return "TB_BUTTONCOUNT";
2984 case WM_USER+25: return "TB_COMMANDTOINDEX";
2985 case WM_USER+26: return "TB_SAVERESTOREA";
2986 case WM_USER+76: return "TB_SAVERESTOREW";
2987 case WM_USER+27: return "TB_CUSTOMIZE";
2988 case WM_USER+28: return "TB_ADDSTRINGA";
2989 case WM_USER+77: return "TB_ADDSTRINGW";
2990 case WM_USER+29: return "TB_GETITEMRECT";
2991 case WM_USER+30: return "TB_BUTTONSTRUCTSIZE";
2992 case WM_USER+31: return "TB_SETBUTTONSIZE";
2993 case WM_USER+32: return "TB_SETBITMAPSIZE";
2994 case WM_USER+33: return "TB_AUTOSIZE";
2995 case WM_USER+35: return "TB_GETTOOLTIPS";
2996 case WM_USER+36: return "TB_SETTOOLTIPS";
2997 case WM_USER+37: return "TB_SETPARENT";
2998 case WM_USER+39: return "TB_SETROWS";
2999 case WM_USER+40: return "TB_GETROWS";
3000 case WM_USER+42: return "TB_SETCMDID";
3001 case WM_USER+43: return "TB_CHANGEBITMAP";
3002 case WM_USER+44: return "TB_GETBITMAP";
3003 case WM_USER+45: return "TB_GETBUTTONTEXTA";
3004 case WM_USER+75: return "TB_GETBUTTONTEXTW";
3005 case WM_USER+46: return "TB_REPLACEBITMAP";
3006 case WM_USER+47: return "TB_SETINDENT";
3007 case WM_USER+48: return "TB_SETIMAGELIST";
3008 case WM_USER+49: return "TB_GETIMAGELIST";
3009 case WM_USER+50: return "TB_LOADIMAGES";
3010 case WM_USER+51: return "TB_GETRECT";
3011 case WM_USER+52: return "TB_SETHOTIMAGELIST";
3012 case WM_USER+53: return "TB_GETHOTIMAGELIST";
3013 case WM_USER+54: return "TB_SETDISABLEDIMAGELIST";
3014 case WM_USER+55: return "TB_GETDISABLEDIMAGELIST";
3015 case WM_USER+56: return "TB_SETSTYLE";
3016 case WM_USER+57: return "TB_GETSTYLE";
3017 case WM_USER+58: return "TB_GETBUTTONSIZE";
3018 case WM_USER+59: return "TB_SETBUTTONWIDTH";
3019 case WM_USER+60: return "TB_SETMAXTEXTROWS";
3020 case WM_USER+61: return "TB_GETTEXTROWS";
3021 case WM_USER+41: return "TB_GETBITMAPFLAGS";
3022
3023 #endif //WIN32
3024
3025 default:
3026 static char s_szBuf[128];
3027 sprintf(s_szBuf, "<unknown message = %d>", message);
3028 return s_szBuf;
3029 }
3030 */
3031 return NULL;
3032 }
3033
3034 #endif // __WXDEBUG__
3035