blob: e3d75f8609f36c08ce45172565ac535e180249a3 [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"
Alexandre Julliard0799c1a2002-03-09 23:29:33 +000022#include "wine/debug.h"
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +000023
Alexandre Julliard0799c1a2002-03-09 23:29:33 +000024WINE_DEFAULT_DEBUG_CHANNEL(gdi);
Patrik Stridvallb4b9fae1999-04-19 14:56:29 +000025
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +000026
27/***********************************************************************
28 * MAPPING_FixIsotropic
29 *
30 * Fix viewport extensions for isotropic mode.
31 */
32void MAPPING_FixIsotropic( DC * dc )
33{
Alexandre Julliard99bb9f92001-07-28 00:18:02 +000034 double xdim = (double)dc->vportExtX * GetDeviceCaps( dc->hSelf, HORZSIZE ) /
35 (GetDeviceCaps( dc->hSelf, HORZRES ) * dc->wndExtX);
36 double ydim = (double)dc->vportExtY * GetDeviceCaps( dc->hSelf, VERTSIZE ) /
37 (GetDeviceCaps( dc->hSelf, VERTRES ) * dc->wndExtY);
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +000038 if (xdim > ydim)
39 {
40 dc->vportExtX = dc->vportExtX * fabs( ydim / xdim );
41 if (!dc->vportExtX) dc->vportExtX = 1;
42 }
43 else
44 {
45 dc->vportExtY = dc->vportExtY * fabs( xdim / ydim );
46 if (!dc->vportExtY) dc->vportExtY = 1;
Alexandre Julliard99bb9f92001-07-28 00:18:02 +000047 }
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +000048}
49
50
51/***********************************************************************
Patrik Stridvall01d5e5b2001-07-02 19:59:40 +000052 * DPtoLP (GDI.67)
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +000053 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +000054BOOL16 WINAPI DPtoLP16( HDC16 hdc, LPPOINT16 points, INT16 count )
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +000055{
Alexandre Julliardd8a92442002-05-31 18:43:22 +000056 DC * dc = DC_GetDCPtr( hdc );
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +000057 if (!dc) return FALSE;
58
59 while (count--)
60 {
Alexandre Julliard5ee15992002-06-25 23:29:51 +000061 points->x = MulDiv( points->x - dc->vportOrgX, dc->wndExtX, dc->vportExtX ) + dc->wndOrgX;
62 points->y = MulDiv( points->y - dc->vportOrgY, dc->wndExtY, dc->vportExtY ) + dc->wndOrgY;
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +000063 points++;
64 }
Alexandre Julliard2a2321b2000-08-19 21:38:55 +000065 GDI_ReleaseObj( hdc );
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +000066 return TRUE;
67}
68
69
70/***********************************************************************
Patrik Stridvalld0a41772001-02-14 23:11:17 +000071 * DPtoLP (GDI32.@)
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +000072 */
Alexandre Julliarda3960291999-02-26 11:11:13 +000073BOOL WINAPI DPtoLP( HDC hdc, LPPOINT points, INT count )
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +000074{
Alexandre Julliardd8a92442002-05-31 18:43:22 +000075 DC * dc = DC_GetDCPtr( hdc );
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +000076 if (!dc) return FALSE;
77
Alexandre Julliard5ee15992002-06-25 23:29:51 +000078 if (dc->vport2WorldValid)
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +000079 {
Alexandre Julliard5ee15992002-06-25 23:29:51 +000080 while (count--)
81 {
82 FLOAT x = points->x;
83 FLOAT y = points->y;
84 points->x = floor( x * dc->xformVport2World.eM11 +
85 y * dc->xformVport2World.eM21 +
86 dc->xformVport2World.eDx + 0.5 );
87 points->y = floor( x * dc->xformVport2World.eM12 +
88 y * dc->xformVport2World.eM22 +
89 dc->xformVport2World.eDy + 0.5 );
90 points++;
91 }
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +000092 }
Alexandre Julliard2a2321b2000-08-19 21:38:55 +000093 GDI_ReleaseObj( hdc );
94 return (count < 0);
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +000095}
96
97
98/***********************************************************************
Patrik Stridvall01d5e5b2001-07-02 19:59:40 +000099 * LPtoDP (GDI.99)
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000100 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000101BOOL16 WINAPI LPtoDP16( HDC16 hdc, LPPOINT16 points, INT16 count )
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000102{
Alexandre Julliardd8a92442002-05-31 18:43:22 +0000103 DC * dc = DC_GetDCPtr( hdc );
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000104 if (!dc) return FALSE;
105
106 while (count--)
107 {
Alexandre Julliard5ee15992002-06-25 23:29:51 +0000108 points->x = MulDiv( points->x - dc->wndOrgX, dc->vportExtX, dc->wndExtX ) + dc->vportOrgX;
109 points->y = MulDiv( points->y - dc->wndOrgY, dc->vportExtY, dc->wndExtY ) + dc->vportOrgY;
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000110 points++;
111 }
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000112 GDI_ReleaseObj( hdc );
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000113 return TRUE;
114}
115
116
117/***********************************************************************
Patrik Stridvalld0a41772001-02-14 23:11:17 +0000118 * LPtoDP (GDI32.@)
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000119 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000120BOOL WINAPI LPtoDP( HDC hdc, LPPOINT points, INT count )
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000121{
Alexandre Julliardd8a92442002-05-31 18:43:22 +0000122 DC * dc = DC_GetDCPtr( hdc );
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000123 if (!dc) return FALSE;
124
125 while (count--)
126 {
Alexandre Julliard5ee15992002-06-25 23:29:51 +0000127 FLOAT x = points->x;
128 FLOAT y = points->y;
129 points->x = floor( x * dc->xformWorld2Vport.eM11 +
130 y * dc->xformWorld2Vport.eM21 +
131 dc->xformWorld2Vport.eDx + 0.5 );
132 points->y = floor( x * dc->xformWorld2Vport.eM12 +
133 y * dc->xformWorld2Vport.eM22 +
134 dc->xformWorld2Vport.eDy + 0.5 );
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000135 points++;
136 }
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000137 GDI_ReleaseObj( hdc );
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000138 return TRUE;
139}
140
141
142/***********************************************************************
Patrik Stridvall01d5e5b2001-07-02 19:59:40 +0000143 * SetMapMode (GDI.3)
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000144 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000145INT16 WINAPI SetMapMode16( HDC16 hdc, INT16 mode )
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000146{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000147 return SetMapMode( hdc, mode );
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000148}
149
150
151/***********************************************************************
Patrik Stridvalld0a41772001-02-14 23:11:17 +0000152 * SetMapMode (GDI32.@)
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000153 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000154INT WINAPI SetMapMode( HDC hdc, INT mode )
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000155{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000156 INT prevMode;
Alexandre Julliard99bb9f92001-07-28 00:18:02 +0000157 INT horzSize, vertSize, horzRes, vertRes;
158
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000159 DC * dc = DC_GetDCPtr( hdc );
160 if (!dc) return 0;
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000161 if (dc->funcs->pSetMapMode)
162 {
Alexandre Julliarde21c15e2002-03-28 22:22:05 +0000163 prevMode = dc->funcs->pSetMapMode( dc->physDev, mode );
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000164 goto done;
165 }
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000166
Alexandre Julliard61fece01999-06-26 19:09:08 +0000167 TRACE("%04x %d\n", hdc, mode );
Alexandre Julliard99bb9f92001-07-28 00:18:02 +0000168
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000169 prevMode = dc->MapMode;
Alexandre Julliard99bb9f92001-07-28 00:18:02 +0000170 horzSize = GetDeviceCaps( hdc, HORZSIZE );
171 vertSize = GetDeviceCaps( hdc, VERTSIZE );
172 horzRes = GetDeviceCaps( hdc, HORZRES );
173 vertRes = GetDeviceCaps( hdc, VERTRES );
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000174 switch(mode)
175 {
Alexandre Julliard99bb9f92001-07-28 00:18:02 +0000176 case MM_TEXT:
177 dc->wndExtX = 1;
178 dc->wndExtY = 1;
179 dc->vportExtX = 1;
180 dc->vportExtY = 1;
181 break;
182 case MM_LOMETRIC:
183 case MM_ISOTROPIC:
184 dc->wndExtX = horzSize;
185 dc->wndExtY = vertSize;
186 dc->vportExtX = horzRes / 10;
187 dc->vportExtY = vertRes / -10;
188 break;
189 case MM_HIMETRIC:
190 dc->wndExtX = horzSize * 10;
191 dc->wndExtY = vertSize * 10;
192 dc->vportExtX = horzRes / 10;
193 dc->vportExtY = vertRes / -10;
194 break;
195 case MM_LOENGLISH:
196 dc->wndExtX = horzSize;
197 dc->wndExtY = vertSize;
198 dc->vportExtX = 254L * horzRes / 1000;
199 dc->vportExtY = -254L * vertRes / 1000;
200 break;
201 case MM_HIENGLISH:
202 dc->wndExtX = horzSize * 10;
203 dc->wndExtY = vertSize * 10;
204 dc->vportExtX = 254L * horzRes / 1000;
205 dc->vportExtY = -254L * vertRes / 1000;
206 break;
207 case MM_TWIPS:
208 dc->wndExtX = 144L * horzSize / 10;
209 dc->wndExtY = 144L * vertSize / 10;
210 dc->vportExtX = 254L * horzRes / 1000;
211 dc->vportExtY = -254L * vertRes / 1000;
212 break;
213 case MM_ANISOTROPIC:
214 break;
215 default:
216 goto done;
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000217 }
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000218 dc->MapMode = mode;
Alexandre Julliarddadf78f1998-05-17 17:13:43 +0000219 DC_UpdateXforms( dc );
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000220 done:
221 GDI_ReleaseObj( hdc );
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000222 return prevMode;
223}
224
225
226/***********************************************************************
227 * SetViewportExt (GDI.14)
228 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000229DWORD WINAPI SetViewportExt16( HDC16 hdc, INT16 x, INT16 y )
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000230{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000231 SIZE size;
232 if (!SetViewportExtEx( hdc, x, y, &size )) return 0;
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000233 return MAKELONG( size.cx, size.cy );
234}
235
236
237/***********************************************************************
Patrik Stridvall01d5e5b2001-07-02 19:59:40 +0000238 * SetViewportExtEx (GDI.479)
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000239 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000240BOOL16 WINAPI SetViewportExtEx16( HDC16 hdc, INT16 x, INT16 y, LPSIZE16 size )
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000241{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000242 SIZE size32;
243 BOOL16 ret = SetViewportExtEx( hdc, x, y, &size32 );
Alexandre Julliard982a2232000-12-13 20:20:09 +0000244 if (size) { size->cx = size32.cx; size->cy = size32.cy; }
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000245 return ret;
246}
247
248
249/***********************************************************************
Patrik Stridvalld0a41772001-02-14 23:11:17 +0000250 * SetViewportExtEx (GDI32.@)
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000251 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000252BOOL WINAPI SetViewportExtEx( HDC hdc, INT x, INT y, LPSIZE size )
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000253{
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000254 BOOL ret = TRUE;
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000255 DC * dc = DC_GetDCPtr( hdc );
256 if (!dc) return FALSE;
257 if (dc->funcs->pSetViewportExt)
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000258 {
Alexandre Julliarde21c15e2002-03-28 22:22:05 +0000259 ret = dc->funcs->pSetViewportExt( dc->physDev, x, y );
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000260 goto done;
261 }
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000262 if (size)
263 {
264 size->cx = dc->vportExtX;
265 size->cy = dc->vportExtY;
266 }
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000267 if ((dc->MapMode != MM_ISOTROPIC) && (dc->MapMode != MM_ANISOTROPIC))
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000268 goto done;
269 if (!x || !y)
270 {
271 ret = FALSE;
272 goto done;
273 }
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000274 dc->vportExtX = x;
275 dc->vportExtY = y;
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000276 if (dc->MapMode == MM_ISOTROPIC) MAPPING_FixIsotropic( dc );
Alexandre Julliarddadf78f1998-05-17 17:13:43 +0000277 DC_UpdateXforms( dc );
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000278 done:
279 GDI_ReleaseObj( hdc );
280 return ret;
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000281}
282
283
284/***********************************************************************
285 * SetViewportOrg (GDI.13)
286 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000287DWORD WINAPI SetViewportOrg16( HDC16 hdc, INT16 x, INT16 y )
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000288{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000289 POINT pt;
290 if (!SetViewportOrgEx( hdc, x, y, &pt )) return 0;
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000291 return MAKELONG( pt.x, pt.y );
292}
293
294
295/***********************************************************************
Patrik Stridvall01d5e5b2001-07-02 19:59:40 +0000296 * SetViewportOrgEx (GDI.480)
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000297 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000298BOOL16 WINAPI SetViewportOrgEx16( HDC16 hdc, INT16 x, INT16 y, LPPOINT16 pt )
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000299{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000300 POINT pt32;
301 BOOL16 ret = SetViewportOrgEx( hdc, x, y, &pt32 );
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000302 if (pt) CONV_POINT32TO16( &pt32, pt );
303 return ret;
304}
305
306
307/***********************************************************************
Patrik Stridvalld0a41772001-02-14 23:11:17 +0000308 * SetViewportOrgEx (GDI32.@)
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000309 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000310BOOL WINAPI SetViewportOrgEx( HDC hdc, INT x, INT y, LPPOINT pt )
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000311{
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000312 BOOL ret = TRUE;
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000313 DC * dc = DC_GetDCPtr( hdc );
314 if (!dc) return FALSE;
315 if (dc->funcs->pSetViewportOrg)
Alexandre Julliarde21c15e2002-03-28 22:22:05 +0000316 ret = dc->funcs->pSetViewportOrg( dc->physDev, x, y );
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000317 else
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000318 {
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000319 if (pt)
320 {
321 pt->x = dc->vportOrgX;
322 pt->y = dc->vportOrgY;
323 }
324 dc->vportOrgX = x;
325 dc->vportOrgY = y;
326 DC_UpdateXforms( dc );
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000327 }
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000328 GDI_ReleaseObj( hdc );
329 return ret;
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000330}
331
332
333/***********************************************************************
334 * SetWindowExt (GDI.12)
335 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000336DWORD WINAPI SetWindowExt16( HDC16 hdc, INT16 x, INT16 y )
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000337{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000338 SIZE size;
339 if (!SetWindowExtEx( hdc, x, y, &size )) return 0;
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000340 return MAKELONG( size.cx, size.cy );
341}
342
343
344/***********************************************************************
Patrik Stridvall01d5e5b2001-07-02 19:59:40 +0000345 * SetWindowExtEx (GDI.481)
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000346 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000347BOOL16 WINAPI SetWindowExtEx16( HDC16 hdc, INT16 x, INT16 y, LPSIZE16 size )
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000348{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000349 SIZE size32;
350 BOOL16 ret = SetWindowExtEx( hdc, x, y, &size32 );
Alexandre Julliard982a2232000-12-13 20:20:09 +0000351 if (size) { size->cx = size32.cx; size->cy = size32.cy; }
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000352 return ret;
353}
354
355
356/***********************************************************************
Patrik Stridvalld0a41772001-02-14 23:11:17 +0000357 * SetWindowExtEx (GDI32.@)
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000358 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000359BOOL WINAPI SetWindowExtEx( HDC hdc, INT x, INT y, LPSIZE size )
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000360{
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000361 BOOL ret = TRUE;
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000362 DC * dc = DC_GetDCPtr( hdc );
363 if (!dc) return FALSE;
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000364 if (dc->funcs->pSetWindowExt)
365 {
Alexandre Julliarde21c15e2002-03-28 22:22:05 +0000366 ret = dc->funcs->pSetWindowExt( dc->physDev, x, y );
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000367 goto done;
368 }
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000369 if (size)
370 {
371 size->cx = dc->wndExtX;
372 size->cy = dc->wndExtY;
373 }
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000374 if ((dc->MapMode != MM_ISOTROPIC) && (dc->MapMode != MM_ANISOTROPIC))
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000375 goto done;
376 if (!x || !y)
377 {
378 ret = FALSE;
379 goto done;
380 }
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000381 dc->wndExtX = x;
382 dc->wndExtY = y;
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000383 if (dc->MapMode == MM_ISOTROPIC) MAPPING_FixIsotropic( dc );
Alexandre Julliarddadf78f1998-05-17 17:13:43 +0000384 DC_UpdateXforms( dc );
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000385 done:
386 GDI_ReleaseObj( hdc );
387 return ret;
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000388}
389
390
391/***********************************************************************
392 * SetWindowOrg (GDI.11)
393 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000394DWORD WINAPI SetWindowOrg16( HDC16 hdc, INT16 x, INT16 y )
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000395{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000396 POINT pt;
397 if (!SetWindowOrgEx( hdc, x, y, &pt )) return 0;
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000398 return MAKELONG( pt.x, pt.y );
399}
400
401
402/***********************************************************************
Patrik Stridvall01d5e5b2001-07-02 19:59:40 +0000403 * SetWindowOrgEx (GDI.482)
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000404 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000405BOOL16 WINAPI SetWindowOrgEx16( HDC16 hdc, INT16 x, INT16 y, LPPOINT16 pt )
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000406{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000407 POINT pt32;
408 BOOL16 ret = SetWindowOrgEx( hdc, x, y, &pt32 );
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000409 if (pt) CONV_POINT32TO16( &pt32, pt );
410 return ret;
411}
412
413
414/***********************************************************************
Patrik Stridvalld0a41772001-02-14 23:11:17 +0000415 * SetWindowOrgEx (GDI32.@)
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000416 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000417BOOL WINAPI SetWindowOrgEx( HDC hdc, INT x, INT y, LPPOINT pt )
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000418{
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000419 BOOL ret = TRUE;
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000420 DC * dc = DC_GetDCPtr( hdc );
421 if (!dc) return FALSE;
Alexandre Julliarde21c15e2002-03-28 22:22:05 +0000422 if (dc->funcs->pSetWindowOrg) ret = dc->funcs->pSetWindowOrg( dc->physDev, x, y );
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000423 else
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000424 {
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000425 if (pt)
426 {
427 pt->x = dc->wndOrgX;
428 pt->y = dc->wndOrgY;
429 }
430 dc->wndOrgX = x;
431 dc->wndOrgY = y;
432 DC_UpdateXforms( dc );
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000433 }
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000434 GDI_ReleaseObj( hdc );
435 return ret;
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000436}
437
438
439/***********************************************************************
440 * OffsetViewportOrg (GDI.17)
441 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000442DWORD WINAPI OffsetViewportOrg16( HDC16 hdc, INT16 x, INT16 y )
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000443{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000444 POINT pt;
445 if (!OffsetViewportOrgEx( hdc, x, y, &pt )) return 0;
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000446 return MAKELONG( pt.x, pt.y );
447}
448
449
450/***********************************************************************
Patrik Stridvall01d5e5b2001-07-02 19:59:40 +0000451 * OffsetViewportOrgEx (GDI.476)
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000452 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000453BOOL16 WINAPI OffsetViewportOrgEx16( HDC16 hdc, INT16 x, INT16 y, LPPOINT16 pt)
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000454{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000455 POINT pt32;
456 BOOL16 ret = OffsetViewportOrgEx( hdc, x, y, &pt32 );
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000457 if (pt) CONV_POINT32TO16( &pt32, pt );
458 return ret;
459}
460
461
462/***********************************************************************
Patrik Stridvalld0a41772001-02-14 23:11:17 +0000463 * OffsetViewportOrgEx (GDI32.@)
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000464 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000465BOOL WINAPI OffsetViewportOrgEx( HDC hdc, INT x, INT y, LPPOINT pt)
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000466{
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000467 BOOL ret = TRUE;
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000468 DC * dc = DC_GetDCPtr( hdc );
469 if (!dc) return FALSE;
470 if (dc->funcs->pOffsetViewportOrg)
Alexandre Julliarde21c15e2002-03-28 22:22:05 +0000471 ret = dc->funcs->pOffsetViewportOrg( dc->physDev, x, y );
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000472 else
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000473 {
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000474 if (pt)
475 {
476 pt->x = dc->vportOrgX;
477 pt->y = dc->vportOrgY;
478 }
479 dc->vportOrgX += x;
480 dc->vportOrgY += y;
481 DC_UpdateXforms( dc );
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000482 }
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000483 GDI_ReleaseObj( hdc );
484 return ret;
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000485}
486
487
488/***********************************************************************
489 * OffsetWindowOrg (GDI.15)
490 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000491DWORD WINAPI OffsetWindowOrg16( HDC16 hdc, INT16 x, INT16 y )
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000492{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000493 POINT pt;
494 if (!OffsetWindowOrgEx( hdc, x, y, &pt )) return 0;
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000495 return MAKELONG( pt.x, pt.y );
496}
497
498
499/***********************************************************************
Patrik Stridvall01d5e5b2001-07-02 19:59:40 +0000500 * OffsetWindowOrgEx (GDI.477)
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000501 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000502BOOL16 WINAPI OffsetWindowOrgEx16( HDC16 hdc, INT16 x, INT16 y, LPPOINT16 pt )
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000503{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000504 POINT pt32;
505 BOOL16 ret = OffsetWindowOrgEx( hdc, x, y, &pt32 );
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000506 if (pt) CONV_POINT32TO16( &pt32, pt );
507 return ret;
508}
509
510
511/***********************************************************************
Patrik Stridvalld0a41772001-02-14 23:11:17 +0000512 * OffsetWindowOrgEx (GDI32.@)
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000513 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000514BOOL WINAPI OffsetWindowOrgEx( HDC hdc, INT x, INT y, LPPOINT pt )
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000515{
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000516 BOOL ret = TRUE;
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000517 DC * dc = DC_GetDCPtr( hdc );
518 if (!dc) return FALSE;
519 if (dc->funcs->pOffsetWindowOrg)
Alexandre Julliarde21c15e2002-03-28 22:22:05 +0000520 ret = dc->funcs->pOffsetWindowOrg( dc->physDev, x, y );
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000521 else
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000522 {
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000523 if (pt)
524 {
525 pt->x = dc->wndOrgX;
526 pt->y = dc->wndOrgY;
527 }
528 dc->wndOrgX += x;
529 dc->wndOrgY += y;
530 DC_UpdateXforms( dc );
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000531 }
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000532 GDI_ReleaseObj( hdc );
533 return ret;
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000534}
535
536
537/***********************************************************************
538 * ScaleViewportExt (GDI.18)
539 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000540DWORD WINAPI ScaleViewportExt16( HDC16 hdc, INT16 xNum, INT16 xDenom,
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000541 INT16 yNum, INT16 yDenom )
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000542{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000543 SIZE size;
544 if (!ScaleViewportExtEx( hdc, xNum, xDenom, yNum, yDenom, &size ))
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000545 return FALSE;
546 return MAKELONG( size.cx, size.cy );
547}
548
549
550/***********************************************************************
Patrik Stridvall01d5e5b2001-07-02 19:59:40 +0000551 * ScaleViewportExtEx (GDI.484)
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000552 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000553BOOL16 WINAPI ScaleViewportExtEx16( HDC16 hdc, INT16 xNum, INT16 xDenom,
554 INT16 yNum, INT16 yDenom, LPSIZE16 size )
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000555{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000556 SIZE size32;
557 BOOL16 ret = ScaleViewportExtEx( hdc, xNum, xDenom, yNum, yDenom,
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000558 &size32 );
Alexandre Julliard982a2232000-12-13 20:20:09 +0000559 if (size) { size->cx = size32.cx; size->cy = size32.cy; }
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000560 return ret;
561}
562
563
564/***********************************************************************
Patrik Stridvalld0a41772001-02-14 23:11:17 +0000565 * ScaleViewportExtEx (GDI32.@)
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000566 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000567BOOL WINAPI ScaleViewportExtEx( HDC hdc, INT xNum, INT xDenom,
568 INT yNum, INT yDenom, LPSIZE size )
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000569{
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000570 BOOL ret = TRUE;
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000571 DC * dc = DC_GetDCPtr( hdc );
572 if (!dc) return FALSE;
573 if (dc->funcs->pScaleViewportExt)
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000574 {
Alexandre Julliarde21c15e2002-03-28 22:22:05 +0000575 ret = dc->funcs->pScaleViewportExt( dc->physDev, xNum, xDenom, yNum, yDenom );
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000576 goto done;
577 }
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000578 if (size)
579 {
580 size->cx = dc->vportExtX;
581 size->cy = dc->vportExtY;
582 }
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000583 if ((dc->MapMode != MM_ISOTROPIC) && (dc->MapMode != MM_ANISOTROPIC))
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000584 goto done;
585 if (!xNum || !xDenom || !xNum || !yDenom)
586 {
587 ret = FALSE;
588 goto done;
589 }
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000590 dc->vportExtX = (dc->vportExtX * xNum) / xDenom;
591 dc->vportExtY = (dc->vportExtY * yNum) / yDenom;
592 if (dc->vportExtX == 0) dc->vportExtX = 1;
593 if (dc->vportExtY == 0) dc->vportExtY = 1;
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000594 if (dc->MapMode == MM_ISOTROPIC) MAPPING_FixIsotropic( dc );
Alexandre Julliarddadf78f1998-05-17 17:13:43 +0000595 DC_UpdateXforms( dc );
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000596 done:
597 GDI_ReleaseObj( hdc );
598 return ret;
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000599}
600
601
602/***********************************************************************
603 * ScaleWindowExt (GDI.16)
604 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000605DWORD WINAPI ScaleWindowExt16( HDC16 hdc, INT16 xNum, INT16 xDenom,
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000606 INT16 yNum, INT16 yDenom )
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000607{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000608 SIZE size;
609 if (!ScaleWindowExtEx( hdc, xNum, xDenom, yNum, yDenom, &size ))
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000610 return FALSE;
611 return MAKELONG( size.cx, size.cy );
612}
613
614
615/***********************************************************************
Patrik Stridvall01d5e5b2001-07-02 19:59:40 +0000616 * ScaleWindowExtEx (GDI.485)
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000617 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000618BOOL16 WINAPI ScaleWindowExtEx16( HDC16 hdc, INT16 xNum, INT16 xDenom,
619 INT16 yNum, INT16 yDenom, LPSIZE16 size )
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000620{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000621 SIZE size32;
622 BOOL16 ret = ScaleWindowExtEx( hdc, xNum, xDenom, yNum, yDenom,
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000623 &size32 );
Alexandre Julliard982a2232000-12-13 20:20:09 +0000624 if (size) { size->cx = size32.cx; size->cy = size32.cy; }
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000625 return ret;
626}
627
628
629/***********************************************************************
Patrik Stridvalld0a41772001-02-14 23:11:17 +0000630 * ScaleWindowExtEx (GDI32.@)
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000631 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000632BOOL WINAPI ScaleWindowExtEx( HDC hdc, INT xNum, INT xDenom,
633 INT yNum, INT yDenom, LPSIZE size )
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000634{
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000635 BOOL ret = TRUE;
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000636 DC * dc = DC_GetDCPtr( hdc );
637 if (!dc) return FALSE;
638 if (dc->funcs->pScaleWindowExt)
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000639 {
Alexandre Julliarde21c15e2002-03-28 22:22:05 +0000640 ret = dc->funcs->pScaleWindowExt( dc->physDev, xNum, xDenom, yNum, yDenom );
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000641 goto done;
642 }
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000643 if (size)
644 {
645 size->cx = dc->wndExtX;
646 size->cy = dc->wndExtY;
647 }
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000648 if ((dc->MapMode != MM_ISOTROPIC) && (dc->MapMode != MM_ANISOTROPIC))
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000649 goto done;
650 if (!xNum || !xDenom || !xNum || !yDenom)
651 {
652 ret = FALSE;
653 goto done;
654 }
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000655 dc->wndExtX = (dc->wndExtX * xNum) / xDenom;
656 dc->wndExtY = (dc->wndExtY * yNum) / yDenom;
657 if (dc->wndExtX == 0) dc->wndExtX = 1;
658 if (dc->wndExtY == 0) dc->wndExtY = 1;
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000659 if (dc->MapMode == MM_ISOTROPIC) MAPPING_FixIsotropic( dc );
Alexandre Julliarddadf78f1998-05-17 17:13:43 +0000660 DC_UpdateXforms( dc );
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000661 done:
662 GDI_ReleaseObj( hdc );
663 return ret;
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000664}