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