2 * GDI Device Context functions
4 * Copyright 1993 Alexandre Julliard
20 extern void CLIPPING_UpdateGCRegion( DC
* dc
); /* objects/clipping.c */
21 extern BOOL
DCHook( HDC
, WORD
, DWORD
, DWORD
); /* windows/dce.c */
23 /* Default DC values */
24 static const WIN_DC_INFO DC_defaultValues
=
34 STOCK_BLACK_PEN
, /* hPen */
35 STOCK_WHITE_BRUSH
, /* hBrush */
36 STOCK_SYSTEM_FONT
, /* hFont */
40 STOCK_DEFAULT_PALETTE
, /* hPalette */
41 R2_COPYPEN
, /* ROPmode */
42 ALTERNATE
, /* polyFillMode */
43 BLACKONWHITE
, /* stretchBltMode */
44 ABSOLUTE
, /* relAbsMode */
45 OPAQUE
, /* backgroundMode */
46 RGB( 255, 255, 255 ), /* backgroundColor */
47 RGB( 0, 0, 0 ), /* textColor */
48 0, /* backgroundPixel */
52 TA_LEFT
| TA_TOP
| TA_NOUPDATECP
, /* textAlign */
54 0, /* breakTotalExtra */
59 MM_TEXT
, /* MapMode */
74 /* ROP code to GC function conversion */
75 const int DC_XROPfunction
[16] =
77 GXclear
, /* R2_BLACK */
78 GXnor
, /* R2_NOTMERGEPEN */
79 GXandInverted
, /* R2_MASKNOTPEN */
80 GXcopyInverted
, /* R2_NOTCOPYPEN */
81 GXandReverse
, /* R2_MASKPENNOT */
82 GXinvert
, /* R2_NOT */
83 GXxor
, /* R2_XORPEN */
84 GXnand
, /* R2_NOTMASKPEN */
85 GXand
, /* R2_MASKPEN */
86 GXequiv
, /* R2_NOTXORPEN */
88 GXorInverted
, /* R2_MERGENOTPEN */
89 GXcopy
, /* R2_COPYPEN */
90 GXorReverse
, /* R2_MERGEPENNOT */
91 GXor
, /* R2_MERGEPEN */
96 /***********************************************************************
99 * Fill the device caps structure.
101 void DC_FillDevCaps( DeviceCaps
* caps
)
103 caps
->version
= 0x300;
104 caps
->technology
= DT_RASDISPLAY
;
105 caps
->horzSize
= WidthMMOfScreen(screen
) * screenWidth
/ WidthOfScreen(screen
);
106 caps
->vertSize
= HeightMMOfScreen(screen
) * screenHeight
/ HeightOfScreen(screen
);
107 caps
->horzRes
= screenWidth
;
108 caps
->vertRes
= screenHeight
;
109 caps
->bitsPixel
= screenDepth
;
111 caps
->numBrushes
= 16+6; /* 16 solid + 6 hatched brushes */
112 caps
->numPens
= 16; /* 16 solid pens */
113 caps
->numMarkers
= 0;
115 caps
->numColors
= 100;
116 caps
->pdeviceSize
= 0;
117 caps
->curveCaps
= CC_CIRCLES
| CC_PIE
| CC_CHORD
| CC_ELLIPSES
|
118 CC_WIDE
| CC_STYLED
| CC_WIDESTYLED
|
119 CC_INTERIORS
| CC_ROUNDRECT
;
120 caps
->lineCaps
= LC_POLYLINE
| LC_MARKER
| LC_POLYMARKER
| LC_WIDE
|
121 LC_STYLED
| LC_WIDESTYLED
| LC_INTERIORS
;
122 caps
->polygonalCaps
= PC_POLYGON
| PC_RECTANGLE
| PC_WINDPOLYGON
|
123 PC_SCANLINE
| PC_WIDE
| PC_STYLED
|
124 PC_WIDESTYLED
| PC_INTERIORS
;
125 caps
->textCaps
= TC_OP_CHARACTER
| TC_OP_STROKE
| TC_CP_STROKE
|
126 TC_IA_ABLE
| TC_UA_ABLE
| TC_SO_ABLE
| TC_RA_ABLE
;
127 caps
->clipCaps
= CP_REGION
;
128 caps
->rasterCaps
= RC_BITBLT
| RC_BANDING
| RC_SCALING
| RC_BITMAP64
|
129 RC_DI_BITMAP
| RC_DIBTODEV
| RC_BIGFONT
|
130 RC_STRETCHBLT
| RC_STRETCHDIB
| RC_DEVBITS
;
132 if( !(COLOR_GetSystemPaletteFlags() & COLOR_VIRTUAL
) )
133 caps
->rasterCaps
|= RC_PALETTE
;
135 caps
->aspectX
= 36; /* ?? */
136 caps
->aspectY
= 36; /* ?? */
138 caps
->logPixelsX
= (int)(caps
->horzRes
* 25.4 / caps
->horzSize
);
139 caps
->logPixelsY
= (int)(caps
->vertRes
* 25.4 / caps
->vertSize
);
140 caps
->sizePalette
= (caps
->rasterCaps
& RC_PALETTE
)
141 ? DefaultVisual(display
,DefaultScreen(display
))->map_entries
143 caps
->numReserved
= 0;
148 /***********************************************************************
151 * Setup device-specific DC values for a newly created DC.
153 void DC_InitDC( DC
* dc
)
155 RealizeDefaultPalette( dc
->hSelf
);
156 SetTextColor( dc
->hSelf
, dc
->w
.textColor
);
157 SetBkColor( dc
->hSelf
, dc
->w
.backgroundColor
);
158 SelectObject( dc
->hSelf
, dc
->w
.hPen
);
159 SelectObject( dc
->hSelf
, dc
->w
.hBrush
);
160 SelectObject( dc
->hSelf
, dc
->w
.hFont
);
161 CLIPPING_UpdateGCRegion( dc
);
165 /***********************************************************************
166 * DC_SetupGCForPatBlt
168 * Setup the GC for a PatBlt operation using current brush.
169 * If fMapColors is TRUE, X pixels are mapped to Windows colors.
170 * Return FALSE if brush is BS_NULL, TRUE otherwise.
172 BOOL
DC_SetupGCForPatBlt( DC
* dc
, GC gc
, BOOL fMapColors
)
178 if (dc
->u
.x
.brush
.style
== BS_NULL
) return FALSE
;
179 if (dc
->u
.x
.brush
.pixel
== -1)
181 /* Special case used for monochrome pattern brushes.
182 * We need to swap foreground and background because
183 * Windows does it the wrong way...
185 val
.foreground
= dc
->w
.backgroundPixel
;
186 val
.background
= dc
->w
.textPixel
;
190 val
.foreground
= dc
->u
.x
.brush
.pixel
;
191 val
.background
= dc
->w
.backgroundPixel
;
193 if (fMapColors
&& COLOR_PixelToPalette
)
195 val
.foreground
= COLOR_PixelToPalette
[val
.foreground
];
196 val
.background
= COLOR_PixelToPalette
[val
.background
];
199 if (dc
->w
.flags
& DC_DIRTY
) CLIPPING_UpdateGCRegion(dc
);
201 val
.function
= DC_XROPfunction
[dc
->w
.ROPmode
-1];
202 val
.fill_style
= dc
->u
.x
.brush
.fillStyle
;
203 switch(val
.fill_style
)
206 case FillOpaqueStippled
:
207 if (dc
->w
.backgroundMode
==OPAQUE
) val
.fill_style
= FillOpaqueStippled
;
208 val
.stipple
= dc
->u
.x
.brush
.pixmap
;
213 if (fMapColors
&& COLOR_PixelToPalette
)
217 pixmap
= XCreatePixmap( display
, rootWindow
, 8, 8, screenDepth
);
218 image
= XGetImage( display
, dc
->u
.x
.brush
.pixmap
, 0, 0, 8, 8,
219 AllPlanes
, ZPixmap
);
220 for (y
= 0; y
< 8; y
++)
221 for (x
= 0; x
< 8; x
++)
222 XPutPixel( image
, x
, y
,
223 COLOR_PixelToPalette
[XGetPixel( image
, x
, y
)] );
224 XPutImage( display
, pixmap
, gc
, image
, 0, 0, 0, 0, 8, 8 );
225 XDestroyImage( image
);
228 else val
.tile
= dc
->u
.x
.brush
.pixmap
;
236 val
.ts_x_origin
= dc
->w
.DCOrgX
+ dc
->w
.brushOrgX
;
237 val
.ts_y_origin
= dc
->w
.DCOrgY
+ dc
->w
.brushOrgY
;
238 val
.fill_rule
= (dc
->w
.polyFillMode
==WINDING
) ? WindingRule
: EvenOddRule
;
239 XChangeGC( display
, gc
,
240 GCFunction
| GCForeground
| GCBackground
| GCFillStyle
|
241 GCFillRule
| GCTileStipXOrigin
| GCTileStipYOrigin
| mask
,
243 if (pixmap
) XFreePixmap( display
, pixmap
);
248 /***********************************************************************
251 * Setup dc->u.x.gc for drawing operations using current brush.
252 * Return FALSE if brush is BS_NULL, TRUE otherwise.
254 BOOL
DC_SetupGCForBrush( DC
* dc
)
256 return DC_SetupGCForPatBlt( dc
, dc
->u
.x
.gc
, FALSE
);
260 /***********************************************************************
263 * Setup dc->u.x.gc for drawing operations using current pen.
264 * Return FALSE if pen is PS_NULL, TRUE otherwise.
266 BOOL
DC_SetupGCForPen( DC
* dc
)
270 if (dc
->u
.x
.pen
.style
== PS_NULL
) return FALSE
;
272 if (dc
->w
.flags
& DC_DIRTY
) CLIPPING_UpdateGCRegion(dc
);
274 if ((screenDepth
<= 8) && /* FIXME: Should check for palette instead */
275 ((dc
->w
.ROPmode
== R2_BLACK
) || (dc
->w
.ROPmode
== R2_WHITE
)))
277 val
.function
= GXcopy
;
278 val
.foreground
= COLOR_ToPhysical( NULL
, (dc
->w
.ROPmode
== R2_BLACK
) ?
279 RGB(0,0,0) : RGB(255,255,255) );
283 val
.function
= DC_XROPfunction
[dc
->w
.ROPmode
-1];
284 val
.foreground
= dc
->u
.x
.pen
.pixel
;
286 val
.background
= dc
->w
.backgroundPixel
;
287 val
.fill_style
= FillSolid
;
288 if ((dc
->u
.x
.pen
.style
!=PS_SOLID
) && (dc
->u
.x
.pen
.style
!=PS_INSIDEFRAME
))
290 XSetDashes( display
, dc
->u
.x
.gc
, 0,
291 dc
->u
.x
.pen
.dashes
, dc
->u
.x
.pen
.dash_len
);
292 val
.line_style
= (dc
->w
.backgroundMode
== OPAQUE
) ?
293 LineDoubleDash
: LineOnOffDash
;
295 else val
.line_style
= LineSolid
;
296 val
.line_width
= dc
->u
.x
.pen
.width
;
297 val
.cap_style
= CapRound
;
298 val
.join_style
= JoinMiter
;
299 XChangeGC( display
, dc
->u
.x
.gc
,
300 GCFunction
| GCForeground
| GCBackground
| GCLineWidth
|
301 GCLineStyle
| GCCapStyle
| GCJoinStyle
| GCFillStyle
, &val
);
306 /***********************************************************************
309 * Setup dc->u.x.gc for text drawing operations.
310 * Return FALSE if the font is null, TRUE otherwise.
312 BOOL
DC_SetupGCForText( DC
* dc
)
316 if (!dc
->u
.x
.font
.fstruct
)
318 fprintf( stderr
, "DC_SetupGCForText: fstruct is NULL. Please report this\n" );
322 if (dc
->w
.flags
& DC_DIRTY
) CLIPPING_UpdateGCRegion(dc
);
324 val
.function
= GXcopy
; /* Text is always GXcopy */
325 val
.foreground
= dc
->w
.textPixel
;
326 val
.background
= dc
->w
.backgroundPixel
;
327 val
.fill_style
= FillSolid
;
328 val
.font
= dc
->u
.x
.font
.fstruct
->fid
;
329 XChangeGC( display
, dc
->u
.x
.gc
,
330 GCFunction
| GCForeground
| GCBackground
| GCFillStyle
|
336 /***********************************************************************
339 BOOL
DC_CallHookProc(DC
* dc
, WORD code
, LPARAM lParam
)
342 FARPROC16 ptr
= GDI_GetDefDCHook();
344 dprintf_dc(stddeb
,"CallDCHook: code %04x\n", code
);
346 /* if 16-bit callback is, in fact, a thunk to DCHook simply call DCHook */
348 if( dc
->hookProc
&& !(dc
->w
.flags
& (DC_SAVED
| DC_MEMORY
)) )
349 bRet
= (dc
->hookProc
== ptr
) ?
350 DCHook(dc
->hSelf
, code
, dc
->dwHookData
, lParam
):
351 CallDCHookProc(dc
->hookProc
, dc
->hSelf
, code
, dc
->dwHookData
, lParam
);
356 /***********************************************************************
357 * GetDCState (GDI.179)
359 HDC
GetDCState( HDC hdc
)
364 if (!(dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
))) return 0;
365 if (!(handle
= GDI_AllocObject( sizeof(DC
), DC_MAGIC
))) return 0;
366 newdc
= (DC
*) GDI_HEAP_LIN_ADDR( handle
);
368 dprintf_dc(stddeb
, "GetDCState(%04x): returning %04x\n", hdc
, handle
);
370 memset( &newdc
->u
.x
, 0, sizeof(newdc
->u
.x
) );
371 memcpy( &newdc
->w
, &dc
->w
, sizeof(dc
->w
) );
372 memcpy( &newdc
->u
.x
.pen
, &dc
->u
.x
.pen
, sizeof(dc
->u
.x
.pen
) );
374 newdc
->hSelf
= (HDC
)handle
;
375 newdc
->saveLevel
= 0;
376 newdc
->w
.flags
|= DC_SAVED
;
378 newdc
->w
.hGCClipRgn
= 0;
379 newdc
->w
.hVisRgn
= CreateRectRgn( 0, 0, 0, 0 );
380 CombineRgn( newdc
->w
.hVisRgn
, dc
->w
.hVisRgn
, 0, RGN_COPY
);
383 newdc
->w
.hClipRgn
= CreateRectRgn( 0, 0, 0, 0 );
384 CombineRgn( newdc
->w
.hClipRgn
, dc
->w
.hClipRgn
, 0, RGN_COPY
);
390 /***********************************************************************
391 * SetDCState (GDI.180)
393 void SetDCState( HDC hdc
, HDC hdcs
)
396 HRGN hVisRgn
, hClipRgn
, hGCClipRgn
;
400 if (!(dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
))) return;
401 if (!(dcs
= (DC
*) GDI_GetObjPtr( hdcs
, DC_MAGIC
))) return;
402 if (!dcs
->w
.flags
& DC_SAVED
) return;
403 dprintf_dc(stddeb
, "SetDCState: %04x %04x\n", hdc
, hdcs
);
405 /* Save the regions, font & brush before overwriting everything */
406 hVisRgn
= dc
->w
.hVisRgn
;
407 hClipRgn
= dc
->w
.hClipRgn
;
408 hGCClipRgn
= dc
->w
.hGCClipRgn
;
410 hbrush
= dc
->w
.hBrush
;
411 memcpy( &dc
->w
, &dcs
->w
, sizeof(dc
->w
) );
412 memcpy( &dc
->u
.x
.pen
, &dcs
->u
.x
.pen
, sizeof(dc
->u
.x
.pen
) );
413 dc
->w
.flags
&= ~DC_SAVED
;
415 /* Restore the regions */
416 dc
->w
.hVisRgn
= hVisRgn
;
417 dc
->w
.hClipRgn
= hClipRgn
;
418 dc
->w
.hGCClipRgn
= hGCClipRgn
;
420 dc
->w
.hBrush
= hbrush
;
421 CombineRgn( dc
->w
.hVisRgn
, dcs
->w
.hVisRgn
, 0, RGN_COPY
);
422 SelectClipRgn( hdc
, dcs
->w
.hClipRgn
);
424 SelectObject( hdc
, dcs
->w
.hBrush
);
425 SelectObject( hdc
, dcs
->w
.hFont
);
429 /***********************************************************************
432 int SaveDC( HDC hdc
)
437 dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
440 dc
= (DC
*)GDI_GetObjPtr(hdc
, METAFILE_DC_MAGIC
);
442 MF_MetaParam0(dc
, META_SAVEDC
);
445 if (!(hdcs
= GetDCState( hdc
))) return 0;
446 dcs
= (DC
*) GDI_HEAP_LIN_ADDR( hdcs
);
447 dcs
->header
.hNext
= dc
->header
.hNext
;
448 dc
->header
.hNext
= hdcs
;
449 dprintf_dc(stddeb
, "SaveDC(%04x): returning %d\n", hdc
, dc
->saveLevel
+1 );
450 return ++dc
->saveLevel
;
454 /***********************************************************************
457 BOOL
RestoreDC( HDC hdc
, short level
)
461 dprintf_dc(stddeb
, "RestoreDC: %04x %d\n", hdc
, level
);
462 dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
465 dc
= (DC
*)GDI_GetObjPtr(hdc
, METAFILE_DC_MAGIC
);
466 if (!dc
) return FALSE
;
467 if (level
!= -1) return FALSE
;
468 MF_MetaParam1(dc
, META_RESTOREDC
, level
);
471 if (level
== -1) level
= dc
->saveLevel
;
472 if ((level
< 1) || (level
> (short)dc
->saveLevel
)) return FALSE
;
474 while ((short)dc
->saveLevel
>= level
)
476 HDC hdcs
= dc
->header
.hNext
;
477 if (!(dcs
= (DC
*) GDI_GetObjPtr( hdcs
, DC_MAGIC
))) return FALSE
;
478 dc
->header
.hNext
= dcs
->header
.hNext
;
479 if ((short)--dc
->saveLevel
< level
) SetDCState( hdc
, hdcs
);
486 /***********************************************************************
489 HDC
CreateDC( LPCSTR driver
, LPCSTR device
, LPCSTR output
, const DEVMODE
* initData
)
493 const DC_FUNCTIONS
*funcs
;
495 if (!(funcs
= DRIVER_FindDriver( driver
))) return 0;
497 handle
= GDI_AllocObject( sizeof(DC
), DC_MAGIC
);
498 if (!handle
) return 0;
499 dc
= (DC
*) GDI_HEAP_LIN_ADDR( handle
);
501 dprintf_dc(stddeb
, "CreateDC(%s %s %s): returning %04x\n",
502 driver
, device
, output
, handle
);
509 dc
->hookProc
= (SEGPTR
)0;
511 memcpy( &dc
->w
, &DC_defaultValues
, sizeof(DC_defaultValues
) );
514 if (dc
->funcs
->pCreateDC
&&
515 !dc
->funcs
->pCreateDC( dc
, driver
, device
, output
, initData
))
517 dprintf_dc( stddeb
, "CreateDC: creation aborted by device\n" );
518 GDI_HEAP_FREE( handle
);
528 /***********************************************************************
531 HDC
CreateIC( LPCSTR driver
, LPCSTR device
, LPCSTR output
, const DEVMODE
* initData
)
533 /* Nothing special yet for ICs */
534 return CreateDC( driver
, device
, output
, initData
);
538 /***********************************************************************
539 * CreateCompatibleDC (GDI.52)
541 HDC
CreateCompatibleDC( HDC hdc
)
546 const DC_FUNCTIONS
*funcs
;
548 if ((origDC
= (DC
*)GDI_GetObjPtr( hdc
, DC_MAGIC
))) funcs
= origDC
->funcs
;
549 else funcs
= DRIVER_FindDriver( "DISPLAY" );
550 if (!funcs
) return 0;
552 handle
= GDI_AllocObject( sizeof(DC
), DC_MAGIC
);
553 if (!handle
) return 0;
554 dc
= (DC
*) GDI_HEAP_LIN_ADDR( handle
);
556 dprintf_dc(stddeb
, "CreateCompatibleDC(%04x): returning %04x\n", hdc
, handle
);
558 /* Create default bitmap */
559 if (!(hbitmap
= CreateBitmap( 1, 1, 1, 1, NULL
)))
561 GDI_HEAP_FREE( handle
);
565 memcpy( &dc
->w
, &DC_defaultValues
, sizeof(DC_defaultValues
) );
572 dc
->hookProc
= (SEGPTR
)0;
573 dc
->w
.flags
= DC_MEMORY
;
574 dc
->w
.bitsPerPixel
= 1;
575 dc
->w
.hBitmap
= hbitmap
;
576 dc
->w
.hFirstBitmap
= hbitmap
;
578 if (dc
->funcs
->pCreateDC
&&
579 !dc
->funcs
->pCreateDC( dc
, NULL
, NULL
, NULL
, NULL
))
581 dprintf_dc( stddeb
, "CreateDC: creation aborted by device\n" );
582 DeleteObject( hbitmap
);
583 GDI_HEAP_FREE( handle
);
593 /***********************************************************************
596 BOOL
DeleteDC( HDC hdc
)
598 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
599 if (!dc
) return FALSE
;
601 dprintf_dc(stddeb
, "DeleteDC: %04x\n", hdc
);
603 while (dc
->saveLevel
)
606 HDC hdcs
= dc
->header
.hNext
;
607 if (!(dcs
= (DC
*) GDI_GetObjPtr( hdcs
, DC_MAGIC
))) break;
608 dc
->header
.hNext
= dcs
->header
.hNext
;
613 if (!(dc
->w
.flags
& DC_SAVED
))
615 SelectObject( hdc
, STOCK_BLACK_PEN
);
616 SelectObject( hdc
, STOCK_WHITE_BRUSH
);
617 SelectObject( hdc
, STOCK_SYSTEM_FONT
);
618 if (dc
->w
.flags
& DC_MEMORY
) DeleteObject( dc
->w
.hFirstBitmap
);
619 if (dc
->funcs
->pDeleteDC
) dc
->funcs
->pDeleteDC(dc
);
622 if (dc
->w
.hClipRgn
) DeleteObject( dc
->w
.hClipRgn
);
623 if (dc
->w
.hVisRgn
) DeleteObject( dc
->w
.hVisRgn
);
624 if (dc
->w
.hGCClipRgn
) DeleteObject( dc
->w
.hGCClipRgn
);
626 return GDI_FreeObject( hdc
);
630 /***********************************************************************
633 HDC
ResetDC( HDC hdc
, /* DEVMODE */ void *devmode
)
635 fprintf( stderr
, "ResetDC: empty stub!\n" );
640 /***********************************************************************
641 * GetDeviceCaps (GDI.80)
643 int GetDeviceCaps( HDC hdc
, WORD cap
)
645 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
648 if (cap
> sizeof(DeviceCaps
)-sizeof(WORD
)) return 0;
650 dprintf_dc(stddeb
, "GetDeviceCaps(%04x,%d): returning %d\n",
651 hdc
, cap
, *(WORD
*)(((char *)dc
->w
.devCaps
) + cap
) );
652 return *(WORD
*)(((char *)dc
->w
.devCaps
) + cap
);
656 /***********************************************************************
657 * SetBkColor (GDI.1) (GDI32.305)
659 COLORREF
SetBkColor( HDC32 hdc
, COLORREF color
)
662 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
665 dc
= (DC
*)GDI_GetObjPtr(hdc
, METAFILE_DC_MAGIC
);
666 if (!dc
) return 0x80000000;
667 MF_MetaParam2(dc
, META_SETBKCOLOR
, HIWORD(color
), LOWORD(color
));
671 oldColor
= dc
->w
.backgroundColor
;
672 dc
->w
.backgroundColor
= color
;
673 dc
->w
.backgroundPixel
= COLOR_ToPhysical( dc
, color
);
678 /***********************************************************************
679 * SetTextColor (GDI.9) (GDI32.338)
681 COLORREF
SetTextColor( HDC32 hdc
, COLORREF color
)
684 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
687 dc
= (DC
*)GDI_GetObjPtr(hdc
, METAFILE_DC_MAGIC
);
688 if (!dc
) return 0x80000000;
689 MF_MetaParam2(dc
, META_SETTEXTCOLOR
, HIWORD(color
), LOWORD(color
));
693 oldColor
= dc
->w
.textColor
;
694 dc
->w
.textColor
= color
;
695 dc
->w
.textPixel
= COLOR_ToPhysical( dc
, color
);
700 /***********************************************************************
701 * SetTextAlign (GDI.346)
703 WORD
SetTextAlign( HDC hdc
, WORD textAlign
)
706 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
709 if (!(dc
= (DC
*)GDI_GetObjPtr( hdc
, METAFILE_DC_MAGIC
))) return 0;
710 MF_MetaParam1( dc
, META_SETTEXTALIGN
, textAlign
);
713 prevAlign
= dc
->w
.textAlign
;
714 dc
->w
.textAlign
= textAlign
;
719 /***********************************************************************
722 DWORD
GetDCOrg( HDC hdc
)
725 int x
, y
, w
, h
, border
, depth
;
727 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
729 if (dc
->w
.flags
& DC_MEMORY
) return 0;
730 XGetGeometry( display
, dc
->u
.x
.drawable
, &root
,
731 &x
, &y
, &w
, &h
, &border
, &depth
);
732 return MAKELONG( dc
->w
.DCOrgX
+ (WORD
)x
, dc
->w
.DCOrgY
+ (WORD
)y
);
736 /***********************************************************************
739 DWORD
SetDCOrg( HDC hdc
, short x
, short y
)
742 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
744 prevOrg
= dc
->w
.DCOrgX
| (dc
->w
.DCOrgY
<< 16);
751 /***********************************************************************
752 * SetDCHook (GDI.190)
754 BOOL
SetDCHook( HDC hDC
, FARPROC16 hookProc
, DWORD dwHookData
)
756 DC
*dc
= (DC
*)GDI_GetObjPtr( hDC
, DC_MAGIC
);
758 dprintf_dc( stddeb
, "SetDCHook: hookProc %08x, default is %08x\n",
759 (unsigned)hookProc
,(unsigned)GDI_GetDefDCHook() );
761 if (!dc
) return FALSE
;
762 dc
->hookProc
= hookProc
;
763 dc
->dwHookData
= dwHookData
;
768 /***********************************************************************
769 * GetDCHook (GDI.191)
771 DWORD
GetDCHook( HDC hDC
, FARPROC16
*phookProc
)
773 DC
*dc
= (DC
*)GDI_GetObjPtr( hDC
, DC_MAGIC
);
775 *phookProc
= dc
->hookProc
;
776 return dc
->dwHookData
;
780 /***********************************************************************
781 * SetHookFlags (GDI.192)
783 WORD
SetHookFlags(HDC hDC
, WORD flags
)
785 DC
* dc
= (DC
*)GDI_GetObjPtr( hDC
, DC_MAGIC
);
789 WORD wRet
= dc
->w
.flags
& DC_DIRTY
;
791 /* "Undocumented Windows" info is slightly
795 dprintf_dc(stddeb
,"SetHookFlags: hDC %04x, flags %04x\n",hDC
,flags
);
797 if( flags
& DCHF_INVALIDATEVISRGN
)
798 dc
->w
.flags
|= DC_DIRTY
;
799 else if( flags
& DCHF_VALIDATEVISRGN
|| !flags
)
800 dc
->w
.flags
&= ~DC_DIRTY
;