blob: 163ecd7e4fe75887fd5dcd22e27d80e3dcc10150 [file] [log] [blame]
Alexandre Julliard401710d1993-09-04 10:09:32 +00001/*
2 * GDI Device Context functions
3 *
4 * Copyright 1993 Alexandre Julliard
Alexandre Julliard234bc241994-12-10 13:02:28 +00005 *
Alexandre Julliard7cbe6571995-01-09 18:21:16 +00006 */
7
Patrik Stridvalld96e1f11999-07-04 13:31:03 +00008#include "config.h"
9
Alexandre Julliard401710d1993-09-04 10:09:32 +000010#include <stdlib.h>
Alexandre Julliard8d24ae61994-04-05 21:42:43 +000011#include <string.h>
Alexandre Julliarda845b881998-06-01 10:44:35 +000012#include "dc.h"
Alexandre Julliard401710d1993-09-04 10:09:32 +000013#include "gdi.h"
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +000014#include "heap.h"
Alexandre Julliard15657091999-05-23 10:25:25 +000015#include "debugtools.h"
Alexandre Julliard234bc241994-12-10 13:02:28 +000016#include "font.h"
Huw D M Davies304d9a41999-09-13 15:15:45 +000017#include "callback.h"
Alexandre Julliard60ce85c1998-02-01 18:33:27 +000018#include "winerror.h"
Jeremy Whited3e22d92000-02-10 19:03:02 +000019#include "windef.h"
20#include "wingdi.h"
Patrik Stridvall8d8703c1999-02-04 14:05:38 +000021#include "wine/winuser16.h"
Alexandre Julliard401710d1993-09-04 10:09:32 +000022
Alexandre Julliard07e42132000-03-19 21:19:21 +000023DEFAULT_DEBUG_CHANNEL(dc);
Patrik Stridvallb4b9fae1999-04-19 14:56:29 +000024
Alexandre Julliard401710d1993-09-04 10:09:32 +000025/***********************************************************************
Alexandre Julliard44ed71f1997-12-21 19:17:50 +000026 * DC_Init_DC_INFO
27 *
28 * Fill the WIN_DC_INFO structure.
29 */
30static void DC_Init_DC_INFO( WIN_DC_INFO *win_dc_info )
31{
Alexandre Julliarddadf78f1998-05-17 17:13:43 +000032 win_dc_info->flags = 0;
33 win_dc_info->devCaps = NULL;
34 win_dc_info->hClipRgn = 0;
35 win_dc_info->hVisRgn = 0;
36 win_dc_info->hGCClipRgn = 0;
37 win_dc_info->hPen = STOCK_BLACK_PEN;
38 win_dc_info->hBrush = STOCK_WHITE_BRUSH;
39 win_dc_info->hFont = STOCK_SYSTEM_FONT;
40 win_dc_info->hBitmap = 0;
Alexandre Julliarddadf78f1998-05-17 17:13:43 +000041 win_dc_info->hDevice = 0;
42 win_dc_info->hPalette = STOCK_DEFAULT_PALETTE;
43 win_dc_info->ROPmode = R2_COPYPEN;
44 win_dc_info->polyFillMode = ALTERNATE;
45 win_dc_info->stretchBltMode = BLACKONWHITE;
46 win_dc_info->relAbsMode = ABSOLUTE;
47 win_dc_info->backgroundMode = OPAQUE;
48 win_dc_info->backgroundColor = RGB( 255, 255, 255 );
49 win_dc_info->textColor = RGB( 0, 0, 0 );
Alexandre Julliarddadf78f1998-05-17 17:13:43 +000050 win_dc_info->brushOrgX = 0;
51 win_dc_info->brushOrgY = 0;
52 win_dc_info->textAlign = TA_LEFT | TA_TOP | TA_NOUPDATECP;
53 win_dc_info->charExtra = 0;
54 win_dc_info->breakTotalExtra = 0;
55 win_dc_info->breakCount = 0;
56 win_dc_info->breakExtra = 0;
57 win_dc_info->breakRem = 0;
58 win_dc_info->bitsPerPixel = 1;
59 win_dc_info->MapMode = MM_TEXT;
60 win_dc_info->GraphicsMode = GM_COMPATIBLE;
61 win_dc_info->DCOrgX = 0;
62 win_dc_info->DCOrgY = 0;
Huw D M Davies304d9a41999-09-13 15:15:45 +000063 win_dc_info->pAbortProc = NULL;
Alexandre Julliarddadf78f1998-05-17 17:13:43 +000064 win_dc_info->CursPosX = 0;
65 win_dc_info->CursPosY = 0;
66 win_dc_info->ArcDirection = AD_COUNTERCLOCKWISE;
67 win_dc_info->xformWorld2Wnd.eM11 = 1.0f;
68 win_dc_info->xformWorld2Wnd.eM12 = 0.0f;
69 win_dc_info->xformWorld2Wnd.eM21 = 0.0f;
70 win_dc_info->xformWorld2Wnd.eM22 = 1.0f;
71 win_dc_info->xformWorld2Wnd.eDx = 0.0f;
72 win_dc_info->xformWorld2Wnd.eDy = 0.0f;
73 win_dc_info->xformWorld2Vport = win_dc_info->xformWorld2Wnd;
74 win_dc_info->xformVport2World = win_dc_info->xformWorld2Wnd;
75 win_dc_info->vport2WorldValid = TRUE;
Alexandre Julliard44ed71f1997-12-21 19:17:50 +000076
77 PATH_InitGdiPath(&win_dc_info->path);
78}
79
80
81/***********************************************************************
Alexandre Julliardbf9130a1996-10-13 17:45:47 +000082 * DC_AllocDC
83 */
84DC *DC_AllocDC( const DC_FUNCTIONS *funcs )
85{
86 HDC16 hdc;
87 DC *dc;
88
89 if (!(hdc = GDI_AllocObject( sizeof(DC), DC_MAGIC ))) return NULL;
Alexandre Julliard670cdc41997-08-24 16:00:30 +000090 dc = (DC *) GDI_HEAP_LOCK( hdc );
Alexandre Julliardbf9130a1996-10-13 17:45:47 +000091
92 dc->hSelf = hdc;
93 dc->funcs = funcs;
94 dc->physDev = NULL;
95 dc->saveLevel = 0;
96 dc->dwHookData = 0L;
97 dc->hookProc = NULL;
Ulrich Weigandf86aab81999-09-20 18:47:14 +000098 dc->hookThunk = NULL;
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +000099 dc->wndOrgX = 0;
100 dc->wndOrgY = 0;
101 dc->wndExtX = 1;
102 dc->wndExtY = 1;
103 dc->vportOrgX = 0;
104 dc->vportOrgY = 0;
105 dc->vportExtX = 1;
106 dc->vportExtY = 1;
Alexandre Julliardbf9130a1996-10-13 17:45:47 +0000107
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000108 DC_Init_DC_INFO( &dc->w );
109
Alexandre Julliardbf9130a1996-10-13 17:45:47 +0000110 return dc;
111}
112
113
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000114
Alexandre Julliardbf9130a1996-10-13 17:45:47 +0000115/***********************************************************************
116 * DC_GetDCPtr
117 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000118DC *DC_GetDCPtr( HDC hdc )
Alexandre Julliardbf9130a1996-10-13 17:45:47 +0000119{
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000120 GDIOBJHDR *ptr = (GDIOBJHDR *)GDI_HEAP_LOCK( hdc );
Alexandre Julliard9ea19e51997-01-01 17:29:55 +0000121 if (!ptr) return NULL;
Huw D M Davies7603dea1999-04-25 09:24:23 +0000122 if ((ptr->wMagic == DC_MAGIC) || (ptr->wMagic == METAFILE_DC_MAGIC) ||
123 (ptr->wMagic == ENHMETAFILE_DC_MAGIC))
Alexandre Julliardbf9130a1996-10-13 17:45:47 +0000124 return (DC *)ptr;
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000125 GDI_HEAP_UNLOCK( hdc );
Alexandre Julliardbf9130a1996-10-13 17:45:47 +0000126 return NULL;
127}
128
129
130/***********************************************************************
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000131 * DC_InitDC
Alexandre Julliard401710d1993-09-04 10:09:32 +0000132 *
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000133 * Setup device-specific DC values for a newly created DC.
Alexandre Julliard401710d1993-09-04 10:09:32 +0000134 */
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000135void DC_InitDC( DC* dc )
Alexandre Julliard401710d1993-09-04 10:09:32 +0000136{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000137 RealizeDefaultPalette16( dc->hSelf );
138 SetTextColor( dc->hSelf, dc->w.textColor );
139 SetBkColor( dc->hSelf, dc->w.backgroundColor );
140 SelectObject( dc->hSelf, dc->w.hPen );
141 SelectObject( dc->hSelf, dc->w.hBrush );
142 SelectObject( dc->hSelf, dc->w.hFont );
Alexandre Julliard3a405ba1994-10-30 16:25:19 +0000143 CLIPPING_UpdateGCRegion( dc );
Alexandre Julliard401710d1993-09-04 10:09:32 +0000144}
145
146
147/***********************************************************************
Alexandre Julliarddadf78f1998-05-17 17:13:43 +0000148 * DC_InvertXform
149 *
150 * Computes the inverse of the transformation xformSrc and stores it to
151 * xformDest. Returns TRUE if successful or FALSE if the xformSrc matrix
152 * is singular.
153 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000154static BOOL DC_InvertXform( const XFORM *xformSrc, XFORM *xformDest )
Alexandre Julliarddadf78f1998-05-17 17:13:43 +0000155{
156 FLOAT determinant;
157
158 determinant = xformSrc->eM11*xformSrc->eM22 -
159 xformSrc->eM12*xformSrc->eM21;
160 if (determinant > -1e-12 && determinant < 1e-12)
161 return FALSE;
162
163 xformDest->eM11 = xformSrc->eM22 / determinant;
164 xformDest->eM12 = -xformSrc->eM12 / determinant;
165 xformDest->eM21 = -xformSrc->eM21 / determinant;
166 xformDest->eM22 = xformSrc->eM11 / determinant;
167 xformDest->eDx = -xformSrc->eDx * xformDest->eM11 -
168 xformSrc->eDy * xformDest->eM21;
169 xformDest->eDy = -xformSrc->eDx * xformDest->eM12 -
170 xformSrc->eDy * xformDest->eM22;
171
172 return TRUE;
173}
174
175
176/***********************************************************************
177 * DC_UpdateXforms
178 *
179 * Updates the xformWorld2Vport, xformVport2World and vport2WorldValid
180 * fields of the specified DC by creating a transformation that
181 * represents the current mapping mode and combining it with the DC's
182 * world transform. This function should be called whenever the
183 * parameters associated with the mapping mode (window and viewport
184 * extents and origins) or the world transform change.
185 */
186void DC_UpdateXforms( DC *dc )
187{
188 XFORM xformWnd2Vport;
189 FLOAT scaleX, scaleY;
190
191 /* Construct a transformation to do the window-to-viewport conversion */
192 scaleX = (FLOAT)dc->vportExtX / (FLOAT)dc->wndExtX;
193 scaleY = (FLOAT)dc->vportExtY / (FLOAT)dc->wndExtY;
194 xformWnd2Vport.eM11 = scaleX;
195 xformWnd2Vport.eM12 = 0.0;
196 xformWnd2Vport.eM21 = 0.0;
197 xformWnd2Vport.eM22 = scaleY;
198 xformWnd2Vport.eDx = (FLOAT)dc->vportOrgX -
199 scaleX * (FLOAT)dc->wndOrgX;
200 xformWnd2Vport.eDy = (FLOAT)dc->vportOrgY -
201 scaleY * (FLOAT)dc->wndOrgY;
202
203 /* Combine with the world transformation */
204 CombineTransform( &dc->w.xformWorld2Vport, &dc->w.xformWorld2Wnd,
205 &xformWnd2Vport );
206
207 /* Create inverse of world-to-viewport transformation */
208 dc->w.vport2WorldValid = DC_InvertXform( &dc->w.xformWorld2Vport,
209 &dc->w.xformVport2World );
210}
211
212
213/***********************************************************************
Alexandre Julliard401710d1993-09-04 10:09:32 +0000214 * GetDCState (GDI.179)
215 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000216HDC16 WINAPI GetDCState16( HDC16 hdc )
Alexandre Julliard401710d1993-09-04 10:09:32 +0000217{
218 DC * newdc, * dc;
Alexandre Julliardbf9130a1996-10-13 17:45:47 +0000219 HGDIOBJ16 handle;
Alexandre Julliard401710d1993-09-04 10:09:32 +0000220
221 if (!(dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ))) return 0;
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000222 if (!(handle = GDI_AllocObject( sizeof(DC), DC_MAGIC )))
223 {
224 GDI_HEAP_UNLOCK( hdc );
225 return 0;
226 }
227 newdc = (DC *) GDI_HEAP_LOCK( handle );
Alexandre Julliard401710d1993-09-04 10:09:32 +0000228
Alexandre Julliard15657091999-05-23 10:25:25 +0000229 TRACE("(%04x): returning %04x\n", hdc, handle );
Alexandre Julliard401710d1993-09-04 10:09:32 +0000230
Alexandre Julliarddadf78f1998-05-17 17:13:43 +0000231 newdc->w.flags = dc->w.flags | DC_SAVED;
232 newdc->w.devCaps = dc->w.devCaps;
233 newdc->w.hPen = dc->w.hPen;
234 newdc->w.hBrush = dc->w.hBrush;
235 newdc->w.hFont = dc->w.hFont;
236 newdc->w.hBitmap = dc->w.hBitmap;
Alexandre Julliarddadf78f1998-05-17 17:13:43 +0000237 newdc->w.hDevice = dc->w.hDevice;
238 newdc->w.hPalette = dc->w.hPalette;
Ulrich Weigand27bb3621998-10-14 18:06:44 +0000239 newdc->w.totalExtent = dc->w.totalExtent;
Alexandre Julliarddadf78f1998-05-17 17:13:43 +0000240 newdc->w.bitsPerPixel = dc->w.bitsPerPixel;
241 newdc->w.ROPmode = dc->w.ROPmode;
242 newdc->w.polyFillMode = dc->w.polyFillMode;
243 newdc->w.stretchBltMode = dc->w.stretchBltMode;
244 newdc->w.relAbsMode = dc->w.relAbsMode;
245 newdc->w.backgroundMode = dc->w.backgroundMode;
246 newdc->w.backgroundColor = dc->w.backgroundColor;
247 newdc->w.textColor = dc->w.textColor;
Alexandre Julliarddadf78f1998-05-17 17:13:43 +0000248 newdc->w.brushOrgX = dc->w.brushOrgX;
249 newdc->w.brushOrgY = dc->w.brushOrgY;
250 newdc->w.textAlign = dc->w.textAlign;
251 newdc->w.charExtra = dc->w.charExtra;
252 newdc->w.breakTotalExtra = dc->w.breakTotalExtra;
253 newdc->w.breakCount = dc->w.breakCount;
254 newdc->w.breakExtra = dc->w.breakExtra;
255 newdc->w.breakRem = dc->w.breakRem;
256 newdc->w.MapMode = dc->w.MapMode;
257 newdc->w.GraphicsMode = dc->w.GraphicsMode;
Ulrich Weigandd4663661998-10-11 18:47:02 +0000258#if 0
259 /* Apparently, the DC origin is not changed by [GS]etDCState */
Alexandre Julliarddadf78f1998-05-17 17:13:43 +0000260 newdc->w.DCOrgX = dc->w.DCOrgX;
261 newdc->w.DCOrgY = dc->w.DCOrgY;
Ulrich Weigandd4663661998-10-11 18:47:02 +0000262#endif
Alexandre Julliarddadf78f1998-05-17 17:13:43 +0000263 newdc->w.CursPosX = dc->w.CursPosX;
264 newdc->w.CursPosY = dc->w.CursPosY;
265 newdc->w.ArcDirection = dc->w.ArcDirection;
266 newdc->w.xformWorld2Wnd = dc->w.xformWorld2Wnd;
267 newdc->w.xformWorld2Vport = dc->w.xformWorld2Vport;
268 newdc->w.xformVport2World = dc->w.xformVport2World;
269 newdc->w.vport2WorldValid = dc->w.vport2WorldValid;
270 newdc->wndOrgX = dc->wndOrgX;
271 newdc->wndOrgY = dc->wndOrgY;
272 newdc->wndExtX = dc->wndExtX;
273 newdc->wndExtY = dc->wndExtY;
274 newdc->vportOrgX = dc->vportOrgX;
275 newdc->vportOrgY = dc->vportOrgY;
276 newdc->vportExtX = dc->vportExtX;
277 newdc->vportExtY = dc->vportExtY;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000278
Alexandre Julliarda3960291999-02-26 11:11:13 +0000279 newdc->hSelf = (HDC)handle;
Alexandre Julliard401710d1993-09-04 10:09:32 +0000280 newdc->saveLevel = 0;
Alexandre Julliard401710d1993-09-04 10:09:32 +0000281
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000282 PATH_InitGdiPath( &newdc->w.path );
283
Huw D M Davies304d9a41999-09-13 15:15:45 +0000284 newdc->w.pAbortProc = NULL;
285
Alexandre Julliard491502b1997-11-01 19:08:16 +0000286 /* Get/SetDCState() don't change hVisRgn field ("Undoc. Windows" p.559). */
287
288 newdc->w.hGCClipRgn = newdc->w.hVisRgn = 0;
Alexandre Julliard401710d1993-09-04 10:09:32 +0000289 if (dc->w.hClipRgn)
290 {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000291 newdc->w.hClipRgn = CreateRectRgn( 0, 0, 0, 0 );
292 CombineRgn( newdc->w.hClipRgn, dc->w.hClipRgn, 0, RGN_COPY );
Alexandre Julliard401710d1993-09-04 10:09:32 +0000293 }
Alexandre Julliard349a9531997-02-02 19:01:52 +0000294 else
295 newdc->w.hClipRgn = 0;
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000296 GDI_HEAP_UNLOCK( handle );
297 GDI_HEAP_UNLOCK( hdc );
Alexandre Julliard401710d1993-09-04 10:09:32 +0000298 return handle;
299}
300
301
302/***********************************************************************
303 * SetDCState (GDI.180)
304 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000305void WINAPI SetDCState16( HDC16 hdc, HDC16 hdcs )
Alexandre Julliard401710d1993-09-04 10:09:32 +0000306{
Alexandre Julliard139a4b11996-11-02 14:24:07 +0000307 DC *dc, *dcs;
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000308
Alexandre Julliard401710d1993-09-04 10:09:32 +0000309 if (!(dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ))) return;
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000310 if (!(dcs = (DC *) GDI_GetObjPtr( hdcs, DC_MAGIC )))
311 {
312 GDI_HEAP_UNLOCK( hdc );
313 return;
314 }
315 if (!dcs->w.flags & DC_SAVED)
316 {
317 GDI_HEAP_UNLOCK( hdc );
318 GDI_HEAP_UNLOCK( hdcs );
319 return;
320 }
Alexandre Julliard15657091999-05-23 10:25:25 +0000321 TRACE("%04x %04x\n", hdc, hdcs );
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000322
Alexandre Julliarddadf78f1998-05-17 17:13:43 +0000323 dc->w.flags = dcs->w.flags & ~DC_SAVED;
324 dc->w.devCaps = dcs->w.devCaps;
Alexandre Julliarddadf78f1998-05-17 17:13:43 +0000325 dc->w.hDevice = dcs->w.hDevice;
Ulrich Weigand27bb3621998-10-14 18:06:44 +0000326 dc->w.totalExtent = dcs->w.totalExtent;
Alexandre Julliarddadf78f1998-05-17 17:13:43 +0000327 dc->w.ROPmode = dcs->w.ROPmode;
328 dc->w.polyFillMode = dcs->w.polyFillMode;
329 dc->w.stretchBltMode = dcs->w.stretchBltMode;
330 dc->w.relAbsMode = dcs->w.relAbsMode;
331 dc->w.backgroundMode = dcs->w.backgroundMode;
332 dc->w.backgroundColor = dcs->w.backgroundColor;
333 dc->w.textColor = dcs->w.textColor;
Alexandre Julliarddadf78f1998-05-17 17:13:43 +0000334 dc->w.brushOrgX = dcs->w.brushOrgX;
335 dc->w.brushOrgY = dcs->w.brushOrgY;
336 dc->w.textAlign = dcs->w.textAlign;
337 dc->w.charExtra = dcs->w.charExtra;
338 dc->w.breakTotalExtra = dcs->w.breakTotalExtra;
339 dc->w.breakCount = dcs->w.breakCount;
340 dc->w.breakExtra = dcs->w.breakExtra;
341 dc->w.breakRem = dcs->w.breakRem;
342 dc->w.MapMode = dcs->w.MapMode;
343 dc->w.GraphicsMode = dcs->w.GraphicsMode;
Ulrich Weigandd4663661998-10-11 18:47:02 +0000344#if 0
345 /* Apparently, the DC origin is not changed by [GS]etDCState */
Alexandre Julliarddadf78f1998-05-17 17:13:43 +0000346 dc->w.DCOrgX = dcs->w.DCOrgX;
347 dc->w.DCOrgY = dcs->w.DCOrgY;
Ulrich Weigandd4663661998-10-11 18:47:02 +0000348#endif
Alexandre Julliarddadf78f1998-05-17 17:13:43 +0000349 dc->w.CursPosX = dcs->w.CursPosX;
350 dc->w.CursPosY = dcs->w.CursPosY;
351 dc->w.ArcDirection = dcs->w.ArcDirection;
352 dc->w.xformWorld2Wnd = dcs->w.xformWorld2Wnd;
353 dc->w.xformWorld2Vport = dcs->w.xformWorld2Vport;
354 dc->w.xformVport2World = dcs->w.xformVport2World;
355 dc->w.vport2WorldValid = dcs->w.vport2WorldValid;
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000356
Alexandre Julliarddadf78f1998-05-17 17:13:43 +0000357 dc->wndOrgX = dcs->wndOrgX;
358 dc->wndOrgY = dcs->wndOrgY;
359 dc->wndExtX = dcs->wndExtX;
360 dc->wndExtY = dcs->wndExtY;
361 dc->vportOrgX = dcs->vportOrgX;
362 dc->vportOrgY = dcs->vportOrgY;
363 dc->vportExtX = dcs->vportExtX;
364 dc->vportExtY = dcs->vportExtY;
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000365
Alexandre Julliard139a4b11996-11-02 14:24:07 +0000366 if (!(dc->w.flags & DC_MEMORY)) dc->w.bitsPerPixel = dcs->w.bitsPerPixel;
Ulrich Weigandd4663661998-10-11 18:47:02 +0000367
368 if (dcs->w.hClipRgn)
369 {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000370 if (!dc->w.hClipRgn) dc->w.hClipRgn = CreateRectRgn( 0, 0, 0, 0 );
371 CombineRgn( dc->w.hClipRgn, dcs->w.hClipRgn, 0, RGN_COPY );
Ulrich Weigandd4663661998-10-11 18:47:02 +0000372 }
373 else
Ulrich Weigand7119a6e1998-11-01 14:05:33 +0000374 {
375 if (dc->w.hClipRgn) DeleteObject16( dc->w.hClipRgn );
Ulrich Weigandd4663661998-10-11 18:47:02 +0000376 dc->w.hClipRgn = 0;
Ulrich Weigand7119a6e1998-11-01 14:05:33 +0000377 }
378 CLIPPING_UpdateGCRegion( dc );
Alexandre Julliard491502b1997-11-01 19:08:16 +0000379
Alexandre Julliarda3960291999-02-26 11:11:13 +0000380 SelectObject( hdc, dcs->w.hBitmap );
381 SelectObject( hdc, dcs->w.hBrush );
382 SelectObject( hdc, dcs->w.hFont );
383 SelectObject( hdc, dcs->w.hPen );
384 SetBkColor( hdc, dcs->w.backgroundColor);
385 SetTextColor( hdc, dcs->w.textColor);
386 GDISelectPalette16( hdc, dcs->w.hPalette, FALSE );
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000387 GDI_HEAP_UNLOCK( hdc );
388 GDI_HEAP_UNLOCK( hdcs );
Alexandre Julliard401710d1993-09-04 10:09:32 +0000389}
390
391
392/***********************************************************************
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000393 * SaveDC16 (GDI.30)
Alexandre Julliard401710d1993-09-04 10:09:32 +0000394 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000395INT16 WINAPI SaveDC16( HDC16 hdc )
Alexandre Julliard401710d1993-09-04 10:09:32 +0000396{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000397 return (INT16)SaveDC( hdc );
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000398}
399
400
401/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +0000402 * SaveDC (GDI32.292)
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000403 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000404INT WINAPI SaveDC( HDC hdc )
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000405{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000406 HDC hdcs;
Alexandre Julliard401710d1993-09-04 10:09:32 +0000407 DC * dc, * dcs;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000408 INT ret;
Alexandre Julliard401710d1993-09-04 10:09:32 +0000409
Huw D M Davies7603dea1999-04-25 09:24:23 +0000410 dc = DC_GetDCPtr( hdc );
411 if (!dc) return 0;
412
413 if(dc->funcs->pSaveDC)
414 return dc->funcs->pSaveDC( dc );
415
Alexandre Julliarda3960291999-02-26 11:11:13 +0000416 if (!(hdcs = GetDCState16( hdc )))
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000417 {
418 GDI_HEAP_UNLOCK( hdc );
419 return 0;
420 }
421 dcs = (DC *) GDI_HEAP_LOCK( hdcs );
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000422
423 /* Copy path. The reason why path saving / restoring is in SaveDC/
424 * RestoreDC and not in GetDCState/SetDCState is that the ...DCState
425 * functions are only in Win16 (which doesn't have paths) and that
426 * SetDCState doesn't allow us to signal an error (which can happen
427 * when copying paths).
428 */
429 if (!PATH_AssignGdiPath( &dcs->w.path, &dc->w.path ))
430 {
431 GDI_HEAP_UNLOCK( hdc );
432 GDI_HEAP_UNLOCK( hdcs );
Alexandre Julliarda3960291999-02-26 11:11:13 +0000433 DeleteDC( hdcs );
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000434 return 0;
435 }
436
Alexandre Julliard401710d1993-09-04 10:09:32 +0000437 dcs->header.hNext = dc->header.hNext;
438 dc->header.hNext = hdcs;
Alexandre Julliard15657091999-05-23 10:25:25 +0000439 TRACE("(%04x): returning %d\n", hdc, dc->saveLevel+1 );
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000440 ret = ++dc->saveLevel;
441 GDI_HEAP_UNLOCK( hdcs );
442 GDI_HEAP_UNLOCK( hdc );
443 return ret;
Alexandre Julliard401710d1993-09-04 10:09:32 +0000444}
445
446
447/***********************************************************************
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000448 * RestoreDC16 (GDI.39)
Alexandre Julliard401710d1993-09-04 10:09:32 +0000449 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000450BOOL16 WINAPI RestoreDC16( HDC16 hdc, INT16 level )
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000451{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000452 return RestoreDC( hdc, level );
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000453}
454
455
456/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +0000457 * RestoreDC (GDI32.290)
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000458 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000459BOOL WINAPI RestoreDC( HDC hdc, INT level )
Alexandre Julliard401710d1993-09-04 10:09:32 +0000460{
461 DC * dc, * dcs;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000462 BOOL success;
Alexandre Julliard401710d1993-09-04 10:09:32 +0000463
Alexandre Julliard15657091999-05-23 10:25:25 +0000464 TRACE("%04x %d\n", hdc, level );
Huw D M Davies7603dea1999-04-25 09:24:23 +0000465 dc = DC_GetDCPtr( hdc );
466 if(!dc) return FALSE;
467 if(dc->funcs->pRestoreDC)
468 return dc->funcs->pRestoreDC( dc, level );
469
Alexandre Julliard401710d1993-09-04 10:09:32 +0000470 if (level == -1) level = dc->saveLevel;
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000471 if ((level < 1) || (level > dc->saveLevel))
472 {
473 GDI_HEAP_UNLOCK( hdc );
474 return FALSE;
475 }
Alexandre Julliard401710d1993-09-04 10:09:32 +0000476
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000477 success=TRUE;
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000478 while (dc->saveLevel >= level)
Alexandre Julliard401710d1993-09-04 10:09:32 +0000479 {
Alexandre Julliard530ee841996-10-23 16:59:13 +0000480 HDC16 hdcs = dc->header.hNext;
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000481 if (!(dcs = (DC *) GDI_GetObjPtr( hdcs, DC_MAGIC )))
482 {
483 GDI_HEAP_UNLOCK( hdc );
484 return FALSE;
485 }
Alexandre Julliard401710d1993-09-04 10:09:32 +0000486 dc->header.hNext = dcs->header.hNext;
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000487 if (--dc->saveLevel < level)
488 {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000489 SetDCState16( hdc, hdcs );
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000490 if (!PATH_AssignGdiPath( &dc->w.path, &dcs->w.path ))
491 /* FIXME: This might not be quite right, since we're
492 * returning FALSE but still destroying the saved DC state */
493 success=FALSE;
494 }
Alexandre Julliarda3960291999-02-26 11:11:13 +0000495 DeleteDC( hdcs );
Alexandre Julliard401710d1993-09-04 10:09:32 +0000496 }
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000497 GDI_HEAP_UNLOCK( hdc );
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000498 return success;
Alexandre Julliard401710d1993-09-04 10:09:32 +0000499}
500
501
502/***********************************************************************
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000503 * CreateDC16 (GDI.53)
Alexandre Julliard401710d1993-09-04 10:09:32 +0000504 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000505HDC16 WINAPI CreateDC16( LPCSTR driver, LPCSTR device, LPCSTR output,
Huw D M Daviese39b6761999-05-17 16:20:51 +0000506 const DEVMODEA *initData )
Alexandre Julliard401710d1993-09-04 10:09:32 +0000507{
508 DC * dc;
Alexandre Julliard0e270f41996-08-24 18:26:35 +0000509 const DC_FUNCTIONS *funcs;
Huw D M Daviese39b6761999-05-17 16:20:51 +0000510 char buf[300];
Alexandre Julliard0e270f41996-08-24 18:26:35 +0000511
Huw D M Daviese39b6761999-05-17 16:20:51 +0000512 if (device) {
513 if(!DRIVER_GetDriverName( device, buf, sizeof(buf) )) return 0;
514 } else
515 strcpy(buf, driver);
516
517 if (!(funcs = DRIVER_FindDriver( buf ))) return 0;
Alexandre Julliardbf9130a1996-10-13 17:45:47 +0000518 if (!(dc = DC_AllocDC( funcs ))) return 0;
519 dc->w.flags = 0;
Alexandre Julliard401710d1993-09-04 10:09:32 +0000520
Alexandre Julliard15657091999-05-23 10:25:25 +0000521 TRACE("(driver=%s, device=%s, output=%s): returning %04x\n",
Alexandre Julliarda0d77311998-09-13 16:32:00 +0000522 debugstr_a(driver), debugstr_a(device), debugstr_a(output), dc->hSelf );
Alexandre Julliard401710d1993-09-04 10:09:32 +0000523
Alexandre Julliard0e270f41996-08-24 18:26:35 +0000524 if (dc->funcs->pCreateDC &&
Huw D M Davies304d9a41999-09-13 15:15:45 +0000525 !dc->funcs->pCreateDC( dc, buf, device, output, initData ))
Alexandre Julliard3a405ba1994-10-30 16:25:19 +0000526 {
Alexandre Julliard15657091999-05-23 10:25:25 +0000527 WARN("creation aborted by device\n" );
Alexandre Julliardbf9130a1996-10-13 17:45:47 +0000528 GDI_HEAP_FREE( dc->hSelf );
Alexandre Julliard3a405ba1994-10-30 16:25:19 +0000529 return 0;
530 }
Alexandre Julliard401710d1993-09-04 10:09:32 +0000531
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000532 DC_InitDC( dc );
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000533 GDI_HEAP_UNLOCK( dc->hSelf );
Alexandre Julliardbf9130a1996-10-13 17:45:47 +0000534 return dc->hSelf;
Alexandre Julliard401710d1993-09-04 10:09:32 +0000535}
536
537
538/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +0000539 * CreateDCA (GDI32.)
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000540 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000541HDC WINAPI CreateDCA( LPCSTR driver, LPCSTR device, LPCSTR output,
542 const DEVMODEA *initData )
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000543{
Huw D M Daviese39b6761999-05-17 16:20:51 +0000544 return CreateDC16( driver, device, output, (const DEVMODEA *)initData );
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000545}
546
547
548/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +0000549 * CreateDCW (GDI32.)
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000550 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000551HDC WINAPI CreateDCW( LPCWSTR driver, LPCWSTR device, LPCWSTR output,
552 const DEVMODEW *initData )
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000553{
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000554 LPSTR driverA = HEAP_strdupWtoA( GetProcessHeap(), 0, driver );
555 LPSTR deviceA = HEAP_strdupWtoA( GetProcessHeap(), 0, device );
556 LPSTR outputA = HEAP_strdupWtoA( GetProcessHeap(), 0, output );
Alexandre Julliarda3960291999-02-26 11:11:13 +0000557 HDC res = CreateDC16( driverA, deviceA, outputA,
Huw D M Daviese39b6761999-05-17 16:20:51 +0000558 (const DEVMODEA *)initData /*FIXME*/ );
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000559 HeapFree( GetProcessHeap(), 0, driverA );
560 HeapFree( GetProcessHeap(), 0, deviceA );
561 HeapFree( GetProcessHeap(), 0, outputA );
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000562 return res;
563}
564
565
566/***********************************************************************
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000567 * CreateIC16 (GDI.153)
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000568 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000569HDC16 WINAPI CreateIC16( LPCSTR driver, LPCSTR device, LPCSTR output,
Huw D M Daviese39b6761999-05-17 16:20:51 +0000570 const DEVMODEA* initData )
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000571{
572 /* Nothing special yet for ICs */
Alexandre Julliardb1bac321996-12-15 19:45:59 +0000573 return CreateDC16( driver, device, output, initData );
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000574}
575
576
577/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +0000578 * CreateICA (GDI32.49)
Alexandre Julliard401710d1993-09-04 10:09:32 +0000579 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000580HDC WINAPI CreateICA( LPCSTR driver, LPCSTR device, LPCSTR output,
581 const DEVMODEA* initData )
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000582{
583 /* Nothing special yet for ICs */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000584 return CreateDCA( driver, device, output, initData );
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000585}
586
587
588/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +0000589 * CreateICW (GDI32.50)
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000590 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000591HDC WINAPI CreateICW( LPCWSTR driver, LPCWSTR device, LPCWSTR output,
592 const DEVMODEW* initData )
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000593{
594 /* Nothing special yet for ICs */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000595 return CreateDCW( driver, device, output, initData );
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000596}
597
598
599/***********************************************************************
600 * CreateCompatibleDC16 (GDI.52)
601 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000602HDC16 WINAPI CreateCompatibleDC16( HDC16 hdc )
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000603{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000604 return (HDC16)CreateCompatibleDC( hdc );
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000605}
606
607
608/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +0000609 * CreateCompatibleDC (GDI32.31)
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000610 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000611HDC WINAPI CreateCompatibleDC( HDC hdc )
Alexandre Julliard401710d1993-09-04 10:09:32 +0000612{
Alexandre Julliard0e270f41996-08-24 18:26:35 +0000613 DC *dc, *origDC;
Alexandre Julliard0e270f41996-08-24 18:26:35 +0000614 const DC_FUNCTIONS *funcs;
615
616 if ((origDC = (DC *)GDI_GetObjPtr( hdc, DC_MAGIC ))) funcs = origDC->funcs;
617 else funcs = DRIVER_FindDriver( "DISPLAY" );
618 if (!funcs) return 0;
Alexandre Julliardaca05781994-10-17 18:12:41 +0000619
Alexandre Julliardbf9130a1996-10-13 17:45:47 +0000620 if (!(dc = DC_AllocDC( funcs ))) return 0;
Alexandre Julliard401710d1993-09-04 10:09:32 +0000621
Alexandre Julliard15657091999-05-23 10:25:25 +0000622 TRACE("(%04x): returning %04x\n",
Alexandre Julliardbf9130a1996-10-13 17:45:47 +0000623 hdc, dc->hSelf );
Alexandre Julliard401710d1993-09-04 10:09:32 +0000624
Alexandre Julliard401710d1993-09-04 10:09:32 +0000625 dc->w.flags = DC_MEMORY;
Alexandre Julliard401710d1993-09-04 10:09:32 +0000626 dc->w.bitsPerPixel = 1;
Gerard Pateld1795f62000-01-09 20:52:53 +0000627 dc->w.hBitmap = hPseudoStockBitmap;
Alexandre Julliard3a405ba1994-10-30 16:25:19 +0000628
Noel Borthwick86b686f1999-06-05 08:52:30 +0000629 /* Copy the driver-specific physical device info into
630 * the new DC. The driver may use this read-only info
631 * while creating the compatible DC below. */
632 if (origDC)
633 dc->physDev = origDC->physDev;
634
Alexandre Julliard0e270f41996-08-24 18:26:35 +0000635 if (dc->funcs->pCreateDC &&
636 !dc->funcs->pCreateDC( dc, NULL, NULL, NULL, NULL ))
Alexandre Julliard3a405ba1994-10-30 16:25:19 +0000637 {
Alexandre Julliard15657091999-05-23 10:25:25 +0000638 WARN("creation aborted by device\n");
Alexandre Julliardbf9130a1996-10-13 17:45:47 +0000639 GDI_HEAP_FREE( dc->hSelf );
Alexandre Julliard3a405ba1994-10-30 16:25:19 +0000640 return 0;
641 }
Alexandre Julliard401710d1993-09-04 10:09:32 +0000642
Alexandre Julliardd1ce8b21996-09-02 16:46:30 +0000643 DC_InitDC( dc );
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000644 GDI_HEAP_UNLOCK( dc->hSelf );
Alexandre Julliardbf9130a1996-10-13 17:45:47 +0000645 return dc->hSelf;
Alexandre Julliard401710d1993-09-04 10:09:32 +0000646}
647
648
649/***********************************************************************
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000650 * DeleteDC16 (GDI.68)
Alexandre Julliard401710d1993-09-04 10:09:32 +0000651 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000652BOOL16 WINAPI DeleteDC16( HDC16 hdc )
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000653{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000654 return DeleteDC( hdc );
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000655}
656
657
658/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +0000659 * DeleteDC (GDI32.67)
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000660 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000661BOOL WINAPI DeleteDC( HDC hdc )
Alexandre Julliard401710d1993-09-04 10:09:32 +0000662{
Ulrich Weigande6ea9eb1999-05-08 09:50:52 +0000663 DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
Alexandre Julliard401710d1993-09-04 10:09:32 +0000664 if (!dc) return FALSE;
665
Alexandre Julliard15657091999-05-23 10:25:25 +0000666 TRACE("%04x\n", hdc );
Alexandre Julliard401710d1993-09-04 10:09:32 +0000667
Ulrich Weigande6ea9eb1999-05-08 09:50:52 +0000668 /* Call hook procedure to check whether is it OK to delete this DC */
Ulrich Weigandf86aab81999-09-20 18:47:14 +0000669 if ( dc->hookThunk && !(dc->w.flags & (DC_SAVED | DC_MEMORY))
670 && dc->hookThunk( hdc, DCHC_DELETEDC, dc->dwHookData, 0 ) == FALSE )
Ulrich Weigande6ea9eb1999-05-08 09:50:52 +0000671 {
672 GDI_HEAP_UNLOCK( hdc );
673 return FALSE;
674 }
675
Alexandre Julliard401710d1993-09-04 10:09:32 +0000676 while (dc->saveLevel)
677 {
678 DC * dcs;
Alexandre Julliard530ee841996-10-23 16:59:13 +0000679 HDC16 hdcs = dc->header.hNext;
Alexandre Julliard401710d1993-09-04 10:09:32 +0000680 if (!(dcs = (DC *) GDI_GetObjPtr( hdcs, DC_MAGIC ))) break;
681 dc->header.hNext = dcs->header.hNext;
682 dc->saveLevel--;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000683 DeleteDC( hdcs );
Alexandre Julliard401710d1993-09-04 10:09:32 +0000684 }
685
686 if (!(dc->w.flags & DC_SAVED))
687 {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000688 SelectObject( hdc, STOCK_BLACK_PEN );
689 SelectObject( hdc, STOCK_WHITE_BRUSH );
690 SelectObject( hdc, STOCK_SYSTEM_FONT );
Alexandre Julliard0e270f41996-08-24 18:26:35 +0000691 if (dc->funcs->pDeleteDC) dc->funcs->pDeleteDC(dc);
Alexandre Julliard401710d1993-09-04 10:09:32 +0000692 }
Alexandre Julliardaca05781994-10-17 18:12:41 +0000693
Alexandre Julliarda3960291999-02-26 11:11:13 +0000694 if (dc->w.hClipRgn) DeleteObject( dc->w.hClipRgn );
695 if (dc->w.hVisRgn) DeleteObject( dc->w.hVisRgn );
696 if (dc->w.hGCClipRgn) DeleteObject( dc->w.hGCClipRgn );
Huw D M Davies304d9a41999-09-13 15:15:45 +0000697 if (dc->w.pAbortProc) THUNK_Free( (FARPROC)dc->w.pAbortProc );
Ulrich Weigandf86aab81999-09-20 18:47:14 +0000698 if (dc->hookThunk) THUNK_Free( (FARPROC)dc->hookThunk );
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000699 PATH_DestroyGdiPath(&dc->w.path);
700
Alexandre Julliard401710d1993-09-04 10:09:32 +0000701 return GDI_FreeObject( hdc );
702}
703
704
705/***********************************************************************
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000706 * ResetDC16 (GDI.376)
Alexandre Julliardaf0bae51995-10-03 17:06:08 +0000707 */
Huw D M Daviese39b6761999-05-17 16:20:51 +0000708HDC16 WINAPI ResetDC16( HDC16 hdc, const DEVMODEA *devmode )
Alexandre Julliardaf0bae51995-10-03 17:06:08 +0000709{
Alexandre Julliard15657091999-05-23 10:25:25 +0000710 FIXME("stub\n" );
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000711 return hdc;
712}
713
714
715/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +0000716 * ResetDCA (GDI32.287)
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000717 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000718HDC WINAPI ResetDCA( HDC hdc, const DEVMODEA *devmode )
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000719{
Alexandre Julliard15657091999-05-23 10:25:25 +0000720 FIXME("stub\n" );
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000721 return hdc;
722}
723
724
725/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +0000726 * ResetDCW (GDI32.288)
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000727 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000728HDC WINAPI ResetDCW( HDC hdc, const DEVMODEW *devmode )
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000729{
Alexandre Julliard15657091999-05-23 10:25:25 +0000730 FIXME("stub\n" );
Alexandre Julliardaf0bae51995-10-03 17:06:08 +0000731 return hdc;
732}
733
734
735/***********************************************************************
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +0000736 * GetDeviceCaps16 (GDI.80)
Alexandre Julliard401710d1993-09-04 10:09:32 +0000737 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000738INT16 WINAPI GetDeviceCaps16( HDC16 hdc, INT16 cap )
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +0000739{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000740 return GetDeviceCaps( hdc, cap );
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +0000741}
742
743
744/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +0000745 * GetDeviceCaps (GDI32.171)
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +0000746 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000747INT WINAPI GetDeviceCaps( HDC hdc, INT cap )
Alexandre Julliard401710d1993-09-04 10:09:32 +0000748{
749 DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
Alexandre Julliarda3960291999-02-26 11:11:13 +0000750 INT ret;
Huw D M Daviese39b6761999-05-17 16:20:51 +0000751 POINT pt;
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000752
Alexandre Julliard401710d1993-09-04 10:09:32 +0000753 if (!dc) return 0;
754
Huw D M Daviese39b6761999-05-17 16:20:51 +0000755 /* Device capabilities for the printer */
756 switch (cap)
757 {
758 case PHYSICALWIDTH:
759 if(Escape(hdc, GETPHYSPAGESIZE, 0, NULL, (LPVOID)&pt) > 0)
760 return pt.x;
761 case PHYSICALHEIGHT:
762 if(Escape(hdc, GETPHYSPAGESIZE, 0, NULL, (LPVOID)&pt) > 0)
763 return pt.y;
764 case PHYSICALOFFSETX:
765 if(Escape(hdc, GETPRINTINGOFFSET, 0, NULL, (LPVOID)&pt) > 0)
766 return pt.x;
767 case PHYSICALOFFSETY:
768 if(Escape(hdc, GETPRINTINGOFFSET, 0, NULL, (LPVOID)&pt) > 0)
769 return pt.y;
770 case SCALINGFACTORX:
771 if(Escape(hdc, GETSCALINGFACTOR, 0, NULL, (LPVOID)&pt) > 0)
772 return pt.x;
773 case SCALINGFACTORY:
774 if(Escape(hdc, GETSCALINGFACTOR, 0, NULL, (LPVOID)&pt) > 0)
775 return pt.y;
776 }
777
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000778 if ((cap < 0) || (cap > sizeof(DeviceCaps)-sizeof(WORD)))
779 {
780 GDI_HEAP_UNLOCK( hdc );
781 return 0;
782 }
Marcus Meissner382354e2000-01-30 22:19:08 +0000783
784 if (((cap>=46) && (cap<88)) || ((cap>=92) && (cap<104)))
785 FIXME("(%04x,%d): unsupported DeviceCaps capability, will yield 0!\n",
786 hdc,cap
787 );
Alexandre Julliard15657091999-05-23 10:25:25 +0000788 TRACE("(%04x,%d): returning %d\n",
Alexandre Julliard401710d1993-09-04 10:09:32 +0000789 hdc, cap, *(WORD *)(((char *)dc->w.devCaps) + cap) );
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000790 ret = *(WORD *)(((char *)dc->w.devCaps) + cap);
791 GDI_HEAP_UNLOCK( hdc );
792 return ret;
Alexandre Julliard401710d1993-09-04 10:09:32 +0000793}
794
795
796/***********************************************************************
Alexandre Julliard21979011997-03-05 08:22:35 +0000797 * SetBkColor16 (GDI.1)
Alexandre Julliard401710d1993-09-04 10:09:32 +0000798 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000799COLORREF WINAPI SetBkColor16( HDC16 hdc, COLORREF color )
Alexandre Julliard21979011997-03-05 08:22:35 +0000800{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000801 return SetBkColor( hdc, color );
Alexandre Julliard21979011997-03-05 08:22:35 +0000802}
803
804
805/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +0000806 * SetBkColor (GDI32.305)
Alexandre Julliard21979011997-03-05 08:22:35 +0000807 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000808COLORREF WINAPI SetBkColor( HDC hdc, COLORREF color )
Alexandre Julliard401710d1993-09-04 10:09:32 +0000809{
810 COLORREF oldColor;
Alexandre Julliarda0d77311998-09-13 16:32:00 +0000811 DC * dc = DC_GetDCPtr( hdc );
812
813 if (!dc) return 0x80000000;
814 if (dc->funcs->pSetBkColor)
815 oldColor = dc->funcs->pSetBkColor(dc, color);
816 else {
817 oldColor = dc->w.backgroundColor;
818 dc->w.backgroundColor = color;
Alexandre Julliard73450d61994-05-18 18:29:32 +0000819 }
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000820 GDI_HEAP_UNLOCK( hdc );
Alexandre Julliard401710d1993-09-04 10:09:32 +0000821 return oldColor;
822}
823
824
825/***********************************************************************
Alexandre Julliard21979011997-03-05 08:22:35 +0000826 * SetTextColor16 (GDI.9)
Alexandre Julliard401710d1993-09-04 10:09:32 +0000827 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000828COLORREF WINAPI SetTextColor16( HDC16 hdc, COLORREF color )
Alexandre Julliard21979011997-03-05 08:22:35 +0000829{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000830 return SetTextColor( hdc, color );
Alexandre Julliard21979011997-03-05 08:22:35 +0000831}
832
833
834/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +0000835 * SetTextColor (GDI32.338)
Alexandre Julliard21979011997-03-05 08:22:35 +0000836 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000837COLORREF WINAPI SetTextColor( HDC hdc, COLORREF color )
Alexandre Julliard401710d1993-09-04 10:09:32 +0000838{
839 COLORREF oldColor;
Alexandre Julliarda0d77311998-09-13 16:32:00 +0000840 DC * dc = DC_GetDCPtr( hdc );
841
842 if (!dc) return 0x80000000;
843 if (dc->funcs->pSetTextColor)
844 oldColor = dc->funcs->pSetTextColor(dc, color);
845 else {
846 oldColor = dc->w.textColor;
847 dc->w.textColor = color;
Alexandre Julliard73450d61994-05-18 18:29:32 +0000848 }
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000849 GDI_HEAP_UNLOCK( hdc );
Alexandre Julliard401710d1993-09-04 10:09:32 +0000850 return oldColor;
851}
852
Alexandre Julliard401710d1993-09-04 10:09:32 +0000853/***********************************************************************
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000854 * SetTextAlign16 (GDI.346)
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000855 */
Huw D M Davies7603dea1999-04-25 09:24:23 +0000856UINT16 WINAPI SetTextAlign16( HDC16 hdc, UINT16 align )
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000857{
Huw D M Davies7603dea1999-04-25 09:24:23 +0000858 return SetTextAlign( hdc, align );
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000859}
860
861
862/***********************************************************************
Huw D M Davies7603dea1999-04-25 09:24:23 +0000863 * SetTextAlign (GDI32.336)
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000864 */
Huw D M Davies7603dea1999-04-25 09:24:23 +0000865UINT WINAPI SetTextAlign( HDC hdc, UINT align )
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000866{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000867 UINT prevAlign;
Huw D M Davies7603dea1999-04-25 09:24:23 +0000868 DC *dc = DC_GetDCPtr( hdc );
869 if (!dc) return 0x0;
870 if (dc->funcs->pSetTextAlign)
871 prevAlign = dc->funcs->pSetTextAlign(dc, align);
872 else {
873 prevAlign = dc->w.textAlign;
874 dc->w.textAlign = align;
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000875 }
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000876 GDI_HEAP_UNLOCK( hdc );
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000877 return prevAlign;
878}
879
Alexandre Julliard2ace16a1996-04-28 15:09:19 +0000880/***********************************************************************
Alexandre Julliardda0cfb31996-12-01 17:17:47 +0000881 * GetDCOrgEx (GDI32.168)
882 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000883BOOL WINAPI GetDCOrgEx( HDC hDC, LPPOINT lpp )
Alexandre Julliardda0cfb31996-12-01 17:17:47 +0000884{
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000885 DC * dc;
Huw D M Davies9c68faa1998-11-25 12:36:03 +0000886
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000887 if (!lpp) return FALSE;
888 if (!(dc = (DC *) GDI_GetObjPtr( hDC, DC_MAGIC ))) return FALSE;
Alexandre Julliardda0cfb31996-12-01 17:17:47 +0000889
Alexandre Julliard07e42132000-03-19 21:19:21 +0000890 lpp->x = lpp->y = 0;
891 if (dc->funcs->pGetDCOrgEx) dc->funcs->pGetDCOrgEx( dc, lpp );
892 lpp->x += dc->w.DCOrgX;
893 lpp->y += dc->w.DCOrgY;
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000894 GDI_HEAP_UNLOCK( hDC );
Alexandre Julliardda0cfb31996-12-01 17:17:47 +0000895 return TRUE;
896}
897
898
899/***********************************************************************
Alexandre Julliard3f2abfa1994-08-16 15:43:11 +0000900 * GetDCOrg (GDI.79)
901 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000902DWORD WINAPI GetDCOrg16( HDC16 hdc )
Alexandre Julliard3f2abfa1994-08-16 15:43:11 +0000903{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000904 POINT pt;
Alexandre Julliardda0cfb31996-12-01 17:17:47 +0000905 if( GetDCOrgEx( hdc, &pt) )
906 return MAKELONG( (WORD)pt.x, (WORD)pt.y );
907 return 0;
Alexandre Julliard3f2abfa1994-08-16 15:43:11 +0000908}
909
910
911/***********************************************************************
Alexandre Julliard401710d1993-09-04 10:09:32 +0000912 * SetDCOrg (GDI.117)
913 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000914DWORD WINAPI SetDCOrg16( HDC16 hdc, INT16 x, INT16 y )
Alexandre Julliard401710d1993-09-04 10:09:32 +0000915{
916 DWORD prevOrg;
917 DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
918 if (!dc) return 0;
919 prevOrg = dc->w.DCOrgX | (dc->w.DCOrgY << 16);
920 dc->w.DCOrgX = x;
921 dc->w.DCOrgY = y;
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000922 GDI_HEAP_UNLOCK( hdc );
Alexandre Julliard401710d1993-09-04 10:09:32 +0000923 return prevOrg;
924}
Alexandre Julliard1e9ac791996-06-06 18:38:27 +0000925
926
927/***********************************************************************
Alexandre Julliard17216f51997-10-12 16:30:17 +0000928 * GetGraphicsMode (GDI32.188)
929 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000930INT WINAPI GetGraphicsMode( HDC hdc )
Alexandre Julliard17216f51997-10-12 16:30:17 +0000931{
932 DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
933 if (!dc) return 0;
934 return dc->w.GraphicsMode;
935}
936
937
938/***********************************************************************
939 * SetGraphicsMode (GDI32.317)
940 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000941INT WINAPI SetGraphicsMode( HDC hdc, INT mode )
Alexandre Julliard17216f51997-10-12 16:30:17 +0000942{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000943 INT ret;
Alexandre Julliard17216f51997-10-12 16:30:17 +0000944 DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000945
946 /* One would think that setting the graphics mode to GM_COMPATIBLE
947 * would also reset the world transformation matrix to the unity
948 * matrix. However, in Windows, this is not the case. This doesn't
949 * make a lot of sense to me, but that's the way it is.
950 */
951
Alexandre Julliard17216f51997-10-12 16:30:17 +0000952 if (!dc) return 0;
953 if ((mode <= 0) || (mode > GM_LAST)) return 0;
954 ret = dc->w.GraphicsMode;
955 dc->w.GraphicsMode = mode;
956 return ret;
957}
958
959
960/***********************************************************************
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000961 * GetArcDirection16 (GDI.524)
962 */
963INT16 WINAPI GetArcDirection16( HDC16 hdc )
964{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000965 return GetArcDirection( (HDC)hdc );
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000966}
967
968
969/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +0000970 * GetArcDirection (GDI32.141)
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000971 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000972INT WINAPI GetArcDirection( HDC hdc )
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000973{
974 DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
975
976 if (!dc)
977 return 0;
978
979 return dc->w.ArcDirection;
980}
981
982
983/***********************************************************************
984 * SetArcDirection16 (GDI.525)
985 */
986INT16 WINAPI SetArcDirection16( HDC16 hdc, INT16 nDirection )
987{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000988 return SetArcDirection( (HDC)hdc, (INT)nDirection );
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000989}
990
991
992/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +0000993 * SetArcDirection (GDI32.302)
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000994 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000995INT WINAPI SetArcDirection( HDC hdc, INT nDirection )
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000996{
997 DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
Alexandre Julliarda3960291999-02-26 11:11:13 +0000998 INT nOldDirection;
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000999
1000 if (!dc)
1001 return 0;
1002
1003 if (nDirection!=AD_COUNTERCLOCKWISE && nDirection!=AD_CLOCKWISE)
1004 {
1005 SetLastError(ERROR_INVALID_PARAMETER);
1006 return 0;
1007 }
1008
1009 nOldDirection = dc->w.ArcDirection;
1010 dc->w.ArcDirection = nDirection;
1011
1012 return nOldDirection;
1013}
1014
1015
1016/***********************************************************************
Alexandre Julliard17216f51997-10-12 16:30:17 +00001017 * GetWorldTransform (GDI32.244)
1018 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001019BOOL WINAPI GetWorldTransform( HDC hdc, LPXFORM xform )
Alexandre Julliard17216f51997-10-12 16:30:17 +00001020{
Alexandre Julliard60ce85c1998-02-01 18:33:27 +00001021 DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
1022
1023 if (!dc)
Alexandre Julliard60ce85c1998-02-01 18:33:27 +00001024 return FALSE;
1025 if (!xform)
Alexandre Julliard60ce85c1998-02-01 18:33:27 +00001026 return FALSE;
1027
Alexandre Julliarddadf78f1998-05-17 17:13:43 +00001028 *xform = dc->w.xformWorld2Wnd;
Alexandre Julliard60ce85c1998-02-01 18:33:27 +00001029
1030 return TRUE;
1031}
1032
1033
1034/***********************************************************************
1035 * SetWorldTransform (GDI32.346)
1036 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001037BOOL WINAPI SetWorldTransform( HDC hdc, const XFORM *xform )
Alexandre Julliard60ce85c1998-02-01 18:33:27 +00001038{
1039 DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
1040
1041 if (!dc)
1042 {
1043 SetLastError( ERROR_INVALID_HANDLE );
1044 return FALSE;
1045 }
1046
1047 if (!xform)
1048 return FALSE;
1049
1050 /* Check that graphics mode is GM_ADVANCED */
1051 if (dc->w.GraphicsMode!=GM_ADVANCED)
1052 return FALSE;
1053
Alexandre Julliarddadf78f1998-05-17 17:13:43 +00001054 dc->w.xformWorld2Wnd = *xform;
Alexandre Julliard60ce85c1998-02-01 18:33:27 +00001055
Alexandre Julliarddadf78f1998-05-17 17:13:43 +00001056 DC_UpdateXforms( dc );
1057
1058 return TRUE;
1059}
1060
1061
1062/****************************************************************************
1063 * ModifyWorldTransform [GDI32.253]
1064 * Modifies the world transformation for a device context.
1065 *
1066 * PARAMS
1067 * hdc [I] Handle to device context
1068 * xform [I] XFORM structure that will be used to modify the world
1069 * transformation
1070 * iMode [I] Specifies in what way to modify the world transformation
1071 * Possible values:
1072 * MWT_IDENTITY
1073 * Resets the world transformation to the identity matrix.
1074 * The parameter xform is ignored.
1075 * MWT_LEFTMULTIPLY
1076 * Multiplies xform into the world transformation matrix from
1077 * the left.
1078 * MWT_RIGHTMULTIPLY
1079 * Multiplies xform into the world transformation matrix from
1080 * the right.
1081 *
1082 * RETURNS STD
1083 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001084BOOL WINAPI ModifyWorldTransform( HDC hdc, const XFORM *xform,
Alexandre Julliarddadf78f1998-05-17 17:13:43 +00001085 DWORD iMode )
1086{
1087 DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
1088
1089 /* Check for illegal parameters */
1090 if (!dc)
1091 {
1092 SetLastError( ERROR_INVALID_HANDLE );
1093 return FALSE;
1094 }
1095 if (!xform)
1096 return FALSE;
1097
1098 /* Check that graphics mode is GM_ADVANCED */
1099 if (dc->w.GraphicsMode!=GM_ADVANCED)
1100 return FALSE;
1101
1102 switch (iMode)
1103 {
1104 case MWT_IDENTITY:
1105 dc->w.xformWorld2Wnd.eM11 = 1.0f;
1106 dc->w.xformWorld2Wnd.eM12 = 0.0f;
1107 dc->w.xformWorld2Wnd.eM21 = 0.0f;
1108 dc->w.xformWorld2Wnd.eM22 = 1.0f;
1109 dc->w.xformWorld2Wnd.eDx = 0.0f;
1110 dc->w.xformWorld2Wnd.eDy = 0.0f;
1111 break;
1112 case MWT_LEFTMULTIPLY:
1113 CombineTransform( &dc->w.xformWorld2Wnd, xform,
1114 &dc->w.xformWorld2Wnd );
1115 break;
1116 case MWT_RIGHTMULTIPLY:
1117 CombineTransform( &dc->w.xformWorld2Wnd, &dc->w.xformWorld2Wnd,
1118 xform );
1119 break;
1120 default:
1121 return FALSE;
1122 }
1123
1124 DC_UpdateXforms( dc );
1125
1126 return TRUE;
1127}
1128
1129
1130/****************************************************************************
1131 * CombineTransform [GDI32.20]
1132 * Combines two transformation matrices.
1133 *
1134 * PARAMS
1135 * xformResult [O] Stores the result of combining the two matrices
1136 * xform1 [I] Specifies the first matrix to apply
1137 * xform2 [I] Specifies the second matrix to apply
1138 *
1139 * REMARKS
1140 * The same matrix can be passed in for more than one of the parameters.
1141 *
1142 * RETURNS STD
1143 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001144BOOL WINAPI CombineTransform( LPXFORM xformResult, const XFORM *xform1,
Alexandre Julliarddadf78f1998-05-17 17:13:43 +00001145 const XFORM *xform2 )
1146{
1147 XFORM xformTemp;
1148
1149 /* Check for illegal parameters */
1150 if (!xformResult || !xform1 || !xform2)
1151 return FALSE;
1152
1153 /* Create the result in a temporary XFORM, since xformResult may be
1154 * equal to xform1 or xform2 */
1155 xformTemp.eM11 = xform1->eM11 * xform2->eM11 +
1156 xform1->eM12 * xform2->eM21;
1157 xformTemp.eM12 = xform1->eM11 * xform2->eM12 +
1158 xform1->eM12 * xform2->eM22;
1159 xformTemp.eM21 = xform1->eM21 * xform2->eM11 +
1160 xform1->eM22 * xform2->eM21;
1161 xformTemp.eM22 = xform1->eM21 * xform2->eM12 +
1162 xform1->eM22 * xform2->eM22;
1163 xformTemp.eDx = xform1->eDx * xform2->eM11 +
1164 xform1->eDy * xform2->eM21 +
1165 xform2->eDx;
1166 xformTemp.eDy = xform1->eDx * xform2->eM12 +
1167 xform1->eDy * xform2->eM22 +
1168 xform2->eDy;
1169
1170 /* Copy the result to xformResult */
1171 *xformResult = xformTemp;
1172
Alexandre Julliard60ce85c1998-02-01 18:33:27 +00001173 return TRUE;
Alexandre Julliard17216f51997-10-12 16:30:17 +00001174}
1175
1176
1177/***********************************************************************
Alexandre Julliard1e9ac791996-06-06 18:38:27 +00001178 * SetDCHook (GDI.190)
1179 */
Ulrich Weigandf86aab81999-09-20 18:47:14 +00001180/* ### start build ### */
1181extern WORD CALLBACK GDI_CallTo16_word_wwll(FARPROC16,WORD,WORD,LONG,LONG);
1182/* ### stop build ### */
Alexandre Julliard670cdc41997-08-24 16:00:30 +00001183BOOL16 WINAPI SetDCHook( HDC16 hdc, FARPROC16 hookProc, DWORD dwHookData )
Alexandre Julliard1e9ac791996-06-06 18:38:27 +00001184{
Alexandre Julliardbf9130a1996-10-13 17:45:47 +00001185 DC *dc = (DC *)GDI_GetObjPtr( hdc, DC_MAGIC );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +00001186 if (!dc) return FALSE;
Ulrich Weigandf86aab81999-09-20 18:47:14 +00001187
1188 /*
1189 * Note: We store the original SEGPTR 'hookProc' as we need to be
1190 * able to return it verbatim in GetDCHook,
1191 *
1192 * On the other hand, we still call THUNK_Alloc and store the
1193 * 32-bit thunk into another DC member, because THUNK_Alloc
1194 * recognizes the (typical) case that the 'hookProc' is indeed
1195 * the 16-bit API entry point of a built-in routine (e.g. DCHook16)
1196 *
1197 * We could perform that test every time the hook is about to
1198 * be called (or else we could live with the 32->16->32 detour),
1199 * but this way is the most efficient ...
1200 */
1201
Alexandre Julliard1e9ac791996-06-06 18:38:27 +00001202 dc->hookProc = hookProc;
1203 dc->dwHookData = dwHookData;
Ulrich Weigandf86aab81999-09-20 18:47:14 +00001204
1205 THUNK_Free( (FARPROC)dc->hookThunk );
1206 dc->hookThunk = (DCHOOKPROC)
1207 THUNK_Alloc( hookProc, (RELAY)GDI_CallTo16_word_wwll );
1208
Alexandre Julliard670cdc41997-08-24 16:00:30 +00001209 GDI_HEAP_UNLOCK( hdc );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +00001210 return TRUE;
1211}
1212
1213
1214/***********************************************************************
1215 * GetDCHook (GDI.191)
1216 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +00001217DWORD WINAPI GetDCHook( HDC16 hdc, FARPROC16 *phookProc )
Alexandre Julliard1e9ac791996-06-06 18:38:27 +00001218{
Alexandre Julliardbf9130a1996-10-13 17:45:47 +00001219 DC *dc = (DC *)GDI_GetObjPtr( hdc, DC_MAGIC );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +00001220 if (!dc) return 0;
1221 *phookProc = dc->hookProc;
Alexandre Julliard670cdc41997-08-24 16:00:30 +00001222 GDI_HEAP_UNLOCK( hdc );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +00001223 return dc->dwHookData;
1224}
1225
1226
1227/***********************************************************************
1228 * SetHookFlags (GDI.192)
1229 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001230WORD WINAPI SetHookFlags16(HDC16 hDC, WORD flags)
Alexandre Julliard1e9ac791996-06-06 18:38:27 +00001231{
Alexandre Julliard491502b1997-11-01 19:08:16 +00001232 DC* dc = (DC*)GDI_GetObjPtr( hDC, DC_MAGIC );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +00001233
Alexandre Julliard491502b1997-11-01 19:08:16 +00001234 if( dc )
Alexandre Julliard1e9ac791996-06-06 18:38:27 +00001235 {
1236 WORD wRet = dc->w.flags & DC_DIRTY;
1237
Alexandre Julliard491502b1997-11-01 19:08:16 +00001238 /* "Undocumented Windows" info is slightly confusing.
Alexandre Julliard1e9ac791996-06-06 18:38:27 +00001239 */
1240
Alexandre Julliard15657091999-05-23 10:25:25 +00001241 TRACE("hDC %04x, flags %04x\n",hDC,flags);
Alexandre Julliard1e9ac791996-06-06 18:38:27 +00001242
1243 if( flags & DCHF_INVALIDATEVISRGN )
1244 dc->w.flags |= DC_DIRTY;
1245 else if( flags & DCHF_VALIDATEVISRGN || !flags )
1246 dc->w.flags &= ~DC_DIRTY;
Alexandre Julliard670cdc41997-08-24 16:00:30 +00001247 GDI_HEAP_UNLOCK( hDC );
Alexandre Julliard1e9ac791996-06-06 18:38:27 +00001248 return wRet;
1249 }
Alexandre Julliard491502b1997-11-01 19:08:16 +00001250 return 0;
Alexandre Julliard1e9ac791996-06-06 18:38:27 +00001251}
1252
Alexandre Julliard85ed45e1998-08-22 19:03:56 +00001253/***********************************************************************
1254 * SetICMMode (GDI32.318)
1255 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001256INT WINAPI SetICMMode(HDC hdc, INT iEnableICM)
Alexandre Julliard85ed45e1998-08-22 19:03:56 +00001257{
1258/*FIXME Asuming that ICM is always off, and cannot be turned on */
1259 if (iEnableICM == ICM_OFF) return ICM_OFF;
1260 if (iEnableICM == ICM_ON) return 0;
1261 if (iEnableICM == ICM_QUERY) return ICM_OFF;
1262 return 0;
1263}
1264
1265
1266/***********************************************************************
1267 * GetColorSpace (GDI32.165)
1268 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001269HCOLORSPACE WINAPI GetColorSpace(HDC hdc)
Alexandre Julliard85ed45e1998-08-22 19:03:56 +00001270{
1271/*FIXME Need to to whatever GetColorSpace actually does */
1272 return 0;
1273}
Alexandre Julliardd30dfd21998-09-27 18:28:36 +00001274
1275/***********************************************************************
Gerard Patel82f37be2000-01-15 22:11:21 +00001276 * CreateColorSpaceA (GDI32.???)
1277 */
1278HCOLORSPACE WINAPI CreateColorSpaceA( LPLOGCOLORSPACEA lpLogColorSpace )
1279{
1280 FIXME( "stub\n" );
1281 return 0;
1282}
1283
1284/***********************************************************************
1285 * CreateColorSpaceW (GDI32.???)
1286 */
1287HCOLORSPACE WINAPI CreateColorSpaceW( LPLOGCOLORSPACEW lpLogColorSpace )
1288{
1289 FIXME( "stub\n" );
1290 return 0;
1291}
1292
1293/***********************************************************************
1294 * DeleteColorSpace (GDI32.???)
1295 */
1296BOOL WINAPI DeleteColorSpace( HCOLORSPACE hColorSpace )
1297{
1298 FIXME( "stub\n" );
1299
Alexandre Julliard07e42132000-03-19 21:19:21 +00001300 return TRUE;
Gerard Patel82f37be2000-01-15 22:11:21 +00001301}
1302
1303/***********************************************************************
1304 * SetColorSpace (GDI32.???)
1305 */
1306HCOLORSPACE WINAPI SetColorSpace( HDC hDC, HCOLORSPACE hColorSpace )
1307{
1308 FIXME( "stub\n" );
1309
1310 return hColorSpace;
1311}
1312
1313/***********************************************************************
Alexandre Julliardd30dfd21998-09-27 18:28:36 +00001314 * GetBoundsRect16 (GDI.194)
1315 */
1316UINT16 WINAPI GetBoundsRect16(HDC16 hdc, LPRECT16 rect, UINT16 flags)
1317{
Ulrich Weigande62cbca1998-11-26 15:06:47 +00001318 return DCB_RESET | DCB_DISABLE; /* bounding rectangle always empty and disabled*/
Alexandre Julliardd30dfd21998-09-27 18:28:36 +00001319}
1320
Ulrich Weigandd4663661998-10-11 18:47:02 +00001321/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +00001322 * GetBoundsRect (GDI32.147)
Paul Quinn1beaae51998-12-15 15:38:36 +00001323 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001324UINT WINAPI GetBoundsRect(HDC hdc, LPRECT rect, UINT flags)
Paul Quinn1beaae51998-12-15 15:38:36 +00001325{
Alexandre Julliard15657091999-05-23 10:25:25 +00001326 FIXME("(): stub\n");
Paul Quinn1beaae51998-12-15 15:38:36 +00001327 return DCB_RESET; /* bounding rectangle always empty */
1328}
1329
1330/***********************************************************************
Ulrich Weigandd4663661998-10-11 18:47:02 +00001331 * SetBoundsRect16 (GDI.193)
1332 */
François Gouget241c7301998-10-28 10:47:09 +00001333UINT16 WINAPI SetBoundsRect16(HDC16 hdc, const RECT16* rect, UINT16 flags)
Ulrich Weigandd4663661998-10-11 18:47:02 +00001334{
Ulrich Weigande62cbca1998-11-26 15:06:47 +00001335 if ( (flags & DCB_ACCUMULATE) || (flags & DCB_ENABLE) )
Alexandre Julliard15657091999-05-23 10:25:25 +00001336 FIXME("(%04x, %p, %04x): stub\n", hdc, rect, flags );
Ulrich Weigande62cbca1998-11-26 15:06:47 +00001337
1338 return DCB_RESET | DCB_DISABLE; /* bounding rectangle always empty and disabled*/
Ulrich Weigandd4663661998-10-11 18:47:02 +00001339}
1340
Alexandre Julliard0c0e3be1998-12-10 15:49:22 +00001341/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +00001342 * SetBoundsRect (GDI32.307)
Alexandre Julliard0c0e3be1998-12-10 15:49:22 +00001343 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001344UINT WINAPI SetBoundsRect(HDC hdc, const RECT* rect, UINT flags)
Alexandre Julliard0c0e3be1998-12-10 15:49:22 +00001345{
Alexandre Julliard15657091999-05-23 10:25:25 +00001346 FIXME("(): stub\n");
Alexandre Julliard0c0e3be1998-12-10 15:49:22 +00001347 return DCB_DISABLE; /* bounding rectangle always empty */
1348}
1349
Alexandre Julliard8da12c41999-01-17 16:55:11 +00001350/***********************************************************************
1351 * Death (GDI.121)
1352 *
1353 * Disables GDI, switches back to text mode.
1354 * We don't have to do anything here,
1355 * just let console support handle everything
1356 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001357void WINAPI Death16(HDC16 hDC)
Alexandre Julliard8da12c41999-01-17 16:55:11 +00001358{
Alexandre Julliard15657091999-05-23 10:25:25 +00001359 MESSAGE("Death(%04x) called. Application enters text mode...\n", hDC);
Alexandre Julliard8da12c41999-01-17 16:55:11 +00001360}
1361
1362/***********************************************************************
1363 * Resurrection (GDI.122)
1364 *
1365 * Restores GDI functionality
1366 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001367void WINAPI Resurrection16(HDC16 hDC,
Alexandre Julliard8da12c41999-01-17 16:55:11 +00001368 WORD w1, WORD w2, WORD w3, WORD w4, WORD w5, WORD w6)
1369{
Alexandre Julliard15657091999-05-23 10:25:25 +00001370 MESSAGE("Resurrection(%04x, %04x, %04x, %04x, %04x, %04x, %04x) called. Application left text mode.\n", hDC, w1, w2, w3, w4, w5, w6);
Alexandre Julliard8da12c41999-01-17 16:55:11 +00001371}
Huw D M Daviesf64e0d71999-11-21 00:49:50 +00001372
1373/***********************************************************************
1374 * GetLayout (GDI32.321)
1375 *
1376 * Gets left->right or right->left text layout flags of a dc.
1377 * win98 just returns 0 and sets ERROR_CALL_NOT_IMPLEMENTED so we do the same
1378 *
1379 */
1380DWORD WINAPI GetLayout(HDC hdc)
1381{
1382 FIXME("(%08x): stub\n", hdc);
1383 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1384 return 0;
1385}
1386
1387/***********************************************************************
1388 * SetLayout (GDI32.450)
1389 *
1390 * Sets left->right or right->left text layout flags of a dc.
1391 * win98 just returns 0 and sets ERROR_CALL_NOT_IMPLEMENTED so we do the same
1392 *
1393 */
1394DWORD WINAPI SetLayout(HDC hdc, DWORD layout)
1395{
1396 FIXME("(%08x,%08lx): stub\n", hdc, layout);
1397 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1398 return 0;
1399}