blob: 507c78989fdf96649f4cdc28f0f7e33a60c7ac0f [file] [log] [blame]
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +00001/*
2 * GDI mapping mode functions
3 *
4 * Copyright 1993 Alexandre Julliard
Alexandre Julliard0799c1a2002-03-09 23:29:33 +00005 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +000019 */
20
Alexandre Julliard2239abb2000-11-05 02:05:07 +000021#include "gdi.h"
Michael Stefaniuc28a632a2002-11-21 21:50:04 +000022#include "wownt32.h"
Alexandre Julliard6ec42c02004-01-15 00:35:38 +000023#include "gdi_private.h"
Alexandre Julliard0799c1a2002-03-09 23:29:33 +000024#include "wine/debug.h"
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +000025
Alexandre Julliard0799c1a2002-03-09 23:29:33 +000026WINE_DEFAULT_DEBUG_CHANNEL(gdi);
Patrik Stridvallb4b9fae1999-04-19 14:56:29 +000027
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +000028
29/***********************************************************************
30 * MAPPING_FixIsotropic
31 *
32 * Fix viewport extensions for isotropic mode.
33 */
34void MAPPING_FixIsotropic( DC * dc )
35{
Alexandre Julliard99bb9f92001-07-28 00:18:02 +000036 double xdim = (double)dc->vportExtX * GetDeviceCaps( dc->hSelf, HORZSIZE ) /
37 (GetDeviceCaps( dc->hSelf, HORZRES ) * dc->wndExtX);
38 double ydim = (double)dc->vportExtY * GetDeviceCaps( dc->hSelf, VERTSIZE ) /
39 (GetDeviceCaps( dc->hSelf, VERTRES ) * dc->wndExtY);
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +000040 if (xdim > ydim)
41 {
Dmitry Timoshkove8e10e92003-05-11 02:50:21 +000042 dc->vportExtX = floor(dc->vportExtX * fabs( ydim / xdim ) + 0.5);
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +000043 if (!dc->vportExtX) dc->vportExtX = 1;
44 }
45 else
46 {
Dmitry Timoshkove8e10e92003-05-11 02:50:21 +000047 dc->vportExtY = floor(dc->vportExtY * fabs( xdim / ydim ) + 0.5);
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +000048 if (!dc->vportExtY) dc->vportExtY = 1;
Alexandre Julliard99bb9f92001-07-28 00:18:02 +000049 }
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +000050}
51
52
53/***********************************************************************
Patrik Stridvall01d5e5b2001-07-02 19:59:40 +000054 * DPtoLP (GDI.67)
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +000055 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +000056BOOL16 WINAPI DPtoLP16( HDC16 hdc, LPPOINT16 points, INT16 count )
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +000057{
Michael Stefaniuc28a632a2002-11-21 21:50:04 +000058 DC * dc = DC_GetDCPtr( HDC_32(hdc) );
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +000059 if (!dc) return FALSE;
60
61 while (count--)
62 {
Alexandre Julliard5ee15992002-06-25 23:29:51 +000063 points->x = MulDiv( points->x - dc->vportOrgX, dc->wndExtX, dc->vportExtX ) + dc->wndOrgX;
64 points->y = MulDiv( points->y - dc->vportOrgY, dc->wndExtY, dc->vportExtY ) + dc->wndOrgY;
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +000065 points++;
66 }
Michael Stefaniuc28a632a2002-11-21 21:50:04 +000067 GDI_ReleaseObj( HDC_32(hdc) );
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +000068 return TRUE;
69}
70
71
72/***********************************************************************
Patrik Stridvalld0a41772001-02-14 23:11:17 +000073 * DPtoLP (GDI32.@)
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +000074 */
Alexandre Julliarda3960291999-02-26 11:11:13 +000075BOOL WINAPI DPtoLP( HDC hdc, LPPOINT points, INT count )
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +000076{
Alexandre Julliardd8a92442002-05-31 18:43:22 +000077 DC * dc = DC_GetDCPtr( hdc );
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +000078 if (!dc) return FALSE;
79
Alexandre Julliard5ee15992002-06-25 23:29:51 +000080 if (dc->vport2WorldValid)
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +000081 {
Alexandre Julliard5ee15992002-06-25 23:29:51 +000082 while (count--)
83 {
84 FLOAT x = points->x;
85 FLOAT y = points->y;
86 points->x = floor( x * dc->xformVport2World.eM11 +
87 y * dc->xformVport2World.eM21 +
88 dc->xformVport2World.eDx + 0.5 );
89 points->y = floor( x * dc->xformVport2World.eM12 +
90 y * dc->xformVport2World.eM22 +
91 dc->xformVport2World.eDy + 0.5 );
92 points++;
93 }
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +000094 }
Alexandre Julliard2a2321b2000-08-19 21:38:55 +000095 GDI_ReleaseObj( hdc );
96 return (count < 0);
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +000097}
98
99
100/***********************************************************************
Patrik Stridvall01d5e5b2001-07-02 19:59:40 +0000101 * LPtoDP (GDI.99)
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000102 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000103BOOL16 WINAPI LPtoDP16( HDC16 hdc, LPPOINT16 points, INT16 count )
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000104{
Michael Stefaniuc28a632a2002-11-21 21:50:04 +0000105 DC * dc = DC_GetDCPtr( HDC_32(hdc) );
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000106 if (!dc) return FALSE;
107
108 while (count--)
109 {
Alexandre Julliard5ee15992002-06-25 23:29:51 +0000110 points->x = MulDiv( points->x - dc->wndOrgX, dc->vportExtX, dc->wndExtX ) + dc->vportOrgX;
111 points->y = MulDiv( points->y - dc->wndOrgY, dc->vportExtY, dc->wndExtY ) + dc->vportOrgY;
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000112 points++;
113 }
Michael Stefaniuc28a632a2002-11-21 21:50:04 +0000114 GDI_ReleaseObj( HDC_32(hdc) );
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000115 return TRUE;
116}
117
118
119/***********************************************************************
Patrik Stridvalld0a41772001-02-14 23:11:17 +0000120 * LPtoDP (GDI32.@)
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000121 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000122BOOL WINAPI LPtoDP( HDC hdc, LPPOINT points, INT count )
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000123{
Alexandre Julliardd8a92442002-05-31 18:43:22 +0000124 DC * dc = DC_GetDCPtr( hdc );
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000125 if (!dc) return FALSE;
126
127 while (count--)
128 {
Alexandre Julliard5ee15992002-06-25 23:29:51 +0000129 FLOAT x = points->x;
130 FLOAT y = points->y;
131 points->x = floor( x * dc->xformWorld2Vport.eM11 +
132 y * dc->xformWorld2Vport.eM21 +
133 dc->xformWorld2Vport.eDx + 0.5 );
134 points->y = floor( x * dc->xformWorld2Vport.eM12 +
135 y * dc->xformWorld2Vport.eM22 +
136 dc->xformWorld2Vport.eDy + 0.5 );
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000137 points++;
138 }
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000139 GDI_ReleaseObj( hdc );
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000140 return TRUE;
141}
142
143
144/***********************************************************************
Patrik Stridvalld0a41772001-02-14 23:11:17 +0000145 * SetMapMode (GDI32.@)
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000146 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000147INT WINAPI SetMapMode( HDC hdc, INT mode )
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000148{
Huw D M Davies3d10c1f2002-08-17 18:32:12 +0000149 INT ret;
Alexandre Julliard99bb9f92001-07-28 00:18:02 +0000150 INT horzSize, vertSize, horzRes, vertRes;
151
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000152 DC * dc = DC_GetDCPtr( hdc );
153 if (!dc) return 0;
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000154 if (dc->funcs->pSetMapMode)
155 {
Huw D M Davies3d10c1f2002-08-17 18:32:12 +0000156 if((ret = dc->funcs->pSetMapMode( dc->physDev, mode )) != TRUE)
157 {
158 if(ret == GDI_NO_MORE_WORK)
159 ret = TRUE;
160 goto done;
161 }
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000162 }
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000163
Alexandre Julliard547cdc22002-11-22 22:16:53 +0000164 TRACE("%p %d\n", hdc, mode );
Alexandre Julliard99bb9f92001-07-28 00:18:02 +0000165
Huw D M Davies3d10c1f2002-08-17 18:32:12 +0000166 ret = dc->MapMode;
Dmitry Timoshkove8e10e92003-05-11 02:50:21 +0000167
168 if (mode == dc->MapMode && (mode == MM_ISOTROPIC || mode == MM_ANISOTROPIC))
169 goto done;
170
Alexandre Julliard99bb9f92001-07-28 00:18:02 +0000171 horzSize = GetDeviceCaps( hdc, HORZSIZE );
172 vertSize = GetDeviceCaps( hdc, VERTSIZE );
173 horzRes = GetDeviceCaps( hdc, HORZRES );
174 vertRes = GetDeviceCaps( hdc, VERTRES );
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000175 switch(mode)
176 {
Alexandre Julliard99bb9f92001-07-28 00:18:02 +0000177 case MM_TEXT:
178 dc->wndExtX = 1;
179 dc->wndExtY = 1;
180 dc->vportExtX = 1;
181 dc->vportExtY = 1;
182 break;
183 case MM_LOMETRIC:
184 case MM_ISOTROPIC:
Dmitry Timoshkove8e10e92003-05-11 02:50:21 +0000185 dc->wndExtX = horzSize * 10;
186 dc->wndExtY = vertSize * 10;
187 dc->vportExtX = horzRes;
188 dc->vportExtY = -vertRes;
Alexandre Julliard99bb9f92001-07-28 00:18:02 +0000189 break;
190 case MM_HIMETRIC:
Dmitry Timoshkove8e10e92003-05-11 02:50:21 +0000191 dc->wndExtX = horzSize * 100;
192 dc->wndExtY = vertSize * 100;
193 dc->vportExtX = horzRes;
194 dc->vportExtY = -vertRes;
Alexandre Julliard99bb9f92001-07-28 00:18:02 +0000195 break;
196 case MM_LOENGLISH:
Dmitry Timoshkove8e10e92003-05-11 02:50:21 +0000197 dc->wndExtX = MulDiv(1000, horzSize, 254);
198 dc->wndExtY = MulDiv(1000, vertSize, 254);
199 dc->vportExtX = horzRes;
200 dc->vportExtY = -vertRes;
Alexandre Julliard99bb9f92001-07-28 00:18:02 +0000201 break;
202 case MM_HIENGLISH:
Dmitry Timoshkove8e10e92003-05-11 02:50:21 +0000203 dc->wndExtX = MulDiv(10000, horzSize, 254);
204 dc->wndExtY = MulDiv(10000, vertSize, 254);
205 dc->vportExtX = horzRes;
206 dc->vportExtY = -vertRes;
Alexandre Julliard99bb9f92001-07-28 00:18:02 +0000207 break;
208 case MM_TWIPS:
Dmitry Timoshkove8e10e92003-05-11 02:50:21 +0000209 dc->wndExtX = MulDiv(14400, horzSize, 254);
210 dc->wndExtY = MulDiv(14400, vertSize, 254);
211 dc->vportExtX = horzRes;
212 dc->vportExtY = -vertRes;
Alexandre Julliard99bb9f92001-07-28 00:18:02 +0000213 break;
214 case MM_ANISOTROPIC:
215 break;
216 default:
217 goto done;
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000218 }
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000219 dc->MapMode = mode;
Alexandre Julliarddadf78f1998-05-17 17:13:43 +0000220 DC_UpdateXforms( dc );
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000221 done:
222 GDI_ReleaseObj( hdc );
Huw D M Davies3d10c1f2002-08-17 18:32:12 +0000223 return ret;
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000224}
225
226
227/***********************************************************************
Patrik Stridvalld0a41772001-02-14 23:11:17 +0000228 * SetViewportExtEx (GDI32.@)
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000229 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000230BOOL WINAPI SetViewportExtEx( HDC hdc, INT x, INT y, LPSIZE size )
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000231{
Huw D M Davies3d10c1f2002-08-17 18:32:12 +0000232 INT ret = TRUE;
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000233 DC * dc = DC_GetDCPtr( hdc );
234 if (!dc) return FALSE;
235 if (dc->funcs->pSetViewportExt)
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000236 {
Huw D M Davies3d10c1f2002-08-17 18:32:12 +0000237 if((ret = dc->funcs->pSetViewportExt( dc->physDev, x, y )) != TRUE)
238 {
239 if(ret == GDI_NO_MORE_WORK)
240 ret = TRUE;
241 goto done;
242 }
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000243 }
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000244 if (size)
245 {
246 size->cx = dc->vportExtX;
247 size->cy = dc->vportExtY;
248 }
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000249 if ((dc->MapMode != MM_ISOTROPIC) && (dc->MapMode != MM_ANISOTROPIC))
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000250 goto done;
251 if (!x || !y)
252 {
253 ret = FALSE;
254 goto done;
255 }
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000256 dc->vportExtX = x;
257 dc->vportExtY = y;
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000258 if (dc->MapMode == MM_ISOTROPIC) MAPPING_FixIsotropic( dc );
Alexandre Julliarddadf78f1998-05-17 17:13:43 +0000259 DC_UpdateXforms( dc );
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000260 done:
261 GDI_ReleaseObj( hdc );
262 return ret;
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000263}
264
265
266/***********************************************************************
Patrik Stridvalld0a41772001-02-14 23:11:17 +0000267 * SetViewportOrgEx (GDI32.@)
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000268 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000269BOOL WINAPI SetViewportOrgEx( HDC hdc, INT x, INT y, LPPOINT pt )
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000270{
Huw D M Davies3d10c1f2002-08-17 18:32:12 +0000271 INT ret = TRUE;
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000272 DC * dc = DC_GetDCPtr( hdc );
273 if (!dc) return FALSE;
274 if (dc->funcs->pSetViewportOrg)
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000275 {
Huw D M Davies3d10c1f2002-08-17 18:32:12 +0000276 if((ret = dc->funcs->pSetViewportOrg( dc->physDev, x, y )) != TRUE)
277 {
278 if(ret == GDI_NO_MORE_WORK)
279 ret = TRUE;
280 goto done;
281 }
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000282 }
Huw D M Davies3d10c1f2002-08-17 18:32:12 +0000283 if (pt)
284 {
285 pt->x = dc->vportOrgX;
286 pt->y = dc->vportOrgY;
287 }
288 dc->vportOrgX = x;
289 dc->vportOrgY = y;
290 DC_UpdateXforms( dc );
291
292 done:
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000293 GDI_ReleaseObj( hdc );
294 return ret;
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000295}
296
297
298/***********************************************************************
Patrik Stridvalld0a41772001-02-14 23:11:17 +0000299 * SetWindowExtEx (GDI32.@)
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000300 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000301BOOL WINAPI SetWindowExtEx( HDC hdc, INT x, INT y, LPSIZE size )
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000302{
Huw D M Davies3d10c1f2002-08-17 18:32:12 +0000303 INT ret = TRUE;
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000304 DC * dc = DC_GetDCPtr( hdc );
305 if (!dc) return FALSE;
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000306 if (dc->funcs->pSetWindowExt)
307 {
Huw D M Davies3d10c1f2002-08-17 18:32:12 +0000308 if((ret = dc->funcs->pSetWindowExt( dc->physDev, x, y )) != TRUE)
309 {
310 if(ret == GDI_NO_MORE_WORK)
311 ret = TRUE;
312 goto done;
313 }
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000314 }
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000315 if (size)
316 {
317 size->cx = dc->wndExtX;
318 size->cy = dc->wndExtY;
319 }
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000320 if ((dc->MapMode != MM_ISOTROPIC) && (dc->MapMode != MM_ANISOTROPIC))
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000321 goto done;
322 if (!x || !y)
323 {
324 ret = FALSE;
325 goto done;
326 }
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000327 dc->wndExtX = x;
328 dc->wndExtY = y;
Dmitry Timoshkove8e10e92003-05-11 02:50:21 +0000329 /* Windows fixes MM_ISOTROPIC mode only in SetViewportExtEx() */
Alexandre Julliarddadf78f1998-05-17 17:13:43 +0000330 DC_UpdateXforms( dc );
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000331 done:
332 GDI_ReleaseObj( hdc );
333 return ret;
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000334}
335
336
337/***********************************************************************
Patrik Stridvalld0a41772001-02-14 23:11:17 +0000338 * SetWindowOrgEx (GDI32.@)
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000339 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000340BOOL WINAPI SetWindowOrgEx( HDC hdc, INT x, INT y, LPPOINT pt )
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000341{
Huw D M Davies3d10c1f2002-08-17 18:32:12 +0000342 INT ret = TRUE;
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000343 DC * dc = DC_GetDCPtr( hdc );
344 if (!dc) return FALSE;
Huw D M Davies3d10c1f2002-08-17 18:32:12 +0000345 if (dc->funcs->pSetWindowOrg)
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000346 {
Huw D M Davies3d10c1f2002-08-17 18:32:12 +0000347 if((ret = dc->funcs->pSetWindowOrg( dc->physDev, x, y )) != TRUE)
348 {
349 if(ret == GDI_NO_MORE_WORK)
350 ret = TRUE;
351 goto done;
352 }
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000353 }
Huw D M Davies3d10c1f2002-08-17 18:32:12 +0000354 if (pt)
355 {
356 pt->x = dc->wndOrgX;
357 pt->y = dc->wndOrgY;
358 }
359 dc->wndOrgX = x;
360 dc->wndOrgY = y;
361 DC_UpdateXforms( dc );
362 done:
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000363 GDI_ReleaseObj( hdc );
364 return ret;
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000365}
366
367
368/***********************************************************************
Patrik Stridvalld0a41772001-02-14 23:11:17 +0000369 * OffsetViewportOrgEx (GDI32.@)
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000370 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000371BOOL WINAPI OffsetViewportOrgEx( HDC hdc, INT x, INT y, LPPOINT pt)
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000372{
Huw D M Davies3d10c1f2002-08-17 18:32:12 +0000373 INT ret = TRUE;
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000374 DC * dc = DC_GetDCPtr( hdc );
375 if (!dc) return FALSE;
376 if (dc->funcs->pOffsetViewportOrg)
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000377 {
Huw D M Davies3d10c1f2002-08-17 18:32:12 +0000378 if((ret = dc->funcs->pOffsetViewportOrg( dc->physDev, x, y )) != TRUE)
379 {
380 if(ret == GDI_NO_MORE_WORK)
381 ret = TRUE;
382 goto done;
383 }
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000384 }
Huw D M Davies3d10c1f2002-08-17 18:32:12 +0000385 if (pt)
386 {
387 pt->x = dc->vportOrgX;
388 pt->y = dc->vportOrgY;
389 }
390 dc->vportOrgX += x;
391 dc->vportOrgY += y;
392 DC_UpdateXforms( dc );
393 done:
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000394 GDI_ReleaseObj( hdc );
395 return ret;
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000396}
397
398
399/***********************************************************************
Patrik Stridvalld0a41772001-02-14 23:11:17 +0000400 * OffsetWindowOrgEx (GDI32.@)
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000401 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000402BOOL WINAPI OffsetWindowOrgEx( HDC hdc, INT x, INT y, LPPOINT pt )
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000403{
Huw D M Davies3d10c1f2002-08-17 18:32:12 +0000404 INT ret = TRUE;
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000405 DC * dc = DC_GetDCPtr( hdc );
406 if (!dc) return FALSE;
407 if (dc->funcs->pOffsetWindowOrg)
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000408 {
Huw D M Davies3d10c1f2002-08-17 18:32:12 +0000409 if((ret = dc->funcs->pOffsetWindowOrg( dc->physDev, x, y )) != TRUE)
410 {
411 if(ret == GDI_NO_MORE_WORK)
412 ret = TRUE;
413 goto done;
414 }
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000415 }
Huw D M Davies3d10c1f2002-08-17 18:32:12 +0000416 if (pt)
417 {
418 pt->x = dc->wndOrgX;
419 pt->y = dc->wndOrgY;
420 }
421 dc->wndOrgX += x;
422 dc->wndOrgY += y;
423 DC_UpdateXforms( dc );
424 done:
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000425 GDI_ReleaseObj( hdc );
426 return ret;
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000427}
428
429
430/***********************************************************************
Patrik Stridvalld0a41772001-02-14 23:11:17 +0000431 * ScaleViewportExtEx (GDI32.@)
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000432 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000433BOOL WINAPI ScaleViewportExtEx( HDC hdc, INT xNum, INT xDenom,
434 INT yNum, INT yDenom, LPSIZE size )
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000435{
Huw D M Davies3d10c1f2002-08-17 18:32:12 +0000436 INT ret = TRUE;
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000437 DC * dc = DC_GetDCPtr( hdc );
438 if (!dc) return FALSE;
439 if (dc->funcs->pScaleViewportExt)
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000440 {
Huw D M Davies3d10c1f2002-08-17 18:32:12 +0000441 if((ret = dc->funcs->pScaleViewportExt( dc->physDev, xNum, xDenom, yNum, yDenom )) != TRUE)
442 {
443 if(ret == GDI_NO_MORE_WORK)
444 ret = TRUE;
445 goto done;
446 }
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000447 }
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000448 if (size)
449 {
450 size->cx = dc->vportExtX;
451 size->cy = dc->vportExtY;
452 }
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000453 if ((dc->MapMode != MM_ISOTROPIC) && (dc->MapMode != MM_ANISOTROPIC))
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000454 goto done;
455 if (!xNum || !xDenom || !xNum || !yDenom)
456 {
457 ret = FALSE;
458 goto done;
459 }
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000460 dc->vportExtX = (dc->vportExtX * xNum) / xDenom;
461 dc->vportExtY = (dc->vportExtY * yNum) / yDenom;
462 if (dc->vportExtX == 0) dc->vportExtX = 1;
463 if (dc->vportExtY == 0) dc->vportExtY = 1;
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000464 if (dc->MapMode == MM_ISOTROPIC) MAPPING_FixIsotropic( dc );
Alexandre Julliarddadf78f1998-05-17 17:13:43 +0000465 DC_UpdateXforms( dc );
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000466 done:
467 GDI_ReleaseObj( hdc );
468 return ret;
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000469}
470
471
472/***********************************************************************
Patrik Stridvalld0a41772001-02-14 23:11:17 +0000473 * ScaleWindowExtEx (GDI32.@)
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000474 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000475BOOL WINAPI ScaleWindowExtEx( HDC hdc, INT xNum, INT xDenom,
476 INT yNum, INT yDenom, LPSIZE size )
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000477{
Huw D M Davies3d10c1f2002-08-17 18:32:12 +0000478 INT ret = TRUE;
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000479 DC * dc = DC_GetDCPtr( hdc );
480 if (!dc) return FALSE;
481 if (dc->funcs->pScaleWindowExt)
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000482 {
Huw D M Davies3d10c1f2002-08-17 18:32:12 +0000483 if((ret = dc->funcs->pScaleWindowExt( dc->physDev, xNum, xDenom, yNum, yDenom )) != TRUE)
484 {
485 if(ret == GDI_NO_MORE_WORK)
486 ret = TRUE;
487 goto done;
488 }
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000489 }
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000490 if (size)
491 {
492 size->cx = dc->wndExtX;
493 size->cy = dc->wndExtY;
494 }
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000495 if ((dc->MapMode != MM_ISOTROPIC) && (dc->MapMode != MM_ANISOTROPIC))
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000496 goto done;
497 if (!xNum || !xDenom || !xNum || !yDenom)
498 {
499 ret = FALSE;
500 goto done;
501 }
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000502 dc->wndExtX = (dc->wndExtX * xNum) / xDenom;
503 dc->wndExtY = (dc->wndExtY * yNum) / yDenom;
504 if (dc->wndExtX == 0) dc->wndExtX = 1;
505 if (dc->wndExtY == 0) dc->wndExtY = 1;
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000506 if (dc->MapMode == MM_ISOTROPIC) MAPPING_FixIsotropic( dc );
Alexandre Julliarddadf78f1998-05-17 17:13:43 +0000507 DC_UpdateXforms( dc );
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000508 done:
509 GDI_ReleaseObj( hdc );
510 return ret;
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000511}