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