source: trunk/src/gdi32/transform.cpp@ 4557

Last change on this file since 4557 was 4557, checked in by sandervl, 25 years ago

rewrote transform +coordinate apis

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