| 1 | /* $Id: transform.cpp,v 1.4 2001-05-19 19:43:54 sandervl Exp $ */
|
|---|
| 2 |
|
|---|
| 3 | /*
|
|---|
| 4 | * GDI32 coordinate & transformation 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 | //region.cpp (todo; move to header)
|
|---|
| 37 | LONG hdcHeight(HWND hwnd, pDCData pHps);
|
|---|
| 38 | LONG hdcWidth(HWND hwnd, pDCData pHps);
|
|---|
| 39 |
|
|---|
| 40 | //******************************************************************************
|
|---|
| 41 | //******************************************************************************
|
|---|
| 42 | BOOL WIN32API LPtoDP(HDC hdc, PPOINT lpPoints, int nCount)
|
|---|
| 43 | {
|
|---|
| 44 | BOOL ret;
|
|---|
| 45 | DWORD hdcwidth, hdcheight;
|
|---|
| 46 | pDCData pHps;
|
|---|
| 47 |
|
|---|
| 48 | pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
|
|---|
| 49 | if(!pHps)
|
|---|
| 50 | {
|
|---|
| 51 | dprintf(("WARNING: LPtoDP %x invalid handle!!", hdc));
|
|---|
| 52 | SetLastError(ERROR_INVALID_HANDLE_W);
|
|---|
| 53 | return FALSE;
|
|---|
| 54 | }
|
|---|
| 55 |
|
|---|
| 56 | dprintf(("LPtoDP %x %x %d", hdc, lpPoints, nCount));
|
|---|
| 57 |
|
|---|
| 58 | //GpiConvert doesn't like illegal values; TODO: check what NT does
|
|---|
| 59 | if(nCount && lpPoints) {
|
|---|
| 60 | hdcwidth = hdcWidth(0, pHps);
|
|---|
| 61 | hdcheight = hdcHeight(0, pHps);
|
|---|
| 62 | for(int i=0;i<nCount;i++) {
|
|---|
| 63 | dprintf(("LPtoDP in (%d,%d)", lpPoints[i].x, lpPoints[i].y));
|
|---|
| 64 | if(lpPoints[i].x > hdcwidth) {
|
|---|
| 65 | dprintf(("WARNING: LPtoDP correcting x value; hdcwidth = %d", hdcwidth));
|
|---|
| 66 | lpPoints[i].x = 0;
|
|---|
| 67 | }
|
|---|
| 68 | if(lpPoints[i].y > hdcwidth) {
|
|---|
| 69 | dprintf(("WARNING: LPtoDP correcting y value; hdcheight = %d", hdcheight));
|
|---|
| 70 | lpPoints[i].y = 0;
|
|---|
| 71 | }
|
|---|
| 72 | }
|
|---|
| 73 | }
|
|---|
| 74 | ret = O32_LPtoDP(hdc, lpPoints, nCount);
|
|---|
| 75 | #ifdef DEBUG
|
|---|
| 76 | if(nCount && lpPoints) {
|
|---|
| 77 | for(int i=0;i<nCount;i++) {
|
|---|
| 78 | dprintf(("LPtoDP out (%d,%d)", lpPoints[i].x, lpPoints[i].y));
|
|---|
| 79 | }
|
|---|
| 80 | }
|
|---|
| 81 | #endif
|
|---|
| 82 | return ret;
|
|---|
| 83 | }
|
|---|
| 84 | //******************************************************************************
|
|---|
| 85 | //******************************************************************************
|
|---|
| 86 | BOOL WIN32API DPtoLP(HDC hdc, PPOINT lpPoints, int nCount)
|
|---|
| 87 | {
|
|---|
| 88 | BOOL ret;
|
|---|
| 89 | DWORD hdcwidth, hdcheight;
|
|---|
| 90 | pDCData pHps;
|
|---|
| 91 |
|
|---|
| 92 | pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
|
|---|
| 93 | if(!pHps)
|
|---|
| 94 | {
|
|---|
| 95 | dprintf(("WARNING: DPtoLP %x invalid handle!!", hdc));
|
|---|
| 96 | SetLastError(ERROR_INVALID_HANDLE_W);
|
|---|
| 97 | return FALSE;
|
|---|
| 98 | }
|
|---|
| 99 |
|
|---|
| 100 | dprintf(("GDI32: DPtoLP %x %x %d", hdc, lpPoints, nCount));
|
|---|
| 101 |
|
|---|
| 102 | //GpiConvert doesn't like illegal values; TODO: check what NT does
|
|---|
| 103 | if(nCount && lpPoints) {
|
|---|
| 104 | hdcwidth = hdcWidth(0, pHps);
|
|---|
| 105 | hdcheight = hdcHeight(0, pHps);
|
|---|
| 106 | for(int i=0;i<nCount;i++) {
|
|---|
| 107 | dprintf(("DPtoLP in (%d,%d)", lpPoints[i].x, lpPoints[i].y));
|
|---|
| 108 | if(lpPoints[i].x > hdcwidth) {
|
|---|
| 109 | dprintf(("WARNING: DPtoLP correcting x value; hdcwidth = %d", hdcwidth));
|
|---|
| 110 | lpPoints[i].x = 0;
|
|---|
| 111 | }
|
|---|
| 112 | if(lpPoints[i].y > hdcwidth) {
|
|---|
| 113 | dprintf(("WARNING: DPtoLP correcting y value; hdcheight = %d", hdcheight));
|
|---|
| 114 | lpPoints[i].y = 0;
|
|---|
| 115 | }
|
|---|
| 116 | }
|
|---|
| 117 | }
|
|---|
| 118 |
|
|---|
| 119 | ret = O32_DPtoLP(hdc, lpPoints, nCount);
|
|---|
| 120 | #ifdef DEBUG
|
|---|
| 121 | if(nCount && lpPoints) {
|
|---|
| 122 | for(int i=0;i<nCount;i++) {
|
|---|
| 123 | dprintf(("DPtoLP out (%d,%d)", lpPoints[i].x, lpPoints[i].y));
|
|---|
| 124 | }
|
|---|
| 125 | }
|
|---|
| 126 | #endif
|
|---|
| 127 | return ret;
|
|---|
| 128 | }
|
|---|
| 129 | //******************************************************************************
|
|---|
| 130 | //******************************************************************************
|
|---|
| 131 | BOOL WIN32API SetWorldTransform(HDC hdc, const XFORM_W * pXform)
|
|---|
| 132 | {
|
|---|
| 133 | BOOL ret;
|
|---|
| 134 |
|
|---|
| 135 | //Only proceed if DC is in GM_ADVANCED mode, unless it's a metafile PS
|
|---|
| 136 | pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
|
|---|
| 137 | if(!pHps || ((pHps->graphicsMode != GM_ADVANCED_W) && !pHps->isMetaPS))
|
|---|
| 138 | {
|
|---|
| 139 | dprintf(("WARNING: SetWorldTransform %x %x; not in GM_ADVANCED mode!!", hdc, pXform));
|
|---|
| 140 | SetLastError(ERROR_INVALID_HANDLE_W);
|
|---|
| 141 | return FALSE;
|
|---|
| 142 | }
|
|---|
| 143 |
|
|---|
| 144 | if(!pXform)
|
|---|
| 145 | {
|
|---|
| 146 | dprintf(("WARNING: SetWorldTransform %x %x; invalid parameter!!", hdc, pXform));
|
|---|
| 147 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 148 | return FALSE;
|
|---|
| 149 | }
|
|---|
| 150 |
|
|---|
| 151 | //todo: metafile recording!!!!
|
|---|
| 152 |
|
|---|
| 153 | MATRIXLF matrixlf;
|
|---|
| 154 | matrixlf.fxM11 = pXform->eM11 * (float)0x10000;
|
|---|
| 155 | matrixlf.fxM12 = pXform->eM12 * (float)0x10000;
|
|---|
| 156 | matrixlf.lM13 = 0;
|
|---|
| 157 | matrixlf.fxM21 = pXform->eM21 * (float)0x10000;
|
|---|
| 158 | matrixlf.fxM22 = pXform->eM22 * (float)0x10000;
|
|---|
| 159 | matrixlf.lM23 = 0;
|
|---|
| 160 | matrixlf.lM31 = pXform->eDx;
|
|---|
| 161 | matrixlf.lM32 = pXform->eDy;
|
|---|
| 162 | matrixlf.lM33 = 1;
|
|---|
| 163 |
|
|---|
| 164 | ret = GpiSetModelTransformMatrix(pHps->hps, 9, &matrixlf, TRANSFORM_REPLACE);
|
|---|
| 165 | if(ret)
|
|---|
| 166 | {
|
|---|
| 167 | TestWideLine(pHps);
|
|---|
| 168 | Calculate1PixelDelta(pHps);
|
|---|
| 169 | pHps->xform = *pXform; // save transform in DC struct
|
|---|
| 170 | dprintf(("SetWorldTransform %x %x", hdc, pXform));
|
|---|
| 171 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 172 | }
|
|---|
| 173 | else {
|
|---|
| 174 | dprintf(("WARNING: SetWorldTransform %x %x; GpiSetModelTransformMatrix failed!!", hdc, pXform));
|
|---|
| 175 | SetLastError(ERROR_INVALID_PARAMETER_W); //TODO: translate PM error
|
|---|
| 176 | }
|
|---|
| 177 | return ret;
|
|---|
| 178 | }
|
|---|
| 179 | //******************************************************************************
|
|---|
| 180 | //******************************************************************************
|
|---|
| 181 | BOOL WIN32API GetWorldTransform(HDC hdc, LPXFORM_W pXform)
|
|---|
| 182 | {
|
|---|
| 183 | pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
|
|---|
| 184 | if(!pHps)
|
|---|
| 185 | {
|
|---|
| 186 | dprintf(("WARNING: GetWorldTransform %x %x -> INVALID HDC", hdc, pXform));
|
|---|
| 187 | SetLastError(ERROR_INVALID_HANDLE_W);
|
|---|
| 188 | return FALSE;
|
|---|
| 189 | }
|
|---|
| 190 |
|
|---|
| 191 | if (!pXform)
|
|---|
| 192 | {
|
|---|
| 193 | dprintf(("WARNING: GetWorldTransform %x NULL -> INVALID parameter", hdc));
|
|---|
| 194 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 195 | return FALSE;
|
|---|
| 196 | }
|
|---|
| 197 |
|
|---|
| 198 | *pXform = pHps->xform;
|
|---|
| 199 |
|
|---|
| 200 | dprintf(("WARNING: GetWorldTransform %x %x", hdc, pXform));
|
|---|
| 201 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 202 | return TRUE;
|
|---|
| 203 | }
|
|---|
| 204 | //******************************************************************************
|
|---|
| 205 | //******************************************************************************
|
|---|
| 206 | BOOL WIN32API ModifyWorldTransform(HDC hdc, const XFORM_W *pXform, DWORD mode)
|
|---|
| 207 | {
|
|---|
| 208 | MATRIXLF matrixlf;
|
|---|
| 209 | LONG lOptions;
|
|---|
| 210 | BOOL ret;
|
|---|
| 211 |
|
|---|
| 212 | //Only proceed if DC is in GM_ADVANCED mode, unless it's a metafile PS
|
|---|
| 213 | pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
|
|---|
| 214 | if(!pHps || ((pHps->graphicsMode != GM_ADVANCED_W) && !pHps->isMetaPS))
|
|---|
| 215 | {
|
|---|
| 216 | dprintf(("WARNING: ModifyWorldTransform %x %x %x; not in GM_ADVANCED mode!!", hdc, pXform, mode));
|
|---|
| 217 | SetLastError(ERROR_INVALID_HANDLE_W);
|
|---|
| 218 | return FALSE;
|
|---|
| 219 | }
|
|---|
| 220 |
|
|---|
| 221 | if(mode == MWT_IDENTITY_W)
|
|---|
| 222 | {
|
|---|
| 223 | matrixlf.fxM11 = MAKEFIXED(1,0);
|
|---|
| 224 | matrixlf.fxM12 = 0;
|
|---|
| 225 | matrixlf.lM13 = 0;
|
|---|
| 226 | matrixlf.fxM21 = 0;
|
|---|
| 227 | matrixlf.fxM22 = MAKEFIXED(1,0);
|
|---|
| 228 | matrixlf.lM23 = 0;
|
|---|
| 229 | matrixlf.lM31 = 0;
|
|---|
| 230 | matrixlf.lM32 = 0;
|
|---|
| 231 | matrixlf.lM33 = MAKEFIXED(1,0);
|
|---|
| 232 |
|
|---|
| 233 | lOptions = TRANSFORM_REPLACE;
|
|---|
| 234 | }
|
|---|
| 235 | else
|
|---|
| 236 | if(mode == MWT_LEFTMULTIPLY_W || mode == MWT_RIGHTMULTIPLY_W)
|
|---|
| 237 | {
|
|---|
| 238 | matrixlf.fxM11 = pXform->eM11 * (float)0x10000;
|
|---|
| 239 | matrixlf.fxM12 = pXform->eM12 * (float)0x10000;
|
|---|
| 240 | matrixlf.lM13 = 0;
|
|---|
| 241 | matrixlf.fxM21 = pXform->eM21 * (float)0x10000;
|
|---|
| 242 | matrixlf.fxM22 = pXform->eM22 * (float)0x10000;
|
|---|
| 243 | matrixlf.lM23 = 0;
|
|---|
| 244 | matrixlf.lM31 = pXform->eDx;
|
|---|
| 245 | matrixlf.lM32 = pXform->eDy;
|
|---|
| 246 | matrixlf.lM33 = 1;
|
|---|
| 247 |
|
|---|
| 248 | if(mode == MWT_LEFTMULTIPLY_W) {
|
|---|
| 249 | lOptions = TRANSFORM_PREEMPT;
|
|---|
| 250 | }
|
|---|
| 251 | else lOptions = TRANSFORM_ADD;
|
|---|
| 252 | }
|
|---|
| 253 | else
|
|---|
| 254 | {
|
|---|
| 255 | dprintf(("WARNING: ModifyWorldTransform %x %x %x; invalid parameter!!", hdc, pXform, mode));
|
|---|
| 256 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 257 | return FALSE;
|
|---|
| 258 | }
|
|---|
| 259 | //todo: metafile recording!!!
|
|---|
| 260 |
|
|---|
| 261 | ret = GpiSetModelTransformMatrix( pHps->hps, 9, &matrixlf, lOptions);
|
|---|
| 262 | if(ret)
|
|---|
| 263 | {
|
|---|
| 264 | if(mode == MWT_IDENTITY_W) {
|
|---|
| 265 | pHps->xform = XFORMIdentity;
|
|---|
| 266 | }
|
|---|
| 267 | else GetWorldTransform(hdc, &pHps->xform);
|
|---|
| 268 |
|
|---|
| 269 | dprintf(("ModifyWorldTransform %x %x %d", hdc, pXform, mode));
|
|---|
| 270 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 271 | }
|
|---|
| 272 | else {
|
|---|
| 273 | dprintf(("ModifyWorldTransform %x %x %d; GpiSetModelTransformMatrix failed!!", hdc, pXform, mode));
|
|---|
| 274 | SetLastError(ERROR_INVALID_PARAMETER_W); //TODO: translate PM error
|
|---|
| 275 | }
|
|---|
| 276 |
|
|---|
| 277 | return ret;
|
|---|
| 278 | }
|
|---|
| 279 | //******************************************************************************
|
|---|
| 280 | //******************************************************************************
|
|---|
| 281 | BOOL WIN32API OffsetViewportOrgEx(HDC hdc, int xOffset, int yOffset, LPPOINT pPoint)
|
|---|
| 282 | {
|
|---|
| 283 | pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
|
|---|
| 284 |
|
|---|
| 285 | if(pHps && changePageXForm(pHps, (PPOINTL) &pHps->viewportOrg,
|
|---|
| 286 | xOffset + pHps->viewportOrg.x,
|
|---|
| 287 | yOffset + pHps->viewportOrg.y,
|
|---|
| 288 | (PPOINTL) pPoint))
|
|---|
| 289 | {
|
|---|
| 290 | //todo: metafile recording!!!
|
|---|
| 291 | dprintf(("OffsetViewportOrgEx %x (%d,%d) %x", hdc, xOffset, yOffset));
|
|---|
| 292 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 293 | return TRUE;
|
|---|
| 294 | }
|
|---|
| 295 |
|
|---|
| 296 | dprintf(("WARNING: OffsetViewportOrgEx %x (%d,%d) %x; HDC invalid or changePageXForm failed!!", hdc, xOffset, yOffset));
|
|---|
| 297 | SetLastError(ERROR_INVALID_PARAMETER_W); //TODO: translate PM error
|
|---|
| 298 | return FALSE;
|
|---|
| 299 | }
|
|---|
| 300 | //******************************************************************************
|
|---|
| 301 | //******************************************************************************
|
|---|
| 302 | BOOL WIN32API OffsetWindowOrgEx(HDC hdc, int xOffset, int yOffset, LPPOINT pPoint)
|
|---|
| 303 | {
|
|---|
| 304 | pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
|
|---|
| 305 |
|
|---|
| 306 | if(pHps && changePageXForm(pHps, (PPOINTL) &pHps->windowOrg,
|
|---|
| 307 | xOffset + pHps->windowOrg.x,
|
|---|
| 308 | yOffset + pHps->windowOrg.y,
|
|---|
| 309 | (PPOINTL) pPoint))
|
|---|
| 310 | {
|
|---|
| 311 | //todo: metafile recording!!!
|
|---|
| 312 | dprintf(("OffsetWindowOrgEx %x (%d,%d) %x", hdc, xOffset, yOffset));
|
|---|
| 313 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 314 | return TRUE;
|
|---|
| 315 | }
|
|---|
| 316 |
|
|---|
| 317 | dprintf(("WARNING: OffsetWindowOrgEx %x (%d,%d) %x; HDC invalid or changePageXForm failed!!", hdc, xOffset, yOffset));
|
|---|
| 318 | SetLastError(ERROR_INVALID_PARAMETER_W); //TODO: translate PM error
|
|---|
| 319 | return FALSE;
|
|---|
| 320 | }
|
|---|
| 321 | //******************************************************************************
|
|---|
| 322 | //******************************************************************************
|
|---|
| 323 | BOOL WIN32API ScaleViewportExtEx(HDC hdc, int xNum, int xDenom, int yNum, int yDenom, LPSIZE pSize)
|
|---|
| 324 | {
|
|---|
| 325 | pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
|
|---|
| 326 |
|
|---|
| 327 | if(!pHps)
|
|---|
| 328 | {
|
|---|
| 329 | dprintf(("WARNING: ScaleViewportExtEx %x (%d,%d) (%d,%d), %x; HDC INVALID!!1", hdc, xNum, xDenom, yNum, yDenom, pSize));
|
|---|
| 330 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 331 | return FALSE;
|
|---|
| 332 | }
|
|---|
| 333 |
|
|---|
| 334 | if(xNum && yNum && xDenom && yDenom &&
|
|---|
| 335 | (pHps->MapMode == MM_ISOTROPIC_W || pHps->MapMode == MM_ANISOTROPIC_W))
|
|---|
| 336 | {
|
|---|
| 337 | if(changePageXForm(pHps, NULL, pHps->viewportXExt * xNum / xDenom,
|
|---|
| 338 | pHps->viewportYExt * yNum / yDenom, (PPOINTL) pSize))
|
|---|
| 339 | {
|
|---|
| 340 | //todo: metafile recording!!!
|
|---|
| 341 | dprintf(("ScaleViewportExtEx %x (%d,%d) (%d,%d), %x", hdc, xNum, xDenom, yNum, yDenom, pSize));
|
|---|
| 342 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 343 | return TRUE;
|
|---|
| 344 | }
|
|---|
| 345 |
|
|---|
| 346 | dprintf(("WARNING: ScaleViewportExtEx %x (%d,%d) (%d,%d), %x; changePageXForm failed!!", hdc, xNum, xDenom, yNum, yDenom, pSize));
|
|---|
| 347 | SetLastError(ERROR_INVALID_PARAMETER_W); //TODO: translate PM error
|
|---|
| 348 | return FALSE;
|
|---|
| 349 | }
|
|---|
| 350 | else
|
|---|
| 351 | {
|
|---|
| 352 | pHps->lWndXExtSave = pHps->viewportXExt * xNum / xDenom;
|
|---|
| 353 | pHps->lWndYExtSave = pHps->viewportYExt * yNum / yDenom;
|
|---|
| 354 |
|
|---|
| 355 | //function is a no-op if map mode is not (AN)ISOTROPIC; NT returns TRUE
|
|---|
| 356 | dprintf(("ScaleViewportExtEx %x (%d,%d) (%d,%d), %x", hdc, xNum, xDenom, yNum, yDenom, pSize));
|
|---|
| 357 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 358 | return TRUE;
|
|---|
| 359 | }
|
|---|
| 360 | }
|
|---|
| 361 | //******************************************************************************
|
|---|
| 362 | //******************************************************************************
|
|---|
| 363 | BOOL WIN32API ScaleWindowExtEx(HDC hdc, int xNum, int xDenom, int yNum, int yDenom, LPSIZE pSize )
|
|---|
| 364 | {
|
|---|
| 365 | pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
|
|---|
| 366 |
|
|---|
| 367 | if(pHps && xDenom && yDenom)
|
|---|
| 368 | {
|
|---|
| 369 | if(changePageXForm(pHps, (PPOINTL) &pHps->windowExt,
|
|---|
| 370 | pHps->windowExt.cx * xNum / xDenom,
|
|---|
| 371 | pHps->windowExt.cy * yNum / yDenom,
|
|---|
| 372 | (PPOINTL) pSize))
|
|---|
| 373 | {
|
|---|
| 374 | //todo: metafile recording!!!
|
|---|
| 375 | dprintf(("ScaleWindowExtEx %x (%d,%d) (%d,%d), %x", hdc, xNum, xDenom, yNum, yDenom, pSize));
|
|---|
| 376 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 377 | return TRUE;
|
|---|
| 378 | }
|
|---|
| 379 |
|
|---|
| 380 | dprintf(("WARNING: ScaleWindowExtEx %x (%d,%d) (%d,%d), %x; changePageXForm failed!!", hdc, xNum, xDenom, yNum, yDenom, pSize));
|
|---|
| 381 | SetLastError(ERROR_INVALID_PARAMETER_W); //TODO: translate PM error
|
|---|
| 382 | return FALSE;
|
|---|
| 383 | }
|
|---|
| 384 |
|
|---|
| 385 | dprintf(("WARNING: ScaleWindowExtEx %x (%d,%d) (%d,%d), %x; invalid HDC!!", hdc, xNum, xDenom, yNum, yDenom, pSize));
|
|---|
| 386 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 387 | return FALSE;
|
|---|
| 388 | }
|
|---|
| 389 | //******************************************************************************
|
|---|
| 390 | //******************************************************************************
|
|---|
| 391 | int WIN32API SetMapMode(HDC hdc, int mode)
|
|---|
| 392 | {
|
|---|
| 393 | pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
|
|---|
| 394 | if(!pHps)
|
|---|
| 395 | {
|
|---|
| 396 | dprintf(("WARNING: SetMapMode %x %d; invalid HDC!!", hdc, mode));
|
|---|
| 397 | SetLastError(ERROR_INVALID_HANDLE_W);
|
|---|
| 398 | return 0;
|
|---|
| 399 | }
|
|---|
| 400 |
|
|---|
| 401 | //todo: metafile recording!!!
|
|---|
| 402 | dprintf(("SetMapMode %x %x", hdc, mode));
|
|---|
| 403 | return setMapMode(pHps, mode);
|
|---|
| 404 | }
|
|---|
| 405 | //******************************************************************************
|
|---|
| 406 | //******************************************************************************
|
|---|
| 407 | int WIN32API GetMapMode(HDC hdc)
|
|---|
| 408 | {
|
|---|
| 409 | pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
|
|---|
| 410 | if(pHps) {
|
|---|
| 411 | dprintf(("GDI32: GetMapMode %x -> %d", hdc, pHps->MapMode));
|
|---|
| 412 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 413 | return pHps->MapMode;
|
|---|
| 414 | }
|
|---|
| 415 | dprintf(("WARNING: GetMapMode %x invalid HDC!!", hdc));
|
|---|
| 416 | SetLastError(ERROR_INVALID_HANDLE_W);
|
|---|
| 417 | return 0;
|
|---|
| 418 | }
|
|---|
| 419 | //******************************************************************************
|
|---|
| 420 | //******************************************************************************
|
|---|
| 421 | BOOL WIN32API SetViewportExtEx( HDC hdc, int xExt, int yExt, LPSIZE pSize)
|
|---|
| 422 | {
|
|---|
| 423 | pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
|
|---|
| 424 | if (!pHps)
|
|---|
| 425 | {
|
|---|
| 426 | dprintf(("WARNING: SetViewPortExtEx: HDC %x not found!!", hdc));
|
|---|
| 427 | SetLastError(ERROR_INVALID_HANDLE_W);
|
|---|
| 428 | return FALSE;
|
|---|
| 429 | }
|
|---|
| 430 |
|
|---|
| 431 | if(xExt && yExt)
|
|---|
| 432 | {
|
|---|
| 433 | //todo: metafile recording!!! (always)
|
|---|
| 434 | if (pHps->MapMode == MM_ISOTROPIC_W || pHps->MapMode == MM_ANISOTROPIC_W )
|
|---|
| 435 | {
|
|---|
| 436 | if(changePageXForm(pHps, NULL, xExt, yExt, (PPOINTL)pSize))
|
|---|
| 437 | {
|
|---|
| 438 | dprintf(("SetViewPortExtEx: %x (%d,%d), %x", hdc, xExt, yExt, pSize));
|
|---|
| 439 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 440 | return TRUE;
|
|---|
| 441 | }
|
|---|
| 442 | }
|
|---|
| 443 | else
|
|---|
| 444 | {
|
|---|
| 445 | pHps->lVwpXExtSave = xExt, pHps->lVwpYExtSave = yExt;
|
|---|
| 446 |
|
|---|
| 447 | //function is a no-op if map mode is not (AN)ISOTROPIC; NT returns TRUE
|
|---|
| 448 | dprintf(("SetViewPortExtEx: %x (%d,%d), %x", hdc, xExt, yExt, pSize));
|
|---|
| 449 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 450 | return TRUE;
|
|---|
| 451 | }
|
|---|
| 452 |
|
|---|
| 453 | dprintf(("WARNING: SetViewPortExtEx: %x (%d,%d) -> changePageXForm failed!!!, %x", hdc, xExt, yExt, pSize));
|
|---|
| 454 | SetLastError(ERROR_INVALID_PARAMETER_W); //TODO: translate PM error
|
|---|
| 455 | return FALSE;
|
|---|
| 456 | }
|
|---|
| 457 |
|
|---|
| 458 | dprintf(("WARNING: SetViewPortExtEx: %x (%d,%d) -> invalid parameters!!!, %x", hdc, xExt, yExt, pSize));
|
|---|
| 459 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 460 | return FALSE;
|
|---|
| 461 | }
|
|---|
| 462 | //******************************************************************************
|
|---|
| 463 | //******************************************************************************
|
|---|
| 464 | BOOL WIN32API GetViewportExtEx(HDC hdc, LPSIZE pSize)
|
|---|
| 465 | {
|
|---|
| 466 | pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
|
|---|
| 467 | if(!pHps)
|
|---|
| 468 | {
|
|---|
| 469 | dprintf(("WARNING: GetViewportExtEx %x %x -> INVALID HDC", hdc, pSize));
|
|---|
| 470 | SetLastError(ERROR_INVALID_HANDLE_W);
|
|---|
| 471 | return FALSE;
|
|---|
| 472 | }
|
|---|
| 473 |
|
|---|
| 474 | if(!pSize)
|
|---|
| 475 | {
|
|---|
| 476 | dprintf(("WARNING: GetViewportExtEx %x NULL -> INVALID parameter", hdc));
|
|---|
| 477 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 478 | return FALSE;
|
|---|
| 479 | }
|
|---|
| 480 |
|
|---|
| 481 | pSize->cx = (LONG)pHps->viewportXExt;
|
|---|
| 482 | pSize->cy = (LONG)pHps->viewportYExt;
|
|---|
| 483 | dprintf(("GDI32: GetViewportExtEx %x -> (%d,%d)", hdc, pSize->cx, pSize->cy));
|
|---|
| 484 |
|
|---|
| 485 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 486 | return TRUE;
|
|---|
| 487 | }
|
|---|
| 488 | //******************************************************************************
|
|---|
| 489 | //******************************************************************************
|
|---|
| 490 | BOOL WIN32API SetViewportOrgEx(HDC hdc, int xOrg, int yOrg, LPPOINT pPoint)
|
|---|
| 491 | {
|
|---|
| 492 | pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
|
|---|
| 493 |
|
|---|
| 494 | if(pHps)
|
|---|
| 495 | {
|
|---|
| 496 | if(changePageXForm(pHps, (PPOINTL) &pHps->viewportOrg, xOrg,
|
|---|
| 497 | yOrg, (PPOINTL) pPoint))
|
|---|
| 498 | {
|
|---|
| 499 | //todo: metafile recording!!!
|
|---|
| 500 | dprintf(("SetViewPortOrgEx: %x (%d,%d), %x", hdc, xOrg, yOrg, pPoint));
|
|---|
| 501 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 502 | return TRUE;
|
|---|
| 503 | }
|
|---|
| 504 | dprintf(("WARNING: SetViewPortOrgEx: %x (%d,%d) %x-> changePageXForm failed!!!, %x", hdc, xOrg, yOrg, pPoint));
|
|---|
| 505 | SetLastError(ERROR_INVALID_PARAMETER_W); //TODO: translate PM error
|
|---|
| 506 | return FALSE;
|
|---|
| 507 | }
|
|---|
| 508 |
|
|---|
| 509 | dprintf(("WARNING: SetViewPortOrgEx: HDC %x not found!!", hdc));
|
|---|
| 510 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 511 | return FALSE;
|
|---|
| 512 | }
|
|---|
| 513 | //******************************************************************************
|
|---|
| 514 | //******************************************************************************
|
|---|
| 515 | BOOL WIN32API GetViewportOrgEx(HDC hdc, LPPOINT pPoint)
|
|---|
| 516 | {
|
|---|
| 517 | pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
|
|---|
| 518 | if(!pHps)
|
|---|
| 519 | {
|
|---|
| 520 | dprintf(("WARNING: GetViewportOrgEx %x %x -> INVALID HDC", hdc, pPoint));
|
|---|
| 521 | SetLastError(ERROR_INVALID_HANDLE_W);
|
|---|
| 522 | return FALSE;
|
|---|
| 523 | }
|
|---|
| 524 |
|
|---|
| 525 | if(!pPoint)
|
|---|
| 526 | {
|
|---|
| 527 | dprintf(("WARNING: GetViewportOrgEx %x NULL -> INVALID parameter", hdc));
|
|---|
| 528 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 529 | return FALSE;
|
|---|
| 530 | }
|
|---|
| 531 |
|
|---|
| 532 | pPoint->x = pHps->viewportOrg.x;
|
|---|
| 533 | pPoint->y = pHps->viewportOrg.y;
|
|---|
| 534 |
|
|---|
| 535 | dprintf(("GDI32: GetViewportOrgEx %x -> (%d,%d)", hdc, pPoint->x, pPoint->y));
|
|---|
| 536 |
|
|---|
| 537 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 538 | return TRUE;
|
|---|
| 539 | }
|
|---|
| 540 | //******************************************************************************
|
|---|
| 541 | //******************************************************************************
|
|---|
| 542 | BOOL WIN32API SetWindowExtEx(HDC hdc, int xExt, int yExt, LPSIZE pSize)
|
|---|
| 543 | {
|
|---|
| 544 | pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
|
|---|
| 545 | if(!pHps)
|
|---|
| 546 | {
|
|---|
| 547 | dprintf(("WARNING: SetWindowExtEx: HDC %x not found!!", hdc));
|
|---|
| 548 | SetLastError(ERROR_INVALID_HANDLE_W);
|
|---|
| 549 | return FALSE;
|
|---|
| 550 | }
|
|---|
| 551 |
|
|---|
| 552 | if(xExt && yExt)
|
|---|
| 553 | {
|
|---|
| 554 | //todo: metafile recording!!! (always)
|
|---|
| 555 |
|
|---|
| 556 | if(pHps->MapMode == MM_ISOTROPIC_W || pHps->MapMode == MM_ANISOTROPIC_W)
|
|---|
| 557 | {
|
|---|
| 558 | if(changePageXForm(pHps, (PPOINTL) &pHps->windowExt,
|
|---|
| 559 | xExt, yExt, (PPOINTL) pSize) )
|
|---|
| 560 | {
|
|---|
| 561 | dprintf(("SetWindowExtEx: %x (%d,%d), %x", hdc, xExt, yExt, pSize));
|
|---|
| 562 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 563 | return TRUE;
|
|---|
| 564 | }
|
|---|
| 565 | dprintf(("WARNING: SetWindowExtEx: %x (%d,%d) -> changePageXForm failed!!!, %x", hdc, xExt, yExt, pSize));
|
|---|
| 566 | SetLastError(ERROR_INVALID_PARAMETER_W); //TODO: translate PM error
|
|---|
| 567 | return FALSE;
|
|---|
| 568 | }
|
|---|
| 569 | else
|
|---|
| 570 | {
|
|---|
| 571 | pHps->lWndXExtSave = xExt, pHps->lWndYExtSave = yExt;
|
|---|
| 572 |
|
|---|
| 573 | //function is a no-op if map mode is not (AN)ISOTROPIC; NT returns TRUE
|
|---|
| 574 | dprintf(("SetWindowExtEx: %x (%d,%d), %x", hdc, xExt, yExt, pSize));
|
|---|
| 575 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 576 | return TRUE;
|
|---|
| 577 | }
|
|---|
| 578 | }
|
|---|
| 579 | dprintf(("WARNING: SetWindowExtEx %x (%d,%d) %x; invalid parameter", hdc, xExt, yExt, pSize));
|
|---|
| 580 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 581 | return FALSE;
|
|---|
| 582 | }
|
|---|
| 583 | //******************************************************************************
|
|---|
| 584 | //******************************************************************************
|
|---|
| 585 | BOOL WIN32API GetWindowExtEx(HDC hdc, LPSIZE pSize)
|
|---|
| 586 | {
|
|---|
| 587 | pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
|
|---|
| 588 | if(!pHps)
|
|---|
| 589 | {
|
|---|
| 590 | dprintf(("WARNING: GetWindowExtEx %x %x -> INVALID HDC", hdc, pSize));
|
|---|
| 591 | SetLastError(ERROR_INVALID_HANDLE_W);
|
|---|
| 592 | return FALSE;
|
|---|
| 593 | }
|
|---|
| 594 |
|
|---|
| 595 | if(!pSize)
|
|---|
| 596 | {
|
|---|
| 597 | dprintf(("WARNING: GetWindowExtEx %x NULL -> INVALID parameter", hdc));
|
|---|
| 598 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 599 | return FALSE;
|
|---|
| 600 | }
|
|---|
| 601 |
|
|---|
| 602 | pSize->cx = pHps->windowExt.cx;
|
|---|
| 603 | pSize->cy = pHps->windowExt.cy;
|
|---|
| 604 |
|
|---|
| 605 | dprintf(("GDI32: GetWindowExtEx %x -> (%d,%d)", hdc, pSize->cx, pSize->cy));
|
|---|
| 606 |
|
|---|
| 607 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 608 | return TRUE;
|
|---|
| 609 | }
|
|---|
| 610 | //******************************************************************************
|
|---|
| 611 | //******************************************************************************
|
|---|
| 612 | BOOL WIN32API SetWindowOrgEx(HDC hdc, int xOrg, int yOrg, LPPOINT pPoint)
|
|---|
| 613 | {
|
|---|
| 614 | pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
|
|---|
| 615 | if(pHps)
|
|---|
| 616 | {
|
|---|
| 617 | if(changePageXForm(pHps, (PPOINTL) &pHps->windowOrg, xOrg,
|
|---|
| 618 | yOrg, (PPOINTL) pPoint))
|
|---|
| 619 | {
|
|---|
| 620 | //todo: metafile recording!!!
|
|---|
| 621 |
|
|---|
| 622 | dprintf(("SetWindowOrgEx: %x (%d,%d), %x", hdc, xOrg, yOrg, pPoint));
|
|---|
| 623 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 624 | return TRUE;
|
|---|
| 625 | }
|
|---|
| 626 | //todo: set correct error
|
|---|
| 627 | dprintf(("WARNING: SetWindowOrgEx: %x (%d,%d) %x -> changePageXForm failed!!!, %x", hdc, xOrg, yOrg, pPoint));
|
|---|
| 628 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 629 | return FALSE;
|
|---|
| 630 | }
|
|---|
| 631 | dprintf(("WARNING: SetWindowOrgEx: HDC %x not found!!", hdc));
|
|---|
| 632 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 633 | return FALSE;
|
|---|
| 634 | }
|
|---|
| 635 | //******************************************************************************
|
|---|
| 636 | //******************************************************************************
|
|---|
| 637 | BOOL WIN32API GetWindowOrgEx(HDC hdc, LPPOINT pPoint)
|
|---|
| 638 | {
|
|---|
| 639 | pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
|
|---|
| 640 | if(!pHps)
|
|---|
| 641 | {
|
|---|
| 642 | dprintf(("WARNING: GetWindowOrgEx %x %x -> INVALID HDC", hdc, pPoint));
|
|---|
| 643 | SetLastError(ERROR_INVALID_HANDLE_W);
|
|---|
| 644 | return FALSE;
|
|---|
| 645 | }
|
|---|
| 646 |
|
|---|
| 647 | if(!pPoint)
|
|---|
| 648 | {
|
|---|
| 649 | dprintf(("WARNING: GetWindowOrgEx %x NULL -> INVALID parameter", hdc));
|
|---|
| 650 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 651 | return FALSE;
|
|---|
| 652 | }
|
|---|
| 653 |
|
|---|
| 654 | pPoint->x = pHps->windowOrg.x;
|
|---|
| 655 | pPoint->y = pHps->windowOrg.y;
|
|---|
| 656 |
|
|---|
| 657 | dprintf(("GDI32: GetWindowOrgEx %x -> (%d,%d)", hdc, pPoint->x, pPoint->y));
|
|---|
| 658 |
|
|---|
| 659 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 660 | return TRUE;
|
|---|
| 661 | }
|
|---|
| 662 | //******************************************************************************
|
|---|
| 663 | //******************************************************************************
|
|---|
| 664 | int WIN32API SetGraphicsMode(HDC hdc, int iMode)
|
|---|
| 665 | {
|
|---|
| 666 | pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
|
|---|
| 667 | if(!pHps)
|
|---|
| 668 | {
|
|---|
| 669 | dprintf(("WARNING: SetGraphicsMode HDC %x NOT FOUND!!", hdc));
|
|---|
| 670 | SetLastError(ERROR_INVALID_HANDLE_W);
|
|---|
| 671 | return 0;
|
|---|
| 672 | }
|
|---|
| 673 |
|
|---|
| 674 | if(iMode != GM_COMPATIBLE_W && iMode != GM_ADVANCED_W)
|
|---|
| 675 | {
|
|---|
| 676 | dprintf(("WARNING: SetGraphicsMode invalid mode %x!!", iMode));
|
|---|
| 677 | SetLastError(ERROR_INVALID_PARAMETER_W);
|
|---|
| 678 | return 0;
|
|---|
| 679 | }
|
|---|
| 680 |
|
|---|
| 681 | //Only switch from GM_ADVANCED_W to GM_COMPATIBLE_W if default matrix is active
|
|---|
| 682 | if (iMode == GM_COMPATIBLE_W && pHps->graphicsMode == GM_ADVANCED_W)
|
|---|
| 683 | {
|
|---|
| 684 | MATRIXLF matrixlf;
|
|---|
| 685 |
|
|---|
| 686 | if(!GpiQueryModelTransformMatrix(pHps->hps, 9, &matrixlf))
|
|---|
| 687 | {
|
|---|
| 688 | dprintf(("WARNING: SetGraphicsMode %x %d; GpiQueryModelTransformMatrix failed!", hdc, iMode));
|
|---|
| 689 | SetLastError(ERROR_INVALID_PARAMETER_W); //todo translate PM error!!
|
|---|
| 690 | return 0;
|
|---|
| 691 |
|
|---|
| 692 | }
|
|---|
| 693 |
|
|---|
| 694 | if (!(matrixlf.fxM11 == MAKEFIXED(1,0) && matrixlf.fxM12 == MAKEFIXED(0,0) &&
|
|---|
| 695 | matrixlf.fxM21 == MAKEFIXED(0,0) && matrixlf.fxM22 == MAKEFIXED(1,0) &&
|
|---|
| 696 | matrixlf.lM31 == 0 && matrixlf.lM32 == 0 ))
|
|---|
| 697 | {
|
|---|
| 698 | dprintf(("WARNING: SetGraphicsMode %x %d; can't complete!", hdc, iMode));
|
|---|
| 699 | SetLastError(ERROR_CAN_NOT_COMPLETE_W); // done by NT
|
|---|
| 700 | return 0;
|
|---|
| 701 | }
|
|---|
| 702 | }
|
|---|
| 703 | int oldMode = pHps->graphicsMode;
|
|---|
| 704 |
|
|---|
| 705 | dprintf(("SetGraphicsMode %x %d (old mode %d)", hdc, iMode, oldMode));
|
|---|
| 706 | pHps->graphicsMode = iMode;
|
|---|
| 707 |
|
|---|
| 708 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 709 | return oldMode;
|
|---|
| 710 | }
|
|---|
| 711 | //******************************************************************************
|
|---|
| 712 | //******************************************************************************
|
|---|
| 713 | int WIN32API GetGraphicsMode(HDC hdc)
|
|---|
| 714 | {
|
|---|
| 715 | pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
|
|---|
| 716 | if (!pHps)
|
|---|
| 717 | {
|
|---|
| 718 | dprintf(("WARNING: GetGraphicsMode HDC %x NOT FOUND!!", hdc));
|
|---|
| 719 | SetLastError(ERROR_INVALID_HANDLE_W);
|
|---|
| 720 | return 0;
|
|---|
| 721 | }
|
|---|
| 722 |
|
|---|
| 723 | dprintf(("GetGraphicsMode %x = %x", hdc, pHps->graphicsMode));
|
|---|
| 724 | SetLastError(ERROR_SUCCESS_W);
|
|---|
| 725 | return pHps->graphicsMode;
|
|---|
| 726 | }
|
|---|
| 727 | //******************************************************************************
|
|---|
| 728 | //******************************************************************************
|
|---|
| 729 |
|
|---|