| 1 | /* $Id: transform.cpp,v 1.2 2000-12-29 18:40:44 sandervl Exp $ */
|
|---|
| 2 |
|
|---|
| 3 | /*
|
|---|
| 4 | * GDI32 coordinate & translformation code
|
|---|
| 5 | *
|
|---|
| 6 | * Copyright 2000 Sander van Leeuwen (sandervl@xs4all.nl)
|
|---|
| 7 | *
|
|---|
| 8 | * TODO: Metafile recording
|
|---|
| 9 | * TODO: Translate & set the last error for Gpi operations
|
|---|
| 10 | *
|
|---|
| 11 | * Project Odin Software License can be found in LICENSE.TXT
|
|---|
| 12 | *
|
|---|
| 13 | */
|
|---|
| 14 | #define INCL_GPI
|
|---|
| 15 | #define INCL_WIN
|
|---|
| 16 | #include <os2wrap.h> //need odin wrappers
|
|---|
| 17 |
|
|---|
| 18 | #include <win32type.h>
|
|---|
| 19 | #include <win32api.h>
|
|---|
| 20 | #include <winconst.h>
|
|---|
| 21 | #include <stdlib.h>
|
|---|
| 22 | #include <stdarg.h>
|
|---|
| 23 | #include <string.h>
|
|---|
| 24 | #include <misc.h>
|
|---|
| 25 | #include <odinwrap.h>
|
|---|
| 26 | #include <objhandle.h>
|
|---|
| 27 | #include <dcdata.h>
|
|---|
| 28 | #include <winuser32.h>
|
|---|
| 29 | #include "oslibgpi.h"
|
|---|
| 30 |
|
|---|
| 31 | #define DBG_LOCALLOG DBG_transform
|
|---|
| 32 | #include "dbglocal.h"
|
|---|
| 33 |
|
|---|
| 34 | static const XFORM_W XFORMIdentity = { 1.0, 0.0, 0.0, 1.0, 0, 0 };
|
|---|
| 35 |
|
|---|
| 36 | //******************************************************************************
|
|---|
| 37 | //******************************************************************************
|
|---|
| 38 | BOOL WIN32API SetWorldTransform(HDC hdc, const XFORM_W * pXform)
|
|---|
| 39 | {
|
|---|
| 40 | BOOL ret;
|
|---|
| 41 |
|
|---|
| 42 | //Only proceed if DC is in GM_ADVANCED mode, unless it's a metafile PS
|
|---|
| 43 | pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
|
|---|
| 44 | if(!pHps || ((pHps->graphicsMode != GM_ADVANCED_W) && !pHps->isMetaPS))
|
|---|
| 45 | {
|
|---|
| 46 | dprintf(("WARNING: SetWorldTransform %x %x; not in GM_ADVANCED mode!!", hdc, pXform));
|
|---|
| 47 | SetLastError(ERROR_INVALID_HANDLE_W);
|
|---|
| 48 | return FALSE;
|
|---|
| 49 | }
|
|---|
| 50 |
|
|---|
| 51 | if(!pXform)
|
|---|
| 52 | {
|
|---|
| 53 | dprintf(("WARNING: SetWorldTransform %x %x; invalid parameter!!", hdc, pXform));
|
|---|
| 54 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 55 | return FALSE;
|
|---|
| 56 | }
|
|---|
| 57 |
|
|---|
| 58 | //todo: metafile recording!!!!
|
|---|
| 59 |
|
|---|
| 60 | MATRIXLF matrixlf;
|
|---|
| 61 | matrixlf.fxM11 = pXform->eM11 * (float)0x10000;
|
|---|
| 62 | matrixlf.fxM12 = pXform->eM12 * (float)0x10000;
|
|---|
| 63 | matrixlf.lM13 = 0;
|
|---|
| 64 | matrixlf.fxM21 = pXform->eM21 * (float)0x10000;
|
|---|
| 65 | matrixlf.fxM22 = pXform->eM22 * (float)0x10000;
|
|---|
| 66 | matrixlf.lM23 = 0;
|
|---|
| 67 | matrixlf.lM31 = pXform->eDx;
|
|---|
| 68 | matrixlf.lM32 = pXform->eDy;
|
|---|
| 69 | matrixlf.lM33 = 1;
|
|---|
| 70 |
|
|---|
| 71 | ret = GpiSetModelTransformMatrix(pHps->hps, 9, &matrixlf, TRANSFORM_REPLACE);
|
|---|
| 72 | if(ret)
|
|---|
| 73 | {
|
|---|
| 74 | TestWideLine(pHps);
|
|---|
| 75 | Calculate1PixelDelta(pHps);
|
|---|
| 76 | pHps->xform = *pXform; // save transform in DC struct
|
|---|
| 77 | dprintf(("SetWorldTransform %x %x", hdc, pXform));
|
|---|
| 78 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 79 | }
|
|---|
| 80 | else {
|
|---|
| 81 | dprintf(("WARNING: SetWorldTransform %x %x; GpiSetModelTransformMatrix failed!!", hdc, pXform));
|
|---|
| 82 | SetLastError(ERROR_INVALID_PARAMETER_W); //TODO: translate PM error
|
|---|
| 83 | }
|
|---|
| 84 | return ret;
|
|---|
| 85 | }
|
|---|
| 86 | //******************************************************************************
|
|---|
| 87 | //******************************************************************************
|
|---|
| 88 | BOOL WIN32API GetWorldTransform(HDC hdc, LPXFORM_W pXform)
|
|---|
| 89 | {
|
|---|
| 90 | pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
|
|---|
| 91 | if(!pHps)
|
|---|
| 92 | {
|
|---|
| 93 | dprintf(("WARNING: GetWorldTransform %x %x -> INVALID HDC", hdc, pXform));
|
|---|
| 94 | SetLastError(ERROR_INVALID_HANDLE_W);
|
|---|
| 95 | return FALSE;
|
|---|
| 96 | }
|
|---|
| 97 |
|
|---|
| 98 | if (!pXform)
|
|---|
| 99 | {
|
|---|
| 100 | dprintf(("WARNING: GetWorldTransform %x NULL -> INVALID parameter", hdc));
|
|---|
| 101 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 102 | return FALSE;
|
|---|
| 103 | }
|
|---|
| 104 |
|
|---|
| 105 | *pXform = pHps->xform;
|
|---|
| 106 |
|
|---|
| 107 | dprintf(("WARNING: GetWorldTransform %x %x", hdc, pXform));
|
|---|
| 108 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 109 | return TRUE;
|
|---|
| 110 | }
|
|---|
| 111 | //******************************************************************************
|
|---|
| 112 | //******************************************************************************
|
|---|
| 113 | BOOL WIN32API ModifyWorldTransform(HDC hdc, const XFORM_W *pXform, DWORD mode)
|
|---|
| 114 | {
|
|---|
| 115 | MATRIXLF matrixlf;
|
|---|
| 116 | LONG lOptions;
|
|---|
| 117 | BOOL ret;
|
|---|
| 118 |
|
|---|
| 119 | //Only proceed if DC is in GM_ADVANCED mode, unless it's a metafile PS
|
|---|
| 120 | pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
|
|---|
| 121 | if(!pHps || ((pHps->graphicsMode != GM_ADVANCED_W) && !pHps->isMetaPS))
|
|---|
| 122 | {
|
|---|
| 123 | dprintf(("WARNING: ModifyWorldTransform %x %x %x; not in GM_ADVANCED mode!!", hdc, pXform, mode));
|
|---|
| 124 | SetLastError(ERROR_INVALID_HANDLE_W);
|
|---|
| 125 | return FALSE;
|
|---|
| 126 | }
|
|---|
| 127 |
|
|---|
| 128 | if(mode == MWT_IDENTITY_W)
|
|---|
| 129 | {
|
|---|
| 130 | matrixlf.fxM11 = MAKEFIXED(1,0);
|
|---|
| 131 | matrixlf.fxM12 = 0;
|
|---|
| 132 | matrixlf.lM13 = 0;
|
|---|
| 133 | matrixlf.fxM21 = 0;
|
|---|
| 134 | matrixlf.fxM22 = MAKEFIXED(1,0);
|
|---|
| 135 | matrixlf.lM23 = 0;
|
|---|
| 136 | matrixlf.lM31 = 0;
|
|---|
| 137 | matrixlf.lM32 = 0;
|
|---|
| 138 | matrixlf.lM33 = MAKEFIXED(1,0);
|
|---|
| 139 |
|
|---|
| 140 | lOptions = TRANSFORM_REPLACE;
|
|---|
| 141 | }
|
|---|
| 142 | else
|
|---|
| 143 | if(mode == MWT_LEFTMULTIPLY_W || mode == MWT_RIGHTMULTIPLY_W)
|
|---|
| 144 | {
|
|---|
| 145 | matrixlf.fxM11 = pXform->eM11 * (float)0x10000;
|
|---|
| 146 | matrixlf.fxM12 = pXform->eM12 * (float)0x10000;
|
|---|
| 147 | matrixlf.lM13 = 0;
|
|---|
| 148 | matrixlf.fxM21 = pXform->eM21 * (float)0x10000;
|
|---|
| 149 | matrixlf.fxM22 = pXform->eM22 * (float)0x10000;
|
|---|
| 150 | matrixlf.lM23 = 0;
|
|---|
| 151 | matrixlf.lM31 = pXform->eDx;
|
|---|
| 152 | matrixlf.lM32 = pXform->eDy;
|
|---|
| 153 | matrixlf.lM33 = 1;
|
|---|
| 154 |
|
|---|
| 155 | if(mode == MWT_LEFTMULTIPLY_W) {
|
|---|
| 156 | lOptions = TRANSFORM_PREEMPT;
|
|---|
| 157 | }
|
|---|
| 158 | else lOptions = TRANSFORM_ADD;
|
|---|
| 159 | }
|
|---|
| 160 | else
|
|---|
| 161 | {
|
|---|
| 162 | dprintf(("WARNING: ModifyWorldTransform %x %x %x; invalid parameter!!", hdc, pXform, mode));
|
|---|
| 163 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 164 | return FALSE;
|
|---|
| 165 | }
|
|---|
| 166 | //todo: metafile recording!!!
|
|---|
| 167 |
|
|---|
| 168 | ret = GpiSetModelTransformMatrix( pHps->hps, 9, &matrixlf, lOptions);
|
|---|
| 169 | if(ret)
|
|---|
| 170 | {
|
|---|
| 171 | if(mode == MWT_IDENTITY_W) {
|
|---|
| 172 | pHps->xform = XFORMIdentity;
|
|---|
| 173 | }
|
|---|
| 174 | else GetWorldTransform(hdc, &pHps->xform);
|
|---|
| 175 |
|
|---|
| 176 | dprintf(("ModifyWorldTransform %x %x %d", hdc, pXform, mode));
|
|---|
| 177 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 178 | }
|
|---|
| 179 | else {
|
|---|
| 180 | dprintf(("ModifyWorldTransform %x %x %d; GpiSetModelTransformMatrix failed!!", hdc, pXform, mode));
|
|---|
| 181 | SetLastError(ERROR_INVALID_PARAMETER_W); //TODO: translate PM error
|
|---|
| 182 | }
|
|---|
| 183 |
|
|---|
| 184 | return ret;
|
|---|
| 185 | }
|
|---|
| 186 | //******************************************************************************
|
|---|
| 187 | //******************************************************************************
|
|---|
| 188 | BOOL WIN32API OffsetViewportOrgEx(HDC hdc, int xOffset, int yOffset, LPPOINT pPoint)
|
|---|
| 189 | {
|
|---|
| 190 | pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
|
|---|
| 191 |
|
|---|
| 192 | if(pHps && changePageXForm(pHps, (PPOINTL) &pHps->viewportOrg,
|
|---|
| 193 | xOffset + pHps->viewportOrg.x,
|
|---|
| 194 | yOffset + pHps->viewportOrg.y,
|
|---|
| 195 | (PPOINTL) pPoint))
|
|---|
| 196 | {
|
|---|
| 197 | //todo: metafile recording!!!
|
|---|
| 198 | dprintf(("OffsetViewportOrgEx %x (%d,%d) %x", hdc, xOffset, yOffset));
|
|---|
| 199 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 200 | return TRUE;
|
|---|
| 201 | }
|
|---|
| 202 |
|
|---|
| 203 | dprintf(("WARNING: OffsetViewportOrgEx %x (%d,%d) %x; HDC invalid or changePageXForm failed!!", hdc, xOffset, yOffset));
|
|---|
| 204 | SetLastError(ERROR_INVALID_PARAMETER_W); //TODO: translate PM error
|
|---|
| 205 | return FALSE;
|
|---|
| 206 | }
|
|---|
| 207 | //******************************************************************************
|
|---|
| 208 | //******************************************************************************
|
|---|
| 209 | BOOL WIN32API OffsetWindowOrgEx(HDC hdc, int xOffset, int yOffset, LPPOINT pPoint)
|
|---|
| 210 | {
|
|---|
| 211 | pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
|
|---|
| 212 |
|
|---|
| 213 | if(pHps && changePageXForm(pHps, (PPOINTL) &pHps->windowOrg,
|
|---|
| 214 | xOffset + pHps->windowOrg.x,
|
|---|
| 215 | yOffset + pHps->windowOrg.y,
|
|---|
| 216 | (PPOINTL) pPoint))
|
|---|
| 217 | {
|
|---|
| 218 | //todo: metafile recording!!!
|
|---|
| 219 | dprintf(("OffsetWindowOrgEx %x (%d,%d) %x", hdc, xOffset, yOffset));
|
|---|
| 220 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 221 | return TRUE;
|
|---|
| 222 | }
|
|---|
| 223 |
|
|---|
| 224 | dprintf(("WARNING: OffsetWindowOrgEx %x (%d,%d) %x; HDC invalid or changePageXForm failed!!", hdc, xOffset, yOffset));
|
|---|
| 225 | SetLastError(ERROR_INVALID_PARAMETER_W); //TODO: translate PM error
|
|---|
| 226 | return FALSE;
|
|---|
| 227 | }
|
|---|
| 228 | //******************************************************************************
|
|---|
| 229 | //******************************************************************************
|
|---|
| 230 | BOOL WIN32API ScaleViewportExtEx(HDC hdc, int xNum, int xDenom, int yNum, int yDenom, LPSIZE pSize)
|
|---|
| 231 | {
|
|---|
| 232 | pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
|
|---|
| 233 |
|
|---|
| 234 | if(!pHps)
|
|---|
| 235 | {
|
|---|
| 236 | dprintf(("WARNING: ScaleViewportExtEx %x (%d,%d) (%d,%d), %x; HDC INVALID!!1", hdc, xNum, xDenom, yNum, yDenom, pSize));
|
|---|
| 237 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 238 | return FALSE;
|
|---|
| 239 | }
|
|---|
| 240 |
|
|---|
| 241 | if(xNum && yNum && xDenom && yDenom &&
|
|---|
| 242 | (pHps->MapMode == MM_ISOTROPIC_W || pHps->MapMode == MM_ANISOTROPIC_W))
|
|---|
| 243 | {
|
|---|
| 244 | if(changePageXForm(pHps, NULL, pHps->viewportXExt * xNum / xDenom,
|
|---|
| 245 | pHps->viewportYExt * yNum / yDenom, (PPOINTL) pSize))
|
|---|
| 246 | {
|
|---|
| 247 | //todo: metafile recording!!!
|
|---|
| 248 | dprintf(("ScaleViewportExtEx %x (%d,%d) (%d,%d), %x", hdc, xNum, xDenom, yNum, yDenom, pSize));
|
|---|
| 249 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 250 | return TRUE;
|
|---|
| 251 | }
|
|---|
| 252 |
|
|---|
| 253 | dprintf(("WARNING: ScaleViewportExtEx %x (%d,%d) (%d,%d), %x; changePageXForm failed!!", hdc, xNum, xDenom, yNum, yDenom, pSize));
|
|---|
| 254 | SetLastError(ERROR_INVALID_PARAMETER_W); //TODO: translate PM error
|
|---|
| 255 | return FALSE;
|
|---|
| 256 | }
|
|---|
| 257 | else
|
|---|
| 258 | {
|
|---|
| 259 | pHps->lWndXExtSave = pHps->viewportXExt * xNum / xDenom;
|
|---|
| 260 | pHps->lWndYExtSave = pHps->viewportYExt * yNum / yDenom;
|
|---|
| 261 |
|
|---|
| 262 | //function is a no-op if map mode is not (AN)ISOTROPIC; NT returns TRUE
|
|---|
| 263 | dprintf(("ScaleViewportExtEx %x (%d,%d) (%d,%d), %x", hdc, xNum, xDenom, yNum, yDenom, pSize));
|
|---|
| 264 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 265 | return TRUE;
|
|---|
| 266 | }
|
|---|
| 267 | }
|
|---|
| 268 | //******************************************************************************
|
|---|
| 269 | //******************************************************************************
|
|---|
| 270 | BOOL WIN32API ScaleWindowExtEx(HDC hdc, int xNum, int xDenom, int yNum, int yDenom, LPSIZE pSize )
|
|---|
| 271 | {
|
|---|
| 272 | pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
|
|---|
| 273 |
|
|---|
| 274 | if(pHps && xDenom && yDenom)
|
|---|
| 275 | {
|
|---|
| 276 | if(changePageXForm(pHps, (PPOINTL) &pHps->windowExt,
|
|---|
| 277 | pHps->windowExt.cx * xNum / xDenom,
|
|---|
| 278 | pHps->windowExt.cy * yNum / yDenom,
|
|---|
| 279 | (PPOINTL) pSize))
|
|---|
| 280 | {
|
|---|
| 281 | //todo: metafile recording!!!
|
|---|
| 282 | dprintf(("ScaleWindowExtEx %x (%d,%d) (%d,%d), %x", hdc, xNum, xDenom, yNum, yDenom, pSize));
|
|---|
| 283 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 284 | return TRUE;
|
|---|
| 285 | }
|
|---|
| 286 |
|
|---|
| 287 | dprintf(("WARNING: ScaleWindowExtEx %x (%d,%d) (%d,%d), %x; changePageXForm failed!!", hdc, xNum, xDenom, yNum, yDenom, pSize));
|
|---|
| 288 | SetLastError(ERROR_INVALID_PARAMETER_W); //TODO: translate PM error
|
|---|
| 289 | return FALSE;
|
|---|
| 290 | }
|
|---|
| 291 |
|
|---|
| 292 | dprintf(("WARNING: ScaleWindowExtEx %x (%d,%d) (%d,%d), %x; invalid HDC!!", hdc, xNum, xDenom, yNum, yDenom, pSize));
|
|---|
| 293 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 294 | return FALSE;
|
|---|
| 295 | }
|
|---|
| 296 | //******************************************************************************
|
|---|
| 297 | //******************************************************************************
|
|---|
| 298 | int WIN32API SetMapMode(HDC hdc, int mode)
|
|---|
| 299 | {
|
|---|
| 300 | pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
|
|---|
| 301 | if(!pHps)
|
|---|
| 302 | {
|
|---|
| 303 | dprintf(("WARNING: SetMapMode %x %d; invalid HDC!!", hdc, mode));
|
|---|
| 304 | SetLastError(ERROR_INVALID_HANDLE_W);
|
|---|
| 305 | return 0;
|
|---|
| 306 | }
|
|---|
| 307 |
|
|---|
| 308 | //todo: metafile recording!!!
|
|---|
| 309 | return setMapMode(pHps, mode);
|
|---|
| 310 | }
|
|---|
| 311 | //******************************************************************************
|
|---|
| 312 | //******************************************************************************
|
|---|
| 313 | int WIN32API GetMapMode(HDC hdc)
|
|---|
| 314 | {
|
|---|
| 315 | pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
|
|---|
| 316 | if(pHps) {
|
|---|
| 317 | dprintf(("GDI32: GetMapMode %x -> %d", hdc, pHps->MapMode));
|
|---|
| 318 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 319 | return pHps->MapMode;
|
|---|
| 320 | }
|
|---|
| 321 | dprintf(("WARNING: GetMapMode %x invalid HDC!!", hdc));
|
|---|
| 322 | SetLastError(ERROR_INVALID_HANDLE_W);
|
|---|
| 323 | return 0;
|
|---|
| 324 | }
|
|---|
| 325 | //******************************************************************************
|
|---|
| 326 | //******************************************************************************
|
|---|
| 327 | BOOL WIN32API SetViewportExtEx( HDC hdc, int xExt, int yExt, LPSIZE pSize)
|
|---|
| 328 | {
|
|---|
| 329 | pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
|
|---|
| 330 | if (!pHps)
|
|---|
| 331 | {
|
|---|
| 332 | dprintf(("WARNING: SetViewPortExtEx: HDC %x not found!!", hdc));
|
|---|
| 333 | SetLastError(ERROR_INVALID_HANDLE_W);
|
|---|
| 334 | return FALSE;
|
|---|
| 335 | }
|
|---|
| 336 |
|
|---|
| 337 | if(xExt && yExt)
|
|---|
| 338 | {
|
|---|
| 339 | //todo: metafile recording!!! (always)
|
|---|
| 340 | if (pHps->MapMode == MM_ISOTROPIC_W || pHps->MapMode == MM_ANISOTROPIC_W )
|
|---|
| 341 | {
|
|---|
| 342 | if(changePageXForm(pHps, NULL, xExt, yExt, (PPOINTL)pSize))
|
|---|
| 343 | {
|
|---|
| 344 | dprintf(("SetViewPortExtEx: %x (%d,%d), %x", hdc, xExt, yExt, pSize));
|
|---|
| 345 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 346 | return TRUE;
|
|---|
| 347 | }
|
|---|
| 348 | }
|
|---|
| 349 | else
|
|---|
| 350 | {
|
|---|
| 351 | pHps->lVwpXExtSave = xExt, pHps->lVwpYExtSave = yExt;
|
|---|
| 352 |
|
|---|
| 353 | //function is a no-op if map mode is not (AN)ISOTROPIC; NT returns TRUE
|
|---|
| 354 | dprintf(("SetViewPortExtEx: %x (%d,%d), %x", hdc, xExt, yExt, pSize));
|
|---|
| 355 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 356 | return TRUE;
|
|---|
| 357 | }
|
|---|
| 358 |
|
|---|
| 359 | dprintf(("WARNING: SetViewPortExtEx: %x (%d,%d) -> changePageXForm failed!!!, %x", hdc, xExt, yExt, pSize));
|
|---|
| 360 | SetLastError(ERROR_INVALID_PARAMETER_W); //TODO: translate PM error
|
|---|
| 361 | return FALSE;
|
|---|
| 362 | }
|
|---|
| 363 |
|
|---|
| 364 | dprintf(("WARNING: SetViewPortExtEx: %x (%d,%d) -> invalid parameters!!!, %x", hdc, xExt, yExt, pSize));
|
|---|
| 365 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 366 | return FALSE;
|
|---|
| 367 | }
|
|---|
| 368 | //******************************************************************************
|
|---|
| 369 | //******************************************************************************
|
|---|
| 370 | BOOL WIN32API GetViewportExtEx(HDC hdc, LPSIZE pSize)
|
|---|
| 371 | {
|
|---|
| 372 | pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
|
|---|
| 373 | if(!pHps)
|
|---|
| 374 | {
|
|---|
| 375 | dprintf(("WARNING: GetViewportExtEx %x %x -> INVALID HDC", hdc, pSize));
|
|---|
| 376 | SetLastError(ERROR_INVALID_HANDLE_W);
|
|---|
| 377 | return FALSE;
|
|---|
| 378 | }
|
|---|
| 379 |
|
|---|
| 380 | if(!pSize)
|
|---|
| 381 | {
|
|---|
| 382 | dprintf(("WARNING: GetViewportExtEx %x NULL -> INVALID parameter", hdc));
|
|---|
| 383 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 384 | return FALSE;
|
|---|
| 385 | }
|
|---|
| 386 |
|
|---|
| 387 | pSize->cx = (LONG)pHps->viewportXExt;
|
|---|
| 388 | pSize->cy = (LONG)pHps->viewportYExt;
|
|---|
| 389 | dprintf(("GDI32: GetViewportExtEx %x -> (%d,%d)", hdc, pSize->cx, pSize->cy));
|
|---|
| 390 |
|
|---|
| 391 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 392 | return TRUE;
|
|---|
| 393 | }
|
|---|
| 394 | //******************************************************************************
|
|---|
| 395 | //******************************************************************************
|
|---|
| 396 | BOOL WIN32API SetViewportOrgEx(HDC hdc, int xOrg, int yOrg, LPPOINT pPoint)
|
|---|
| 397 | {
|
|---|
| 398 | pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
|
|---|
| 399 |
|
|---|
| 400 | if(pHps)
|
|---|
| 401 | {
|
|---|
| 402 | if(changePageXForm(pHps, (PPOINTL) &pHps->viewportOrg, xOrg,
|
|---|
| 403 | yOrg, (PPOINTL) pPoint))
|
|---|
| 404 | {
|
|---|
| 405 | //todo: metafile recording!!!
|
|---|
| 406 | dprintf(("SetViewPortOrgEx: %x (%d,%d), %x", hdc, xOrg, yOrg, pPoint));
|
|---|
| 407 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 408 | return TRUE;
|
|---|
| 409 | }
|
|---|
| 410 | dprintf(("WARNING: SetViewPortOrgEx: %x (%d,%d) %x-> changePageXForm failed!!!, %x", hdc, xOrg, yOrg, pPoint));
|
|---|
| 411 | SetLastError(ERROR_INVALID_PARAMETER_W); //TODO: translate PM error
|
|---|
| 412 | return FALSE;
|
|---|
| 413 | }
|
|---|
| 414 |
|
|---|
| 415 | dprintf(("WARNING: SetViewPortOrgEx: HDC %x not found!!", hdc));
|
|---|
| 416 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 417 | return FALSE;
|
|---|
| 418 | }
|
|---|
| 419 | //******************************************************************************
|
|---|
| 420 | //******************************************************************************
|
|---|
| 421 | BOOL WIN32API GetViewportOrgEx(HDC hdc, LPPOINT pPoint)
|
|---|
| 422 | {
|
|---|
| 423 | pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
|
|---|
| 424 | if(!pHps)
|
|---|
| 425 | {
|
|---|
| 426 | dprintf(("WARNING: GetViewportOrgEx %x %x -> INVALID HDC", hdc, pPoint));
|
|---|
| 427 | SetLastError(ERROR_INVALID_HANDLE_W);
|
|---|
| 428 | return FALSE;
|
|---|
| 429 | }
|
|---|
| 430 |
|
|---|
| 431 | if(!pPoint)
|
|---|
| 432 | {
|
|---|
| 433 | dprintf(("WARNING: GetViewportOrgEx %x NULL -> INVALID parameter", hdc));
|
|---|
| 434 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 435 | return FALSE;
|
|---|
| 436 | }
|
|---|
| 437 |
|
|---|
| 438 | pPoint->x = pHps->viewportOrg.x;
|
|---|
| 439 | pPoint->y = pHps->viewportOrg.y;
|
|---|
| 440 |
|
|---|
| 441 | dprintf(("GDI32: GetViewportOrgEx %x -> (%d,%d)", hdc, pPoint->x, pPoint->y));
|
|---|
| 442 |
|
|---|
| 443 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 444 | return TRUE;
|
|---|
| 445 | }
|
|---|
| 446 | //******************************************************************************
|
|---|
| 447 | //******************************************************************************
|
|---|
| 448 | BOOL WIN32API SetWindowExtEx(HDC hdc, int xExt, int yExt, LPSIZE pSize)
|
|---|
| 449 | {
|
|---|
| 450 | pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
|
|---|
| 451 | if(!pHps)
|
|---|
| 452 | {
|
|---|
| 453 | dprintf(("WARNING: SetWindowExtEx: HDC %x not found!!", hdc));
|
|---|
| 454 | SetLastError(ERROR_INVALID_HANDLE_W);
|
|---|
| 455 | return FALSE;
|
|---|
| 456 | }
|
|---|
| 457 |
|
|---|
| 458 | if(xExt && yExt)
|
|---|
| 459 | {
|
|---|
| 460 | //todo: metafile recording!!! (always)
|
|---|
| 461 |
|
|---|
| 462 | if(pHps->MapMode == MM_ISOTROPIC_W || pHps->MapMode == MM_ANISOTROPIC_W)
|
|---|
| 463 | {
|
|---|
| 464 | if(changePageXForm(pHps, (PPOINTL) &pHps->windowExt,
|
|---|
| 465 | xExt, yExt, (PPOINTL) pSize) )
|
|---|
| 466 | {
|
|---|
| 467 | dprintf(("SetWindowExtEx: %x (%d,%d), %x", hdc, xExt, yExt, pSize));
|
|---|
| 468 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 469 | return TRUE;
|
|---|
| 470 | }
|
|---|
| 471 | dprintf(("WARNING: SetWindowExtEx: %x (%d,%d) -> changePageXForm failed!!!, %x", hdc, xExt, yExt, pSize));
|
|---|
| 472 | SetLastError(ERROR_INVALID_PARAMETER_W); //TODO: translate PM error
|
|---|
| 473 | return FALSE;
|
|---|
| 474 | }
|
|---|
| 475 | else
|
|---|
| 476 | {
|
|---|
| 477 | pHps->lWndXExtSave = xExt, pHps->lWndYExtSave = yExt;
|
|---|
| 478 |
|
|---|
| 479 | //function is a no-op if map mode is not (AN)ISOTROPIC; NT returns TRUE
|
|---|
| 480 | dprintf(("SetWindowExtEx: %x (%d,%d), %x", hdc, xExt, yExt, pSize));
|
|---|
| 481 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 482 | return TRUE;
|
|---|
| 483 | }
|
|---|
| 484 | }
|
|---|
| 485 | dprintf(("WARNING: SetWindowExtEx %x (%d,%d) %x; invalid parameter", hdc, xExt, yExt, pSize));
|
|---|
| 486 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 487 | return FALSE;
|
|---|
| 488 | }
|
|---|
| 489 | //******************************************************************************
|
|---|
| 490 | //******************************************************************************
|
|---|
| 491 | BOOL WIN32API GetWindowExtEx(HDC hdc, LPSIZE pSize)
|
|---|
| 492 | {
|
|---|
| 493 | pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
|
|---|
| 494 | if(!pHps)
|
|---|
| 495 | {
|
|---|
| 496 | dprintf(("WARNING: GetWindowExtEx %x %x -> INVALID HDC", hdc, pSize));
|
|---|
| 497 | SetLastError(ERROR_INVALID_HANDLE_W);
|
|---|
| 498 | return FALSE;
|
|---|
| 499 | }
|
|---|
| 500 |
|
|---|
| 501 | if(!pSize)
|
|---|
| 502 | {
|
|---|
| 503 | dprintf(("WARNING: GetWindowExtEx %x NULL -> INVALID parameter", hdc));
|
|---|
| 504 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 505 | return FALSE;
|
|---|
| 506 | }
|
|---|
| 507 |
|
|---|
| 508 | pSize->cx = pHps->windowExt.cx;
|
|---|
| 509 | pSize->cy = pHps->windowExt.cy;
|
|---|
| 510 |
|
|---|
| 511 | dprintf(("GDI32: GetWindowExtEx %x -> (%d,%d)", hdc, pSize->cx, pSize->cy));
|
|---|
| 512 |
|
|---|
| 513 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 514 | return TRUE;
|
|---|
| 515 | }
|
|---|
| 516 | //******************************************************************************
|
|---|
| 517 | //******************************************************************************
|
|---|
| 518 | BOOL WIN32API SetWindowOrgEx(HDC hdc, int xOrg, int yOrg, LPPOINT pPoint)
|
|---|
| 519 | {
|
|---|
| 520 | pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
|
|---|
| 521 | if(pHps)
|
|---|
| 522 | {
|
|---|
| 523 | if(changePageXForm(pHps, (PPOINTL) &pHps->windowOrg, xOrg,
|
|---|
| 524 | yOrg, (PPOINTL) pPoint))
|
|---|
| 525 | {
|
|---|
| 526 | //todo: metafile recording!!!
|
|---|
| 527 |
|
|---|
| 528 | dprintf(("SetWindowOrgEx: %x (%d,%d), %x", hdc, xOrg, yOrg, pPoint));
|
|---|
| 529 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 530 | return TRUE;
|
|---|
| 531 | }
|
|---|
| 532 | //todo: set correct error
|
|---|
| 533 | dprintf(("WARNING: SetWindowOrgEx: %x (%d,%d) %x -> changePageXForm failed!!!, %x", hdc, xOrg, yOrg, pPoint));
|
|---|
| 534 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 535 | return FALSE;
|
|---|
| 536 | }
|
|---|
| 537 | dprintf(("WARNING: SetWindowOrgEx: HDC %x not found!!", hdc));
|
|---|
| 538 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 539 | return FALSE;
|
|---|
| 540 | }
|
|---|
| 541 | //******************************************************************************
|
|---|
| 542 | //******************************************************************************
|
|---|
| 543 | BOOL WIN32API GetWindowOrgEx(HDC hdc, LPPOINT pPoint)
|
|---|
| 544 | {
|
|---|
| 545 | pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
|
|---|
| 546 | if(!pHps)
|
|---|
| 547 | {
|
|---|
| 548 | dprintf(("WARNING: GetWindowOrgEx %x %x -> INVALID HDC", hdc, pPoint));
|
|---|
| 549 | SetLastError(ERROR_INVALID_HANDLE_W);
|
|---|
| 550 | return FALSE;
|
|---|
| 551 | }
|
|---|
| 552 |
|
|---|
| 553 | if(!pPoint)
|
|---|
| 554 | {
|
|---|
| 555 | dprintf(("WARNING: GetWindowOrgEx %x NULL -> INVALID parameter", hdc));
|
|---|
| 556 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 557 | return FALSE;
|
|---|
| 558 | }
|
|---|
| 559 |
|
|---|
| 560 | pPoint->x = pHps->windowOrg.x;
|
|---|
| 561 | pPoint->y = pHps->windowOrg.y;
|
|---|
| 562 |
|
|---|
| 563 | dprintf(("GDI32: GetWindowOrgEx %x -> (%d,%d)", hdc, pPoint->x, pPoint->y));
|
|---|
| 564 |
|
|---|
| 565 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 566 | return TRUE;
|
|---|
| 567 | }
|
|---|
| 568 | //******************************************************************************
|
|---|
| 569 | //******************************************************************************
|
|---|
| 570 | int WIN32API SetGraphicsMode(HDC hdc, int iMode)
|
|---|
| 571 | {
|
|---|
| 572 | pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
|
|---|
| 573 | if(!pHps)
|
|---|
| 574 | {
|
|---|
| 575 | dprintf(("WARNING: SetGraphicsMode HDC %x NOT FOUND!!", hdc));
|
|---|
| 576 | SetLastError(ERROR_INVALID_HANDLE_W);
|
|---|
| 577 | return 0;
|
|---|
| 578 | }
|
|---|
| 579 |
|
|---|
| 580 | if(iMode != GM_COMPATIBLE_W && iMode != GM_ADVANCED_W)
|
|---|
| 581 | {
|
|---|
| 582 | dprintf(("WARNING: SetGraphicsMode invalid mode %x!!", iMode));
|
|---|
| 583 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 584 | return 0;
|
|---|
| 585 | }
|
|---|
| 586 |
|
|---|
| 587 | //Only switch from GM_ADVANCED_W to GM_COMPATIBLE_W if default matrix is active
|
|---|
| 588 | if (iMode == GM_COMPATIBLE_W && pHps->graphicsMode == GM_ADVANCED_W)
|
|---|
| 589 | {
|
|---|
| 590 | MATRIXLF matrixlf;
|
|---|
| 591 |
|
|---|
| 592 | if(!GpiQueryModelTransformMatrix(pHps->hps, 9, &matrixlf))
|
|---|
| 593 | {
|
|---|
| 594 | dprintf(("WARNING: SetGraphicsMode %x %d; GpiQueryModelTransformMatrix failed!", hdc, iMode));
|
|---|
| 595 | SetLastError(ERROR_INVALID_PARAMETER_W); //todo translate PM error!!
|
|---|
| 596 | return 0;
|
|---|
| 597 |
|
|---|
| 598 | }
|
|---|
| 599 |
|
|---|
| 600 | if (!(matrixlf.fxM11 == MAKEFIXED(1,0) && matrixlf.fxM12 == MAKEFIXED(0,0) &&
|
|---|
| 601 | matrixlf.fxM21 == MAKEFIXED(0,0) && matrixlf.fxM22 == MAKEFIXED(1,0) &&
|
|---|
| 602 | matrixlf.lM31 == 0 && matrixlf.lM32 == 0 ))
|
|---|
| 603 | {
|
|---|
| 604 | dprintf(("WARNING: SetGraphicsMode %x %d; can't complete!", hdc, iMode));
|
|---|
| 605 | SetLastError(ERROR_CAN_NOT_COMPLETE_W); // done by NT
|
|---|
| 606 | return 0;
|
|---|
| 607 | }
|
|---|
| 608 | }
|
|---|
| 609 | int oldMode = pHps->graphicsMode;
|
|---|
| 610 |
|
|---|
| 611 | dprintf(("SetGraphicsMode %x %d (old mode %d)", hdc, iMode, oldMode));
|
|---|
| 612 | pHps->graphicsMode = iMode;
|
|---|
| 613 |
|
|---|
| 614 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 615 | return oldMode;
|
|---|
| 616 | }
|
|---|
| 617 | //******************************************************************************
|
|---|
| 618 | //******************************************************************************
|
|---|
| 619 | int WIN32API GetGraphicsMode(HDC hdc)
|
|---|
| 620 | {
|
|---|
| 621 | pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
|
|---|
| 622 | if (!pHps)
|
|---|
| 623 | {
|
|---|
| 624 | dprintf(("WARNING: GetGraphicsMode HDC %x NOT FOUND!!", hdc));
|
|---|
| 625 | SetLastError(ERROR_INVALID_HANDLE_W);
|
|---|
| 626 | return 0;
|
|---|
| 627 | }
|
|---|
| 628 |
|
|---|
| 629 | dprintf(("GetGraphicsMode %x = %x", hdc, pHps->graphicsMode));
|
|---|
| 630 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 631 | return pHps->graphicsMode;
|
|---|
| 632 | }
|
|---|
| 633 | //******************************************************************************
|
|---|
| 634 | //******************************************************************************
|
|---|
| 635 |
|
|---|