2 * GDI Device Context functions
4 * Copyright 1993 Alexandre Julliard
19 extern void CLIPPING_UpdateGCRegion( DC
* dc
); /* objects/clipping.c */
21 /* Default DC values */
22 static const WIN_DC_INFO DC_defaultValues
=
29 STOCK_BLACK_PEN
, /* hPen */
30 STOCK_WHITE_BRUSH
, /* hBrush */
31 STOCK_SYSTEM_FONT
, /* hFont */
35 STOCK_DEFAULT_PALETTE
, /* hPalette */
36 R2_COPYPEN
, /* ROPmode */
37 ALTERNATE
, /* polyFillMode */
38 BLACKONWHITE
, /* stretchBltMode */
39 ABSOLUTE
, /* relAbsMode */
40 OPAQUE
, /* backgroundMode */
41 RGB( 255, 255, 255 ), /* backgroundColor */
42 RGB( 0, 0, 0 ), /* textColor */
43 0, /* backgroundPixel */
47 TA_LEFT
| TA_TOP
| TA_NOUPDATECP
, /* textAlign */
49 0, /* breakTotalExtra */
54 MM_TEXT
, /* MapMode */
69 /* ROP code to GC function conversion */
70 const int DC_XROPfunction
[16] =
72 GXclear
, /* R2_BLACK */
73 GXnor
, /* R2_NOTMERGEPEN */
74 GXandInverted
, /* R2_MASKNOTPEN */
75 GXcopyInverted
, /* R2_NOTCOPYPEN */
76 GXandReverse
, /* R2_MASKPENNOT */
77 GXinvert
, /* R2_NOT */
78 GXxor
, /* R2_XORPEN */
79 GXnand
, /* R2_NOTMASKPEN */
80 GXand
, /* R2_MASKPEN */
81 GXequiv
, /* R2_NOTXORPEN */
83 GXorInverted
, /* R2_MERGENOTPEN */
84 GXcopy
, /* R2_COPYPEN */
85 GXorReverse
, /* R2_MERGEPENNOT */
86 GXor
, /* R2_MERGEPEN */
91 /***********************************************************************
94 * Fill the device caps structure.
96 void DC_FillDevCaps( DeviceCaps
* caps
)
98 caps
->version
= 0x300;
99 caps
->technology
= DT_RASDISPLAY
;
100 caps
->horzSize
= WidthMMOfScreen(screen
) * screenWidth
/ WidthOfScreen(screen
);
101 caps
->vertSize
= HeightMMOfScreen(screen
) * screenHeight
/ HeightOfScreen(screen
);
102 caps
->horzRes
= screenWidth
;
103 caps
->vertRes
= screenHeight
;
104 caps
->bitsPixel
= screenDepth
;
106 caps
->numBrushes
= 16+6; /* 16 solid + 6 hatched brushes */
107 caps
->numPens
= 16; /* 16 solid pens */
108 caps
->numMarkers
= 0;
110 caps
->numColors
= 100;
111 caps
->pdeviceSize
= 0;
112 caps
->curveCaps
= CC_CIRCLES
| CC_PIE
| CC_CHORD
| CC_ELLIPSES
|
113 CC_WIDE
| CC_STYLED
| CC_WIDESTYLED
|
114 CC_INTERIORS
| CC_ROUNDRECT
;
115 caps
->lineCaps
= LC_POLYLINE
| LC_MARKER
| LC_POLYMARKER
| LC_WIDE
|
116 LC_STYLED
| LC_WIDESTYLED
| LC_INTERIORS
;
117 caps
->polygonalCaps
= PC_POLYGON
| PC_RECTANGLE
| PC_WINDPOLYGON
|
118 PC_SCANLINE
| PC_WIDE
| PC_STYLED
|
119 PC_WIDESTYLED
| PC_INTERIORS
;
120 caps
->textCaps
= TC_OP_CHARACTER
| TC_OP_STROKE
| TC_CP_STROKE
|
121 TC_IA_ABLE
| TC_UA_ABLE
| TC_SO_ABLE
| TC_RA_ABLE
;
122 caps
->clipCaps
= CP_REGION
;
123 caps
->rasterCaps
= RC_BITBLT
| RC_BANDING
| RC_SCALING
| RC_BITMAP64
|
124 RC_DI_BITMAP
| RC_DIBTODEV
| RC_BIGFONT
|
125 RC_STRETCHBLT
| RC_STRETCHDIB
| RC_DEVBITS
;
127 if( !(COLOR_GetSystemPaletteFlags() & COLOR_VIRTUAL
) )
128 caps
->rasterCaps
|= RC_PALETTE
;
130 caps
->aspectX
= 36; /* ?? */
131 caps
->aspectY
= 36; /* ?? */
133 caps
->logPixelsX
= (int)(caps
->horzRes
* 25.4 / caps
->horzSize
);
134 caps
->logPixelsY
= (int)(caps
->vertRes
* 25.4 / caps
->vertSize
);
135 caps
->sizePalette
= (caps
->rasterCaps
& RC_PALETTE
)
136 ? DefaultVisual(display
,DefaultScreen(display
))->map_entries
138 caps
->numReserved
= 0;
143 /***********************************************************************
146 DC
*DC_AllocDC( const DC_FUNCTIONS
*funcs
)
151 if (!(hdc
= GDI_AllocObject( sizeof(DC
), DC_MAGIC
))) return NULL
;
152 dc
= (DC
*) GDI_HEAP_LIN_ADDR( hdc
);
161 memcpy( &dc
->w
, &DC_defaultValues
, sizeof(DC_defaultValues
) );
166 /***********************************************************************
169 DC
*DC_GetDCPtr( HDC32 hdc
)
171 GDIOBJHDR
*ptr
= (GDIOBJHDR
*)GDI_HEAP_LIN_ADDR( hdc
);
172 if ((ptr
->wMagic
== DC_MAGIC
) || (ptr
->wMagic
== METAFILE_DC_MAGIC
))
178 /***********************************************************************
181 * Setup device-specific DC values for a newly created DC.
183 void DC_InitDC( DC
* dc
)
185 RealizeDefaultPalette( dc
->hSelf
);
186 SetTextColor( dc
->hSelf
, dc
->w
.textColor
);
187 SetBkColor( dc
->hSelf
, dc
->w
.backgroundColor
);
188 SelectObject32( dc
->hSelf
, dc
->w
.hPen
);
189 SelectObject32( dc
->hSelf
, dc
->w
.hBrush
);
190 SelectObject32( dc
->hSelf
, dc
->w
.hFont
);
191 CLIPPING_UpdateGCRegion( dc
);
195 /***********************************************************************
196 * DC_SetupGCForPatBlt
198 * Setup the GC for a PatBlt operation using current brush.
199 * If fMapColors is TRUE, X pixels are mapped to Windows colors.
200 * Return FALSE if brush is BS_NULL, TRUE otherwise.
202 BOOL32
DC_SetupGCForPatBlt( DC
* dc
, GC gc
, BOOL32 fMapColors
)
208 if (dc
->u
.x
.brush
.style
== BS_NULL
) return FALSE
;
209 if (dc
->u
.x
.brush
.pixel
== -1)
211 /* Special case used for monochrome pattern brushes.
212 * We need to swap foreground and background because
213 * Windows does it the wrong way...
215 val
.foreground
= dc
->w
.backgroundPixel
;
216 val
.background
= dc
->w
.textPixel
;
220 val
.foreground
= dc
->u
.x
.brush
.pixel
;
221 val
.background
= dc
->w
.backgroundPixel
;
223 if (fMapColors
&& COLOR_PixelToPalette
)
225 val
.foreground
= COLOR_PixelToPalette
[val
.foreground
];
226 val
.background
= COLOR_PixelToPalette
[val
.background
];
229 if (dc
->w
.flags
& DC_DIRTY
) CLIPPING_UpdateGCRegion(dc
);
231 val
.function
= DC_XROPfunction
[dc
->w
.ROPmode
-1];
232 val
.fill_style
= dc
->u
.x
.brush
.fillStyle
;
233 switch(val
.fill_style
)
236 case FillOpaqueStippled
:
237 if (dc
->w
.backgroundMode
==OPAQUE
) val
.fill_style
= FillOpaqueStippled
;
238 val
.stipple
= dc
->u
.x
.brush
.pixmap
;
243 if (fMapColors
&& COLOR_PixelToPalette
)
247 pixmap
= XCreatePixmap( display
, rootWindow
, 8, 8, screenDepth
);
248 image
= XGetImage( display
, dc
->u
.x
.brush
.pixmap
, 0, 0, 8, 8,
249 AllPlanes
, ZPixmap
);
250 for (y
= 0; y
< 8; y
++)
251 for (x
= 0; x
< 8; x
++)
252 XPutPixel( image
, x
, y
,
253 COLOR_PixelToPalette
[XGetPixel( image
, x
, y
)] );
254 XPutImage( display
, pixmap
, gc
, image
, 0, 0, 0, 0, 8, 8 );
255 XDestroyImage( image
);
258 else val
.tile
= dc
->u
.x
.brush
.pixmap
;
266 val
.ts_x_origin
= dc
->w
.DCOrgX
+ dc
->w
.brushOrgX
;
267 val
.ts_y_origin
= dc
->w
.DCOrgY
+ dc
->w
.brushOrgY
;
268 val
.fill_rule
= (dc
->w
.polyFillMode
==WINDING
) ? WindingRule
: EvenOddRule
;
269 XChangeGC( display
, gc
,
270 GCFunction
| GCForeground
| GCBackground
| GCFillStyle
|
271 GCFillRule
| GCTileStipXOrigin
| GCTileStipYOrigin
| mask
,
273 if (pixmap
) XFreePixmap( display
, pixmap
);
278 /***********************************************************************
281 * Setup dc->u.x.gc for drawing operations using current brush.
282 * Return FALSE if brush is BS_NULL, TRUE otherwise.
284 BOOL32
DC_SetupGCForBrush( DC
* dc
)
286 return DC_SetupGCForPatBlt( dc
, dc
->u
.x
.gc
, FALSE
);
290 /***********************************************************************
293 * Setup dc->u.x.gc for drawing operations using current pen.
294 * Return FALSE if pen is PS_NULL, TRUE otherwise.
296 BOOL32
DC_SetupGCForPen( DC
* dc
)
300 if (dc
->u
.x
.pen
.style
== PS_NULL
) return FALSE
;
302 if (dc
->w
.flags
& DC_DIRTY
) CLIPPING_UpdateGCRegion(dc
);
304 if ((screenDepth
<= 8) && /* FIXME: Should check for palette instead */
305 ((dc
->w
.ROPmode
== R2_BLACK
) || (dc
->w
.ROPmode
== R2_WHITE
)))
307 val
.function
= GXcopy
;
308 val
.foreground
= COLOR_ToPhysical( NULL
, (dc
->w
.ROPmode
== R2_BLACK
) ?
309 RGB(0,0,0) : RGB(255,255,255) );
313 val
.function
= DC_XROPfunction
[dc
->w
.ROPmode
-1];
314 val
.foreground
= dc
->u
.x
.pen
.pixel
;
316 val
.background
= dc
->w
.backgroundPixel
;
317 val
.fill_style
= FillSolid
;
318 if ((dc
->u
.x
.pen
.style
!=PS_SOLID
) && (dc
->u
.x
.pen
.style
!=PS_INSIDEFRAME
))
320 XSetDashes( display
, dc
->u
.x
.gc
, 0,
321 dc
->u
.x
.pen
.dashes
, dc
->u
.x
.pen
.dash_len
);
322 val
.line_style
= (dc
->w
.backgroundMode
== OPAQUE
) ?
323 LineDoubleDash
: LineOnOffDash
;
325 else val
.line_style
= LineSolid
;
326 val
.line_width
= dc
->u
.x
.pen
.width
;
327 val
.cap_style
= CapRound
;
328 val
.join_style
= JoinMiter
;
329 XChangeGC( display
, dc
->u
.x
.gc
,
330 GCFunction
| GCForeground
| GCBackground
| GCLineWidth
|
331 GCLineStyle
| GCCapStyle
| GCJoinStyle
| GCFillStyle
, &val
);
336 /***********************************************************************
339 * Setup dc->u.x.gc for text drawing operations.
340 * Return FALSE if the font is null, TRUE otherwise.
342 BOOL32
DC_SetupGCForText( DC
* dc
)
346 if (!dc
->u
.x
.font
.fstruct
)
348 fprintf( stderr
, "DC_SetupGCForText: fstruct is NULL. Please report this\n" );
352 if (dc
->w
.flags
& DC_DIRTY
) CLIPPING_UpdateGCRegion(dc
);
354 val
.function
= GXcopy
; /* Text is always GXcopy */
355 val
.foreground
= dc
->w
.textPixel
;
356 val
.background
= dc
->w
.backgroundPixel
;
357 val
.fill_style
= FillSolid
;
358 val
.font
= dc
->u
.x
.font
.fstruct
->fid
;
359 XChangeGC( display
, dc
->u
.x
.gc
,
360 GCFunction
| GCForeground
| GCBackground
| GCFillStyle
|
366 /***********************************************************************
367 * GetDCState (GDI.179)
369 HDC16
GetDCState( HDC16 hdc
)
374 if (!(dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
))) return 0;
375 if (!(handle
= GDI_AllocObject( sizeof(DC
), DC_MAGIC
))) return 0;
376 newdc
= (DC
*) GDI_HEAP_LIN_ADDR( handle
);
378 dprintf_dc(stddeb
, "GetDCState(%04x): returning %04x\n", hdc
, handle
);
380 memset( &newdc
->u
.x
, 0, sizeof(newdc
->u
.x
) );
381 memcpy( &newdc
->w
, &dc
->w
, sizeof(dc
->w
) );
383 newdc
->hSelf
= (HDC32
)handle
;
384 newdc
->saveLevel
= 0;
385 newdc
->w
.flags
|= DC_SAVED
;
387 newdc
->w
.hGCClipRgn
= 0;
388 newdc
->w
.hVisRgn
= CreateRectRgn32( 0, 0, 0, 0 );
389 CombineRgn32( newdc
->w
.hVisRgn
, dc
->w
.hVisRgn
, 0, RGN_COPY
);
392 newdc
->w
.hClipRgn
= CreateRectRgn32( 0, 0, 0, 0 );
393 CombineRgn32( newdc
->w
.hClipRgn
, dc
->w
.hClipRgn
, 0, RGN_COPY
);
399 /***********************************************************************
400 * SetDCState (GDI.180)
402 void SetDCState( HDC16 hdc
, HDC16 hdcs
)
406 if (!(dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
))) return;
407 if (!(dcs
= (DC
*) GDI_GetObjPtr( hdcs
, DC_MAGIC
))) return;
408 if (!dcs
->w
.flags
& DC_SAVED
) return;
409 dprintf_dc(stddeb
, "SetDCState: %04x %04x\n", hdc
, hdcs
);
411 dc
->w
.flags
= dcs
->w
.flags
& ~DC_SAVED
;
412 dc
->w
.devCaps
= dcs
->w
.devCaps
;
413 dc
->w
.hFirstBitmap
= dcs
->w
.hFirstBitmap
;
414 dc
->w
.hDevice
= dcs
->w
.hDevice
;
415 dc
->w
.ROPmode
= dcs
->w
.ROPmode
;
416 dc
->w
.polyFillMode
= dcs
->w
.polyFillMode
;
417 dc
->w
.stretchBltMode
= dcs
->w
.stretchBltMode
;
418 dc
->w
.relAbsMode
= dcs
->w
.relAbsMode
;
419 dc
->w
.backgroundMode
= dcs
->w
.backgroundMode
;
420 dc
->w
.backgroundColor
= dcs
->w
.backgroundColor
;
421 dc
->w
.textColor
= dcs
->w
.textColor
;
422 dc
->w
.backgroundPixel
= dcs
->w
.backgroundPixel
;
423 dc
->w
.textPixel
= dcs
->w
.textPixel
;
424 dc
->w
.brushOrgX
= dcs
->w
.brushOrgX
;
425 dc
->w
.brushOrgY
= dcs
->w
.brushOrgY
;
426 dc
->w
.textAlign
= dcs
->w
.textAlign
;
427 dc
->w
.charExtra
= dcs
->w
.charExtra
;
428 dc
->w
.breakTotalExtra
= dcs
->w
.breakTotalExtra
;
429 dc
->w
.breakCount
= dcs
->w
.breakCount
;
430 dc
->w
.breakExtra
= dcs
->w
.breakExtra
;
431 dc
->w
.breakRem
= dcs
->w
.breakRem
;
432 dc
->w
.MapMode
= dcs
->w
.MapMode
;
433 dc
->w
.DCOrgX
= dcs
->w
.DCOrgX
;
434 dc
->w
.DCOrgY
= dcs
->w
.DCOrgY
;
435 dc
->w
.CursPosX
= dcs
->w
.CursPosX
;
436 dc
->w
.CursPosY
= dcs
->w
.CursPosY
;
437 dc
->w
.WndOrgX
= dcs
->w
.WndOrgX
;
438 dc
->w
.WndOrgY
= dcs
->w
.WndOrgY
;
439 dc
->w
.WndExtX
= dcs
->w
.WndExtX
;
440 dc
->w
.WndExtY
= dcs
->w
.WndExtY
;
441 dc
->w
.VportOrgX
= dcs
->w
.VportOrgX
;
442 dc
->w
.VportOrgY
= dcs
->w
.VportOrgY
;
443 dc
->w
.VportExtX
= dcs
->w
.VportExtX
;
444 dc
->w
.VportExtY
= dcs
->w
.VportExtY
;
446 if (!(dc
->w
.flags
& DC_MEMORY
)) dc
->w
.bitsPerPixel
= dcs
->w
.bitsPerPixel
;
447 CombineRgn32( dc
->w
.hVisRgn
, dcs
->w
.hVisRgn
, 0, RGN_COPY
);
448 SelectClipRgn32( hdc
, dcs
->w
.hClipRgn
);
449 SelectObject32( hdc
, dcs
->w
.hBitmap
);
450 SelectObject32( hdc
, dcs
->w
.hBrush
);
451 SelectObject32( hdc
, dcs
->w
.hFont
);
452 SelectObject32( hdc
, dcs
->w
.hPen
);
453 GDISelectPalette( hdc
, dcs
->w
.hPalette
, FALSE
);
457 /***********************************************************************
460 int SaveDC( HDC16 hdc
)
465 dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
468 dc
= (DC
*)GDI_GetObjPtr(hdc
, METAFILE_DC_MAGIC
);
470 MF_MetaParam0(dc
, META_SAVEDC
);
473 if (!(hdcs
= GetDCState( hdc
))) return 0;
474 dcs
= (DC
*) GDI_HEAP_LIN_ADDR( hdcs
);
475 dcs
->header
.hNext
= dc
->header
.hNext
;
476 dc
->header
.hNext
= hdcs
;
477 dprintf_dc(stddeb
, "SaveDC(%04x): returning %d\n", hdc
, dc
->saveLevel
+1 );
478 return ++dc
->saveLevel
;
482 /***********************************************************************
485 BOOL
RestoreDC( HDC16 hdc
, short level
)
489 dprintf_dc(stddeb
, "RestoreDC: %04x %d\n", hdc
, level
);
490 dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
493 dc
= (DC
*)GDI_GetObjPtr(hdc
, METAFILE_DC_MAGIC
);
494 if (!dc
) return FALSE
;
495 if (level
!= -1) return FALSE
;
496 MF_MetaParam1(dc
, META_RESTOREDC
, level
);
499 if (level
== -1) level
= dc
->saveLevel
;
500 if ((level
< 1) || (level
> (short)dc
->saveLevel
)) return FALSE
;
502 while ((short)dc
->saveLevel
>= level
)
504 HDC16 hdcs
= dc
->header
.hNext
;
505 if (!(dcs
= (DC
*) GDI_GetObjPtr( hdcs
, DC_MAGIC
))) return FALSE
;
506 dc
->header
.hNext
= dcs
->header
.hNext
;
507 if ((short)--dc
->saveLevel
< level
) SetDCState( hdc
, hdcs
);
514 /***********************************************************************
517 HDC16
CreateDC( LPCSTR driver
, LPCSTR device
, LPCSTR output
, const DEVMODE
* initData
)
520 const DC_FUNCTIONS
*funcs
;
522 if (!(funcs
= DRIVER_FindDriver( driver
))) return 0;
523 if (!(dc
= DC_AllocDC( funcs
))) return 0;
526 dprintf_dc(stddeb
, "CreateDC(%s %s %s): returning %04x\n",
527 driver
, device
, output
, dc
->hSelf
);
529 if (dc
->funcs
->pCreateDC
&&
530 !dc
->funcs
->pCreateDC( dc
, driver
, device
, output
, initData
))
532 dprintf_dc( stddeb
, "CreateDC: creation aborted by device\n" );
533 GDI_HEAP_FREE( dc
->hSelf
);
542 /***********************************************************************
545 HDC16
CreateIC( LPCSTR driver
, LPCSTR device
, LPCSTR output
, const DEVMODE
* initData
)
547 /* Nothing special yet for ICs */
548 return CreateDC( driver
, device
, output
, initData
);
552 /***********************************************************************
553 * CreateCompatibleDC (GDI.52)
555 HDC16
CreateCompatibleDC( HDC16 hdc
)
559 const DC_FUNCTIONS
*funcs
;
561 if ((origDC
= (DC
*)GDI_GetObjPtr( hdc
, DC_MAGIC
))) funcs
= origDC
->funcs
;
562 else funcs
= DRIVER_FindDriver( "DISPLAY" );
563 if (!funcs
) return 0;
565 if (!(dc
= DC_AllocDC( funcs
))) return 0;
567 dprintf_dc(stddeb
, "CreateCompatibleDC(%04x): returning %04x\n",
570 /* Create default bitmap */
571 if (!(hbitmap
= CreateBitmap( 1, 1, 1, 1, NULL
)))
573 GDI_HEAP_FREE( dc
->hSelf
);
576 dc
->w
.flags
= DC_MEMORY
;
577 dc
->w
.bitsPerPixel
= 1;
578 dc
->w
.hBitmap
= hbitmap
;
579 dc
->w
.hFirstBitmap
= hbitmap
;
581 if (dc
->funcs
->pCreateDC
&&
582 !dc
->funcs
->pCreateDC( dc
, NULL
, NULL
, NULL
, NULL
))
584 dprintf_dc( stddeb
, "CreateDC: creation aborted by device\n" );
585 DeleteObject32( hbitmap
);
586 GDI_HEAP_FREE( dc
->hSelf
);
595 /***********************************************************************
598 BOOL
DeleteDC( HDC16 hdc
)
600 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
601 if (!dc
) return FALSE
;
603 dprintf_dc(stddeb
, "DeleteDC: %04x\n", hdc
);
605 while (dc
->saveLevel
)
608 HDC16 hdcs
= dc
->header
.hNext
;
609 if (!(dcs
= (DC
*) GDI_GetObjPtr( hdcs
, DC_MAGIC
))) break;
610 dc
->header
.hNext
= dcs
->header
.hNext
;
615 if (!(dc
->w
.flags
& DC_SAVED
))
617 SelectObject32( hdc
, STOCK_BLACK_PEN
);
618 SelectObject32( hdc
, STOCK_WHITE_BRUSH
);
619 SelectObject32( hdc
, STOCK_SYSTEM_FONT
);
620 if (dc
->w
.flags
& DC_MEMORY
) DeleteObject32( dc
->w
.hFirstBitmap
);
621 if (dc
->funcs
->pDeleteDC
) dc
->funcs
->pDeleteDC(dc
);
624 if (dc
->w
.hClipRgn
) DeleteObject32( dc
->w
.hClipRgn
);
625 if (dc
->w
.hVisRgn
) DeleteObject32( dc
->w
.hVisRgn
);
626 if (dc
->w
.hGCClipRgn
) DeleteObject32( dc
->w
.hGCClipRgn
);
628 return GDI_FreeObject( hdc
);
632 /***********************************************************************
635 HDC16
ResetDC( HDC16 hdc
, /* DEVMODE */ void *devmode
)
637 fprintf( stderr
, "ResetDC: empty stub!\n" );
642 /***********************************************************************
643 * GetDeviceCaps (GDI.80)
645 int GetDeviceCaps( HDC16 hdc
, WORD cap
)
647 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
650 if (cap
> sizeof(DeviceCaps
)-sizeof(WORD
)) return 0;
652 dprintf_dc(stddeb
, "GetDeviceCaps(%04x,%d): returning %d\n",
653 hdc
, cap
, *(WORD
*)(((char *)dc
->w
.devCaps
) + cap
) );
654 return *(WORD
*)(((char *)dc
->w
.devCaps
) + cap
);
658 /***********************************************************************
659 * SetBkColor (GDI.1) (GDI32.305)
661 COLORREF
SetBkColor( HDC32 hdc
, COLORREF color
)
664 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
667 dc
= (DC
*)GDI_GetObjPtr(hdc
, METAFILE_DC_MAGIC
);
668 if (!dc
) return 0x80000000;
669 MF_MetaParam2(dc
, META_SETBKCOLOR
, HIWORD(color
), LOWORD(color
));
673 oldColor
= dc
->w
.backgroundColor
;
674 dc
->w
.backgroundColor
= color
;
675 dc
->w
.backgroundPixel
= COLOR_ToPhysical( dc
, color
);
680 /***********************************************************************
681 * SetTextColor (GDI.9) (GDI32.338)
683 COLORREF
SetTextColor( HDC32 hdc
, COLORREF color
)
686 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
689 dc
= (DC
*)GDI_GetObjPtr(hdc
, METAFILE_DC_MAGIC
);
690 if (!dc
) return 0x80000000;
691 MF_MetaParam2(dc
, META_SETTEXTCOLOR
, HIWORD(color
), LOWORD(color
));
695 oldColor
= dc
->w
.textColor
;
696 dc
->w
.textColor
= color
;
697 dc
->w
.textPixel
= COLOR_ToPhysical( dc
, color
);
702 /***********************************************************************
703 * SetTextAlign (GDI.346)
705 WORD
SetTextAlign( HDC16 hdc
, WORD textAlign
)
708 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
711 if (!(dc
= (DC
*)GDI_GetObjPtr( hdc
, METAFILE_DC_MAGIC
))) return 0;
712 MF_MetaParam1( dc
, META_SETTEXTALIGN
, textAlign
);
715 prevAlign
= dc
->w
.textAlign
;
716 dc
->w
.textAlign
= textAlign
;
721 /***********************************************************************
724 DWORD
GetDCOrg( HDC16 hdc
)
727 int x
, y
, w
, h
, border
, depth
;
729 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
731 if (dc
->w
.flags
& DC_MEMORY
) return 0;
732 XGetGeometry( display
, dc
->u
.x
.drawable
, &root
,
733 &x
, &y
, &w
, &h
, &border
, &depth
);
734 return MAKELONG( dc
->w
.DCOrgX
+ (WORD
)x
, dc
->w
.DCOrgY
+ (WORD
)y
);
738 /***********************************************************************
741 DWORD
SetDCOrg( HDC16 hdc
, short x
, short y
)
744 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
746 prevOrg
= dc
->w
.DCOrgX
| (dc
->w
.DCOrgY
<< 16);
753 /***********************************************************************
754 * SetDCHook (GDI.190)
756 BOOL16
SetDCHook( HDC16 hdc
, FARPROC16 hookProc
, DWORD dwHookData
)
758 DC
*dc
= (DC
*)GDI_GetObjPtr( hdc
, DC_MAGIC
);
760 dprintf_dc( stddeb
, "SetDCHook: hookProc %08x, default is %08x\n",
761 (UINT32
)hookProc
, (UINT32
)DCHook
);
763 if (!dc
) return FALSE
;
764 dc
->hookProc
= hookProc
;
765 dc
->dwHookData
= dwHookData
;
770 /***********************************************************************
771 * GetDCHook (GDI.191)
773 DWORD
GetDCHook( HDC16 hdc
, FARPROC16
*phookProc
)
775 DC
*dc
= (DC
*)GDI_GetObjPtr( hdc
, DC_MAGIC
);
777 *phookProc
= dc
->hookProc
;
778 return dc
->dwHookData
;
782 /***********************************************************************
783 * SetHookFlags (GDI.192)
785 WORD
SetHookFlags(HDC16 hDC
, WORD flags
)
787 DC
* dc
= (DC
*)GDI_GetObjPtr( hDC
, DC_MAGIC
);
791 WORD wRet
= dc
->w
.flags
& DC_DIRTY
;
793 /* "Undocumented Windows" info is slightly
797 dprintf_dc(stddeb
,"SetHookFlags: hDC %04x, flags %04x\n",hDC
,flags
);
799 if( flags
& DCHF_INVALIDATEVISRGN
)
800 dc
->w
.flags
|= DC_DIRTY
;
801 else if( flags
& DCHF_VALIDATEVISRGN
|| !flags
)
802 dc
->w
.flags
&= ~DC_DIRTY
;