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