2 * GDI mapping mode functions
4 * Copyright 1993 Alexandre Julliard
11 /***********************************************************************
12 * MAPPING_FixIsotropic
14 * Fix viewport extensions for isotropic mode.
16 void MAPPING_FixIsotropic( DC
* dc
)
18 double xdim
= (double)dc
->vportExtX
* dc
->w
.devCaps
->horzSize
/
19 (dc
->w
.devCaps
->horzRes
* dc
->wndExtX
);
20 double ydim
= (double)dc
->vportExtY
* dc
->w
.devCaps
->vertSize
/
21 (dc
->w
.devCaps
->vertRes
* dc
->wndExtY
);
24 dc
->vportExtX
= dc
->vportExtX
* fabs( ydim
/ xdim
);
25 if (!dc
->vportExtX
) dc
->vportExtX
= 1;
29 dc
->vportExtY
= dc
->vportExtY
* fabs( xdim
/ ydim
);
30 if (!dc
->vportExtY
) dc
->vportExtY
= 1;
35 /***********************************************************************
38 BOOL16 WINAPI
DPtoLP16( HDC16 hdc
, LPPOINT16 points
, INT16 count
)
40 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
41 if (!dc
) return FALSE
;
45 points
->x
= XDPTOLP( dc
, points
->x
);
46 points
->y
= YDPTOLP( dc
, points
->y
);
53 /***********************************************************************
56 BOOL WINAPI
DPtoLP( HDC hdc
, LPPOINT points
, INT count
)
58 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
59 if (!dc
) return FALSE
;
63 if (!INTERNAL_DPTOLP( dc
, points
))
71 /***********************************************************************
74 BOOL16 WINAPI
LPtoDP16( HDC16 hdc
, LPPOINT16 points
, INT16 count
)
76 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
77 if (!dc
) return FALSE
;
81 points
->x
= XLPTODP( dc
, points
->x
);
82 points
->y
= YLPTODP( dc
, points
->y
);
89 /***********************************************************************
90 * LPtoDP32 (GDI32.247)
92 BOOL WINAPI
LPtoDP( HDC hdc
, LPPOINT points
, INT count
)
94 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
95 if (!dc
) return FALSE
;
99 INTERNAL_LPTODP( dc
, points
);
106 /***********************************************************************
107 * SetMapMode16 (GDI.3)
109 INT16 WINAPI
SetMapMode16( HDC16 hdc
, INT16 mode
)
111 return SetMapMode( hdc
, mode
);
115 /***********************************************************************
116 * SetMapMode32 (GDI32.321)
118 INT WINAPI
SetMapMode( HDC hdc
, INT mode
)
121 DC
* dc
= DC_GetDCPtr( hdc
);
123 if (dc
->funcs
->pSetMapMode
) return dc
->funcs
->pSetMapMode( dc
, mode
);
125 TRACE(gdi
, "%04x %d\n", hdc
, mode
);
127 prevMode
= dc
->w
.MapMode
;
131 dc
->wndOrgX
= dc
->wndOrgY
= 0;
132 dc
->vportOrgX
= dc
->vportOrgY
= 0;
141 dc
->wndOrgX
= dc
->wndOrgY
= 0;
142 dc
->vportOrgX
= dc
->vportOrgY
= 0;
143 dc
->wndExtX
= dc
->w
.devCaps
->horzSize
;
144 dc
->wndExtY
= dc
->w
.devCaps
->vertSize
;
145 dc
->vportExtX
= dc
->w
.devCaps
->horzRes
/ 10;
146 dc
->vportExtY
= dc
->w
.devCaps
->vertRes
/ -10;
150 dc
->wndOrgX
= dc
->wndOrgY
= 0;
151 dc
->vportOrgX
= dc
->vportOrgY
= 0;
152 dc
->wndExtX
= dc
->w
.devCaps
->horzSize
* 10;
153 dc
->wndExtY
= dc
->w
.devCaps
->vertSize
* 10;
154 dc
->vportExtX
= dc
->w
.devCaps
->horzRes
/ 10;
155 dc
->vportExtY
= dc
->w
.devCaps
->vertRes
/ -10;
159 dc
->wndOrgX
= dc
->wndOrgY
= 0;
160 dc
->vportOrgX
= dc
->vportOrgY
= 0;
161 dc
->wndExtX
= dc
->w
.devCaps
->horzSize
;
162 dc
->wndExtY
= dc
->w
.devCaps
->vertSize
;
163 dc
->vportExtX
= 254L * dc
->w
.devCaps
->horzRes
/ 1000;
164 dc
->vportExtY
= -254L * dc
->w
.devCaps
->vertRes
/ 1000;
168 dc
->wndOrgX
= dc
->wndOrgY
= 0;
169 dc
->vportOrgX
= dc
->vportOrgY
= 0;
170 dc
->wndExtX
= dc
->w
.devCaps
->horzSize
* 10;
171 dc
->wndExtY
= dc
->w
.devCaps
->vertSize
* 10;
172 dc
->vportExtX
= 254L * dc
->w
.devCaps
->horzRes
/ 1000;
173 dc
->vportExtY
= -254L * dc
->w
.devCaps
->vertRes
/ 1000;
177 dc
->wndOrgX
= dc
->wndOrgY
= 0;
178 dc
->vportOrgX
= dc
->vportOrgY
= 0;
179 dc
->wndExtX
= 144L * dc
->w
.devCaps
->horzSize
/ 10;
180 dc
->wndExtY
= 144L * dc
->w
.devCaps
->vertSize
/ 10;
181 dc
->vportExtX
= 254L * dc
->w
.devCaps
->horzRes
/ 1000;
182 dc
->vportExtY
= -254L * dc
->w
.devCaps
->vertRes
/ 1000;
191 dc
->w
.MapMode
= mode
;
192 DC_UpdateXforms( dc
);
197 /***********************************************************************
198 * SetViewportExt (GDI.14)
200 DWORD WINAPI
SetViewportExt16( HDC16 hdc
, INT16 x
, INT16 y
)
203 if (!SetViewportExtEx( hdc
, x
, y
, &size
)) return 0;
204 return MAKELONG( size
.cx
, size
.cy
);
208 /***********************************************************************
209 * SetViewportExtEx16 (GDI.479)
211 BOOL16 WINAPI
SetViewportExtEx16( HDC16 hdc
, INT16 x
, INT16 y
, LPSIZE16 size
)
214 BOOL16 ret
= SetViewportExtEx( hdc
, x
, y
, &size32
);
215 if (size
) CONV_SIZE32TO16( &size32
, size
);
220 /***********************************************************************
221 * SetViewportExtEx32 (GDI32.340)
223 BOOL WINAPI
SetViewportExtEx( HDC hdc
, INT x
, INT y
, LPSIZE size
)
225 DC
* dc
= DC_GetDCPtr( hdc
);
226 if (!dc
) return FALSE
;
227 if (dc
->funcs
->pSetViewportExt
)
228 return dc
->funcs
->pSetViewportExt( dc
, x
, y
);
231 size
->cx
= dc
->vportExtX
;
232 size
->cy
= dc
->vportExtY
;
234 if ((dc
->w
.MapMode
!= MM_ISOTROPIC
) && (dc
->w
.MapMode
!= MM_ANISOTROPIC
))
236 if (!x
|| !y
) return FALSE
;
239 if (dc
->w
.MapMode
== MM_ISOTROPIC
) MAPPING_FixIsotropic( dc
);
240 DC_UpdateXforms( dc
);
245 /***********************************************************************
246 * SetViewportOrg (GDI.13)
248 DWORD WINAPI
SetViewportOrg16( HDC16 hdc
, INT16 x
, INT16 y
)
251 if (!SetViewportOrgEx( hdc
, x
, y
, &pt
)) return 0;
252 return MAKELONG( pt
.x
, pt
.y
);
256 /***********************************************************************
257 * SetViewportOrgEx16 (GDI.480)
259 BOOL16 WINAPI
SetViewportOrgEx16( HDC16 hdc
, INT16 x
, INT16 y
, LPPOINT16 pt
)
262 BOOL16 ret
= SetViewportOrgEx( hdc
, x
, y
, &pt32
);
263 if (pt
) CONV_POINT32TO16( &pt32
, pt
);
268 /***********************************************************************
269 * SetViewportOrgEx32 (GDI32.341)
271 BOOL WINAPI
SetViewportOrgEx( HDC hdc
, INT x
, INT y
, LPPOINT pt
)
273 DC
* dc
= DC_GetDCPtr( hdc
);
274 if (!dc
) return FALSE
;
275 if (dc
->funcs
->pSetViewportOrg
)
276 return dc
->funcs
->pSetViewportOrg( dc
, x
, y
);
279 pt
->x
= dc
->vportOrgX
;
280 pt
->y
= dc
->vportOrgY
;
284 DC_UpdateXforms( dc
);
289 /***********************************************************************
290 * SetWindowExt (GDI.12)
292 DWORD WINAPI
SetWindowExt16( HDC16 hdc
, INT16 x
, INT16 y
)
295 if (!SetWindowExtEx( hdc
, x
, y
, &size
)) return 0;
296 return MAKELONG( size
.cx
, size
.cy
);
300 /***********************************************************************
301 * SetWindowExtEx16 (GDI.481)
303 BOOL16 WINAPI
SetWindowExtEx16( HDC16 hdc
, INT16 x
, INT16 y
, LPSIZE16 size
)
306 BOOL16 ret
= SetWindowExtEx( hdc
, x
, y
, &size32
);
307 if (size
) CONV_SIZE32TO16( &size32
, size
);
312 /***********************************************************************
313 * SetWindowExtEx32 (GDI32.344)
315 BOOL WINAPI
SetWindowExtEx( HDC hdc
, INT x
, INT y
, LPSIZE size
)
317 DC
* dc
= DC_GetDCPtr( hdc
);
318 if (!dc
) return FALSE
;
319 if (dc
->funcs
->pSetWindowExt
) return dc
->funcs
->pSetWindowExt( dc
, x
, y
);
322 size
->cx
= dc
->wndExtX
;
323 size
->cy
= dc
->wndExtY
;
325 if ((dc
->w
.MapMode
!= MM_ISOTROPIC
) && (dc
->w
.MapMode
!= MM_ANISOTROPIC
))
327 if (!x
|| !y
) return FALSE
;
330 if (dc
->w
.MapMode
== MM_ISOTROPIC
) MAPPING_FixIsotropic( dc
);
331 DC_UpdateXforms( dc
);
336 /***********************************************************************
337 * SetWindowOrg (GDI.11)
339 DWORD WINAPI
SetWindowOrg16( HDC16 hdc
, INT16 x
, INT16 y
)
342 if (!SetWindowOrgEx( hdc
, x
, y
, &pt
)) return 0;
343 return MAKELONG( pt
.x
, pt
.y
);
347 /***********************************************************************
348 * SetWindowOrgEx16 (GDI.482)
350 BOOL16 WINAPI
SetWindowOrgEx16( HDC16 hdc
, INT16 x
, INT16 y
, LPPOINT16 pt
)
353 BOOL16 ret
= SetWindowOrgEx( hdc
, x
, y
, &pt32
);
354 if (pt
) CONV_POINT32TO16( &pt32
, pt
);
359 /***********************************************************************
360 * SetWindowOrgEx32 (GDI32.345)
362 BOOL WINAPI
SetWindowOrgEx( HDC hdc
, INT x
, INT y
, LPPOINT pt
)
364 DC
* dc
= DC_GetDCPtr( hdc
);
365 if (!dc
) return FALSE
;
366 if (dc
->funcs
->pSetWindowOrg
) return dc
->funcs
->pSetWindowOrg( dc
, x
, y
);
374 DC_UpdateXforms( dc
);
379 /***********************************************************************
380 * OffsetViewportOrg (GDI.17)
382 DWORD WINAPI
OffsetViewportOrg16( HDC16 hdc
, INT16 x
, INT16 y
)
385 if (!OffsetViewportOrgEx( hdc
, x
, y
, &pt
)) return 0;
386 return MAKELONG( pt
.x
, pt
.y
);
390 /***********************************************************************
391 * OffsetViewportOrgEx16 (GDI.476)
393 BOOL16 WINAPI
OffsetViewportOrgEx16( HDC16 hdc
, INT16 x
, INT16 y
, LPPOINT16 pt
)
396 BOOL16 ret
= OffsetViewportOrgEx( hdc
, x
, y
, &pt32
);
397 if (pt
) CONV_POINT32TO16( &pt32
, pt
);
402 /***********************************************************************
403 * OffsetViewportOrgEx32 (GDI32.257)
405 BOOL WINAPI
OffsetViewportOrgEx( HDC hdc
, INT x
, INT y
, LPPOINT pt
)
407 DC
* dc
= DC_GetDCPtr( hdc
);
408 if (!dc
) return FALSE
;
409 if (dc
->funcs
->pOffsetViewportOrg
)
410 return dc
->funcs
->pOffsetViewportOrg( dc
, x
, y
);
413 pt
->x
= dc
->vportOrgX
;
414 pt
->y
= dc
->vportOrgY
;
418 DC_UpdateXforms( dc
);
423 /***********************************************************************
424 * OffsetWindowOrg (GDI.15)
426 DWORD WINAPI
OffsetWindowOrg16( HDC16 hdc
, INT16 x
, INT16 y
)
429 if (!OffsetWindowOrgEx( hdc
, x
, y
, &pt
)) return 0;
430 return MAKELONG( pt
.x
, pt
.y
);
434 /***********************************************************************
435 * OffsetWindowOrgEx16 (GDI.477)
437 BOOL16 WINAPI
OffsetWindowOrgEx16( HDC16 hdc
, INT16 x
, INT16 y
, LPPOINT16 pt
)
440 BOOL16 ret
= OffsetWindowOrgEx( hdc
, x
, y
, &pt32
);
441 if (pt
) CONV_POINT32TO16( &pt32
, pt
);
446 /***********************************************************************
447 * OffsetWindowOrgEx32 (GDI32.258)
449 BOOL WINAPI
OffsetWindowOrgEx( HDC hdc
, INT x
, INT y
, LPPOINT pt
)
451 DC
* dc
= DC_GetDCPtr( hdc
);
452 if (!dc
) return FALSE
;
453 if (dc
->funcs
->pOffsetWindowOrg
)
454 return dc
->funcs
->pOffsetWindowOrg( dc
, x
, y
);
462 DC_UpdateXforms( dc
);
467 /***********************************************************************
468 * ScaleViewportExt (GDI.18)
470 DWORD WINAPI
ScaleViewportExt16( HDC16 hdc
, INT16 xNum
, INT16 xDenom
,
471 INT16 yNum
, INT16 yDenom
)
474 if (!ScaleViewportExtEx( hdc
, xNum
, xDenom
, yNum
, yDenom
, &size
))
476 return MAKELONG( size
.cx
, size
.cy
);
480 /***********************************************************************
481 * ScaleViewportExtEx16 (GDI.484)
483 BOOL16 WINAPI
ScaleViewportExtEx16( HDC16 hdc
, INT16 xNum
, INT16 xDenom
,
484 INT16 yNum
, INT16 yDenom
, LPSIZE16 size
)
487 BOOL16 ret
= ScaleViewportExtEx( hdc
, xNum
, xDenom
, yNum
, yDenom
,
489 if (size
) CONV_SIZE32TO16( &size32
, size
);
494 /***********************************************************************
495 * ScaleViewportExtEx32 (GDI32.293)
497 BOOL WINAPI
ScaleViewportExtEx( HDC hdc
, INT xNum
, INT xDenom
,
498 INT yNum
, INT yDenom
, LPSIZE size
)
500 DC
* dc
= DC_GetDCPtr( hdc
);
501 if (!dc
) return FALSE
;
502 if (dc
->funcs
->pScaleViewportExt
)
503 return dc
->funcs
->pScaleViewportExt( dc
, xNum
, xDenom
, yNum
, yDenom
);
506 size
->cx
= dc
->vportExtX
;
507 size
->cy
= dc
->vportExtY
;
509 if ((dc
->w
.MapMode
!= MM_ISOTROPIC
) && (dc
->w
.MapMode
!= MM_ANISOTROPIC
))
511 if (!xNum
|| !xDenom
|| !xNum
|| !yDenom
) return FALSE
;
512 dc
->vportExtX
= (dc
->vportExtX
* xNum
) / xDenom
;
513 dc
->vportExtY
= (dc
->vportExtY
* yNum
) / yDenom
;
514 if (dc
->vportExtX
== 0) dc
->vportExtX
= 1;
515 if (dc
->vportExtY
== 0) dc
->vportExtY
= 1;
516 if (dc
->w
.MapMode
== MM_ISOTROPIC
) MAPPING_FixIsotropic( dc
);
517 DC_UpdateXforms( dc
);
522 /***********************************************************************
523 * ScaleWindowExt (GDI.16)
525 DWORD WINAPI
ScaleWindowExt16( HDC16 hdc
, INT16 xNum
, INT16 xDenom
,
526 INT16 yNum
, INT16 yDenom
)
529 if (!ScaleWindowExtEx( hdc
, xNum
, xDenom
, yNum
, yDenom
, &size
))
531 return MAKELONG( size
.cx
, size
.cy
);
535 /***********************************************************************
536 * ScaleWindowExtEx16 (GDI.485)
538 BOOL16 WINAPI
ScaleWindowExtEx16( HDC16 hdc
, INT16 xNum
, INT16 xDenom
,
539 INT16 yNum
, INT16 yDenom
, LPSIZE16 size
)
542 BOOL16 ret
= ScaleWindowExtEx( hdc
, xNum
, xDenom
, yNum
, yDenom
,
544 if (size
) CONV_SIZE32TO16( &size32
, size
);
549 /***********************************************************************
550 * ScaleWindowExtEx32 (GDI32.294)
552 BOOL WINAPI
ScaleWindowExtEx( HDC hdc
, INT xNum
, INT xDenom
,
553 INT yNum
, INT yDenom
, LPSIZE size
)
555 DC
* dc
= DC_GetDCPtr( hdc
);
556 if (!dc
) return FALSE
;
557 if (dc
->funcs
->pScaleWindowExt
)
558 return dc
->funcs
->pScaleWindowExt( dc
, xNum
, xDenom
, yNum
, yDenom
);
561 size
->cx
= dc
->wndExtX
;
562 size
->cy
= dc
->wndExtY
;
564 if ((dc
->w
.MapMode
!= MM_ISOTROPIC
) && (dc
->w
.MapMode
!= MM_ANISOTROPIC
))
566 if (!xNum
|| !xDenom
|| !xNum
|| !yDenom
) return FALSE
;
567 dc
->wndExtX
= (dc
->wndExtX
* xNum
) / xDenom
;
568 dc
->wndExtY
= (dc
->wndExtY
* yNum
) / yDenom
;
569 if (dc
->wndExtX
== 0) dc
->wndExtX
= 1;
570 if (dc
->wndExtY
== 0) dc
->wndExtY
= 1;
571 if (dc
->w
.MapMode
== MM_ISOTROPIC
) MAPPING_FixIsotropic( dc
);
572 DC_UpdateXforms( dc
);