Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 1 | /* |
| 2 | * GDI Device Context functions |
| 3 | * |
| 4 | * Copyright 1993 Alexandre Julliard |
Alexandre Julliard | 234bc24 | 1994-12-10 13:02:28 +0000 | [diff] [blame] | 5 | * |
Alexandre Julliard | 7cbe657 | 1995-01-09 18:21:16 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
Patrik Stridvall | d96e1f1 | 1999-07-04 13:31:03 +0000 | [diff] [blame] | 8 | #include "config.h" |
| 9 | |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 10 | #include <stdlib.h> |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 11 | #include <string.h> |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 12 | #include "dc.h" |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 13 | #include "gdi.h" |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 14 | #include "heap.h" |
Alexandre Julliard | 1565709 | 1999-05-23 10:25:25 +0000 | [diff] [blame] | 15 | #include "debugtools.h" |
Alexandre Julliard | 234bc24 | 1994-12-10 13:02:28 +0000 | [diff] [blame] | 16 | #include "font.h" |
Huw D M Davies | 304d9a4 | 1999-09-13 15:15:45 +0000 | [diff] [blame] | 17 | #include "callback.h" |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 18 | #include "winerror.h" |
Jeremy White | d3e22d9 | 2000-02-10 19:03:02 +0000 | [diff] [blame] | 19 | #include "windef.h" |
| 20 | #include "wingdi.h" |
Patrik Stridvall | 8d8703c | 1999-02-04 14:05:38 +0000 | [diff] [blame] | 21 | #include "wine/winuser16.h" |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 22 | |
Alexandre Julliard | 07e4213 | 2000-03-19 21:19:21 +0000 | [diff] [blame] | 23 | DEFAULT_DEBUG_CHANNEL(dc); |
Patrik Stridvall | b4b9fae | 1999-04-19 14:56:29 +0000 | [diff] [blame] | 24 | |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 25 | /*********************************************************************** |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 26 | * DC_Init_DC_INFO |
| 27 | * |
| 28 | * Fill the WIN_DC_INFO structure. |
| 29 | */ |
| 30 | static void DC_Init_DC_INFO( WIN_DC_INFO *win_dc_info ) |
| 31 | { |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 32 | win_dc_info->flags = 0; |
| 33 | win_dc_info->devCaps = NULL; |
| 34 | win_dc_info->hClipRgn = 0; |
| 35 | win_dc_info->hVisRgn = 0; |
| 36 | win_dc_info->hGCClipRgn = 0; |
| 37 | win_dc_info->hPen = STOCK_BLACK_PEN; |
| 38 | win_dc_info->hBrush = STOCK_WHITE_BRUSH; |
| 39 | win_dc_info->hFont = STOCK_SYSTEM_FONT; |
| 40 | win_dc_info->hBitmap = 0; |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 41 | win_dc_info->hDevice = 0; |
| 42 | win_dc_info->hPalette = STOCK_DEFAULT_PALETTE; |
| 43 | win_dc_info->ROPmode = R2_COPYPEN; |
| 44 | win_dc_info->polyFillMode = ALTERNATE; |
| 45 | win_dc_info->stretchBltMode = BLACKONWHITE; |
| 46 | win_dc_info->relAbsMode = ABSOLUTE; |
| 47 | win_dc_info->backgroundMode = OPAQUE; |
| 48 | win_dc_info->backgroundColor = RGB( 255, 255, 255 ); |
| 49 | win_dc_info->textColor = RGB( 0, 0, 0 ); |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 50 | win_dc_info->brushOrgX = 0; |
| 51 | win_dc_info->brushOrgY = 0; |
| 52 | win_dc_info->textAlign = TA_LEFT | TA_TOP | TA_NOUPDATECP; |
| 53 | win_dc_info->charExtra = 0; |
| 54 | win_dc_info->breakTotalExtra = 0; |
| 55 | win_dc_info->breakCount = 0; |
| 56 | win_dc_info->breakExtra = 0; |
| 57 | win_dc_info->breakRem = 0; |
| 58 | win_dc_info->bitsPerPixel = 1; |
| 59 | win_dc_info->MapMode = MM_TEXT; |
| 60 | win_dc_info->GraphicsMode = GM_COMPATIBLE; |
| 61 | win_dc_info->DCOrgX = 0; |
| 62 | win_dc_info->DCOrgY = 0; |
Huw D M Davies | 304d9a4 | 1999-09-13 15:15:45 +0000 | [diff] [blame] | 63 | win_dc_info->pAbortProc = NULL; |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 64 | win_dc_info->CursPosX = 0; |
| 65 | win_dc_info->CursPosY = 0; |
| 66 | win_dc_info->ArcDirection = AD_COUNTERCLOCKWISE; |
| 67 | win_dc_info->xformWorld2Wnd.eM11 = 1.0f; |
| 68 | win_dc_info->xformWorld2Wnd.eM12 = 0.0f; |
| 69 | win_dc_info->xformWorld2Wnd.eM21 = 0.0f; |
| 70 | win_dc_info->xformWorld2Wnd.eM22 = 1.0f; |
| 71 | win_dc_info->xformWorld2Wnd.eDx = 0.0f; |
| 72 | win_dc_info->xformWorld2Wnd.eDy = 0.0f; |
| 73 | win_dc_info->xformWorld2Vport = win_dc_info->xformWorld2Wnd; |
| 74 | win_dc_info->xformVport2World = win_dc_info->xformWorld2Wnd; |
| 75 | win_dc_info->vport2WorldValid = TRUE; |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 76 | |
| 77 | PATH_InitGdiPath(&win_dc_info->path); |
| 78 | } |
| 79 | |
| 80 | |
| 81 | /*********************************************************************** |
Alexandre Julliard | bf9130a | 1996-10-13 17:45:47 +0000 | [diff] [blame] | 82 | * DC_AllocDC |
| 83 | */ |
| 84 | DC *DC_AllocDC( const DC_FUNCTIONS *funcs ) |
| 85 | { |
| 86 | HDC16 hdc; |
| 87 | DC *dc; |
| 88 | |
| 89 | if (!(hdc = GDI_AllocObject( sizeof(DC), DC_MAGIC ))) return NULL; |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 90 | dc = (DC *) GDI_HEAP_LOCK( hdc ); |
Alexandre Julliard | bf9130a | 1996-10-13 17:45:47 +0000 | [diff] [blame] | 91 | |
| 92 | dc->hSelf = hdc; |
| 93 | dc->funcs = funcs; |
| 94 | dc->physDev = NULL; |
| 95 | dc->saveLevel = 0; |
| 96 | dc->dwHookData = 0L; |
| 97 | dc->hookProc = NULL; |
Ulrich Weigand | f86aab8 | 1999-09-20 18:47:14 +0000 | [diff] [blame] | 98 | dc->hookThunk = NULL; |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 99 | dc->wndOrgX = 0; |
| 100 | dc->wndOrgY = 0; |
| 101 | dc->wndExtX = 1; |
| 102 | dc->wndExtY = 1; |
| 103 | dc->vportOrgX = 0; |
| 104 | dc->vportOrgY = 0; |
| 105 | dc->vportExtX = 1; |
| 106 | dc->vportExtY = 1; |
Alexandre Julliard | bf9130a | 1996-10-13 17:45:47 +0000 | [diff] [blame] | 107 | |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 108 | DC_Init_DC_INFO( &dc->w ); |
| 109 | |
Alexandre Julliard | bf9130a | 1996-10-13 17:45:47 +0000 | [diff] [blame] | 110 | return dc; |
| 111 | } |
| 112 | |
| 113 | |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 114 | |
Alexandre Julliard | bf9130a | 1996-10-13 17:45:47 +0000 | [diff] [blame] | 115 | /*********************************************************************** |
| 116 | * DC_GetDCPtr |
| 117 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 118 | DC *DC_GetDCPtr( HDC hdc ) |
Alexandre Julliard | bf9130a | 1996-10-13 17:45:47 +0000 | [diff] [blame] | 119 | { |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 120 | GDIOBJHDR *ptr = (GDIOBJHDR *)GDI_HEAP_LOCK( hdc ); |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 121 | if (!ptr) return NULL; |
Huw D M Davies | 7603dea | 1999-04-25 09:24:23 +0000 | [diff] [blame] | 122 | if ((ptr->wMagic == DC_MAGIC) || (ptr->wMagic == METAFILE_DC_MAGIC) || |
| 123 | (ptr->wMagic == ENHMETAFILE_DC_MAGIC)) |
Alexandre Julliard | bf9130a | 1996-10-13 17:45:47 +0000 | [diff] [blame] | 124 | return (DC *)ptr; |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 125 | GDI_HEAP_UNLOCK( hdc ); |
Alexandre Julliard | bf9130a | 1996-10-13 17:45:47 +0000 | [diff] [blame] | 126 | return NULL; |
| 127 | } |
| 128 | |
| 129 | |
| 130 | /*********************************************************************** |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 131 | * DC_InitDC |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 132 | * |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 133 | * Setup device-specific DC values for a newly created DC. |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 134 | */ |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 135 | void DC_InitDC( DC* dc ) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 136 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 137 | RealizeDefaultPalette16( dc->hSelf ); |
| 138 | SetTextColor( dc->hSelf, dc->w.textColor ); |
| 139 | SetBkColor( dc->hSelf, dc->w.backgroundColor ); |
| 140 | SelectObject( dc->hSelf, dc->w.hPen ); |
| 141 | SelectObject( dc->hSelf, dc->w.hBrush ); |
| 142 | SelectObject( dc->hSelf, dc->w.hFont ); |
Alexandre Julliard | 3a405ba | 1994-10-30 16:25:19 +0000 | [diff] [blame] | 143 | CLIPPING_UpdateGCRegion( dc ); |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 144 | } |
| 145 | |
| 146 | |
| 147 | /*********************************************************************** |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 148 | * DC_InvertXform |
| 149 | * |
| 150 | * Computes the inverse of the transformation xformSrc and stores it to |
| 151 | * xformDest. Returns TRUE if successful or FALSE if the xformSrc matrix |
| 152 | * is singular. |
| 153 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 154 | static BOOL DC_InvertXform( const XFORM *xformSrc, XFORM *xformDest ) |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 155 | { |
| 156 | FLOAT determinant; |
| 157 | |
| 158 | determinant = xformSrc->eM11*xformSrc->eM22 - |
| 159 | xformSrc->eM12*xformSrc->eM21; |
| 160 | if (determinant > -1e-12 && determinant < 1e-12) |
| 161 | return FALSE; |
| 162 | |
| 163 | xformDest->eM11 = xformSrc->eM22 / determinant; |
| 164 | xformDest->eM12 = -xformSrc->eM12 / determinant; |
| 165 | xformDest->eM21 = -xformSrc->eM21 / determinant; |
| 166 | xformDest->eM22 = xformSrc->eM11 / determinant; |
| 167 | xformDest->eDx = -xformSrc->eDx * xformDest->eM11 - |
| 168 | xformSrc->eDy * xformDest->eM21; |
| 169 | xformDest->eDy = -xformSrc->eDx * xformDest->eM12 - |
| 170 | xformSrc->eDy * xformDest->eM22; |
| 171 | |
| 172 | return TRUE; |
| 173 | } |
| 174 | |
| 175 | |
| 176 | /*********************************************************************** |
| 177 | * DC_UpdateXforms |
| 178 | * |
| 179 | * Updates the xformWorld2Vport, xformVport2World and vport2WorldValid |
| 180 | * fields of the specified DC by creating a transformation that |
| 181 | * represents the current mapping mode and combining it with the DC's |
| 182 | * world transform. This function should be called whenever the |
| 183 | * parameters associated with the mapping mode (window and viewport |
| 184 | * extents and origins) or the world transform change. |
| 185 | */ |
| 186 | void DC_UpdateXforms( DC *dc ) |
| 187 | { |
| 188 | XFORM xformWnd2Vport; |
| 189 | FLOAT scaleX, scaleY; |
| 190 | |
| 191 | /* Construct a transformation to do the window-to-viewport conversion */ |
| 192 | scaleX = (FLOAT)dc->vportExtX / (FLOAT)dc->wndExtX; |
| 193 | scaleY = (FLOAT)dc->vportExtY / (FLOAT)dc->wndExtY; |
| 194 | xformWnd2Vport.eM11 = scaleX; |
| 195 | xformWnd2Vport.eM12 = 0.0; |
| 196 | xformWnd2Vport.eM21 = 0.0; |
| 197 | xformWnd2Vport.eM22 = scaleY; |
| 198 | xformWnd2Vport.eDx = (FLOAT)dc->vportOrgX - |
| 199 | scaleX * (FLOAT)dc->wndOrgX; |
| 200 | xformWnd2Vport.eDy = (FLOAT)dc->vportOrgY - |
| 201 | scaleY * (FLOAT)dc->wndOrgY; |
| 202 | |
| 203 | /* Combine with the world transformation */ |
| 204 | CombineTransform( &dc->w.xformWorld2Vport, &dc->w.xformWorld2Wnd, |
| 205 | &xformWnd2Vport ); |
| 206 | |
| 207 | /* Create inverse of world-to-viewport transformation */ |
| 208 | dc->w.vport2WorldValid = DC_InvertXform( &dc->w.xformWorld2Vport, |
| 209 | &dc->w.xformVport2World ); |
| 210 | } |
| 211 | |
| 212 | |
| 213 | /*********************************************************************** |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 214 | * GetDCState (GDI.179) |
| 215 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 216 | HDC16 WINAPI GetDCState16( HDC16 hdc ) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 217 | { |
| 218 | DC * newdc, * dc; |
Alexandre Julliard | bf9130a | 1996-10-13 17:45:47 +0000 | [diff] [blame] | 219 | HGDIOBJ16 handle; |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 220 | |
| 221 | if (!(dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ))) return 0; |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 222 | if (!(handle = GDI_AllocObject( sizeof(DC), DC_MAGIC ))) |
| 223 | { |
| 224 | GDI_HEAP_UNLOCK( hdc ); |
| 225 | return 0; |
| 226 | } |
| 227 | newdc = (DC *) GDI_HEAP_LOCK( handle ); |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 228 | |
Alexandre Julliard | 1565709 | 1999-05-23 10:25:25 +0000 | [diff] [blame] | 229 | TRACE("(%04x): returning %04x\n", hdc, handle ); |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 230 | |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 231 | newdc->w.flags = dc->w.flags | DC_SAVED; |
| 232 | newdc->w.devCaps = dc->w.devCaps; |
| 233 | newdc->w.hPen = dc->w.hPen; |
| 234 | newdc->w.hBrush = dc->w.hBrush; |
| 235 | newdc->w.hFont = dc->w.hFont; |
| 236 | newdc->w.hBitmap = dc->w.hBitmap; |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 237 | newdc->w.hDevice = dc->w.hDevice; |
| 238 | newdc->w.hPalette = dc->w.hPalette; |
Ulrich Weigand | 27bb362 | 1998-10-14 18:06:44 +0000 | [diff] [blame] | 239 | newdc->w.totalExtent = dc->w.totalExtent; |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 240 | newdc->w.bitsPerPixel = dc->w.bitsPerPixel; |
| 241 | newdc->w.ROPmode = dc->w.ROPmode; |
| 242 | newdc->w.polyFillMode = dc->w.polyFillMode; |
| 243 | newdc->w.stretchBltMode = dc->w.stretchBltMode; |
| 244 | newdc->w.relAbsMode = dc->w.relAbsMode; |
| 245 | newdc->w.backgroundMode = dc->w.backgroundMode; |
| 246 | newdc->w.backgroundColor = dc->w.backgroundColor; |
| 247 | newdc->w.textColor = dc->w.textColor; |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 248 | newdc->w.brushOrgX = dc->w.brushOrgX; |
| 249 | newdc->w.brushOrgY = dc->w.brushOrgY; |
| 250 | newdc->w.textAlign = dc->w.textAlign; |
| 251 | newdc->w.charExtra = dc->w.charExtra; |
| 252 | newdc->w.breakTotalExtra = dc->w.breakTotalExtra; |
| 253 | newdc->w.breakCount = dc->w.breakCount; |
| 254 | newdc->w.breakExtra = dc->w.breakExtra; |
| 255 | newdc->w.breakRem = dc->w.breakRem; |
| 256 | newdc->w.MapMode = dc->w.MapMode; |
| 257 | newdc->w.GraphicsMode = dc->w.GraphicsMode; |
Ulrich Weigand | d466366 | 1998-10-11 18:47:02 +0000 | [diff] [blame] | 258 | #if 0 |
| 259 | /* Apparently, the DC origin is not changed by [GS]etDCState */ |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 260 | newdc->w.DCOrgX = dc->w.DCOrgX; |
| 261 | newdc->w.DCOrgY = dc->w.DCOrgY; |
Ulrich Weigand | d466366 | 1998-10-11 18:47:02 +0000 | [diff] [blame] | 262 | #endif |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 263 | newdc->w.CursPosX = dc->w.CursPosX; |
| 264 | newdc->w.CursPosY = dc->w.CursPosY; |
| 265 | newdc->w.ArcDirection = dc->w.ArcDirection; |
| 266 | newdc->w.xformWorld2Wnd = dc->w.xformWorld2Wnd; |
| 267 | newdc->w.xformWorld2Vport = dc->w.xformWorld2Vport; |
| 268 | newdc->w.xformVport2World = dc->w.xformVport2World; |
| 269 | newdc->w.vport2WorldValid = dc->w.vport2WorldValid; |
| 270 | newdc->wndOrgX = dc->wndOrgX; |
| 271 | newdc->wndOrgY = dc->wndOrgY; |
| 272 | newdc->wndExtX = dc->wndExtX; |
| 273 | newdc->wndExtY = dc->wndExtY; |
| 274 | newdc->vportOrgX = dc->vportOrgX; |
| 275 | newdc->vportOrgY = dc->vportOrgY; |
| 276 | newdc->vportExtX = dc->vportExtX; |
| 277 | newdc->vportExtY = dc->vportExtY; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 278 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 279 | newdc->hSelf = (HDC)handle; |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 280 | newdc->saveLevel = 0; |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 281 | |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 282 | PATH_InitGdiPath( &newdc->w.path ); |
| 283 | |
Huw D M Davies | 304d9a4 | 1999-09-13 15:15:45 +0000 | [diff] [blame] | 284 | newdc->w.pAbortProc = NULL; |
| 285 | |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 286 | /* Get/SetDCState() don't change hVisRgn field ("Undoc. Windows" p.559). */ |
| 287 | |
| 288 | newdc->w.hGCClipRgn = newdc->w.hVisRgn = 0; |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 289 | if (dc->w.hClipRgn) |
| 290 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 291 | newdc->w.hClipRgn = CreateRectRgn( 0, 0, 0, 0 ); |
| 292 | CombineRgn( newdc->w.hClipRgn, dc->w.hClipRgn, 0, RGN_COPY ); |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 293 | } |
Alexandre Julliard | 349a953 | 1997-02-02 19:01:52 +0000 | [diff] [blame] | 294 | else |
| 295 | newdc->w.hClipRgn = 0; |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 296 | GDI_HEAP_UNLOCK( handle ); |
| 297 | GDI_HEAP_UNLOCK( hdc ); |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 298 | return handle; |
| 299 | } |
| 300 | |
| 301 | |
| 302 | /*********************************************************************** |
| 303 | * SetDCState (GDI.180) |
| 304 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 305 | void WINAPI SetDCState16( HDC16 hdc, HDC16 hdcs ) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 306 | { |
Alexandre Julliard | 139a4b1 | 1996-11-02 14:24:07 +0000 | [diff] [blame] | 307 | DC *dc, *dcs; |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 308 | |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 309 | if (!(dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ))) return; |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 310 | if (!(dcs = (DC *) GDI_GetObjPtr( hdcs, DC_MAGIC ))) |
| 311 | { |
| 312 | GDI_HEAP_UNLOCK( hdc ); |
| 313 | return; |
| 314 | } |
| 315 | if (!dcs->w.flags & DC_SAVED) |
| 316 | { |
| 317 | GDI_HEAP_UNLOCK( hdc ); |
| 318 | GDI_HEAP_UNLOCK( hdcs ); |
| 319 | return; |
| 320 | } |
Alexandre Julliard | 1565709 | 1999-05-23 10:25:25 +0000 | [diff] [blame] | 321 | TRACE("%04x %04x\n", hdc, hdcs ); |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 322 | |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 323 | dc->w.flags = dcs->w.flags & ~DC_SAVED; |
| 324 | dc->w.devCaps = dcs->w.devCaps; |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 325 | dc->w.hDevice = dcs->w.hDevice; |
Ulrich Weigand | 27bb362 | 1998-10-14 18:06:44 +0000 | [diff] [blame] | 326 | dc->w.totalExtent = dcs->w.totalExtent; |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 327 | dc->w.ROPmode = dcs->w.ROPmode; |
| 328 | dc->w.polyFillMode = dcs->w.polyFillMode; |
| 329 | dc->w.stretchBltMode = dcs->w.stretchBltMode; |
| 330 | dc->w.relAbsMode = dcs->w.relAbsMode; |
| 331 | dc->w.backgroundMode = dcs->w.backgroundMode; |
| 332 | dc->w.backgroundColor = dcs->w.backgroundColor; |
| 333 | dc->w.textColor = dcs->w.textColor; |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 334 | dc->w.brushOrgX = dcs->w.brushOrgX; |
| 335 | dc->w.brushOrgY = dcs->w.brushOrgY; |
| 336 | dc->w.textAlign = dcs->w.textAlign; |
| 337 | dc->w.charExtra = dcs->w.charExtra; |
| 338 | dc->w.breakTotalExtra = dcs->w.breakTotalExtra; |
| 339 | dc->w.breakCount = dcs->w.breakCount; |
| 340 | dc->w.breakExtra = dcs->w.breakExtra; |
| 341 | dc->w.breakRem = dcs->w.breakRem; |
| 342 | dc->w.MapMode = dcs->w.MapMode; |
| 343 | dc->w.GraphicsMode = dcs->w.GraphicsMode; |
Ulrich Weigand | d466366 | 1998-10-11 18:47:02 +0000 | [diff] [blame] | 344 | #if 0 |
| 345 | /* Apparently, the DC origin is not changed by [GS]etDCState */ |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 346 | dc->w.DCOrgX = dcs->w.DCOrgX; |
| 347 | dc->w.DCOrgY = dcs->w.DCOrgY; |
Ulrich Weigand | d466366 | 1998-10-11 18:47:02 +0000 | [diff] [blame] | 348 | #endif |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 349 | dc->w.CursPosX = dcs->w.CursPosX; |
| 350 | dc->w.CursPosY = dcs->w.CursPosY; |
| 351 | dc->w.ArcDirection = dcs->w.ArcDirection; |
| 352 | dc->w.xformWorld2Wnd = dcs->w.xformWorld2Wnd; |
| 353 | dc->w.xformWorld2Vport = dcs->w.xformWorld2Vport; |
| 354 | dc->w.xformVport2World = dcs->w.xformVport2World; |
| 355 | dc->w.vport2WorldValid = dcs->w.vport2WorldValid; |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 356 | |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 357 | dc->wndOrgX = dcs->wndOrgX; |
| 358 | dc->wndOrgY = dcs->wndOrgY; |
| 359 | dc->wndExtX = dcs->wndExtX; |
| 360 | dc->wndExtY = dcs->wndExtY; |
| 361 | dc->vportOrgX = dcs->vportOrgX; |
| 362 | dc->vportOrgY = dcs->vportOrgY; |
| 363 | dc->vportExtX = dcs->vportExtX; |
| 364 | dc->vportExtY = dcs->vportExtY; |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 365 | |
Alexandre Julliard | 139a4b1 | 1996-11-02 14:24:07 +0000 | [diff] [blame] | 366 | if (!(dc->w.flags & DC_MEMORY)) dc->w.bitsPerPixel = dcs->w.bitsPerPixel; |
Ulrich Weigand | d466366 | 1998-10-11 18:47:02 +0000 | [diff] [blame] | 367 | |
| 368 | if (dcs->w.hClipRgn) |
| 369 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 370 | if (!dc->w.hClipRgn) dc->w.hClipRgn = CreateRectRgn( 0, 0, 0, 0 ); |
| 371 | CombineRgn( dc->w.hClipRgn, dcs->w.hClipRgn, 0, RGN_COPY ); |
Ulrich Weigand | d466366 | 1998-10-11 18:47:02 +0000 | [diff] [blame] | 372 | } |
| 373 | else |
Ulrich Weigand | 7119a6e | 1998-11-01 14:05:33 +0000 | [diff] [blame] | 374 | { |
| 375 | if (dc->w.hClipRgn) DeleteObject16( dc->w.hClipRgn ); |
Ulrich Weigand | d466366 | 1998-10-11 18:47:02 +0000 | [diff] [blame] | 376 | dc->w.hClipRgn = 0; |
Ulrich Weigand | 7119a6e | 1998-11-01 14:05:33 +0000 | [diff] [blame] | 377 | } |
| 378 | CLIPPING_UpdateGCRegion( dc ); |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 379 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 380 | SelectObject( hdc, dcs->w.hBitmap ); |
| 381 | SelectObject( hdc, dcs->w.hBrush ); |
| 382 | SelectObject( hdc, dcs->w.hFont ); |
| 383 | SelectObject( hdc, dcs->w.hPen ); |
| 384 | SetBkColor( hdc, dcs->w.backgroundColor); |
| 385 | SetTextColor( hdc, dcs->w.textColor); |
| 386 | GDISelectPalette16( hdc, dcs->w.hPalette, FALSE ); |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 387 | GDI_HEAP_UNLOCK( hdc ); |
| 388 | GDI_HEAP_UNLOCK( hdcs ); |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 389 | } |
| 390 | |
| 391 | |
| 392 | /*********************************************************************** |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 393 | * SaveDC16 (GDI.30) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 394 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 395 | INT16 WINAPI SaveDC16( HDC16 hdc ) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 396 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 397 | return (INT16)SaveDC( hdc ); |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 398 | } |
| 399 | |
| 400 | |
| 401 | /*********************************************************************** |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame^] | 402 | * SaveDC (GDI32.292) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 403 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 404 | INT WINAPI SaveDC( HDC hdc ) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 405 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 406 | HDC hdcs; |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 407 | DC * dc, * dcs; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 408 | INT ret; |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 409 | |
Huw D M Davies | 7603dea | 1999-04-25 09:24:23 +0000 | [diff] [blame] | 410 | dc = DC_GetDCPtr( hdc ); |
| 411 | if (!dc) return 0; |
| 412 | |
| 413 | if(dc->funcs->pSaveDC) |
| 414 | return dc->funcs->pSaveDC( dc ); |
| 415 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 416 | if (!(hdcs = GetDCState16( hdc ))) |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 417 | { |
| 418 | GDI_HEAP_UNLOCK( hdc ); |
| 419 | return 0; |
| 420 | } |
| 421 | dcs = (DC *) GDI_HEAP_LOCK( hdcs ); |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 422 | |
| 423 | /* Copy path. The reason why path saving / restoring is in SaveDC/ |
| 424 | * RestoreDC and not in GetDCState/SetDCState is that the ...DCState |
| 425 | * functions are only in Win16 (which doesn't have paths) and that |
| 426 | * SetDCState doesn't allow us to signal an error (which can happen |
| 427 | * when copying paths). |
| 428 | */ |
| 429 | if (!PATH_AssignGdiPath( &dcs->w.path, &dc->w.path )) |
| 430 | { |
| 431 | GDI_HEAP_UNLOCK( hdc ); |
| 432 | GDI_HEAP_UNLOCK( hdcs ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 433 | DeleteDC( hdcs ); |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 434 | return 0; |
| 435 | } |
| 436 | |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 437 | dcs->header.hNext = dc->header.hNext; |
| 438 | dc->header.hNext = hdcs; |
Alexandre Julliard | 1565709 | 1999-05-23 10:25:25 +0000 | [diff] [blame] | 439 | TRACE("(%04x): returning %d\n", hdc, dc->saveLevel+1 ); |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 440 | ret = ++dc->saveLevel; |
| 441 | GDI_HEAP_UNLOCK( hdcs ); |
| 442 | GDI_HEAP_UNLOCK( hdc ); |
| 443 | return ret; |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 444 | } |
| 445 | |
| 446 | |
| 447 | /*********************************************************************** |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 448 | * RestoreDC16 (GDI.39) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 449 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 450 | BOOL16 WINAPI RestoreDC16( HDC16 hdc, INT16 level ) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 451 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 452 | return RestoreDC( hdc, level ); |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 453 | } |
| 454 | |
| 455 | |
| 456 | /*********************************************************************** |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame^] | 457 | * RestoreDC (GDI32.290) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 458 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 459 | BOOL WINAPI RestoreDC( HDC hdc, INT level ) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 460 | { |
| 461 | DC * dc, * dcs; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 462 | BOOL success; |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 463 | |
Alexandre Julliard | 1565709 | 1999-05-23 10:25:25 +0000 | [diff] [blame] | 464 | TRACE("%04x %d\n", hdc, level ); |
Huw D M Davies | 7603dea | 1999-04-25 09:24:23 +0000 | [diff] [blame] | 465 | dc = DC_GetDCPtr( hdc ); |
| 466 | if(!dc) return FALSE; |
| 467 | if(dc->funcs->pRestoreDC) |
| 468 | return dc->funcs->pRestoreDC( dc, level ); |
| 469 | |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 470 | if (level == -1) level = dc->saveLevel; |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 471 | if ((level < 1) || (level > dc->saveLevel)) |
| 472 | { |
| 473 | GDI_HEAP_UNLOCK( hdc ); |
| 474 | return FALSE; |
| 475 | } |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 476 | |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 477 | success=TRUE; |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 478 | while (dc->saveLevel >= level) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 479 | { |
Alexandre Julliard | 530ee84 | 1996-10-23 16:59:13 +0000 | [diff] [blame] | 480 | HDC16 hdcs = dc->header.hNext; |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 481 | if (!(dcs = (DC *) GDI_GetObjPtr( hdcs, DC_MAGIC ))) |
| 482 | { |
| 483 | GDI_HEAP_UNLOCK( hdc ); |
| 484 | return FALSE; |
| 485 | } |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 486 | dc->header.hNext = dcs->header.hNext; |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 487 | if (--dc->saveLevel < level) |
| 488 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 489 | SetDCState16( hdc, hdcs ); |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 490 | if (!PATH_AssignGdiPath( &dc->w.path, &dcs->w.path )) |
| 491 | /* FIXME: This might not be quite right, since we're |
| 492 | * returning FALSE but still destroying the saved DC state */ |
| 493 | success=FALSE; |
| 494 | } |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 495 | DeleteDC( hdcs ); |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 496 | } |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 497 | GDI_HEAP_UNLOCK( hdc ); |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 498 | return success; |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 499 | } |
| 500 | |
| 501 | |
| 502 | /*********************************************************************** |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 503 | * CreateDC16 (GDI.53) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 504 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 505 | HDC16 WINAPI CreateDC16( LPCSTR driver, LPCSTR device, LPCSTR output, |
Huw D M Davies | e39b676 | 1999-05-17 16:20:51 +0000 | [diff] [blame] | 506 | const DEVMODEA *initData ) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 507 | { |
| 508 | DC * dc; |
Alexandre Julliard | 0e270f4 | 1996-08-24 18:26:35 +0000 | [diff] [blame] | 509 | const DC_FUNCTIONS *funcs; |
Huw D M Davies | e39b676 | 1999-05-17 16:20:51 +0000 | [diff] [blame] | 510 | char buf[300]; |
Alexandre Julliard | 0e270f4 | 1996-08-24 18:26:35 +0000 | [diff] [blame] | 511 | |
Huw D M Davies | e39b676 | 1999-05-17 16:20:51 +0000 | [diff] [blame] | 512 | if (device) { |
| 513 | if(!DRIVER_GetDriverName( device, buf, sizeof(buf) )) return 0; |
| 514 | } else |
| 515 | strcpy(buf, driver); |
| 516 | |
| 517 | if (!(funcs = DRIVER_FindDriver( buf ))) return 0; |
Alexandre Julliard | bf9130a | 1996-10-13 17:45:47 +0000 | [diff] [blame] | 518 | if (!(dc = DC_AllocDC( funcs ))) return 0; |
| 519 | dc->w.flags = 0; |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 520 | |
Alexandre Julliard | 1565709 | 1999-05-23 10:25:25 +0000 | [diff] [blame] | 521 | TRACE("(driver=%s, device=%s, output=%s): returning %04x\n", |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 522 | debugstr_a(driver), debugstr_a(device), debugstr_a(output), dc->hSelf ); |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 523 | |
Alexandre Julliard | 0e270f4 | 1996-08-24 18:26:35 +0000 | [diff] [blame] | 524 | if (dc->funcs->pCreateDC && |
Huw D M Davies | 304d9a4 | 1999-09-13 15:15:45 +0000 | [diff] [blame] | 525 | !dc->funcs->pCreateDC( dc, buf, device, output, initData )) |
Alexandre Julliard | 3a405ba | 1994-10-30 16:25:19 +0000 | [diff] [blame] | 526 | { |
Alexandre Julliard | 1565709 | 1999-05-23 10:25:25 +0000 | [diff] [blame] | 527 | WARN("creation aborted by device\n" ); |
Alexandre Julliard | bf9130a | 1996-10-13 17:45:47 +0000 | [diff] [blame] | 528 | GDI_HEAP_FREE( dc->hSelf ); |
Alexandre Julliard | 3a405ba | 1994-10-30 16:25:19 +0000 | [diff] [blame] | 529 | return 0; |
| 530 | } |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 531 | |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 532 | DC_InitDC( dc ); |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 533 | GDI_HEAP_UNLOCK( dc->hSelf ); |
Alexandre Julliard | bf9130a | 1996-10-13 17:45:47 +0000 | [diff] [blame] | 534 | return dc->hSelf; |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 535 | } |
| 536 | |
| 537 | |
| 538 | /*********************************************************************** |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame^] | 539 | * CreateDCA (GDI32.) |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 540 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 541 | HDC WINAPI CreateDCA( LPCSTR driver, LPCSTR device, LPCSTR output, |
| 542 | const DEVMODEA *initData ) |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 543 | { |
Huw D M Davies | e39b676 | 1999-05-17 16:20:51 +0000 | [diff] [blame] | 544 | return CreateDC16( driver, device, output, (const DEVMODEA *)initData ); |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 545 | } |
| 546 | |
| 547 | |
| 548 | /*********************************************************************** |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame^] | 549 | * CreateDCW (GDI32.) |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 550 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 551 | HDC WINAPI CreateDCW( LPCWSTR driver, LPCWSTR device, LPCWSTR output, |
| 552 | const DEVMODEW *initData ) |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 553 | { |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 554 | LPSTR driverA = HEAP_strdupWtoA( GetProcessHeap(), 0, driver ); |
| 555 | LPSTR deviceA = HEAP_strdupWtoA( GetProcessHeap(), 0, device ); |
| 556 | LPSTR outputA = HEAP_strdupWtoA( GetProcessHeap(), 0, output ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 557 | HDC res = CreateDC16( driverA, deviceA, outputA, |
Huw D M Davies | e39b676 | 1999-05-17 16:20:51 +0000 | [diff] [blame] | 558 | (const DEVMODEA *)initData /*FIXME*/ ); |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 559 | HeapFree( GetProcessHeap(), 0, driverA ); |
| 560 | HeapFree( GetProcessHeap(), 0, deviceA ); |
| 561 | HeapFree( GetProcessHeap(), 0, outputA ); |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 562 | return res; |
| 563 | } |
| 564 | |
| 565 | |
| 566 | /*********************************************************************** |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 567 | * CreateIC16 (GDI.153) |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 568 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 569 | HDC16 WINAPI CreateIC16( LPCSTR driver, LPCSTR device, LPCSTR output, |
Huw D M Davies | e39b676 | 1999-05-17 16:20:51 +0000 | [diff] [blame] | 570 | const DEVMODEA* initData ) |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 571 | { |
| 572 | /* Nothing special yet for ICs */ |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 573 | return CreateDC16( driver, device, output, initData ); |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 574 | } |
| 575 | |
| 576 | |
| 577 | /*********************************************************************** |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame^] | 578 | * CreateICA (GDI32.49) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 579 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 580 | HDC WINAPI CreateICA( LPCSTR driver, LPCSTR device, LPCSTR output, |
| 581 | const DEVMODEA* initData ) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 582 | { |
| 583 | /* Nothing special yet for ICs */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 584 | return CreateDCA( driver, device, output, initData ); |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 585 | } |
| 586 | |
| 587 | |
| 588 | /*********************************************************************** |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame^] | 589 | * CreateICW (GDI32.50) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 590 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 591 | HDC WINAPI CreateICW( LPCWSTR driver, LPCWSTR device, LPCWSTR output, |
| 592 | const DEVMODEW* initData ) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 593 | { |
| 594 | /* Nothing special yet for ICs */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 595 | return CreateDCW( driver, device, output, initData ); |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 596 | } |
| 597 | |
| 598 | |
| 599 | /*********************************************************************** |
| 600 | * CreateCompatibleDC16 (GDI.52) |
| 601 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 602 | HDC16 WINAPI CreateCompatibleDC16( HDC16 hdc ) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 603 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 604 | return (HDC16)CreateCompatibleDC( hdc ); |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 605 | } |
| 606 | |
| 607 | |
| 608 | /*********************************************************************** |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame^] | 609 | * CreateCompatibleDC (GDI32.31) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 610 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 611 | HDC WINAPI CreateCompatibleDC( HDC hdc ) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 612 | { |
Alexandre Julliard | 0e270f4 | 1996-08-24 18:26:35 +0000 | [diff] [blame] | 613 | DC *dc, *origDC; |
Alexandre Julliard | 0e270f4 | 1996-08-24 18:26:35 +0000 | [diff] [blame] | 614 | const DC_FUNCTIONS *funcs; |
| 615 | |
| 616 | if ((origDC = (DC *)GDI_GetObjPtr( hdc, DC_MAGIC ))) funcs = origDC->funcs; |
| 617 | else funcs = DRIVER_FindDriver( "DISPLAY" ); |
| 618 | if (!funcs) return 0; |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 619 | |
Alexandre Julliard | bf9130a | 1996-10-13 17:45:47 +0000 | [diff] [blame] | 620 | if (!(dc = DC_AllocDC( funcs ))) return 0; |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 621 | |
Alexandre Julliard | 1565709 | 1999-05-23 10:25:25 +0000 | [diff] [blame] | 622 | TRACE("(%04x): returning %04x\n", |
Alexandre Julliard | bf9130a | 1996-10-13 17:45:47 +0000 | [diff] [blame] | 623 | hdc, dc->hSelf ); |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 624 | |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 625 | dc->w.flags = DC_MEMORY; |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 626 | dc->w.bitsPerPixel = 1; |
Gerard Patel | d1795f6 | 2000-01-09 20:52:53 +0000 | [diff] [blame] | 627 | dc->w.hBitmap = hPseudoStockBitmap; |
Alexandre Julliard | 3a405ba | 1994-10-30 16:25:19 +0000 | [diff] [blame] | 628 | |
Noel Borthwick | 86b686f | 1999-06-05 08:52:30 +0000 | [diff] [blame] | 629 | /* Copy the driver-specific physical device info into |
| 630 | * the new DC. The driver may use this read-only info |
| 631 | * while creating the compatible DC below. */ |
| 632 | if (origDC) |
| 633 | dc->physDev = origDC->physDev; |
| 634 | |
Alexandre Julliard | 0e270f4 | 1996-08-24 18:26:35 +0000 | [diff] [blame] | 635 | if (dc->funcs->pCreateDC && |
| 636 | !dc->funcs->pCreateDC( dc, NULL, NULL, NULL, NULL )) |
Alexandre Julliard | 3a405ba | 1994-10-30 16:25:19 +0000 | [diff] [blame] | 637 | { |
Alexandre Julliard | 1565709 | 1999-05-23 10:25:25 +0000 | [diff] [blame] | 638 | WARN("creation aborted by device\n"); |
Alexandre Julliard | bf9130a | 1996-10-13 17:45:47 +0000 | [diff] [blame] | 639 | GDI_HEAP_FREE( dc->hSelf ); |
Alexandre Julliard | 3a405ba | 1994-10-30 16:25:19 +0000 | [diff] [blame] | 640 | return 0; |
| 641 | } |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 642 | |
Alexandre Julliard | d1ce8b2 | 1996-09-02 16:46:30 +0000 | [diff] [blame] | 643 | DC_InitDC( dc ); |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 644 | GDI_HEAP_UNLOCK( dc->hSelf ); |
Alexandre Julliard | bf9130a | 1996-10-13 17:45:47 +0000 | [diff] [blame] | 645 | return dc->hSelf; |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 646 | } |
| 647 | |
| 648 | |
| 649 | /*********************************************************************** |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 650 | * DeleteDC16 (GDI.68) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 651 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 652 | BOOL16 WINAPI DeleteDC16( HDC16 hdc ) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 653 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 654 | return DeleteDC( hdc ); |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 655 | } |
| 656 | |
| 657 | |
| 658 | /*********************************************************************** |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame^] | 659 | * DeleteDC (GDI32.67) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 660 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 661 | BOOL WINAPI DeleteDC( HDC hdc ) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 662 | { |
Ulrich Weigand | e6ea9eb | 1999-05-08 09:50:52 +0000 | [diff] [blame] | 663 | DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 664 | if (!dc) return FALSE; |
| 665 | |
Alexandre Julliard | 1565709 | 1999-05-23 10:25:25 +0000 | [diff] [blame] | 666 | TRACE("%04x\n", hdc ); |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 667 | |
Ulrich Weigand | e6ea9eb | 1999-05-08 09:50:52 +0000 | [diff] [blame] | 668 | /* Call hook procedure to check whether is it OK to delete this DC */ |
Ulrich Weigand | f86aab8 | 1999-09-20 18:47:14 +0000 | [diff] [blame] | 669 | if ( dc->hookThunk && !(dc->w.flags & (DC_SAVED | DC_MEMORY)) |
| 670 | && dc->hookThunk( hdc, DCHC_DELETEDC, dc->dwHookData, 0 ) == FALSE ) |
Ulrich Weigand | e6ea9eb | 1999-05-08 09:50:52 +0000 | [diff] [blame] | 671 | { |
| 672 | GDI_HEAP_UNLOCK( hdc ); |
| 673 | return FALSE; |
| 674 | } |
| 675 | |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 676 | while (dc->saveLevel) |
| 677 | { |
| 678 | DC * dcs; |
Alexandre Julliard | 530ee84 | 1996-10-23 16:59:13 +0000 | [diff] [blame] | 679 | HDC16 hdcs = dc->header.hNext; |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 680 | if (!(dcs = (DC *) GDI_GetObjPtr( hdcs, DC_MAGIC ))) break; |
| 681 | dc->header.hNext = dcs->header.hNext; |
| 682 | dc->saveLevel--; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 683 | DeleteDC( hdcs ); |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 684 | } |
| 685 | |
| 686 | if (!(dc->w.flags & DC_SAVED)) |
| 687 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 688 | SelectObject( hdc, STOCK_BLACK_PEN ); |
| 689 | SelectObject( hdc, STOCK_WHITE_BRUSH ); |
| 690 | SelectObject( hdc, STOCK_SYSTEM_FONT ); |
Alexandre Julliard | 0e270f4 | 1996-08-24 18:26:35 +0000 | [diff] [blame] | 691 | if (dc->funcs->pDeleteDC) dc->funcs->pDeleteDC(dc); |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 692 | } |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 693 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 694 | if (dc->w.hClipRgn) DeleteObject( dc->w.hClipRgn ); |
| 695 | if (dc->w.hVisRgn) DeleteObject( dc->w.hVisRgn ); |
| 696 | if (dc->w.hGCClipRgn) DeleteObject( dc->w.hGCClipRgn ); |
Huw D M Davies | 304d9a4 | 1999-09-13 15:15:45 +0000 | [diff] [blame] | 697 | if (dc->w.pAbortProc) THUNK_Free( (FARPROC)dc->w.pAbortProc ); |
Ulrich Weigand | f86aab8 | 1999-09-20 18:47:14 +0000 | [diff] [blame] | 698 | if (dc->hookThunk) THUNK_Free( (FARPROC)dc->hookThunk ); |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 699 | PATH_DestroyGdiPath(&dc->w.path); |
| 700 | |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 701 | return GDI_FreeObject( hdc ); |
| 702 | } |
| 703 | |
| 704 | |
| 705 | /*********************************************************************** |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 706 | * ResetDC16 (GDI.376) |
Alexandre Julliard | af0bae5 | 1995-10-03 17:06:08 +0000 | [diff] [blame] | 707 | */ |
Huw D M Davies | e39b676 | 1999-05-17 16:20:51 +0000 | [diff] [blame] | 708 | HDC16 WINAPI ResetDC16( HDC16 hdc, const DEVMODEA *devmode ) |
Alexandre Julliard | af0bae5 | 1995-10-03 17:06:08 +0000 | [diff] [blame] | 709 | { |
Alexandre Julliard | 1565709 | 1999-05-23 10:25:25 +0000 | [diff] [blame] | 710 | FIXME("stub\n" ); |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 711 | return hdc; |
| 712 | } |
| 713 | |
| 714 | |
| 715 | /*********************************************************************** |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame^] | 716 | * ResetDCA (GDI32.287) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 717 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 718 | HDC WINAPI ResetDCA( HDC hdc, const DEVMODEA *devmode ) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 719 | { |
Alexandre Julliard | 1565709 | 1999-05-23 10:25:25 +0000 | [diff] [blame] | 720 | FIXME("stub\n" ); |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 721 | return hdc; |
| 722 | } |
| 723 | |
| 724 | |
| 725 | /*********************************************************************** |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame^] | 726 | * ResetDCW (GDI32.288) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 727 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 728 | HDC WINAPI ResetDCW( HDC hdc, const DEVMODEW *devmode ) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 729 | { |
Alexandre Julliard | 1565709 | 1999-05-23 10:25:25 +0000 | [diff] [blame] | 730 | FIXME("stub\n" ); |
Alexandre Julliard | af0bae5 | 1995-10-03 17:06:08 +0000 | [diff] [blame] | 731 | return hdc; |
| 732 | } |
| 733 | |
| 734 | |
| 735 | /*********************************************************************** |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 736 | * GetDeviceCaps16 (GDI.80) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 737 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 738 | INT16 WINAPI GetDeviceCaps16( HDC16 hdc, INT16 cap ) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 739 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 740 | return GetDeviceCaps( hdc, cap ); |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 741 | } |
| 742 | |
| 743 | |
| 744 | /*********************************************************************** |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame^] | 745 | * GetDeviceCaps (GDI32.171) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 746 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 747 | INT WINAPI GetDeviceCaps( HDC hdc, INT cap ) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 748 | { |
| 749 | DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 750 | INT ret; |
Huw D M Davies | e39b676 | 1999-05-17 16:20:51 +0000 | [diff] [blame] | 751 | POINT pt; |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 752 | |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 753 | if (!dc) return 0; |
| 754 | |
Huw D M Davies | e39b676 | 1999-05-17 16:20:51 +0000 | [diff] [blame] | 755 | /* Device capabilities for the printer */ |
| 756 | switch (cap) |
| 757 | { |
| 758 | case PHYSICALWIDTH: |
| 759 | if(Escape(hdc, GETPHYSPAGESIZE, 0, NULL, (LPVOID)&pt) > 0) |
| 760 | return pt.x; |
| 761 | case PHYSICALHEIGHT: |
| 762 | if(Escape(hdc, GETPHYSPAGESIZE, 0, NULL, (LPVOID)&pt) > 0) |
| 763 | return pt.y; |
| 764 | case PHYSICALOFFSETX: |
| 765 | if(Escape(hdc, GETPRINTINGOFFSET, 0, NULL, (LPVOID)&pt) > 0) |
| 766 | return pt.x; |
| 767 | case PHYSICALOFFSETY: |
| 768 | if(Escape(hdc, GETPRINTINGOFFSET, 0, NULL, (LPVOID)&pt) > 0) |
| 769 | return pt.y; |
| 770 | case SCALINGFACTORX: |
| 771 | if(Escape(hdc, GETSCALINGFACTOR, 0, NULL, (LPVOID)&pt) > 0) |
| 772 | return pt.x; |
| 773 | case SCALINGFACTORY: |
| 774 | if(Escape(hdc, GETSCALINGFACTOR, 0, NULL, (LPVOID)&pt) > 0) |
| 775 | return pt.y; |
| 776 | } |
| 777 | |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 778 | if ((cap < 0) || (cap > sizeof(DeviceCaps)-sizeof(WORD))) |
| 779 | { |
| 780 | GDI_HEAP_UNLOCK( hdc ); |
| 781 | return 0; |
| 782 | } |
Marcus Meissner | 382354e | 2000-01-30 22:19:08 +0000 | [diff] [blame] | 783 | |
| 784 | if (((cap>=46) && (cap<88)) || ((cap>=92) && (cap<104))) |
| 785 | FIXME("(%04x,%d): unsupported DeviceCaps capability, will yield 0!\n", |
| 786 | hdc,cap |
| 787 | ); |
Alexandre Julliard | 1565709 | 1999-05-23 10:25:25 +0000 | [diff] [blame] | 788 | TRACE("(%04x,%d): returning %d\n", |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 789 | hdc, cap, *(WORD *)(((char *)dc->w.devCaps) + cap) ); |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 790 | ret = *(WORD *)(((char *)dc->w.devCaps) + cap); |
| 791 | GDI_HEAP_UNLOCK( hdc ); |
| 792 | return ret; |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 793 | } |
| 794 | |
| 795 | |
| 796 | /*********************************************************************** |
Alexandre Julliard | 2197901 | 1997-03-05 08:22:35 +0000 | [diff] [blame] | 797 | * SetBkColor16 (GDI.1) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 798 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 799 | COLORREF WINAPI SetBkColor16( HDC16 hdc, COLORREF color ) |
Alexandre Julliard | 2197901 | 1997-03-05 08:22:35 +0000 | [diff] [blame] | 800 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 801 | return SetBkColor( hdc, color ); |
Alexandre Julliard | 2197901 | 1997-03-05 08:22:35 +0000 | [diff] [blame] | 802 | } |
| 803 | |
| 804 | |
| 805 | /*********************************************************************** |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame^] | 806 | * SetBkColor (GDI32.305) |
Alexandre Julliard | 2197901 | 1997-03-05 08:22:35 +0000 | [diff] [blame] | 807 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 808 | COLORREF WINAPI SetBkColor( HDC hdc, COLORREF color ) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 809 | { |
| 810 | COLORREF oldColor; |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 811 | DC * dc = DC_GetDCPtr( hdc ); |
| 812 | |
| 813 | if (!dc) return 0x80000000; |
| 814 | if (dc->funcs->pSetBkColor) |
| 815 | oldColor = dc->funcs->pSetBkColor(dc, color); |
| 816 | else { |
| 817 | oldColor = dc->w.backgroundColor; |
| 818 | dc->w.backgroundColor = color; |
Alexandre Julliard | 73450d6 | 1994-05-18 18:29:32 +0000 | [diff] [blame] | 819 | } |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 820 | GDI_HEAP_UNLOCK( hdc ); |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 821 | return oldColor; |
| 822 | } |
| 823 | |
| 824 | |
| 825 | /*********************************************************************** |
Alexandre Julliard | 2197901 | 1997-03-05 08:22:35 +0000 | [diff] [blame] | 826 | * SetTextColor16 (GDI.9) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 827 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 828 | COLORREF WINAPI SetTextColor16( HDC16 hdc, COLORREF color ) |
Alexandre Julliard | 2197901 | 1997-03-05 08:22:35 +0000 | [diff] [blame] | 829 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 830 | return SetTextColor( hdc, color ); |
Alexandre Julliard | 2197901 | 1997-03-05 08:22:35 +0000 | [diff] [blame] | 831 | } |
| 832 | |
| 833 | |
| 834 | /*********************************************************************** |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame^] | 835 | * SetTextColor (GDI32.338) |
Alexandre Julliard | 2197901 | 1997-03-05 08:22:35 +0000 | [diff] [blame] | 836 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 837 | COLORREF WINAPI SetTextColor( HDC hdc, COLORREF color ) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 838 | { |
| 839 | COLORREF oldColor; |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 840 | DC * dc = DC_GetDCPtr( hdc ); |
| 841 | |
| 842 | if (!dc) return 0x80000000; |
| 843 | if (dc->funcs->pSetTextColor) |
| 844 | oldColor = dc->funcs->pSetTextColor(dc, color); |
| 845 | else { |
| 846 | oldColor = dc->w.textColor; |
| 847 | dc->w.textColor = color; |
Alexandre Julliard | 73450d6 | 1994-05-18 18:29:32 +0000 | [diff] [blame] | 848 | } |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 849 | GDI_HEAP_UNLOCK( hdc ); |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 850 | return oldColor; |
| 851 | } |
| 852 | |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 853 | /*********************************************************************** |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 854 | * SetTextAlign16 (GDI.346) |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 855 | */ |
Huw D M Davies | 7603dea | 1999-04-25 09:24:23 +0000 | [diff] [blame] | 856 | UINT16 WINAPI SetTextAlign16( HDC16 hdc, UINT16 align ) |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 857 | { |
Huw D M Davies | 7603dea | 1999-04-25 09:24:23 +0000 | [diff] [blame] | 858 | return SetTextAlign( hdc, align ); |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 859 | } |
| 860 | |
| 861 | |
| 862 | /*********************************************************************** |
Huw D M Davies | 7603dea | 1999-04-25 09:24:23 +0000 | [diff] [blame] | 863 | * SetTextAlign (GDI32.336) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 864 | */ |
Huw D M Davies | 7603dea | 1999-04-25 09:24:23 +0000 | [diff] [blame] | 865 | UINT WINAPI SetTextAlign( HDC hdc, UINT align ) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 866 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 867 | UINT prevAlign; |
Huw D M Davies | 7603dea | 1999-04-25 09:24:23 +0000 | [diff] [blame] | 868 | DC *dc = DC_GetDCPtr( hdc ); |
| 869 | if (!dc) return 0x0; |
| 870 | if (dc->funcs->pSetTextAlign) |
| 871 | prevAlign = dc->funcs->pSetTextAlign(dc, align); |
| 872 | else { |
| 873 | prevAlign = dc->w.textAlign; |
| 874 | dc->w.textAlign = align; |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 875 | } |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 876 | GDI_HEAP_UNLOCK( hdc ); |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 877 | return prevAlign; |
| 878 | } |
| 879 | |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 880 | /*********************************************************************** |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 881 | * GetDCOrgEx (GDI32.168) |
| 882 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 883 | BOOL WINAPI GetDCOrgEx( HDC hDC, LPPOINT lpp ) |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 884 | { |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 885 | DC * dc; |
Huw D M Davies | 9c68faa | 1998-11-25 12:36:03 +0000 | [diff] [blame] | 886 | |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 887 | if (!lpp) return FALSE; |
| 888 | if (!(dc = (DC *) GDI_GetObjPtr( hDC, DC_MAGIC ))) return FALSE; |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 889 | |
Alexandre Julliard | 07e4213 | 2000-03-19 21:19:21 +0000 | [diff] [blame] | 890 | lpp->x = lpp->y = 0; |
| 891 | if (dc->funcs->pGetDCOrgEx) dc->funcs->pGetDCOrgEx( dc, lpp ); |
| 892 | lpp->x += dc->w.DCOrgX; |
| 893 | lpp->y += dc->w.DCOrgY; |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 894 | GDI_HEAP_UNLOCK( hDC ); |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 895 | return TRUE; |
| 896 | } |
| 897 | |
| 898 | |
| 899 | /*********************************************************************** |
Alexandre Julliard | 3f2abfa | 1994-08-16 15:43:11 +0000 | [diff] [blame] | 900 | * GetDCOrg (GDI.79) |
| 901 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 902 | DWORD WINAPI GetDCOrg16( HDC16 hdc ) |
Alexandre Julliard | 3f2abfa | 1994-08-16 15:43:11 +0000 | [diff] [blame] | 903 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 904 | POINT pt; |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 905 | if( GetDCOrgEx( hdc, &pt) ) |
| 906 | return MAKELONG( (WORD)pt.x, (WORD)pt.y ); |
| 907 | return 0; |
Alexandre Julliard | 3f2abfa | 1994-08-16 15:43:11 +0000 | [diff] [blame] | 908 | } |
| 909 | |
| 910 | |
| 911 | /*********************************************************************** |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 912 | * SetDCOrg (GDI.117) |
| 913 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 914 | DWORD WINAPI SetDCOrg16( HDC16 hdc, INT16 x, INT16 y ) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 915 | { |
| 916 | DWORD prevOrg; |
| 917 | DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); |
| 918 | if (!dc) return 0; |
| 919 | prevOrg = dc->w.DCOrgX | (dc->w.DCOrgY << 16); |
| 920 | dc->w.DCOrgX = x; |
| 921 | dc->w.DCOrgY = y; |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 922 | GDI_HEAP_UNLOCK( hdc ); |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 923 | return prevOrg; |
| 924 | } |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 925 | |
| 926 | |
| 927 | /*********************************************************************** |
Alexandre Julliard | 17216f5 | 1997-10-12 16:30:17 +0000 | [diff] [blame] | 928 | * GetGraphicsMode (GDI32.188) |
| 929 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 930 | INT WINAPI GetGraphicsMode( HDC hdc ) |
Alexandre Julliard | 17216f5 | 1997-10-12 16:30:17 +0000 | [diff] [blame] | 931 | { |
| 932 | DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); |
| 933 | if (!dc) return 0; |
| 934 | return dc->w.GraphicsMode; |
| 935 | } |
| 936 | |
| 937 | |
| 938 | /*********************************************************************** |
| 939 | * SetGraphicsMode (GDI32.317) |
| 940 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 941 | INT WINAPI SetGraphicsMode( HDC hdc, INT mode ) |
Alexandre Julliard | 17216f5 | 1997-10-12 16:30:17 +0000 | [diff] [blame] | 942 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 943 | INT ret; |
Alexandre Julliard | 17216f5 | 1997-10-12 16:30:17 +0000 | [diff] [blame] | 944 | DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 945 | |
| 946 | /* One would think that setting the graphics mode to GM_COMPATIBLE |
| 947 | * would also reset the world transformation matrix to the unity |
| 948 | * matrix. However, in Windows, this is not the case. This doesn't |
| 949 | * make a lot of sense to me, but that's the way it is. |
| 950 | */ |
| 951 | |
Alexandre Julliard | 17216f5 | 1997-10-12 16:30:17 +0000 | [diff] [blame] | 952 | if (!dc) return 0; |
| 953 | if ((mode <= 0) || (mode > GM_LAST)) return 0; |
| 954 | ret = dc->w.GraphicsMode; |
| 955 | dc->w.GraphicsMode = mode; |
| 956 | return ret; |
| 957 | } |
| 958 | |
| 959 | |
| 960 | /*********************************************************************** |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 961 | * GetArcDirection16 (GDI.524) |
| 962 | */ |
| 963 | INT16 WINAPI GetArcDirection16( HDC16 hdc ) |
| 964 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 965 | return GetArcDirection( (HDC)hdc ); |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 966 | } |
| 967 | |
| 968 | |
| 969 | /*********************************************************************** |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame^] | 970 | * GetArcDirection (GDI32.141) |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 971 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 972 | INT WINAPI GetArcDirection( HDC hdc ) |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 973 | { |
| 974 | DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); |
| 975 | |
| 976 | if (!dc) |
| 977 | return 0; |
| 978 | |
| 979 | return dc->w.ArcDirection; |
| 980 | } |
| 981 | |
| 982 | |
| 983 | /*********************************************************************** |
| 984 | * SetArcDirection16 (GDI.525) |
| 985 | */ |
| 986 | INT16 WINAPI SetArcDirection16( HDC16 hdc, INT16 nDirection ) |
| 987 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 988 | return SetArcDirection( (HDC)hdc, (INT)nDirection ); |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 989 | } |
| 990 | |
| 991 | |
| 992 | /*********************************************************************** |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame^] | 993 | * SetArcDirection (GDI32.302) |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 994 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 995 | INT WINAPI SetArcDirection( HDC hdc, INT nDirection ) |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 996 | { |
| 997 | DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 998 | INT nOldDirection; |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 999 | |
| 1000 | if (!dc) |
| 1001 | return 0; |
| 1002 | |
| 1003 | if (nDirection!=AD_COUNTERCLOCKWISE && nDirection!=AD_CLOCKWISE) |
| 1004 | { |
| 1005 | SetLastError(ERROR_INVALID_PARAMETER); |
| 1006 | return 0; |
| 1007 | } |
| 1008 | |
| 1009 | nOldDirection = dc->w.ArcDirection; |
| 1010 | dc->w.ArcDirection = nDirection; |
| 1011 | |
| 1012 | return nOldDirection; |
| 1013 | } |
| 1014 | |
| 1015 | |
| 1016 | /*********************************************************************** |
Alexandre Julliard | 17216f5 | 1997-10-12 16:30:17 +0000 | [diff] [blame] | 1017 | * GetWorldTransform (GDI32.244) |
| 1018 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1019 | BOOL WINAPI GetWorldTransform( HDC hdc, LPXFORM xform ) |
Alexandre Julliard | 17216f5 | 1997-10-12 16:30:17 +0000 | [diff] [blame] | 1020 | { |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 1021 | DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); |
| 1022 | |
| 1023 | if (!dc) |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 1024 | return FALSE; |
| 1025 | if (!xform) |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 1026 | return FALSE; |
| 1027 | |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1028 | *xform = dc->w.xformWorld2Wnd; |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 1029 | |
| 1030 | return TRUE; |
| 1031 | } |
| 1032 | |
| 1033 | |
| 1034 | /*********************************************************************** |
| 1035 | * SetWorldTransform (GDI32.346) |
| 1036 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1037 | BOOL WINAPI SetWorldTransform( HDC hdc, const XFORM *xform ) |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 1038 | { |
| 1039 | DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); |
| 1040 | |
| 1041 | if (!dc) |
| 1042 | { |
| 1043 | SetLastError( ERROR_INVALID_HANDLE ); |
| 1044 | return FALSE; |
| 1045 | } |
| 1046 | |
| 1047 | if (!xform) |
| 1048 | return FALSE; |
| 1049 | |
| 1050 | /* Check that graphics mode is GM_ADVANCED */ |
| 1051 | if (dc->w.GraphicsMode!=GM_ADVANCED) |
| 1052 | return FALSE; |
| 1053 | |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1054 | dc->w.xformWorld2Wnd = *xform; |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 1055 | |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1056 | DC_UpdateXforms( dc ); |
| 1057 | |
| 1058 | return TRUE; |
| 1059 | } |
| 1060 | |
| 1061 | |
| 1062 | /**************************************************************************** |
| 1063 | * ModifyWorldTransform [GDI32.253] |
| 1064 | * Modifies the world transformation for a device context. |
| 1065 | * |
| 1066 | * PARAMS |
| 1067 | * hdc [I] Handle to device context |
| 1068 | * xform [I] XFORM structure that will be used to modify the world |
| 1069 | * transformation |
| 1070 | * iMode [I] Specifies in what way to modify the world transformation |
| 1071 | * Possible values: |
| 1072 | * MWT_IDENTITY |
| 1073 | * Resets the world transformation to the identity matrix. |
| 1074 | * The parameter xform is ignored. |
| 1075 | * MWT_LEFTMULTIPLY |
| 1076 | * Multiplies xform into the world transformation matrix from |
| 1077 | * the left. |
| 1078 | * MWT_RIGHTMULTIPLY |
| 1079 | * Multiplies xform into the world transformation matrix from |
| 1080 | * the right. |
| 1081 | * |
| 1082 | * RETURNS STD |
| 1083 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1084 | BOOL WINAPI ModifyWorldTransform( HDC hdc, const XFORM *xform, |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1085 | DWORD iMode ) |
| 1086 | { |
| 1087 | DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); |
| 1088 | |
| 1089 | /* Check for illegal parameters */ |
| 1090 | if (!dc) |
| 1091 | { |
| 1092 | SetLastError( ERROR_INVALID_HANDLE ); |
| 1093 | return FALSE; |
| 1094 | } |
| 1095 | if (!xform) |
| 1096 | return FALSE; |
| 1097 | |
| 1098 | /* Check that graphics mode is GM_ADVANCED */ |
| 1099 | if (dc->w.GraphicsMode!=GM_ADVANCED) |
| 1100 | return FALSE; |
| 1101 | |
| 1102 | switch (iMode) |
| 1103 | { |
| 1104 | case MWT_IDENTITY: |
| 1105 | dc->w.xformWorld2Wnd.eM11 = 1.0f; |
| 1106 | dc->w.xformWorld2Wnd.eM12 = 0.0f; |
| 1107 | dc->w.xformWorld2Wnd.eM21 = 0.0f; |
| 1108 | dc->w.xformWorld2Wnd.eM22 = 1.0f; |
| 1109 | dc->w.xformWorld2Wnd.eDx = 0.0f; |
| 1110 | dc->w.xformWorld2Wnd.eDy = 0.0f; |
| 1111 | break; |
| 1112 | case MWT_LEFTMULTIPLY: |
| 1113 | CombineTransform( &dc->w.xformWorld2Wnd, xform, |
| 1114 | &dc->w.xformWorld2Wnd ); |
| 1115 | break; |
| 1116 | case MWT_RIGHTMULTIPLY: |
| 1117 | CombineTransform( &dc->w.xformWorld2Wnd, &dc->w.xformWorld2Wnd, |
| 1118 | xform ); |
| 1119 | break; |
| 1120 | default: |
| 1121 | return FALSE; |
| 1122 | } |
| 1123 | |
| 1124 | DC_UpdateXforms( dc ); |
| 1125 | |
| 1126 | return TRUE; |
| 1127 | } |
| 1128 | |
| 1129 | |
| 1130 | /**************************************************************************** |
| 1131 | * CombineTransform [GDI32.20] |
| 1132 | * Combines two transformation matrices. |
| 1133 | * |
| 1134 | * PARAMS |
| 1135 | * xformResult [O] Stores the result of combining the two matrices |
| 1136 | * xform1 [I] Specifies the first matrix to apply |
| 1137 | * xform2 [I] Specifies the second matrix to apply |
| 1138 | * |
| 1139 | * REMARKS |
| 1140 | * The same matrix can be passed in for more than one of the parameters. |
| 1141 | * |
| 1142 | * RETURNS STD |
| 1143 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1144 | BOOL WINAPI CombineTransform( LPXFORM xformResult, const XFORM *xform1, |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1145 | const XFORM *xform2 ) |
| 1146 | { |
| 1147 | XFORM xformTemp; |
| 1148 | |
| 1149 | /* Check for illegal parameters */ |
| 1150 | if (!xformResult || !xform1 || !xform2) |
| 1151 | return FALSE; |
| 1152 | |
| 1153 | /* Create the result in a temporary XFORM, since xformResult may be |
| 1154 | * equal to xform1 or xform2 */ |
| 1155 | xformTemp.eM11 = xform1->eM11 * xform2->eM11 + |
| 1156 | xform1->eM12 * xform2->eM21; |
| 1157 | xformTemp.eM12 = xform1->eM11 * xform2->eM12 + |
| 1158 | xform1->eM12 * xform2->eM22; |
| 1159 | xformTemp.eM21 = xform1->eM21 * xform2->eM11 + |
| 1160 | xform1->eM22 * xform2->eM21; |
| 1161 | xformTemp.eM22 = xform1->eM21 * xform2->eM12 + |
| 1162 | xform1->eM22 * xform2->eM22; |
| 1163 | xformTemp.eDx = xform1->eDx * xform2->eM11 + |
| 1164 | xform1->eDy * xform2->eM21 + |
| 1165 | xform2->eDx; |
| 1166 | xformTemp.eDy = xform1->eDx * xform2->eM12 + |
| 1167 | xform1->eDy * xform2->eM22 + |
| 1168 | xform2->eDy; |
| 1169 | |
| 1170 | /* Copy the result to xformResult */ |
| 1171 | *xformResult = xformTemp; |
| 1172 | |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 1173 | return TRUE; |
Alexandre Julliard | 17216f5 | 1997-10-12 16:30:17 +0000 | [diff] [blame] | 1174 | } |
| 1175 | |
| 1176 | |
| 1177 | /*********************************************************************** |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1178 | * SetDCHook (GDI.190) |
| 1179 | */ |
Ulrich Weigand | f86aab8 | 1999-09-20 18:47:14 +0000 | [diff] [blame] | 1180 | /* ### start build ### */ |
| 1181 | extern WORD CALLBACK GDI_CallTo16_word_wwll(FARPROC16,WORD,WORD,LONG,LONG); |
| 1182 | /* ### stop build ### */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 1183 | BOOL16 WINAPI SetDCHook( HDC16 hdc, FARPROC16 hookProc, DWORD dwHookData ) |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1184 | { |
Alexandre Julliard | bf9130a | 1996-10-13 17:45:47 +0000 | [diff] [blame] | 1185 | DC *dc = (DC *)GDI_GetObjPtr( hdc, DC_MAGIC ); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1186 | if (!dc) return FALSE; |
Ulrich Weigand | f86aab8 | 1999-09-20 18:47:14 +0000 | [diff] [blame] | 1187 | |
| 1188 | /* |
| 1189 | * Note: We store the original SEGPTR 'hookProc' as we need to be |
| 1190 | * able to return it verbatim in GetDCHook, |
| 1191 | * |
| 1192 | * On the other hand, we still call THUNK_Alloc and store the |
| 1193 | * 32-bit thunk into another DC member, because THUNK_Alloc |
| 1194 | * recognizes the (typical) case that the 'hookProc' is indeed |
| 1195 | * the 16-bit API entry point of a built-in routine (e.g. DCHook16) |
| 1196 | * |
| 1197 | * We could perform that test every time the hook is about to |
| 1198 | * be called (or else we could live with the 32->16->32 detour), |
| 1199 | * but this way is the most efficient ... |
| 1200 | */ |
| 1201 | |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1202 | dc->hookProc = hookProc; |
| 1203 | dc->dwHookData = dwHookData; |
Ulrich Weigand | f86aab8 | 1999-09-20 18:47:14 +0000 | [diff] [blame] | 1204 | |
| 1205 | THUNK_Free( (FARPROC)dc->hookThunk ); |
| 1206 | dc->hookThunk = (DCHOOKPROC) |
| 1207 | THUNK_Alloc( hookProc, (RELAY)GDI_CallTo16_word_wwll ); |
| 1208 | |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 1209 | GDI_HEAP_UNLOCK( hdc ); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1210 | return TRUE; |
| 1211 | } |
| 1212 | |
| 1213 | |
| 1214 | /*********************************************************************** |
| 1215 | * GetDCHook (GDI.191) |
| 1216 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 1217 | DWORD WINAPI GetDCHook( HDC16 hdc, FARPROC16 *phookProc ) |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1218 | { |
Alexandre Julliard | bf9130a | 1996-10-13 17:45:47 +0000 | [diff] [blame] | 1219 | DC *dc = (DC *)GDI_GetObjPtr( hdc, DC_MAGIC ); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1220 | if (!dc) return 0; |
| 1221 | *phookProc = dc->hookProc; |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 1222 | GDI_HEAP_UNLOCK( hdc ); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1223 | return dc->dwHookData; |
| 1224 | } |
| 1225 | |
| 1226 | |
| 1227 | /*********************************************************************** |
| 1228 | * SetHookFlags (GDI.192) |
| 1229 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1230 | WORD WINAPI SetHookFlags16(HDC16 hDC, WORD flags) |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1231 | { |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 1232 | DC* dc = (DC*)GDI_GetObjPtr( hDC, DC_MAGIC ); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1233 | |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 1234 | if( dc ) |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1235 | { |
| 1236 | WORD wRet = dc->w.flags & DC_DIRTY; |
| 1237 | |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 1238 | /* "Undocumented Windows" info is slightly confusing. |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1239 | */ |
| 1240 | |
Alexandre Julliard | 1565709 | 1999-05-23 10:25:25 +0000 | [diff] [blame] | 1241 | TRACE("hDC %04x, flags %04x\n",hDC,flags); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1242 | |
| 1243 | if( flags & DCHF_INVALIDATEVISRGN ) |
| 1244 | dc->w.flags |= DC_DIRTY; |
| 1245 | else if( flags & DCHF_VALIDATEVISRGN || !flags ) |
| 1246 | dc->w.flags &= ~DC_DIRTY; |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 1247 | GDI_HEAP_UNLOCK( hDC ); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1248 | return wRet; |
| 1249 | } |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 1250 | return 0; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 1251 | } |
| 1252 | |
Alexandre Julliard | 85ed45e | 1998-08-22 19:03:56 +0000 | [diff] [blame] | 1253 | /*********************************************************************** |
| 1254 | * SetICMMode (GDI32.318) |
| 1255 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1256 | INT WINAPI SetICMMode(HDC hdc, INT iEnableICM) |
Alexandre Julliard | 85ed45e | 1998-08-22 19:03:56 +0000 | [diff] [blame] | 1257 | { |
| 1258 | /*FIXME Asuming that ICM is always off, and cannot be turned on */ |
| 1259 | if (iEnableICM == ICM_OFF) return ICM_OFF; |
| 1260 | if (iEnableICM == ICM_ON) return 0; |
| 1261 | if (iEnableICM == ICM_QUERY) return ICM_OFF; |
| 1262 | return 0; |
| 1263 | } |
| 1264 | |
| 1265 | |
| 1266 | /*********************************************************************** |
| 1267 | * GetColorSpace (GDI32.165) |
| 1268 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1269 | HCOLORSPACE WINAPI GetColorSpace(HDC hdc) |
Alexandre Julliard | 85ed45e | 1998-08-22 19:03:56 +0000 | [diff] [blame] | 1270 | { |
| 1271 | /*FIXME Need to to whatever GetColorSpace actually does */ |
| 1272 | return 0; |
| 1273 | } |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 1274 | |
| 1275 | /*********************************************************************** |
Gerard Patel | 82f37be | 2000-01-15 22:11:21 +0000 | [diff] [blame] | 1276 | * CreateColorSpaceA (GDI32.???) |
| 1277 | */ |
| 1278 | HCOLORSPACE WINAPI CreateColorSpaceA( LPLOGCOLORSPACEA lpLogColorSpace ) |
| 1279 | { |
| 1280 | FIXME( "stub\n" ); |
| 1281 | return 0; |
| 1282 | } |
| 1283 | |
| 1284 | /*********************************************************************** |
| 1285 | * CreateColorSpaceW (GDI32.???) |
| 1286 | */ |
| 1287 | HCOLORSPACE WINAPI CreateColorSpaceW( LPLOGCOLORSPACEW lpLogColorSpace ) |
| 1288 | { |
| 1289 | FIXME( "stub\n" ); |
| 1290 | return 0; |
| 1291 | } |
| 1292 | |
| 1293 | /*********************************************************************** |
| 1294 | * DeleteColorSpace (GDI32.???) |
| 1295 | */ |
| 1296 | BOOL WINAPI DeleteColorSpace( HCOLORSPACE hColorSpace ) |
| 1297 | { |
| 1298 | FIXME( "stub\n" ); |
| 1299 | |
Alexandre Julliard | 07e4213 | 2000-03-19 21:19:21 +0000 | [diff] [blame] | 1300 | return TRUE; |
Gerard Patel | 82f37be | 2000-01-15 22:11:21 +0000 | [diff] [blame] | 1301 | } |
| 1302 | |
| 1303 | /*********************************************************************** |
| 1304 | * SetColorSpace (GDI32.???) |
| 1305 | */ |
| 1306 | HCOLORSPACE WINAPI SetColorSpace( HDC hDC, HCOLORSPACE hColorSpace ) |
| 1307 | { |
| 1308 | FIXME( "stub\n" ); |
| 1309 | |
| 1310 | return hColorSpace; |
| 1311 | } |
| 1312 | |
| 1313 | /*********************************************************************** |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 1314 | * GetBoundsRect16 (GDI.194) |
| 1315 | */ |
| 1316 | UINT16 WINAPI GetBoundsRect16(HDC16 hdc, LPRECT16 rect, UINT16 flags) |
| 1317 | { |
Ulrich Weigand | e62cbca | 1998-11-26 15:06:47 +0000 | [diff] [blame] | 1318 | return DCB_RESET | DCB_DISABLE; /* bounding rectangle always empty and disabled*/ |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 1319 | } |
| 1320 | |
Ulrich Weigand | d466366 | 1998-10-11 18:47:02 +0000 | [diff] [blame] | 1321 | /*********************************************************************** |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame^] | 1322 | * GetBoundsRect (GDI32.147) |
Paul Quinn | 1beaae5 | 1998-12-15 15:38:36 +0000 | [diff] [blame] | 1323 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1324 | UINT WINAPI GetBoundsRect(HDC hdc, LPRECT rect, UINT flags) |
Paul Quinn | 1beaae5 | 1998-12-15 15:38:36 +0000 | [diff] [blame] | 1325 | { |
Alexandre Julliard | 1565709 | 1999-05-23 10:25:25 +0000 | [diff] [blame] | 1326 | FIXME("(): stub\n"); |
Paul Quinn | 1beaae5 | 1998-12-15 15:38:36 +0000 | [diff] [blame] | 1327 | return DCB_RESET; /* bounding rectangle always empty */ |
| 1328 | } |
| 1329 | |
| 1330 | /*********************************************************************** |
Ulrich Weigand | d466366 | 1998-10-11 18:47:02 +0000 | [diff] [blame] | 1331 | * SetBoundsRect16 (GDI.193) |
| 1332 | */ |
François Gouget | 241c730 | 1998-10-28 10:47:09 +0000 | [diff] [blame] | 1333 | UINT16 WINAPI SetBoundsRect16(HDC16 hdc, const RECT16* rect, UINT16 flags) |
Ulrich Weigand | d466366 | 1998-10-11 18:47:02 +0000 | [diff] [blame] | 1334 | { |
Ulrich Weigand | e62cbca | 1998-11-26 15:06:47 +0000 | [diff] [blame] | 1335 | if ( (flags & DCB_ACCUMULATE) || (flags & DCB_ENABLE) ) |
Alexandre Julliard | 1565709 | 1999-05-23 10:25:25 +0000 | [diff] [blame] | 1336 | FIXME("(%04x, %p, %04x): stub\n", hdc, rect, flags ); |
Ulrich Weigand | e62cbca | 1998-11-26 15:06:47 +0000 | [diff] [blame] | 1337 | |
| 1338 | return DCB_RESET | DCB_DISABLE; /* bounding rectangle always empty and disabled*/ |
Ulrich Weigand | d466366 | 1998-10-11 18:47:02 +0000 | [diff] [blame] | 1339 | } |
| 1340 | |
Alexandre Julliard | 0c0e3be | 1998-12-10 15:49:22 +0000 | [diff] [blame] | 1341 | /*********************************************************************** |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame^] | 1342 | * SetBoundsRect (GDI32.307) |
Alexandre Julliard | 0c0e3be | 1998-12-10 15:49:22 +0000 | [diff] [blame] | 1343 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1344 | UINT WINAPI SetBoundsRect(HDC hdc, const RECT* rect, UINT flags) |
Alexandre Julliard | 0c0e3be | 1998-12-10 15:49:22 +0000 | [diff] [blame] | 1345 | { |
Alexandre Julliard | 1565709 | 1999-05-23 10:25:25 +0000 | [diff] [blame] | 1346 | FIXME("(): stub\n"); |
Alexandre Julliard | 0c0e3be | 1998-12-10 15:49:22 +0000 | [diff] [blame] | 1347 | return DCB_DISABLE; /* bounding rectangle always empty */ |
| 1348 | } |
| 1349 | |
Alexandre Julliard | 8da12c4 | 1999-01-17 16:55:11 +0000 | [diff] [blame] | 1350 | /*********************************************************************** |
| 1351 | * Death (GDI.121) |
| 1352 | * |
| 1353 | * Disables GDI, switches back to text mode. |
| 1354 | * We don't have to do anything here, |
| 1355 | * just let console support handle everything |
| 1356 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1357 | void WINAPI Death16(HDC16 hDC) |
Alexandre Julliard | 8da12c4 | 1999-01-17 16:55:11 +0000 | [diff] [blame] | 1358 | { |
Alexandre Julliard | 1565709 | 1999-05-23 10:25:25 +0000 | [diff] [blame] | 1359 | MESSAGE("Death(%04x) called. Application enters text mode...\n", hDC); |
Alexandre Julliard | 8da12c4 | 1999-01-17 16:55:11 +0000 | [diff] [blame] | 1360 | } |
| 1361 | |
| 1362 | /*********************************************************************** |
| 1363 | * Resurrection (GDI.122) |
| 1364 | * |
| 1365 | * Restores GDI functionality |
| 1366 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1367 | void WINAPI Resurrection16(HDC16 hDC, |
Alexandre Julliard | 8da12c4 | 1999-01-17 16:55:11 +0000 | [diff] [blame] | 1368 | WORD w1, WORD w2, WORD w3, WORD w4, WORD w5, WORD w6) |
| 1369 | { |
Alexandre Julliard | 1565709 | 1999-05-23 10:25:25 +0000 | [diff] [blame] | 1370 | MESSAGE("Resurrection(%04x, %04x, %04x, %04x, %04x, %04x, %04x) called. Application left text mode.\n", hDC, w1, w2, w3, w4, w5, w6); |
Alexandre Julliard | 8da12c4 | 1999-01-17 16:55:11 +0000 | [diff] [blame] | 1371 | } |
Huw D M Davies | f64e0d7 | 1999-11-21 00:49:50 +0000 | [diff] [blame] | 1372 | |
| 1373 | /*********************************************************************** |
| 1374 | * GetLayout (GDI32.321) |
| 1375 | * |
| 1376 | * Gets left->right or right->left text layout flags of a dc. |
| 1377 | * win98 just returns 0 and sets ERROR_CALL_NOT_IMPLEMENTED so we do the same |
| 1378 | * |
| 1379 | */ |
| 1380 | DWORD WINAPI GetLayout(HDC hdc) |
| 1381 | { |
| 1382 | FIXME("(%08x): stub\n", hdc); |
| 1383 | SetLastError(ERROR_CALL_NOT_IMPLEMENTED); |
| 1384 | return 0; |
| 1385 | } |
| 1386 | |
| 1387 | /*********************************************************************** |
| 1388 | * SetLayout (GDI32.450) |
| 1389 | * |
| 1390 | * Sets left->right or right->left text layout flags of a dc. |
| 1391 | * win98 just returns 0 and sets ERROR_CALL_NOT_IMPLEMENTED so we do the same |
| 1392 | * |
| 1393 | */ |
| 1394 | DWORD WINAPI SetLayout(HDC hdc, DWORD layout) |
| 1395 | { |
| 1396 | FIXME("(%08x,%08lx): stub\n", hdc, layout); |
| 1397 | SetLastError(ERROR_CALL_NOT_IMPLEMENTED); |
| 1398 | return 0; |
| 1399 | } |