Changeset 693 for trunk/src/user32/new/oslibwin.cpp
- Timestamp:
- Aug 25, 1999, 5:08:51 PM (26 years ago)
- File:
-
- 1 edited
-
trunk/src/user32/new/oslibwin.cpp (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/new/oslibwin.cpp
r628 r693 1 /* $Id: oslibwin.cpp,v 1.2 3 1999-08-22 18:29:37dengert Exp $ */1 /* $Id: oslibwin.cpp,v 1.24 1999-08-25 15:08:50 dengert Exp $ */ 2 2 /* 3 3 * Window API wrappers for OS/2 … … 5 5 * 6 6 * Copyright 1999 Sander van Leeuwen (sandervl@xs4all.nl) 7 * Copyright 1999 Daniela Engert (dani@ngrt.de) 7 8 * 8 9 * … … 18 19 19 20 #include <misc.h> 21 #include "win32type.h" 20 22 #include <winconst.h> 21 23 #include "oslibwin.h" … … 31 33 if(hwndParent == OSLIB_HWND_DESKTOP) 32 34 { 33 hwndParent = HWND_DESKTOP;35 hwndParent = HWND_DESKTOP; 34 36 } 35 37 … … 39 41 //****************************************************************************** 40 42 HWND OSLibWinCreateWindow(HWND hwndParent, ULONG dwWinStyle, ULONG dwFrameStyle, 41 char *pszName, HWND Owner, ULONG fHWND_BOTTOM, HWND *hwndFrame)43 char *pszName, HWND Owner, ULONG fHWND_BOTTOM, HWND *hwndFrame) 42 44 { 43 45 HWND hwndClient; … … 46 48 47 49 if(pszName && *pszName == 0) { 48 pszName = NULL;50 pszName = NULL; 49 51 } 50 52 if(hwndParent == OSLIB_HWND_DESKTOP) { 51 hwndParent = HWND_DESKTOP;53 hwndParent = HWND_DESKTOP; 52 54 } 53 55 if(Owner == OSLIB_HWND_DESKTOP) { 54 Owner = HWND_DESKTOP;56 Owner = HWND_DESKTOP; 55 57 } 56 58 57 59 if(dwFrameStyle) { 58 ULONG dwClientStyle;59 60 dwClientStyle = dwWinStyle & ~(WS_TABSTOP | WS_GROUP);61 if(pszName)62 dwFrameStyle |= FCF_TITLEBAR;63 64 dwFrameStyle |= FCF_TASKLIST;65 *hwndFrame = WinCreateStdWindow(hwndParent, dwWinStyle,66 &dwFrameStyle, WIN32_STDCLASS,67 "", dwClientStyle, 0, 0, &hwndClient);68 if(*hwndFrame) {69 if(pszName) {70 WinSetWindowText(*hwndFrame, pszName);71 }72 return hwndClient;73 }74 dprintf(("OSLibWinCreateWindow: WinCreateStdWindow failed (%x)", WinGetLastError(GetThreadHAB())));75 return 0;60 ULONG dwClientStyle; 61 62 dwClientStyle = dwWinStyle & ~(WS_TABSTOP | WS_GROUP); 63 if(pszName) 64 dwFrameStyle |= FCF_TITLEBAR; 65 66 dwFrameStyle |= FCF_TASKLIST; 67 *hwndFrame = WinCreateStdWindow(hwndParent, dwWinStyle, 68 &dwFrameStyle, WIN32_STDCLASS, 69 "", dwClientStyle, 0, 0, &hwndClient); 70 if(*hwndFrame) { 71 if(pszName) { 72 WinSetWindowText(*hwndFrame, pszName); 73 } 74 return hwndClient; 75 } 76 dprintf(("OSLibWinCreateWindow: WinCreateStdWindow failed (%x)", WinGetLastError(GetThreadHAB()))); 77 return 0; 76 78 } 77 79 hwndClient = WinCreateWindow(hwndParent, WIN32_STDCLASS, pszName, dwWinStyle, 0, 0, 0, 0, 78 Owner, (fHWND_BOTTOM) ? HWND_BOTTOM :HWND_TOP, 0, NULL,79 NULL);80 Owner, (fHWND_BOTTOM) ? HWND_BOTTOM :HWND_TOP, 0, NULL, 81 NULL); 80 82 *hwndFrame = hwndClient; 81 83 return hwndClient; … … 85 87 BOOL OSLibWinConvertStyle(ULONG dwStyle, ULONG dwExStyle, ULONG *OSWinStyle, ULONG *OSFrameStyle) 86 88 { 87 *OSWinStyle = 0;89 *OSWinStyle = 0; 88 90 *OSFrameStyle = 0; 89 91 90 92 /* Window styles */ 91 93 if(dwStyle & WS_MINIMIZE_W) 92 *OSWinStyle |= WS_MINIMIZED;94 *OSWinStyle |= WS_MINIMIZED; 93 95 //Done explicitely in CreateWindowExA 94 96 #if 0 95 97 if(dwStyle & WS_VISIBLE_W) 96 *OSWinStyle |= WS_VISIBLE;98 *OSWinStyle |= WS_VISIBLE; 97 99 #endif 98 100 if(dwStyle & WS_DISABLED_W) 99 *OSWinStyle |= WS_DISABLED;101 *OSWinStyle |= WS_DISABLED; 100 102 if(dwStyle & WS_CLIPSIBLINGS_W) 101 *OSWinStyle |= WS_CLIPSIBLINGS;103 *OSWinStyle |= WS_CLIPSIBLINGS; 102 104 if(dwStyle & WS_CLIPCHILDREN_W) 103 *OSWinStyle |= WS_CLIPCHILDREN;105 *OSWinStyle |= WS_CLIPCHILDREN; 104 106 if(dwStyle & WS_MAXIMIZE_W) 105 *OSWinStyle |= WS_MAXIMIZED;107 *OSWinStyle |= WS_MAXIMIZED; 106 108 if(dwStyle & WS_GROUP_W) 107 *OSWinStyle |= WS_GROUP;109 *OSWinStyle |= WS_GROUP; 108 110 if(dwStyle & WS_TABSTOP_W) 109 *OSWinStyle |= WS_TABSTOP;111 *OSWinStyle |= WS_TABSTOP; 110 112 111 113 if(dwStyle & WS_CAPTION_W) 112 *OSFrameStyle |= FCF_TITLEBAR;114 *OSFrameStyle |= FCF_TITLEBAR; 113 115 if(dwStyle & WS_DLGFRAME_W) 114 *OSFrameStyle |= FCF_DLGBORDER;116 *OSFrameStyle |= FCF_DLGBORDER; 115 117 else 116 118 if(dwStyle & WS_BORDER_W) 117 *OSFrameStyle |= FCF_BORDER;119 *OSFrameStyle |= FCF_BORDER; 118 120 119 121 if(dwStyle & WS_VSCROLL_W) 120 *OSFrameStyle |= FCF_VERTSCROLL;122 *OSFrameStyle |= FCF_VERTSCROLL; 121 123 if(dwStyle & WS_HSCROLL_W) 122 *OSFrameStyle |= FCF_HORZSCROLL;124 *OSFrameStyle |= FCF_HORZSCROLL; 123 125 if(dwStyle & WS_SYSMENU_W) 124 *OSFrameStyle |= FCF_SYSMENU;126 *OSFrameStyle |= FCF_SYSMENU; 125 127 if(dwStyle & WS_THICKFRAME_W) 126 *OSFrameStyle |= FCF_SIZEBORDER;//??128 *OSFrameStyle |= FCF_SIZEBORDER; //?? 127 129 if(dwStyle & WS_MINIMIZEBOX_W) 128 *OSFrameStyle |= FCF_MINBUTTON;130 *OSFrameStyle |= FCF_MINBUTTON; 129 131 if(dwStyle & WS_MAXIMIZEBOX_W) 130 *OSFrameStyle |= FCF_MAXBUTTON;132 *OSFrameStyle |= FCF_MAXBUTTON; 131 133 132 134 if(dwExStyle & WS_EX_DLGMODALFRAME_W) 133 *OSFrameStyle |= FCF_DLGBORDER;135 *OSFrameStyle |= FCF_DLGBORDER; 134 136 135 137 return TRUE; … … 226 228 //****************************************************************************** 227 229 BOOL OSLibWinSetWindowPos(HWND hwnd, HWND hwndInsertBehind, LONG x, LONG y, LONG cx, 228 LONG cy, ULONG fl)230 LONG cy, ULONG fl) 229 231 { 230 232 HWND hwndParent = hwndInsertBehind; … … 232 234 233 235 if(fl & SWP_MOVE) { 234 switch(hwndParent)235 {236 case HWNDOS_TOP:237 case HWNDOS_BOTTOM:238 hwndParent = HWND_DESKTOP;239 break;240 }241 y = MapOS2ToWin32Y(hwndParent, cy, y);236 switch(hwndParent) 237 { 238 case HWNDOS_TOP: 239 case HWNDOS_BOTTOM: 240 hwndParent = HWND_DESKTOP; 241 break; 242 } 243 y = MapOS2ToWin32Y(hwndParent, cy, y); 242 244 } 243 245 rc = WinSetWindowPos(hwnd, hwndInsertBehind, x, y, cx, cy, fl); … … 247 249 //****************************************************************************** 248 250 //****************************************************************************** 251 BOOL OSLibWinSetMultWindowPos(PSWP pswp, ULONG num) 252 { 253 return WinSetMultWindowPos(GetThreadHAB(), pswp, num); 254 } 255 //****************************************************************************** 256 //****************************************************************************** 249 257 BOOL OSLibWinShowWindow(HWND hwnd, ULONG fl) 250 258 { … … 252 260 253 261 if(fl & SWP_SHOW) { 254 rc = WinShowWindow(hwnd, TRUE);262 rc = WinShowWindow(hwnd, TRUE); 255 263 } 256 264 if(rc == 0) 257 dprintf(("WinShowWindow %x failed %x", hwnd, WinGetLastError(GetThreadHAB())));265 dprintf(("WinShowWindow %x failed %x", hwnd, WinGetLastError(GetThreadHAB()))); 258 266 rc = WinSetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, fl); 259 267 if(rc == 0) 260 dprintf(("WinShowWindow %x failed %x", hwnd, WinGetLastError(GetThreadHAB())));268 dprintf(("WinShowWindow %x failed %x", hwnd, WinGetLastError(GetThreadHAB()))); 261 269 return rc; 262 270 } … … 271 279 BOOL OSLibWinQueryWindowRect(HWND hwnd, PRECT pRect, int RelativeTo) 272 280 { 273 BOOL rc;281 BOOL rc; 274 282 RECTLOS2 rectl; 275 283 276 284 rc = WinQueryWindowRect(hwnd, (PRECTL)&rectl); 277 285 if(rc) { 278 if(RelativeTo == RELATIVE_TO_SCREEN) {279 MapOS2ToWin32Rectl(OSLIB_HWND_DESKTOP, hwnd, &rectl, pRect);280 }281 elseMapOS2ToWin32Rectl(&rectl, pRect);282 } 283 else memset(pRect, 0, sizeof(RECT));286 if(RelativeTo == RELATIVE_TO_SCREEN) { 287 MapOS2ToWin32Rectl(OSLIB_HWND_DESKTOP, hwnd, &rectl, pRect); 288 } 289 else MapOS2ToWin32Rectl(&rectl, pRect); 290 } 291 else memset(pRect, 0, sizeof(RECT)); 284 292 return rc; 285 293 } … … 293 301 rc = WinQueryWindowPos(hwnd, &swp); 294 302 if(rc == FALSE) { 295 dprintf(("OSLibWinIsIconic: WinQueryWindowPos %x failed", hwnd));296 return FALSE;303 dprintf(("OSLibWinIsIconic: WinQueryWindowPos %x failed", hwnd)); 304 return FALSE; 297 305 } 298 306 299 307 if(swp.fl & SWP_MINIMIZE) 300 return TRUE;301 else return FALSE;308 return TRUE; 309 else return FALSE; 302 310 } 303 311 //****************************************************************************** … … 389 397 //****************************************************************************** 390 398 //****************************************************************************** 391 399 BOOL OSLibWinQueryWindowPos (HWND hwnd, PSWP pswp) 400 { 401 return WinQueryWindowPos(hwnd, pswp); 402 } 403 //****************************************************************************** 404 //****************************************************************************** 405 void OSLibMapSWPtoWINDOWPOS(PSWP pswp, PWINDOWPOS pwpos, PSWP pswpOld, ULONG parentHeight) 406 { 407 HWND hWindow = pswp->hwnd; 408 HWND hWndInsertAfter = pswp->hwndInsertBehind; 409 long x = pswp->x; 410 long y = pswp->y; 411 long cx = pswp->cx; 412 long cy = pswp->cy; 413 UINT fuFlags = (UINT)pswp->fl; 414 415 HWND hWinAfter; 416 ULONG flags = 0; 417 418 //*************************************************** 419 // Map constant HWNDs (e.g. HWND_DESKTOP, HWND_TOP) 420 //*************************************************** 421 HWND hWnd = (hWindow == HWND_DESKTOP) ? HWND_DESKTOP_W: hWindow; 422 423 if ( hWndInsertAfter == HWND_TOP ) 424 hWinAfter = HWND_TOP_W; 425 else if ( hWndInsertAfter == HWND_BOTTOM ) 426 hWinAfter = HWND_BOTTOM_W; 427 else 428 hWinAfter = (HWND) hWndInsertAfter; 429 430 //*********************************** 431 // convert PM flags to Windows flags 432 //*********************************** 433 if (!(fuFlags & SWP_SIZE)) flags |= SWP_NOSIZE_W; 434 if (!(fuFlags & SWP_MOVE)) flags |= SWP_NOMOVE_W; 435 if (!(fuFlags & SWP_ZORDER)) flags |= SWP_NOZORDER_W; 436 if ( fuFlags & SWP_NOREDRAW) flags |= SWP_NOREDRAW_W; 437 if (!(fuFlags & SWP_ACTIVATE)) flags |= SWP_NOACTIVATE_W; 438 if ( fuFlags & SWP_SHOW) flags |= SWP_SHOWWINDOW_W; 439 if ( fuFlags & SWP_HIDE) flags |= SWP_HIDEWINDOW_W; 440 441 //************************************************************************** 442 // When moving or sizing we'll have to do some calculations for Y inversion. 443 // 444 // If moving - invert Y coord. 445 // 446 // If sizing - if the height is changing, have to move the window to 447 // maintain correct windows position. If we just size then the 448 // TR corner will extend. The Windows behaviour should be to 449 // extend the BR corner. 450 // 451 // If this is a child window then we'll have to move within the client 452 // area of the parent. 453 // 454 // If this is an overlapped or popup window we'll have to move around 455 // within the desktop. 456 //************************************************************************** 457 if ( fuFlags & (SWP_MOVE | SWP_SIZE) ) 458 { 459 if (fuFlags & SWP_SIZE) 460 { 461 // If height is changing we MUST move to maintain top-left alignment 462 if (cy != pswpOld->cy) 463 { 464 flags &= ~SWP_NOMOVE_W; 465 } 466 } 467 else 468 { 469 cx = pswpOld->cx; 470 cy = pswpOld->cy; 471 } 472 473 //********************************************************** 474 // We'll need both a y and cy for the Y inversion code. 475 // If either wasn't passed in, calculate the current value. 476 //********************************************************** 477 if ((fuFlags & SWP_MOVE) == 0) 478 { 479 x = pswpOld->x; 480 y = pswpOld->y; 481 } 482 483 //******************************************************** 484 // Y inversion here... old Y is top left corner of window 485 // relative to top left of parent. 486 //******************************************************** 487 y = parentHeight - y - cy; 488 489 LONG oldY = parentHeight - pswpOld->y - pswpOld->cy; 490 491 // Set the SWP_NOMOVE_W flag if the window has not moved in windows 492 // coordinates. 493 if ( ( pswpOld->x == x ) && ( oldY == y ) ) 494 flags |= SWP_NOMOVE_W; 495 496 // Set the SWP_NOSIZE_W flag if the window is not really being sized. 497 if ( ( pswpOld->cx == cx ) && ( pswpOld->cy == cy ) ) 498 flags |= SWP_NOSIZE_W; 499 } 500 501 // Fill in the WINDOWPOS structure with the now calculated PM values. 502 pwpos->flags = (UINT)flags; 503 pwpos->cy = (int)cy; 504 pwpos->cx = (int)cx; 505 pwpos->x = (int)x; 506 pwpos->y = (int)y; 507 pwpos->hwndInsertAfter = hWinAfter; 508 pwpos->hwnd = hWindow; 509 } 510 //****************************************************************************** 511 //****************************************************************************** 512 void OSLibMapWINDOWPOStoSWP(PWINDOWPOS pwpos, PSWP pswp, PSWP pswpOld, ULONG parentHeight) 513 { 514 HWND hWnd = pwpos->hwnd; 515 HWND hWndInsertAfter = pwpos->hwndInsertAfter; 516 long x = pwpos->x; 517 long y = pwpos->y; 518 long cx = pwpos->cx; 519 long cy = pwpos->cy; 520 UINT fuFlags = pwpos->flags; 521 522 HWND hWinAfter; 523 ULONG flags = 0; 524 525 //*************************************************** 526 // Map constant HWNDs (e.g. HWND_DESKTOP, HWND_TOP) 527 //*************************************************** 528 HWND hWindow = hWnd ? (HWND)hWnd : HWND_DESKTOP; 529 530 if ( hWndInsertAfter == HWND_TOPMOST_W ) 531 // hWinAfter = HWND_TOPMOST; 532 hWinAfter = HWND_TOP; 533 else if ( hWndInsertAfter == HWND_NOTOPMOST_W ) 534 // hWinAfter = HWND_NOTOPMOST; 535 hWinAfter = HWND_TOP; 536 else if ( hWndInsertAfter == HWND_TOP_W ) 537 hWinAfter = HWND_TOP; 538 else if ( hWndInsertAfter == HWND_BOTTOM_W ) 539 hWinAfter = HWND_BOTTOM; 540 else 541 hWinAfter = (HWND) hWndInsertAfter; 542 543 //*********************************** 544 // convert Windows flags to PM flags 545 //*********************************** 546 if ( ! ( fuFlags & SWP_NOSIZE_W ) ) flags |= SWP_SIZE; 547 if ( ! ( fuFlags & SWP_NOMOVE_W ) ) flags |= SWP_MOVE; 548 if ( ! ( fuFlags & SWP_NOZORDER_W ) ) flags |= SWP_ZORDER; 549 if ( fuFlags & SWP_NOREDRAW_W ) flags |= SWP_NOREDRAW; 550 if ( ! ( fuFlags & SWP_NOACTIVATE_W ) ) flags |= SWP_ACTIVATE; 551 if ( fuFlags & SWP_SHOWWINDOW_W ) flags |= SWP_SHOW; 552 if ( fuFlags & SWP_HIDEWINDOW_W ) flags |= SWP_HIDE; 553 /* no PM equivalent for SWP_FRAMECHANGED_W, SWP_NOCOPYBITS_W and SWP_NOOWNERZORDER_W */ 554 555 //************************************************************************** 556 // When moving or sizing we'll have to do some calculations for Y inversion. 557 // 558 // If moving - invert Y coord. 559 // 560 // If sizing - if the height is changing, have to move the window to 561 // maintain correct windows position. If we just size then the 562 // TR corner will extend. The Windows behaviour should be to 563 // extend the BR corner. 564 // 565 // If this is a child window then we'll have to move within the client 566 // area of the parent. 567 // 568 // If this is an overlapped or popup window we'll have to move around 569 // within the desktop. 570 //************************************************************************** 571 if ( flags & (SWP_MOVE | SWP_SIZE) ) 572 { 573 //********************************************************** 574 // We'll need both a y and cy for the Y inversion code. 575 // If either wasn't passed in, calculate the current value. 576 //********************************************************** 577 if ((flags & SWP_MOVE) == 0) 578 { 579 x = pswpOld->x; 580 y = pswpOld->y; 581 582 // If the window is at (x,0) with a height of zero then this calculation 583 // won't quite work. Instead of calculating the Windows y coord, we set 584 // it at (x,0). 585 if (!(y == 0 && pswpOld->cy == 0)) 586 { 587 // convert Y coordinate back to Windows's for later conversion with new size 588 y = parentHeight - y - pswpOld->cy; 589 } 590 } 591 592 if (flags & SWP_SIZE) 593 { 594 // If height is changing we MUST move to maintain top-left alignment 595 if (cy != pswpOld->cy) 596 flags |= SWP_MOVE; 597 } 598 else 599 { 600 cx = pswpOld->cx; 601 cy = pswpOld->cy; 602 } 603 604 //******************************************************** 605 // Y inversion here... old Y is top left corner of window 606 // relative to top left of parent. 607 //******************************************************** 608 y = parentHeight - y - cy; 609 610 // Clear the SWP_MOVE flag if the window is not really being moved. 611 if ( ( pswpOld->x == x ) && ( pswpOld->y == y ) ) 612 flags &= ~SWP_MOVE; 613 614 // Clear the SWP_SIZE flag if the window is not really being sized. 615 if ( ( pswpOld->cx == cx ) && ( pswpOld->cy == cy ) ) 616 flags &= ~SWP_SIZE; 617 } 618 619 // Fill in the WINDOWPOS structure with the now calculated PM values. 620 pswp->fl = flags; 621 pswp->cy = cy; 622 pswp->cx = cx; 623 pswp->x = x; 624 pswp->y = y; 625 pswp->hwndInsertBehind = hWinAfter; 626 pswp->hwnd = hWindow; 627 pswp->ulReserved1 = 0; 628 pswp->ulReserved2 = 0; 629 } 630 //****************************************************************************** 631 //****************************************************************************** 632
Note:
See TracChangeset
for help on using the changeset viewer.
