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