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