| 1 | /* $Id: region.cpp,v 1.35 2003-11-14 17:31:47 sandervl Exp $ */
|
|---|
| 2 |
|
|---|
| 3 | /*
|
|---|
| 4 | * GDI32 region code
|
|---|
| 5 | *
|
|---|
| 6 | * Copyright 1998-2000 Sander van Leeuwen (sandervl@xs4all.nl)
|
|---|
| 7 | * Copyright 1998 Patrick Haller
|
|---|
| 8 | * Copyright 2002-2003 Innotek Systemberatung GmbH (sandervl@innotek.de)
|
|---|
| 9 | *
|
|---|
| 10 | * TODO: Metafile recording
|
|---|
| 11 | * TODO: Do we need to translate & set the last error for Gpi operations?
|
|---|
| 12 | *
|
|---|
| 13 | *
|
|---|
| 14 | * NOTE: In windows there is a clip and a visible region (just like in PM)
|
|---|
| 15 | * We do not map the Win32 visible region to the PM visible region
|
|---|
| 16 | * as that's rather annoying.
|
|---|
| 17 | * Instead we use the intersection of the win32 visible and win32 clip
|
|---|
| 18 | * region for the PM clip region.
|
|---|
| 19 | * The original Win32 clip region is saved in pHps->hrgnWin32Clip.
|
|---|
| 20 | * The Win32 visible region is saved in pHps->hrgnWinVis.
|
|---|
| 21 | *
|
|---|
| 22 | *
|
|---|
| 23 | *
|
|---|
| 24 | * Project Odin Software License can be found in LICENSE.TXT
|
|---|
| 25 | *
|
|---|
| 26 | */
|
|---|
| 27 |
|
|---|
| 28 | #define INCL_GPI
|
|---|
| 29 | #define INCL_WIN
|
|---|
| 30 | #include <os2wrap.h> //need odin wrappers
|
|---|
| 31 |
|
|---|
| 32 | #include <win32type.h>
|
|---|
| 33 | #include <win32api.h>
|
|---|
| 34 | #include <winconst.h>
|
|---|
| 35 | #include <stdlib.h>
|
|---|
| 36 | #include <stdarg.h>
|
|---|
| 37 | #include <string.h>
|
|---|
| 38 | #include <misc.h>
|
|---|
| 39 | #include <objhandle.h>
|
|---|
| 40 | #include <dcdata.h>
|
|---|
| 41 | #include <winuser32.h>
|
|---|
| 42 | #include "oslibgpi.h"
|
|---|
| 43 | #include <stats.h>
|
|---|
| 44 | #include "dibsect.h"
|
|---|
| 45 | #include <wingdi32.h>
|
|---|
| 46 |
|
|---|
| 47 | #define DBG_LOCALLOG DBG_region
|
|---|
| 48 | #include "dbglocal.h"
|
|---|
| 49 |
|
|---|
| 50 | //GPI and Windows use the same values
|
|---|
| 51 | #define GPI_TO_WIN_COMPLEXITY(a) a
|
|---|
| 52 |
|
|---|
| 53 | typedef enum
|
|---|
| 54 | {
|
|---|
| 55 | AS_DEVICE,
|
|---|
| 56 | AS_WORLD
|
|---|
| 57 | } InterpMode;
|
|---|
| 58 |
|
|---|
| 59 | #define MEM_HPS_MAX 768
|
|---|
| 60 |
|
|---|
| 61 | int WIN32API OffsetRgn( HRGN hrgn, int xOffset, int yOffset);
|
|---|
| 62 |
|
|---|
| 63 | static void convertDeviceRect(HWND hwnd, pDCData pHps, PRECTL pRectl, ULONG count);
|
|---|
| 64 |
|
|---|
| 65 | #define convertWinDeviceRectToPMDeviceRect(arg1, arg2, arg3) convertDeviceRect(arg1, arg2, arg3)
|
|---|
| 66 | #define convertPMDeviceRectToWinDeviceRect(arg1, arg2, arg3) convertDeviceRect(arg1, arg2, arg3)
|
|---|
| 67 |
|
|---|
| 68 | inline void convertDeviceRect(pDCData pHps, PRECTL pRectl, ULONG count)
|
|---|
| 69 | {
|
|---|
| 70 | convertDeviceRect(0, pHps, pRectl, count);
|
|---|
| 71 | }
|
|---|
| 72 | inline void convertDeviceRect(HWND hwnd, PRECTL pRectl, ULONG count)
|
|---|
| 73 | {
|
|---|
| 74 | convertDeviceRect(hwnd, 0, pRectl, count);
|
|---|
| 75 | }
|
|---|
| 76 |
|
|---|
| 77 | HPS hpsRegion = 0;
|
|---|
| 78 |
|
|---|
| 79 |
|
|---|
| 80 | #ifdef DEBUG
|
|---|
| 81 | //#define dprintfRegion(a,b,c) if(DbgEnabledLvl2GDI32[DBG_LOCALLOG] == 1) dprintfRegion1(a,b,c)
|
|---|
| 82 | //#define dprintfRegion(a,b,c) dprintfRegion1(a,b,c)
|
|---|
| 83 |
|
|---|
| 84 | void dprintfRegion(HPS hps, HRGN hrgnClip)
|
|---|
| 85 | {
|
|---|
| 86 | RGNRECT rgnRect = {0, 16, 0, RECTDIR_LFRT_TOPBOT};
|
|---|
| 87 | RECTL rectRegion[16];
|
|---|
| 88 | APIRET rc;
|
|---|
| 89 |
|
|---|
| 90 | dprintf(("dprintfRegion %x", hps));
|
|---|
| 91 | rc = GpiQueryRegionRects(hps, hrgnClip, NULL, &rgnRect, &rectRegion[0]);
|
|---|
| 92 | for(int i=0;i<rgnRect.crcReturned;i++) {
|
|---|
| 93 | dprintf(("(%d,%d)(%d,%d)", rectRegion[i].xLeft, rectRegion[i].yBottom, rectRegion[i].xRight, rectRegion[i].yTop));
|
|---|
| 94 | }
|
|---|
| 95 | }
|
|---|
| 96 | #else
|
|---|
| 97 | #define dprintfRegion(a,c)
|
|---|
| 98 | #endif
|
|---|
| 99 |
|
|---|
| 100 | //******************************************************************************
|
|---|
| 101 | //******************************************************************************
|
|---|
| 102 | BOOL InitRegionSpace()
|
|---|
| 103 | {
|
|---|
| 104 | hpsRegion = WinGetScreenPS(HWND_DESKTOP);
|
|---|
| 105 | return hpsRegion != 0;
|
|---|
| 106 | }
|
|---|
| 107 | //******************************************************************************
|
|---|
| 108 | //******************************************************************************
|
|---|
| 109 | void DestroyRegionSpace()
|
|---|
| 110 | {
|
|---|
| 111 | if(hpsRegion) WinReleasePS(hpsRegion);
|
|---|
| 112 | hpsRegion = 0;
|
|---|
| 113 | }
|
|---|
| 114 | //******************************************************************************
|
|---|
| 115 | //******************************************************************************
|
|---|
| 116 | LONG hdcHeight(HWND hwnd, pDCData pHps)
|
|---|
| 117 | {
|
|---|
| 118 | if(hwnd == 0 && pHps != 0)
|
|---|
| 119 | hwnd = pHps->hwnd;
|
|---|
| 120 |
|
|---|
| 121 | if(hwnd != 0 || pHps == 0)
|
|---|
| 122 | {
|
|---|
| 123 | RECT rect;
|
|---|
| 124 | RECTL rectl;
|
|---|
| 125 | LONG y = 0;
|
|---|
| 126 |
|
|---|
| 127 | if(pHps && pHps->isClient) //client area
|
|---|
| 128 | {
|
|---|
| 129 | if(GetClientRect(OS2ToWin32Handle(hwnd), &rect) == TRUE) {
|
|---|
| 130 | y = rect.bottom - rect.top;
|
|---|
| 131 | }
|
|---|
| 132 | }
|
|---|
| 133 | else
|
|---|
| 134 | if(WinQueryWindowRect(hwnd, &rectl)) //whole window
|
|---|
| 135 | y = rectl.yTop;
|
|---|
| 136 |
|
|---|
| 137 | return y;
|
|---|
| 138 | }
|
|---|
| 139 | else
|
|---|
| 140 | if(pHps->bitmapHandle)
|
|---|
| 141 | {
|
|---|
| 142 | return pHps->bitmapHeight;
|
|---|
| 143 | }
|
|---|
| 144 | else
|
|---|
| 145 | if(pHps->isMetaPS)
|
|---|
| 146 | {
|
|---|
| 147 | return 0;
|
|---|
| 148 | }
|
|---|
| 149 | else
|
|---|
| 150 | if(pHps->isPrinter)
|
|---|
| 151 | {
|
|---|
| 152 | return GetDeviceCaps(pHps->hps, VERTRES_W);
|
|---|
| 153 | }
|
|---|
| 154 | else
|
|---|
| 155 | {
|
|---|
| 156 | return MEM_HPS_MAX;
|
|---|
| 157 | }
|
|---|
| 158 | }
|
|---|
| 159 | //******************************************************************************
|
|---|
| 160 | //******************************************************************************
|
|---|
| 161 | LONG hdcWidth(HWND hwnd, pDCData pHps)
|
|---|
| 162 | {
|
|---|
| 163 | if(hwnd == 0 && pHps != 0)
|
|---|
| 164 | hwnd = pHps->hwnd;
|
|---|
| 165 |
|
|---|
| 166 | if(hwnd != 0 || pHps == 0)
|
|---|
| 167 | {
|
|---|
| 168 | RECT rect;
|
|---|
| 169 | RECTL rectl;
|
|---|
| 170 | LONG x = 0;
|
|---|
| 171 |
|
|---|
| 172 | if(pHps && pHps->isClient) //client area
|
|---|
| 173 | {
|
|---|
| 174 | if(GetClientRect(OS2ToWin32Handle(hwnd), &rect) == TRUE) {
|
|---|
| 175 | x = rect.right - rect.left;
|
|---|
| 176 | }
|
|---|
| 177 | }
|
|---|
| 178 | else
|
|---|
| 179 | if(WinQueryWindowRect(hwnd, &rectl)) //whole window
|
|---|
| 180 | x = rectl.xRight;
|
|---|
| 181 |
|
|---|
| 182 | return x;
|
|---|
| 183 | }
|
|---|
| 184 | else
|
|---|
| 185 | if(pHps->bitmapHandle)
|
|---|
| 186 | {
|
|---|
| 187 | return pHps->bitmapWidth;
|
|---|
| 188 | }
|
|---|
| 189 | else
|
|---|
| 190 | if(pHps->isMetaPS)
|
|---|
| 191 | {
|
|---|
| 192 | return 0;
|
|---|
| 193 | }
|
|---|
| 194 | else
|
|---|
| 195 | if(pHps->isPrinter)
|
|---|
| 196 | {
|
|---|
| 197 | return GetDeviceCaps(pHps->hps, HORZRES_W);
|
|---|
| 198 | }
|
|---|
| 199 | // else
|
|---|
| 200 | // DebugInt3();
|
|---|
| 201 | return 0;
|
|---|
| 202 | }
|
|---|
| 203 | //******************************************************************************
|
|---|
| 204 | //******************************************************************************
|
|---|
| 205 | static void convertWinWorldRectToPMDeviceRect(pDCData pHps_Hdc, PRECTL pRects, UINT count = 1)
|
|---|
| 206 | {
|
|---|
| 207 | PRECTL pRectl;
|
|---|
| 208 | for (int x=0; x < count; x++)
|
|---|
| 209 | {
|
|---|
| 210 | pRectl = &pRects[x];
|
|---|
| 211 |
|
|---|
| 212 | if(pRectl->yTop < pRectl->yBottom) {
|
|---|
| 213 | ULONG temp = pRectl->yBottom;
|
|---|
| 214 | pRectl->yBottom = pRectl->yTop;
|
|---|
| 215 | pRectl->yTop = temp;
|
|---|
| 216 | }
|
|---|
| 217 | BOOL success = GpiConvert( pHps_Hdc->hps, CVTC_WORLD, CVTC_DEVICE, 2, (PPOINTL)pRectl);
|
|---|
| 218 | if(!success)
|
|---|
| 219 | {
|
|---|
| 220 | break;
|
|---|
| 221 | }
|
|---|
| 222 | if(pRectl->yTop < pRectl->yBottom) {
|
|---|
| 223 | ULONG temp = pRectl->yBottom;
|
|---|
| 224 | pRectl->yBottom = pRectl->yTop;
|
|---|
| 225 | pRectl->yTop = temp;
|
|---|
| 226 | }
|
|---|
| 227 | }
|
|---|
| 228 | }
|
|---|
| 229 | //******************************************************************************
|
|---|
| 230 | //******************************************************************************
|
|---|
| 231 | static void convertDeviceRect(HWND hwnd, pDCData pHps, PRECTL pRectl, ULONG count)
|
|---|
| 232 | {
|
|---|
| 233 | long wHeight, wWidth;
|
|---|
| 234 |
|
|---|
| 235 | if(hwnd == HWND_DESKTOP) {
|
|---|
| 236 | wHeight = OSLibGetScreenHeight();
|
|---|
| 237 | wWidth = OSLibGetScreenWidth();
|
|---|
| 238 | }
|
|---|
| 239 | else {
|
|---|
| 240 | wHeight = hdcHeight(hwnd, pHps);
|
|---|
| 241 | wWidth = hdcWidth(hwnd, pHps);
|
|---|
| 242 | }
|
|---|
| 243 |
|
|---|
| 244 | if(pHps)
|
|---|
| 245 | {
|
|---|
| 246 | wHeight += pHps->HPStoHDCInversionHeight;
|
|---|
| 247 | }
|
|---|
| 248 |
|
|---|
| 249 | if(hwnd || (pHps && pHps->hwnd)) {
|
|---|
| 250 | for(int x=0; x < count; x++)
|
|---|
| 251 | {
|
|---|
| 252 | if(pRectl[x].xRight > wWidth) {
|
|---|
| 253 | pRectl[x].xRight = wWidth;
|
|---|
| 254 | }
|
|---|
| 255 | if(pRectl[x].yTop > wHeight) {
|
|---|
| 256 | pRectl[x].yTop = 0;
|
|---|
| 257 | }
|
|---|
| 258 | else pRectl[x].yTop = wHeight - pRectl[x].yTop;
|
|---|
| 259 |
|
|---|
| 260 | pRectl[x].yBottom = wHeight - pRectl[x].yBottom;
|
|---|
| 261 | }
|
|---|
| 262 | }
|
|---|
| 263 | else {
|
|---|
| 264 | for(int x=0; x < count; x++)
|
|---|
| 265 | {
|
|---|
| 266 | pRectl[x].yTop = wHeight - pRectl[x].yTop;
|
|---|
| 267 | pRectl[x].yBottom = wHeight - pRectl[x].yBottom;
|
|---|
| 268 | }
|
|---|
| 269 | }
|
|---|
| 270 | }
|
|---|
| 271 | //******************************************************************************
|
|---|
| 272 | //******************************************************************************
|
|---|
| 273 | static void convertPMDeviceRectToWinWorldRect(pDCData pHps_Hdc, PRECTL pRectl)
|
|---|
| 274 | {
|
|---|
| 275 | GpiConvert(pHps_Hdc->hps, CVTC_DEVICE, CVTC_WORLD, 2, (PPOINTL)pRectl );
|
|---|
| 276 | }
|
|---|
| 277 | //******************************************************************************
|
|---|
| 278 | //******************************************************************************
|
|---|
| 279 | BOOL interpretRegionAs(pDCData pHps, HRGN hrgnDest, HRGN hrgnSrc, InterpMode mode)
|
|---|
| 280 | {
|
|---|
| 281 | BOOL success = FALSE;
|
|---|
| 282 | int x, i;
|
|---|
| 283 | HPS hpsDest;
|
|---|
| 284 |
|
|---|
| 285 | if(pHps)
|
|---|
| 286 | {
|
|---|
| 287 | if(!hrgnDest) {
|
|---|
| 288 | hrgnDest = pHps->hrgnHDC;
|
|---|
| 289 | #ifdef DEBUG
|
|---|
| 290 | if(hrgnDest == 0) {
|
|---|
| 291 | DebugInt3();
|
|---|
| 292 | }
|
|---|
| 293 | #endif
|
|---|
| 294 | }
|
|---|
| 295 | hpsDest = pHps->hps;
|
|---|
| 296 | }
|
|---|
| 297 | else {
|
|---|
| 298 | DebugInt3();
|
|---|
| 299 | return FALSE;
|
|---|
| 300 | }
|
|---|
| 301 |
|
|---|
| 302 | RGNRECT rgnRect;
|
|---|
| 303 | rgnRect.ircStart = 1;
|
|---|
| 304 | rgnRect.crc = 0;
|
|---|
| 305 | rgnRect.ulDirection = RECTDIR_LFRT_TOPBOT;
|
|---|
| 306 | success = GpiQueryRegionRects(hpsRegion, hrgnSrc, NULL, &rgnRect, NULL);
|
|---|
| 307 | if(success)
|
|---|
| 308 | {
|
|---|
| 309 | if(rgnRect.crcReturned > 0)
|
|---|
| 310 | {
|
|---|
| 311 | rgnRect.crc = rgnRect.crcReturned;
|
|---|
| 312 | PRECTL pRectl = new RECTL[rgnRect.crcReturned];
|
|---|
| 313 | success = GpiQueryRegionRects(hpsRegion, hrgnSrc, NULL, &rgnRect, pRectl);
|
|---|
| 314 | if(success)
|
|---|
| 315 | {
|
|---|
| 316 | if(mode == AS_DEVICE)
|
|---|
| 317 | {
|
|---|
| 318 | ULONG temp;
|
|---|
| 319 | for(x=0; x < rgnRect.crcReturned; x++)
|
|---|
| 320 | {
|
|---|
| 321 | temp = pRectl[x].yBottom;
|
|---|
| 322 | pRectl[x].yBottom = pRectl[x].yTop;
|
|---|
| 323 | pRectl[x].yTop = temp;
|
|---|
| 324 | }
|
|---|
| 325 | convertWinDeviceRectToPMDeviceRect(pHps, pRectl, rgnRect.crcReturned);
|
|---|
| 326 | }
|
|---|
| 327 | else
|
|---|
| 328 | {
|
|---|
| 329 | GpiConvert(pHps->hps, CVTC_WORLD, CVTC_DEVICE, rgnRect.crcReturned<<1, (PPOINTL)pRectl);
|
|---|
| 330 |
|
|---|
| 331 | ULONG temp;
|
|---|
| 332 | for(i=0; i < rgnRect.crcReturned; i++)
|
|---|
| 333 | {
|
|---|
| 334 | if(pRectl[i].yTop < pRectl[i].yBottom)
|
|---|
| 335 | {
|
|---|
| 336 | temp = pRectl[i].yBottom + 1;
|
|---|
| 337 | pRectl[i].yBottom = pRectl[i].yTop + 1;
|
|---|
| 338 | pRectl[i].yTop = temp;
|
|---|
| 339 | }
|
|---|
| 340 | else
|
|---|
| 341 | {
|
|---|
| 342 | pRectl[i].yTop++;
|
|---|
| 343 | pRectl[i].yBottom++;
|
|---|
| 344 | }
|
|---|
| 345 | }
|
|---|
| 346 | }
|
|---|
| 347 | success = GpiSetRegion(hpsDest, hrgnDest, rgnRect.crcReturned, pRectl);
|
|---|
| 348 | }
|
|---|
| 349 | delete[] pRectl;
|
|---|
| 350 | }
|
|---|
| 351 | else
|
|---|
| 352 | {
|
|---|
| 353 | success = GpiSetRegion(hpsDest, hrgnDest, 0, NULL);
|
|---|
| 354 | }
|
|---|
| 355 | }
|
|---|
| 356 | return success;
|
|---|
| 357 | }
|
|---|
| 358 | //******************************************************************************
|
|---|
| 359 | //exported (used by user32)
|
|---|
| 360 | //******************************************************************************
|
|---|
| 361 | BOOL WIN32API setWinDeviceRegionFromPMDeviceRegion(HRGN winHrgn, HRGN pmHrgn, pDCData pHpsPmHrgn, HWND hwndPmHrgn)
|
|---|
| 362 | {
|
|---|
| 363 | BOOL success;
|
|---|
| 364 | int x;
|
|---|
| 365 | BOOL mustReleaseScreenPS = FALSE;
|
|---|
| 366 | HPS hps;
|
|---|
| 367 |
|
|---|
| 368 | if(pHpsPmHrgn || hwndPmHrgn)
|
|---|
| 369 | {
|
|---|
| 370 | if(pHpsPmHrgn)
|
|---|
| 371 | hps = pHpsPmHrgn->hps;
|
|---|
| 372 | else
|
|---|
| 373 | {
|
|---|
| 374 | hps = WinGetScreenPS(HWND_DESKTOP);
|
|---|
| 375 | mustReleaseScreenPS = TRUE;
|
|---|
| 376 | }
|
|---|
| 377 |
|
|---|
| 378 | RGNRECT rgnRect;
|
|---|
| 379 | rgnRect.ircStart = 1;
|
|---|
| 380 | rgnRect.crc = 0;
|
|---|
| 381 | rgnRect.ulDirection = RECTDIR_LFRT_TOPBOT;
|
|---|
| 382 | success = GpiQueryRegionRects(hps, pmHrgn, NULL, &rgnRect, NULL);
|
|---|
| 383 | if(success )
|
|---|
| 384 | {
|
|---|
| 385 | if(rgnRect.crcReturned > 0)
|
|---|
| 386 | {
|
|---|
| 387 | rgnRect.crc = rgnRect.crcReturned;
|
|---|
| 388 | PRECTL pRectl = new RECTL[rgnRect.crcReturned];
|
|---|
| 389 | success = GpiQueryRegionRects(hps, pmHrgn, NULL, &rgnRect, pRectl);
|
|---|
| 390 | if(success)
|
|---|
| 391 | {
|
|---|
| 392 | if(pHpsPmHrgn)
|
|---|
| 393 | convertPMDeviceRectToWinDeviceRect(pHpsPmHrgn, pRectl, rgnRect.crcReturned);
|
|---|
| 394 | else
|
|---|
| 395 | convertPMDeviceRectToWinDeviceRect(hwndPmHrgn, pRectl, rgnRect.crcReturned);
|
|---|
| 396 |
|
|---|
| 397 | for(x=0; x < rgnRect.crcReturned; x++)
|
|---|
| 398 | {
|
|---|
| 399 | ULONG temp = pRectl[x].yBottom;
|
|---|
| 400 | pRectl[x].yBottom = pRectl[x].yTop;
|
|---|
| 401 | pRectl[x].yTop = temp;
|
|---|
| 402 | }
|
|---|
| 403 |
|
|---|
| 404 | success = GpiSetRegion(hpsRegion, winHrgn, rgnRect.crcReturned, pRectl);
|
|---|
| 405 | }
|
|---|
| 406 | delete[] pRectl;
|
|---|
| 407 | }
|
|---|
| 408 | else
|
|---|
| 409 | {
|
|---|
| 410 | success = GpiSetRegion(hpsRegion, winHrgn, 0, NULL);
|
|---|
| 411 | }
|
|---|
| 412 | }
|
|---|
| 413 | }
|
|---|
| 414 | else
|
|---|
| 415 | success = FALSE;
|
|---|
| 416 |
|
|---|
| 417 | if(mustReleaseScreenPS)
|
|---|
| 418 | WinReleasePS(hps);
|
|---|
| 419 |
|
|---|
| 420 | return success;
|
|---|
| 421 | }
|
|---|
| 422 | //******************************************************************************
|
|---|
| 423 | // GdiSetVisRgn
|
|---|
| 424 | //
|
|---|
| 425 | // Change the Win32 visible region to the specified region
|
|---|
| 426 | //
|
|---|
| 427 | // Parameters:
|
|---|
| 428 | //
|
|---|
| 429 | // pDCData pHps - presentation space structure
|
|---|
| 430 | // HRGN hrgn - region handle (GPI)
|
|---|
| 431 | //
|
|---|
| 432 | //
|
|---|
| 433 | // Returns: - ERROR_W -> failure
|
|---|
| 434 | // - NULLREGION_W -> empty region
|
|---|
| 435 | // - SIMPLEREGION_W -> rectangular region
|
|---|
| 436 | // - COMPLEXREGION_W -> complex region
|
|---|
| 437 | //
|
|---|
| 438 | // NOTE: In windows there is a clip and a visible region (just like in PM)
|
|---|
| 439 | // We do not map the Win32 visible region to the PM visible region
|
|---|
| 440 | // as that's rather annoying.
|
|---|
| 441 | // Instead we use the intersection of the win32 visible and win32 clip
|
|---|
| 442 | // region for the PM clip region.
|
|---|
| 443 | // The Win32 clip region is saved in pHps->hrgnWin32Clip.
|
|---|
| 444 | // The Win32 visible region is saved in pHps->hrgnWinVis.
|
|---|
| 445 | //
|
|---|
| 446 | //******************************************************************************
|
|---|
| 447 | INT WIN32API GdiSetVisRgn(pDCData pHps, HRGN hrgn)
|
|---|
| 448 | {
|
|---|
| 449 | HRGN hrgnNewClip = NULLHANDLE, hrgnOldClip = NULLHANDLE;
|
|---|
| 450 | LONG lComplexity = RGN_NULL;
|
|---|
| 451 | RECTL rectl = {0, 0, 1, 1};
|
|---|
| 452 |
|
|---|
| 453 | if(pHps == NULL) {
|
|---|
| 454 | DebugInt3();
|
|---|
| 455 | return ERROR_W;
|
|---|
| 456 | }
|
|---|
| 457 |
|
|---|
| 458 | if(hrgn != NULLHANDLE)
|
|---|
| 459 | {
|
|---|
| 460 | hrgnNewClip = GpiCreateRegion(pHps->hps, 1, &rectl);
|
|---|
| 461 | if(hrgnNewClip == NULLHANDLE) {
|
|---|
| 462 | dprintf(("ERROR: GdiCombineVisRgn: GpiCreateRegion failed!!"));
|
|---|
| 463 | DebugInt3();
|
|---|
| 464 | goto failure;
|
|---|
| 465 | }
|
|---|
| 466 | //make a copy of the new visible region
|
|---|
| 467 | lComplexity = GpiCombineRegion(pHps->hps, hrgnNewClip, hrgn, NULLHANDLE, CRGN_COPY);
|
|---|
| 468 | }
|
|---|
| 469 | else {
|
|---|
| 470 | hrgnNewClip = NULLHANDLE;
|
|---|
| 471 | }
|
|---|
| 472 |
|
|---|
| 473 | //and set that as the GPI clip region
|
|---|
| 474 | lComplexity = GpiSetClipRegion(pHps->hps, hrgnNewClip, &hrgnOldClip);
|
|---|
| 475 | if (lComplexity != RGN_ERROR)
|
|---|
| 476 | {
|
|---|
| 477 | //SvL: Must check if origin changed here. Sometimes happens when
|
|---|
| 478 | // window looses focus. (don't know why....)
|
|---|
| 479 | checkOrigin(pHps);
|
|---|
| 480 |
|
|---|
| 481 | if(hrgnOldClip) GpiDestroyRegion(pHps->hps, hrgnOldClip);
|
|---|
| 482 |
|
|---|
| 483 | dprintf(("New visible region %x", hrgn));
|
|---|
| 484 | pHps->hrgnWinVis = hrgn;
|
|---|
| 485 | return GPI_TO_WIN_COMPLEXITY(lComplexity);
|
|---|
| 486 | }
|
|---|
| 487 | failure:
|
|---|
| 488 | if(hrgnNewClip) GpiDestroyRegion(pHps->hps, hrgnNewClip);
|
|---|
| 489 |
|
|---|
| 490 | return ERROR_W;
|
|---|
| 491 | }
|
|---|
| 492 | //******************************************************************************
|
|---|
| 493 | // GdiCombineVisRgn
|
|---|
| 494 | //
|
|---|
| 495 | // Combine the specified region with the visible region according to the operation
|
|---|
| 496 | //
|
|---|
| 497 | // Parameters:
|
|---|
| 498 | //
|
|---|
| 499 | // pDCData pHps - presentation space structure
|
|---|
| 500 | // HRGN hrgn - region handle (Win32)
|
|---|
| 501 | // INT operation - combine operation (RGN_*)
|
|---|
| 502 | //
|
|---|
| 503 | //
|
|---|
| 504 | // Returns: - ERROR_W -> failure
|
|---|
| 505 | // - NULLREGION_W -> empty region
|
|---|
| 506 | // - SIMPLEREGION_W -> rectangular region
|
|---|
| 507 | // - COMPLEXREGION_W -> complex region
|
|---|
| 508 | //
|
|---|
| 509 | // NOTE: In windows there is a clip and a visible region (just like in PM)
|
|---|
| 510 | // We do not map the Win32 visible region to the PM visible region
|
|---|
| 511 | // as that's rather annoying.
|
|---|
| 512 | // Instead we use the intersection of the win32 visible and win32 clip
|
|---|
| 513 | // region for the PM clip region.
|
|---|
| 514 | // The Win32 clip region is saved in pHps->hrgnWin32Clip.
|
|---|
| 515 | // The Win32 visible region is saved in pHps->hrgnWinVis.
|
|---|
| 516 | //
|
|---|
| 517 | //******************************************************************************
|
|---|
| 518 | INT WIN32API GdiCombineVisRgn(pDCData pHps, HRGN hrgn, INT operation)
|
|---|
| 519 | {
|
|---|
| 520 | #ifdef DEBUG
|
|---|
| 521 | HRGN hrgn1 = hrgn;
|
|---|
| 522 | #endif
|
|---|
| 523 | LONG lComplexity = RGN_NULL;
|
|---|
| 524 |
|
|---|
| 525 | if(pHps == NULL) {
|
|---|
| 526 | DebugInt3();
|
|---|
| 527 | return ERROR_W;
|
|---|
| 528 | }
|
|---|
| 529 |
|
|---|
| 530 | hrgn = ObjQueryHandleData(hrgn, HNDL_REGION);
|
|---|
| 531 | if(hrgn == HANDLE_OBJ_ERROR || !pHps) {
|
|---|
| 532 | dprintf(("ERROR: GdiCombineVisRgn %x invalid handle", hrgn1));
|
|---|
| 533 | return ERROR_W;
|
|---|
| 534 | }
|
|---|
| 535 | //interpretRegionAs converts the region and saves it in pHps->hrgnHDC
|
|---|
| 536 | if(!interpretRegionAs(pHps, 0, hrgn, AS_DEVICE) )
|
|---|
| 537 | {
|
|---|
| 538 | dprintf(("ERROR: interpretRegionAs failed!!"));
|
|---|
| 539 | return ERROR_W;
|
|---|
| 540 | }
|
|---|
| 541 |
|
|---|
| 542 | //If there is no visible region, then create one that covers the whole DC
|
|---|
| 543 | if(pHps->hrgnWinVis == NULLHANDLE)
|
|---|
| 544 | {
|
|---|
| 545 | RECTL rectl = {0, 0, hdcWidth(0, pHps), hdcHeight(0, pHps)};
|
|---|
| 546 | dprintf(("No visible region: create one (0,0)(%d,%d)", rectl.xRight, rectl.yTop));
|
|---|
| 547 | pHps->hrgnWinVis = GpiCreateRegion(pHps->hps, 1, &rectl);
|
|---|
| 548 | if(pHps->hrgnWinVis == NULLHANDLE) {
|
|---|
| 549 | dprintf(("ERROR: GdiCombineVisRgn: GpiCreateRegion failed!!"));
|
|---|
| 550 | DebugInt3();
|
|---|
| 551 | goto failure;
|
|---|
| 552 | }
|
|---|
| 553 | }
|
|---|
| 554 |
|
|---|
| 555 | LONG lMode;
|
|---|
| 556 | switch (operation)
|
|---|
| 557 | {
|
|---|
| 558 | case RGN_AND_W : lMode = CRGN_AND ; break;
|
|---|
| 559 | case RGN_DIFF_W : lMode = CRGN_DIFF; break;
|
|---|
| 560 | default:
|
|---|
| 561 | dprintf(("ERROR: GdiCombineVisRgn %d invalid parameter", operation));
|
|---|
| 562 | DebugInt3();
|
|---|
| 563 | goto failure;
|
|---|
| 564 | }
|
|---|
| 565 | lComplexity = GpiCombineRegion(pHps->hps, pHps->hrgnWinVis, pHps->hrgnWinVis, pHps->hrgnHDC, lMode);
|
|---|
| 566 | if (lComplexity != RGN_ERROR)
|
|---|
| 567 | {
|
|---|
| 568 | return GdiSetVisRgn(pHps, pHps->hrgnWinVis);
|
|---|
| 569 | }
|
|---|
| 570 | dprintf(("ERROR: GdiCombineVisRgn: GpiCombineRegion failed"));
|
|---|
| 571 | DebugInt3();
|
|---|
| 572 |
|
|---|
| 573 | failure:
|
|---|
| 574 | return ERROR_W;
|
|---|
| 575 | }
|
|---|
| 576 | //******************************************************************************
|
|---|
| 577 | // GdiCombineVisRgnClipRgn
|
|---|
| 578 | //
|
|---|
| 579 | // Combine the specified clip region with the visible region according to the operation
|
|---|
| 580 | //
|
|---|
| 581 | // Parameters:
|
|---|
| 582 | //
|
|---|
| 583 | // pDCData pHps - presentation space structure
|
|---|
| 584 | // HRGN hrgn - region handle (GPI)
|
|---|
| 585 | // INT operation - combine operation (RGN_*)
|
|---|
| 586 | //
|
|---|
| 587 | //
|
|---|
| 588 | // Returns: - ERROR_W -> failure
|
|---|
| 589 | // - NULLREGION_W -> empty region
|
|---|
| 590 | // - SIMPLEREGION_W -> rectangular region
|
|---|
| 591 | // - COMPLEXREGION_W -> complex region
|
|---|
| 592 | //
|
|---|
| 593 | // NOTE: In windows there is a clip and a visible region (just like in PM)
|
|---|
| 594 | // We do not map the Win32 visible region to the PM visible region
|
|---|
| 595 | // as that's rather annoying.
|
|---|
| 596 | // Instead we use the intersection of the win32 visible and win32 clip
|
|---|
| 597 | // region for the PM clip region.
|
|---|
| 598 | // The Win32 clip region is saved in pHps->hrgnWin32Clip.
|
|---|
| 599 | // The Win32 visible region is saved in pHps->hrgnWinVis.
|
|---|
| 600 | //
|
|---|
| 601 | //******************************************************************************
|
|---|
| 602 | INT WIN32API GdiCombineVisRgnClipRgn(pDCData pHps, HRGN hrgn, INT operation)
|
|---|
| 603 | {
|
|---|
| 604 | HRGN hrgnClip = NULL, hrgnOldClip, hrgnNewClip;
|
|---|
| 605 | LONG lComplexity = RGN_NULL;
|
|---|
| 606 |
|
|---|
| 607 | //Create a region that will be used for the new GPI clip region
|
|---|
| 608 | RECTL rectl = {0, 0, 1, 1};
|
|---|
| 609 | hrgnNewClip = GpiCreateRegion(pHps->hps, 1, &rectl);
|
|---|
| 610 | if(hrgnNewClip == NULLHANDLE) {
|
|---|
| 611 | dprintf(("ERROR: GdiCombineVisRgnClipRgn: GpiCreateRegion failed!!"));
|
|---|
| 612 | DebugInt3();
|
|---|
| 613 | return ERROR_W;
|
|---|
| 614 | }
|
|---|
| 615 |
|
|---|
| 616 | if(hrgn == NULLHANDLE)
|
|---|
| 617 | {
|
|---|
| 618 | if(pHps->hrgnWin32Clip != NULL)
|
|---|
| 619 | {
|
|---|
| 620 | //Only reset the path if both the visible and clip regions are zero
|
|---|
| 621 | if(!pHps->hrgnWinVis) {
|
|---|
| 622 | GpiSetClipPath(pHps->hps, 0, SCP_RESET);
|
|---|
| 623 |
|
|---|
| 624 | GpiDestroyRegion(pHps->hps, hrgnNewClip);
|
|---|
| 625 | hrgnNewClip = NULLHANDLE;
|
|---|
| 626 | }
|
|---|
| 627 | else
|
|---|
| 628 | {//set PM clip region to Win32 visible region
|
|---|
| 629 | lComplexity = GpiCombineRegion(pHps->hps, hrgnNewClip, pHps->hrgnWinVis, NULLHANDLE, CRGN_COPY);
|
|---|
| 630 | if(lComplexity == RGN_ERROR) {
|
|---|
| 631 | dprintf(("ERROR: GdiCombineVisRgnClipRgn: GpiSetClipRegion failed!!"));
|
|---|
| 632 | DebugInt3();
|
|---|
| 633 | goto failure;
|
|---|
| 634 | }
|
|---|
| 635 | }
|
|---|
| 636 | dprintfRegion(pHps->hps, hrgnNewClip);
|
|---|
| 637 | lComplexity = GpiSetClipRegion(pHps->hps, hrgnNewClip, &hrgnOldClip);
|
|---|
| 638 | if(lComplexity == RGN_ERROR) {
|
|---|
| 639 | dprintf(("ERROR: GdiCombineVisRgnClipRgn: GpiSetClipRegion failed!!"));
|
|---|
| 640 | DebugInt3();
|
|---|
| 641 | }
|
|---|
| 642 |
|
|---|
| 643 | //SvL: Must check if origin changed here. Sometimes happens when
|
|---|
| 644 | // window looses focus. (don't know why....)
|
|---|
| 645 | checkOrigin(pHps);
|
|---|
| 646 | if(hrgnOldClip) GpiDestroyRegion(pHps->hps, hrgnOldClip);
|
|---|
| 647 | }
|
|---|
| 648 | //else already NULL, so nothing to do.
|
|---|
| 649 |
|
|---|
| 650 | pHps->hrgnWin32Clip = hrgn;
|
|---|
| 651 | return NULLREGION_W;
|
|---|
| 652 | }
|
|---|
| 653 |
|
|---|
| 654 | LONG lMode;
|
|---|
| 655 | switch (operation)
|
|---|
| 656 | {
|
|---|
| 657 | case RGN_AND_W : lMode = CRGN_AND ; break; //intersect clip & visible region
|
|---|
| 658 | default:
|
|---|
| 659 | dprintf(("ERROR: GdiCombineVisRgnClipRgn %d invalid parameter", operation));
|
|---|
| 660 | DebugInt3();
|
|---|
| 661 | goto failure;
|
|---|
| 662 | }
|
|---|
| 663 | // If there's no visible region (meaning entire DC is visible), then just set
|
|---|
| 664 | // the GPI clip region to the win32 clip region
|
|---|
| 665 | if (pHps->hrgnWinVis == NULLHANDLE)
|
|---|
| 666 | {
|
|---|
| 667 | lComplexity = GpiCombineRegion(pHps->hps, hrgnNewClip, hrgn, NULLHANDLE, CRGN_COPY);
|
|---|
| 668 | }
|
|---|
| 669 | else lComplexity = GpiCombineRegion(pHps->hps, hrgnNewClip, pHps->hrgnWinVis, hrgn, lMode);
|
|---|
| 670 |
|
|---|
| 671 | if (lComplexity != RGN_ERROR)
|
|---|
| 672 | {
|
|---|
| 673 | dprintfRegion(pHps->hps, hrgnNewClip);
|
|---|
| 674 | //And activate the new clip region
|
|---|
| 675 | lComplexity = GpiSetClipRegion(pHps->hps, hrgnNewClip, &hrgnOldClip);
|
|---|
| 676 | if (lComplexity == RGN_ERROR )
|
|---|
| 677 | {
|
|---|
| 678 | dprintf(("ERROR: GdiCombineVisRgnClipRgn: GpiSetClipRegion failed"));
|
|---|
| 679 | DebugInt3();
|
|---|
| 680 | goto failure;
|
|---|
| 681 | }
|
|---|
| 682 | //SvL: Must check if origin changed here. Sometimes happens when
|
|---|
| 683 | // window looses focus. (don't know why....)
|
|---|
| 684 | checkOrigin(pHps);
|
|---|
| 685 |
|
|---|
| 686 | if(hrgnOldClip) GpiDestroyRegion(pHps->hps, hrgnOldClip);
|
|---|
| 687 |
|
|---|
| 688 | pHps->hrgnWin32Clip = hrgn;
|
|---|
| 689 |
|
|---|
| 690 | return GPI_TO_WIN_COMPLEXITY(lComplexity);
|
|---|
| 691 | }
|
|---|
| 692 | dprintf(("ERROR: GdiCombineVisRgnClipRgn: GpiCombineRegion failed"));
|
|---|
| 693 | DebugInt3();
|
|---|
| 694 |
|
|---|
| 695 | failure:
|
|---|
| 696 | if(hrgnNewClip) GpiDestroyRegion(pHps->hps, hrgnNewClip);
|
|---|
| 697 |
|
|---|
| 698 | return ERROR_W;
|
|---|
| 699 | }
|
|---|
| 700 | //******************************************************************************
|
|---|
| 701 | //******************************************************************************
|
|---|
| 702 | int WIN32API ExtSelectClipRgn(HDC hdc, HRGN hrgn, int mode)
|
|---|
| 703 | {
|
|---|
| 704 | #ifdef DEBUG
|
|---|
| 705 | HRGN hrgn1 = hrgn;
|
|---|
| 706 | #endif
|
|---|
| 707 |
|
|---|
| 708 | pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
|
|---|
| 709 | if (!pHps)
|
|---|
| 710 | {
|
|---|
| 711 | dprintf(("WARNING: ExtSelectRgn %x %x %d invalid hdc", hdc, hrgn, mode));
|
|---|
| 712 | SetLastError(ERROR_INVALID_HANDLE_W);
|
|---|
| 713 | return ERROR_W;
|
|---|
| 714 | }
|
|---|
| 715 |
|
|---|
| 716 | LONG lComplexity;
|
|---|
| 717 | HRGN hrgnCurrent = NULLHANDLE, hrgnOld = NULLHANDLE;
|
|---|
| 718 |
|
|---|
| 719 | if(!hrgn && mode != RGN_COPY_W)
|
|---|
| 720 | {
|
|---|
| 721 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 722 | dprintf(("WARNING: ExtSelectRgn %x %x %d invalid parameter", hdc, hrgn1, mode));
|
|---|
| 723 | return ERROR_W;
|
|---|
| 724 | }
|
|---|
| 725 |
|
|---|
| 726 | LONG lMode;
|
|---|
| 727 | switch (mode)
|
|---|
| 728 | {
|
|---|
| 729 | case RGN_AND_W : lMode = CRGN_AND ; break;
|
|---|
| 730 | case RGN_COPY_W : lMode = CRGN_COPY; break;
|
|---|
| 731 | case RGN_DIFF_W : lMode = CRGN_DIFF; break;
|
|---|
| 732 | case RGN_OR_W : lMode = CRGN_OR ; break;
|
|---|
| 733 | case RGN_XOR_W : lMode = CRGN_XOR ; break;
|
|---|
| 734 | default:
|
|---|
| 735 | {
|
|---|
| 736 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 737 | dprintf(("WARNING: ExtSelectRgn %x %x %d invalid parameter", hdc, hrgn1, mode));
|
|---|
| 738 | return ERROR_W;
|
|---|
| 739 | }
|
|---|
| 740 | }
|
|---|
| 741 |
|
|---|
| 742 | if(hrgn)
|
|---|
| 743 | {
|
|---|
| 744 | hrgn = ObjQueryHandleData(hrgn, HNDL_REGION);
|
|---|
| 745 | if(hrgn == HANDLE_OBJ_ERROR) {
|
|---|
| 746 | dprintf(("WARNING: ExtSelectRgn %x %x %d invalid region handle", hdc, hrgn1, mode));
|
|---|
| 747 | SetLastError(ERROR_INVALID_HANDLE_W);
|
|---|
| 748 | return 0;
|
|---|
| 749 | }
|
|---|
| 750 | dprintfRegion(hdc, hrgn);
|
|---|
| 751 | }
|
|---|
| 752 |
|
|---|
| 753 | //TODO: metafile recording
|
|---|
| 754 | if(hrgn)
|
|---|
| 755 | {
|
|---|
| 756 | //interpretRegionAs converts the region and saves it in pHps->hrgnHDC
|
|---|
| 757 | if(!interpretRegionAs(pHps, 0, hrgn, AS_DEVICE) )
|
|---|
| 758 | {
|
|---|
| 759 | return ERROR_W;
|
|---|
| 760 | }
|
|---|
| 761 | }
|
|---|
| 762 | else
|
|---|
| 763 | {
|
|---|
| 764 | //Intersect the Windows clip region with the current visible region
|
|---|
| 765 | lComplexity = GdiCombineVisRgnClipRgn(pHps, NULLHANDLE, RGN_AND_W);
|
|---|
| 766 |
|
|---|
| 767 | return NULLREGION_W;
|
|---|
| 768 | }
|
|---|
| 769 |
|
|---|
| 770 | // get current clipping region
|
|---|
| 771 | hrgnOld = pHps->hrgnWin32Clip;
|
|---|
| 772 | hrgnCurrent = hrgnOld;
|
|---|
| 773 |
|
|---|
| 774 | if(hrgnCurrent == NULLHANDLE)
|
|---|
| 775 | {//if none, then create one
|
|---|
| 776 | lMode = CRGN_COPY;
|
|---|
| 777 | RECTL rectl = {0, 0, 1, 1};
|
|---|
| 778 | hrgnCurrent = GpiCreateRegion(pHps->hps, 1, &rectl);
|
|---|
| 779 | }
|
|---|
| 780 |
|
|---|
| 781 | HRGN hrgnSrc1;
|
|---|
| 782 | HRGN hrgnSrc2;
|
|---|
| 783 | if(lMode != CRGN_COPY)
|
|---|
| 784 | {
|
|---|
| 785 | hrgnSrc1 = hrgnCurrent;
|
|---|
| 786 | hrgnSrc2 = pHps->hrgnHDC;
|
|---|
| 787 | }
|
|---|
| 788 | else
|
|---|
| 789 | {
|
|---|
| 790 | hrgnSrc1 = pHps->hrgnHDC;
|
|---|
| 791 | hrgnSrc2 = NULLHANDLE;
|
|---|
| 792 | }
|
|---|
| 793 |
|
|---|
| 794 | lComplexity = GpiCombineRegion(pHps->hps, hrgnCurrent, hrgnSrc1, hrgnSrc2, lMode);
|
|---|
| 795 | if (lComplexity != RGN_ERROR)
|
|---|
| 796 | {
|
|---|
| 797 | HRGN hrgnOld;
|
|---|
| 798 |
|
|---|
| 799 | //Intersect the Windows clip region with the current visible region
|
|---|
| 800 | lComplexity = GdiCombineVisRgnClipRgn(pHps, hrgnCurrent, RGN_AND_W);
|
|---|
| 801 |
|
|---|
| 802 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 803 |
|
|---|
| 804 | if (lComplexity != RGN_ERROR) {
|
|---|
| 805 | return lComplexity;
|
|---|
| 806 | }
|
|---|
| 807 | }
|
|---|
| 808 | GpiDestroyRegion(pHps->hps, hrgnCurrent); //delete newly created region
|
|---|
| 809 |
|
|---|
| 810 | SetLastError(ERROR_INVALID_PARAMETER_W); //TODO
|
|---|
| 811 | return ERROR_W;
|
|---|
| 812 | }
|
|---|
| 813 | //******************************************************************************
|
|---|
| 814 | //******************************************************************************
|
|---|
| 815 | int WIN32API SelectClipRgn(HDC hdc, HRGN hrgn)
|
|---|
| 816 | {
|
|---|
| 817 | return ExtSelectClipRgn(hdc, hrgn, RGN_COPY_W);
|
|---|
| 818 | }
|
|---|
| 819 | //******************************************************************************
|
|---|
| 820 | // The GetClipBox function retrieves the dimensions of the tightest bounding
|
|---|
| 821 | // rectangle that can be drawn around the current visible area on the device.
|
|---|
| 822 | // The visible area is defined by the current clipping region or clip path, as well
|
|---|
| 823 | // as any overlapping windows.
|
|---|
| 824 | //
|
|---|
| 825 | // NOTE: We simply call GpiQueryClipBox as it behaves just like GetClipBox
|
|---|
| 826 | //
|
|---|
| 827 | //******************************************************************************
|
|---|
| 828 | int WIN32API GetClipBox(HDC hdc, PRECT lpRect)
|
|---|
| 829 | {
|
|---|
| 830 | pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
|
|---|
| 831 | RECTL rectl;
|
|---|
| 832 | LONG lComplexity;
|
|---|
| 833 | int rc;
|
|---|
| 834 |
|
|---|
| 835 | if(!hdc || !lpRect || !pHps) {
|
|---|
| 836 | dprintf(("GDI32: GetClipBox %x %x ERROR_INVALID_PARAMETER", hdc, lpRect));
|
|---|
| 837 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 838 | return ERROR_W;
|
|---|
| 839 | }
|
|---|
| 840 | if(pHps->isPrinter)
|
|---|
| 841 | {
|
|---|
| 842 | //Some printers return the wrong clip box. Return the full page instead.
|
|---|
| 843 | //(TODO: which is incorrect!)
|
|---|
| 844 | lpRect->left = 0;
|
|---|
| 845 | lpRect->top = 0;
|
|---|
| 846 | lpRect->right = GetDeviceCaps( hdc, HORZRES_W);
|
|---|
| 847 | lpRect->bottom = GetDeviceCaps( hdc, VERTRES_W);
|
|---|
| 848 | includeBottomRightPoint(pHps, (PPOINTLOS2)&rectl);
|
|---|
| 849 | convertPMDeviceRectToWinWorldRect(pHps, &rectl);
|
|---|
| 850 |
|
|---|
| 851 | rc = SIMPLEREGION_W;
|
|---|
| 852 | }
|
|---|
| 853 | else {
|
|---|
| 854 | lComplexity = GpiQueryClipBox(pHps->hps, &rectl);
|
|---|
| 855 | if(lComplexity == RGN_ERROR)
|
|---|
| 856 | {
|
|---|
| 857 | rc = ERROR_W;
|
|---|
| 858 | }
|
|---|
| 859 | else
|
|---|
| 860 | if(lComplexity == RGN_NULL)
|
|---|
| 861 | {
|
|---|
| 862 | memset(lpRect, 0, sizeof(*lpRect));
|
|---|
| 863 | rc = NULLREGION_W;
|
|---|
| 864 | }
|
|---|
| 865 | else {
|
|---|
| 866 | #ifndef INVERT
|
|---|
| 867 | //Convert coordinates from PM to win32
|
|---|
| 868 | if (pHps->yInvert > 0) {
|
|---|
| 869 | LONG temp = pHps->yInvert - rectl.yBottom;
|
|---|
| 870 | rectl.yBottom = pHps->yInvert - rectl.yTop;
|
|---|
| 871 | rectl.yTop = temp;
|
|---|
| 872 | }
|
|---|
| 873 | #endif
|
|---|
| 874 | //Convert including/including to including/excluding
|
|---|
| 875 | includeBottomRightPoint(pHps, (PPOINTLOS2)&rectl);
|
|---|
| 876 |
|
|---|
| 877 | lpRect->left = rectl.xLeft;
|
|---|
| 878 | lpRect->right = rectl.xRight;
|
|---|
| 879 |
|
|---|
| 880 | if(rectl.yBottom > rectl.yTop) {
|
|---|
| 881 | lpRect->top = rectl.yTop;
|
|---|
| 882 | lpRect->bottom = rectl.yBottom;
|
|---|
| 883 | }
|
|---|
| 884 | else {
|
|---|
| 885 | lpRect->top = rectl.yBottom;
|
|---|
| 886 | lpRect->bottom = rectl.yTop;
|
|---|
| 887 | }
|
|---|
| 888 |
|
|---|
| 889 | rc = GPI_TO_WIN_COMPLEXITY(lComplexity);
|
|---|
| 890 | }
|
|---|
| 891 | }
|
|---|
| 892 | // if(lpRect->left == 0 && lpRect->top == 0 && lpRect->right == 0 && lpRect->bottom == 0)
|
|---|
| 893 | // DebugInt3();
|
|---|
| 894 | dprintf(("GDI32: GetClipBox of %X returned %d; (%d,%d)(%d,%d)", hdc, rc, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom));
|
|---|
| 895 | return rc;
|
|---|
| 896 | }
|
|---|
| 897 | //******************************************************************************
|
|---|
| 898 | //******************************************************************************
|
|---|
| 899 | int WIN32API GetClipRgn(HDC hdc, HRGN hrgn)
|
|---|
| 900 | {
|
|---|
| 901 | pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
|
|---|
| 902 | BOOL success;
|
|---|
| 903 | LONG lComplexity = RGN_RECT;
|
|---|
| 904 | HRGN hrgnClip = NULL, hrgnTemp;
|
|---|
| 905 | #ifdef DEBUG
|
|---|
| 906 | HRGN hrgn1 = hrgn;
|
|---|
| 907 | #endif
|
|---|
| 908 |
|
|---|
| 909 | hrgn = ObjQueryHandleData(hrgn, HNDL_REGION);
|
|---|
| 910 | if(hrgn == HANDLE_OBJ_ERROR || !pHps) {
|
|---|
| 911 | dprintf(("WARNING: GetClipRgn %x %x invalid handle", hdc, hrgn1));
|
|---|
| 912 | SetLastError(ERROR_INVALID_HANDLE_W);
|
|---|
| 913 | return 0;
|
|---|
| 914 | }
|
|---|
| 915 |
|
|---|
| 916 | if(pHps->hrgnWin32Clip) {
|
|---|
| 917 | dprintfRegion(hdc, pHps->hrgnWin32Clip);
|
|---|
| 918 | if(!setWinDeviceRegionFromPMDeviceRegion(hrgn, pHps->hrgnWin32Clip, pHps, NULL)) {
|
|---|
| 919 | dprintf(("WARNING: GetClipRgn setWinDeviceRegionFromPMDeviceRegion failed!"));
|
|---|
| 920 | GpiSetClipRegion(pHps->hps, hrgnClip, &hrgnTemp);
|
|---|
| 921 | SetLastError(ERROR_INVALID_PARAMETER_W); //todo right errror
|
|---|
| 922 | return 0;
|
|---|
| 923 | }
|
|---|
| 924 | }
|
|---|
| 925 | else {
|
|---|
| 926 | //no clip region; return NULL
|
|---|
| 927 | lComplexity = RGN_NULL;
|
|---|
| 928 | }
|
|---|
| 929 |
|
|---|
| 930 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 931 | if(lComplexity == RGN_NULL)
|
|---|
| 932 | return 0;
|
|---|
| 933 | else return 1;
|
|---|
| 934 | }
|
|---|
| 935 | //******************************************************************************
|
|---|
| 936 | // The GetRandomRgn function copies the system clipping region of a specified
|
|---|
| 937 | // device context to a specific region.
|
|---|
| 938 | // It returns the visible region of the specified device context in screen
|
|---|
| 939 | // coordinates (if it belongs to a window).
|
|---|
| 940 | //
|
|---|
| 941 | // VALUE = 1: This undocumented value will return the current Clip Region contained in the DC.
|
|---|
| 942 | // VALUE = 2: This undocumented value will return the current Meta Region contained in the DC.
|
|---|
| 943 | // VALUE = 3: This undocumented value will return the intersection of the Clip Region and Meta Region.
|
|---|
| 944 | // VALUE = 4, SYSRGN: The only value that is documented and defined for this function.
|
|---|
| 945 | // This value returns the System Region
|
|---|
| 946 | //******************************************************************************
|
|---|
| 947 | INT WIN32API GetRandomRgn(HDC hdc, HRGN hrgn, INT iNum)
|
|---|
| 948 | {
|
|---|
| 949 | HWND hwnd;
|
|---|
| 950 | INT ret;
|
|---|
| 951 |
|
|---|
| 952 | if(iNum != SYSRGN_W) {
|
|---|
| 953 | dprintf(("WARNING: GetRandomRgn: invalid parameter %x", iNum));
|
|---|
| 954 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 955 | return ERROR_W;
|
|---|
| 956 | }
|
|---|
| 957 | ret = GetClipRgn(hdc, hrgn);
|
|---|
| 958 |
|
|---|
| 959 | hwnd = WindowFromDC(hdc);
|
|---|
| 960 | if(hwnd) {
|
|---|
| 961 | POINT pt = {0,0};
|
|---|
| 962 | //map from client to desktop coordinates
|
|---|
| 963 | MapWindowPoints(hwnd, 0, &pt, 1);
|
|---|
| 964 |
|
|---|
| 965 | OffsetRgn(hrgn, pt.x, pt.y);
|
|---|
| 966 | }
|
|---|
| 967 | return ret;
|
|---|
| 968 | }
|
|---|
| 969 | //******************************************************************************
|
|---|
| 970 | //******************************************************************************
|
|---|
| 971 | int WIN32API ExcludeClipRect(HDC hdc, int left, int top, int right, int bottom)
|
|---|
| 972 | {
|
|---|
| 973 | pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
|
|---|
| 974 | if(!pHps)
|
|---|
| 975 | {
|
|---|
| 976 | dprintf(("ERROR: ExcludeClipRgn %x (%d,%d)(%d,%d) invalid hdc", hdc, left, top, right, bottom));
|
|---|
| 977 | SetLastError(ERROR_INVALID_HANDLE_W);
|
|---|
| 978 | return ERROR_W;
|
|---|
| 979 | }
|
|---|
| 980 |
|
|---|
| 981 | LONG lComplexity;
|
|---|
| 982 | RECTL rectl = { left, bottom, right, top };
|
|---|
| 983 |
|
|---|
| 984 | excludeBottomRightPoint(pHps, (PPOINTLOS2)&rectl);
|
|---|
| 985 | if(rectl.yTop < rectl.yBottom) {
|
|---|
| 986 | ULONG temp = rectl.yBottom;
|
|---|
| 987 | rectl.yBottom = rectl.yTop;
|
|---|
| 988 | rectl.yTop = temp;
|
|---|
| 989 | }
|
|---|
| 990 |
|
|---|
| 991 | #ifndef INVERT
|
|---|
| 992 | if (pHps->yInvert > 0) {
|
|---|
| 993 | LONG temp = pHps->yInvert - rectl.yBottom;
|
|---|
| 994 | rectl.yBottom = pHps->yInvert - rectl.yTop;
|
|---|
| 995 | rectl.yTop = temp;
|
|---|
| 996 | }
|
|---|
| 997 | #endif
|
|---|
| 998 |
|
|---|
| 999 | dprintf(("ExcludeClipRgn %x (%d,%d)(%d,%d)", hdc, left, top, right, bottom));
|
|---|
| 1000 |
|
|---|
| 1001 | lComplexity = GpiExcludeClipRectangle(pHps->hps, &rectl);
|
|---|
| 1002 | if (lComplexity == RGN_ERROR) {
|
|---|
| 1003 | dprintf(("ERROR: ExcludeClipRgn: GpiExcludeClipRectangle failed!!"));
|
|---|
| 1004 | SetLastError(ERROR_INVALID_PARAMETER_W); //TODO: wrong error
|
|---|
| 1005 | return ERROR_W;
|
|---|
| 1006 | }
|
|---|
| 1007 |
|
|---|
| 1008 | //Ok, success. Now update the cached win32 clip region
|
|---|
| 1009 | if(pHps->hrgnWin32Clip != NULLHANDLE)
|
|---|
| 1010 | {
|
|---|
| 1011 | HRGN hrgnClipRect = GpiCreateRegion(pHps->hps, 1, &rectl);
|
|---|
| 1012 | if(hrgnClipRect == NULLHANDLE) {
|
|---|
| 1013 | dprintf(("ERROR: ExcludeClipRgn GpiCreateRegion failed!!"));
|
|---|
| 1014 | DebugInt3();
|
|---|
| 1015 | SetLastError(ERROR_INVALID_PARAMETER_W); //TODO: wrong error
|
|---|
| 1016 | return ERROR_W;
|
|---|
| 1017 | }
|
|---|
| 1018 | //subtract rect region from clip region
|
|---|
| 1019 | lComplexity = GpiCombineRegion(pHps->hps, pHps->hrgnWin32Clip, pHps->hrgnWin32Clip, hrgnClipRect, CRGN_DIFF);
|
|---|
| 1020 | GpiDestroyRegion(pHps->hps, hrgnClipRect);
|
|---|
| 1021 |
|
|---|
| 1022 | if (lComplexity == RGN_ERROR) {
|
|---|
| 1023 | dprintf(("ERROR: ExcludeClipRgn GpiCombineRegion failed!!"));
|
|---|
| 1024 | DebugInt3();
|
|---|
| 1025 | SetLastError(ERROR_INVALID_PARAMETER_W); //TODO: wrong error
|
|---|
| 1026 | return ERROR_W;
|
|---|
| 1027 | }
|
|---|
| 1028 | }
|
|---|
| 1029 |
|
|---|
| 1030 | //todo metafile recording
|
|---|
| 1031 |
|
|---|
| 1032 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 1033 | return lComplexity;
|
|---|
| 1034 | }
|
|---|
| 1035 | //******************************************************************************
|
|---|
| 1036 | //******************************************************************************
|
|---|
| 1037 | int WIN32API IntersectClipRect(HDC hdc, int left, int top, int right, int bottom)
|
|---|
| 1038 | {
|
|---|
| 1039 | pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
|
|---|
| 1040 | LONG lComplexity;
|
|---|
| 1041 | BOOL success;
|
|---|
| 1042 |
|
|---|
| 1043 | if(!pHps) {
|
|---|
| 1044 | dprintf(("WARNING: IntersectClipRect %x (%d,%d)(%d,%d) invalid hdc", hdc, left, top, right, bottom));
|
|---|
| 1045 | SetLastError(ERROR_INVALID_HANDLE_W);
|
|---|
| 1046 | return ERROR_W;
|
|---|
| 1047 | }
|
|---|
| 1048 | RECTL rectl = { left, bottom, right, top };
|
|---|
| 1049 |
|
|---|
| 1050 | excludeBottomRightPoint(pHps, (PPOINTLOS2)&rectl);
|
|---|
| 1051 | if(rectl.yTop < rectl.yBottom) {
|
|---|
| 1052 | ULONG temp = rectl.yBottom;
|
|---|
| 1053 | rectl.yBottom = rectl.yTop;
|
|---|
| 1054 | rectl.yTop = temp;
|
|---|
| 1055 | }
|
|---|
| 1056 |
|
|---|
| 1057 | #ifndef INVERT
|
|---|
| 1058 | //Convert coordinates from PM to win32
|
|---|
| 1059 | if (pHps->yInvert > 0) {
|
|---|
| 1060 | LONG temp = pHps->yInvert - rectl.yBottom;
|
|---|
| 1061 | rectl.yBottom = pHps->yInvert - rectl.yTop;
|
|---|
| 1062 | rectl.yTop = temp;
|
|---|
| 1063 | }
|
|---|
| 1064 | #endif
|
|---|
| 1065 |
|
|---|
| 1066 | dprintf(("IntersectClipRect %x (%d,%d)(%d,%d)", hdc, left, top, right, bottom));
|
|---|
| 1067 | lComplexity = GpiIntersectClipRectangle(pHps->hps, &rectl);
|
|---|
| 1068 | if (lComplexity == RGN_ERROR) {
|
|---|
| 1069 | dprintf(("ERROR: IntersectClipRect: GpiIntersectClipRectangle failed!!"));
|
|---|
| 1070 | SetLastError(ERROR_INVALID_PARAMETER_W); //TODO: wrong error
|
|---|
| 1071 | return ERROR_W;
|
|---|
| 1072 | }
|
|---|
| 1073 |
|
|---|
| 1074 | //Ok, success. Now update the cached win32 clip region
|
|---|
| 1075 | if(pHps->hrgnWin32Clip != NULLHANDLE)
|
|---|
| 1076 | {
|
|---|
| 1077 | HRGN hrgnClipRect = GpiCreateRegion(pHps->hps, 1, &rectl);
|
|---|
| 1078 | if(hrgnClipRect == NULLHANDLE) {
|
|---|
| 1079 | dprintf(("ERROR: IntersectClipRect GpiCreateRegion failed!!"));
|
|---|
| 1080 | DebugInt3();
|
|---|
| 1081 | SetLastError(ERROR_INVALID_PARAMETER_W); //TODO: wrong error
|
|---|
| 1082 | return ERROR_W;
|
|---|
| 1083 | }
|
|---|
| 1084 | //intersect rect region with clip region
|
|---|
| 1085 | lComplexity = GpiCombineRegion(pHps->hps, pHps->hrgnWin32Clip, pHps->hrgnWin32Clip, hrgnClipRect, CRGN_AND);
|
|---|
| 1086 | GpiDestroyRegion(pHps->hps, hrgnClipRect);
|
|---|
| 1087 |
|
|---|
| 1088 | if (lComplexity == RGN_ERROR) {
|
|---|
| 1089 | dprintf(("ERROR: IntersectClipRect GpiCombineRegion failed!!"));
|
|---|
| 1090 | DebugInt3();
|
|---|
| 1091 | SetLastError(ERROR_INVALID_PARAMETER_W); //TODO: wrong error
|
|---|
| 1092 | return ERROR_W;
|
|---|
| 1093 | }
|
|---|
| 1094 | }
|
|---|
| 1095 |
|
|---|
| 1096 | //todo metafile recording
|
|---|
| 1097 |
|
|---|
| 1098 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 1099 | return lComplexity;
|
|---|
| 1100 | }
|
|---|
| 1101 | //******************************************************************************
|
|---|
| 1102 | //******************************************************************************
|
|---|
| 1103 | int WIN32API OffsetClipRgn(HDC hdc, int nXOffset, int nYOffset )
|
|---|
| 1104 | {
|
|---|
| 1105 | BOOL success;
|
|---|
| 1106 | pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
|
|---|
| 1107 | LONG lComplexity;
|
|---|
| 1108 |
|
|---|
| 1109 | if(!pHps) {
|
|---|
| 1110 | dprintf(("OffsetClipRgn %x (%d,%d) invalid hdc", hdc, nXOffset, nYOffset));
|
|---|
| 1111 | SetLastError(ERROR_INVALID_HANDLE_W);
|
|---|
| 1112 | return ERROR_W;
|
|---|
| 1113 | }
|
|---|
| 1114 |
|
|---|
| 1115 | dprintf(("OffsetClipRgn %x (%d,%d)", hdc, nXOffset, nYOffset));
|
|---|
| 1116 | POINTL pointl = { nXOffset, nYOffset };
|
|---|
| 1117 | #ifndef INVERT
|
|---|
| 1118 | if (pHps->yInvert > 0) {
|
|---|
| 1119 | pointl.y = pHps->yInvert - pointl.y;
|
|---|
| 1120 | }
|
|---|
| 1121 | #endif
|
|---|
| 1122 |
|
|---|
| 1123 | if(pHps->hrgnWin32Clip == NULLHANDLE) {
|
|---|
| 1124 | lComplexity = NULLREGION_W;
|
|---|
| 1125 | }
|
|---|
| 1126 | else {
|
|---|
| 1127 | lComplexity = GpiOffsetRegion(pHps->hps, pHps->hrgnWin32Clip, &pointl);
|
|---|
| 1128 | if (lComplexity == RGN_ERROR) {
|
|---|
| 1129 | dprintf(("ERROR: OffsetClipRgn: GpiOffsetRegion failed!!"));
|
|---|
| 1130 | SetLastError(ERROR_INVALID_PARAMETER_W); //TODO: wrong error
|
|---|
| 1131 | return ERROR_W;
|
|---|
| 1132 | }
|
|---|
| 1133 |
|
|---|
| 1134 | //Intersect the Windows clip region with the current visible region
|
|---|
| 1135 | lComplexity = GdiCombineVisRgnClipRgn(pHps, pHps->hrgnWin32Clip, RGN_AND_W);
|
|---|
| 1136 |
|
|---|
| 1137 | lComplexity = GPI_TO_WIN_COMPLEXITY(lComplexity);
|
|---|
| 1138 | }
|
|---|
| 1139 |
|
|---|
| 1140 | //todo metafile recording
|
|---|
| 1141 |
|
|---|
| 1142 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 1143 | return lComplexity;
|
|---|
| 1144 | }
|
|---|
| 1145 | //******************************************************************************
|
|---|
| 1146 | //******************************************************************************
|
|---|
| 1147 | HRGN WIN32API CreatePolyPolygonRgn(const POINT *lppt, const int *pPolyCount,
|
|---|
| 1148 | int nCount, int fnPolyFillMode)
|
|---|
| 1149 | {
|
|---|
| 1150 | LONG flMode;
|
|---|
| 1151 |
|
|---|
| 1152 | switch(fnPolyFillMode)
|
|---|
| 1153 | {
|
|---|
| 1154 | case ALTERNATE_W:
|
|---|
| 1155 | flMode = POLYGON_ALTERNATE;
|
|---|
| 1156 | break;
|
|---|
| 1157 | case WINDING_W:
|
|---|
| 1158 | flMode = POLYGON_WINDING;
|
|---|
| 1159 | break;
|
|---|
| 1160 | default:
|
|---|
| 1161 | dprintf(("WARNING: CreatePolyPolygonRgn %x %x %d %d invalid parameter", lppt, pPolyCount, nCount, fnPolyFillMode));
|
|---|
| 1162 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 1163 | return 0;
|
|---|
| 1164 | }
|
|---|
| 1165 |
|
|---|
| 1166 | if(nCount < 1)
|
|---|
| 1167 | {
|
|---|
| 1168 | dprintf(("WARNING: CreatePolyPolygonRgn %x %x %d %d invalid parameter", lppt, pPolyCount, nCount, fnPolyFillMode));
|
|---|
| 1169 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 1170 | return 0;
|
|---|
| 1171 | }
|
|---|
| 1172 |
|
|---|
| 1173 | PPOLYGON pPolygon = new POLYGON[nCount];
|
|---|
| 1174 | if(!pPolygon) {
|
|---|
| 1175 | dprintf(("ERROR: CreatePolyPolygonRgn: out of memory!!"));
|
|---|
| 1176 | SetLastError(ERROR_OUTOFMEMORY_W);
|
|---|
| 1177 | return 0;
|
|---|
| 1178 | }
|
|---|
| 1179 | dprintf(("CreatePolyPolygonRgn %x %x %d %d", lppt, pPolyCount, nCount, fnPolyFillMode));
|
|---|
| 1180 |
|
|---|
| 1181 | PPOINTL pPointl = (PPOINTL)lppt+1; // skip first point
|
|---|
| 1182 | for (int x=0; x < nCount; x++) {
|
|---|
| 1183 | pPolygon[x].ulPoints = (x == 0) ? pPolyCount[x] - 1 : pPolyCount[x];
|
|---|
| 1184 | pPolygon[x].aPointl = pPointl;
|
|---|
| 1185 | pPointl += pPolygon[x].ulPoints;
|
|---|
| 1186 | }
|
|---|
| 1187 | GpiMove(hpsRegion, (PPOINTL)lppt);
|
|---|
| 1188 | HRGN hrgn = GpiCreatePolygonRegion(hpsRegion, nCount, pPolygon, POLYGON_BOUNDARY | flMode);
|
|---|
| 1189 |
|
|---|
| 1190 | delete[] pPolygon;
|
|---|
| 1191 |
|
|---|
| 1192 | if(!hrgn) {
|
|---|
| 1193 | SetLastError(ERROR_INVALID_PARAMETER_W); //todo: not right
|
|---|
| 1194 | return 0;
|
|---|
| 1195 | }
|
|---|
| 1196 |
|
|---|
| 1197 | if(ObjAllocateHandle(&hrgn, hrgn, HNDL_REGION) == FALSE) {
|
|---|
| 1198 | GpiDestroyRegion(hpsRegion, hrgn);
|
|---|
| 1199 | SetLastError(ERROR_OUTOFMEMORY_W);
|
|---|
| 1200 | return 0;
|
|---|
| 1201 | }
|
|---|
| 1202 | STATS_CreatePolyPolygonRgn(hrgn, lppt, pPolyCount, nCount, fnPolyFillMode);
|
|---|
| 1203 |
|
|---|
| 1204 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 1205 | return hrgn;
|
|---|
| 1206 | }
|
|---|
| 1207 | //******************************************************************************
|
|---|
| 1208 | //******************************************************************************
|
|---|
| 1209 | HRGN WIN32API CreateRectRgn(int left, int top, int right, int bottom)
|
|---|
| 1210 | {
|
|---|
| 1211 | HRGN hrgn;
|
|---|
| 1212 | RECTL rectl = { left, top < bottom ? top : bottom, right, top < bottom ? bottom : top };
|
|---|
| 1213 |
|
|---|
| 1214 | hrgn = GpiCreateRegion(hpsRegion, 1, &rectl);
|
|---|
| 1215 | if(!hrgn) {
|
|---|
| 1216 | dprintf(("WARNING: CreateRectRgn: GpiCreateRectRegion failed! %x", WinGetLastError(0)));
|
|---|
| 1217 | SetLastError(ERROR_INVALID_PARAMETER_W); //todo: not right
|
|---|
| 1218 | return 0;
|
|---|
| 1219 | }
|
|---|
| 1220 |
|
|---|
| 1221 | if(ObjAllocateHandle(&hrgn, hrgn, HNDL_REGION) == FALSE) {
|
|---|
| 1222 | GpiDestroyRegion(hpsRegion, hrgn);
|
|---|
| 1223 | SetLastError(ERROR_OUTOFMEMORY_W);
|
|---|
| 1224 | return 0;
|
|---|
| 1225 | }
|
|---|
| 1226 | STATS_CreateRectRgn(hrgn, left, top, right, bottom);
|
|---|
| 1227 |
|
|---|
| 1228 | dprintf(("CreateRectRegion (%d,%d)(%d,%d) returned %x", left, top, right, bottom, hrgn));
|
|---|
| 1229 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 1230 | return hrgn;
|
|---|
| 1231 | }
|
|---|
| 1232 | //******************************************************************************
|
|---|
| 1233 | //******************************************************************************
|
|---|
| 1234 | HRGN WIN32API CreateRectRgnIndirect( const RECT * lprc)
|
|---|
| 1235 | {
|
|---|
| 1236 | return CreateRectRgn(lprc->left, lprc->top, lprc->right, lprc->bottom);
|
|---|
| 1237 | }
|
|---|
| 1238 | //******************************************************************************
|
|---|
| 1239 | //******************************************************************************
|
|---|
| 1240 | HRGN WIN32API CreateRoundRectRgn(int left, int top, int right, int bottom, int nWidthEllipse, int nHeightEllipse)
|
|---|
| 1241 | {
|
|---|
| 1242 | HRGN hrgn;
|
|---|
| 1243 | RECTL rectl = { left, top < bottom ? top : bottom, right, top < bottom ? bottom : top };
|
|---|
| 1244 |
|
|---|
| 1245 | PPOINTL pPointl = (PPOINTL)&rectl;
|
|---|
| 1246 |
|
|---|
| 1247 | GpiMove(hpsRegion, &pPointl[0]);
|
|---|
| 1248 | hrgn = GpiCreateRoundRectRegion(hpsRegion, &pPointl[1], labs(nWidthEllipse), labs(nHeightEllipse));
|
|---|
| 1249 |
|
|---|
| 1250 | if(!hrgn) {
|
|---|
| 1251 | SetLastError(ERROR_INVALID_PARAMETER_W); //todo: not right
|
|---|
| 1252 | dprintf(("WARNING: CreateRoundRectRgn: GpiCreateRoundRectRegion failed! %x", WinGetLastError(0)));
|
|---|
| 1253 | return 0;
|
|---|
| 1254 | }
|
|---|
| 1255 |
|
|---|
| 1256 | if(ObjAllocateHandle(&hrgn, hrgn, HNDL_REGION) == FALSE) {
|
|---|
| 1257 | GpiDestroyRegion(hpsRegion, hrgn);
|
|---|
| 1258 | SetLastError(ERROR_OUTOFMEMORY_W);
|
|---|
| 1259 | return 0;
|
|---|
| 1260 | }
|
|---|
| 1261 | STATS_CreateRoundRectRgn(hrgn, left, top, right, bottom, nWidthEllipse, nHeightEllipse);
|
|---|
| 1262 |
|
|---|
| 1263 | dprintf(("CreateRoundRectRegion (%d,%d)(%d,%d) (%d,%d) returned %x", left, top, right, bottom, nWidthEllipse, nHeightEllipse, hrgn));
|
|---|
| 1264 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 1265 | return hrgn;
|
|---|
| 1266 | }
|
|---|
| 1267 | //******************************************************************************
|
|---|
| 1268 | //******************************************************************************
|
|---|
| 1269 | HRGN WIN32API ExtCreateRegion(const XFORM_W * pXform, DWORD count,
|
|---|
| 1270 | const RGNDATA * pData)
|
|---|
| 1271 | {
|
|---|
| 1272 | HRGN hrgn;
|
|---|
| 1273 |
|
|---|
| 1274 | if(!pData || count < (sizeof(RGNDATAHEADER) + pData->rdh.nCount * sizeof(RECT))) {
|
|---|
| 1275 | dprintf(("WARNING: ExtCreateRegion %x %d %x; invalid parameter", pXform, count, pData));
|
|---|
| 1276 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 1277 | return 0;
|
|---|
| 1278 | }
|
|---|
| 1279 |
|
|---|
| 1280 | PRECTL pRectl = new RECTL[pData->rdh.nCount];
|
|---|
| 1281 | PRECT pDataRects = (PRECT)pData->Buffer;
|
|---|
| 1282 | for(int i=0; i < pData->rdh.nCount; i++) {
|
|---|
| 1283 | MapWin32ToOS2Rect(pDataRects[i], pRectl[i]);
|
|---|
| 1284 | }
|
|---|
| 1285 |
|
|---|
| 1286 | BOOL doShear = pXform && (pXform->eM12 || pXform->eM21);
|
|---|
| 1287 | HPS hpsTemp = NULLHANDLE;
|
|---|
| 1288 |
|
|---|
| 1289 | dprintf(("ExtCreateRegion %x %d %x", pXform, count, pData));
|
|---|
| 1290 | if(doShear) {
|
|---|
| 1291 | hpsTemp = WinGetPS(HWND_DESKTOP);
|
|---|
| 1292 | GpiBeginPath(hpsTemp, 1);
|
|---|
| 1293 |
|
|---|
| 1294 | MATRIXLF matrixlf;
|
|---|
| 1295 | matrixlf.fxM11 = pXform->eM11 * (float)0x10000;
|
|---|
| 1296 | matrixlf.fxM12 = pXform->eM12 * (float)0x10000;
|
|---|
| 1297 | matrixlf.lM13 = 0;
|
|---|
| 1298 | matrixlf.fxM21 = pXform->eM21 * (float)0x10000;
|
|---|
| 1299 | matrixlf.fxM22 = pXform->eM22 * (float)0x10000;
|
|---|
| 1300 | matrixlf.lM23 = 0;
|
|---|
| 1301 | matrixlf.lM31 = pXform->eDx;
|
|---|
| 1302 | matrixlf.lM32 = pXform->eDy;
|
|---|
| 1303 | matrixlf.lM33 = 1;
|
|---|
| 1304 |
|
|---|
| 1305 | GpiSetModelTransformMatrix(hpsTemp, 9, &matrixlf, TRANSFORM_REPLACE);
|
|---|
| 1306 | }
|
|---|
| 1307 |
|
|---|
| 1308 | for(i=0; i < pData->rdh.nCount; i++)
|
|---|
| 1309 | {
|
|---|
| 1310 | LONG temp = pRectl[i].yTop;
|
|---|
| 1311 | pRectl[i].yTop = pRectl[i].yBottom;
|
|---|
| 1312 | pRectl[i].yBottom = temp;
|
|---|
| 1313 |
|
|---|
| 1314 | if(pXform)
|
|---|
| 1315 | {
|
|---|
| 1316 | PPOINTL pPointl = ((PPOINTL)&pRectl[i]);
|
|---|
| 1317 |
|
|---|
| 1318 | if (doShear) {
|
|---|
| 1319 | GpiMove(hpsTemp, pPointl);
|
|---|
| 1320 | GpiBox(hpsTemp, DRO_OUTLINE, pPointl+1, 0, 0);
|
|---|
| 1321 | }
|
|---|
| 1322 | else
|
|---|
| 1323 | {
|
|---|
| 1324 | for(int j=0; j < 2; j++) {
|
|---|
| 1325 | pPointl[j].x = (pXform->eM11 * (float)pPointl[j].x) + (pXform->eM12 * (float)pPointl[j].y) + pXform->eDx;
|
|---|
| 1326 | pPointl[j].y = (pXform->eM21 * (float)pPointl[j].x) + (pXform->eM22 * (float)pPointl[j].y) + pXform->eDy;
|
|---|
| 1327 | }
|
|---|
| 1328 |
|
|---|
| 1329 | PRECTL pRectlT = (PRECTL)pPointl;
|
|---|
| 1330 | if (pRectlT->xLeft > pRectlT->xRight) {
|
|---|
| 1331 | LONG temp = pRectlT->xLeft;
|
|---|
| 1332 | pRectlT->xLeft = pRectlT->xRight;
|
|---|
| 1333 | pRectlT->xRight = temp;
|
|---|
| 1334 | }
|
|---|
| 1335 | if (pRectlT->yBottom > pRectlT->yTop) {
|
|---|
| 1336 | LONG temp = pRectlT->yBottom;
|
|---|
| 1337 | pRectlT->yBottom = pRectlT->yTop;
|
|---|
| 1338 | pRectlT->yTop = temp;
|
|---|
| 1339 | }
|
|---|
| 1340 | }
|
|---|
| 1341 | }
|
|---|
| 1342 | }
|
|---|
| 1343 |
|
|---|
| 1344 | if(doShear) {
|
|---|
| 1345 | GpiEndPath(hpsTemp);
|
|---|
| 1346 | hrgn = GpiPathToRegion(hpsTemp, 1, FPATH_WINDING);
|
|---|
| 1347 |
|
|---|
| 1348 | if(pRectl)
|
|---|
| 1349 | delete[] pRectl;
|
|---|
| 1350 |
|
|---|
| 1351 | if(hrgn == 0) {
|
|---|
| 1352 | dprintf(("WARNING: ExtCreateRegion GpiCreateRegion failed! (%x)", WinGetLastError(0)));
|
|---|
| 1353 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 1354 | return 0;
|
|---|
| 1355 | }
|
|---|
| 1356 | WinReleasePS(hpsTemp);
|
|---|
| 1357 | }
|
|---|
| 1358 | else {
|
|---|
| 1359 | hrgn = GpiCreateRegion(hpsRegion, pData->rdh.nCount, pRectl);
|
|---|
| 1360 | if(pRectl)
|
|---|
| 1361 | delete[] pRectl;
|
|---|
| 1362 |
|
|---|
| 1363 | if(hrgn == 0) {
|
|---|
| 1364 | dprintf(("WARNING: ExtCreateRegion GpiCreateRegion failed! (%x)", WinGetLastError(0)));
|
|---|
| 1365 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 1366 | return 0;
|
|---|
| 1367 | }
|
|---|
| 1368 | }
|
|---|
| 1369 |
|
|---|
| 1370 | if(ObjAllocateHandle(&hrgn, hrgn, HNDL_REGION) == FALSE) {
|
|---|
| 1371 | GpiDestroyRegion(hpsRegion, hrgn);
|
|---|
| 1372 | SetLastError(ERROR_OUTOFMEMORY_W);
|
|---|
| 1373 | return 0;
|
|---|
| 1374 | }
|
|---|
| 1375 | STATS_ExtCreateRegion(hrgn, (PVOID)pXform, count, pData);
|
|---|
| 1376 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 1377 | return hrgn;
|
|---|
| 1378 | }
|
|---|
| 1379 | //******************************************************************************
|
|---|
| 1380 | //******************************************************************************
|
|---|
| 1381 | HRGN WIN32API CreateEllipticRgn(int left, int top, int right, int bottom)
|
|---|
| 1382 | {
|
|---|
| 1383 | HRGN hrgn;
|
|---|
| 1384 |
|
|---|
| 1385 | RECTL rectl = { left,
|
|---|
| 1386 | top < bottom ? top : bottom,
|
|---|
| 1387 | right,
|
|---|
| 1388 | top < bottom ? bottom : top };
|
|---|
| 1389 |
|
|---|
| 1390 | dprintf(("CreateEllipticRgn (%d,%d)(%d,%d)", left, top, right, bottom));
|
|---|
| 1391 | hrgn = GpiCreateEllipticRegion(hpsRegion, &rectl);
|
|---|
| 1392 | if(hrgn == RGN_ERROR) {
|
|---|
| 1393 | SetLastError(ERROR_INVALID_PARAMETER_W); //todo: not right
|
|---|
| 1394 | dprintf(("WARNING: CreateEllipticRgn: GpiCreateEllipticRegion failed! %x", WinGetLastError(0)));
|
|---|
| 1395 | return 0;
|
|---|
| 1396 | }
|
|---|
| 1397 |
|
|---|
| 1398 | if(ObjAllocateHandle(&hrgn, hrgn, HNDL_REGION) == FALSE) {
|
|---|
| 1399 | GpiDestroyRegion(hpsRegion, hrgn);
|
|---|
| 1400 | SetLastError(ERROR_OUTOFMEMORY_W);
|
|---|
| 1401 | return 0;
|
|---|
| 1402 | }
|
|---|
| 1403 | STATS_CreateEllipticRgn(hrgn, left, top, right, bottom);
|
|---|
| 1404 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 1405 | return hrgn;
|
|---|
| 1406 | }
|
|---|
| 1407 | //******************************************************************************
|
|---|
| 1408 | //******************************************************************************
|
|---|
| 1409 | HRGN WIN32API CreateEllipticRgnIndirect(const RECT *pRect)
|
|---|
| 1410 | {
|
|---|
| 1411 | return CreateEllipticRgn(pRect->left, pRect->top, pRect->right, pRect->bottom);
|
|---|
| 1412 | }
|
|---|
| 1413 | //******************************************************************************
|
|---|
| 1414 | //******************************************************************************
|
|---|
| 1415 | HRGN WIN32API CreatePolygonRgn(const POINT * lppt, int cPoints, int fnPolyFillMode)
|
|---|
| 1416 | {
|
|---|
| 1417 | HRGN hrgn;
|
|---|
| 1418 | LONG flMode;
|
|---|
| 1419 |
|
|---|
| 1420 | if(!lppt || cPoints < 2) {
|
|---|
| 1421 | dprintf(("WARNING: CreatePolygonRgn %x %d %d invalid parameter", lppt, cPoints, fnPolyFillMode));
|
|---|
| 1422 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 1423 | return 0;
|
|---|
| 1424 | }
|
|---|
| 1425 |
|
|---|
| 1426 | switch (fnPolyFillMode)
|
|---|
| 1427 | {
|
|---|
| 1428 | case ALTERNATE_W :
|
|---|
| 1429 | flMode = POLYGON_ALTERNATE;
|
|---|
| 1430 | break;
|
|---|
| 1431 | case WINDING_W :
|
|---|
| 1432 | flMode = POLYGON_WINDING;
|
|---|
| 1433 | break;
|
|---|
| 1434 | default:
|
|---|
| 1435 | dprintf(("WARNING: CreatePolygonRgn %x %d %d invalid parameter", lppt, cPoints, fnPolyFillMode));
|
|---|
| 1436 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 1437 | return 0;
|
|---|
| 1438 | }
|
|---|
| 1439 | dprintf(("CreatePolygonRgn %x %d %d", lppt, cPoints, fnPolyFillMode));
|
|---|
| 1440 |
|
|---|
| 1441 | POLYGON polygon;
|
|---|
| 1442 | polygon.ulPoints = cPoints - 1;
|
|---|
| 1443 | polygon.aPointl = (PPOINTL)(lppt + 1);
|
|---|
| 1444 |
|
|---|
| 1445 | #ifdef DEBUG
|
|---|
| 1446 | for(int i=0;i<cPoints;i++) {
|
|---|
| 1447 | dprintf(("Point %d: (%d,%d)", i, lppt[i].x, lppt[i].y));
|
|---|
| 1448 | }
|
|---|
| 1449 | #endif
|
|---|
| 1450 | GpiMove(hpsRegion, (PPOINTL)lppt);
|
|---|
| 1451 | hrgn = GpiCreatePolygonRegion(hpsRegion, 1, &polygon, POLYGON_BOUNDARY | flMode);
|
|---|
| 1452 | if(hrgn == RGN_ERROR) {
|
|---|
| 1453 | SetLastError(ERROR_INVALID_PARAMETER_W); //todo: not right
|
|---|
| 1454 | dprintf(("WARNING: CreatePolygonRgn: GpiCreatePolygonRegion failed! %x", WinGetLastError(0)));
|
|---|
| 1455 | return 0;
|
|---|
| 1456 | }
|
|---|
| 1457 |
|
|---|
| 1458 | if(ObjAllocateHandle(&hrgn, hrgn, HNDL_REGION) == FALSE) {
|
|---|
| 1459 | GpiDestroyRegion(hpsRegion, hrgn);
|
|---|
| 1460 | SetLastError(ERROR_OUTOFMEMORY_W);
|
|---|
| 1461 | return 0;
|
|---|
| 1462 | }
|
|---|
| 1463 | STATS_CreatePolygonRgn(hrgn, lppt, cPoints, fnPolyFillMode);
|
|---|
| 1464 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 1465 | return hrgn;
|
|---|
| 1466 | }
|
|---|
| 1467 | //******************************************************************************
|
|---|
| 1468 | //******************************************************************************
|
|---|
| 1469 | int WIN32API CombineRgn(HRGN hrgnDest, HRGN hrgnSrc1, HRGN hrgnSrc2, int combineMode)
|
|---|
| 1470 | {
|
|---|
| 1471 | ULONG lComplexity;
|
|---|
| 1472 | LONG mode;
|
|---|
| 1473 | #ifdef DEBUG
|
|---|
| 1474 | HRGN hrgn1 = hrgnDest;
|
|---|
| 1475 | HRGN hrgn2 = hrgnSrc1;
|
|---|
| 1476 | HRGN hrgn3 = hrgnSrc2;
|
|---|
| 1477 | #endif
|
|---|
| 1478 |
|
|---|
| 1479 | switch(combineMode) {
|
|---|
| 1480 | case RGN_AND_W:
|
|---|
| 1481 | mode = CRGN_AND;
|
|---|
| 1482 | break;
|
|---|
| 1483 | case RGN_COPY_W:
|
|---|
| 1484 | mode = CRGN_COPY;
|
|---|
| 1485 | break;
|
|---|
| 1486 | case RGN_DIFF_W:
|
|---|
| 1487 | mode = CRGN_DIFF;
|
|---|
| 1488 | break;
|
|---|
| 1489 | case RGN_OR_W:
|
|---|
| 1490 | mode = CRGN_OR;
|
|---|
| 1491 | break;
|
|---|
| 1492 | case RGN_XOR_W:
|
|---|
| 1493 | mode = CRGN_XOR;
|
|---|
| 1494 | break;
|
|---|
| 1495 | default:
|
|---|
| 1496 | dprintf(("WARNING: CombineRgn %x %x %x %d; invalid mode!", hrgnDest, hrgnSrc1, hrgnSrc2, combineMode));
|
|---|
| 1497 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 1498 | return ERROR_W;
|
|---|
| 1499 | }
|
|---|
| 1500 |
|
|---|
| 1501 | hrgnDest = ObjQueryHandleData(hrgnDest, HNDL_REGION);
|
|---|
| 1502 | hrgnSrc1 = ObjQueryHandleData(hrgnSrc1, HNDL_REGION);
|
|---|
| 1503 | hrgnSrc2 = ObjQueryHandleData(hrgnSrc2, HNDL_REGION);
|
|---|
| 1504 | if(hrgnDest == HANDLE_OBJ_ERROR || hrgnSrc1 == HANDLE_OBJ_ERROR || (hrgnSrc2 == HANDLE_OBJ_ERROR && combineMode != RGN_COPY_W)) {
|
|---|
| 1505 | dprintf(("WARNING: CombineRgn %x %x %x %d invalid region", hrgn1, hrgn2, hrgn3, combineMode));
|
|---|
| 1506 | SetLastError(ERROR_INVALID_HANDLE_W);
|
|---|
| 1507 | return ERROR_W;
|
|---|
| 1508 | }
|
|---|
| 1509 |
|
|---|
| 1510 | lComplexity = GpiCombineRegion(hpsRegion, hrgnDest, hrgnSrc1, hrgnSrc2, mode);
|
|---|
| 1511 | if(lComplexity == RGN_ERROR) {
|
|---|
| 1512 | dprintf(("WARNING: CombineRgn %x %x %x %d GpiCombineRegion failed (%x)", hrgn1, hrgn2, hrgn3, mode, WinGetLastError(0)));
|
|---|
| 1513 | SetLastError(ERROR_INVALID_HANDLE_W);
|
|---|
| 1514 | return ERROR_W;
|
|---|
| 1515 | }
|
|---|
| 1516 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 1517 | return lComplexity;
|
|---|
| 1518 | }
|
|---|
| 1519 | //******************************************************************************
|
|---|
| 1520 | //******************************************************************************
|
|---|
| 1521 | BOOL WIN32API EqualRgn(HRGN hrgn1, HRGN hrgn2)
|
|---|
| 1522 | {
|
|---|
| 1523 | LONG lEquality;
|
|---|
| 1524 | #ifdef DEBUG
|
|---|
| 1525 | HRGN hrgnt1 = hrgn1;
|
|---|
| 1526 | HRGN hrgnt2 = hrgn2;
|
|---|
| 1527 | #endif
|
|---|
| 1528 |
|
|---|
| 1529 | hrgn1 = ObjQueryHandleData(hrgn1, HNDL_REGION);
|
|---|
| 1530 | hrgn2 = ObjQueryHandleData(hrgn2, HNDL_REGION);
|
|---|
| 1531 | if(hrgn1 == HANDLE_OBJ_ERROR || hrgn2 == HANDLE_OBJ_ERROR) {
|
|---|
| 1532 | dprintf(("WARNING: EqualRgn %x %x invalid region", hrgnt1, hrgnt2));
|
|---|
| 1533 | SetLastError(ERROR_INVALID_HANDLE_W);
|
|---|
| 1534 | return FALSE;
|
|---|
| 1535 | }
|
|---|
| 1536 | lEquality = GpiEqualRegion(hpsRegion, hrgn1, hrgn2);
|
|---|
| 1537 |
|
|---|
| 1538 | dprintf(("EqualRgn %x %x = %d", hrgnt1, hrgnt2, lEquality));
|
|---|
| 1539 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 1540 |
|
|---|
| 1541 | if(lEquality == EQRGN_EQUAL)
|
|---|
| 1542 | return TRUE;
|
|---|
| 1543 | else
|
|---|
| 1544 | if(lEquality == EQRGN_NOTEQUAL)
|
|---|
| 1545 | return FALSE;
|
|---|
| 1546 | else {
|
|---|
| 1547 | return FALSE;
|
|---|
| 1548 | }
|
|---|
| 1549 | }
|
|---|
| 1550 | //******************************************************************************
|
|---|
| 1551 | //******************************************************************************
|
|---|
| 1552 | BOOL WIN32API SetRectRgn(HRGN hrgn, int left, int top, int right, int bottom)
|
|---|
| 1553 | {
|
|---|
| 1554 | BOOL result = FALSE;
|
|---|
| 1555 | #ifdef DEBUG
|
|---|
| 1556 | HRGN hrgn1 = hrgn;
|
|---|
| 1557 | #endif
|
|---|
| 1558 |
|
|---|
| 1559 | hrgn = ObjQueryHandleData(hrgn, HNDL_REGION);
|
|---|
| 1560 | if(hrgn == HANDLE_OBJ_ERROR) {
|
|---|
| 1561 | dprintf(("WARNING: SetRectRgn %x (%d,%d)(%d,%d) invalid region handle", hrgn1, left, top, right, bottom));
|
|---|
| 1562 | SetLastError(ERROR_INVALID_HANDLE_W);
|
|---|
| 1563 | return 0;
|
|---|
| 1564 | }
|
|---|
| 1565 | RECTL rectl = { left, top, right, bottom }; //reversed y coordinates
|
|---|
| 1566 | if(GpiSetRegion(hpsRegion, hrgn, 1, &rectl)) {
|
|---|
| 1567 | dprintf(("SetRectRgn %x (%d,%d)(%d,%d)", hrgn1, left, top, right, bottom));
|
|---|
| 1568 | return TRUE;
|
|---|
| 1569 | }
|
|---|
| 1570 | dprintf(("WARNING: SetRectRgn %x (%d,%d)(%d,%d) GpiSetRegion failed %x", hrgn1, left, top, right, bottom, WinGetLastError(0)));
|
|---|
| 1571 | return FALSE;
|
|---|
| 1572 | }
|
|---|
| 1573 | //******************************************************************************
|
|---|
| 1574 | //NOTE: depends on hps inversion
|
|---|
| 1575 | //******************************************************************************
|
|---|
| 1576 | ULONG WIN32API GetRegionData( HRGN hrgn, ULONG count, PRGNDATA pData)
|
|---|
| 1577 | {
|
|---|
| 1578 | #ifdef DEBUG
|
|---|
| 1579 | HRGN hrgn1 = hrgn;
|
|---|
| 1580 | #endif
|
|---|
| 1581 |
|
|---|
| 1582 | if(!count && pData)
|
|---|
| 1583 | {
|
|---|
| 1584 | dprintf(("WARNING: GetRegionData %x %d %x; invalid parameter", hrgn1, count, pData));
|
|---|
| 1585 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 1586 | return 0;
|
|---|
| 1587 | }
|
|---|
| 1588 | hrgn = ObjQueryHandleData(hrgn, HNDL_REGION);
|
|---|
| 1589 | if(hrgn == HANDLE_OBJ_ERROR) {
|
|---|
| 1590 | dprintf(("WARNING: GetRegionData %x %d %x; invalid region handle", hrgn1, count, pData));
|
|---|
| 1591 | SetLastError(ERROR_INVALID_HANDLE_W);
|
|---|
| 1592 | return 0;
|
|---|
| 1593 | }
|
|---|
| 1594 | RGNRECT rgnRect;
|
|---|
| 1595 | rgnRect.ircStart = 1;
|
|---|
| 1596 | rgnRect.crc = 0;
|
|---|
| 1597 | rgnRect.ulDirection = RECTDIR_LFRT_TOPBOT;
|
|---|
| 1598 | if(!GpiQueryRegionRects(hpsRegion, hrgn, NULL, &rgnRect, NULL))
|
|---|
| 1599 | {
|
|---|
| 1600 | dprintf(("WARNING: GetRegionData %x %d %x: GpiQueryRegionRects failed! (%x)", hrgn1, count, pData, WinGetLastError(0)));
|
|---|
| 1601 | return 0;
|
|---|
| 1602 | }
|
|---|
| 1603 |
|
|---|
| 1604 | dprintf(("GetRegionData %x %d %x", hrgn1, count, pData));
|
|---|
| 1605 |
|
|---|
| 1606 | ULONG bufSizeNeeded = rgnRect.crcReturned * sizeof(RECT) + sizeof (RGNDATAHEADER);
|
|---|
| 1607 |
|
|---|
| 1608 | if(pData && (count >= (sizeof(RGNDATAHEADER) + rgnRect.crcReturned * sizeof(RECT))))
|
|---|
| 1609 | {
|
|---|
| 1610 | //we actually need to flip the top & bottom values, but as the layout of the PM RECTL and
|
|---|
| 1611 | //Win32 RECT have exactly those two members reversed, we don't do this for the returned
|
|---|
| 1612 | //rectangles (more efficient)
|
|---|
| 1613 | PRECTL pRectl = (PRECTL)pData->Buffer;
|
|---|
| 1614 | rgnRect.crc = rgnRect.crcReturned;
|
|---|
| 1615 | if(!GpiQueryRegionRects(hpsRegion, hrgn, NULL, &rgnRect, pRectl))
|
|---|
| 1616 | {
|
|---|
| 1617 | dprintf(("WARNING: GetRegionData: GpiQueryRegionRects failed! (%x)", WinGetLastError(0)));
|
|---|
| 1618 | return 0;
|
|---|
| 1619 | }
|
|---|
| 1620 |
|
|---|
| 1621 | RECTL boundRect;
|
|---|
| 1622 | GpiQueryRegionBox(hpsRegion, hrgn, &boundRect); // no need to check rc
|
|---|
| 1623 |
|
|---|
| 1624 | pData->rdh.dwSize = sizeof(pData->rdh);
|
|---|
| 1625 | pData->rdh.iType = RDH_RECTANGLES_W; // one and only possible value
|
|---|
| 1626 | pData->rdh.nCount = rgnRect.crcReturned;
|
|---|
| 1627 | pData->rdh.nRgnSize = rgnRect.crcReturned * sizeof(RECT);
|
|---|
| 1628 |
|
|---|
| 1629 | //flip top & bottom for bounding rectangle (not really necessary; but cleaner coding)
|
|---|
| 1630 | LONG temp = boundRect.yTop;
|
|---|
| 1631 | boundRect.yTop = boundRect.yBottom;
|
|---|
| 1632 | boundRect.yBottom = temp;
|
|---|
| 1633 | MapOS2ToWin32Rect(boundRect, pData->rdh.rcBound);
|
|---|
| 1634 | }
|
|---|
| 1635 |
|
|---|
| 1636 | //return size needed
|
|---|
| 1637 | return bufSizeNeeded;
|
|---|
| 1638 | }
|
|---|
| 1639 | //******************************************************************************
|
|---|
| 1640 | //******************************************************************************
|
|---|
| 1641 | int WIN32API GetRgnBox( HRGN hrgn, PRECT pRect)
|
|---|
| 1642 | {
|
|---|
| 1643 | BOOL success;
|
|---|
| 1644 | LONG lComplexity;
|
|---|
| 1645 | #ifdef DEBUG
|
|---|
| 1646 | HRGN hrgn1 = hrgn;
|
|---|
| 1647 | #endif
|
|---|
| 1648 |
|
|---|
| 1649 | hrgn = ObjQueryHandleData(hrgn, HNDL_REGION);
|
|---|
| 1650 | if(hrgn == HANDLE_OBJ_ERROR) {
|
|---|
| 1651 | dprintf(("WARNING: GetRgnBox %x %x invalid region!", hrgn1, pRect));
|
|---|
| 1652 | SetLastError(ERROR_INVALID_HANDLE_W);
|
|---|
| 1653 | return ERROR_W;
|
|---|
| 1654 | }
|
|---|
| 1655 |
|
|---|
| 1656 | RECTL rectl;
|
|---|
| 1657 | lComplexity = GpiQueryRegionBox(hpsRegion, hrgn, &rectl);
|
|---|
| 1658 | if(lComplexity != RGN_ERROR)
|
|---|
| 1659 | {
|
|---|
| 1660 | //no conversion required, just flip top & bottom
|
|---|
| 1661 | ULONG temp = rectl.yBottom;
|
|---|
| 1662 | rectl.yBottom = rectl.yTop;
|
|---|
| 1663 | rectl.yTop = temp;
|
|---|
| 1664 |
|
|---|
| 1665 | MapOS2ToWin32Rect(rectl, *pRect);
|
|---|
| 1666 | }
|
|---|
| 1667 | else {
|
|---|
| 1668 | lComplexity = ERROR_W;
|
|---|
| 1669 | dprintf(("WARNING: GetRgnBox error in region!"));
|
|---|
| 1670 | }
|
|---|
| 1671 | dprintf(("GetRgnBox %x (%d,%d)(%d,%d)", hrgn1, pRect->left, pRect->top, pRect->right, pRect->bottom));
|
|---|
| 1672 |
|
|---|
| 1673 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 1674 | return lComplexity;
|
|---|
| 1675 | }
|
|---|
| 1676 | //******************************************************************************
|
|---|
| 1677 | //******************************************************************************
|
|---|
| 1678 | BOOL WIN32API InvertRgn( HDC hdc, HRGN hrgn)
|
|---|
| 1679 | {
|
|---|
| 1680 | #ifdef DEBUG
|
|---|
| 1681 | HRGN hrgn1 = hrgn;
|
|---|
| 1682 | #endif
|
|---|
| 1683 | pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
|
|---|
| 1684 |
|
|---|
| 1685 | hrgn = ObjQueryHandleData(hrgn, HNDL_REGION);
|
|---|
| 1686 | if(!pHps || hrgn == HANDLE_OBJ_ERROR) {
|
|---|
| 1687 | dprintf(("WARNING: InvertRgn %x %x invalid handle!", hdc, hrgn));
|
|---|
| 1688 | SetLastError(ERROR_INVALID_HANDLE_W);
|
|---|
| 1689 | return FALSE;
|
|---|
| 1690 | }
|
|---|
| 1691 | //todo metafile recording
|
|---|
| 1692 |
|
|---|
| 1693 | dprintf(("InvertRgn %x %x", hdc, hrgn1));
|
|---|
| 1694 |
|
|---|
| 1695 | interpretRegionAs(pHps, NULL, hrgn, AS_WORLD);
|
|---|
| 1696 |
|
|---|
| 1697 | LONG lHits = GPI_ERROR;
|
|---|
| 1698 | HRGN hrgnOld;
|
|---|
| 1699 | LONG lComplexity ;
|
|---|
| 1700 | RECTL boundingRect; // this gets a rectangle in world cordinates!
|
|---|
| 1701 |
|
|---|
| 1702 | lComplexity = GpiQueryRegionBox(pHps->hps, pHps->hrgnHDC, &boundingRect);
|
|---|
| 1703 | if(lComplexity != RGN_ERROR)
|
|---|
| 1704 | {
|
|---|
| 1705 | lComplexity = GpiSetClipRegion(pHps->hps, pHps->hrgnHDC, &hrgnOld);
|
|---|
| 1706 | if(lComplexity != RGN_ERROR)
|
|---|
| 1707 | {
|
|---|
| 1708 | RECTL rectls[2];
|
|---|
| 1709 | rectls[0] = boundingRect;
|
|---|
| 1710 | rectls[1] = boundingRect;
|
|---|
| 1711 | lHits = GpiBitBlt(pHps->hps, NULL, 3, (PPOINTL)rectls,
|
|---|
| 1712 | ROP_DSTINVERT, 0);
|
|---|
| 1713 |
|
|---|
| 1714 | /* Restore the old region */
|
|---|
| 1715 | GpiSetClipRegion(pHps->hps, hrgnOld, &hrgnOld);
|
|---|
| 1716 | }
|
|---|
| 1717 | }
|
|---|
| 1718 |
|
|---|
| 1719 | if(lHits == GPI_ERROR || lComplexity == RGN_ERROR)
|
|---|
| 1720 | {
|
|---|
| 1721 | dprintf(("WARNING: InvertRgn error during Gpi operation (%x) (%d,%d)", WinGetLastError(0), lHits, lComplexity));
|
|---|
| 1722 | return FALSE;
|
|---|
| 1723 | }
|
|---|
| 1724 |
|
|---|
| 1725 | DIBSECTION_MARK_INVALID(hdc);
|
|---|
| 1726 | return TRUE;
|
|---|
| 1727 | }
|
|---|
| 1728 | //******************************************************************************
|
|---|
| 1729 | //******************************************************************************
|
|---|
| 1730 | int WIN32API OffsetRgn( HRGN hrgn, int xOffset, int yOffset)
|
|---|
| 1731 | {
|
|---|
| 1732 | LONG lComplexity;
|
|---|
| 1733 | #ifdef DEBUG
|
|---|
| 1734 | HRGN hrgn1 = hrgn;
|
|---|
| 1735 | #endif
|
|---|
| 1736 |
|
|---|
| 1737 | hrgn = ObjQueryHandleData(hrgn, HNDL_REGION);
|
|---|
| 1738 | if(hrgn == HANDLE_OBJ_ERROR) {
|
|---|
| 1739 | dprintf(("WARNING: OffsetRgn %x %d %d invalid handle!", hrgn, xOffset, yOffset));
|
|---|
| 1740 | SetLastError(ERROR_INVALID_HANDLE_W);
|
|---|
| 1741 | return ERROR_W;
|
|---|
| 1742 | }
|
|---|
| 1743 | dprintf(("OffsetRgn %x %d %d", hrgn1, xOffset, yOffset));
|
|---|
| 1744 |
|
|---|
| 1745 | POINTL ptlOffset = {xOffset, yOffset};
|
|---|
| 1746 | GpiOffsetRegion(hpsRegion, hrgn, &ptlOffset);
|
|---|
| 1747 |
|
|---|
| 1748 | RECTL rectl[8];
|
|---|
| 1749 | RGNRECT rgnRect;
|
|---|
| 1750 | rgnRect.ircStart = 1;
|
|---|
| 1751 | rgnRect.crc = 8;
|
|---|
| 1752 | rgnRect.ulDirection = RECTDIR_LFRT_TOPBOT; // doesn't make a difference
|
|---|
| 1753 | if(GpiQueryRegionRects(hpsRegion, hrgn, NULL, &rgnRect, &rectl[0]))
|
|---|
| 1754 | {
|
|---|
| 1755 | switch (rgnRect.crcReturned) {
|
|---|
| 1756 | case 0:
|
|---|
| 1757 | lComplexity = NULLREGION_W;
|
|---|
| 1758 | break;
|
|---|
| 1759 | case 1:
|
|---|
| 1760 | lComplexity = SIMPLEREGION_W;
|
|---|
| 1761 | break;
|
|---|
| 1762 | default:
|
|---|
| 1763 | lComplexity = COMPLEXREGION_W;
|
|---|
| 1764 | break;
|
|---|
| 1765 | }
|
|---|
| 1766 | }
|
|---|
| 1767 | else {
|
|---|
| 1768 | lComplexity = ERROR_W;
|
|---|
| 1769 | dprintf(("WARNING: OffsetRgn error in region! (%x)", WinGetLastError(0)));
|
|---|
| 1770 | }
|
|---|
| 1771 |
|
|---|
| 1772 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 1773 |
|
|---|
| 1774 | return lComplexity;
|
|---|
| 1775 | }
|
|---|
| 1776 | //******************************************************************************
|
|---|
| 1777 | //******************************************************************************
|
|---|
| 1778 | BOOL WIN32API FrameRgn(HDC hdc, HRGN hrgn, HBRUSH hBrush, int width, int height)
|
|---|
| 1779 | {
|
|---|
| 1780 | HBRUSH hbrushRestore = 0;
|
|---|
| 1781 | #ifdef DEBUG
|
|---|
| 1782 | HRGN hrgn1 = hrgn;
|
|---|
| 1783 | #endif
|
|---|
| 1784 | pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
|
|---|
| 1785 |
|
|---|
| 1786 | hrgn = ObjQueryHandleData(hrgn, HNDL_REGION);
|
|---|
| 1787 | if(!pHps || hrgn == HANDLE_OBJ_ERROR) {
|
|---|
| 1788 | dprintf(("WARNING: FrameRgn %x %x %x (%d,%d) invalid handle!", hdc, hrgn, hBrush, width, height));
|
|---|
| 1789 | SetLastError(ERROR_INVALID_HANDLE_W);
|
|---|
| 1790 | return FALSE;
|
|---|
| 1791 | }
|
|---|
| 1792 |
|
|---|
| 1793 | width = abs(width);
|
|---|
| 1794 | height = abs(height);
|
|---|
| 1795 |
|
|---|
| 1796 | if(pHps->lastBrushKey != (UINT)hBrush)
|
|---|
| 1797 | {
|
|---|
| 1798 | hbrushRestore = SelectObject(hdc, hBrush);
|
|---|
| 1799 | if(!hbrushRestore)
|
|---|
| 1800 | {
|
|---|
| 1801 | dprintf(("WARNING: FrameRgn %x %x %x (%d,%d) invalid brush!", hdc, hrgn, hBrush, width, height));
|
|---|
| 1802 | SetLastError(ERROR_INVALID_HANDLE_W);
|
|---|
| 1803 | return FALSE;
|
|---|
| 1804 | }
|
|---|
| 1805 | }
|
|---|
| 1806 | dprintf(("FrameRgn %x %x %x (%d,%d)", hdc, hrgn1, hBrush, width, height));
|
|---|
| 1807 | interpretRegionAs(pHps, NULL, hrgn, AS_WORLD);
|
|---|
| 1808 |
|
|---|
| 1809 | SIZEL thickness = { width, height };
|
|---|
| 1810 | LONG lHits = GpiFrameRegion(pHps->hps, pHps->hrgnHDC, &thickness);
|
|---|
| 1811 |
|
|---|
| 1812 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 1813 |
|
|---|
| 1814 | // Restore the brush if necessary
|
|---|
| 1815 | if(hbrushRestore)
|
|---|
| 1816 | SelectObject(hdc, hbrushRestore);
|
|---|
| 1817 |
|
|---|
| 1818 | if(lHits != GPI_ERROR)
|
|---|
| 1819 | DIBSECTION_MARK_INVALID(hdc);
|
|---|
| 1820 |
|
|---|
| 1821 | //todo metafile recording
|
|---|
| 1822 | return (lHits != GPI_ERROR);
|
|---|
| 1823 | }
|
|---|
| 1824 | //******************************************************************************
|
|---|
| 1825 | //******************************************************************************
|
|---|
| 1826 | BOOL WIN32API FillRgn(HDC hdc, HRGN hrgn, HBRUSH hBrush)
|
|---|
| 1827 | {
|
|---|
| 1828 | BOOL success;
|
|---|
| 1829 | HBRUSH hbrushRestore = 0;
|
|---|
| 1830 | #ifdef DEBUG
|
|---|
| 1831 | HRGN hrgn1 = hrgn;
|
|---|
| 1832 | #endif
|
|---|
| 1833 |
|
|---|
| 1834 | pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
|
|---|
| 1835 |
|
|---|
| 1836 | hrgn = ObjQueryHandleData(hrgn, HNDL_REGION);
|
|---|
| 1837 | if(!pHps || hrgn == HANDLE_OBJ_ERROR) {
|
|---|
| 1838 | dprintf(("WARNING: FillRgn %x %x %x invalid handle!", hdc, hrgn1, hBrush));
|
|---|
| 1839 | SetLastError(ERROR_INVALID_HANDLE_W);
|
|---|
| 1840 | return FALSE;
|
|---|
| 1841 | }
|
|---|
| 1842 |
|
|---|
| 1843 | if(pHps->lastBrushKey != (UINT)hBrush)
|
|---|
| 1844 | {
|
|---|
| 1845 | hbrushRestore = SelectObject(hdc, hBrush);
|
|---|
| 1846 | if (!hbrushRestore)
|
|---|
| 1847 | {
|
|---|
| 1848 | dprintf(("WARNING: FillRgn %x %x %x invalid brush!", hdc, hrgn1, hBrush));
|
|---|
| 1849 | SetLastError(ERROR_INVALID_HANDLE_W);
|
|---|
| 1850 | return FALSE;
|
|---|
| 1851 | }
|
|---|
| 1852 | }
|
|---|
| 1853 | dprintf(("FillRgn %x %x %x", hdc, hrgn1, hBrush));
|
|---|
| 1854 |
|
|---|
| 1855 | DIBSECTION_CHECK_IF_DIRTY(hdc);
|
|---|
| 1856 | interpretRegionAs(pHps, NULL, hrgn, AS_WORLD);
|
|---|
| 1857 |
|
|---|
| 1858 | dprintfRegion(pHps->hps, pHps->hrgnHDC);
|
|---|
| 1859 |
|
|---|
| 1860 | success = GpiPaintRegion(pHps->hps, pHps->hrgnHDC);
|
|---|
| 1861 |
|
|---|
| 1862 | //todo metafile recording
|
|---|
| 1863 |
|
|---|
| 1864 | /* Restore the brush if necessary */
|
|---|
| 1865 | if(hbrushRestore)
|
|---|
| 1866 | SelectObject(hdc, hbrushRestore);
|
|---|
| 1867 |
|
|---|
| 1868 | if(success)
|
|---|
| 1869 | DIBSECTION_MARK_INVALID(hdc);
|
|---|
| 1870 |
|
|---|
| 1871 | return(success);
|
|---|
| 1872 | }
|
|---|
| 1873 | //******************************************************************************
|
|---|
| 1874 | //******************************************************************************
|
|---|
| 1875 | BOOL WIN32API PaintRgn( HDC hdc, HRGN hrgn)
|
|---|
| 1876 | {
|
|---|
| 1877 | return FillRgn(hdc, hrgn, (HBRUSH) GetCurrentObject(hdc, OBJ_BRUSH_W));
|
|---|
| 1878 | }
|
|---|
| 1879 | //******************************************************************************
|
|---|
| 1880 | //******************************************************************************
|
|---|
| 1881 | BOOL WIN32API PtInRegion( HRGN hrgn, int x, int y)
|
|---|
| 1882 | {
|
|---|
| 1883 | BOOL success;
|
|---|
| 1884 | LONG lInside;
|
|---|
| 1885 | #ifdef DEBUG
|
|---|
| 1886 | HRGN hrgn1 = hrgn;
|
|---|
| 1887 | #endif
|
|---|
| 1888 |
|
|---|
| 1889 | hrgn = ObjQueryHandleData(hrgn, HNDL_REGION);
|
|---|
| 1890 | if(hrgn == HANDLE_OBJ_ERROR) {
|
|---|
| 1891 | dprintf(("WARNING: PtInRgn %x (%d,%d) invalid region!", hrgn1, x, y));
|
|---|
| 1892 | SetLastError(ERROR_INVALID_HANDLE_W);
|
|---|
| 1893 | return FALSE;
|
|---|
| 1894 | }
|
|---|
| 1895 |
|
|---|
| 1896 | POINTL pointl = {x,y};
|
|---|
| 1897 | lInside = GpiPtInRegion(hpsRegion, hrgn, &pointl);
|
|---|
| 1898 | if(lInside == PRGN_ERROR) {
|
|---|
| 1899 | success = FALSE;
|
|---|
| 1900 | }
|
|---|
| 1901 | else success = TRUE;
|
|---|
| 1902 |
|
|---|
| 1903 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 1904 |
|
|---|
| 1905 | dprintf(("PtInRgn %x (%d,%d) returned %d", hrgn1, x, y, (success && lInside == PRGN_INSIDE) ? 1 : 0));
|
|---|
| 1906 |
|
|---|
| 1907 | if(success && lInside == PRGN_INSIDE)
|
|---|
| 1908 | return TRUE;
|
|---|
| 1909 | else
|
|---|
| 1910 | return FALSE;
|
|---|
| 1911 | }
|
|---|
| 1912 | //******************************************************************************
|
|---|
| 1913 | //******************************************************************************
|
|---|
| 1914 | BOOL WIN32API RectInRegion( HRGN hrgn, const RECT * pRect)
|
|---|
| 1915 | {
|
|---|
| 1916 | BOOL success;
|
|---|
| 1917 | LONG lInside;
|
|---|
| 1918 | #ifdef DEBUG
|
|---|
| 1919 | HRGN hrgn1 = hrgn;
|
|---|
| 1920 | #endif
|
|---|
| 1921 |
|
|---|
| 1922 | if(!pRect) {
|
|---|
| 1923 | dprintf(("WARNING: RectInRgn %x %x invalid parameter!", hrgn1, pRect));
|
|---|
| 1924 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 1925 | return FALSE;
|
|---|
| 1926 | }
|
|---|
| 1927 | hrgn = ObjQueryHandleData(hrgn, HNDL_REGION);
|
|---|
| 1928 | if(hrgn == HANDLE_OBJ_ERROR) {
|
|---|
| 1929 | dprintf(("WARNING: RectInRgn %x %x invalid region", hrgn1, pRect));
|
|---|
| 1930 | SetLastError(ERROR_INVALID_HANDLE_W);
|
|---|
| 1931 | return FALSE;
|
|---|
| 1932 | }
|
|---|
| 1933 |
|
|---|
| 1934 | RECTL rectl;
|
|---|
| 1935 | MapWin32ToOS2Rect(*pRect, rectl);
|
|---|
| 1936 | //switch bottom & top
|
|---|
| 1937 | UINT temp = rectl.yBottom;
|
|---|
| 1938 | rectl.yBottom = rectl.yTop;
|
|---|
| 1939 | rectl.yTop = temp;
|
|---|
| 1940 |
|
|---|
| 1941 | lInside = GpiRectInRegion(hpsRegion, hrgn, &rectl);
|
|---|
| 1942 | if(lInside == RRGN_ERROR) {
|
|---|
| 1943 | success = FALSE;
|
|---|
| 1944 | }
|
|---|
| 1945 | else success = TRUE;
|
|---|
| 1946 |
|
|---|
| 1947 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 1948 |
|
|---|
| 1949 | dprintf(("RectInRgn %x %x returned %d", hrgn1, pRect, (success && (lInside == RRGN_INSIDE || lInside == RRGN_PARTIAL)) ? 1 : 0));
|
|---|
| 1950 |
|
|---|
| 1951 | if(success && (lInside == RRGN_INSIDE || lInside == RRGN_PARTIAL))
|
|---|
| 1952 | return TRUE;
|
|---|
| 1953 | else
|
|---|
| 1954 | return FALSE;
|
|---|
| 1955 | }
|
|---|
| 1956 | //******************************************************************************
|
|---|
| 1957 | //Returned region in device coordinates (undocumented behaviour)
|
|---|
| 1958 | //******************************************************************************
|
|---|
| 1959 | HRGN WIN32API PathToRegion( HDC hdc)
|
|---|
| 1960 | {
|
|---|
| 1961 | pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
|
|---|
| 1962 | if(!pHps)
|
|---|
| 1963 | {
|
|---|
| 1964 | dprintf(("WARNING: PathToRegion %x; invalid hdc!", hdc));
|
|---|
| 1965 | SetLastError(ERROR_INVALID_HANDLE_W);
|
|---|
| 1966 | return NULLHANDLE;
|
|---|
| 1967 | }
|
|---|
| 1968 |
|
|---|
| 1969 | HRGN hrgn, hrgnTemp, hrgnwin;
|
|---|
| 1970 |
|
|---|
| 1971 | dprintf(("GDI32: PathToRegion %x", hdc));
|
|---|
| 1972 |
|
|---|
| 1973 | hrgnTemp = GpiPathToRegion(pHps->hps, 1, (pHps->polyFillMode == ALTERNATE_W) ? FPATH_ALTERNATE : FPATH_WINDING);
|
|---|
| 1974 | if(hrgnTemp == NULLHANDLE)
|
|---|
| 1975 | goto error;
|
|---|
| 1976 |
|
|---|
| 1977 | hrgnwin = CreateRectRgn(1, 1, 2, 2);
|
|---|
| 1978 | hrgn = ObjQueryHandleData(hrgnwin, HNDL_REGION);
|
|---|
| 1979 | if(hrgn == HANDLE_OBJ_ERROR) {
|
|---|
| 1980 | dprintf(("WARNING: PathToRegion invalid region", hrgnwin));
|
|---|
| 1981 | SetLastError(ERROR_INVALID_HANDLE_W);
|
|---|
| 1982 | return NULLHANDLE;
|
|---|
| 1983 | }
|
|---|
| 1984 |
|
|---|
| 1985 | if(!setWinDeviceRegionFromPMDeviceRegion(hrgn, hrgnTemp, pHps, NULL))
|
|---|
| 1986 | goto error;
|
|---|
| 1987 |
|
|---|
| 1988 | GpiDestroyRegion(pHps->hps, hrgnTemp);
|
|---|
| 1989 |
|
|---|
| 1990 | return hrgnwin;
|
|---|
| 1991 |
|
|---|
| 1992 | error:
|
|---|
| 1993 | if(hrgnwin)
|
|---|
| 1994 | DeleteObject(hrgnwin);
|
|---|
| 1995 |
|
|---|
| 1996 | SetLastError(ERROR_INVALID_HANDLE_W); //todo right error
|
|---|
| 1997 | return NULLHANDLE;
|
|---|
| 1998 | }
|
|---|
| 1999 | //******************************************************************************
|
|---|
| 2000 | //Needs wrapper as this file includes os2.h!!
|
|---|
| 2001 | //******************************************************************************
|
|---|
| 2002 | BOOL WIN32API OSLibDeleteRegion(HANDLE hRegion)
|
|---|
| 2003 | {
|
|---|
| 2004 | if(GpiDestroyRegion(hpsRegion, hRegion) == FALSE) {
|
|---|
| 2005 | dprintf(("WARNING: OSLibDeleteRegion %x; GpiDestroyRegion failed (%x)", hRegion, WinGetLastError(0)));
|
|---|
| 2006 | }
|
|---|
| 2007 | return (0);
|
|---|
| 2008 | }
|
|---|
| 2009 | /*****************************************************************************
|
|---|
| 2010 | * Name : int GetMetaRgn
|
|---|
| 2011 | * Purpose : The GetMetaRgn function retrieves the current metaregion for
|
|---|
| 2012 | * the specified device context.
|
|---|
| 2013 | * Parameters: HDC hdc handle of device context
|
|---|
| 2014 | * HRGN hrgn handle of region
|
|---|
| 2015 | * Variables :
|
|---|
| 2016 | * Result : 0 / 1
|
|---|
| 2017 | * Remark :
|
|---|
| 2018 | * Status : UNTESTED STUB
|
|---|
| 2019 | *
|
|---|
| 2020 | * Author : Patrick Haller [Mon, 1998/06/15 08:00]
|
|---|
| 2021 | *****************************************************************************/
|
|---|
| 2022 |
|
|---|
| 2023 | int WIN32API GetMetaRgn( HDC hdc, HRGN hrgn)
|
|---|
| 2024 | {
|
|---|
| 2025 | dprintf(("GDI32: GetMetaRgn(%08xh, %08xh) not implemented.\n",
|
|---|
| 2026 | hdc,
|
|---|
| 2027 | hrgn));
|
|---|
| 2028 |
|
|---|
| 2029 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 2030 | return (0);
|
|---|
| 2031 | }
|
|---|
| 2032 | /*****************************************************************************
|
|---|
| 2033 | * Name : int SetMetaRgn
|
|---|
| 2034 | * Purpose : The SetMetaRgn function intersects the current clipping region
|
|---|
| 2035 | * for the specified device context with the current metaregion
|
|---|
| 2036 | * and saves the combined region as the new metaregion for the
|
|---|
| 2037 | * specified device context. The clipping region is reset to a null region.
|
|---|
| 2038 | * Parameters: HDC hdc handle of device context
|
|---|
| 2039 | * Variables :
|
|---|
| 2040 | * Result : TRUE / FALSE
|
|---|
| 2041 | * Remark :
|
|---|
| 2042 | * Status : UNTESTED STUB
|
|---|
| 2043 | *
|
|---|
| 2044 | * Author : Patrick Haller [Mon, 1998/06/15 08:00]
|
|---|
| 2045 | *****************************************************************************/
|
|---|
| 2046 |
|
|---|
| 2047 | BOOL WIN32API SetMetaRgn( HDC hdc)
|
|---|
| 2048 | {
|
|---|
| 2049 | dprintf(("GDI32: SetMetaRgn(%08xh) not implemented.\n",
|
|---|
| 2050 | hdc));
|
|---|
| 2051 |
|
|---|
| 2052 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 2053 | return (NULLREGION_W);
|
|---|
| 2054 | }
|
|---|
| 2055 | //******************************************************************************
|
|---|
| 2056 | //******************************************************************************
|
|---|