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