Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 1 | /* |
| 2 | * GDI mapping mode functions |
| 3 | * |
| 4 | * Copyright 1993 Alexandre Julliard |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 5 | * |
| 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 Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 19 | */ |
| 20 | |
Alexandre Julliard | 2239abb | 2000-11-05 02:05:07 +0000 | [diff] [blame] | 21 | #include "gdi.h" |
Michael Stefaniuc | 28a632a | 2002-11-21 21:50:04 +0000 | [diff] [blame] | 22 | #include "wownt32.h" |
Alexandre Julliard | 6ec42c0 | 2004-01-15 00:35:38 +0000 | [diff] [blame] | 23 | #include "gdi_private.h" |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 24 | #include "wine/debug.h" |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 25 | |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 26 | WINE_DEFAULT_DEBUG_CHANNEL(gdi); |
Patrik Stridvall | b4b9fae | 1999-04-19 14:56:29 +0000 | [diff] [blame] | 27 | |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 28 | |
| 29 | /*********************************************************************** |
| 30 | * MAPPING_FixIsotropic |
| 31 | * |
| 32 | * Fix viewport extensions for isotropic mode. |
| 33 | */ |
| 34 | void MAPPING_FixIsotropic( DC * dc ) |
| 35 | { |
Alexandre Julliard | 99bb9f9 | 2001-07-28 00:18:02 +0000 | [diff] [blame] | 36 | 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 Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 40 | if (xdim > ydim) |
| 41 | { |
Dmitry Timoshkov | e8e10e9 | 2003-05-11 02:50:21 +0000 | [diff] [blame] | 42 | dc->vportExtX = floor(dc->vportExtX * fabs( ydim / xdim ) + 0.5); |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 43 | if (!dc->vportExtX) dc->vportExtX = 1; |
| 44 | } |
| 45 | else |
| 46 | { |
Dmitry Timoshkov | e8e10e9 | 2003-05-11 02:50:21 +0000 | [diff] [blame] | 47 | dc->vportExtY = floor(dc->vportExtY * fabs( xdim / ydim ) + 0.5); |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 48 | if (!dc->vportExtY) dc->vportExtY = 1; |
Alexandre Julliard | 99bb9f9 | 2001-07-28 00:18:02 +0000 | [diff] [blame] | 49 | } |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | |
| 53 | /*********************************************************************** |
Patrik Stridvall | 01d5e5b | 2001-07-02 19:59:40 +0000 | [diff] [blame] | 54 | * DPtoLP (GDI.67) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 55 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 56 | BOOL16 WINAPI DPtoLP16( HDC16 hdc, LPPOINT16 points, INT16 count ) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 57 | { |
Michael Stefaniuc | 28a632a | 2002-11-21 21:50:04 +0000 | [diff] [blame] | 58 | DC * dc = DC_GetDCPtr( HDC_32(hdc) ); |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 59 | if (!dc) return FALSE; |
| 60 | |
| 61 | while (count--) |
| 62 | { |
Alexandre Julliard | 5ee1599 | 2002-06-25 23:29:51 +0000 | [diff] [blame] | 63 | 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 Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 65 | points++; |
| 66 | } |
Michael Stefaniuc | 28a632a | 2002-11-21 21:50:04 +0000 | [diff] [blame] | 67 | GDI_ReleaseObj( HDC_32(hdc) ); |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 68 | return TRUE; |
| 69 | } |
| 70 | |
| 71 | |
| 72 | /*********************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 73 | * DPtoLP (GDI32.@) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 74 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 75 | BOOL WINAPI DPtoLP( HDC hdc, LPPOINT points, INT count ) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 76 | { |
Alexandre Julliard | d8a9244 | 2002-05-31 18:43:22 +0000 | [diff] [blame] | 77 | DC * dc = DC_GetDCPtr( hdc ); |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 78 | if (!dc) return FALSE; |
| 79 | |
Alexandre Julliard | 5ee1599 | 2002-06-25 23:29:51 +0000 | [diff] [blame] | 80 | if (dc->vport2WorldValid) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 81 | { |
Alexandre Julliard | 5ee1599 | 2002-06-25 23:29:51 +0000 | [diff] [blame] | 82 | 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 Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 94 | } |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 95 | GDI_ReleaseObj( hdc ); |
| 96 | return (count < 0); |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 97 | } |
| 98 | |
| 99 | |
| 100 | /*********************************************************************** |
Patrik Stridvall | 01d5e5b | 2001-07-02 19:59:40 +0000 | [diff] [blame] | 101 | * LPtoDP (GDI.99) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 102 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 103 | BOOL16 WINAPI LPtoDP16( HDC16 hdc, LPPOINT16 points, INT16 count ) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 104 | { |
Michael Stefaniuc | 28a632a | 2002-11-21 21:50:04 +0000 | [diff] [blame] | 105 | DC * dc = DC_GetDCPtr( HDC_32(hdc) ); |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 106 | if (!dc) return FALSE; |
| 107 | |
| 108 | while (count--) |
| 109 | { |
Alexandre Julliard | 5ee1599 | 2002-06-25 23:29:51 +0000 | [diff] [blame] | 110 | 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 Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 112 | points++; |
| 113 | } |
Michael Stefaniuc | 28a632a | 2002-11-21 21:50:04 +0000 | [diff] [blame] | 114 | GDI_ReleaseObj( HDC_32(hdc) ); |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 115 | return TRUE; |
| 116 | } |
| 117 | |
| 118 | |
| 119 | /*********************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 120 | * LPtoDP (GDI32.@) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 121 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 122 | BOOL WINAPI LPtoDP( HDC hdc, LPPOINT points, INT count ) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 123 | { |
Alexandre Julliard | d8a9244 | 2002-05-31 18:43:22 +0000 | [diff] [blame] | 124 | DC * dc = DC_GetDCPtr( hdc ); |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 125 | if (!dc) return FALSE; |
| 126 | |
| 127 | while (count--) |
| 128 | { |
Alexandre Julliard | 5ee1599 | 2002-06-25 23:29:51 +0000 | [diff] [blame] | 129 | 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 Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 137 | points++; |
| 138 | } |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 139 | GDI_ReleaseObj( hdc ); |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 140 | return TRUE; |
| 141 | } |
| 142 | |
| 143 | |
| 144 | /*********************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 145 | * SetMapMode (GDI32.@) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 146 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 147 | INT WINAPI SetMapMode( HDC hdc, INT mode ) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 148 | { |
Huw D M Davies | 3d10c1f | 2002-08-17 18:32:12 +0000 | [diff] [blame] | 149 | INT ret; |
Alexandre Julliard | 99bb9f9 | 2001-07-28 00:18:02 +0000 | [diff] [blame] | 150 | INT horzSize, vertSize, horzRes, vertRes; |
| 151 | |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 152 | DC * dc = DC_GetDCPtr( hdc ); |
| 153 | if (!dc) return 0; |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 154 | if (dc->funcs->pSetMapMode) |
| 155 | { |
Huw D M Davies | 3d10c1f | 2002-08-17 18:32:12 +0000 | [diff] [blame] | 156 | 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 Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 162 | } |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 163 | |
Alexandre Julliard | 547cdc2 | 2002-11-22 22:16:53 +0000 | [diff] [blame] | 164 | TRACE("%p %d\n", hdc, mode ); |
Alexandre Julliard | 99bb9f9 | 2001-07-28 00:18:02 +0000 | [diff] [blame] | 165 | |
Huw D M Davies | 3d10c1f | 2002-08-17 18:32:12 +0000 | [diff] [blame] | 166 | ret = dc->MapMode; |
Dmitry Timoshkov | e8e10e9 | 2003-05-11 02:50:21 +0000 | [diff] [blame] | 167 | |
| 168 | if (mode == dc->MapMode && (mode == MM_ISOTROPIC || mode == MM_ANISOTROPIC)) |
| 169 | goto done; |
| 170 | |
Alexandre Julliard | 99bb9f9 | 2001-07-28 00:18:02 +0000 | [diff] [blame] | 171 | horzSize = GetDeviceCaps( hdc, HORZSIZE ); |
| 172 | vertSize = GetDeviceCaps( hdc, VERTSIZE ); |
| 173 | horzRes = GetDeviceCaps( hdc, HORZRES ); |
| 174 | vertRes = GetDeviceCaps( hdc, VERTRES ); |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 175 | switch(mode) |
| 176 | { |
Alexandre Julliard | 99bb9f9 | 2001-07-28 00:18:02 +0000 | [diff] [blame] | 177 | 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 Timoshkov | e8e10e9 | 2003-05-11 02:50:21 +0000 | [diff] [blame] | 185 | dc->wndExtX = horzSize * 10; |
| 186 | dc->wndExtY = vertSize * 10; |
| 187 | dc->vportExtX = horzRes; |
| 188 | dc->vportExtY = -vertRes; |
Alexandre Julliard | 99bb9f9 | 2001-07-28 00:18:02 +0000 | [diff] [blame] | 189 | break; |
| 190 | case MM_HIMETRIC: |
Dmitry Timoshkov | e8e10e9 | 2003-05-11 02:50:21 +0000 | [diff] [blame] | 191 | dc->wndExtX = horzSize * 100; |
| 192 | dc->wndExtY = vertSize * 100; |
| 193 | dc->vportExtX = horzRes; |
| 194 | dc->vportExtY = -vertRes; |
Alexandre Julliard | 99bb9f9 | 2001-07-28 00:18:02 +0000 | [diff] [blame] | 195 | break; |
| 196 | case MM_LOENGLISH: |
Dmitry Timoshkov | e8e10e9 | 2003-05-11 02:50:21 +0000 | [diff] [blame] | 197 | dc->wndExtX = MulDiv(1000, horzSize, 254); |
| 198 | dc->wndExtY = MulDiv(1000, vertSize, 254); |
| 199 | dc->vportExtX = horzRes; |
| 200 | dc->vportExtY = -vertRes; |
Alexandre Julliard | 99bb9f9 | 2001-07-28 00:18:02 +0000 | [diff] [blame] | 201 | break; |
| 202 | case MM_HIENGLISH: |
Dmitry Timoshkov | e8e10e9 | 2003-05-11 02:50:21 +0000 | [diff] [blame] | 203 | dc->wndExtX = MulDiv(10000, horzSize, 254); |
| 204 | dc->wndExtY = MulDiv(10000, vertSize, 254); |
| 205 | dc->vportExtX = horzRes; |
| 206 | dc->vportExtY = -vertRes; |
Alexandre Julliard | 99bb9f9 | 2001-07-28 00:18:02 +0000 | [diff] [blame] | 207 | break; |
| 208 | case MM_TWIPS: |
Dmitry Timoshkov | e8e10e9 | 2003-05-11 02:50:21 +0000 | [diff] [blame] | 209 | dc->wndExtX = MulDiv(14400, horzSize, 254); |
| 210 | dc->wndExtY = MulDiv(14400, vertSize, 254); |
| 211 | dc->vportExtX = horzRes; |
| 212 | dc->vportExtY = -vertRes; |
Alexandre Julliard | 99bb9f9 | 2001-07-28 00:18:02 +0000 | [diff] [blame] | 213 | break; |
| 214 | case MM_ANISOTROPIC: |
| 215 | break; |
| 216 | default: |
| 217 | goto done; |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 218 | } |
Alexandre Julliard | 2239abb | 2000-11-05 02:05:07 +0000 | [diff] [blame] | 219 | dc->MapMode = mode; |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 220 | DC_UpdateXforms( dc ); |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 221 | done: |
| 222 | GDI_ReleaseObj( hdc ); |
Huw D M Davies | 3d10c1f | 2002-08-17 18:32:12 +0000 | [diff] [blame] | 223 | return ret; |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 224 | } |
| 225 | |
| 226 | |
| 227 | /*********************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 228 | * SetViewportExtEx (GDI32.@) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 229 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 230 | BOOL WINAPI SetViewportExtEx( HDC hdc, INT x, INT y, LPSIZE size ) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 231 | { |
Huw D M Davies | 3d10c1f | 2002-08-17 18:32:12 +0000 | [diff] [blame] | 232 | INT ret = TRUE; |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 233 | DC * dc = DC_GetDCPtr( hdc ); |
| 234 | if (!dc) return FALSE; |
| 235 | if (dc->funcs->pSetViewportExt) |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 236 | { |
Huw D M Davies | 3d10c1f | 2002-08-17 18:32:12 +0000 | [diff] [blame] | 237 | 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 Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 243 | } |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 244 | if (size) |
| 245 | { |
| 246 | size->cx = dc->vportExtX; |
| 247 | size->cy = dc->vportExtY; |
| 248 | } |
Alexandre Julliard | 2239abb | 2000-11-05 02:05:07 +0000 | [diff] [blame] | 249 | if ((dc->MapMode != MM_ISOTROPIC) && (dc->MapMode != MM_ANISOTROPIC)) |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 250 | goto done; |
| 251 | if (!x || !y) |
| 252 | { |
| 253 | ret = FALSE; |
| 254 | goto done; |
| 255 | } |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 256 | dc->vportExtX = x; |
| 257 | dc->vportExtY = y; |
Alexandre Julliard | 2239abb | 2000-11-05 02:05:07 +0000 | [diff] [blame] | 258 | if (dc->MapMode == MM_ISOTROPIC) MAPPING_FixIsotropic( dc ); |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 259 | DC_UpdateXforms( dc ); |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 260 | done: |
| 261 | GDI_ReleaseObj( hdc ); |
| 262 | return ret; |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 263 | } |
| 264 | |
| 265 | |
| 266 | /*********************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 267 | * SetViewportOrgEx (GDI32.@) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 268 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 269 | BOOL WINAPI SetViewportOrgEx( HDC hdc, INT x, INT y, LPPOINT pt ) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 270 | { |
Huw D M Davies | 3d10c1f | 2002-08-17 18:32:12 +0000 | [diff] [blame] | 271 | INT ret = TRUE; |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 272 | DC * dc = DC_GetDCPtr( hdc ); |
| 273 | if (!dc) return FALSE; |
| 274 | if (dc->funcs->pSetViewportOrg) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 275 | { |
Huw D M Davies | 3d10c1f | 2002-08-17 18:32:12 +0000 | [diff] [blame] | 276 | 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 Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 282 | } |
Huw D M Davies | 3d10c1f | 2002-08-17 18:32:12 +0000 | [diff] [blame] | 283 | 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 Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 293 | GDI_ReleaseObj( hdc ); |
| 294 | return ret; |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 295 | } |
| 296 | |
| 297 | |
| 298 | /*********************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 299 | * SetWindowExtEx (GDI32.@) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 300 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 301 | BOOL WINAPI SetWindowExtEx( HDC hdc, INT x, INT y, LPSIZE size ) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 302 | { |
Huw D M Davies | 3d10c1f | 2002-08-17 18:32:12 +0000 | [diff] [blame] | 303 | INT ret = TRUE; |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 304 | DC * dc = DC_GetDCPtr( hdc ); |
| 305 | if (!dc) return FALSE; |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 306 | if (dc->funcs->pSetWindowExt) |
| 307 | { |
Huw D M Davies | 3d10c1f | 2002-08-17 18:32:12 +0000 | [diff] [blame] | 308 | 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 Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 314 | } |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 315 | if (size) |
| 316 | { |
| 317 | size->cx = dc->wndExtX; |
| 318 | size->cy = dc->wndExtY; |
| 319 | } |
Alexandre Julliard | 2239abb | 2000-11-05 02:05:07 +0000 | [diff] [blame] | 320 | if ((dc->MapMode != MM_ISOTROPIC) && (dc->MapMode != MM_ANISOTROPIC)) |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 321 | goto done; |
| 322 | if (!x || !y) |
| 323 | { |
| 324 | ret = FALSE; |
| 325 | goto done; |
| 326 | } |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 327 | dc->wndExtX = x; |
| 328 | dc->wndExtY = y; |
Dmitry Timoshkov | e8e10e9 | 2003-05-11 02:50:21 +0000 | [diff] [blame] | 329 | /* Windows fixes MM_ISOTROPIC mode only in SetViewportExtEx() */ |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 330 | DC_UpdateXforms( dc ); |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 331 | done: |
| 332 | GDI_ReleaseObj( hdc ); |
| 333 | return ret; |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 334 | } |
| 335 | |
| 336 | |
| 337 | /*********************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 338 | * SetWindowOrgEx (GDI32.@) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 339 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 340 | BOOL WINAPI SetWindowOrgEx( HDC hdc, INT x, INT y, LPPOINT pt ) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 341 | { |
Huw D M Davies | 3d10c1f | 2002-08-17 18:32:12 +0000 | [diff] [blame] | 342 | INT ret = TRUE; |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 343 | DC * dc = DC_GetDCPtr( hdc ); |
| 344 | if (!dc) return FALSE; |
Huw D M Davies | 3d10c1f | 2002-08-17 18:32:12 +0000 | [diff] [blame] | 345 | if (dc->funcs->pSetWindowOrg) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 346 | { |
Huw D M Davies | 3d10c1f | 2002-08-17 18:32:12 +0000 | [diff] [blame] | 347 | 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 Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 353 | } |
Huw D M Davies | 3d10c1f | 2002-08-17 18:32:12 +0000 | [diff] [blame] | 354 | 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 Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 363 | GDI_ReleaseObj( hdc ); |
| 364 | return ret; |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 365 | } |
| 366 | |
| 367 | |
| 368 | /*********************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 369 | * OffsetViewportOrgEx (GDI32.@) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 370 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 371 | BOOL WINAPI OffsetViewportOrgEx( HDC hdc, INT x, INT y, LPPOINT pt) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 372 | { |
Huw D M Davies | 3d10c1f | 2002-08-17 18:32:12 +0000 | [diff] [blame] | 373 | INT ret = TRUE; |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 374 | DC * dc = DC_GetDCPtr( hdc ); |
| 375 | if (!dc) return FALSE; |
| 376 | if (dc->funcs->pOffsetViewportOrg) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 377 | { |
Huw D M Davies | 3d10c1f | 2002-08-17 18:32:12 +0000 | [diff] [blame] | 378 | 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 Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 384 | } |
Huw D M Davies | 3d10c1f | 2002-08-17 18:32:12 +0000 | [diff] [blame] | 385 | 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 Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 394 | GDI_ReleaseObj( hdc ); |
| 395 | return ret; |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 396 | } |
| 397 | |
| 398 | |
| 399 | /*********************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 400 | * OffsetWindowOrgEx (GDI32.@) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 401 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 402 | BOOL WINAPI OffsetWindowOrgEx( HDC hdc, INT x, INT y, LPPOINT pt ) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 403 | { |
Huw D M Davies | 3d10c1f | 2002-08-17 18:32:12 +0000 | [diff] [blame] | 404 | INT ret = TRUE; |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 405 | DC * dc = DC_GetDCPtr( hdc ); |
| 406 | if (!dc) return FALSE; |
| 407 | if (dc->funcs->pOffsetWindowOrg) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 408 | { |
Huw D M Davies | 3d10c1f | 2002-08-17 18:32:12 +0000 | [diff] [blame] | 409 | 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 Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 415 | } |
Huw D M Davies | 3d10c1f | 2002-08-17 18:32:12 +0000 | [diff] [blame] | 416 | 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 Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 425 | GDI_ReleaseObj( hdc ); |
| 426 | return ret; |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 427 | } |
| 428 | |
| 429 | |
| 430 | /*********************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 431 | * ScaleViewportExtEx (GDI32.@) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 432 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 433 | BOOL WINAPI ScaleViewportExtEx( HDC hdc, INT xNum, INT xDenom, |
| 434 | INT yNum, INT yDenom, LPSIZE size ) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 435 | { |
Huw D M Davies | 3d10c1f | 2002-08-17 18:32:12 +0000 | [diff] [blame] | 436 | INT ret = TRUE; |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 437 | DC * dc = DC_GetDCPtr( hdc ); |
| 438 | if (!dc) return FALSE; |
| 439 | if (dc->funcs->pScaleViewportExt) |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 440 | { |
Huw D M Davies | 3d10c1f | 2002-08-17 18:32:12 +0000 | [diff] [blame] | 441 | 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 Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 447 | } |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 448 | if (size) |
| 449 | { |
| 450 | size->cx = dc->vportExtX; |
| 451 | size->cy = dc->vportExtY; |
| 452 | } |
Alexandre Julliard | 2239abb | 2000-11-05 02:05:07 +0000 | [diff] [blame] | 453 | if ((dc->MapMode != MM_ISOTROPIC) && (dc->MapMode != MM_ANISOTROPIC)) |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 454 | goto done; |
| 455 | if (!xNum || !xDenom || !xNum || !yDenom) |
| 456 | { |
| 457 | ret = FALSE; |
| 458 | goto done; |
| 459 | } |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 460 | 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 Julliard | 2239abb | 2000-11-05 02:05:07 +0000 | [diff] [blame] | 464 | if (dc->MapMode == MM_ISOTROPIC) MAPPING_FixIsotropic( dc ); |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 465 | DC_UpdateXforms( dc ); |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 466 | done: |
| 467 | GDI_ReleaseObj( hdc ); |
| 468 | return ret; |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 469 | } |
| 470 | |
| 471 | |
| 472 | /*********************************************************************** |
Patrik Stridvall | d0a4177 | 2001-02-14 23:11:17 +0000 | [diff] [blame] | 473 | * ScaleWindowExtEx (GDI32.@) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 474 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 475 | BOOL WINAPI ScaleWindowExtEx( HDC hdc, INT xNum, INT xDenom, |
| 476 | INT yNum, INT yDenom, LPSIZE size ) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 477 | { |
Huw D M Davies | 3d10c1f | 2002-08-17 18:32:12 +0000 | [diff] [blame] | 478 | INT ret = TRUE; |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 479 | DC * dc = DC_GetDCPtr( hdc ); |
| 480 | if (!dc) return FALSE; |
| 481 | if (dc->funcs->pScaleWindowExt) |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 482 | { |
Huw D M Davies | 3d10c1f | 2002-08-17 18:32:12 +0000 | [diff] [blame] | 483 | 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 Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 489 | } |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 490 | if (size) |
| 491 | { |
| 492 | size->cx = dc->wndExtX; |
| 493 | size->cy = dc->wndExtY; |
| 494 | } |
Alexandre Julliard | 2239abb | 2000-11-05 02:05:07 +0000 | [diff] [blame] | 495 | if ((dc->MapMode != MM_ISOTROPIC) && (dc->MapMode != MM_ANISOTROPIC)) |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 496 | goto done; |
| 497 | if (!xNum || !xDenom || !xNum || !yDenom) |
| 498 | { |
| 499 | ret = FALSE; |
| 500 | goto done; |
| 501 | } |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 502 | 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 Julliard | 2239abb | 2000-11-05 02:05:07 +0000 | [diff] [blame] | 506 | if (dc->MapMode == MM_ISOTROPIC) MAPPING_FixIsotropic( dc ); |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 507 | DC_UpdateXforms( dc ); |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 508 | done: |
| 509 | GDI_ReleaseObj( hdc ); |
| 510 | return ret; |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 511 | } |