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