]>
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 | ||
87 | // --------------------------------------------------------------------------- | |
88 | // global variables | |
89 | // --------------------------------------------------------------------------- | |
90 | ||
a885d89a DW |
91 | // |
92 | // The last Windows message we got (MT-UNSAFE) | |
93 | // | |
94 | extern WXMSGID s_currentMsg; | |
849949b1 | 95 | |
a885d89a DW |
96 | wxMenu* wxCurrentPopupMenu = NULL; |
97 | extern wxList WXDLLEXPORT wxPendingDelete; | |
98 | extern wxChar* wxCanvasClassName; | |
99 | wxList* wxWinHandleList = NULL; | |
849949b1 DW |
100 | |
101 | // --------------------------------------------------------------------------- | |
102 | // private functions | |
103 | // --------------------------------------------------------------------------- | |
a885d89a DW |
104 | |
105 | // | |
849949b1 | 106 | // the window proc for all our windows; most gui's have something similar |
a885d89a | 107 | // |
849949b1 DW |
108 | MRESULT wxWndProc( HWND hWnd |
109 | ,ULONG message | |
110 | ,MPARAM mp1 | |
111 | ,MPARAM mp2 | |
112 | ); | |
11e59d47 DW |
113 | |
114 | #ifdef __WXDEBUG__ | |
115 | const char *wxGetMessageName(int message); | |
116 | #endif //__WXDEBUG__ | |
117 | ||
a885d89a DW |
118 | void wxRemoveHandleAssociation(wxWindow* pWin); |
119 | void wxAssociateWinWithHandle( HWND hWnd | |
120 | ,wxWindow* pWin | |
121 | ); | |
122 | wxWindow* wxFindWinFromHandle(WXHWND hWnd); | |
849949b1 | 123 | |
a885d89a DW |
124 | // |
125 | // This magical function is used to translate VK_APPS key presses to right | |
126 | // mouse clicks | |
127 | // | |
128 | static void TranslateKbdEventToMouse( wxWindow* pWin | |
129 | ,int* pX | |
130 | ,int* pY | |
131 | ,MPARAM* pFlags | |
132 | ); | |
133 | ||
134 | // | |
135 | // get the current state of SHIFT/CTRL keys | |
136 | // | |
137 | static inline bool IsShiftDown() { return (::WinGetKeyState(HWND_DESKTOP, VK_SHIFT) & 0x8000) != 0; } | |
138 | static inline bool IsCtrlDown() { return (::WinGetKeyState(HWND_DESKTOP, VK_CTRL) & 0x8000) != 0; } | |
849949b1 DW |
139 | // --------------------------------------------------------------------------- |
140 | // event tables | |
141 | // --------------------------------------------------------------------------- | |
0e320a79 | 142 | |
849949b1 | 143 | IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxWindowBase) |
0e320a79 | 144 | |
849949b1 DW |
145 | BEGIN_EVENT_TABLE(wxWindow, wxWindowBase) |
146 | EVT_ERASE_BACKGROUND(wxWindow::OnEraseBackground) | |
147 | EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged) | |
148 | EVT_INIT_DIALOG(wxWindow::OnInitDialog) | |
149 | EVT_IDLE(wxWindow::OnIdle) | |
150 | END_EVENT_TABLE() | |
0e320a79 | 151 | |
849949b1 DW |
152 | // =========================================================================== |
153 | // implementation | |
154 | // =========================================================================== | |
0e320a79 | 155 | |
a885d89a | 156 | // |
776d87d5 | 157 | // Find an item given the PM Window id |
a885d89a | 158 | // |
776d87d5 | 159 | wxWindow* wxWindow::FindItem( |
a885d89a | 160 | long lId |
776d87d5 | 161 | ) const |
cdf1e714 | 162 | { |
a885d89a DW |
163 | wxControl* pItem = wxDynamicCast( this |
164 | ,wxControl | |
165 | ); | |
166 | ||
167 | if (pItem) | |
168 | { | |
169 | // | |
170 | // I it we or one of our "internal" children? | |
171 | // | |
172 | if (pItem->GetId() == lId || | |
173 | (pItem->GetSubcontrols().Index(lId) != wxNOT_FOUND)) | |
174 | { | |
175 | return pItem; | |
176 | } | |
177 | } | |
178 | ||
776d87d5 DW |
179 | wxWindowList::Node* pCurrent = GetChildren().GetFirst(); |
180 | ||
181 | while (pCurrent) | |
cdf1e714 | 182 | { |
776d87d5 | 183 | wxWindow* pChildWin = pCurrent->GetData(); |
a885d89a | 184 | wxWindow* pWnd = pChildWin->FindItem(lId); |
cdf1e714 | 185 | |
776d87d5 DW |
186 | if (pWnd) |
187 | return pWnd; | |
cdf1e714 | 188 | |
776d87d5 | 189 | pCurrent = pCurrent->GetNext(); |
cdf1e714 | 190 | } |
776d87d5 | 191 | return(NULL); |
a885d89a | 192 | } // end of wxWindow::FindItem |
cdf1e714 | 193 | |
a885d89a | 194 | // |
776d87d5 | 195 | // Find an item given the PM Window handle |
a885d89a | 196 | // |
776d87d5 DW |
197 | wxWindow* wxWindow::FindItemByHWND( |
198 | WXHWND hWnd | |
199 | , bool bControlOnly | |
200 | ) const | |
cdf1e714 | 201 | { |
776d87d5 DW |
202 | wxWindowList::Node* pCurrent = GetChildren().GetFirst(); |
203 | ||
204 | while (pCurrent) | |
cdf1e714 | 205 | { |
776d87d5 | 206 | wxWindow* pParent = pCurrent->GetData(); |
cdf1e714 | 207 | |
a885d89a | 208 | // |
cdf1e714 | 209 | // Do a recursive search. |
a885d89a | 210 | // |
776d87d5 DW |
211 | wxWindow* pWnd = pParent->FindItemByHWND(hWnd); |
212 | ||
213 | if (pWnd) | |
214 | return(pWnd); | |
cdf1e714 | 215 | |
776d87d5 | 216 | if (!bControlOnly || pParent->IsKindOf(CLASSINFO(wxControl))) |
cdf1e714 | 217 | { |
776d87d5 DW |
218 | wxWindow* pItem = pCurrent->GetData(); |
219 | ||
220 | if (pItem->GetHWND() == hWnd) | |
221 | return(pItem); | |
cdf1e714 DW |
222 | else |
223 | { | |
776d87d5 DW |
224 | if (pItem->ContainsHWND(hWnd)) |
225 | return(pItem); | |
cdf1e714 DW |
226 | } |
227 | } | |
776d87d5 | 228 | pCurrent = pCurrent->GetNext(); |
cdf1e714 | 229 | } |
776d87d5 | 230 | return(NULL); |
a885d89a | 231 | } // end of wxWindow::FindItemByHWND |
cdf1e714 | 232 | |
a885d89a | 233 | // |
cdf1e714 | 234 | // Default command handler |
a885d89a | 235 | // |
776d87d5 DW |
236 | bool wxWindow::OS2Command( |
237 | WXUINT WXUNUSED(uParam) | |
238 | , WXWORD WXUNUSED(uId) | |
239 | ) | |
cdf1e714 | 240 | { |
776d87d5 | 241 | return(FALSE); |
cdf1e714 DW |
242 | } |
243 | ||
244 | // ---------------------------------------------------------------------------- | |
245 | // constructors and such | |
246 | // ---------------------------------------------------------------------------- | |
247 | ||
849949b1 | 248 | void wxWindow::Init() |
0e320a79 | 249 | { |
a885d89a DW |
250 | // |
251 | // Generic | |
252 | // | |
849949b1 | 253 | InitBase(); |
0e320a79 | 254 | |
a885d89a | 255 | // |
849949b1 | 256 | // PM specific |
a885d89a | 257 | // |
776d87d5 DW |
258 | m_bDoubleClickAllowed = 0; |
259 | m_bWinCaptured = FALSE; | |
cdf1e714 | 260 | |
849949b1 | 261 | m_isBeingDeleted = FALSE; |
776d87d5 DW |
262 | m_fnOldWndProc = 0; |
263 | m_bUseCtl3D = FALSE; | |
264 | m_bMouseInWindow = FALSE; | |
0e320a79 | 265 | |
a885d89a | 266 | // |
849949b1 | 267 | // wxWnd |
a885d89a | 268 | // |
849949b1 | 269 | m_hMenu = 0; |
849949b1 | 270 | m_hWnd = 0; |
0e320a79 | 271 | |
a885d89a DW |
272 | // |
273 | // Pass WM_GETDLGCODE to DefWindowProc() | |
849949b1 | 274 | m_lDlgCode = 0; |
0e320a79 | 275 | |
776d87d5 DW |
276 | m_nXThumbSize = 0; |
277 | m_nYThumbSize = 0; | |
278 | m_bBackgroundTransparent = FALSE; | |
0e320a79 | 279 | |
a885d89a DW |
280 | // |
281 | // As all windows are created with WS_VISIBLE style... | |
282 | // | |
849949b1 | 283 | m_isShown = TRUE; |
0e320a79 | 284 | |
cdf1e714 | 285 | #if wxUSE_MOUSEEVENT_HACK |
776d87d5 DW |
286 | m_lLastMouseX = |
287 | m_lLastMouseY = -1; | |
288 | m_nLastMouseEvent = -1; | |
cdf1e714 | 289 | #endif // wxUSE_MOUSEEVENT_HACK |
a885d89a | 290 | } // wxWindow::Init |
0e320a79 | 291 | |
a885d89a | 292 | // |
849949b1 | 293 | // Destructor |
a885d89a | 294 | // |
849949b1 | 295 | wxWindow::~wxWindow() |
0e320a79 | 296 | { |
849949b1 | 297 | m_isBeingDeleted = TRUE; |
0e320a79 | 298 | |
cdf1e714 | 299 | OS2DetachWindowMenu(); |
849949b1 DW |
300 | if (m_parent) |
301 | m_parent->RemoveChild(this); | |
302 | DestroyChildren(); | |
303 | if (m_hWnd) | |
304 | { | |
a885d89a | 305 | if(!::WinDestroyWindow(GetHWND())) |
223d09f6 | 306 | wxLogLastError(wxT("DestroyWindow")); |
a885d89a | 307 | // |
849949b1 | 308 | // remove hWnd <-> wxWindow association |
a885d89a | 309 | // |
849949b1 DW |
310 | wxRemoveHandleAssociation(this); |
311 | } | |
a885d89a | 312 | } // end of wxWindow::~wxWindow |
0e320a79 | 313 | |
776d87d5 DW |
314 | bool wxWindow::Create( |
315 | wxWindow* pParent | |
316 | , wxWindowID vId | |
317 | , const wxPoint& rPos | |
318 | , const wxSize& rSize | |
319 | , long lStyle | |
320 | , const wxString& rName | |
321 | ) | |
322 | { | |
323 | wxCHECK_MSG(pParent, FALSE, wxT("can't create wxWindow without parent")); | |
324 | ||
325 | if ( !CreateBase( pParent | |
326 | ,vId | |
327 | ,rPos | |
328 | ,rSize | |
329 | ,lStyle | |
330 | ,wxDefaultValidator | |
331 | ,rName | |
332 | )) | |
333 | return(FALSE); | |
334 | ||
335 | pParent->AddChild(this); | |
336 | ||
a885d89a DW |
337 | ULONG ulFlags = 0L; |
338 | ||
339 | // | |
340 | // Frame windows and their derivatives only | |
341 | // | |
342 | if (lStyle & wxBORDER) | |
343 | ulFlags |= FCF_BORDER; | |
344 | if (lStyle & wxTHICK_FRAME ) | |
345 | ulFlags |= FCF_SIZEBORDER; | |
346 | ||
347 | // | |
348 | // Some generic window styles | |
349 | // | |
350 | ulFlags |= WS_VISIBLE; | |
351 | if (lStyle & wxCLIP_CHILDREN ) | |
352 | ulFlags |= WS_CLIPCHILDREN; | |
353 | ||
776d87d5 DW |
354 | bool bWant3D; |
355 | WXDWORD dwExStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &bWant3D); | |
776d87d5 | 356 | |
a885d89a DW |
357 | // |
358 | // OS/2 PM doesn't have "extended" styles but if the library specifies | |
359 | // them and we are creating a frame window then at least give it a border | |
360 | // | |
361 | if ( bWant3D || | |
362 | (m_windowStyle & wxSIMPLE_BORDER) || | |
363 | (m_windowStyle & wxRAISED_BORDER ) || | |
364 | (m_windowStyle & wxSUNKEN_BORDER) || | |
365 | (m_windowStyle & wxDOUBLE_BORDER) | |
366 | ) | |
367 | { | |
368 | ulFlags |= FCF_BORDER; | |
369 | } | |
776d87d5 DW |
370 | OS2Create( m_windowId |
371 | ,pParent | |
372 | ,wxCanvasClassName | |
373 | ,this | |
374 | ,NULL | |
375 | ,rPos.x | |
376 | ,rPos.y | |
377 | ,WidthDefault(rSize.x) | |
378 | ,HeightDefault(rSize.y) | |
379 | ,ulFlags | |
380 | ,NULL | |
381 | ,dwExStyle | |
382 | ); | |
383 | return(TRUE); | |
a885d89a | 384 | } // end of wxWindow::Create |
0e320a79 | 385 | |
cdf1e714 DW |
386 | // --------------------------------------------------------------------------- |
387 | // basic operations | |
388 | // --------------------------------------------------------------------------- | |
0e320a79 | 389 | |
cdf1e714 | 390 | void wxWindow::SetFocus() |
0e320a79 | 391 | { |
bbdc9a87 DW |
392 | HWND hWnd = GetHwnd(); |
393 | ||
394 | if (hWnd) | |
395 | ::WinSetFocus(HWND_DESKTOP, hWnd); | |
a885d89a | 396 | } // end of wxWindow::SetFocus |
0e320a79 | 397 | |
11e59d47 | 398 | wxWindow* wxWindowBase::FindFocus() |
0e320a79 | 399 | { |
bbdc9a87 DW |
400 | HWND hWnd = ::WinQueryFocus(HWND_DESKTOP); |
401 | ||
402 | if (hWnd) | |
403 | { | |
404 | return wxFindWinFromHandle((WXHWND)hWnd); | |
405 | } | |
406 | return NULL; | |
a885d89a | 407 | } // wxWindowBase::FindFocus |
0e320a79 | 408 | |
bbdc9a87 DW |
409 | bool wxWindow::Enable( |
410 | bool bEnable | |
411 | ) | |
0e320a79 | 412 | { |
bbdc9a87 DW |
413 | if (!wxWindowBase::Enable(bEnable)) |
414 | return(FALSE); | |
415 | ||
416 | HWND hWnd = GetHwnd(); | |
417 | ||
418 | if ( hWnd ) | |
419 | ::WinEnableWindow(hWnd, (BOOL)bEnable); | |
420 | ||
421 | wxWindowList::Node* pNode = GetChildren().GetFirst(); | |
422 | ||
423 | while (pNode) | |
424 | { | |
425 | wxWindow* pChild = pNode->GetData(); | |
426 | ||
427 | pChild->Enable(bEnable); | |
428 | pNode = pNode->GetNext(); | |
429 | } | |
cdf1e714 | 430 | return(TRUE); |
a885d89a | 431 | } // end of wxWindow::Enable |
0e320a79 | 432 | |
bbdc9a87 DW |
433 | bool wxWindow::Show( |
434 | bool bShow | |
435 | ) | |
0e320a79 | 436 | { |
bbdc9a87 DW |
437 | if (!wxWindowBase::Show(bShow)) |
438 | return(FALSE); | |
439 | ||
440 | HWND hWnd = GetHwnd(); | |
441 | ||
442 | ::WinShowWindow(hWnd, bShow); | |
443 | ||
444 | if (bShow) | |
445 | { | |
a885d89a | 446 | ::WinSetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE | SWP_ZORDER); |
bbdc9a87 | 447 | } |
849949b1 | 448 | return(TRUE); |
a885d89a | 449 | } // end of wxWindow::Show |
0e320a79 | 450 | |
cdf1e714 | 451 | void wxWindow::Raise() |
0e320a79 | 452 | { |
a885d89a DW |
453 | ::WinSetWindowPos(GetHwnd(), HWND_TOP, 0, 0, 0, 0, SWP_ZORDER | SWP_ACTIVATE); |
454 | } // end of wxWindow::Raise | |
0e320a79 | 455 | |
cdf1e714 | 456 | void wxWindow::Lower() |
0e320a79 | 457 | { |
a885d89a DW |
458 | ::WinSetWindowPos(GetHwnd(), HWND_BOTTOM, 0, 0, 0, 0, SWP_ZORDER | SWP_DEACTIVATE); |
459 | } // end of wxWindow::Lower | |
0e320a79 | 460 | |
bbdc9a87 DW |
461 | void wxWindow::SetTitle( |
462 | const wxString& rTitle | |
463 | ) | |
0e320a79 | 464 | { |
f38374d0 | 465 | ::WinSetWindowText(GetHwnd(), rTitle.c_str()); |
a885d89a | 466 | } // end of wxWindow::SetTitle |
0e320a79 | 467 | |
cdf1e714 | 468 | wxString wxWindow::GetTitle() const |
0e320a79 | 469 | { |
cdf1e714 | 470 | return wxGetWindowText(GetHWND()); |
a885d89a | 471 | } // end of wxWindow::GetTitle |
0e320a79 | 472 | |
cdf1e714 | 473 | void wxWindow::CaptureMouse() |
0e320a79 | 474 | { |
f38374d0 DW |
475 | HWND hWnd = GetHwnd(); |
476 | ||
477 | if (hWnd && !m_bWinCaptured) | |
478 | { | |
479 | ::WinSetCapture(HWND_DESKTOP, hWnd); | |
480 | m_bWinCaptured = TRUE; | |
481 | } | |
a885d89a | 482 | } // end of wxWindow::GetTitle |
0e320a79 | 483 | |
cdf1e714 | 484 | void wxWindow::ReleaseMouse() |
0e320a79 | 485 | { |
a885d89a | 486 | if (m_bWinCaptured) |
f38374d0 DW |
487 | { |
488 | ::WinSetCapture(HWND_DESKTOP, NULLHANDLE); | |
489 | m_bWinCaptured = FALSE; | |
490 | } | |
a885d89a | 491 | } // end of wxWindow::ReleaseMouse |
0e320a79 | 492 | |
f38374d0 DW |
493 | bool wxWindow::SetFont( |
494 | const wxFont& rFont | |
495 | ) | |
0e320a79 | 496 | { |
f38374d0 DW |
497 | if (!wxWindowBase::SetFont(rFont)) |
498 | { | |
499 | // nothing to do | |
500 | return(FALSE); | |
501 | } | |
502 | ||
503 | HWND hWnd = GetHwnd(); | |
504 | ||
505 | if (hWnd != 0) | |
506 | { | |
507 | wxChar zFont[128]; | |
508 | ||
509 | sprintf(zFont, "%d.%s", rFont.GetPointSize(), rFont.GetFaceName().c_str()); | |
510 | return(::WinSetPresParam(hWnd, PP_FONTNAMESIZE, strlen(zFont), (PVOID)zFont)); | |
511 | } | |
cdf1e714 | 512 | return(TRUE); |
0e320a79 DW |
513 | } |
514 | ||
f38374d0 DW |
515 | bool wxWindow::SetCursor( |
516 | const wxCursor& rCursor | |
517 | ) // check if base implementation is OK | |
0e320a79 | 518 | { |
f38374d0 DW |
519 | if ( !wxWindowBase::SetCursor(rCursor)) |
520 | { | |
521 | // no change | |
522 | return FALSE; | |
523 | } | |
524 | ||
525 | wxASSERT_MSG( m_cursor.Ok(), | |
526 | wxT("cursor must be valid after call to the base version")); | |
527 | ||
528 | HWND hWnd = GetHwnd(); | |
529 | POINTL vPoint; | |
530 | RECTL vRect; | |
531 | HPS hPS; | |
532 | HRGN hRGN; | |
533 | ||
534 | hPS = ::WinGetPS(hWnd); | |
535 | ||
536 | ::WinQueryPointerPos(HWND_DESKTOP, &vPoint); | |
537 | ::WinQueryWindowRect(hWnd, &vRect); | |
538 | ||
539 | hRGN = ::GpiCreateRegion(hPS, 1L, &vRect); | |
540 | ||
541 | if ((::GpiPtInRegion(hPS, hRGN, &vPoint) == PRGN_INSIDE) && !wxIsBusy()) | |
542 | { | |
a885d89a | 543 | ::WinSetPointer(HWND_DESKTOP, (HPOINTER)m_cursor.GetHCURSOR()); |
f38374d0 DW |
544 | } |
545 | return TRUE; | |
a885d89a | 546 | } // end of wxWindow::SetCursor |
0e320a79 | 547 | |
a885d89a DW |
548 | void wxWindow::WarpPointer( |
549 | int nXPos | |
550 | , int nYPos | |
551 | ) | |
0e320a79 | 552 | { |
a885d89a DW |
553 | int nX = nXPos; |
554 | int nY = nYPos; | |
555 | RECTL vRect; | |
556 | ||
557 | ::WinQueryWindowRect(GetHwnd(), &vRect); | |
558 | nX += vRect.xLeft; | |
559 | nY += vRect.yBottom; | |
560 | ||
561 | ::WinSetPointerPos(HWND_DESKTOP, (LONG)nX, (LONG)(nY)); | |
562 | } // end of wxWindow::WarpPointer | |
0e320a79 | 563 | |
cdf1e714 DW |
564 | #if WXWIN_COMPATIBILITY |
565 | void wxWindow::OS2DeviceToLogical (float *x, float *y) const | |
0e320a79 | 566 | { |
0e320a79 | 567 | } |
cdf1e714 | 568 | #endif // WXWIN_COMPATIBILITY |
0e320a79 | 569 | |
cdf1e714 DW |
570 | // --------------------------------------------------------------------------- |
571 | // scrolling stuff | |
572 | // --------------------------------------------------------------------------- | |
0e320a79 | 573 | |
cdf1e714 | 574 | #if WXWIN_COMPATIBILITY |
a885d89a DW |
575 | void wxWindow::SetScrollRange( |
576 | int nOrient | |
577 | , int nRange | |
578 | , bool bRefresh | |
579 | ) | |
0e320a79 | 580 | { |
a885d89a DW |
581 | ::WinSendMsg(GetHwnd(), SBM_SETSCROLLBAR, (MPARAM)0, MPFROM2SHORT(0, nRange)); |
582 | } // end of wxWindow::SetScrollRange | |
0e320a79 | 583 | |
a885d89a DW |
584 | void wxWindow::SetScrollPage( |
585 | int nOrient | |
586 | , int nPage | |
587 | , bool bRefresh | |
588 | ) | |
0e320a79 | 589 | { |
a885d89a DW |
590 | if ( orient == wxHORIZONTAL ) |
591 | m_xThumbSize = page; | |
592 | else | |
593 | m_yThumbSize = page; | |
0e320a79 DW |
594 | } |
595 | ||
a885d89a DW |
596 | int wxWindow::OldGetScrollRange( |
597 | int nOrient | |
598 | ) const | |
0e320a79 | 599 | { |
a885d89a DW |
600 | MRESULT mRc; |
601 | HWND hWnd = GetHwnd(); | |
0e320a79 | 602 | |
a885d89a DW |
603 | if (hWnd) |
604 | { | |
605 | mRc = WinSendMsg(hWnd, SBM_QUERYRANGE, (MPARAM)0L, (MPARAM)0L); | |
606 | return(SHORT2FROMMR(mRc)); | |
607 | } | |
608 | return 0; | |
609 | } // end of wxWindow::OldGetScrollRange | |
610 | ||
611 | int wxWindow::GetScrollPage( | |
612 | int nOrient | |
613 | ) const | |
0e320a79 | 614 | { |
a885d89a | 615 | if (nOrient == wxHORIZONTAL) |
05fc6c0a | 616 | return m_nXThumbSize; |
a885d89a | 617 | else |
05fc6c0a | 618 | return m_nYThumbSize; |
a885d89a | 619 | } // end of wxWindow::GetScrollPage |
11e59d47 | 620 | #endif // WXWIN_COMPATIBILITY |
0e320a79 | 621 | |
05fc6c0a DW |
622 | int wxWindow::GetScrollPos( |
623 | int nOrient | |
624 | ) const | |
0e320a79 | 625 | { |
05fc6c0a DW |
626 | return((int)::WinSendMsg(GetHwnd(), SBM_QUERYPOS, (MPARAM)NULL, (MPARAM)NULL)); |
627 | } // end of wxWindow::GetScrollPos | |
0e320a79 | 628 | |
05fc6c0a DW |
629 | int wxWindow::GetScrollRange( |
630 | int nOrient | |
631 | ) const | |
0e320a79 | 632 | { |
05fc6c0a | 633 | MRESULT mr; |
0e320a79 | 634 | |
05fc6c0a DW |
635 | mr = ::WinSendMsg(GetHwnd(), SBM_QUERYRANGE, (MPARAM)NULL, (MPARAM)NULL); |
636 | return((int)SHORT2FROMMR(mr)); | |
637 | } // end of wxWindow::GetScrollRange | |
638 | ||
639 | int wxWindow::GetScrollThumb( | |
640 | int nOrient | |
641 | ) const | |
0e320a79 | 642 | { |
05fc6c0a DW |
643 | WNDPARAMS vWndParams; |
644 | PSBCDATA pSbcd; | |
645 | ||
646 | ::WinSendMsg(GetHwnd(), WM_QUERYWINDOWPARAMS, (MPARAM)&vWndParams, (MPARAM)NULL); | |
647 | pSbcd = (PSBCDATA)vWndParams.pCtlData; | |
648 | return((int)pSbcd->posThumb); | |
649 | } // end of wxWindow::GetScrollThumb | |
0e320a79 | 650 | |
05fc6c0a DW |
651 | void wxWindow::SetScrollPos( |
652 | int nOrient | |
653 | , int nPos | |
654 | , bool bRefresh | |
655 | ) | |
0e320a79 | 656 | { |
05fc6c0a DW |
657 | ::WinSendMsg(GetHwnd(), SBM_SETPOS, (MPARAM)nPos, (MPARAM)NULL); |
658 | } // end of wxWindow::SetScrollPos( | |
0e320a79 | 659 | |
05fc6c0a DW |
660 | void wxWindow::SetScrollbar( |
661 | int nOrient | |
662 | , int nPos | |
663 | , int nThumbVisible | |
664 | , int nRange | |
665 | , bool bRefresh | |
666 | ) | |
0e320a79 | 667 | { |
05fc6c0a DW |
668 | ::WinSendMsg(GetHwnd(), SBM_SETSCROLLBAR, (MPARAM)nPos, MPFROM2SHORT(0, nRange)); |
669 | if (nOrient == wxHORIZONTAL) | |
670 | { | |
671 | m_nXThumbSize = nThumbVisible; | |
672 | } | |
673 | else | |
674 | { | |
675 | m_nYThumbSize = nThumbVisible; | |
676 | } | |
677 | } // end of wxWindow::SetScrollbar | |
0e320a79 | 678 | |
05fc6c0a DW |
679 | void wxWindow::ScrollWindow( |
680 | int nDx | |
681 | , int nDy | |
682 | , const wxRect* pRect | |
683 | ) | |
0e320a79 | 684 | { |
05fc6c0a DW |
685 | RECTL vRect2; |
686 | ||
687 | if (pRect) | |
688 | { | |
689 | vRect2.xLeft = pRect->x; | |
690 | vRect2.yTop = pRect->y; | |
691 | vRect2.xRight = pRect->x + pRect->width; | |
692 | vRect2.yBottom = pRect->y + pRect->height; | |
693 | } | |
694 | ||
695 | if (pRect) | |
696 | ::WinScrollWindow(GetHwnd(), (LONG)nDx, (LONG)nDy, &vRect2, NULL, NULLHANDLE, NULL, 0L); | |
697 | else | |
698 | ::WinScrollWindow(GetHwnd(), nDx, nDy, NULL, NULL, NULLHANDLE, NULL, 0L); | |
699 | } // end of wxWindow::ScrollWindow | |
0e320a79 | 700 | |
cdf1e714 DW |
701 | // --------------------------------------------------------------------------- |
702 | // subclassing | |
703 | // --------------------------------------------------------------------------- | |
0e320a79 | 704 | |
c86c44a0 DW |
705 | void wxWindow::SubclassWin( |
706 | WXHWND hWnd | |
707 | ) | |
0e320a79 | 708 | { |
05fc6c0a DW |
709 | HAB hab; |
710 | HWND hwnd = (HWND)hWnd; | |
711 | ||
776d87d5 | 712 | wxASSERT_MSG( !m_fnOldWndProc, wxT("subclassing window twice?") ); |
0e320a79 | 713 | |
c86c44a0 DW |
714 | wxCHECK_RET(::WinIsWindow(hab, hwnd), wxT("invalid HWND in SubclassWin") ); |
715 | ||
716 | wxAssociateWinWithHandle(hwnd, this); | |
717 | ||
542875a8 DW |
718 | m_fnOldWndProc = (WXFARPROC) ::WinSubclassWindow(hwnd, (PFNWP)wxWndProc); |
719 | ::WinSetWindowULong(hwnd, QWS_USER, (ULONG)wxWndProc); | |
c86c44a0 | 720 | } // end of wxWindow::SubclassWin |
0e320a79 | 721 | |
cdf1e714 | 722 | void wxWindow::UnsubclassWin() |
0e320a79 | 723 | { |
c86c44a0 | 724 | HAB hab; |
0e320a79 | 725 | |
cdf1e714 | 726 | wxRemoveHandleAssociation(this); |
0e320a79 | 727 | |
c86c44a0 | 728 | // |
cdf1e714 | 729 | // Restore old Window proc |
c86c44a0 DW |
730 | // |
731 | HWND hwnd = GetHwnd(); | |
732 | ||
733 | if (hwnd) | |
cdf1e714 DW |
734 | { |
735 | m_hWnd = 0; | |
0e320a79 | 736 | |
c86c44a0 | 737 | wxCHECK_RET( ::WinIsWindow(hab, hwnd), wxT("invalid HWND in UnsubclassWin") ); |
0e320a79 | 738 | |
c86c44a0 DW |
739 | PFNWP fnProc = (PFNWP)::WinQueryWindowULong(hwnd, QWS_USER); |
740 | if ( (m_fnOldWndProc != 0) && (fnProc != (PFNWP) m_fnOldWndProc)) | |
cdf1e714 | 741 | { |
c86c44a0 DW |
742 | WinSubclassWindow(hwnd, (PFNWP)m_fnOldWndProc); |
743 | m_fnOldWndProc = 0; | |
cdf1e714 DW |
744 | } |
745 | } | |
c86c44a0 | 746 | } // end of wxWindow::UnsubclassWin |
0e320a79 | 747 | |
05fc6c0a | 748 | // |
cdf1e714 | 749 | // Make a Windows extended style from the given wxWindows window style |
05fc6c0a DW |
750 | // |
751 | WXDWORD wxWindow::MakeExtendedStyle( | |
752 | long lStyle | |
753 | , bool bEliminateBorders | |
754 | ) | |
0e320a79 | 755 | { |
05fc6c0a DW |
756 | // |
757 | // PM does not support extended style | |
758 | // | |
759 | WXDWORD exStyle = 0; | |
cdf1e714 | 760 | return exStyle; |
05fc6c0a | 761 | } // end of wxWindow::MakeExtendedStyle |
cdf1e714 | 762 | |
c86c44a0 | 763 | // |
cdf1e714 DW |
764 | // Determines whether native 3D effects or CTL3D should be used, |
765 | // applying a default border style if required, and returning an extended | |
766 | // style to pass to CreateWindowEx. | |
c86c44a0 DW |
767 | // |
768 | WXDWORD wxWindow::Determine3DEffects( | |
769 | WXDWORD dwDefaultBorderStyle | |
542875a8 | 770 | , bool* pbWant3D |
c86c44a0 DW |
771 | ) const |
772 | { | |
542875a8 DW |
773 | WXDWORD dwStyle = 0L; |
774 | ||
c86c44a0 DW |
775 | // |
776 | // Native PM does not have any specialize 3D effects like WIN32 does | |
777 | // | |
778 | *pbWant3D = FALSE; | |
779 | return dwStyle; | |
780 | } // end of wxWindow::Determine3DEffects | |
cdf1e714 DW |
781 | |
782 | #if WXWIN_COMPATIBILITY | |
c86c44a0 DW |
783 | void wxWindow::OnCommand( |
784 | wxWindow& rWin | |
785 | , wxCommandEvent& rEvent | |
786 | ) | |
cdf1e714 | 787 | { |
c86c44a0 DW |
788 | if (GetEventHandler()->ProcessEvent(rEvent)) |
789 | return; | |
790 | if (m_parent) | |
791 | m_parent->GetEventHandler()->OnCommand( rWin | |
792 | ,rEvent | |
793 | ); | |
794 | } // end of wxWindow::OnCommand | |
cdf1e714 | 795 | |
c86c44a0 DW |
796 | wxObject* wxWindow::GetChild( |
797 | int nNumber | |
798 | ) const | |
cdf1e714 | 799 | { |
c86c44a0 DW |
800 | // |
801 | // Return a pointer to the Nth object in the Panel | |
802 | // | |
803 | wxNode* pNode = GetChildren().First(); | |
804 | int n = nNumber; | |
cdf1e714 | 805 | |
c86c44a0 DW |
806 | while (pNode && n--) |
807 | pNode = pNode->Next(); | |
808 | if (pNode) | |
809 | { | |
810 | wxObject* pObj = (wxObject*)pNode->Data(); | |
811 | return(pObj); | |
812 | } | |
813 | else | |
814 | return NULL; | |
815 | } // end of wxWindow::GetChild | |
cdf1e714 DW |
816 | |
817 | #endif // WXWIN_COMPATIBILITY | |
818 | ||
c86c44a0 | 819 | // |
cdf1e714 | 820 | // Setup background and foreground colours correctly |
c86c44a0 | 821 | // |
cdf1e714 DW |
822 | void wxWindow::SetupColours() |
823 | { | |
824 | if ( GetParent() ) | |
825 | SetBackgroundColour(GetParent()->GetBackgroundColour()); | |
c86c44a0 | 826 | } // end of wxWindow::SetupColours |
cdf1e714 | 827 | |
c86c44a0 DW |
828 | void wxWindow::OnIdle( |
829 | wxIdleEvent& rEvent | |
830 | ) | |
cdf1e714 | 831 | { |
c86c44a0 DW |
832 | // |
833 | // Check if we need to send a LEAVE event | |
834 | // | |
835 | if (m_bMouseInWindow) | |
836 | { | |
837 | POINTL vPoint; | |
cdf1e714 | 838 | |
c86c44a0 DW |
839 | ::WinQueryPointerPos(HWND_DESKTOP, &vPoint); |
840 | if (::WinWindowFromPoint(HWND_DESKTOP, &vPoint, FALSE) != (HWND)GetHwnd()) | |
841 | { | |
842 | // | |
843 | // Generate a LEAVE event | |
844 | // | |
845 | m_bMouseInWindow = FALSE; | |
846 | ||
847 | // | |
848 | // Unfortunately the mouse button and keyboard state may have changed | |
849 | // by the time the OnIdle function is called, so 'state' may be | |
850 | // meaningless. | |
851 | // | |
852 | int nState = 0; | |
853 | ||
854 | if (::WinGetKeyState(HWND_DESKTOP, VK_SHIFT) != 0) | |
855 | nState |= VK_SHIFT; | |
542875a8 | 856 | if (::WinGetKeyState(HWND_DESKTOP, VK_CTRL) != 0); |
c86c44a0 DW |
857 | nState |= VK_CTRL; |
858 | ||
859 | wxMouseEvent rEvent(wxEVT_LEAVE_WINDOW); | |
860 | ||
861 | InitMouseEvent( rEvent | |
862 | ,vPoint.x | |
863 | ,vPoint.y | |
864 | ,nState | |
865 | ); | |
542875a8 | 866 | (void)GetEventHandler()->ProcessEvent(rEvent); |
c86c44a0 DW |
867 | } |
868 | } | |
869 | UpdateWindowUI(); | |
870 | } // end of wxWindow::OnIdle | |
871 | ||
872 | // | |
cdf1e714 | 873 | // Set this window to be the child of 'parent'. |
c86c44a0 DW |
874 | // |
875 | bool wxWindow::Reparent( | |
876 | wxWindow* pParent | |
877 | ) | |
cdf1e714 | 878 | { |
c86c44a0 | 879 | if (!wxWindowBase::Reparent(pParent)) |
cdf1e714 | 880 | return FALSE; |
c86c44a0 DW |
881 | |
882 | HWND hWndChild = GetHwnd(); | |
883 | HWND hWndParent = GetParent() ? GetWinHwnd(GetParent()) : (HWND)0; | |
884 | ||
885 | ::WinSetParent(hWndChild, hWndParent, TRUE); | |
886 | return TRUE; | |
887 | } // end of wxWindow::Reparent | |
cdf1e714 DW |
888 | |
889 | void wxWindow::Clear() | |
890 | { | |
c86c44a0 DW |
891 | wxClientDC vDc(this); |
892 | wxBrush vBrush( GetBackgroundColour() | |
893 | ,wxSOLID | |
894 | ); | |
895 | ||
896 | vDc.SetBackground(vBrush); | |
897 | vDc.Clear(); | |
898 | } // end of wxWindow::Clear | |
cdf1e714 | 899 | |
c86c44a0 DW |
900 | void wxWindow::Refresh( |
901 | bool bEraseBack | |
902 | , const wxRect* pRect | |
903 | ) | |
cdf1e714 | 904 | { |
c86c44a0 DW |
905 | HWND hWnd = GetHwnd(); |
906 | ||
907 | if (hWnd) | |
908 | { | |
909 | if (pRect) | |
910 | { | |
911 | RECTL vOs2Rect; | |
912 | ||
913 | vOs2Rect.xLeft = pRect->x; | |
542875a8 | 914 | vOs2Rect.yTop = pRect->y; |
c86c44a0 DW |
915 | vOs2Rect.xRight = pRect->x + pRect->width; |
916 | vOs2Rect.yBottom = pRect->y + pRect->height; | |
917 | ||
918 | ::WinInvalidateRect(hWnd, &vOs2Rect, bEraseBack); | |
919 | } | |
920 | else | |
921 | ::WinInvalidateRect(hWnd, NULL, bEraseBack); | |
922 | } | |
923 | } // end of wxWindow::Refresh | |
cdf1e714 DW |
924 | |
925 | // --------------------------------------------------------------------------- | |
926 | // drag and drop | |
927 | // --------------------------------------------------------------------------- | |
928 | ||
929 | #if wxUSE_DRAG_AND_DROP | |
c86c44a0 DW |
930 | void wxWindow::SetDropTarget( |
931 | wxDropTarget* pDropTarget | |
932 | ) | |
cdf1e714 | 933 | { |
542875a8 | 934 | if (m_dropTarget != 0) |
c86c44a0 DW |
935 | { |
936 | m_dropTarget->Revoke(m_hWnd); | |
937 | delete m_dropTarget; | |
938 | } | |
939 | m_dropTarget = pDropTarget; | |
940 | if (m_dropTarget != 0) | |
941 | m_dropTarget->Register(m_hWnd); | |
942 | } // end of wxWindow::SetDropTarget | |
cdf1e714 DW |
943 | #endif |
944 | ||
c86c44a0 | 945 | // |
cdf1e714 DW |
946 | // old style file-manager drag&drop support: we retain the old-style |
947 | // DragAcceptFiles in parallel with SetDropTarget. | |
c86c44a0 DW |
948 | // |
949 | void wxWindow::DragAcceptFiles( | |
950 | bool bAccept | |
951 | ) | |
cdf1e714 | 952 | { |
c86c44a0 DW |
953 | HWND hWnd = GetHwnd(); |
954 | ||
955 | if (hWnd && bAccept) | |
542875a8 | 956 | ::DrgAcceptDroppedFiles(hWnd, NULL, NULL, DO_COPY, 0L); |
c86c44a0 | 957 | } // end of wxWindow::DragAcceptFiles |
cdf1e714 DW |
958 | |
959 | // ---------------------------------------------------------------------------- | |
960 | // tooltips | |
961 | // ---------------------------------------------------------------------------- | |
962 | ||
963 | #if wxUSE_TOOLTIPS | |
964 | ||
c86c44a0 DW |
965 | void wxWindow::DoSetToolTip( |
966 | wxToolTip* pTooltip | |
967 | ) | |
cdf1e714 | 968 | { |
c86c44a0 | 969 | wxWindowBase::DoSetToolTip(pTooltip); |
cdf1e714 | 970 | |
542875a8 | 971 | if (m_tooltip) |
cdf1e714 | 972 | m_tooltip->SetWindow(this); |
c86c44a0 | 973 | } // end of wxWindow::DoSetToolTip |
cdf1e714 DW |
974 | |
975 | #endif // wxUSE_TOOLTIPS | |
976 | ||
977 | // --------------------------------------------------------------------------- | |
978 | // moving and resizing | |
979 | // --------------------------------------------------------------------------- | |
980 | ||
981 | // Get total size | |
542875a8 | 982 | void wxWindow::DoGetSize( |
a7ef993c DW |
983 | int* pWidth |
984 | , int* pHeight | |
985 | ) const | |
cdf1e714 | 986 | { |
a7ef993c DW |
987 | HWND hWnd = GetHwnd(); |
988 | RECTL vRect; | |
c86c44a0 | 989 | |
a7ef993c DW |
990 | ::WinQueryWindowRect(hWnd, &vRect); |
991 | ||
992 | if (pWidth) | |
993 | *pWidth = vRect.xRight - vRect.xLeft; | |
994 | if (pHeight ) | |
995 | // OS/2 PM is backwards from windows | |
996 | *pHeight = vRect.yTop - vRect.yBottom; | |
997 | } // end of wxWindow::DoGetSize | |
cdf1e714 | 998 | |
a7ef993c DW |
999 | void wxWindow::DoGetPosition( |
1000 | int* pX | |
1001 | , int* pY | |
1002 | ) const | |
cdf1e714 | 1003 | { |
a7ef993c DW |
1004 | HWND hWnd = GetHwnd(); |
1005 | RECT vRect; | |
1006 | POINTL vPoint; | |
c86c44a0 | 1007 | |
a7ef993c | 1008 | ::WinQueryWindowRect(hWnd, &vRect); |
c86c44a0 | 1009 | |
a7ef993c DW |
1010 | vPoint.x = vRect.xLeft; |
1011 | vPoint.y = vRect.yBottom; | |
c86c44a0 | 1012 | |
a7ef993c DW |
1013 | // |
1014 | // We do the adjustments with respect to the parent only for the "real" | |
c86c44a0 | 1015 | // children, not for the dialogs/frames |
a7ef993c DW |
1016 | // |
1017 | if (!IsTopLevel()) | |
c86c44a0 | 1018 | { |
a7ef993c DW |
1019 | HWND hParentWnd = 0; |
1020 | wxWindow* pParent = GetParent(); | |
1021 | ||
1022 | if (pParent) | |
1023 | hParentWnd = GetWinHwnd(pParent); | |
c86c44a0 | 1024 | |
a7ef993c | 1025 | // |
c86c44a0 | 1026 | // Since we now have the absolute screen coords, if there's a parent we |
a7ef993c DW |
1027 | // must subtract its bottom left corner |
1028 | // | |
1029 | if (hParentWnd) | |
c86c44a0 | 1030 | { |
a7ef993c DW |
1031 | RECTL vRect2; |
1032 | ||
542875a8 | 1033 | ::WinQueryWindowRect(hParentWnd, &vRect2); |
a7ef993c DW |
1034 | vPoint.x -= vRect.xLeft; |
1035 | vPoint.y -= vRect.yBottom; | |
c86c44a0 DW |
1036 | } |
1037 | ||
a7ef993c | 1038 | // |
c86c44a0 DW |
1039 | // We may be faking the client origin. So a window that's really at (0, |
1040 | // 30) may appear (to wxWin apps) to be at (0, 0). | |
a7ef993c DW |
1041 | // |
1042 | wxPoint vPt(pParent->GetClientAreaOrigin()); | |
1043 | ||
1044 | vPoint.x -= vPt.x; | |
1045 | vPoint.y -= vPt.y; | |
c86c44a0 DW |
1046 | } |
1047 | ||
a7ef993c DW |
1048 | if (pX) |
1049 | *pX = vPoint.x; | |
542875a8 | 1050 | if (pY) |
a7ef993c DW |
1051 | *pY = vPoint.y; |
1052 | } // end of wxWindow::DoGetPosition | |
cdf1e714 | 1053 | |
a7ef993c DW |
1054 | void wxWindow::DoScreenToClient( |
1055 | int* pX | |
1056 | , int* pY | |
1057 | ) const | |
cdf1e714 | 1058 | { |
a7ef993c | 1059 | HWND hWnd = GetHwnd(); |
542875a8 DW |
1060 | SWP vSwp; |
1061 | ||
1062 | ::WinQueryWindowPos(hWnd, &vSwp); | |
cdf1e714 | 1063 | |
a7ef993c | 1064 | if (pX) |
542875a8 | 1065 | *pX -= vSwp.x; |
a7ef993c | 1066 | if (pY) |
542875a8 | 1067 | *pY -= vSwp.y; |
a7ef993c DW |
1068 | } // end of wxWindow::DoScreenToClient |
1069 | ||
1070 | void wxWindow::DoClientToScreen( | |
1071 | int* pX | |
1072 | , int* pY | |
1073 | ) const | |
cdf1e714 | 1074 | { |
a7ef993c | 1075 | HWND hWnd = GetHwnd(); |
542875a8 | 1076 | SWP vSwp; |
c86c44a0 | 1077 | |
542875a8 | 1078 | ::WinQueryWindowPos(hWnd, &vSwp); |
c86c44a0 | 1079 | |
a7ef993c | 1080 | if (pX) |
542875a8 | 1081 | *pX += vSwp.x; |
a7ef993c | 1082 | if (pY) |
542875a8 | 1083 | *pY += vSwp.y; |
a7ef993c | 1084 | } // end of wxWindow::DoClientToScreen |
cdf1e714 | 1085 | |
a7ef993c | 1086 | // |
cdf1e714 | 1087 | // Get size *available for subwindows* i.e. excluding menu bar etc. |
a7ef993c DW |
1088 | // Must be a frame type window |
1089 | // | |
1090 | void wxWindow::DoGetClientSize( | |
1091 | int* pWidth | |
1092 | , int* pHeight | |
1093 | ) const | |
cdf1e714 | 1094 | { |
a7ef993c DW |
1095 | HWND hWnd = GetHwnd(); |
1096 | HWND hWndClient; | |
1097 | RECTL vRect; | |
1098 | ||
1099 | hWndClient = ::WinWindowFromID(GetHwnd(), FID_CLIENT); | |
1100 | ::WinQueryWindowRect(hWndClient, &vRect); | |
1101 | ||
542875a8 | 1102 | if (pWidth) |
a7ef993c | 1103 | *pWidth = vRect.xRight; |
542875a8 | 1104 | if (pHeight) |
a7ef993c DW |
1105 | *pHeight = vRect.yTop; |
1106 | } // end of wxWindow::DoGetClientSize | |
cdf1e714 | 1107 | |
a7ef993c DW |
1108 | void wxWindow::DoMoveWindow( |
1109 | int nX | |
1110 | , int nY | |
1111 | , int nWidth | |
1112 | , int nHeight | |
1113 | ) | |
cdf1e714 | 1114 | { |
542875a8 DW |
1115 | if ( !::WinSetWindowPos( GetHwnd() |
1116 | ,HWND_TOP | |
1117 | ,(LONG)nX | |
1118 | ,(LONG)nY | |
1119 | ,(LONG)nWidth | |
1120 | ,(LONG)nHeight | |
1121 | ,SWP_SIZE | SWP_MOVE | |
1122 | )) | |
c86c44a0 DW |
1123 | { |
1124 | wxLogLastError("MoveWindow"); | |
1125 | } | |
a7ef993c | 1126 | } // end of wxWindow::DoMoveWindow |
cdf1e714 | 1127 | |
c86c44a0 DW |
1128 | // |
1129 | // Set the size of the window: if the dimensions are positive, just use them, | |
cdf1e714 DW |
1130 | // but if any of them is equal to -1, it means that we must find the value for |
1131 | // it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in | |
1132 | // which case -1 is a valid value for x and y) | |
1133 | // | |
1134 | // If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate | |
1135 | // the width/height to best suit our contents, otherwise we reuse the current | |
1136 | // width/height | |
c86c44a0 | 1137 | // |
a7ef993c DW |
1138 | void wxWindow::DoSetSize( |
1139 | int nX | |
1140 | , int nY | |
1141 | , int nWidth | |
1142 | , int nHeight | |
1143 | , int nSizeFlags | |
1144 | ) | |
cdf1e714 | 1145 | { |
a7ef993c DW |
1146 | // |
1147 | // Get the current size and position... | |
1148 | // | |
1149 | int nCurrentX; | |
1150 | int nCurrentY; | |
1151 | int nCurrentWidth; | |
1152 | int nCurrentHeight; | |
542875a8 | 1153 | wxSize vSize(-1, -1); |
a7ef993c DW |
1154 | |
1155 | GetPosition( &nCurrentX | |
1156 | ,&nCurrentY | |
1157 | ); | |
1158 | GetSize( &nCurrentWidth | |
1159 | ,&nCurrentHeight | |
1160 | ); | |
c86c44a0 | 1161 | |
a7ef993c | 1162 | // |
c86c44a0 | 1163 | // ... and don't do anything (avoiding flicker) if it's already ok |
a7ef993c | 1164 | // |
542875a8 | 1165 | if ( nX == nCurrentX && |
a7ef993c | 1166 | nY == nCurrentY && |
542875a8 | 1167 | nWidth == nCurrentWidth && |
a7ef993c DW |
1168 | nHeight == nCurrentHeight |
1169 | ) | |
c86c44a0 DW |
1170 | { |
1171 | return; | |
1172 | } | |
1173 | ||
a7ef993c DW |
1174 | if (nX == -1 && !(nSizeFlags & wxSIZE_ALLOW_MINUS_ONE)) |
1175 | nX = nCurrentX; | |
542875a8 | 1176 | if (nY == -1 && !(nSizeFlags & wxSIZE_ALLOW_MINUS_ONE)) |
a7ef993c | 1177 | nY = nCurrentY; |
c86c44a0 | 1178 | |
a7ef993c DW |
1179 | AdjustForParentClientOrigin( nX |
1180 | ,nY | |
1181 | ,nSizeFlags | |
1182 | ); | |
c86c44a0 | 1183 | |
a7ef993c | 1184 | if (nWidth == -1) |
c86c44a0 | 1185 | { |
a7ef993c | 1186 | if (nSizeFlags & wxSIZE_AUTO_WIDTH) |
c86c44a0 | 1187 | { |
a7ef993c DW |
1188 | vSize = DoGetBestSize(); |
1189 | nWidth = vSize.x; | |
c86c44a0 DW |
1190 | } |
1191 | else | |
1192 | { | |
a7ef993c DW |
1193 | // |
1194 | // Just take the current one | |
1195 | // | |
1196 | nWidth = nCurrentWidth; | |
c86c44a0 DW |
1197 | } |
1198 | } | |
1199 | ||
a7ef993c | 1200 | if (nHeight == -1) |
c86c44a0 | 1201 | { |
a7ef993c | 1202 | if (nSizeFlags & wxSIZE_AUTO_HEIGHT) |
c86c44a0 | 1203 | { |
a7ef993c | 1204 | if (vSize.x == -1) |
c86c44a0 | 1205 | { |
a7ef993c | 1206 | vSize = DoGetBestSize(); |
c86c44a0 | 1207 | } |
a7ef993c | 1208 | nHeight = vSize.y; |
c86c44a0 DW |
1209 | } |
1210 | else | |
1211 | { | |
1212 | // just take the current one | |
a7ef993c | 1213 | nHeight = nCurrentHeight; |
c86c44a0 DW |
1214 | } |
1215 | } | |
1216 | ||
a7ef993c DW |
1217 | DoMoveWindow( nX |
1218 | ,nY | |
1219 | ,nWidth | |
1220 | ,nHeight | |
1221 | ); | |
1222 | } // end of wxWindow::DoSetSize | |
cdf1e714 | 1223 | |
a7ef993c DW |
1224 | void wxWindow::DoSetClientSize( |
1225 | int nWidth | |
1226 | , int nHeight | |
1227 | ) | |
cdf1e714 | 1228 | { |
a7ef993c DW |
1229 | wxWindow* pParent = GetParent(); |
1230 | HWND hWnd = GetHwnd(); | |
1231 | HWND hParentWnd = (HWND)0; | |
1232 | HWND hClientWnd = (HWND)0; | |
1233 | RECTL vRect; | |
1234 | RECT vRect2; | |
1235 | RECT vRect3; | |
c86c44a0 | 1236 | |
542875a8 | 1237 | hClientWnd = ::WinWindowFromID(GetHwnd(), FID_CLIENT); |
a7ef993c | 1238 | ::WinQueryWindowRect(hClientWnd, &vRect2); |
c86c44a0 | 1239 | |
a7ef993c DW |
1240 | if (pParent) |
1241 | hParentWnd = (HWND) pParent->GetHWND(); | |
c86c44a0 | 1242 | |
a7ef993c DW |
1243 | ::WinQueryWindowRect(hWnd, &vRect); |
1244 | ::WinQueryWindowRect(hParentWnd, &vRect3); | |
1245 | // | |
c86c44a0 DW |
1246 | // Find the difference between the entire window (title bar and all) |
1247 | // and the client area; add this to the new client size to move the | |
a7ef993c DW |
1248 | // window. OS/2 is backward from windows on height |
1249 | // | |
1250 | int nActualWidth = vRect2.xRight - vRect2.xLeft - vRect.xRight + nWidth; | |
1251 | int nActualHeight = vRect2.yTop - vRect2.yBottom - vRect.yTop + nHeight; | |
c86c44a0 | 1252 | |
a7ef993c DW |
1253 | // |
1254 | // If there's a parent, must subtract the parent's bottom left corner | |
c86c44a0 | 1255 | // since MoveWindow moves relative to the parent |
a7ef993c DW |
1256 | // |
1257 | POINTL vPoint; | |
c86c44a0 | 1258 | |
a7ef993c DW |
1259 | vPoint.x = vRect2.xLeft; |
1260 | vPoint.y = vRect2.yBottom; | |
1261 | if (pParent) | |
c86c44a0 | 1262 | { |
a7ef993c | 1263 | vPoint.x -= vRect3.xLeft; |
542875a8 | 1264 | vPoint.y -= vRect3.yBottom; |
c86c44a0 DW |
1265 | } |
1266 | ||
a7ef993c DW |
1267 | DoMoveWindow( vPoint.x |
1268 | ,vPoint.y | |
1269 | ,nActualWidth | |
1270 | ,nActualHeight | |
1271 | ); | |
c86c44a0 | 1272 | |
a7ef993c DW |
1273 | wxSizeEvent vEvent( wxSize( nWidth |
1274 | ,nHeight | |
1275 | ) | |
1276 | ,m_windowId | |
1277 | ); | |
1278 | ||
1279 | vEvent.SetEventObject(this); | |
1280 | GetEventHandler()->ProcessEvent(vEvent); | |
1281 | } // end of wxWindow::DoSetClientSize | |
cdf1e714 DW |
1282 | |
1283 | wxPoint wxWindow::GetClientAreaOrigin() const | |
1284 | { | |
1285 | return wxPoint(0, 0); | |
a7ef993c | 1286 | } // end of wxWindow::GetClientAreaOrigin |
cdf1e714 | 1287 | |
a7ef993c DW |
1288 | void wxWindow::AdjustForParentClientOrigin( |
1289 | int& rX | |
1290 | , int& rY | |
1291 | , int nSizeFlags | |
1292 | ) | |
cdf1e714 | 1293 | { |
a7ef993c DW |
1294 | // |
1295 | // Don't do it for the dialogs/frames - they float independently of their | |
c86c44a0 | 1296 | // parent |
a7ef993c DW |
1297 | // |
1298 | if (!IsTopLevel()) | |
c86c44a0 | 1299 | { |
a7ef993c DW |
1300 | wxWindow* pParent = GetParent(); |
1301 | ||
1302 | if (!(nSizeFlags & wxSIZE_NO_ADJUSTMENTS) && pParent) | |
c86c44a0 | 1303 | { |
a7ef993c | 1304 | wxPoint vPoint(pParent->GetClientAreaOrigin()); |
542875a8 | 1305 | rX += vPoint.x; |
a7ef993c | 1306 | rY += vPoint.y; |
c86c44a0 DW |
1307 | } |
1308 | } | |
a7ef993c | 1309 | } // end of wxWindow::AdjustForParentClientOrigin |
cdf1e714 DW |
1310 | |
1311 | // --------------------------------------------------------------------------- | |
1312 | // text metrics | |
1313 | // --------------------------------------------------------------------------- | |
1314 | ||
a7ef993c | 1315 | int wxWindow::GetCharHeight() const |
cdf1e714 | 1316 | { |
a7ef993c DW |
1317 | HPS hPs; |
1318 | FONTMETRICS vFontMetrics; | |
1319 | BOOL bRc; | |
cdf1e714 | 1320 | |
a7ef993c DW |
1321 | hPs = ::WinGetPS(GetHwnd()); |
1322 | ||
542875a8 | 1323 | if(!GpiQueryFontMetrics(hPs, sizeof(FONTMETRICS), &vFontMetrics)) |
a7ef993c DW |
1324 | return (0); |
1325 | else | |
1326 | return(vFontMetrics.lMaxAscender + vFontMetrics.lMaxDescender); | |
1327 | ::WinReleasePS(hPs); | |
1328 | } // end of wxWindow::GetCharHeight | |
1329 | ||
1330 | int wxWindow::GetCharWidth() const | |
cdf1e714 | 1331 | { |
542875a8 DW |
1332 | HPS hPs; |
1333 | FONTMETRICS vFontMetrics; | |
1334 | ||
a7ef993c | 1335 | hPs = ::WinGetPS(GetHwnd()); |
cdf1e714 | 1336 | |
542875a8 | 1337 | if(!GpiQueryFontMetrics(hPs, sizeof(FONTMETRICS), &vFontMetrics)) |
a7ef993c DW |
1338 | return (0); |
1339 | else | |
1340 | return(vFontMetrics.lAveCharWidth); | |
1341 | ::WinReleasePS(hPs); | |
1342 | } // end of wxWindow::GetCharWidth | |
1343 | ||
542875a8 | 1344 | void wxWindow::GetTextExtent( |
a7ef993c DW |
1345 | const wxString& rString |
1346 | , int* pX | |
1347 | , int* pY | |
1348 | , int* pDescent | |
1349 | , int* pExternalLeading | |
1350 | , const wxFont* pTheFont | |
1351 | ) const | |
cdf1e714 | 1352 | { |
a7ef993c DW |
1353 | const wxFont* pFontToUse = pTheFont; |
1354 | HPS hPs; | |
1355 | ||
1356 | hPs = ::WinGetPS(GetHwnd()); | |
1357 | /* | |
1358 | // TODO: Will have to play with fonts later | |
1359 | ||
1360 | if (!pFontToUse) | |
1361 | pFontToUse = &m_font; | |
1362 | ||
1363 | HFONT hFnt = 0; | |
1364 | HFONT hFfontOld = 0; | |
1365 | ||
1366 | if (pFontToUse && pFontToUse->Ok()) | |
1367 | { | |
1368 | ::GpiCreateLog | |
1369 | hFnt = (HFONT)((wxFont *)pFontToUse)->GetResourceHandle(); // const_cast | |
1370 | if (hFnt) | |
1371 | hFontOld = (HFONT)SelectObject(dc,fnt); | |
1372 | } | |
1373 | ||
1374 | SIZE sizeRect; | |
1375 | TEXTMETRIC tm; | |
1376 | GetTextExtentPoint(dc, string, (int)string.Length(), &sizeRect); | |
1377 | GetTextMetrics(dc, &tm); | |
1378 | ||
1379 | if ( fontToUse && fnt && hfontOld ) | |
1380 | SelectObject(dc, hfontOld); | |
1381 | ||
1382 | ReleaseDC(hWnd, dc); | |
1383 | ||
1384 | if ( x ) | |
1385 | *x = sizeRect.cx; | |
1386 | if ( y ) | |
1387 | *y = sizeRect.cy; | |
1388 | if ( descent ) | |
1389 | *descent = tm.tmDescent; | |
1390 | if ( externalLeading ) | |
1391 | *externalLeading = tm.tmExternalLeading; | |
1392 | */ | |
1393 | ::WinReleasePS(hPs); | |
cdf1e714 DW |
1394 | } |
1395 | ||
1396 | #if wxUSE_CARET && WXWIN_COMPATIBILITY | |
1397 | // --------------------------------------------------------------------------- | |
1398 | // Caret manipulation | |
1399 | // --------------------------------------------------------------------------- | |
1400 | ||
a7ef993c DW |
1401 | void wxWindow::CreateCaret( |
1402 | int nWidth | |
1403 | , int nHeight | |
1404 | ) | |
cdf1e714 | 1405 | { |
a7ef993c DW |
1406 | SetCaret(new wxCaret( this |
1407 | ,nWidth | |
1408 | ,nHeight | |
1409 | )); | |
1410 | } // end of wxWindow::CreateCaret | |
1411 | ||
1412 | void wxWindow::CreateCaret( | |
1413 | const wxBitmap* pBitmap | |
1414 | ) | |
cdf1e714 | 1415 | { |
a7ef993c DW |
1416 | wxFAIL_MSG("not implemented"); |
1417 | } // end of wxWindow::CreateCaret | |
cdf1e714 | 1418 | |
a7ef993c DW |
1419 | void wxWindow::ShowCaret( |
1420 | bool bShow | |
1421 | ) | |
cdf1e714 | 1422 | { |
a7ef993c DW |
1423 | wxCHECK_RET( m_caret, "no caret to show" ); |
1424 | ||
1425 | m_caret->Show(bShow); | |
1426 | } // end of wxWindow::ShowCaret | |
cdf1e714 DW |
1427 | |
1428 | void wxWindow::DestroyCaret() | |
1429 | { | |
a7ef993c DW |
1430 | SetCaret(NULL); |
1431 | } // end of wxWindow::DestroyCaret | |
cdf1e714 | 1432 | |
a7ef993c DW |
1433 | void wxWindow::SetCaretPos( |
1434 | int nX | |
1435 | , int nY) | |
cdf1e714 | 1436 | { |
a7ef993c DW |
1437 | wxCHECK_RET( m_caret, "no caret to move" ); |
1438 | ||
1439 | m_caret->Move( nX | |
1440 | ,nY | |
1441 | ); | |
1442 | } // end of wxWindow::SetCaretPos | |
cdf1e714 | 1443 | |
a7ef993c DW |
1444 | void wxWindow::GetCaretPos( |
1445 | int* pX | |
1446 | , int* pY | |
1447 | ) const | |
cdf1e714 | 1448 | { |
a7ef993c DW |
1449 | wxCHECK_RET( m_caret, "no caret to get position of" ); |
1450 | ||
1451 | m_caret->GetPosition( pX | |
1452 | ,pY | |
1453 | ); | |
1454 | } // end of wxWindow::GetCaretPos | |
cdf1e714 DW |
1455 | |
1456 | #endif //wxUSE_CARET | |
1457 | ||
1458 | // --------------------------------------------------------------------------- | |
1459 | // popup menu | |
1460 | // --------------------------------------------------------------------------- | |
1461 | ||
1462 | bool wxWindow::DoPopupMenu( wxMenu *menu, int x, int y ) | |
1463 | { | |
1464 | // TODO: | |
1465 | return(TRUE); | |
1466 | } | |
1467 | ||
1468 | // =========================================================================== | |
1469 | // pre/post message processing | |
1470 | // =========================================================================== | |
1471 | ||
a885d89a | 1472 | MRESULT wxWindow::OS2DefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) |
cdf1e714 DW |
1473 | { |
1474 | // TODO: | |
1475 | return (MRESULT)0; | |
1476 | } | |
1477 | ||
1478 | bool wxWindow::OS2ProcessMessage(WXMSG* pMsg) | |
1479 | { | |
1480 | // TODO: | |
1481 | return FALSE; | |
1482 | } | |
1483 | ||
1484 | bool wxWindow::OS2TranslateMessage(WXMSG* pMsg) | |
1485 | { | |
1486 | return m_acceleratorTable.Translate(this, pMsg); | |
1487 | } | |
1488 | ||
1489 | // --------------------------------------------------------------------------- | |
1490 | // message params unpackers (different for Win16 and Win32) | |
1491 | // --------------------------------------------------------------------------- | |
1492 | ||
1493 | void wxWindow::UnpackCommand(WXWPARAM wParam, WXLPARAM lParam, | |
1494 | WORD *id, WXHWND *hwnd, WORD *cmd) | |
1495 | { | |
1496 | *id = LOWORD(wParam); | |
1497 | *hwnd = (WXHWND)lParam; | |
1498 | *cmd = HIWORD(wParam); | |
1499 | } | |
1500 | ||
1501 | void wxWindow::UnpackActivate(WXWPARAM wParam, WXLPARAM lParam, | |
1502 | WXWORD *state, WXWORD *minimized, WXHWND *hwnd) | |
1503 | { | |
1504 | *state = LOWORD(wParam); | |
1505 | *minimized = HIWORD(wParam); | |
1506 | *hwnd = (WXHWND)lParam; | |
1507 | } | |
1508 | ||
1509 | void wxWindow::UnpackScroll(WXWPARAM wParam, WXLPARAM lParam, | |
1510 | WXWORD *code, WXWORD *pos, WXHWND *hwnd) | |
1511 | { | |
1512 | *code = LOWORD(wParam); | |
1513 | *pos = HIWORD(wParam); | |
1514 | *hwnd = (WXHWND)lParam; | |
1515 | } | |
1516 | ||
1517 | void wxWindow::UnpackCtlColor(WXWPARAM wParam, WXLPARAM lParam, | |
1518 | WXWORD *nCtlColor, WXHDC *hdc, WXHWND *hwnd) | |
1519 | { | |
11e59d47 | 1520 | *nCtlColor = 0; // TODO: CTLCOLOR_BTN; |
cdf1e714 DW |
1521 | *hwnd = (WXHWND)lParam; |
1522 | *hdc = (WXHDC)wParam; | |
1523 | } | |
1524 | ||
1525 | void wxWindow::UnpackMenuSelect(WXWPARAM wParam, WXLPARAM lParam, | |
1526 | WXWORD *item, WXWORD *flags, WXHMENU *hmenu) | |
1527 | { | |
11e59d47 | 1528 | *item = (WXWORD)LOWORD(wParam); |
cdf1e714 DW |
1529 | *flags = HIWORD(wParam); |
1530 | *hmenu = (WXHMENU)lParam; | |
1531 | } | |
1532 | ||
1533 | // --------------------------------------------------------------------------- | |
1534 | // Main wxWindows window proc and the window proc for wxWindow | |
1535 | // --------------------------------------------------------------------------- | |
1536 | ||
1537 | // Hook for new window just as it's being created, when the window isn't yet | |
1538 | // associated with the handle | |
1539 | wxWindow *wxWndHook = NULL; | |
1540 | ||
1541 | // Main window proc | |
9dea36ef | 1542 | MRESULT wxWndProc(HWND hWnd, ULONG message, MPARAM wParam, MPARAM lParam) |
cdf1e714 DW |
1543 | { |
1544 | // trace all messages - useful for the debugging | |
1545 | #ifdef __WXDEBUG__ | |
1546 | wxLogTrace(wxTraceMessages, wxT("Processing %s(wParam=%8lx, lParam=%8lx)"), | |
1547 | wxGetMessageName(message), wParam, lParam); | |
1548 | #endif // __WXDEBUG__ | |
1549 | ||
1550 | wxWindow *wnd = wxFindWinFromHandle((WXHWND) hWnd); | |
1551 | ||
1552 | // when we get the first message for the HWND we just created, we associate | |
1553 | // it with wxWindow stored in wxWndHook | |
1554 | if ( !wnd && wxWndHook ) | |
1555 | { | |
1556 | #if 0 // def __WXDEBUG__ | |
1557 | char buf[512]; | |
1558 | ::GetClassNameA((HWND) hWnd, buf, 512); | |
1559 | wxString className(buf); | |
1560 | #endif | |
1561 | ||
1562 | wxAssociateWinWithHandle(hWnd, wxWndHook); | |
1563 | wnd = wxWndHook; | |
1564 | wxWndHook = NULL; | |
1565 | wnd->SetHWND((WXHWND)hWnd); | |
1566 | } | |
1567 | ||
1568 | MRESULT rc; | |
1569 | ||
1570 | // Stop right here if we don't have a valid handle in our wxWindow object. | |
1571 | if ( wnd && !wnd->GetHWND() ) | |
1572 | { | |
1573 | // FIXME: why do we do this? | |
1574 | wnd->SetHWND((WXHWND) hWnd); | |
a885d89a | 1575 | rc = wnd->OS2DefWindowProc(message, wParam, lParam ); |
cdf1e714 DW |
1576 | wnd->SetHWND(0); |
1577 | } | |
1578 | else | |
1579 | { | |
1580 | if ( wnd ) | |
a885d89a | 1581 | rc = wnd->OS2WindowProc(message, wParam, lParam); |
cdf1e714 | 1582 | else |
11e59d47 | 1583 | rc = 0; //TODO: DefWindowProc( hWnd, message, wParam, lParam ); |
cdf1e714 DW |
1584 | } |
1585 | ||
1586 | return rc; | |
1587 | } | |
1588 | ||
a885d89a | 1589 | MRESULT wxWindow::OS2WindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) |
cdf1e714 DW |
1590 | { |
1591 | // did we process the message? | |
1592 | bool processed = FALSE; | |
1593 | ||
1594 | // the return value | |
1595 | union | |
1596 | { | |
1597 | bool allow; | |
1598 | long result; | |
1599 | WXHICON hIcon; | |
1600 | WXHBRUSH hBrush; | |
1601 | } rc; | |
1602 | ||
1603 | // for most messages we should return 0 when we do process the message | |
1604 | rc.result = 0; | |
1605 | // TODO: | |
1606 | /* | |
1607 | switch ( message ) | |
1608 | { | |
1609 | case WM_CREATE: | |
1610 | { | |
1611 | bool mayCreate; | |
1612 | processed = HandleCreate((WXLPCREATESTRUCT)lParam, &mayCreate); | |
1613 | if ( processed ) | |
1614 | { | |
1615 | // return 0 to allow window creation | |
1616 | rc.result = mayCreate ? 0 : -1; | |
1617 | } | |
1618 | } | |
1619 | break; | |
1620 | ||
1621 | case WM_DESTROY: | |
1622 | processed = HandleDestroy(); | |
1623 | break; | |
1624 | ||
1625 | case WM_MOVE: | |
1626 | processed = HandleMove(LOWORD(lParam), HIWORD(lParam)); | |
1627 | break; | |
1628 | ||
1629 | case WM_SIZE: | |
1630 | processed = HandleSize(LOWORD(lParam), HIWORD(lParam), wParam); | |
1631 | break; | |
1632 | ||
1633 | case WM_ACTIVATE: | |
1634 | { | |
1635 | WXWORD state, minimized; | |
1636 | WXHWND hwnd; | |
1637 | UnpackActivate(wParam, lParam, &state, &minimized, &hwnd); | |
1638 | ||
1639 | processed = HandleActivate(state, minimized != 0, (WXHWND)hwnd); | |
1640 | } | |
1641 | break; | |
1642 | ||
1643 | case WM_SETFOCUS: | |
1644 | processed = HandleSetFocus((WXHWND)(HWND)wParam); | |
1645 | break; | |
1646 | ||
1647 | case WM_KILLFOCUS: | |
1648 | processed = HandleKillFocus((WXHWND)(HWND)wParam); | |
1649 | break; | |
1650 | ||
1651 | case WM_PAINT: | |
1652 | processed = HandlePaint(); | |
1653 | break; | |
1654 | ||
1655 | case WM_CLOSE: | |
1656 | // don't let the DefWindowProc() destroy our window - we'll do it | |
1657 | // ourselves in ~wxWindow | |
1658 | processed = TRUE; | |
1659 | rc.result = TRUE; | |
1660 | break; | |
1661 | ||
1662 | case WM_SHOWWINDOW: | |
1663 | processed = HandleShow(wParam != 0, (int)lParam); | |
1664 | break; | |
1665 | ||
1666 | case WM_MOUSEMOVE: | |
1667 | case WM_LBUTTONDOWN: | |
1668 | case WM_LBUTTONUP: | |
1669 | case WM_LBUTTONDBLCLK: | |
1670 | case WM_RBUTTONDOWN: | |
1671 | case WM_RBUTTONUP: | |
1672 | case WM_RBUTTONDBLCLK: | |
1673 | case WM_MBUTTONDOWN: | |
1674 | case WM_MBUTTONUP: | |
1675 | case WM_MBUTTONDBLCLK: | |
1676 | { | |
1677 | short x = LOWORD(lParam); | |
1678 | short y = HIWORD(lParam); | |
1679 | ||
1680 | processed = HandleMouseEvent(message, x, y, wParam); | |
1681 | } | |
1682 | break; | |
1683 | ||
1684 | case MM_JOY1MOVE: | |
1685 | case MM_JOY2MOVE: | |
1686 | case MM_JOY1ZMOVE: | |
1687 | case MM_JOY2ZMOVE: | |
1688 | case MM_JOY1BUTTONDOWN: | |
1689 | case MM_JOY2BUTTONDOWN: | |
1690 | case MM_JOY1BUTTONUP: | |
1691 | case MM_JOY2BUTTONUP: | |
1692 | { | |
1693 | int x = LOWORD(lParam); | |
1694 | int y = HIWORD(lParam); | |
1695 | ||
1696 | processed = HandleJoystickEvent(message, x, y, wParam); | |
1697 | } | |
1698 | break; | |
1699 | ||
1700 | case WM_SYSCOMMAND: | |
1701 | processed = HandleSysCommand(wParam, lParam); | |
1702 | break; | |
1703 | ||
1704 | case WM_COMMAND: | |
1705 | { | |
1706 | WORD id, cmd; | |
1707 | WXHWND hwnd; | |
1708 | UnpackCommand(wParam, lParam, &id, &hwnd, &cmd); | |
1709 | ||
1710 | processed = HandleCommand(id, cmd, hwnd); | |
1711 | } | |
1712 | break; | |
1713 | ||
1714 | #ifdef __WIN95__ | |
1715 | case WM_NOTIFY: | |
1716 | processed = HandleNotify((int)wParam, lParam, &rc.result); | |
1717 | break; | |
1718 | #endif // Win95 | |
1719 | ||
1720 | // for these messages we must return TRUE if process the message | |
1721 | case WM_DRAWITEM: | |
1722 | case WM_MEASUREITEM: | |
1723 | { | |
1724 | int idCtrl = (UINT)wParam; | |
1725 | if ( message == WM_DRAWITEM ) | |
1726 | { | |
1727 | processed = MSWOnDrawItem(idCtrl, | |
1728 | (WXDRAWITEMSTRUCT *)lParam); | |
1729 | } | |
1730 | else | |
1731 | { | |
1732 | processed = MSWOnMeasureItem(idCtrl, | |
1733 | (WXMEASUREITEMSTRUCT *)lParam); | |
1734 | } | |
1735 | ||
1736 | if ( processed ) | |
1737 | rc.result = TRUE; | |
1738 | } | |
1739 | break; | |
1740 | ||
1741 | case WM_GETDLGCODE: | |
1742 | if ( m_lDlgCode ) | |
1743 | { | |
1744 | rc.result = m_lDlgCode; | |
1745 | processed = TRUE; | |
1746 | } | |
1747 | //else: get the dlg code from the DefWindowProc() | |
1748 | break; | |
1749 | ||
1750 | case WM_KEYDOWN: | |
1751 | // If this has been processed by an event handler, | |
1752 | // return 0 now (we've handled it). | |
1753 | if ( HandleKeyDown((WORD) wParam, lParam) ) | |
1754 | { | |
1755 | processed = TRUE; | |
1756 | ||
1757 | break; | |
1758 | } | |
1759 | ||
1760 | // we consider these message "not interesting" to OnChar | |
1761 | if ( wParam == VK_SHIFT || wParam == VK_CONTROL ) | |
1762 | { | |
1763 | processed = TRUE; | |
1764 | ||
1765 | break; | |
1766 | } | |
1767 | ||
1768 | switch ( wParam ) | |
1769 | { | |
1770 | // avoid duplicate messages to OnChar for these ASCII keys: they | |
1771 | // will be translated by TranslateMessage() and received in WM_CHAR | |
1772 | case VK_ESCAPE: | |
1773 | case VK_SPACE: | |
1774 | case VK_RETURN: | |
1775 | case VK_BACK: | |
1776 | case VK_TAB: | |
1777 | // but set processed to FALSE, not TRUE to still pass them to | |
1778 | // the control's default window proc - otherwise built-in | |
1779 | // keyboard handling won't work | |
1780 | processed = FALSE; | |
1781 | ||
1782 | break; | |
1783 | ||
1784 | #ifdef VK_APPS | |
1785 | // special case of VK_APPS: treat it the same as right mouse | |
1786 | // click because both usually pop up a context menu | |
1787 | case VK_APPS: | |
1788 | { | |
1789 | // construct the key mask | |
1790 | WPARAM fwKeys = MK_RBUTTON; | |
1791 | if ( (::GetKeyState(VK_CONTROL) & 0x100) != 0 ) | |
1792 | fwKeys |= MK_CONTROL; | |
1793 | if ( (::GetKeyState(VK_SHIFT) & 0x100) != 0 ) | |
1794 | fwKeys |= MK_SHIFT; | |
1795 | ||
1796 | // simulate right mouse button click | |
1797 | DWORD dwPos = ::GetMessagePos(); | |
1798 | int x = GET_X_LPARAM(dwPos), | |
1799 | y = GET_Y_LPARAM(dwPos); | |
1800 | ||
1801 | ScreenToClient(&x, &y); | |
1802 | processed = HandleMouseEvent(WM_RBUTTONDOWN, x, y, fwKeys); | |
1803 | } | |
1804 | break; | |
1805 | #endif // VK_APPS | |
1806 | ||
1807 | case VK_LEFT: | |
1808 | case VK_RIGHT: | |
1809 | case VK_DOWN: | |
1810 | case VK_UP: | |
1811 | default: | |
1812 | processed = HandleChar((WORD)wParam, lParam); | |
1813 | } | |
1814 | break; | |
1815 | ||
1816 | case WM_KEYUP: | |
1817 | processed = HandleKeyUp((WORD) wParam, lParam); | |
1818 | break; | |
1819 | ||
1820 | case WM_CHAR: // Always an ASCII character | |
1821 | processed = HandleChar((WORD)wParam, lParam, TRUE); | |
1822 | break; | |
1823 | ||
1824 | case WM_HSCROLL: | |
1825 | case WM_VSCROLL: | |
1826 | { | |
1827 | WXWORD code, pos; | |
1828 | WXHWND hwnd; | |
1829 | UnpackScroll(wParam, lParam, &code, &pos, &hwnd); | |
1830 | ||
1831 | processed = MSWOnScroll(message == WM_HSCROLL ? wxHORIZONTAL | |
1832 | : wxVERTICAL, | |
1833 | code, pos, hwnd); | |
1834 | } | |
1835 | break; | |
1836 | ||
1837 | // CTLCOLOR messages are sent by children to query the parent for their | |
1838 | // colors | |
1839 | #ifdef __WIN32__ | |
1840 | case WM_CTLCOLORMSGBOX: | |
1841 | case WM_CTLCOLOREDIT: | |
1842 | case WM_CTLCOLORLISTBOX: | |
1843 | case WM_CTLCOLORBTN: | |
1844 | case WM_CTLCOLORDLG: | |
1845 | case WM_CTLCOLORSCROLLBAR: | |
1846 | case WM_CTLCOLORSTATIC: | |
1847 | #else // Win16 | |
1848 | case WM_CTLCOLOR: | |
1849 | #endif // Win32/16 | |
1850 | { | |
1851 | WXWORD nCtlColor; | |
1852 | WXHDC hdc; | |
1853 | WXHWND hwnd; | |
1854 | UnpackCtlColor(wParam, lParam, &nCtlColor, &hdc, &hwnd); | |
1855 | ||
1856 | processed = HandleCtlColor(&rc.hBrush, | |
1857 | (WXHDC)hdc, | |
1858 | (WXHWND)hwnd, | |
1859 | nCtlColor, | |
1860 | message, | |
1861 | wParam, | |
1862 | lParam); | |
1863 | } | |
1864 | break; | |
1865 | ||
1866 | // the return value for this message is ignored | |
1867 | case WM_SYSCOLORCHANGE: | |
1868 | processed = HandleSysColorChange(); | |
1869 | break; | |
1870 | ||
1871 | case WM_PALETTECHANGED: | |
1872 | processed = HandlePaletteChanged((WXHWND) (HWND) wParam); | |
1873 | break; | |
1874 | ||
1875 | case WM_QUERYNEWPALETTE: | |
1876 | processed = HandleQueryNewPalette(); | |
1877 | break; | |
1878 | ||
1879 | case WM_ERASEBKGND: | |
1880 | processed = HandleEraseBkgnd((WXHDC)(HDC)wParam); | |
1881 | if ( processed ) | |
1882 | { | |
1883 | // we processed the message, i.e. erased the background | |
1884 | rc.result = TRUE; | |
1885 | } | |
1886 | break; | |
1887 | ||
1888 | case WM_DROPFILES: | |
1889 | processed = HandleDropFiles(wParam); | |
1890 | break; | |
1891 | ||
1892 | case WM_INITDIALOG: | |
1893 | processed = HandleInitDialog((WXHWND)(HWND)wParam); | |
1894 | ||
1895 | if ( processed ) | |
1896 | { | |
1897 | // we never set focus from here | |
1898 | rc.result = FALSE; | |
1899 | } | |
1900 | break; | |
1901 | ||
1902 | case WM_QUERYENDSESSION: | |
1903 | processed = HandleQueryEndSession(lParam, &rc.allow); | |
1904 | break; | |
1905 | ||
1906 | case WM_ENDSESSION: | |
1907 | processed = HandleEndSession(wParam != 0, lParam); | |
1908 | break; | |
1909 | ||
1910 | case WM_GETMINMAXINFO: | |
1911 | processed = HandleGetMinMaxInfo((MINMAXINFO*)lParam); | |
1912 | break; | |
1913 | ||
1914 | case WM_SETCURSOR: | |
1915 | processed = HandleSetCursor((WXHWND)(HWND)wParam, | |
1916 | LOWORD(lParam), // hit test | |
1917 | HIWORD(lParam)); // mouse msg | |
1918 | ||
1919 | if ( processed ) | |
1920 | { | |
1921 | // returning TRUE stops the DefWindowProc() from further | |
1922 | // processing this message - exactly what we need because we've | |
1923 | // just set the cursor. | |
1924 | rc.result = TRUE; | |
1925 | } | |
1926 | break; | |
1927 | } | |
1928 | ||
1929 | if ( !processed ) | |
1930 | { | |
1931 | #ifdef __WXDEBUG__ | |
1932 | wxLogTrace(wxTraceMessages, wxT("Forwarding %s to DefWindowProc."), | |
1933 | wxGetMessageName(message)); | |
1934 | #endif // __WXDEBUG__ | |
1935 | rc.result = MSWDefWindowProc(message, wParam, lParam); | |
1936 | } | |
1937 | */ | |
11e59d47 | 1938 | return (MRESULT)0; |
cdf1e714 DW |
1939 | } |
1940 | ||
1941 | // Dialog window proc | |
11e59d47 | 1942 | MRESULT wxDlgProc(HWND hWnd, UINT message, MPARAM wParam, MPARAM lParam) |
cdf1e714 DW |
1943 | { |
1944 | // TODO: | |
1945 | /* | |
1946 | if ( message == WM_INITDIALOG ) | |
1947 | { | |
1948 | // for this message, returning TRUE tells system to set focus to the | |
1949 | // first control in the dialog box | |
1950 | return TRUE; | |
1951 | } | |
1952 | else | |
1953 | { | |
1954 | // for all the other ones, FALSE means that we didn't process the | |
1955 | // message | |
1956 | return 0; | |
1957 | } | |
1958 | */ | |
1959 | return (MRESULT)0; | |
1960 | } | |
1961 | ||
cdf1e714 DW |
1962 | wxWindow *wxFindWinFromHandle(WXHWND hWnd) |
1963 | { | |
1964 | wxNode *node = wxWinHandleList->Find((long)hWnd); | |
1965 | if ( !node ) | |
1966 | return NULL; | |
1967 | return (wxWindow *)node->Data(); | |
1968 | } | |
1969 | ||
1970 | void wxAssociateWinWithHandle(HWND hWnd, wxWindow *win) | |
1971 | { | |
1972 | // adding NULL hWnd is (first) surely a result of an error and | |
1973 | // (secondly) breaks menu command processing | |
1974 | wxCHECK_RET( hWnd != (HWND)NULL, | |
1975 | wxT("attempt to add a NULL hWnd to window list ignored") ); | |
1976 | ||
1977 | ||
1978 | wxWindow *oldWin = wxFindWinFromHandle((WXHWND) hWnd); | |
1979 | if ( oldWin && (oldWin != win) ) | |
1980 | { | |
1981 | wxString str(win->GetClassInfo()->GetClassName()); | |
1982 | wxLogError("Bug! Found existing HWND %X for new window of class %s", (int) hWnd, (const char*) str); | |
1983 | } | |
1984 | else if (!oldWin) | |
1985 | { | |
1986 | wxWinHandleList->Append((long)hWnd, win); | |
1987 | } | |
1988 | } | |
1989 | ||
1990 | void wxRemoveHandleAssociation(wxWindow *win) | |
1991 | { | |
1992 | wxWinHandleList->DeleteObject(win); | |
1993 | } | |
1994 | ||
1995 | // Default destroyer - override if you destroy it in some other way | |
1996 | // (e.g. with MDI child windows) | |
1997 | void wxWindow::OS2DestroyWindow() | |
1998 | { | |
1999 | } | |
2000 | ||
2001 | void wxWindow::OS2DetachWindowMenu() | |
2002 | { | |
2003 | if ( m_hMenu ) | |
2004 | { | |
2005 | HMENU hMenu = (HMENU)m_hMenu; | |
2006 | ||
2007 | int N = (int)WinSendMsg(hMenu, MM_QUERYITEMCOUNT, 0, 0); | |
2008 | int i; | |
2009 | for (i = 0; i < N; i++) | |
2010 | { | |
2011 | wxChar buf[100]; | |
2012 | int chars = (int)WinSendMsg(hMenu, MM_QUERYITEMTEXT, MPFROM2SHORT(i, N), buf); | |
2013 | if ( !chars ) | |
2014 | { | |
2015 | wxLogLastError(wxT("GetMenuString")); | |
2016 | ||
2017 | continue; | |
2018 | } | |
2019 | ||
2020 | if ( wxStrcmp(buf, wxT("&Window")) == 0 ) | |
2021 | { | |
2022 | WinSendMsg(hMenu, MM_DELETEITEM, MPFROM2SHORT(i, TRUE), 0); | |
2023 | break; | |
2024 | } | |
2025 | } | |
2026 | } | |
2027 | } | |
2028 | ||
2029 | bool wxWindow::OS2Create(int id, | |
2030 | wxWindow *parent, | |
2031 | const wxChar *wclass, | |
2032 | wxWindow *wx_win, | |
2033 | const wxChar *title, | |
2034 | int x, | |
2035 | int y, | |
2036 | int width, | |
2037 | int height, | |
2038 | WXDWORD style, | |
2039 | const wxChar *dialog_template, | |
2040 | WXDWORD extendedStyle) | |
2041 | { | |
2042 | // TODO: | |
2043 | /* | |
2044 | int x1 = CW_USEDEFAULT; | |
2045 | int y1 = 0; | |
2046 | int width1 = CW_USEDEFAULT; | |
2047 | int height1 = 100; | |
2048 | ||
2049 | // Find parent's size, if it exists, to set up a possible default | |
2050 | // panel size the size of the parent window | |
2051 | RECT parent_rect; | |
2052 | if ( parent ) | |
2053 | { | |
2054 | ::GetClientRect((HWND) parent->GetHWND(), &parent_rect); | |
2055 | ||
2056 | width1 = parent_rect.right - parent_rect.left; | |
2057 | height1 = parent_rect.bottom - parent_rect.top; | |
2058 | } | |
2059 | ||
2060 | if ( x > -1 ) x1 = x; | |
2061 | if ( y > -1 ) y1 = y; | |
2062 | if ( width > -1 ) width1 = width; | |
2063 | if ( height > -1 ) height1 = height; | |
2064 | ||
2065 | HWND hParent = (HWND)NULL; | |
2066 | if ( parent ) | |
2067 | hParent = (HWND) parent->GetHWND(); | |
2068 | ||
2069 | wxWndHook = this; | |
2070 | ||
2071 | if ( dialog_template ) | |
2072 | { | |
2073 | m_hWnd = (WXHWND)::CreateDialog(wxGetInstance(), | |
2074 | dialog_template, | |
2075 | hParent, | |
2076 | (DLGPROC)wxDlgProc); | |
2077 | ||
2078 | if ( m_hWnd == 0 ) | |
2079 | { | |
2080 | wxLogError(_("Can't find dummy dialog template!\n" | |
2081 | "Check resource include path for finding wx.rc.")); | |
2082 | ||
2083 | return FALSE; | |
2084 | } | |
2085 | ||
2086 | // ::SetWindowLong(GWL_EXSTYLE) doesn't work for the dialogs, so try | |
2087 | // to take care of (at least some) extended style flags ourselves | |
2088 | if ( extendedStyle & WS_EX_TOPMOST ) | |
2089 | { | |
2090 | if ( !::SetWindowPos(GetHwnd(), HWND_TOPMOST, 0, 0, 0, 0, | |
2091 | SWP_NOSIZE | SWP_NOMOVE) ) | |
2092 | { | |
2093 | wxLogLastError(wxT("SetWindowPos")); | |
2094 | } | |
2095 | } | |
2096 | ||
2097 | // move the dialog to its initial position without forcing repainting | |
2098 | if ( !::MoveWindow(GetHwnd(), x1, y1, width1, height1, FALSE) ) | |
2099 | { | |
2100 | wxLogLastError(wxT("MoveWindow")); | |
2101 | } | |
2102 | } | |
2103 | else | |
2104 | { | |
2105 | int controlId = 0; | |
2106 | if ( style & WS_CHILD ) | |
2107 | controlId = id; | |
2108 | ||
2109 | wxString className(wclass); | |
2110 | if ( GetWindowStyleFlag() & wxNO_FULL_REPAINT_ON_RESIZE ) | |
2111 | { | |
2112 | className += wxT("NR"); | |
2113 | } | |
2114 | ||
2115 | m_hWnd = (WXHWND)CreateWindowEx(extendedStyle, | |
2116 | className, | |
2117 | title ? title : wxT(""), | |
2118 | style, | |
2119 | x1, y1, | |
2120 | width1, height1, | |
2121 | hParent, (HMENU)controlId, | |
2122 | wxGetInstance(), | |
2123 | NULL); | |
2124 | ||
2125 | if ( !m_hWnd ) | |
2126 | { | |
2127 | wxLogError(_("Can't create window of class %s!\n" | |
2128 | "Possible Windows 3.x compatibility problem?"), | |
2129 | wclass); | |
2130 | ||
2131 | return FALSE; | |
2132 | } | |
2133 | } | |
2134 | ||
2135 | wxWndHook = NULL; | |
2136 | #ifdef __WXDEBUG__ | |
2137 | wxNode* node = wxWinHandleList->Member(this); | |
2138 | if (node) | |
2139 | { | |
2140 | HWND hWnd = (HWND) node->GetKeyInteger(); | |
2141 | if (hWnd != (HWND) m_hWnd) | |
2142 | { | |
2143 | wxLogError("A second HWND association is being added for the same window!"); | |
2144 | } | |
2145 | } | |
2146 | #endif | |
2147 | */ | |
2148 | wxAssociateWinWithHandle((HWND) m_hWnd, this); | |
2149 | ||
2150 | return TRUE; | |
2151 | } | |
2152 | ||
2153 | // =========================================================================== | |
2154 | // OS2 PM message handlers | |
2155 | // =========================================================================== | |
2156 | ||
2157 | // --------------------------------------------------------------------------- | |
2158 | // WM_NOTIFY | |
2159 | // --------------------------------------------------------------------------- | |
2160 | ||
2161 | bool wxWindow::HandleNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) | |
2162 | { | |
2163 | // TODO: | |
2164 | return FALSE; | |
2165 | } | |
2166 | ||
2167 | bool wxWindow::OS2OnNotify(int WXUNUSED(idCtrl), | |
2168 | WXLPARAM lParam, | |
2169 | WXLPARAM* WXUNUSED(result)) | |
2170 | { | |
2171 | // TODO: | |
2172 | return FALSE; | |
2173 | } | |
2174 | ||
2175 | // --------------------------------------------------------------------------- | |
2176 | // end session messages | |
2177 | // --------------------------------------------------------------------------- | |
2178 | ||
2179 | bool wxWindow::HandleQueryEndSession(long logOff, bool *mayEnd) | |
2180 | { | |
2181 | wxCloseEvent event(wxEVT_QUERY_END_SESSION, -1); | |
2182 | event.SetEventObject(wxTheApp); | |
2183 | event.SetCanVeto(TRUE); | |
2184 | event.SetLoggingOff(logOff == ENDSESSION_LOGOFF); | |
2185 | ||
2186 | bool rc = wxTheApp->ProcessEvent(event); | |
2187 | ||
2188 | if ( rc ) | |
2189 | { | |
2190 | // we may end only if the app didn't veto session closing (double | |
2191 | // negation...) | |
2192 | *mayEnd = !event.GetVeto(); | |
2193 | } | |
2194 | ||
2195 | return rc; | |
2196 | } | |
2197 | ||
2198 | bool wxWindow::HandleEndSession(bool endSession, long logOff) | |
2199 | { | |
2200 | // do nothing if the session isn't ending | |
2201 | if ( !endSession ) | |
2202 | return FALSE; | |
2203 | ||
2204 | wxCloseEvent event(wxEVT_END_SESSION, -1); | |
2205 | event.SetEventObject(wxTheApp); | |
2206 | event.SetCanVeto(FALSE); | |
2207 | event.SetLoggingOff( (logOff == ENDSESSION_LOGOFF) ); | |
2208 | if ( (this == wxTheApp->GetTopWindow()) && // Only send once | |
2209 | wxTheApp->ProcessEvent(event)) | |
2210 | { | |
2211 | } | |
2212 | return TRUE; | |
2213 | } | |
2214 | ||
2215 | // --------------------------------------------------------------------------- | |
2216 | // window creation/destruction | |
2217 | // --------------------------------------------------------------------------- | |
2218 | ||
2219 | bool wxWindow::HandleCreate(WXLPCREATESTRUCT cs, bool *mayCreate) | |
2220 | { | |
2221 | // TODO: should generate this event from WM_NCCREATE | |
2222 | wxWindowCreateEvent event(this); | |
2223 | (void)GetEventHandler()->ProcessEvent(event); | |
2224 | ||
2225 | *mayCreate = TRUE; | |
2226 | ||
2227 | return TRUE; | |
2228 | } | |
2229 | ||
2230 | bool wxWindow::HandleDestroy() | |
2231 | { | |
2232 | wxWindowDestroyEvent event(this); | |
2233 | (void)GetEventHandler()->ProcessEvent(event); | |
2234 | ||
2235 | // delete our drop target if we've got one | |
2236 | #if wxUSE_DRAG_AND_DROP | |
2237 | if ( m_dropTarget != NULL ) | |
2238 | { | |
11e59d47 | 2239 | // m_dropTarget->Revoke(m_hWnd); |
cdf1e714 DW |
2240 | |
2241 | delete m_dropTarget; | |
2242 | m_dropTarget = NULL; | |
2243 | } | |
2244 | #endif // wxUSE_DRAG_AND_DROP | |
2245 | ||
2246 | // WM_DESTROY handled | |
2247 | return TRUE; | |
2248 | } | |
2249 | ||
2250 | // --------------------------------------------------------------------------- | |
2251 | // activation/focus | |
2252 | // --------------------------------------------------------------------------- | |
2253 | ||
2254 | bool wxWindow::HandleActivate(int state, | |
2255 | bool WXUNUSED(minimized), | |
2256 | WXHWND WXUNUSED(activate)) | |
2257 | { | |
11e59d47 DW |
2258 | // TODO: |
2259 | /* | |
cdf1e714 DW |
2260 | wxActivateEvent event(wxEVT_ACTIVATE, |
2261 | (state == WA_ACTIVE) || (state == WA_CLICKACTIVE), | |
2262 | m_windowId); | |
2263 | event.SetEventObject(this); | |
2264 | ||
2265 | return GetEventHandler()->ProcessEvent(event); | |
11e59d47 DW |
2266 | */ |
2267 | return FALSE; | |
cdf1e714 DW |
2268 | } |
2269 | ||
2270 | bool wxWindow::HandleSetFocus(WXHWND WXUNUSED(hwnd)) | |
2271 | { | |
2272 | #if wxUSE_CARET | |
2273 | // Deal with caret | |
2274 | if ( m_caret ) | |
2275 | { | |
2276 | m_caret->OnSetFocus(); | |
2277 | } | |
2278 | #endif // wxUSE_CARET | |
2279 | ||
2280 | // panel wants to track the window which was the last to have focus in it | |
2281 | wxPanel *panel = wxDynamicCast(GetParent(), wxPanel); | |
2282 | if ( panel ) | |
2283 | { | |
2284 | panel->SetLastFocus(this); | |
2285 | } | |
2286 | ||
2287 | wxFocusEvent event(wxEVT_SET_FOCUS, m_windowId); | |
2288 | event.SetEventObject(this); | |
2289 | ||
2290 | return GetEventHandler()->ProcessEvent(event); | |
2291 | } | |
2292 | ||
2293 | bool wxWindow::HandleKillFocus(WXHWND WXUNUSED(hwnd)) | |
2294 | { | |
2295 | #if wxUSE_CARET | |
2296 | // Deal with caret | |
2297 | if ( m_caret ) | |
2298 | { | |
2299 | m_caret->OnKillFocus(); | |
2300 | } | |
2301 | #endif // wxUSE_CARET | |
2302 | ||
2303 | wxFocusEvent event(wxEVT_KILL_FOCUS, m_windowId); | |
2304 | event.SetEventObject(this); | |
2305 | ||
2306 | return GetEventHandler()->ProcessEvent(event); | |
2307 | } | |
2308 | ||
2309 | // --------------------------------------------------------------------------- | |
2310 | // miscellaneous | |
2311 | // --------------------------------------------------------------------------- | |
2312 | ||
2313 | bool wxWindow::HandleShow(bool show, int status) | |
2314 | { | |
2315 | wxShowEvent event(GetId(), show); | |
2316 | event.m_eventObject = this; | |
2317 | ||
2318 | return GetEventHandler()->ProcessEvent(event); | |
2319 | } | |
2320 | ||
2321 | bool wxWindow::HandleInitDialog(WXHWND WXUNUSED(hWndFocus)) | |
2322 | { | |
2323 | wxInitDialogEvent event(GetId()); | |
2324 | event.m_eventObject = this; | |
2325 | ||
2326 | return GetEventHandler()->ProcessEvent(event); | |
2327 | } | |
2328 | ||
2329 | bool wxWindow::HandleDropFiles(WXWPARAM wParam) | |
2330 | { | |
2331 | // TODO: | |
2332 | return FALSE; | |
2333 | } | |
2334 | ||
2335 | bool wxWindow::HandleSetCursor(WXHWND hWnd, | |
2336 | short nHitTest, | |
2337 | int WXUNUSED(mouseMsg)) | |
2338 | { | |
2339 | // don't set cursor for other windows, only for this one: this prevents | |
2340 | // children of this window from getting the same cursor as the parent has | |
2341 | // (don't forget that this message is propagated by default up the window | |
2342 | // parent-child hierarchy) | |
2343 | if ( GetHWND() == hWnd ) | |
2344 | { | |
2345 | // don't set cursor when the mouse is not in the client part | |
11e59d47 DW |
2346 | // TODO |
2347 | /* | |
cdf1e714 DW |
2348 | if ( nHitTest == HTCLIENT || nHitTest == HTERROR ) |
2349 | { | |
2350 | HCURSOR hcursor = 0; | |
2351 | if ( wxIsBusy() ) | |
2352 | { | |
2353 | // from msw\utils.cpp | |
2354 | extern HCURSOR gs_wxBusyCursor; | |
2355 | ||
2356 | hcursor = gs_wxBusyCursor; | |
2357 | } | |
2358 | else | |
2359 | { | |
2360 | wxCursor *cursor = NULL; | |
2361 | ||
2362 | if ( m_cursor.Ok() ) | |
2363 | { | |
2364 | cursor = &m_cursor; | |
2365 | } | |
2366 | else | |
2367 | { | |
2368 | // from msw\data.cpp | |
2369 | extern wxCursor *g_globalCursor; | |
2370 | ||
2371 | if ( g_globalCursor && g_globalCursor->Ok() ) | |
2372 | cursor = g_globalCursor; | |
2373 | } | |
2374 | ||
2375 | if ( cursor ) | |
2376 | hcursor = (HCURSOR)cursor->GetHCURSOR(); | |
2377 | } | |
2378 | ||
2379 | if ( hcursor ) | |
2380 | { | |
2381 | // ::SetCursor(hcursor); | |
2382 | ||
2383 | return TRUE; | |
2384 | } | |
2385 | } | |
11e59d47 | 2386 | */ |
cdf1e714 DW |
2387 | } |
2388 | ||
2389 | return FALSE; | |
2390 | } | |
2391 | ||
2392 | // --------------------------------------------------------------------------- | |
2393 | // owner drawn stuff | |
2394 | // --------------------------------------------------------------------------- | |
2395 | ||
11e59d47 | 2396 | bool wxWindow::OS2OnDrawItem(int id, WXDRAWITEMSTRUCT *itemStruct) |
cdf1e714 DW |
2397 | { |
2398 | // TODO: | |
2399 | /* | |
2400 | #if wxUSE_OWNER_DRAWN | |
2401 | // is it a menu item? | |
2402 | if ( id == 0 ) | |
2403 | { | |
2404 | DRAWITEMSTRUCT *pDrawStruct = (DRAWITEMSTRUCT *)itemStruct; | |
2405 | wxMenuItem *pMenuItem = (wxMenuItem *)(pDrawStruct->itemData); | |
2406 | ||
2407 | wxCHECK( pMenuItem->IsKindOf(CLASSINFO(wxMenuItem)), FALSE ); | |
2408 | ||
2409 | // prepare to call OnDrawItem() | |
2410 | wxDC dc; | |
2411 | dc.SetHDC((WXHDC)pDrawStruct->hDC, FALSE); | |
2412 | wxRect rect(pDrawStruct->rcItem.left, pDrawStruct->rcItem.top, | |
2413 | pDrawStruct->rcItem.right - pDrawStruct->rcItem.left, | |
2414 | pDrawStruct->rcItem.bottom - pDrawStruct->rcItem.top); | |
2415 | ||
2416 | return pMenuItem->OnDrawItem | |
2417 | ( | |
2418 | dc, rect, | |
2419 | (wxOwnerDrawn::wxODAction)pDrawStruct->itemAction, | |
2420 | (wxOwnerDrawn::wxODStatus)pDrawStruct->itemState | |
2421 | ); | |
2422 | } | |
2423 | ||
2424 | wxWindow *item = FindItem(id); | |
2425 | if ( item && item->IsKindOf(CLASSINFO(wxControl)) ) | |
2426 | { | |
2427 | return ((wxControl *)item)->MSWOnDraw(itemStruct); | |
2428 | } | |
2429 | else | |
2430 | #endif | |
2431 | return FALSE; | |
2432 | */ | |
2433 | return FALSE; | |
2434 | } | |
2435 | ||
2436 | bool wxWindow::OS2OnMeasureItem(int id, WXMEASUREITEMSTRUCT *itemStruct) | |
0e320a79 | 2437 | { |
cdf1e714 DW |
2438 | // TODO: |
2439 | /* | |
2440 | #if wxUSE_OWNER_DRAWN | |
2441 | // is it a menu item? | |
2442 | if ( id == 0 ) | |
2443 | { | |
2444 | MEASUREITEMSTRUCT *pMeasureStruct = (MEASUREITEMSTRUCT *)itemStruct; | |
2445 | wxMenuItem *pMenuItem = (wxMenuItem *)(pMeasureStruct->itemData); | |
2446 | ||
2447 | wxCHECK( pMenuItem->IsKindOf(CLASSINFO(wxMenuItem)), FALSE ); | |
2448 | ||
2449 | return pMenuItem->OnMeasureItem(&pMeasureStruct->itemWidth, | |
2450 | &pMeasureStruct->itemHeight); | |
2451 | } | |
2452 | ||
2453 | wxWindow *item = FindItem(id); | |
2454 | if ( item && item->IsKindOf(CLASSINFO(wxControl)) ) | |
2455 | { | |
2456 | return ((wxControl *)item)->MSWOnMeasure(itemStruct); | |
2457 | } | |
2458 | #endif // owner-drawn menus | |
2459 | */ | |
2460 | return FALSE; | |
0e320a79 DW |
2461 | } |
2462 | ||
cdf1e714 DW |
2463 | // --------------------------------------------------------------------------- |
2464 | // colours and palettes | |
2465 | // --------------------------------------------------------------------------- | |
849949b1 | 2466 | |
cdf1e714 | 2467 | bool wxWindow::HandleSysColorChange() |
0e320a79 | 2468 | { |
cdf1e714 DW |
2469 | wxSysColourChangedEvent event; |
2470 | event.SetEventObject(this); | |
2471 | ||
2472 | return GetEventHandler()->ProcessEvent(event); | |
0e320a79 DW |
2473 | } |
2474 | ||
cdf1e714 DW |
2475 | bool wxWindow::HandleCtlColor(WXHBRUSH *brush, |
2476 | WXHDC pDC, | |
2477 | WXHWND pWnd, | |
2478 | WXUINT nCtlColor, | |
2479 | WXUINT message, | |
2480 | WXWPARAM wParam, | |
2481 | WXLPARAM lParam) | |
0e320a79 | 2482 | { |
cdf1e714 | 2483 | WXHBRUSH hBrush = 0; |
11e59d47 DW |
2484 | // TODO: |
2485 | /* | |
cdf1e714 DW |
2486 | if ( nCtlColor == CTLCOLOR_DLG ) |
2487 | { | |
2488 | hBrush = OnCtlColor(pDC, pWnd, nCtlColor, message, wParam, lParam); | |
2489 | } | |
2490 | else | |
2491 | { | |
2492 | wxControl *item = (wxControl *)FindItemByHWND(pWnd, TRUE); | |
2493 | if ( item ) | |
2494 | hBrush = item->OnCtlColor(pDC, pWnd, nCtlColor, message, wParam, lParam); | |
2495 | } | |
2496 | ||
2497 | if ( hBrush ) | |
2498 | *brush = hBrush; | |
2499 | ||
2500 | return hBrush != 0; | |
11e59d47 DW |
2501 | */ |
2502 | return FALSE; | |
0e320a79 DW |
2503 | } |
2504 | ||
cdf1e714 DW |
2505 | // Define for each class of dialog and control |
2506 | WXHBRUSH wxWindow::OnCtlColor(WXHDC hDC, | |
2507 | WXHWND hWnd, | |
2508 | WXUINT nCtlColor, | |
2509 | WXUINT message, | |
2510 | WXWPARAM wParam, | |
2511 | WXLPARAM lParam) | |
0e320a79 | 2512 | { |
cdf1e714 | 2513 | return (WXHBRUSH)0; |
0e320a79 DW |
2514 | } |
2515 | ||
cdf1e714 | 2516 | bool wxWindow::HandlePaletteChanged(WXHWND hWndPalChange) |
0e320a79 | 2517 | { |
cdf1e714 DW |
2518 | wxPaletteChangedEvent event(GetId()); |
2519 | event.SetEventObject(this); | |
2520 | event.SetChangedWindow(wxFindWinFromHandle(hWndPalChange)); | |
2521 | ||
2522 | return GetEventHandler()->ProcessEvent(event); | |
0e320a79 DW |
2523 | } |
2524 | ||
cdf1e714 | 2525 | bool wxWindow::HandleQueryNewPalette() |
0e320a79 | 2526 | { |
cdf1e714 DW |
2527 | wxQueryNewPaletteEvent event(GetId()); |
2528 | event.SetEventObject(this); | |
2529 | ||
2530 | return GetEventHandler()->ProcessEvent(event) && event.GetPaletteRealized(); | |
0e320a79 DW |
2531 | } |
2532 | ||
cdf1e714 DW |
2533 | // Responds to colour changes: passes event on to children. |
2534 | void wxWindow::OnSysColourChanged(wxSysColourChangedEvent& event) | |
0e320a79 | 2535 | { |
cdf1e714 DW |
2536 | wxNode *node = GetChildren().First(); |
2537 | while ( node ) | |
2538 | { | |
2539 | // Only propagate to non-top-level windows | |
2540 | wxWindow *win = (wxWindow *)node->Data(); | |
2541 | if ( win->GetParent() ) | |
2542 | { | |
2543 | wxSysColourChangedEvent event2; | |
2544 | event.m_eventObject = win; | |
2545 | win->GetEventHandler()->ProcessEvent(event2); | |
2546 | } | |
2547 | ||
2548 | node = node->Next(); | |
2549 | } | |
0e320a79 DW |
2550 | } |
2551 | ||
cdf1e714 DW |
2552 | // --------------------------------------------------------------------------- |
2553 | // painting | |
2554 | // --------------------------------------------------------------------------- | |
2555 | ||
2556 | bool wxWindow::HandlePaint() | |
0e320a79 | 2557 | { |
cdf1e714 | 2558 | // TODO: |
11e59d47 | 2559 | return FALSE; |
0e320a79 DW |
2560 | } |
2561 | ||
cdf1e714 | 2562 | bool wxWindow::HandleEraseBkgnd(WXHDC hdc) |
0e320a79 | 2563 | { |
cdf1e714 | 2564 | // Prevents flicker when dragging |
11e59d47 DW |
2565 | // if ( ::IsIconic(GetHwnd()) ) |
2566 | // return TRUE; | |
cdf1e714 DW |
2567 | |
2568 | wxDC dc; | |
2569 | ||
2570 | dc.SetHDC(hdc); | |
2571 | dc.SetWindow(this); | |
2572 | dc.BeginDrawing(); | |
2573 | ||
2574 | wxEraseEvent event(m_windowId, &dc); | |
2575 | event.SetEventObject(this); | |
2576 | bool rc = GetEventHandler()->ProcessEvent(event); | |
2577 | ||
2578 | dc.EndDrawing(); | |
2579 | dc.SelectOldObjects(hdc); | |
2580 | dc.SetHDC((WXHDC) NULL); | |
2581 | ||
2582 | return rc; | |
0e320a79 DW |
2583 | } |
2584 | ||
cdf1e714 | 2585 | void wxWindow::OnEraseBackground(wxEraseEvent& event) |
0e320a79 | 2586 | { |
849949b1 | 2587 | // TODO: |
0e320a79 DW |
2588 | } |
2589 | ||
cdf1e714 DW |
2590 | // --------------------------------------------------------------------------- |
2591 | // moving and resizing | |
2592 | // --------------------------------------------------------------------------- | |
0e320a79 | 2593 | |
cdf1e714 | 2594 | bool wxWindow::HandleMinimize() |
0e320a79 | 2595 | { |
cdf1e714 DW |
2596 | wxIconizeEvent event(m_windowId); |
2597 | event.SetEventObject(this); | |
2598 | ||
2599 | return GetEventHandler()->ProcessEvent(event); | |
0e320a79 DW |
2600 | } |
2601 | ||
cdf1e714 | 2602 | bool wxWindow::HandleMaximize() |
0e320a79 | 2603 | { |
cdf1e714 DW |
2604 | wxMaximizeEvent event(m_windowId); |
2605 | event.SetEventObject(this); | |
2606 | ||
2607 | return GetEventHandler()->ProcessEvent(event); | |
0e320a79 DW |
2608 | } |
2609 | ||
cdf1e714 | 2610 | bool wxWindow::HandleMove(int x, int y) |
0e320a79 | 2611 | { |
cdf1e714 DW |
2612 | wxMoveEvent event(wxPoint(x, y), m_windowId); |
2613 | event.SetEventObject(this); | |
2614 | ||
2615 | return GetEventHandler()->ProcessEvent(event); | |
0e320a79 DW |
2616 | } |
2617 | ||
cdf1e714 | 2618 | bool wxWindow::HandleSize(int w, int h, WXUINT WXUNUSED(flag)) |
0e320a79 | 2619 | { |
cdf1e714 DW |
2620 | wxSizeEvent event(wxSize(w, h), m_windowId); |
2621 | event.SetEventObject(this); | |
2622 | ||
2623 | return GetEventHandler()->ProcessEvent(event); | |
0e320a79 DW |
2624 | } |
2625 | ||
cdf1e714 | 2626 | bool wxWindow::HandleGetMinMaxInfo(void *mmInfo) |
0e320a79 | 2627 | { |
11e59d47 DW |
2628 | // TODO: |
2629 | /* | |
cdf1e714 DW |
2630 | MINMAXINFO *info = (MINMAXINFO *)mmInfo; |
2631 | ||
2632 | bool rc = FALSE; | |
2633 | ||
2634 | if ( m_minWidth != -1 ) | |
2635 | { | |
2636 | info->ptMinTrackSize.x = m_minWidth; | |
2637 | rc = TRUE; | |
2638 | } | |
2639 | ||
2640 | if ( m_minHeight != -1 ) | |
2641 | { | |
2642 | info->ptMinTrackSize.y = m_minHeight; | |
2643 | rc = TRUE; | |
2644 | } | |
2645 | ||
2646 | if ( m_maxWidth != -1 ) | |
2647 | { | |
2648 | info->ptMaxTrackSize.x = m_maxWidth; | |
2649 | rc = TRUE; | |
2650 | } | |
2651 | ||
2652 | if ( m_maxHeight != -1 ) | |
2653 | { | |
2654 | info->ptMaxTrackSize.y = m_maxHeight; | |
2655 | rc = TRUE; | |
2656 | } | |
2657 | ||
2658 | return rc; | |
11e59d47 DW |
2659 | */ |
2660 | return FALSE; | |
0e320a79 DW |
2661 | } |
2662 | ||
cdf1e714 DW |
2663 | // --------------------------------------------------------------------------- |
2664 | // command messages | |
2665 | // --------------------------------------------------------------------------- | |
2666 | ||
2667 | bool wxWindow::HandleCommand(WXWORD id, WXWORD cmd, WXHWND control) | |
0e320a79 | 2668 | { |
cdf1e714 | 2669 | if ( wxCurrentPopupMenu ) |
0e320a79 | 2670 | { |
cdf1e714 DW |
2671 | wxMenu *popupMenu = wxCurrentPopupMenu; |
2672 | wxCurrentPopupMenu = NULL; | |
0e320a79 | 2673 | |
11e59d47 | 2674 | return popupMenu->OS2Command(cmd, id); |
cdf1e714 | 2675 | } |
0e320a79 | 2676 | |
cdf1e714 DW |
2677 | wxWindow *win = FindItem(id); |
2678 | if ( !win ) | |
2679 | { | |
2680 | win = wxFindWinFromHandle(control); | |
0e320a79 | 2681 | } |
cdf1e714 DW |
2682 | |
2683 | if ( win ) | |
11e59d47 | 2684 | return win->OS2Command(cmd, id); |
cdf1e714 DW |
2685 | |
2686 | return FALSE; | |
0e320a79 | 2687 | } |
de44a9f0 | 2688 | |
cdf1e714 | 2689 | bool wxWindow::HandleSysCommand(WXWPARAM wParam, WXLPARAM lParam) |
0e320a79 | 2690 | { |
cdf1e714 DW |
2691 | // TODO: |
2692 | return FALSE; | |
2693 | } | |
2694 | ||
2695 | // --------------------------------------------------------------------------- | |
2696 | // mouse events | |
2697 | // --------------------------------------------------------------------------- | |
2698 | ||
2699 | void wxWindow::InitMouseEvent(wxMouseEvent& event, int x, int y, WXUINT flags) | |
2700 | { | |
11e59d47 DW |
2701 | // TODO: |
2702 | /* | |
cdf1e714 DW |
2703 | event.m_x = x; |
2704 | event.m_y = y; | |
2705 | event.m_shiftDown = ((flags & MK_SHIFT) != 0); | |
2706 | event.m_controlDown = ((flags & MK_CONTROL) != 0); | |
2707 | event.m_leftDown = ((flags & MK_LBUTTON) != 0); | |
2708 | event.m_middleDown = ((flags & MK_MBUTTON) != 0); | |
2709 | event.m_rightDown = ((flags & MK_RBUTTON) != 0); | |
2710 | event.SetTimestamp(s_currentMsg.time); | |
2711 | event.m_eventObject = this; | |
2712 | ||
2713 | #if wxUSE_MOUSEEVENT_HACK | |
2714 | m_lastMouseX = x; | |
2715 | m_lastMouseY = y; | |
2716 | m_lastMouseEvent = event.GetEventType(); | |
2717 | #endif // wxUSE_MOUSEEVENT_HACK | |
11e59d47 | 2718 | */ |
0e320a79 DW |
2719 | } |
2720 | ||
cdf1e714 | 2721 | bool wxWindow::HandleMouseEvent(WXUINT msg, int x, int y, WXUINT flags) |
0e320a79 | 2722 | { |
cdf1e714 DW |
2723 | // the mouse events take consecutive IDs from WM_MOUSEFIRST to |
2724 | // WM_MOUSELAST, so it's enough to substract WM_MOUSEMOVE == WM_MOUSEFIRST | |
2725 | // from the message id and take the value in the table to get wxWin event | |
2726 | // id | |
2727 | static const wxEventType eventsMouse[] = | |
2728 | { | |
2729 | wxEVT_MOTION, | |
2730 | wxEVT_LEFT_DOWN, | |
2731 | wxEVT_LEFT_UP, | |
2732 | wxEVT_LEFT_DCLICK, | |
2733 | wxEVT_RIGHT_DOWN, | |
2734 | wxEVT_RIGHT_UP, | |
2735 | wxEVT_RIGHT_DCLICK, | |
2736 | wxEVT_MIDDLE_DOWN, | |
2737 | wxEVT_MIDDLE_UP, | |
2738 | wxEVT_MIDDLE_DCLICK | |
2739 | }; | |
2740 | ||
2741 | wxMouseEvent event(eventsMouse[msg - WM_MOUSEMOVE]); | |
2742 | InitMouseEvent(event, x, y, flags); | |
2743 | ||
2744 | return GetEventHandler()->ProcessEvent(event); | |
0e320a79 DW |
2745 | } |
2746 | ||
cdf1e714 | 2747 | bool wxWindow::HandleMouseMove(int x, int y, WXUINT flags) |
0e320a79 | 2748 | { |
776d87d5 | 2749 | if ( !m_bMouseInWindow ) |
cdf1e714 DW |
2750 | { |
2751 | // Generate an ENTER event | |
776d87d5 | 2752 | m_bMouseInWindow = TRUE; |
cdf1e714 DW |
2753 | |
2754 | wxMouseEvent event(wxEVT_ENTER_WINDOW); | |
2755 | InitMouseEvent(event, x, y, flags); | |
2756 | ||
2757 | (void)GetEventHandler()->ProcessEvent(event); | |
2758 | } | |
2759 | ||
2760 | #if wxUSE_MOUSEEVENT_HACK | |
2761 | // Window gets a click down message followed by a mouse move message even | |
2762 | // if position isn't changed! We want to discard the trailing move event | |
2763 | // if x and y are the same. | |
2764 | if ( (m_lastMouseEvent == wxEVT_RIGHT_DOWN || | |
2765 | m_lastMouseEvent == wxEVT_LEFT_DOWN || | |
2766 | m_lastMouseEvent == wxEVT_MIDDLE_DOWN) && | |
2767 | (m_lastMouseX == event.m_x && m_lastMouseY == event.m_y) ) | |
2768 | { | |
2769 | m_lastMouseEvent = wxEVT_MOTION; | |
2770 | ||
2771 | return FALSE; | |
2772 | } | |
2773 | #endif // wxUSE_MOUSEEVENT_HACK | |
2774 | ||
2775 | return HandleMouseEvent(WM_MOUSEMOVE, x, y, flags); | |
0e320a79 DW |
2776 | } |
2777 | ||
cdf1e714 DW |
2778 | // --------------------------------------------------------------------------- |
2779 | // keyboard handling | |
2780 | // --------------------------------------------------------------------------- | |
2781 | ||
2782 | // isASCII is TRUE only when we're called from WM_CHAR handler and not from | |
2783 | // WM_KEYDOWN one | |
2784 | bool wxWindow::HandleChar(WXWORD wParam, WXLPARAM lParam, bool isASCII) | |
86de7616 | 2785 | { |
cdf1e714 DW |
2786 | // TODO: |
2787 | return FALSE; | |
2788 | } | |
86de7616 | 2789 | |
cdf1e714 DW |
2790 | bool wxWindow::HandleKeyDown(WXWORD wParam, WXLPARAM lParam) |
2791 | { | |
2792 | // TODO: | |
2793 | return FALSE; | |
86de7616 DW |
2794 | } |
2795 | ||
cdf1e714 | 2796 | bool wxWindow::HandleKeyUp(WXWORD wParam, WXLPARAM lParam) |
86de7616 | 2797 | { |
cdf1e714 DW |
2798 | // TODO: |
2799 | return FALSE; | |
2800 | } | |
86de7616 | 2801 | |
cdf1e714 DW |
2802 | // --------------------------------------------------------------------------- |
2803 | // joystick | |
2804 | // --------------------------------------------------------------------------- | |
86de7616 | 2805 | |
cdf1e714 DW |
2806 | bool wxWindow::HandleJoystickEvent(WXUINT msg, int x, int y, WXUINT flags) |
2807 | { | |
2808 | // TODO: | |
2809 | return FALSE; | |
2810 | } | |
2811 | ||
2812 | // --------------------------------------------------------------------------- | |
2813 | // scrolling | |
2814 | // --------------------------------------------------------------------------- | |
2815 | ||
2816 | bool wxWindow::OS2OnScroll(int orientation, WXWORD wParam, | |
2817 | WXWORD pos, WXHWND control) | |
2818 | { | |
2819 | if ( control ) | |
86de7616 | 2820 | { |
cdf1e714 DW |
2821 | wxWindow *child = wxFindWinFromHandle(control); |
2822 | if ( child ) | |
11e59d47 | 2823 | return child->OS2OnScroll(orientation, wParam, pos, control); |
cdf1e714 | 2824 | } |
86de7616 | 2825 | |
cdf1e714 DW |
2826 | wxScrollWinEvent event; |
2827 | event.SetPosition(pos); | |
2828 | event.SetOrientation(orientation); | |
2829 | event.m_eventObject = this; | |
2830 | // TODO: | |
2831 | return FALSE; | |
2832 | } | |
86de7616 | 2833 | |
cdf1e714 DW |
2834 | // =========================================================================== |
2835 | // global functions | |
2836 | // =========================================================================== | |
2837 | ||
2838 | void wxGetCharSize(WXHWND wnd, int *x, int *y,wxFont *the_font) | |
2839 | { | |
2840 | // TODO: | |
2841 | } | |
2842 | ||
2843 | // Returns 0 if was a normal ASCII value, not a special key. This indicates that | |
2844 | // the key should be ignored by WM_KEYDOWN and processed by WM_CHAR instead. | |
2845 | int wxCharCodeOS2ToWX(int keySym) | |
2846 | { | |
2847 | int id = 0; | |
2848 | // TODO: | |
2849 | /* | |
2850 | switch (keySym) | |
2851 | { | |
2852 | case VK_CANCEL: id = WXK_CANCEL; break; | |
2853 | case VK_BACK: id = WXK_BACK; break; | |
2854 | case VK_TAB: id = WXK_TAB; break; | |
2855 | case VK_CLEAR: id = WXK_CLEAR; break; | |
2856 | case VK_RETURN: id = WXK_RETURN; break; | |
2857 | case VK_SHIFT: id = WXK_SHIFT; break; | |
2858 | case VK_CONTROL: id = WXK_CONTROL; break; | |
2859 | case VK_MENU : id = WXK_MENU; break; | |
2860 | case VK_PAUSE: id = WXK_PAUSE; break; | |
2861 | case VK_SPACE: id = WXK_SPACE; break; | |
2862 | case VK_ESCAPE: id = WXK_ESCAPE; break; | |
2863 | case VK_PRIOR: id = WXK_PRIOR; break; | |
2864 | case VK_NEXT : id = WXK_NEXT; break; | |
2865 | case VK_END: id = WXK_END; break; | |
2866 | case VK_HOME : id = WXK_HOME; break; | |
2867 | case VK_LEFT : id = WXK_LEFT; break; | |
2868 | case VK_UP: id = WXK_UP; break; | |
2869 | case VK_RIGHT: id = WXK_RIGHT; break; | |
2870 | case VK_DOWN : id = WXK_DOWN; break; | |
2871 | case VK_SELECT: id = WXK_SELECT; break; | |
2872 | case VK_PRINT: id = WXK_PRINT; break; | |
2873 | case VK_EXECUTE: id = WXK_EXECUTE; break; | |
2874 | case VK_INSERT: id = WXK_INSERT; break; | |
2875 | case VK_DELETE: id = WXK_DELETE; break; | |
2876 | case VK_HELP : id = WXK_HELP; break; | |
2877 | case VK_NUMPAD0: id = WXK_NUMPAD0; break; | |
2878 | case VK_NUMPAD1: id = WXK_NUMPAD1; break; | |
2879 | case VK_NUMPAD2: id = WXK_NUMPAD2; break; | |
2880 | case VK_NUMPAD3: id = WXK_NUMPAD3; break; | |
2881 | case VK_NUMPAD4: id = WXK_NUMPAD4; break; | |
2882 | case VK_NUMPAD5: id = WXK_NUMPAD5; break; | |
2883 | case VK_NUMPAD6: id = WXK_NUMPAD6; break; | |
2884 | case VK_NUMPAD7: id = WXK_NUMPAD7; break; | |
2885 | case VK_NUMPAD8: id = WXK_NUMPAD8; break; | |
2886 | case VK_NUMPAD9: id = WXK_NUMPAD9; break; | |
2887 | case VK_MULTIPLY: id = WXK_MULTIPLY; break; | |
2888 | case VK_ADD: id = WXK_ADD; break; | |
2889 | case VK_SUBTRACT: id = WXK_SUBTRACT; break; | |
2890 | case VK_DECIMAL: id = WXK_DECIMAL; break; | |
2891 | case VK_DIVIDE: id = WXK_DIVIDE; break; | |
2892 | case VK_F1: id = WXK_F1; break; | |
2893 | case VK_F2: id = WXK_F2; break; | |
2894 | case VK_F3: id = WXK_F3; break; | |
2895 | case VK_F4: id = WXK_F4; break; | |
2896 | case VK_F5: id = WXK_F5; break; | |
2897 | case VK_F6: id = WXK_F6; break; | |
2898 | case VK_F7: id = WXK_F7; break; | |
2899 | case VK_F8: id = WXK_F8; break; | |
2900 | case VK_F9: id = WXK_F9; break; | |
2901 | case VK_F10: id = WXK_F10; break; | |
2902 | case VK_F11: id = WXK_F11; break; | |
2903 | case VK_F12: id = WXK_F12; break; | |
2904 | case VK_F13: id = WXK_F13; break; | |
2905 | case VK_F14: id = WXK_F14; break; | |
2906 | case VK_F15: id = WXK_F15; break; | |
2907 | case VK_F16: id = WXK_F16; break; | |
2908 | case VK_F17: id = WXK_F17; break; | |
2909 | case VK_F18: id = WXK_F18; break; | |
2910 | case VK_F19: id = WXK_F19; break; | |
2911 | case VK_F20: id = WXK_F20; break; | |
2912 | case VK_F21: id = WXK_F21; break; | |
2913 | case VK_F22: id = WXK_F22; break; | |
2914 | case VK_F23: id = WXK_F23; break; | |
2915 | case VK_F24: id = WXK_F24; break; | |
2916 | case VK_NUMLOCK: id = WXK_NUMLOCK; break; | |
2917 | case VK_SCROLL: id = WXK_SCROLL; break; | |
2918 | default: | |
86de7616 | 2919 | { |
cdf1e714 | 2920 | return 0; |
86de7616 DW |
2921 | } |
2922 | } | |
2923 | */ | |
cdf1e714 | 2924 | return id; |
86de7616 DW |
2925 | } |
2926 | ||
cdf1e714 | 2927 | int wxCharCodeWXToOS2(int id, bool *isVirtual) |
86de7616 | 2928 | { |
cdf1e714 DW |
2929 | *isVirtual = TRUE; |
2930 | int keySym = 0; | |
2931 | // TODO | |
2932 | /* | |
2933 | switch (id) | |
86de7616 | 2934 | { |
cdf1e714 DW |
2935 | case WXK_CANCEL: keySym = VK_CANCEL; break; |
2936 | case WXK_CLEAR: keySym = VK_CLEAR; break; | |
2937 | case WXK_SHIFT: keySym = VK_SHIFT; break; | |
2938 | case WXK_CONTROL: keySym = VK_CONTROL; break; | |
2939 | case WXK_MENU : keySym = VK_MENU; break; | |
2940 | case WXK_PAUSE: keySym = VK_PAUSE; break; | |
2941 | case WXK_PRIOR: keySym = VK_PRIOR; break; | |
2942 | case WXK_NEXT : keySym = VK_NEXT; break; | |
2943 | case WXK_END: keySym = VK_END; break; | |
2944 | case WXK_HOME : keySym = VK_HOME; break; | |
2945 | case WXK_LEFT : keySym = VK_LEFT; break; | |
2946 | case WXK_UP: keySym = VK_UP; break; | |
2947 | case WXK_RIGHT: keySym = VK_RIGHT; break; | |
2948 | case WXK_DOWN : keySym = VK_DOWN; break; | |
2949 | case WXK_SELECT: keySym = VK_SELECT; break; | |
2950 | case WXK_PRINT: keySym = VK_PRINT; break; | |
2951 | case WXK_EXECUTE: keySym = VK_EXECUTE; break; | |
2952 | case WXK_INSERT: keySym = VK_INSERT; break; | |
2953 | case WXK_DELETE: keySym = VK_DELETE; break; | |
2954 | case WXK_HELP : keySym = VK_HELP; break; | |
2955 | case WXK_NUMPAD0: keySym = VK_NUMPAD0; break; | |
2956 | case WXK_NUMPAD1: keySym = VK_NUMPAD1; break; | |
2957 | case WXK_NUMPAD2: keySym = VK_NUMPAD2; break; | |
2958 | case WXK_NUMPAD3: keySym = VK_NUMPAD3; break; | |
2959 | case WXK_NUMPAD4: keySym = VK_NUMPAD4; break; | |
2960 | case WXK_NUMPAD5: keySym = VK_NUMPAD5; break; | |
2961 | case WXK_NUMPAD6: keySym = VK_NUMPAD6; break; | |
2962 | case WXK_NUMPAD7: keySym = VK_NUMPAD7; break; | |
2963 | case WXK_NUMPAD8: keySym = VK_NUMPAD8; break; | |
2964 | case WXK_NUMPAD9: keySym = VK_NUMPAD9; break; | |
2965 | case WXK_MULTIPLY: keySym = VK_MULTIPLY; break; | |
2966 | case WXK_ADD: keySym = VK_ADD; break; | |
2967 | case WXK_SUBTRACT: keySym = VK_SUBTRACT; break; | |
2968 | case WXK_DECIMAL: keySym = VK_DECIMAL; break; | |
2969 | case WXK_DIVIDE: keySym = VK_DIVIDE; break; | |
2970 | case WXK_F1: keySym = VK_F1; break; | |
2971 | case WXK_F2: keySym = VK_F2; break; | |
2972 | case WXK_F3: keySym = VK_F3; break; | |
2973 | case WXK_F4: keySym = VK_F4; break; | |
2974 | case WXK_F5: keySym = VK_F5; break; | |
2975 | case WXK_F6: keySym = VK_F6; break; | |
2976 | case WXK_F7: keySym = VK_F7; break; | |
2977 | case WXK_F8: keySym = VK_F8; break; | |
2978 | case WXK_F9: keySym = VK_F9; break; | |
2979 | case WXK_F10: keySym = VK_F10; break; | |
2980 | case WXK_F11: keySym = VK_F11; break; | |
2981 | case WXK_F12: keySym = VK_F12; break; | |
2982 | case WXK_F13: keySym = VK_F13; break; | |
2983 | case WXK_F14: keySym = VK_F14; break; | |
2984 | case WXK_F15: keySym = VK_F15; break; | |
2985 | case WXK_F16: keySym = VK_F16; break; | |
2986 | case WXK_F17: keySym = VK_F17; break; | |
2987 | case WXK_F18: keySym = VK_F18; break; | |
2988 | case WXK_F19: keySym = VK_F19; break; | |
2989 | case WXK_F20: keySym = VK_F20; break; | |
2990 | case WXK_F21: keySym = VK_F21; break; | |
2991 | case WXK_F22: keySym = VK_F22; break; | |
2992 | case WXK_F23: keySym = VK_F23; break; | |
2993 | case WXK_F24: keySym = VK_F24; break; | |
2994 | case WXK_NUMLOCK: keySym = VK_NUMLOCK; break; | |
2995 | case WXK_SCROLL: keySym = VK_SCROLL; break; | |
2996 | default: | |
2997 | { | |
2998 | *isVirtual = FALSE; | |
2999 | keySym = id; | |
3000 | break; | |
3001 | } | |
86de7616 | 3002 | } |
cdf1e714 DW |
3003 | */ |
3004 | return keySym; | |
3005 | } | |
86de7616 | 3006 | |
cdf1e714 DW |
3007 | wxWindow *wxGetActiveWindow() |
3008 | { | |
3009 | // TODO | |
3010 | return NULL; | |
3011 | } | |
86de7616 | 3012 | |
cdf1e714 DW |
3013 | // Windows keyboard hook. Allows interception of e.g. F1, ESCAPE |
3014 | // in active frames and dialogs, regardless of where the focus is. | |
11e59d47 DW |
3015 | //static HHOOK wxTheKeyboardHook = 0; |
3016 | //static FARPROC wxTheKeyboardHookProc = 0; | |
cdf1e714 | 3017 | int wxKeyboardHook(int nCode, WORD wParam, DWORD lParam); |
86de7616 | 3018 | |
cdf1e714 DW |
3019 | void wxSetKeyboardHook(bool doIt) |
3020 | { | |
3021 | // TODO: | |
3022 | } | |
86de7616 | 3023 | |
cdf1e714 DW |
3024 | int wxKeyboardHook(int nCode, WORD wParam, DWORD lParam) |
3025 | { | |
3026 | // TODO: | |
86de7616 | 3027 | |
cdf1e714 DW |
3028 | return 0; |
3029 | } | |
3030 | ||
3031 | #ifdef __WXDEBUG__ | |
3032 | const char *wxGetMessageName(int message) | |
3033 | { | |
3034 | // TODO | |
3035 | /* | |
3036 | switch ( message ) | |
86de7616 | 3037 | { |
cdf1e714 DW |
3038 | case 0x0000: return "WM_NULL"; |
3039 | case 0x0001: return "WM_CREATE"; | |
3040 | case 0x0002: return "WM_DESTROY"; | |
3041 | case 0x0003: return "WM_MOVE"; | |
3042 | case 0x0005: return "WM_SIZE"; | |
3043 | case 0x0006: return "WM_ACTIVATE"; | |
3044 | case 0x0007: return "WM_SETFOCUS"; | |
3045 | case 0x0008: return "WM_KILLFOCUS"; | |
3046 | case 0x000A: return "WM_ENABLE"; | |
3047 | case 0x000B: return "WM_SETREDRAW"; | |
3048 | case 0x000C: return "WM_SETTEXT"; | |
3049 | case 0x000D: return "WM_GETTEXT"; | |
3050 | case 0x000E: return "WM_GETTEXTLENGTH"; | |
3051 | case 0x000F: return "WM_PAINT"; | |
3052 | case 0x0010: return "WM_CLOSE"; | |
3053 | case 0x0011: return "WM_QUERYENDSESSION"; | |
3054 | case 0x0012: return "WM_QUIT"; | |
3055 | case 0x0013: return "WM_QUERYOPEN"; | |
3056 | case 0x0014: return "WM_ERASEBKGND"; | |
3057 | case 0x0015: return "WM_SYSCOLORCHANGE"; | |
3058 | case 0x0016: return "WM_ENDSESSION"; | |
3059 | case 0x0017: return "WM_SYSTEMERROR"; | |
3060 | case 0x0018: return "WM_SHOWWINDOW"; | |
3061 | case 0x0019: return "WM_CTLCOLOR"; | |
3062 | case 0x001A: return "WM_WININICHANGE"; | |
3063 | case 0x001B: return "WM_DEVMODECHANGE"; | |
3064 | case 0x001C: return "WM_ACTIVATEAPP"; | |
3065 | case 0x001D: return "WM_FONTCHANGE"; | |
3066 | case 0x001E: return "WM_TIMECHANGE"; | |
3067 | case 0x001F: return "WM_CANCELMODE"; | |
3068 | case 0x0020: return "WM_SETCURSOR"; | |
3069 | case 0x0021: return "WM_MOUSEACTIVATE"; | |
3070 | case 0x0022: return "WM_CHILDACTIVATE"; | |
3071 | case 0x0023: return "WM_QUEUESYNC"; | |
3072 | case 0x0024: return "WM_GETMINMAXINFO"; | |
3073 | case 0x0026: return "WM_PAINTICON"; | |
3074 | case 0x0027: return "WM_ICONERASEBKGND"; | |
3075 | case 0x0028: return "WM_NEXTDLGCTL"; | |
3076 | case 0x002A: return "WM_SPOOLERSTATUS"; | |
3077 | case 0x002B: return "WM_DRAWITEM"; | |
3078 | case 0x002C: return "WM_MEASUREITEM"; | |
3079 | case 0x002D: return "WM_DELETEITEM"; | |
3080 | case 0x002E: return "WM_VKEYTOITEM"; | |
3081 | case 0x002F: return "WM_CHARTOITEM"; | |
3082 | case 0x0030: return "WM_SETFONT"; | |
3083 | case 0x0031: return "WM_GETFONT"; | |
3084 | case 0x0037: return "WM_QUERYDRAGICON"; | |
3085 | case 0x0039: return "WM_COMPAREITEM"; | |
3086 | case 0x0041: return "WM_COMPACTING"; | |
3087 | case 0x0044: return "WM_COMMNOTIFY"; | |
3088 | case 0x0046: return "WM_WINDOWPOSCHANGING"; | |
3089 | case 0x0047: return "WM_WINDOWPOSCHANGED"; | |
3090 | case 0x0048: return "WM_POWER"; | |
3091 | ||
3092 | #ifdef __WIN32__ | |
3093 | case 0x004A: return "WM_COPYDATA"; | |
3094 | case 0x004B: return "WM_CANCELJOURNAL"; | |
3095 | case 0x004E: return "WM_NOTIFY"; | |
3096 | case 0x0050: return "WM_INPUTLANGCHANGEREQUEST"; | |
3097 | case 0x0051: return "WM_INPUTLANGCHANGE"; | |
3098 | case 0x0052: return "WM_TCARD"; | |
3099 | case 0x0053: return "WM_HELP"; | |
3100 | case 0x0054: return "WM_USERCHANGED"; | |
3101 | case 0x0055: return "WM_NOTIFYFORMAT"; | |
3102 | case 0x007B: return "WM_CONTEXTMENU"; | |
3103 | case 0x007C: return "WM_STYLECHANGING"; | |
3104 | case 0x007D: return "WM_STYLECHANGED"; | |
3105 | case 0x007E: return "WM_DISPLAYCHANGE"; | |
3106 | case 0x007F: return "WM_GETICON"; | |
3107 | case 0x0080: return "WM_SETICON"; | |
3108 | #endif //WIN32 | |
3109 | ||
3110 | case 0x0081: return "WM_NCCREATE"; | |
3111 | case 0x0082: return "WM_NCDESTROY"; | |
3112 | case 0x0083: return "WM_NCCALCSIZE"; | |
3113 | case 0x0084: return "WM_NCHITTEST"; | |
3114 | case 0x0085: return "WM_NCPAINT"; | |
3115 | case 0x0086: return "WM_NCACTIVATE"; | |
3116 | case 0x0087: return "WM_GETDLGCODE"; | |
3117 | case 0x00A0: return "WM_NCMOUSEMOVE"; | |
3118 | case 0x00A1: return "WM_NCLBUTTONDOWN"; | |
3119 | case 0x00A2: return "WM_NCLBUTTONUP"; | |
3120 | case 0x00A3: return "WM_NCLBUTTONDBLCLK"; | |
3121 | case 0x00A4: return "WM_NCRBUTTONDOWN"; | |
3122 | case 0x00A5: return "WM_NCRBUTTONUP"; | |
3123 | case 0x00A6: return "WM_NCRBUTTONDBLCLK"; | |
3124 | case 0x00A7: return "WM_NCMBUTTONDOWN"; | |
3125 | case 0x00A8: return "WM_NCMBUTTONUP"; | |
3126 | case 0x00A9: return "WM_NCMBUTTONDBLCLK"; | |
3127 | case 0x0100: return "WM_KEYDOWN"; | |
3128 | case 0x0101: return "WM_KEYUP"; | |
3129 | case 0x0102: return "WM_CHAR"; | |
3130 | case 0x0103: return "WM_DEADCHAR"; | |
3131 | case 0x0104: return "WM_SYSKEYDOWN"; | |
3132 | case 0x0105: return "WM_SYSKEYUP"; | |
3133 | case 0x0106: return "WM_SYSCHAR"; | |
3134 | case 0x0107: return "WM_SYSDEADCHAR"; | |
3135 | case 0x0108: return "WM_KEYLAST"; | |
3136 | ||
3137 | #ifdef __WIN32__ | |
3138 | case 0x010D: return "WM_IME_STARTCOMPOSITION"; | |
3139 | case 0x010E: return "WM_IME_ENDCOMPOSITION"; | |
3140 | case 0x010F: return "WM_IME_COMPOSITION"; | |
3141 | #endif //WIN32 | |
3142 | ||
3143 | case 0x0110: return "WM_INITDIALOG"; | |
3144 | case 0x0111: return "WM_COMMAND"; | |
3145 | case 0x0112: return "WM_SYSCOMMAND"; | |
3146 | case 0x0113: return "WM_TIMER"; | |
3147 | case 0x0114: return "WM_HSCROLL"; | |
3148 | case 0x0115: return "WM_VSCROLL"; | |
3149 | case 0x0116: return "WM_INITMENU"; | |
3150 | case 0x0117: return "WM_INITMENUPOPUP"; | |
3151 | case 0x011F: return "WM_MENUSELECT"; | |
3152 | case 0x0120: return "WM_MENUCHAR"; | |
3153 | case 0x0121: return "WM_ENTERIDLE"; | |
3154 | case 0x0200: return "WM_MOUSEMOVE"; | |
3155 | case 0x0201: return "WM_LBUTTONDOWN"; | |
3156 | case 0x0202: return "WM_LBUTTONUP"; | |
3157 | case 0x0203: return "WM_LBUTTONDBLCLK"; | |
3158 | case 0x0204: return "WM_RBUTTONDOWN"; | |
3159 | case 0x0205: return "WM_RBUTTONUP"; | |
3160 | case 0x0206: return "WM_RBUTTONDBLCLK"; | |
3161 | case 0x0207: return "WM_MBUTTONDOWN"; | |
3162 | case 0x0208: return "WM_MBUTTONUP"; | |
3163 | case 0x0209: return "WM_MBUTTONDBLCLK"; | |
3164 | case 0x0210: return "WM_PARENTNOTIFY"; | |
3165 | case 0x0211: return "WM_ENTERMENULOOP"; | |
3166 | case 0x0212: return "WM_EXITMENULOOP"; | |
3167 | ||
3168 | #ifdef __WIN32__ | |
3169 | case 0x0213: return "WM_NEXTMENU"; | |
3170 | case 0x0214: return "WM_SIZING"; | |
3171 | case 0x0215: return "WM_CAPTURECHANGED"; | |
3172 | case 0x0216: return "WM_MOVING"; | |
3173 | case 0x0218: return "WM_POWERBROADCAST"; | |
3174 | case 0x0219: return "WM_DEVICECHANGE"; | |
3175 | #endif //WIN32 | |
3176 | ||
3177 | case 0x0220: return "WM_MDICREATE"; | |
3178 | case 0x0221: return "WM_MDIDESTROY"; | |
3179 | case 0x0222: return "WM_MDIACTIVATE"; | |
3180 | case 0x0223: return "WM_MDIRESTORE"; | |
3181 | case 0x0224: return "WM_MDINEXT"; | |
3182 | case 0x0225: return "WM_MDIMAXIMIZE"; | |
3183 | case 0x0226: return "WM_MDITILE"; | |
3184 | case 0x0227: return "WM_MDICASCADE"; | |
3185 | case 0x0228: return "WM_MDIICONARRANGE"; | |
3186 | case 0x0229: return "WM_MDIGETACTIVE"; | |
3187 | case 0x0230: return "WM_MDISETMENU"; | |
3188 | case 0x0233: return "WM_DROPFILES"; | |
3189 | ||
3190 | #ifdef __WIN32__ | |
3191 | case 0x0281: return "WM_IME_SETCONTEXT"; | |
3192 | case 0x0282: return "WM_IME_NOTIFY"; | |
3193 | case 0x0283: return "WM_IME_CONTROL"; | |
3194 | case 0x0284: return "WM_IME_COMPOSITIONFULL"; | |
3195 | case 0x0285: return "WM_IME_SELECT"; | |
3196 | case 0x0286: return "WM_IME_CHAR"; | |
3197 | case 0x0290: return "WM_IME_KEYDOWN"; | |
3198 | case 0x0291: return "WM_IME_KEYUP"; | |
3199 | #endif //WIN32 | |
3200 | ||
3201 | case 0x0300: return "WM_CUT"; | |
3202 | case 0x0301: return "WM_COPY"; | |
3203 | case 0x0302: return "WM_PASTE"; | |
3204 | case 0x0303: return "WM_CLEAR"; | |
3205 | case 0x0304: return "WM_UNDO"; | |
3206 | case 0x0305: return "WM_RENDERFORMAT"; | |
3207 | case 0x0306: return "WM_RENDERALLFORMATS"; | |
3208 | case 0x0307: return "WM_DESTROYCLIPBOARD"; | |
3209 | case 0x0308: return "WM_DRAWCLIPBOARD"; | |
3210 | case 0x0309: return "WM_PAINTCLIPBOARD"; | |
3211 | case 0x030A: return "WM_VSCROLLCLIPBOARD"; | |
3212 | case 0x030B: return "WM_SIZECLIPBOARD"; | |
3213 | case 0x030C: return "WM_ASKCBFORMATNAME"; | |
3214 | case 0x030D: return "WM_CHANGECBCHAIN"; | |
3215 | case 0x030E: return "WM_HSCROLLCLIPBOARD"; | |
3216 | case 0x030F: return "WM_QUERYNEWPALETTE"; | |
3217 | case 0x0310: return "WM_PALETTEISCHANGING"; | |
3218 | case 0x0311: return "WM_PALETTECHANGED"; | |
3219 | ||
3220 | #ifdef __WIN32__ | |
3221 | // common controls messages - although they're not strictly speaking | |
3222 | // standard, it's nice to decode them nevertheless | |
3223 | ||
3224 | // listview | |
3225 | case 0x1000 + 0: return "LVM_GETBKCOLOR"; | |
3226 | case 0x1000 + 1: return "LVM_SETBKCOLOR"; | |
3227 | case 0x1000 + 2: return "LVM_GETIMAGELIST"; | |
3228 | case 0x1000 + 3: return "LVM_SETIMAGELIST"; | |
3229 | case 0x1000 + 4: return "LVM_GETITEMCOUNT"; | |
3230 | case 0x1000 + 5: return "LVM_GETITEMA"; | |
3231 | case 0x1000 + 75: return "LVM_GETITEMW"; | |
3232 | case 0x1000 + 6: return "LVM_SETITEMA"; | |
3233 | case 0x1000 + 76: return "LVM_SETITEMW"; | |
3234 | case 0x1000 + 7: return "LVM_INSERTITEMA"; | |
3235 | case 0x1000 + 77: return "LVM_INSERTITEMW"; | |
3236 | case 0x1000 + 8: return "LVM_DELETEITEM"; | |
3237 | case 0x1000 + 9: return "LVM_DELETEALLITEMS"; | |
3238 | case 0x1000 + 10: return "LVM_GETCALLBACKMASK"; | |
3239 | case 0x1000 + 11: return "LVM_SETCALLBACKMASK"; | |
3240 | case 0x1000 + 12: return "LVM_GETNEXTITEM"; | |
3241 | case 0x1000 + 13: return "LVM_FINDITEMA"; | |
3242 | case 0x1000 + 83: return "LVM_FINDITEMW"; | |
3243 | case 0x1000 + 14: return "LVM_GETITEMRECT"; | |
3244 | case 0x1000 + 15: return "LVM_SETITEMPOSITION"; | |
3245 | case 0x1000 + 16: return "LVM_GETITEMPOSITION"; | |
3246 | case 0x1000 + 17: return "LVM_GETSTRINGWIDTHA"; | |
3247 | case 0x1000 + 87: return "LVM_GETSTRINGWIDTHW"; | |
3248 | case 0x1000 + 18: return "LVM_HITTEST"; | |
3249 | case 0x1000 + 19: return "LVM_ENSUREVISIBLE"; | |
3250 | case 0x1000 + 20: return "LVM_SCROLL"; | |
3251 | case 0x1000 + 21: return "LVM_REDRAWITEMS"; | |
3252 | case 0x1000 + 22: return "LVM_ARRANGE"; | |
3253 | case 0x1000 + 23: return "LVM_EDITLABELA"; | |
3254 | case 0x1000 + 118: return "LVM_EDITLABELW"; | |
3255 | case 0x1000 + 24: return "LVM_GETEDITCONTROL"; | |
3256 | case 0x1000 + 25: return "LVM_GETCOLUMNA"; | |
3257 | case 0x1000 + 95: return "LVM_GETCOLUMNW"; | |
3258 | case 0x1000 + 26: return "LVM_SETCOLUMNA"; | |
3259 | case 0x1000 + 96: return "LVM_SETCOLUMNW"; | |
3260 | case 0x1000 + 27: return "LVM_INSERTCOLUMNA"; | |
3261 | case 0x1000 + 97: return "LVM_INSERTCOLUMNW"; | |
3262 | case 0x1000 + 28: return "LVM_DELETECOLUMN"; | |
3263 | case 0x1000 + 29: return "LVM_GETCOLUMNWIDTH"; | |
3264 | case 0x1000 + 30: return "LVM_SETCOLUMNWIDTH"; | |
3265 | case 0x1000 + 31: return "LVM_GETHEADER"; | |
3266 | case 0x1000 + 33: return "LVM_CREATEDRAGIMAGE"; | |
3267 | case 0x1000 + 34: return "LVM_GETVIEWRECT"; | |
3268 | case 0x1000 + 35: return "LVM_GETTEXTCOLOR"; | |
3269 | case 0x1000 + 36: return "LVM_SETTEXTCOLOR"; | |
3270 | case 0x1000 + 37: return "LVM_GETTEXTBKCOLOR"; | |
3271 | case 0x1000 + 38: return "LVM_SETTEXTBKCOLOR"; | |
3272 | case 0x1000 + 39: return "LVM_GETTOPINDEX"; | |
3273 | case 0x1000 + 40: return "LVM_GETCOUNTPERPAGE"; | |
3274 | case 0x1000 + 41: return "LVM_GETORIGIN"; | |
3275 | case 0x1000 + 42: return "LVM_UPDATE"; | |
3276 | case 0x1000 + 43: return "LVM_SETITEMSTATE"; | |
3277 | case 0x1000 + 44: return "LVM_GETITEMSTATE"; | |
3278 | case 0x1000 + 45: return "LVM_GETITEMTEXTA"; | |
3279 | case 0x1000 + 115: return "LVM_GETITEMTEXTW"; | |
3280 | case 0x1000 + 46: return "LVM_SETITEMTEXTA"; | |
3281 | case 0x1000 + 116: return "LVM_SETITEMTEXTW"; | |
3282 | case 0x1000 + 47: return "LVM_SETITEMCOUNT"; | |
3283 | case 0x1000 + 48: return "LVM_SORTITEMS"; | |
3284 | case 0x1000 + 49: return "LVM_SETITEMPOSITION32"; | |
3285 | case 0x1000 + 50: return "LVM_GETSELECTEDCOUNT"; | |
3286 | case 0x1000 + 51: return "LVM_GETITEMSPACING"; | |
3287 | case 0x1000 + 52: return "LVM_GETISEARCHSTRINGA"; | |
3288 | case 0x1000 + 117: return "LVM_GETISEARCHSTRINGW"; | |
3289 | case 0x1000 + 53: return "LVM_SETICONSPACING"; | |
3290 | case 0x1000 + 54: return "LVM_SETEXTENDEDLISTVIEWSTYLE"; | |
3291 | case 0x1000 + 55: return "LVM_GETEXTENDEDLISTVIEWSTYLE"; | |
3292 | case 0x1000 + 56: return "LVM_GETSUBITEMRECT"; | |
3293 | case 0x1000 + 57: return "LVM_SUBITEMHITTEST"; | |
3294 | case 0x1000 + 58: return "LVM_SETCOLUMNORDERARRAY"; | |
3295 | case 0x1000 + 59: return "LVM_GETCOLUMNORDERARRAY"; | |
3296 | case 0x1000 + 60: return "LVM_SETHOTITEM"; | |
3297 | case 0x1000 + 61: return "LVM_GETHOTITEM"; | |
3298 | case 0x1000 + 62: return "LVM_SETHOTCURSOR"; | |
3299 | case 0x1000 + 63: return "LVM_GETHOTCURSOR"; | |
3300 | case 0x1000 + 64: return "LVM_APPROXIMATEVIEWRECT"; | |
3301 | case 0x1000 + 65: return "LVM_SETWORKAREA"; | |
3302 | ||
3303 | // tree view | |
3304 | case 0x1100 + 0: return "TVM_INSERTITEMA"; | |
3305 | case 0x1100 + 50: return "TVM_INSERTITEMW"; | |
3306 | case 0x1100 + 1: return "TVM_DELETEITEM"; | |
3307 | case 0x1100 + 2: return "TVM_EXPAND"; | |
3308 | case 0x1100 + 4: return "TVM_GETITEMRECT"; | |
3309 | case 0x1100 + 5: return "TVM_GETCOUNT"; | |
3310 | case 0x1100 + 6: return "TVM_GETINDENT"; | |
3311 | case 0x1100 + 7: return "TVM_SETINDENT"; | |
3312 | case 0x1100 + 8: return "TVM_GETIMAGELIST"; | |
3313 | case 0x1100 + 9: return "TVM_SETIMAGELIST"; | |
3314 | case 0x1100 + 10: return "TVM_GETNEXTITEM"; | |
3315 | case 0x1100 + 11: return "TVM_SELECTITEM"; | |
3316 | case 0x1100 + 12: return "TVM_GETITEMA"; | |
3317 | case 0x1100 + 62: return "TVM_GETITEMW"; | |
3318 | case 0x1100 + 13: return "TVM_SETITEMA"; | |
3319 | case 0x1100 + 63: return "TVM_SETITEMW"; | |
3320 | case 0x1100 + 14: return "TVM_EDITLABELA"; | |
3321 | case 0x1100 + 65: return "TVM_EDITLABELW"; | |
3322 | case 0x1100 + 15: return "TVM_GETEDITCONTROL"; | |
3323 | case 0x1100 + 16: return "TVM_GETVISIBLECOUNT"; | |
3324 | case 0x1100 + 17: return "TVM_HITTEST"; | |
3325 | case 0x1100 + 18: return "TVM_CREATEDRAGIMAGE"; | |
3326 | case 0x1100 + 19: return "TVM_SORTCHILDREN"; | |
3327 | case 0x1100 + 20: return "TVM_ENSUREVISIBLE"; | |
3328 | case 0x1100 + 21: return "TVM_SORTCHILDRENCB"; | |
3329 | case 0x1100 + 22: return "TVM_ENDEDITLABELNOW"; | |
3330 | case 0x1100 + 23: return "TVM_GETISEARCHSTRINGA"; | |
3331 | case 0x1100 + 64: return "TVM_GETISEARCHSTRINGW"; | |
3332 | case 0x1100 + 24: return "TVM_SETTOOLTIPS"; | |
3333 | case 0x1100 + 25: return "TVM_GETTOOLTIPS"; | |
3334 | ||
3335 | // header | |
3336 | case 0x1200 + 0: return "HDM_GETITEMCOUNT"; | |
3337 | case 0x1200 + 1: return "HDM_INSERTITEMA"; | |
3338 | case 0x1200 + 10: return "HDM_INSERTITEMW"; | |
3339 | case 0x1200 + 2: return "HDM_DELETEITEM"; | |
3340 | case 0x1200 + 3: return "HDM_GETITEMA"; | |
3341 | case 0x1200 + 11: return "HDM_GETITEMW"; | |
3342 | case 0x1200 + 4: return "HDM_SETITEMA"; | |
3343 | case 0x1200 + 12: return "HDM_SETITEMW"; | |
3344 | case 0x1200 + 5: return "HDM_LAYOUT"; | |
3345 | case 0x1200 + 6: return "HDM_HITTEST"; | |
3346 | case 0x1200 + 7: return "HDM_GETITEMRECT"; | |
3347 | case 0x1200 + 8: return "HDM_SETIMAGELIST"; | |
3348 | case 0x1200 + 9: return "HDM_GETIMAGELIST"; | |
3349 | case 0x1200 + 15: return "HDM_ORDERTOINDEX"; | |
3350 | case 0x1200 + 16: return "HDM_CREATEDRAGIMAGE"; | |
3351 | case 0x1200 + 17: return "HDM_GETORDERARRAY"; | |
3352 | case 0x1200 + 18: return "HDM_SETORDERARRAY"; | |
3353 | case 0x1200 + 19: return "HDM_SETHOTDIVIDER"; | |
3354 | ||
3355 | // tab control | |
3356 | case 0x1300 + 2: return "TCM_GETIMAGELIST"; | |
3357 | case 0x1300 + 3: return "TCM_SETIMAGELIST"; | |
3358 | case 0x1300 + 4: return "TCM_GETITEMCOUNT"; | |
3359 | case 0x1300 + 5: return "TCM_GETITEMA"; | |
3360 | case 0x1300 + 60: return "TCM_GETITEMW"; | |
3361 | case 0x1300 + 6: return "TCM_SETITEMA"; | |
3362 | case 0x1300 + 61: return "TCM_SETITEMW"; | |
3363 | case 0x1300 + 7: return "TCM_INSERTITEMA"; | |
3364 | case 0x1300 + 62: return "TCM_INSERTITEMW"; | |
3365 | case 0x1300 + 8: return "TCM_DELETEITEM"; | |
3366 | case 0x1300 + 9: return "TCM_DELETEALLITEMS"; | |
3367 | case 0x1300 + 10: return "TCM_GETITEMRECT"; | |
3368 | case 0x1300 + 11: return "TCM_GETCURSEL"; | |
3369 | case 0x1300 + 12: return "TCM_SETCURSEL"; | |
3370 | case 0x1300 + 13: return "TCM_HITTEST"; | |
3371 | case 0x1300 + 14: return "TCM_SETITEMEXTRA"; | |
3372 | case 0x1300 + 40: return "TCM_ADJUSTRECT"; | |
3373 | case 0x1300 + 41: return "TCM_SETITEMSIZE"; | |
3374 | case 0x1300 + 42: return "TCM_REMOVEIMAGE"; | |
3375 | case 0x1300 + 43: return "TCM_SETPADDING"; | |
3376 | case 0x1300 + 44: return "TCM_GETROWCOUNT"; | |
3377 | case 0x1300 + 45: return "TCM_GETTOOLTIPS"; | |
3378 | case 0x1300 + 46: return "TCM_SETTOOLTIPS"; | |
3379 | case 0x1300 + 47: return "TCM_GETCURFOCUS"; | |
3380 | case 0x1300 + 48: return "TCM_SETCURFOCUS"; | |
3381 | case 0x1300 + 49: return "TCM_SETMINTABWIDTH"; | |
3382 | case 0x1300 + 50: return "TCM_DESELECTALL"; | |
3383 | ||
3384 | // toolbar | |
3385 | case WM_USER+1: return "TB_ENABLEBUTTON"; | |
3386 | case WM_USER+2: return "TB_CHECKBUTTON"; | |
3387 | case WM_USER+3: return "TB_PRESSBUTTON"; | |
3388 | case WM_USER+4: return "TB_HIDEBUTTON"; | |
3389 | case WM_USER+5: return "TB_INDETERMINATE"; | |
3390 | case WM_USER+9: return "TB_ISBUTTONENABLED"; | |
3391 | case WM_USER+10: return "TB_ISBUTTONCHECKED"; | |
3392 | case WM_USER+11: return "TB_ISBUTTONPRESSED"; | |
3393 | case WM_USER+12: return "TB_ISBUTTONHIDDEN"; | |
3394 | case WM_USER+13: return "TB_ISBUTTONINDETERMINATE"; | |
3395 | case WM_USER+17: return "TB_SETSTATE"; | |
3396 | case WM_USER+18: return "TB_GETSTATE"; | |
3397 | case WM_USER+19: return "TB_ADDBITMAP"; | |
3398 | case WM_USER+20: return "TB_ADDBUTTONS"; | |
3399 | case WM_USER+21: return "TB_INSERTBUTTON"; | |
3400 | case WM_USER+22: return "TB_DELETEBUTTON"; | |
3401 | case WM_USER+23: return "TB_GETBUTTON"; | |
3402 | case WM_USER+24: return "TB_BUTTONCOUNT"; | |
3403 | case WM_USER+25: return "TB_COMMANDTOINDEX"; | |
3404 | case WM_USER+26: return "TB_SAVERESTOREA"; | |
3405 | case WM_USER+76: return "TB_SAVERESTOREW"; | |
3406 | case WM_USER+27: return "TB_CUSTOMIZE"; | |
3407 | case WM_USER+28: return "TB_ADDSTRINGA"; | |
3408 | case WM_USER+77: return "TB_ADDSTRINGW"; | |
3409 | case WM_USER+29: return "TB_GETITEMRECT"; | |
3410 | case WM_USER+30: return "TB_BUTTONSTRUCTSIZE"; | |
3411 | case WM_USER+31: return "TB_SETBUTTONSIZE"; | |
3412 | case WM_USER+32: return "TB_SETBITMAPSIZE"; | |
3413 | case WM_USER+33: return "TB_AUTOSIZE"; | |
3414 | case WM_USER+35: return "TB_GETTOOLTIPS"; | |
3415 | case WM_USER+36: return "TB_SETTOOLTIPS"; | |
3416 | case WM_USER+37: return "TB_SETPARENT"; | |
3417 | case WM_USER+39: return "TB_SETROWS"; | |
3418 | case WM_USER+40: return "TB_GETROWS"; | |
3419 | case WM_USER+42: return "TB_SETCMDID"; | |
3420 | case WM_USER+43: return "TB_CHANGEBITMAP"; | |
3421 | case WM_USER+44: return "TB_GETBITMAP"; | |
3422 | case WM_USER+45: return "TB_GETBUTTONTEXTA"; | |
3423 | case WM_USER+75: return "TB_GETBUTTONTEXTW"; | |
3424 | case WM_USER+46: return "TB_REPLACEBITMAP"; | |
3425 | case WM_USER+47: return "TB_SETINDENT"; | |
3426 | case WM_USER+48: return "TB_SETIMAGELIST"; | |
3427 | case WM_USER+49: return "TB_GETIMAGELIST"; | |
3428 | case WM_USER+50: return "TB_LOADIMAGES"; | |
3429 | case WM_USER+51: return "TB_GETRECT"; | |
3430 | case WM_USER+52: return "TB_SETHOTIMAGELIST"; | |
3431 | case WM_USER+53: return "TB_GETHOTIMAGELIST"; | |
3432 | case WM_USER+54: return "TB_SETDISABLEDIMAGELIST"; | |
3433 | case WM_USER+55: return "TB_GETDISABLEDIMAGELIST"; | |
3434 | case WM_USER+56: return "TB_SETSTYLE"; | |
3435 | case WM_USER+57: return "TB_GETSTYLE"; | |
3436 | case WM_USER+58: return "TB_GETBUTTONSIZE"; | |
3437 | case WM_USER+59: return "TB_SETBUTTONWIDTH"; | |
3438 | case WM_USER+60: return "TB_SETMAXTEXTROWS"; | |
3439 | case WM_USER+61: return "TB_GETTEXTROWS"; | |
3440 | case WM_USER+41: return "TB_GETBITMAPFLAGS"; | |
3441 | ||
3442 | #endif //WIN32 | |
3443 | ||
3444 | default: | |
3445 | static char s_szBuf[128]; | |
3446 | sprintf(s_szBuf, "<unknown message = %d>", message); | |
3447 | return s_szBuf; | |
86de7616 | 3448 | } |
86de7616 | 3449 | */ |
cdf1e714 | 3450 | return NULL; |
86de7616 DW |
3451 | } |
3452 | ||
11e59d47 DW |
3453 | #endif // __WXDEBUG__ |
3454 |