Changeset 911 for trunk/src/user32/new/dc.cpp
- Timestamp:
- Sep 12, 1999, 5:44:20 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/new/dc.cpp
r903 r911 1 /* $Id: dc.cpp,v 1. 2 1999-09-10 19:00:10 dengert Exp $ */1 /* $Id: dc.cpp,v 1.3 1999-09-12 15:44:20 dengert Exp $ */ 2 2 3 3 /* … … 23 23 #include <math.h> 24 24 #include <limits.h> 25 #include "oslibwin.h" 25 26 26 27 #ifndef OPEN32API … … 103 104 #define GM_ADVANCED_W 2 104 105 105 #define DCX_WINDOW 0x00000001L 106 #define DCX_CACHE 0x00000002L 107 #define DCX_NORESETATTRS 0x00000004L 108 #define DCX_CLIPCHILDREN 0x00000008L 109 #define DCX_CLIPSIBLINGS 0x00000010L 110 #define DCX_PARENTCLIP 0x00000020L 111 #define DCX_EXCLUDERGN 0x00000040L 112 #define DCX_INTERSECTRGN 0x00000080L 113 #define DCX_EXCLUDEUPDATE 0x00000100L 114 #define DCX_INTERSECTUPDATE 0x00000200L 115 #define DCX_LOCKWINDOWUPDATE 0x00000400L 116 #define DCX_VALIDATE 0x00200000L 106 #define DCX_WINDOW_W 0x00000001L 107 #define DCX_CACHE_W 0x00000002L 108 #define DCX_NORESETATTRS_W 0x00000004L 109 #define DCX_CLIPCHILDREN_W 0x00000008L 110 #define DCX_CLIPSIBLINGS_W 0x00000010L 111 #define DCX_PARENTCLIP_W 0x00000020L 112 #define DCX_EXCLUDERGN_W 0x00000040L 113 #define DCX_INTERSECTRGN_W 0x00000080L 114 #define DCX_EXCLUDEUPDATE_W 0x00000100L 115 #define DCX_INTERSECTUPDATE_W 0x00000200L 116 #define DCX_LOCKWINDOWUPDATE_W 0x00000400L 117 #define DCX_VALIDATE_W 0x00200000L 118 119 typedef struct _RGNDATAHEADER_W { 120 DWORD dwSize; 121 DWORD iType; 122 DWORD nCount; 123 DWORD nRgnSize; 124 RECT rcBound; 125 } RGNDATAHEADER_W, *LPRGNDATAHEADER_W; 126 127 typedef struct _RGNDATA_W { 128 RGNDATAHEADER_W rdh; 129 char Buffer[1]; 130 } RGNDATA_W , *PRGNDATA_W , *LPRGNDATA_W ; 131 117 132 118 133 /* Xform FLAGS */ … … 251 266 BOOL OPEN32API _O32_EndPaint (HWND hwnd, const PAINTSTRUCT_W *lpps); 252 267 int OPEN32API _O32_GetUpdateRgn (HWND hwnd, HRGN hrgn, BOOL erase); 268 ULONG OPEN32API _O32_GetRegionData (HRGN hrgn, ULONG count, PRGNDATA_W pData); 269 BOOL OPEN32API _O32_DeleteObject (LHANDLE hgdiobj); 253 270 254 271 #define FLOAT_TO_FIXED(x) ((FIXED) ((x) * 65536.0)) … … 276 293 const MATRIXLF matrixlfIdentity = { 0x10000, 0, 0, 0, 0x10000, 0, 0, 0, 0}; 277 294 278 BOOL setPageXForm( pDCData pHps);279 BOOL changePageXForm( pDCData pHps, PPOINTL pValue, int x, int y, PPOINTL pPrev);280 LONG clientHeight( HWND hwnd, pDCData pHps);295 BOOL setPageXForm(Win32BaseWindow *wnd, pDCData pHps); 296 BOOL changePageXForm(Win32BaseWindow *wnd, pDCData pHps, PPOINTL pValue, int x, int y, PPOINTL pPrev); 297 LONG clientHeight(Win32BaseWindow *wnd, HWND hwnd, pDCData pHps); 281 298 282 299 void TestWideLine (pDCData pHps) … … 314 331 //****************************************************************************** 315 332 316 int setMapMode( pDCData pHps, int mode)333 int setMapMode(Win32BaseWindow *wnd, pDCData pHps, int mode) 317 334 { 318 335 int prevMode = 0; … … 376 393 if (pHps->lWndXExtSave && pHps->lWndYExtSave) 377 394 { 378 changePageXForm (pHps, (PPOINTL)&pHps->windowExt,395 changePageXForm (wnd, pHps, (PPOINTL)&pHps->windowExt, 379 396 pHps->lWndXExtSave, pHps->lWndYExtSave, NULL ); 380 397 pHps->lWndXExtSave = pHps->lWndYExtSave = 0; … … 382 399 if (pHps->lVwpXExtSave && pHps->lVwpYExtSave) 383 400 { 384 changePageXForm (pHps, NULL,401 changePageXForm (wnd, pHps, NULL, 385 402 pHps->lVwpXExtSave, pHps->lVwpYExtSave, NULL ); 386 403 pHps->lVwpXExtSave = pHps->lVwpYExtSave = 0; … … 388 405 } 389 406 390 setPageXForm( pHps);407 setPageXForm(wnd, pHps); 391 408 392 409 return prevMode; 393 410 } 394 411 395 BOOL setPageXForm( pDCData pHps)412 BOOL setPageXForm(Win32BaseWindow *wnd, pDCData pHps) 396 413 { 397 414 MATRIXLF mlf; 398 415 BOOL rc = TRUE; 399 416 400 pHps->height = clientHeight( 0, pHps) - 1;417 pHps->height = clientHeight(wnd, 0, pHps) - 1; 401 418 402 419 double xScale = pHps->viewportXExt / (double)pHps->windowExt.cx; … … 445 462 } 446 463 447 BOOL changePageXForm( pDCData pHps, PPOINTL pValue, int x, int y, PPOINTL pPrev)464 BOOL changePageXForm(Win32BaseWindow *wnd, pDCData pHps, PPOINTL pValue, int x, int y, PPOINTL pPrev) 448 465 { 449 466 BOOL result = FALSE; … … 500 517 } 501 518 } 502 result = setPageXForm( pHps);519 result = setPageXForm(wnd, pHps); 503 520 504 521 return (result); 505 522 } 506 523 507 LONG clientHeight( HWND hwnd, pDCData pHps)524 LONG clientHeight(Win32BaseWindow *wnd, HWND hwnd, pDCData pHps) 508 525 { 509 526 if ((hwnd == 0) && (pHps != 0)) … … 512 529 if ((hwnd != 0) || (pHps == 0)) 513 530 { 514 Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd); 515 return (wnd->getWindowHeight()); 531 if (wnd) 532 return (wnd->getWindowHeight()); 533 else 534 return OSLibQueryScreenHeight(); 516 535 } 517 536 else if (pHps->bitmapHandle) … … 549 568 } 550 569 551 voidselectClientArea(Win32BaseWindow *wnd, pDCData pHps, PRECTL prclPaint)570 BOOL selectClientArea(Win32BaseWindow *wnd, pDCData pHps, PRECTL prclPaint) 552 571 { 553 572 RECTL rcl; 554 573 HRGN hrgnRect; 555 574 HWND hwnd; 575 576 if (!wnd) return (FALSE); 556 577 557 578 pHps->isClient = TRUE; … … 583 604 pHps->isClientArea = TRUE; 584 605 GreDestroyRegion(pHps->hps, hrgnRect); 606 607 return (TRUE); 585 608 } 586 609 … … 672 695 673 696 if (hPS_ownDC == 0) 674 setMapMode (pHps, MM_TEXT_W);675 else 676 setPageXForm (pHps);697 setMapMode (wnd, pHps, MM_TEXT_W); 698 else 699 setPageXForm (wnd, pHps); 677 700 678 701 pHps->hdcType = TYPE_3; … … 800 823 } 801 824 825 // This implementation of GetDCEx supports 826 // DCX_WINDOW 827 // DCX_CACHE 828 // DCX_EXCLUDERGN (complex regions allowed) 829 // DCX_INTERSECTRGN (complex regions allowed) 830 831 HDC WIN32API GetDCEx (HWND hwnd, HRGN hrgn, ULONG flags) 832 { 833 USHORT sel = RestoreOS2FS(); 834 Win32BaseWindow *wnd = NULL; 835 HWND hWindow; 836 BOOL success; 837 pDCData pHps = NULL; 838 HPS hps = NULLHANDLE; 839 BOOL drawingAllowed = TRUE; 840 BOOL isWindowOwnDC; 841 BOOL creatingOwnDC = FALSE; 842 PS_Type psType; 843 844 if (hwnd) 845 { 846 wnd = Win32BaseWindow::GetWindowFromHandle(hwnd); 847 if (flags & DCX_WINDOW_W) 848 hWindow = wnd->getOS2FrameWindowHandle(); 849 else 850 hWindow = wnd->getOS2WindowHandle(); 851 } 852 else 853 hWindow = HWND_DESKTOP; 854 855 dprintf (("User32: GetDCEx hwnd %x (%x %x) -> wnd %x", hwnd, hrgn, flags, wnd)); 856 857 isWindowOwnDC = (((hWindow == HWND_DESKTOP) ? FALSE : wnd->isOwnDC()) 858 && !(flags & DCX_CACHE_W)); 859 if (isWindowOwnDC) 860 { 861 hps = wnd->getOwnDC(); 862 if (hps) 863 { 864 pDCData pHps = (pDCData)GpiQueryDCData (hps); 865 if (!pHps) 866 goto error; 867 868 if (flags & DCX_WINDOW_W) 869 removeClientArea (pHps); 870 else 871 selectClientArea (wnd, pHps, 0); 872 873 setPageXForm (wnd, pHps); 874 875 pHps->hdcType = TYPE_1; 876 SetFS(sel); 877 return (HDC)hps; 878 } 879 else 880 creatingOwnDC = TRUE; 881 } 882 883 if (isWindowOwnDC) 884 { 885 SIZEL sizel = {0,0}; 886 hps = GpiCreatePS (WinQueryAnchorBlock (hWindow), 887 WinOpenWindowDC (hWindow), 888 &sizel, PU_PELS | GPIT_MICRO | GPIA_ASSOC ); 889 psType = MICRO; 890 } 891 else 892 { 893 if (hWindow == HWND_DESKTOP) 894 hps = WinGetScreenPS (hWindow); 895 else 896 hps = WinGetPS (hWindow); 897 898 psType = MICRO_CACHED; 899 } 900 901 if (!hps) 902 goto error; 903 904 HPSToHDC (hWindow, hps, NULL, NULL); 905 pHps = (pDCData)GpiQueryDCData (hps); 906 907 if (!(flags & DCX_WINDOW_W)) { 908 if (selectClientArea (wnd, pHps, 0)) 909 setMapMode (wnd, pHps, MM_TEXT_W); 910 } 911 912 if ((flags & DCX_EXCLUDERGN_W) || (flags & DCX_INTERSECTRGN_W)) 913 { 914 ULONG BytesNeeded; 915 PRGNDATA_W RgnData; 916 PRECTL pr; 917 int i; 918 919 if (!hrgn) 920 goto error; 921 922 BytesNeeded = _O32_GetRegionData (hrgn, 0, NULL); 923 RgnData = (PRGNDATA_W)_alloca (BytesNeeded); 924 if (RgnData == NULL) 925 goto error; 926 _O32_GetRegionData (hrgn, BytesNeeded, RgnData); 927 928 i = RgnData->rdh.nCount; 929 pr = (PRECTL)(RgnData->Buffer); 930 931 success = TRUE; 932 if (flags & DCX_EXCLUDERGN_W) 933 for (; (i > 0) && success; i--, pr++) 934 success &= GpiExcludeClipRectangle (pHps->hps, pr); 935 else 936 for (; (i > 0) && success; i--, pr++) 937 success &= GpiIntersectClipRectangle (pHps->hps, pr); 938 if (!success) 939 goto error; 940 } 941 942 if (creatingOwnDC) 943 wnd->setOwnDC ((HDC)hps); 944 945 pHps->psType = psType; 946 pHps->hdcType = TYPE_1; 947 GpiSetDrawControl (hps, DCTL_DISPLAY, drawingAllowed ? DCTL_ON : DCTL_OFF); 948 949 SetFS(sel); 950 return (HDC)pHps->hps; 951 952 error: 953 /* Something went wrong; clean up 954 */ 955 if (pHps) 956 { 957 if (pHps->hps) 958 { 959 if(pHps->psType == MICRO_CACHED) 960 WinReleasePS(pHps->hps); 961 else 962 GpiDestroyPS(pHps->hps); 963 } 964 965 if (pHps->hdc) DevCloseDC(pHps->hdc); 966 if (pHps->hrgnHDC) GpiDestroyRegion(pHps->hps, pHps->hrgnHDC); 967 968 _O32_DeleteObject (pHps->nullBitmapHandle); 969 } 970 // SET_ERROR_LAST(); 971 SetFS(sel); 972 return NULL; 973 } 974 975 HDC WIN32API GetDC (HWND hwnd) 976 { 977 return GetDCEx (hwnd, NULL, 0); 978 } 979 980 802 981 //****************************************************************************** 803 982 //******************************************************************************
Note:
See TracChangeset
for help on using the changeset viewer.