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

Last change on this file since 5709 was 5709, checked in by sandervl, 24 years ago

logging updates

File size: 22.5 KB
Line 
1/* $Id: transform.cpp,v 1.3 2001-05-15 10:34:02 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
34static const XFORM_W XFORMIdentity = { 1.0, 0.0, 0.0, 1.0, 0, 0 };
35
36//******************************************************************************
37//******************************************************************************
38BOOL 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//******************************************************************************
88BOOL 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//******************************************************************************
113BOOL 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//******************************************************************************
188BOOL 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//******************************************************************************
209BOOL 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//******************************************************************************
230BOOL 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//******************************************************************************
270BOOL 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//******************************************************************************
298int 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 dprintf(("SetMapMode %x %x", hdc, mode));
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.