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