mapping.c 16.2 KB
Newer Older
Alexandre Julliard's avatar
Alexandre Julliard committed
1 2 3 4 5 6
/*
 * GDI mapping mode functions
 *
 * Copyright 1993 Alexandre Julliard
 */

7
#include "gdi.h"
8
#include "debugtools.h"
Alexandre Julliard's avatar
Alexandre Julliard committed
9

10
DEFAULT_DEBUG_CHANNEL(gdi);
11

Alexandre Julliard's avatar
Alexandre Julliard committed
12 13 14 15 16 17 18 19

/***********************************************************************
 *           MAPPING_FixIsotropic
 *
 * Fix viewport extensions for isotropic mode.
 */
void MAPPING_FixIsotropic( DC * dc )
{
20 21 22 23
    double xdim = (double)dc->vportExtX * GetDeviceCaps( dc->hSelf, HORZSIZE ) /
                  (GetDeviceCaps( dc->hSelf, HORZRES ) * dc->wndExtX);
    double ydim = (double)dc->vportExtY * GetDeviceCaps( dc->hSelf, VERTSIZE ) /
                  (GetDeviceCaps( dc->hSelf, VERTRES ) * dc->wndExtY);
Alexandre Julliard's avatar
Alexandre Julliard committed
24 25 26 27 28 29 30 31 32
    if (xdim > ydim)
    {
	dc->vportExtX = dc->vportExtX * fabs( ydim / xdim );
	if (!dc->vportExtX) dc->vportExtX = 1;
    }
    else
    {
	dc->vportExtY = dc->vportExtY * fabs( xdim / ydim );
	if (!dc->vportExtY) dc->vportExtY = 1;
33
    }
Alexandre Julliard's avatar
Alexandre Julliard committed
34 35 36 37
}


/***********************************************************************
Patrik Stridvall's avatar
Patrik Stridvall committed
38
 *           DPtoLP    (GDI.67)
Alexandre Julliard's avatar
Alexandre Julliard committed
39
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
40
BOOL16 WINAPI DPtoLP16( HDC16 hdc, LPPOINT16 points, INT16 count )
Alexandre Julliard's avatar
Alexandre Julliard committed
41 42 43 44 45 46 47 48 49 50
{
    DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
    if (!dc) return FALSE;

    while (count--)
    {
	points->x = XDPTOLP( dc, points->x );
	points->y = YDPTOLP( dc, points->y );
        points++;
    }
51
    GDI_ReleaseObj( hdc );
Alexandre Julliard's avatar
Alexandre Julliard committed
52 53 54 55 56
    return TRUE;
}


/***********************************************************************
57
 *           DPtoLP    (GDI32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
58
 */
59
BOOL WINAPI DPtoLP( HDC hdc, LPPOINT points, INT count )
Alexandre Julliard's avatar
Alexandre Julliard committed
60 61 62 63 64 65
{
    DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
    if (!dc) return FALSE;

    while (count--)
    {
Alexandre Julliard's avatar
Alexandre Julliard committed
66
        if (!INTERNAL_DPTOLP( dc, points ))
67
	    break;
Alexandre Julliard's avatar
Alexandre Julliard committed
68 69
        points++;
    }
70 71
    GDI_ReleaseObj( hdc );
    return (count < 0);
Alexandre Julliard's avatar
Alexandre Julliard committed
72 73 74 75
}


/***********************************************************************
Patrik Stridvall's avatar
Patrik Stridvall committed
76
 *           LPtoDP    (GDI.99)
Alexandre Julliard's avatar
Alexandre Julliard committed
77
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
78
BOOL16 WINAPI LPtoDP16( HDC16 hdc, LPPOINT16 points, INT16 count )
Alexandre Julliard's avatar
Alexandre Julliard committed
79 80 81 82 83 84 85 86 87 88
{
    DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
    if (!dc) return FALSE;

    while (count--)
    {
	points->x = XLPTODP( dc, points->x );
	points->y = YLPTODP( dc, points->y );
        points++;
    }
89
    GDI_ReleaseObj( hdc );
Alexandre Julliard's avatar
Alexandre Julliard committed
90 91 92 93 94
    return TRUE;
}


/***********************************************************************
95
 *           LPtoDP    (GDI32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
96
 */
97
BOOL WINAPI LPtoDP( HDC hdc, LPPOINT points, INT count )
Alexandre Julliard's avatar
Alexandre Julliard committed
98 99 100 101 102 103
{
    DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
    if (!dc) return FALSE;

    while (count--)
    {
Alexandre Julliard's avatar
Alexandre Julliard committed
104
	INTERNAL_LPTODP( dc, points );
Alexandre Julliard's avatar
Alexandre Julliard committed
105 106
        points++;
    }
107
    GDI_ReleaseObj( hdc );
Alexandre Julliard's avatar
Alexandre Julliard committed
108 109 110 111 112
    return TRUE;
}


/***********************************************************************
Patrik Stridvall's avatar
Patrik Stridvall committed
113
 *           SetMapMode    (GDI.3)
Alexandre Julliard's avatar
Alexandre Julliard committed
114
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
115
INT16 WINAPI SetMapMode16( HDC16 hdc, INT16 mode )
Alexandre Julliard's avatar
Alexandre Julliard committed
116
{
117
    return SetMapMode( hdc, mode );
Alexandre Julliard's avatar
Alexandre Julliard committed
118 119 120 121
}


/***********************************************************************
122
 *           SetMapMode    (GDI32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
123
 */
124
INT WINAPI SetMapMode( HDC hdc, INT mode )
Alexandre Julliard's avatar
Alexandre Julliard committed
125
{
126
    INT prevMode;
127 128
    INT horzSize, vertSize, horzRes, vertRes;

Alexandre Julliard's avatar
Alexandre Julliard committed
129 130
    DC * dc = DC_GetDCPtr( hdc );
    if (!dc) return 0;
131 132 133 134 135
    if (dc->funcs->pSetMapMode)
    {
        prevMode = dc->funcs->pSetMapMode( dc, mode );
        goto done;
    }
Alexandre Julliard's avatar
Alexandre Julliard committed
136

137
    TRACE("%04x %d\n", hdc, mode );
138

139
    prevMode = dc->MapMode;
140 141 142 143
    horzSize = GetDeviceCaps( hdc, HORZSIZE );
    vertSize = GetDeviceCaps( hdc, VERTSIZE );
    horzRes  = GetDeviceCaps( hdc, HORZRES );
    vertRes  = GetDeviceCaps( hdc, VERTRES );
Alexandre Julliard's avatar
Alexandre Julliard committed
144 145
    switch(mode)
    {
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186
    case MM_TEXT:
        dc->wndExtX   = 1;
        dc->wndExtY   = 1;
        dc->vportExtX = 1;
        dc->vportExtY = 1;
        break;
    case MM_LOMETRIC:
    case MM_ISOTROPIC:
        dc->wndExtX   = horzSize;
        dc->wndExtY   = vertSize;
        dc->vportExtX = horzRes / 10;
        dc->vportExtY = vertRes / -10;
        break;
    case MM_HIMETRIC:
        dc->wndExtX   = horzSize * 10;
        dc->wndExtY   = vertSize * 10;
        dc->vportExtX = horzRes / 10;
        dc->vportExtY = vertRes / -10;
        break;
    case MM_LOENGLISH:
        dc->wndExtX   = horzSize;
        dc->wndExtY   = vertSize;
        dc->vportExtX = 254L * horzRes / 1000;
        dc->vportExtY = -254L * vertRes / 1000;
        break;
    case MM_HIENGLISH:
        dc->wndExtX   = horzSize * 10;
        dc->wndExtY   = vertSize * 10;
        dc->vportExtX = 254L * horzRes / 1000;
        dc->vportExtY = -254L * vertRes / 1000;
        break;
    case MM_TWIPS:
        dc->wndExtX   = 144L * horzSize / 10;
        dc->wndExtY   = 144L * vertSize / 10;
        dc->vportExtX = 254L * horzRes / 1000;
        dc->vportExtY = -254L * vertRes / 1000;
        break;
    case MM_ANISOTROPIC:
        break;
    default:
        goto done;
Alexandre Julliard's avatar
Alexandre Julliard committed
187
    }
188
    dc->MapMode = mode;
Alexandre Julliard's avatar
Alexandre Julliard committed
189
    DC_UpdateXforms( dc );
190 191
 done:
    GDI_ReleaseObj( hdc );
Alexandre Julliard's avatar
Alexandre Julliard committed
192 193 194 195 196 197 198
    return prevMode;
}


/***********************************************************************
 *           SetViewportExt    (GDI.14)
 */
199
DWORD WINAPI SetViewportExt16( HDC16 hdc, INT16 x, INT16 y )
Alexandre Julliard's avatar
Alexandre Julliard committed
200
{
201 202
    SIZE size;
    if (!SetViewportExtEx( hdc, x, y, &size )) return 0;
Alexandre Julliard's avatar
Alexandre Julliard committed
203 204 205 206 207
    return MAKELONG( size.cx, size.cy );
}


/***********************************************************************
Patrik Stridvall's avatar
Patrik Stridvall committed
208
 *           SetViewportExtEx    (GDI.479)
Alexandre Julliard's avatar
Alexandre Julliard committed
209
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
210
BOOL16 WINAPI SetViewportExtEx16( HDC16 hdc, INT16 x, INT16 y, LPSIZE16 size )
Alexandre Julliard's avatar
Alexandre Julliard committed
211
{
212 213
    SIZE size32;
    BOOL16 ret = SetViewportExtEx( hdc, x, y, &size32 );
214
    if (size) { size->cx = size32.cx; size->cy = size32.cy; }
Alexandre Julliard's avatar
Alexandre Julliard committed
215 216 217 218 219
    return ret;
}


/***********************************************************************
220
 *           SetViewportExtEx    (GDI32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
221
 */
222
BOOL WINAPI SetViewportExtEx( HDC hdc, INT x, INT y, LPSIZE size )
Alexandre Julliard's avatar
Alexandre Julliard committed
223
{
224
    BOOL ret = TRUE;
Alexandre Julliard's avatar
Alexandre Julliard committed
225 226 227
    DC * dc = DC_GetDCPtr( hdc );
    if (!dc) return FALSE;
    if (dc->funcs->pSetViewportExt)
228 229 230 231
    {
        ret = dc->funcs->pSetViewportExt( dc, x, y );
        goto done;
    }
Alexandre Julliard's avatar
Alexandre Julliard committed
232 233 234 235 236
    if (size)
    {
	size->cx = dc->vportExtX;
	size->cy = dc->vportExtY;
    }
237
    if ((dc->MapMode != MM_ISOTROPIC) && (dc->MapMode != MM_ANISOTROPIC))
238 239 240 241 242 243
	goto done;
    if (!x || !y)
    {
        ret = FALSE;
        goto done;
    }
Alexandre Julliard's avatar
Alexandre Julliard committed
244 245
    dc->vportExtX = x;
    dc->vportExtY = y;
246
    if (dc->MapMode == MM_ISOTROPIC) MAPPING_FixIsotropic( dc );
Alexandre Julliard's avatar
Alexandre Julliard committed
247
    DC_UpdateXforms( dc );
248 249 250
 done:
    GDI_ReleaseObj( hdc );
    return ret;
Alexandre Julliard's avatar
Alexandre Julliard committed
251 252 253 254 255 256
}


/***********************************************************************
 *           SetViewportOrg    (GDI.13)
 */
257
DWORD WINAPI SetViewportOrg16( HDC16 hdc, INT16 x, INT16 y )
Alexandre Julliard's avatar
Alexandre Julliard committed
258
{
259 260
    POINT pt;
    if (!SetViewportOrgEx( hdc, x, y, &pt )) return 0;
Alexandre Julliard's avatar
Alexandre Julliard committed
261 262 263 264 265
    return MAKELONG( pt.x, pt.y );
}


/***********************************************************************
Patrik Stridvall's avatar
Patrik Stridvall committed
266
 *           SetViewportOrgEx    (GDI.480)
Alexandre Julliard's avatar
Alexandre Julliard committed
267
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
268
BOOL16 WINAPI SetViewportOrgEx16( HDC16 hdc, INT16 x, INT16 y, LPPOINT16 pt )
Alexandre Julliard's avatar
Alexandre Julliard committed
269
{
270 271
    POINT pt32;
    BOOL16 ret = SetViewportOrgEx( hdc, x, y, &pt32 );
Alexandre Julliard's avatar
Alexandre Julliard committed
272 273 274 275 276 277
    if (pt) CONV_POINT32TO16( &pt32, pt );
    return ret;
}


/***********************************************************************
278
 *           SetViewportOrgEx    (GDI32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
279
 */
280
BOOL WINAPI SetViewportOrgEx( HDC hdc, INT x, INT y, LPPOINT pt )
Alexandre Julliard's avatar
Alexandre Julliard committed
281
{
282
    BOOL ret = TRUE;
Alexandre Julliard's avatar
Alexandre Julliard committed
283 284 285
    DC * dc = DC_GetDCPtr( hdc );
    if (!dc) return FALSE;
    if (dc->funcs->pSetViewportOrg)
286 287
        ret = dc->funcs->pSetViewportOrg( dc, x, y );
    else
Alexandre Julliard's avatar
Alexandre Julliard committed
288
    {
289 290 291 292 293 294 295 296
        if (pt)
        {
            pt->x = dc->vportOrgX;
            pt->y = dc->vportOrgY;
        }
        dc->vportOrgX = x;
        dc->vportOrgY = y;
        DC_UpdateXforms( dc );
Alexandre Julliard's avatar
Alexandre Julliard committed
297
    }
298 299
    GDI_ReleaseObj( hdc );
    return ret;
Alexandre Julliard's avatar
Alexandre Julliard committed
300 301 302 303 304 305
}


/***********************************************************************
 *           SetWindowExt    (GDI.12)
 */
306
DWORD WINAPI SetWindowExt16( HDC16 hdc, INT16 x, INT16 y )
Alexandre Julliard's avatar
Alexandre Julliard committed
307
{
308 309
    SIZE size;
    if (!SetWindowExtEx( hdc, x, y, &size )) return 0;
Alexandre Julliard's avatar
Alexandre Julliard committed
310 311 312 313 314
    return MAKELONG( size.cx, size.cy );
}


/***********************************************************************
Patrik Stridvall's avatar
Patrik Stridvall committed
315
 *           SetWindowExtEx    (GDI.481)
Alexandre Julliard's avatar
Alexandre Julliard committed
316
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
317
BOOL16 WINAPI SetWindowExtEx16( HDC16 hdc, INT16 x, INT16 y, LPSIZE16 size )
Alexandre Julliard's avatar
Alexandre Julliard committed
318
{
319 320
    SIZE size32;
    BOOL16 ret = SetWindowExtEx( hdc, x, y, &size32 );
321
    if (size) { size->cx = size32.cx; size->cy = size32.cy; }
Alexandre Julliard's avatar
Alexandre Julliard committed
322 323 324 325 326
    return ret;
}


/***********************************************************************
327
 *           SetWindowExtEx    (GDI32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
328
 */
329
BOOL WINAPI SetWindowExtEx( HDC hdc, INT x, INT y, LPSIZE size )
Alexandre Julliard's avatar
Alexandre Julliard committed
330
{
331
    BOOL ret = TRUE;
Alexandre Julliard's avatar
Alexandre Julliard committed
332 333
    DC * dc = DC_GetDCPtr( hdc );
    if (!dc) return FALSE;
334 335 336 337 338
    if (dc->funcs->pSetWindowExt)
    {
        ret = dc->funcs->pSetWindowExt( dc, x, y );
        goto done;
    }
Alexandre Julliard's avatar
Alexandre Julliard committed
339 340 341 342 343
    if (size)
    {
	size->cx = dc->wndExtX;
	size->cy = dc->wndExtY;
    }
344
    if ((dc->MapMode != MM_ISOTROPIC) && (dc->MapMode != MM_ANISOTROPIC))
345 346 347 348 349 350
	goto done;
    if (!x || !y)
    {
        ret = FALSE;
        goto done;
    }
Alexandre Julliard's avatar
Alexandre Julliard committed
351 352
    dc->wndExtX = x;
    dc->wndExtY = y;
353
    if (dc->MapMode == MM_ISOTROPIC) MAPPING_FixIsotropic( dc );
Alexandre Julliard's avatar
Alexandre Julliard committed
354
    DC_UpdateXforms( dc );
355 356 357
 done:
    GDI_ReleaseObj( hdc );
    return ret;
Alexandre Julliard's avatar
Alexandre Julliard committed
358 359 360 361 362 363
}


/***********************************************************************
 *           SetWindowOrg    (GDI.11)
 */
364
DWORD WINAPI SetWindowOrg16( HDC16 hdc, INT16 x, INT16 y )
Alexandre Julliard's avatar
Alexandre Julliard committed
365
{
366 367
    POINT pt;
    if (!SetWindowOrgEx( hdc, x, y, &pt )) return 0;
Alexandre Julliard's avatar
Alexandre Julliard committed
368 369 370 371 372
    return MAKELONG( pt.x, pt.y );
}


/***********************************************************************
Patrik Stridvall's avatar
Patrik Stridvall committed
373
 *           SetWindowOrgEx    (GDI.482)
Alexandre Julliard's avatar
Alexandre Julliard committed
374
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
375
BOOL16 WINAPI SetWindowOrgEx16( HDC16 hdc, INT16 x, INT16 y, LPPOINT16 pt )
Alexandre Julliard's avatar
Alexandre Julliard committed
376
{
377 378
    POINT pt32;
    BOOL16 ret = SetWindowOrgEx( hdc, x, y, &pt32 );
Alexandre Julliard's avatar
Alexandre Julliard committed
379 380 381 382 383 384
    if (pt) CONV_POINT32TO16( &pt32, pt );
    return ret;
}


/***********************************************************************
385
 *           SetWindowOrgEx    (GDI32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
386
 */
387
BOOL WINAPI SetWindowOrgEx( HDC hdc, INT x, INT y, LPPOINT pt )
Alexandre Julliard's avatar
Alexandre Julliard committed
388
{
389
    BOOL ret = TRUE;
Alexandre Julliard's avatar
Alexandre Julliard committed
390 391
    DC * dc = DC_GetDCPtr( hdc );
    if (!dc) return FALSE;
392 393
    if (dc->funcs->pSetWindowOrg) ret = dc->funcs->pSetWindowOrg( dc, x, y );
    else
Alexandre Julliard's avatar
Alexandre Julliard committed
394
    {
395 396 397 398 399 400 401 402
        if (pt)
        {
            pt->x = dc->wndOrgX;
            pt->y = dc->wndOrgY;
        }
        dc->wndOrgX = x;
        dc->wndOrgY = y;
        DC_UpdateXforms( dc );
Alexandre Julliard's avatar
Alexandre Julliard committed
403
    }
404 405
    GDI_ReleaseObj( hdc );
    return ret;
Alexandre Julliard's avatar
Alexandre Julliard committed
406 407 408 409 410 411
}


/***********************************************************************
 *           OffsetViewportOrg    (GDI.17)
 */
412
DWORD WINAPI OffsetViewportOrg16( HDC16 hdc, INT16 x, INT16 y )
Alexandre Julliard's avatar
Alexandre Julliard committed
413
{
414 415
    POINT pt;
    if (!OffsetViewportOrgEx( hdc, x, y, &pt )) return 0;
Alexandre Julliard's avatar
Alexandre Julliard committed
416 417 418 419 420
    return MAKELONG( pt.x, pt.y );
}


/***********************************************************************
Patrik Stridvall's avatar
Patrik Stridvall committed
421
 *           OffsetViewportOrgEx    (GDI.476)
Alexandre Julliard's avatar
Alexandre Julliard committed
422
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
423
BOOL16 WINAPI OffsetViewportOrgEx16( HDC16 hdc, INT16 x, INT16 y, LPPOINT16 pt)
Alexandre Julliard's avatar
Alexandre Julliard committed
424
{
425 426
    POINT pt32;
    BOOL16 ret = OffsetViewportOrgEx( hdc, x, y, &pt32 );
Alexandre Julliard's avatar
Alexandre Julliard committed
427 428 429 430 431 432
    if (pt) CONV_POINT32TO16( &pt32, pt );
    return ret;
}


/***********************************************************************
433
 *           OffsetViewportOrgEx    (GDI32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
434
 */
435
BOOL WINAPI OffsetViewportOrgEx( HDC hdc, INT x, INT y, LPPOINT pt)
Alexandre Julliard's avatar
Alexandre Julliard committed
436
{
437
    BOOL ret = TRUE;
Alexandre Julliard's avatar
Alexandre Julliard committed
438 439 440
    DC * dc = DC_GetDCPtr( hdc );
    if (!dc) return FALSE;
    if (dc->funcs->pOffsetViewportOrg)
441 442
        ret = dc->funcs->pOffsetViewportOrg( dc, x, y );
    else
Alexandre Julliard's avatar
Alexandre Julliard committed
443
    {
444 445 446 447 448 449 450 451
        if (pt)
        {
            pt->x = dc->vportOrgX;
            pt->y = dc->vportOrgY;
        }
        dc->vportOrgX += x;
        dc->vportOrgY += y;
        DC_UpdateXforms( dc );
Alexandre Julliard's avatar
Alexandre Julliard committed
452
    }
453 454
    GDI_ReleaseObj( hdc );
    return ret;
Alexandre Julliard's avatar
Alexandre Julliard committed
455 456 457 458 459 460
}


/***********************************************************************
 *           OffsetWindowOrg    (GDI.15)
 */
461
DWORD WINAPI OffsetWindowOrg16( HDC16 hdc, INT16 x, INT16 y )
Alexandre Julliard's avatar
Alexandre Julliard committed
462
{
463 464
    POINT pt;
    if (!OffsetWindowOrgEx( hdc, x, y, &pt )) return 0;
Alexandre Julliard's avatar
Alexandre Julliard committed
465 466 467 468 469
    return MAKELONG( pt.x, pt.y );
}


/***********************************************************************
Patrik Stridvall's avatar
Patrik Stridvall committed
470
 *           OffsetWindowOrgEx    (GDI.477)
Alexandre Julliard's avatar
Alexandre Julliard committed
471
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
472
BOOL16 WINAPI OffsetWindowOrgEx16( HDC16 hdc, INT16 x, INT16 y, LPPOINT16 pt )
Alexandre Julliard's avatar
Alexandre Julliard committed
473
{
474 475
    POINT pt32;
    BOOL16 ret = OffsetWindowOrgEx( hdc, x, y, &pt32 );
Alexandre Julliard's avatar
Alexandre Julliard committed
476 477 478 479 480 481
    if (pt) CONV_POINT32TO16( &pt32, pt );
    return ret;
}


/***********************************************************************
482
 *           OffsetWindowOrgEx    (GDI32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
483
 */
484
BOOL WINAPI OffsetWindowOrgEx( HDC hdc, INT x, INT y, LPPOINT pt )
Alexandre Julliard's avatar
Alexandre Julliard committed
485
{
486
    BOOL ret = TRUE;
Alexandre Julliard's avatar
Alexandre Julliard committed
487 488 489
    DC * dc = DC_GetDCPtr( hdc );
    if (!dc) return FALSE;
    if (dc->funcs->pOffsetWindowOrg)
490 491
        ret = dc->funcs->pOffsetWindowOrg( dc, x, y );
    else
Alexandre Julliard's avatar
Alexandre Julliard committed
492
    {
493 494 495 496 497 498 499 500
        if (pt)
        {
            pt->x = dc->wndOrgX;
            pt->y = dc->wndOrgY;
        }
        dc->wndOrgX += x;
        dc->wndOrgY += y;
        DC_UpdateXforms( dc );
Alexandre Julliard's avatar
Alexandre Julliard committed
501
    }
502 503
    GDI_ReleaseObj( hdc );
    return ret;
Alexandre Julliard's avatar
Alexandre Julliard committed
504 505 506 507 508 509
}


/***********************************************************************
 *           ScaleViewportExt    (GDI.18)
 */
510
DWORD WINAPI ScaleViewportExt16( HDC16 hdc, INT16 xNum, INT16 xDenom,
Alexandre Julliard's avatar
Alexandre Julliard committed
511
                               INT16 yNum, INT16 yDenom )
Alexandre Julliard's avatar
Alexandre Julliard committed
512
{
513 514
    SIZE size;
    if (!ScaleViewportExtEx( hdc, xNum, xDenom, yNum, yDenom, &size ))
Alexandre Julliard's avatar
Alexandre Julliard committed
515 516 517 518 519 520
        return FALSE;
    return MAKELONG( size.cx,  size.cy );
}


/***********************************************************************
Patrik Stridvall's avatar
Patrik Stridvall committed
521
 *           ScaleViewportExtEx    (GDI.484)
Alexandre Julliard's avatar
Alexandre Julliard committed
522
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
523 524
BOOL16 WINAPI ScaleViewportExtEx16( HDC16 hdc, INT16 xNum, INT16 xDenom,
                                    INT16 yNum, INT16 yDenom, LPSIZE16 size )
Alexandre Julliard's avatar
Alexandre Julliard committed
525
{
526 527
    SIZE size32;
    BOOL16 ret = ScaleViewportExtEx( hdc, xNum, xDenom, yNum, yDenom,
Alexandre Julliard's avatar
Alexandre Julliard committed
528
                                       &size32 );
529
    if (size) { size->cx = size32.cx; size->cy = size32.cy; }
Alexandre Julliard's avatar
Alexandre Julliard committed
530 531 532 533 534
    return ret;
}


/***********************************************************************
535
 *           ScaleViewportExtEx    (GDI32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
536
 */
537 538
BOOL WINAPI ScaleViewportExtEx( HDC hdc, INT xNum, INT xDenom,
                                    INT yNum, INT yDenom, LPSIZE size )
Alexandre Julliard's avatar
Alexandre Julliard committed
539
{
540
    BOOL ret = TRUE;
Alexandre Julliard's avatar
Alexandre Julliard committed
541 542 543
    DC * dc = DC_GetDCPtr( hdc );
    if (!dc) return FALSE;
    if (dc->funcs->pScaleViewportExt)
544 545 546 547
    {
        ret = dc->funcs->pScaleViewportExt( dc, xNum, xDenom, yNum, yDenom );
        goto done;
    }
Alexandre Julliard's avatar
Alexandre Julliard committed
548 549 550 551 552
    if (size)
    {
	size->cx = dc->vportExtX;
	size->cy = dc->vportExtY;
    }
553
    if ((dc->MapMode != MM_ISOTROPIC) && (dc->MapMode != MM_ANISOTROPIC))
554 555 556 557 558 559
	goto done;
    if (!xNum || !xDenom || !xNum || !yDenom)
    {
        ret = FALSE;
        goto done;
    }
Alexandre Julliard's avatar
Alexandre Julliard committed
560 561 562 563
    dc->vportExtX = (dc->vportExtX * xNum) / xDenom;
    dc->vportExtY = (dc->vportExtY * yNum) / yDenom;
    if (dc->vportExtX == 0) dc->vportExtX = 1;
    if (dc->vportExtY == 0) dc->vportExtY = 1;
564
    if (dc->MapMode == MM_ISOTROPIC) MAPPING_FixIsotropic( dc );
Alexandre Julliard's avatar
Alexandre Julliard committed
565
    DC_UpdateXforms( dc );
566 567 568
 done:
    GDI_ReleaseObj( hdc );
    return ret;
Alexandre Julliard's avatar
Alexandre Julliard committed
569 570 571 572 573 574
}


/***********************************************************************
 *           ScaleWindowExt    (GDI.16)
 */
575
DWORD WINAPI ScaleWindowExt16( HDC16 hdc, INT16 xNum, INT16 xDenom,
Alexandre Julliard's avatar
Alexandre Julliard committed
576
                             INT16 yNum, INT16 yDenom )
Alexandre Julliard's avatar
Alexandre Julliard committed
577
{
578 579
    SIZE size;
    if (!ScaleWindowExtEx( hdc, xNum, xDenom, yNum, yDenom, &size ))
Alexandre Julliard's avatar
Alexandre Julliard committed
580 581 582 583 584 585
        return FALSE;
    return MAKELONG( size.cx,  size.cy );
}


/***********************************************************************
Patrik Stridvall's avatar
Patrik Stridvall committed
586
 *           ScaleWindowExtEx    (GDI.485)
Alexandre Julliard's avatar
Alexandre Julliard committed
587
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
588 589
BOOL16 WINAPI ScaleWindowExtEx16( HDC16 hdc, INT16 xNum, INT16 xDenom,
                                  INT16 yNum, INT16 yDenom, LPSIZE16 size )
Alexandre Julliard's avatar
Alexandre Julliard committed
590
{
591 592
    SIZE size32;
    BOOL16 ret = ScaleWindowExtEx( hdc, xNum, xDenom, yNum, yDenom,
Alexandre Julliard's avatar
Alexandre Julliard committed
593
                                     &size32 );
594
    if (size) { size->cx = size32.cx; size->cy = size32.cy; }
Alexandre Julliard's avatar
Alexandre Julliard committed
595 596 597 598 599
    return ret;
}


/***********************************************************************
600
 *           ScaleWindowExtEx    (GDI32.@)
Alexandre Julliard's avatar
Alexandre Julliard committed
601
 */
602 603
BOOL WINAPI ScaleWindowExtEx( HDC hdc, INT xNum, INT xDenom,
                                  INT yNum, INT yDenom, LPSIZE size )
Alexandre Julliard's avatar
Alexandre Julliard committed
604
{
605
    BOOL ret = TRUE;
Alexandre Julliard's avatar
Alexandre Julliard committed
606 607 608
    DC * dc = DC_GetDCPtr( hdc );
    if (!dc) return FALSE;
    if (dc->funcs->pScaleWindowExt)
609 610 611 612
    {
        ret = dc->funcs->pScaleWindowExt( dc, xNum, xDenom, yNum, yDenom );
        goto done;
    }
Alexandre Julliard's avatar
Alexandre Julliard committed
613 614 615 616 617
    if (size)
    {
	size->cx = dc->wndExtX;
	size->cy = dc->wndExtY;
    }
618
    if ((dc->MapMode != MM_ISOTROPIC) && (dc->MapMode != MM_ANISOTROPIC))
619 620 621 622 623 624
	goto done;
    if (!xNum || !xDenom || !xNum || !yDenom)
    {
        ret = FALSE;
        goto done;
    }
Alexandre Julliard's avatar
Alexandre Julliard committed
625 626 627 628
    dc->wndExtX = (dc->wndExtX * xNum) / xDenom;
    dc->wndExtY = (dc->wndExtY * yNum) / yDenom;
    if (dc->wndExtX == 0) dc->wndExtX = 1;
    if (dc->wndExtY == 0) dc->wndExtY = 1;
629
    if (dc->MapMode == MM_ISOTROPIC) MAPPING_FixIsotropic( dc );
Alexandre Julliard's avatar
Alexandre Julliard committed
630
    DC_UpdateXforms( dc );
631 632 633
 done:
    GDI_ReleaseObj( hdc );
    return ret;
Alexandre Julliard's avatar
Alexandre Julliard committed
634
}