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