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