Changeset 1405 for trunk/src/user32/dc.cpp
- Timestamp:
- Oct 22, 1999, 8:11:51 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/dc.cpp
r1351 r1405 1 /* $Id: dc.cpp,v 1.1 6 1999-10-18 11:59:57sandervl Exp $ */1 /* $Id: dc.cpp,v 1.17 1999-10-22 18:11:43 sandervl Exp $ */ 2 2 3 3 /* … … 13 13 14 14 #include <odin.h> 15 #include <odinwrap.h>16 #include <os2sel.h>17 15 18 16 #define INCL_WIN … … 20 18 #define INCL_GREALL 21 19 #define INCL_DEV 22 #include <os2 .h>20 #include <os2wrap.h> 23 21 #include <pmddi.h> 24 22 #include <stdlib.h> 23 25 24 #include "win32type.h" 26 25 #include <winconst.h> 27 #include <wprocess.h>28 26 #include <misc.h> 29 27 #include <win32wbase.h> … … 33 31 #include "dcdata.h" 34 32 35 ODINDEBUGCHANNEL(USER32-DC) 33 #define INCLUDED_BY_DC 34 #include "dc.h" 36 35 37 36 #undef SEVERITY_ERROR 38 37 #include <winerror.h> 39 40 #ifndef OPEN32API41 #define OPEN32API _System42 #endif43 44 /*********************/45 typedef struct46 {47 HDC hdc;48 BOOL fErase;49 RECT rcPaint;50 BOOL fRestore;51 BOOL IncUpdate;52 BYTE rgbReserved[32];53 } PAINTSTRUCT_W, *PPAINTSTRUCT_W, *LPPAINTSTRUCT_W;54 55 #define PS_SOLID_W 0x0000000056 #define PS_DASH_W 0x0000000157 #define PS_DOT_W 0x0000000258 #define PS_DASHDOT_W 0x0000000359 #define PS_DASHDOTDOT_W 0x0000000460 #define PS_NULL_W 0x0000000561 #define PS_INSIDEFRAME_W 0x0000000662 #define PS_USERSTYLE_W 0x0000000763 #define PS_ALTERNATE_W 0x0000000864 #define PS_STYLE_MASK_W 0x0000000f65 66 typedef struct67 {68 UINT lopnStyle;69 POINT lopnWidth;70 ULONG lopnColor;71 } LOGPEN_W, *LPLOGPEN_W;72 73 typedef struct tagEXTLOGPEN74 {75 DWORD elpPenStyle;76 DWORD elpWidth;77 DWORD elpBrushStyle;78 DWORD elpColor;79 DWORD elpNumEntries;80 DWORD elpStyleEntry[1];81 } EXTLOGPEN_W, *PEXTLOGPEN_W, *NPEXTLOGPEN_W, *LPEXTLOGPEN_W;82 83 typedef struct84 {85 UINT lbStyle;86 ULONG lbColor;87 INT lbHatch;88 } LOGBRUSH_W, *LPLOGBRUSH_W;89 90 typedef struct _penobject91 {92 ULONG filler[9];93 union {94 struct {95 PEXTLOGPEN_W pExtLogPen;96 LOGBRUSH_W logbrush;97 LOGPEN_W logpen;98 } ExtPen;99 struct {100 LOGPEN_W logpen;101 } Pen;102 };103 } tPenObject, *pPenObject;104 105 /* DC Graphics Mode */106 #define GM_COMPATIBLE_W 1107 #define GM_ADVANCED_W 2108 109 #define DCX_WINDOW_W 0x00000001L110 #define DCX_CACHE_W 0x00000002L111 #define DCX_NORESETATTRS_W 0x00000004L112 #define DCX_CLIPCHILDREN_W 0x00000008L113 #define DCX_CLIPSIBLINGS_W 0x00000010L114 #define DCX_PARENTCLIP_W 0x00000020L115 #define DCX_EXCLUDERGN_W 0x00000040L116 #define DCX_INTERSECTRGN_W 0x00000080L117 #define DCX_EXCLUDEUPDATE_W 0x00000100L118 #define DCX_INTERSECTUPDATE_W 0x00000200L119 #define DCX_LOCKWINDOWUPDATE_W 0x00000400L120 #define DCX_VALIDATE_W 0x00200000L121 122 #define RDW_INVALIDATE_W 0x0001123 #define RDW_INTERNALPAINT_W 0x0002124 #define RDW_ERASE_W 0x0004125 #define RDW_VALIDATE_W 0x0008126 #define RDW_NOINTERNALPAINT_W 0x0010127 #define RDW_NOERASE_W 0x0020128 #define RDW_NOCHILDREN_W 0x0040129 #define RDW_ALLCHILDREN_W 0x0080130 #define RDW_UPDATENOW_W 0x0100131 #define RDW_ERASENOW_W 0x0200132 #define RDW_FRAME_W 0x0400133 #define RDW_NOFRAME_W 0x0800134 135 typedef struct _RGNDATAHEADER_W {136 DWORD dwSize;137 DWORD iType;138 DWORD nCount;139 DWORD nRgnSize;140 RECT rcBound;141 } RGNDATAHEADER_W, *LPRGNDATAHEADER_W;142 143 typedef struct _RGNDATA_W {144 RGNDATAHEADER_W rdh;145 char Buffer[1];146 } RGNDATA_W , *PRGNDATA_W , *LPRGNDATA_W ;147 148 149 /* Xform FLAGS */150 #define MWT_IDENTITY_W 1151 #define MWT_LEFTMULTIPLY_W 2152 #define MWT_RIGHTMULTIPLY_W 3153 154 /* Mapping Modes */155 #define MM_TEXT_W 1156 #define MM_LOMETRIC_W 2157 #define MM_HIMETRIC_W 3158 #define MM_LOENGLISH_W 4159 #define MM_HIENGLISH_W 5160 #define MM_TWIPS_W 6161 #define MM_ISOTROPIC_W 7162 #define MM_ANISOTROPIC_W 8163 164 #define RGN_OR_W 2165 166 /* Window scrolling */167 #define SW_SCROLLCHILDREN_W 0x0001168 #define SW_INVALIDATE_W 0x0002169 #define SW_ERASE_W 0x0004170 171 /*********************/172 173 BOOL APIENTRY GpiEnableYInversion (HPS hps, LONG lHeight);174 LONG APIENTRY GpiQueryYInversion (HPS hps);175 PVOID APIENTRY GpiAllocateDCData (HPS GpiH, ULONG size);176 PVOID APIENTRY GpiQueryDCData (HPS hps);177 HDC OPEN32API HPSToHDC (HWND hwnd, HPS hps, HDC hdc, PVOID);178 void OPEN32API DeleteHDC (HDC hdc);179 BOOL OPEN32API _O32_EndPaint (HWND hwnd, const PAINTSTRUCT_W *lpps);180 int OPEN32API _O32_GetUpdateRgn (HWND hwnd, HRGN hrgn, BOOL erase);181 ULONG OPEN32API _O32_GetRegionData (HRGN hrgn, ULONG count, PRGNDATA_W pData);182 BOOL OPEN32API _O32_DeleteObject (LHANDLE hgdiobj);183 int OPEN32API _O32_ReleaseDC (HWND hwnd, HDC hdc);184 VOID OPEN32API _O32_SetLastError( DWORD );185 BOOL OPEN32API _O32_SetRectRgn (HRGN dest, int left, int top, int right, int bottom);186 int OPEN32API _O32_CombineRgn (HRGN dest, HRGN src1, HRGN src2, int mode);187 HRGN OPEN32API _O32_CreateRectRgn (int left, int top, int right, int bottom);188 38 189 39 #ifndef DEVESC_SETPS … … 269 119 case MM_ISOTROPIC_W : flOptions = PU_LOMETRIC ; break; 270 120 default: 271 _O32_SetLastError (ERROR_INVALID_PARAMETER);121 O32_SetLastError (ERROR_INVALID_PARAMETER); 272 122 return FALSE; 273 123 } … … 294 144 if (DevEscape(pHps->hdc ? pHps->hdc : pHps->hps, DEVESC_SETPS, 12, (PBYTE)data, 0, 0) == DEVESC_ERROR) 295 145 { 296 _O32_SetLastError (ERROR_INVALID_PARAMETER);146 O32_SetLastError (ERROR_INVALID_PARAMETER); 297 147 return 0; 298 148 } … … 614 464 615 465 GpiSetBitmap (pHps->hps, NULL); 616 _O32_DeleteObject (pHps->nullBitmapHandle);466 O32_DeleteObject (pHps->nullBitmapHandle); 617 467 GpiDestroyPS(pHps->hps); 618 468 … … 636 486 if ( !lpps ) 637 487 { 638 _O32_SetLastError (ERROR_INVALID_PARAMETER);488 O32_SetLastError (ERROR_INVALID_PARAMETER); 639 489 return (HDC)NULLHANDLE; 640 490 } 641 491 642 USHORT sel = RestoreOS2FS();643 492 Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd); 644 493 … … 649 498 if (!pHps) 650 499 { 651 _O32_SetLastError (ERROR_INVALID_PARAMETER); 652 SetFS(sel); 500 O32_SetLastError (ERROR_INVALID_PARAMETER); 653 501 return (HDC)NULLHANDLE; 654 502 } … … 699 547 WINRECT_FROM_PMRECT(lpps->rcPaint, rect); 700 548 701 SetFS(sel); 702 _O32_SetLastError(0); 549 O32_SetLastError(0); 703 550 return (HDC)pHps->hps; 704 551 } … … 711 558 return TRUE; 712 559 713 USHORT sel = RestoreOS2FS();714 560 Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd); 715 561 … … 727 573 else 728 574 { 729 _O32_EndPaint (HWND_DESKTOP, pPaint);575 O32_EndPaint (HWND_DESKTOP, pPaint); 730 576 } 731 577 732 578 exit: 733 SetFS(sel); 734 _O32_SetLastError(0); 579 O32_SetLastError(0); 735 580 return TRUE; 736 581 } … … 740 585 if (hwnd) 741 586 { 742 _O32_SetLastError (ERROR_INVALID_HANDLE);587 O32_SetLastError (ERROR_INVALID_HANDLE); 743 588 return FALSE; 744 589 } 745 590 746 591 RECTL rectl; 747 USHORT sel = RestoreOS2FS();748 592 Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd); 749 593 750 594 BOOL updateRegionExists = WinQueryUpdateRect (hwnd, pRect ? &rectl : NULL); 751 595 if (!pRect) { 752 SetFS(sel);753 596 return (updateRegionExists); 754 597 } … … 762 605 if (!pHps) 763 606 { 764 _O32_SetLastError (ERROR_INVALID_HANDLE); 765 SetFS(sel); 607 O32_SetLastError (ERROR_INVALID_HANDLE); 766 608 return FALSE; 767 609 } … … 787 629 } 788 630 789 SetFS(sel);790 631 return updateRegionExists; 791 632 } … … 793 634 int WIN32API GetUpdateRgn (HWND hwnd, HRGN hrgn, BOOL erase) 794 635 { 795 USHORT sel = RestoreOS2FS();796 636 LONG Complexity; 797 637 798 Complexity = _O32_GetUpdateRgn (hwnd, hrgn, FALSE);638 Complexity = O32_GetUpdateRgn (hwnd, hrgn, FALSE); 799 639 if (erase && (Complexity > NULLREGION_W)) { 800 640 Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd); … … 802 642 } 803 643 804 SetFS(sel);805 644 return Complexity; 806 645 } … … 814 653 HDC WIN32API GetDCEx (HWND hwnd, HRGN hrgn, ULONG flags) 815 654 { 816 USHORT sel = RestoreOS2FS();817 655 Win32BaseWindow *wnd = NULL; 818 656 HWND hWindow; … … 836 674 hWindow = HWND_DESKTOP; 837 675 838 dprintf (("User32: GetDCEx hwnd %x (%x %x) -> wnd %x", hwnd, hrgn, flags, wnd));676 dprintf (("User32: GetDCEx hwnd %x (%x %x) -> wnd %x", hwnd, hrgn, flags, wnd)); 839 677 840 678 isWindowOwnDC = (((hWindow == HWND_DESKTOP) ? FALSE : wnd->isOwnDC()) 841 679 && !(flags & DCX_CACHE_W)); 680 842 681 if (isWindowOwnDC) 843 682 { … … 857 696 858 697 pHps->hdcType = TYPE_1; 859 SetFS(sel);860 698 return (HDC)hps; 861 699 } … … 904 742 goto error; 905 743 906 BytesNeeded = _O32_GetRegionData (hrgn, 0, NULL);744 BytesNeeded = O32_GetRegionData (hrgn, 0, NULL); 907 745 RgnData = (PRGNDATA_W)_alloca (BytesNeeded); 908 746 if (RgnData == NULL) 909 747 goto error; 910 _O32_GetRegionData (hrgn, BytesNeeded, RgnData);748 O32_GetRegionData (hrgn, BytesNeeded, RgnData); 911 749 912 750 i = RgnData->rdh.nCount; … … 941 779 GpiSetDrawControl (hps, DCTL_DISPLAY, drawingAllowed ? DCTL_ON : DCTL_OFF); 942 780 943 SetFS(sel);944 781 return (HDC)pHps->hps; 945 782 … … 960 797 if (pHps->hrgnHDC) GpiDestroyRegion(pHps->hps, pHps->hrgnHDC); 961 798 962 _O32_DeleteObject (pHps->nullBitmapHandle); 963 } 964 _O32_SetLastError (ERROR_INVALID_PARAMETER); 965 SetFS(sel); 799 O32_DeleteObject (pHps->nullBitmapHandle); 800 } 801 O32_SetLastError (ERROR_INVALID_PARAMETER); 966 802 return NULL; 967 803 } … … 979 815 int WIN32API ReleaseDC (HWND hwnd, HDC hdc) 980 816 { 981 USHORT sel = RestoreOS2FS();982 817 BOOL isOwnDC = FALSE; 983 818 int rc; … … 991 826 rc = TRUE; 992 827 else 993 rc = _O32_ReleaseDC (0, hdc); 994 995 SetFS(sel); 828 rc = O32_ReleaseDC (0, hdc); 829 996 830 dprintf(("ReleaseDC %x %x", hwnd, hdc)); 997 831 return (rc); … … 1003 837 return FALSE; 1004 838 1005 USHORT sel = RestoreOS2FS();1006 839 Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle (hwnd); 1007 840 … … 1017 850 #endif 1018 851 1019 SetFS(sel);1020 852 return (TRUE); 1021 853 } … … 1031 863 // RDW_UPDATENOW 1032 864 1033 ODINFUNCTION4(BOOL,RedrawWindow,HWND, hwnd, 1034 const RECT*, pRect, 1035 HRGN, hrgn, 1036 DWORD, redraw) 865 BOOL WIN32API RedrawWindow(HWND hwnd, const RECT* pRect, HRGN hrgn, DWORD redraw) 1037 866 { 1038 867 Win32BaseWindow *wnd; … … 1040 869 if (redraw & (RDW_FRAME_W | RDW_NOFRAME_W)) 1041 870 { 1042 _O32_SetLastError (ERROR_NOT_SUPPORTED);871 O32_SetLastError (ERROR_NOT_SUPPORTED); 1043 872 return FALSE; 1044 873 } 1045 1046 //@@@PH USHORT sel = RestoreOS2FS();1047 //@@@PH dprintf(("USER32: RedrawWindow %X, %X %X %X", hwnd, pRect, hrgn, redraw));1048 874 1049 875 if (hwnd == NULLHANDLE) … … 1056 882 dprintf(("USER32:dc: RedrawWindow can't find desktop window %08xh\n", 1057 883 hwnd)); 1058 _O32_SetLastError (ERROR_INVALID_PARAMETER); 1059 //@@@PH SetFS(sel); 884 O32_SetLastError (ERROR_INVALID_PARAMETER); 1060 885 return FALSE; 1061 886 } … … 1070 895 dprintf(("USER32:dc: RedrawWindow can't find window %08xh\n", 1071 896 hwnd)); 1072 _O32_SetLastError (ERROR_INVALID_PARAMETER); 1073 //@@@PH SetFS(sel); 897 O32_SetLastError (ERROR_INVALID_PARAMETER); 1074 898 return FALSE; 1075 899 } … … 1124 948 goto error; 1125 949 1126 BytesNeeded = _O32_GetRegionData (hrgn, 0, NULL);950 BytesNeeded = O32_GetRegionData (hrgn, 0, NULL); 1127 951 RgnData = (PRGNDATA_W)_alloca (BytesNeeded); 1128 952 if (RgnData == NULL) 1129 953 goto error; 1130 _O32_GetRegionData (hrgn, BytesNeeded, RgnData);954 O32_GetRegionData (hrgn, BytesNeeded, RgnData); 1131 955 1132 956 pr = (PRECTL)(RgnData->Buffer); … … 1207 1031 1208 1032 if (!success) 1209 _O32_SetLastError (ERROR_INVALID_PARAMETER); 1210 1211 //@@@PH SetFS(sel); 1033 O32_SetLastError (ERROR_INVALID_PARAMETER); 1034 1212 1035 return (success); 1213 1036 } … … 1215 1038 BOOL WIN32API InvalidateRect (HWND hwnd, const RECT *pRect, BOOL erase) 1216 1039 { 1217 USHORT sel = RestoreOS2FS();1218 1040 // Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle (hwnd); 1219 1041 BOOL result; … … 1227 1049 (erase ? RDW_ERASE_W : 0) | 1228 1050 (hwnd == NULLHANDLE ? RDW_UPDATENOW_W : 0)); 1229 SetFS(sel);1230 1051 return (result); 1231 1052 } … … 1233 1054 BOOL WIN32API InvalidateRgn (HWND hwnd, HRGN hrgn, BOOL erase) 1234 1055 { 1235 USHORT sel = RestoreOS2FS();1236 1056 // Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle (hwnd); 1237 1057 BOOL result; … … 1245 1065 (erase ? RDW_ERASE_W : 0) | 1246 1066 (hwnd == NULLHANDLE ? RDW_UPDATENOW_W : 0)); 1247 SetFS(sel);1248 1067 return (result); 1249 1068 } … … 1270 1089 rc = GpiQueryRegionRects (hps, hrgnPM, NULL, &rgnRect, Rcls); 1271 1090 1272 rc = _O32_SetRectRgn (hrgnWin, pRcl->xLeft,1091 rc = O32_SetRectRgn (hrgnWin, pRcl->xLeft, 1273 1092 pRcl->xRight, 1274 1093 height - pRcl->yTop, … … 1279 1098 int i; 1280 1099 HRGN temp; 1281 temp = _O32_CreateRectRgn (0, 0, 1, 1);1100 temp = O32_CreateRectRgn (0, 0, 1, 1); 1282 1101 1283 1102 for (i = 1, pRcl++; rc && (i < rgnRect.crcReturned); i++, pRcl++) 1284 1103 { 1285 rc = _O32_SetRectRgn (temp, pRcl->xLeft,1104 rc = O32_SetRectRgn (temp, pRcl->xLeft, 1286 1105 pRcl->xRight, 1287 1106 height - pRcl->yTop, 1288 1107 height - pRcl->yBottom); 1289 rc &= _O32_CombineRgn (hrgnWin, hrgnWin, temp, RGN_OR_W);1108 rc &= O32_CombineRgn (hrgnWin, hrgnWin, temp, RGN_OR_W); 1290 1109 } 1291 _O32_DeleteObject (temp);1110 O32_DeleteObject (temp); 1292 1111 } 1293 1112 delete[] Rcls; … … 1300 1119 else 1301 1120 { 1302 rc = _O32_SetRectRgn (hrgnWin, 0, 0, 0, 0);1121 rc = O32_SetRectRgn (hrgnWin, 0, 0, 0, 0); 1303 1122 } 1304 1123 … … 1310 1129 const RECT *pClip, HRGN hrgnUpdate, LPRECT pRectUpdate) 1311 1130 { 1312 USHORT sel = RestoreOS2FS();1313 1131 BOOL rc = TRUE; 1314 1132 … … 1317 1135 if (!hDC) 1318 1136 { 1319 SetFS(sel);1320 1137 return (FALSE); 1321 1138 } … … 1327 1144 if ((hwnd == NULLHANDLE) || !wnd) 1328 1145 { 1329 SetFS(sel);1330 1146 return (FALSE); 1331 1147 } … … 1413 1229 if (lComplexity == RGN_ERROR) 1414 1230 { 1415 SetFS(sel);1416 1231 return (FALSE); 1417 1232 } … … 1431 1246 rc = setPMRgnIntoWinRgn (hrgn, hrgnUpdate, height); 1432 1247 1433 SetFS(sel);1434 1248 return (rc); 1435 1249 } … … 1439 1253 BOOL WIN32API ScrollWindow(HWND hwnd, int dx, int dy, const RECT *pScroll, const RECT *pClip) 1440 1254 { 1441 USHORT sel = RestoreOS2FS();1442 1255 Win32BaseWindow *window; 1443 1256 APIRET rc; … … 1452 1265 if(!window) { 1453 1266 dprintf(("ScrollWindow, window %x not found", hwnd)); 1454 SetFS(sel);1455 1267 return 0; 1456 1268 } … … 1497 1309 NULL, scrollFlags); 1498 1310 1499 SetFS(sel);1500 1311 return (rc != RGN_ERROR); 1501 1312 } … … 1505 1316 HRGN hrgnUpdate, PRECT pRectUpdate, UINT scrollFlag) 1506 1317 { 1507 USHORT sel = RestoreOS2FS();1508 1318 Win32BaseWindow *window; 1509 1319 APIRET rc; … … 1516 1326 if(!window) { 1517 1327 dprintf(("ScrollWindowEx, window %x not found", hwnd)); 1518 SetFS(sel);1519 1328 return 0; 1520 1329 } … … 1539 1348 if (lComplexity == RGN_ERROR) 1540 1349 { 1541 SetFS(sel);1542 1350 return (0); 1543 1351 } … … 1563 1371 if (rc == FALSE) 1564 1372 { 1565 SetFS(sel);1566 1373 return (0); 1567 1374 } … … 1584 1391 } 1585 1392 1586 SetFS(sel);1587 1393 return (regionType); 1588 1394 }
Note:
See TracChangeset
for help on using the changeset viewer.