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
=
32 STOCK_BLACK_PEN
, /* hPen */
33 STOCK_WHITE_BRUSH
, /* hBrush */
34 STOCK_SYSTEM_FONT
, /* hFont */
38 STOCK_DEFAULT_PALETTE
, /* hPalette */
39 R2_COPYPEN
, /* ROPmode */
40 ALTERNATE
, /* polyFillMode */
41 BLACKONWHITE
, /* stretchBltMode */
42 ABSOLUTE
, /* relAbsMode */
43 OPAQUE
, /* backgroundMode */
44 RGB( 255, 255, 255 ), /* backgroundColor */
45 RGB( 0, 0, 0 ), /* textColor */
46 0, /* backgroundPixel */
50 TA_LEFT
| TA_TOP
| TA_NOUPDATECP
, /* textAlign */
52 0, /* breakTotalExtra */
57 MM_TEXT
, /* MapMode */
72 /* ROP code to GC function conversion */
73 const int DC_XROPfunction
[16] =
75 GXclear
, /* R2_BLACK */
76 GXnor
, /* R2_NOTMERGEPEN */
77 GXandInverted
, /* R2_MASKNOTPEN */
78 GXcopyInverted
, /* R2_NOTCOPYPEN */
79 GXandReverse
, /* R2_MASKPENNOT */
80 GXinvert
, /* R2_NOT */
81 GXxor
, /* R2_XORPEN */
82 GXnand
, /* R2_NOTMASKPEN */
83 GXand
, /* R2_MASKPEN */
84 GXequiv
, /* R2_NOTXORPEN */
86 GXorInverted
, /* R2_MERGENOTPEN */
87 GXcopy
, /* R2_COPYPEN */
88 GXorReverse
, /* R2_MERGEPENNOT */
89 GXor
, /* R2_MERGEPEN */
94 /***********************************************************************
97 * Fill the device caps structure.
99 void DC_FillDevCaps( DeviceCaps
* caps
)
101 caps
->version
= 0x300;
102 caps
->technology
= DT_RASDISPLAY
;
103 caps
->horzSize
= WidthMMOfScreen(screen
) * screenWidth
/ WidthOfScreen(screen
);
104 caps
->vertSize
= HeightMMOfScreen(screen
) * screenHeight
/ HeightOfScreen(screen
);
105 caps
->horzRes
= screenWidth
;
106 caps
->vertRes
= screenHeight
;
107 caps
->bitsPixel
= screenDepth
;
109 caps
->numBrushes
= 16+6; /* 16 solid + 6 hatched brushes */
110 caps
->numPens
= 16; /* 16 solid pens */
111 caps
->numMarkers
= 0;
113 caps
->numColors
= 100;
114 caps
->pdeviceSize
= 0;
115 caps
->curveCaps
= CC_CIRCLES
| CC_PIE
| CC_CHORD
| CC_ELLIPSES
|
116 CC_WIDE
| CC_STYLED
| CC_WIDESTYLED
|
117 CC_INTERIORS
| CC_ROUNDRECT
;
118 caps
->lineCaps
= LC_POLYLINE
| LC_MARKER
| LC_POLYMARKER
| LC_WIDE
|
119 LC_STYLED
| LC_WIDESTYLED
| LC_INTERIORS
;
120 caps
->polygonalCaps
= PC_POLYGON
| PC_RECTANGLE
| PC_WINDPOLYGON
|
121 PC_SCANLINE
| PC_WIDE
| PC_STYLED
|
122 PC_WIDESTYLED
| PC_INTERIORS
;
123 caps
->textCaps
= TC_OP_CHARACTER
| TC_OP_STROKE
| TC_CP_STROKE
|
124 TC_IA_ABLE
| TC_UA_ABLE
| TC_SO_ABLE
| TC_RA_ABLE
;
125 caps
->clipCaps
= CP_REGION
;
126 caps
->rasterCaps
= RC_BITBLT
| RC_BANDING
| RC_SCALING
| RC_BITMAP64
|
127 RC_DI_BITMAP
| RC_DIBTODEV
| RC_BIGFONT
|
128 RC_STRETCHBLT
| RC_STRETCHDIB
| RC_DEVBITS
;
130 if( !(COLOR_GetSystemPaletteFlags() & COLOR_VIRTUAL
) )
131 caps
->rasterCaps
|= RC_PALETTE
;
133 caps
->aspectX
= 36; /* ?? */
134 caps
->aspectY
= 36; /* ?? */
136 caps
->logPixelsX
= (int)(caps
->horzRes
* 25.4 / caps
->horzSize
);
137 caps
->logPixelsY
= (int)(caps
->vertRes
* 25.4 / caps
->vertSize
);
138 caps
->sizePalette
= (caps
->rasterCaps
& RC_PALETTE
)
139 ? DefaultVisual(display
,DefaultScreen(display
))->map_entries
141 caps
->numReserved
= 0;
146 /***********************************************************************
149 * Setup device-specific DC values for a newly created DC.
151 void DC_InitDC( DC
* dc
)
153 RealizeDefaultPalette( dc
->hSelf
);
154 SetTextColor( dc
->hSelf
, dc
->w
.textColor
);
155 SetBkColor( dc
->hSelf
, dc
->w
.backgroundColor
);
156 SelectObject( dc
->hSelf
, dc
->w
.hPen
);
157 SelectObject( dc
->hSelf
, dc
->w
.hBrush
);
158 SelectObject( dc
->hSelf
, dc
->w
.hFont
);
159 CLIPPING_UpdateGCRegion( dc
);
163 /***********************************************************************
164 * DC_SetupGCForPatBlt
166 * Setup the GC for a PatBlt operation using current brush.
167 * If fMapColors is TRUE, X pixels are mapped to Windows colors.
168 * Return FALSE if brush is BS_NULL, TRUE otherwise.
170 BOOL
DC_SetupGCForPatBlt( DC
* dc
, GC gc
, BOOL fMapColors
)
176 if (dc
->u
.x
.brush
.style
== BS_NULL
) return FALSE
;
177 if (dc
->u
.x
.brush
.pixel
== -1)
179 /* Special case used for monochrome pattern brushes.
180 * We need to swap foreground and background because
181 * Windows does it the wrong way...
183 val
.foreground
= dc
->w
.backgroundPixel
;
184 val
.background
= dc
->w
.textPixel
;
188 val
.foreground
= dc
->u
.x
.brush
.pixel
;
189 val
.background
= dc
->w
.backgroundPixel
;
191 if (fMapColors
&& COLOR_PixelToPalette
)
193 val
.foreground
= COLOR_PixelToPalette
[val
.foreground
];
194 val
.background
= COLOR_PixelToPalette
[val
.background
];
197 if (dc
->w
.flags
& DC_DIRTY
) CLIPPING_UpdateGCRegion(dc
);
199 val
.function
= DC_XROPfunction
[dc
->w
.ROPmode
-1];
200 val
.fill_style
= dc
->u
.x
.brush
.fillStyle
;
201 switch(val
.fill_style
)
204 case FillOpaqueStippled
:
205 if (dc
->w
.backgroundMode
==OPAQUE
) val
.fill_style
= FillOpaqueStippled
;
206 val
.stipple
= dc
->u
.x
.brush
.pixmap
;
211 if (fMapColors
&& COLOR_PixelToPalette
)
215 pixmap
= XCreatePixmap( display
, rootWindow
, 8, 8, screenDepth
);
216 image
= XGetImage( display
, dc
->u
.x
.brush
.pixmap
, 0, 0, 8, 8,
217 AllPlanes
, ZPixmap
);
218 for (y
= 0; y
< 8; y
++)
219 for (x
= 0; x
< 8; x
++)
220 XPutPixel( image
, x
, y
,
221 COLOR_PixelToPalette
[XGetPixel( image
, x
, y
)] );
222 XPutImage( display
, pixmap
, gc
, image
, 0, 0, 0, 0, 8, 8 );
223 XDestroyImage( image
);
226 else val
.tile
= dc
->u
.x
.brush
.pixmap
;
234 val
.ts_x_origin
= dc
->w
.DCOrgX
+ dc
->w
.brushOrgX
;
235 val
.ts_y_origin
= dc
->w
.DCOrgY
+ dc
->w
.brushOrgY
;
236 val
.fill_rule
= (dc
->w
.polyFillMode
==WINDING
) ? WindingRule
: EvenOddRule
;
237 XChangeGC( display
, gc
,
238 GCFunction
| GCForeground
| GCBackground
| GCFillStyle
|
239 GCFillRule
| GCTileStipXOrigin
| GCTileStipYOrigin
| mask
,
241 if (pixmap
) XFreePixmap( display
, pixmap
);
246 /***********************************************************************
249 * Setup dc->u.x.gc for drawing operations using current brush.
250 * Return FALSE if brush is BS_NULL, TRUE otherwise.
252 BOOL
DC_SetupGCForBrush( DC
* dc
)
254 return DC_SetupGCForPatBlt( dc
, dc
->u
.x
.gc
, FALSE
);
258 /***********************************************************************
261 * Setup dc->u.x.gc for drawing operations using current pen.
262 * Return FALSE if pen is PS_NULL, TRUE otherwise.
264 BOOL
DC_SetupGCForPen( DC
* dc
)
268 if (dc
->u
.x
.pen
.style
== PS_NULL
) return FALSE
;
270 if (dc
->w
.flags
& DC_DIRTY
) CLIPPING_UpdateGCRegion(dc
);
272 if ((screenDepth
<= 8) && /* FIXME: Should check for palette instead */
273 ((dc
->w
.ROPmode
== R2_BLACK
) || (dc
->w
.ROPmode
== R2_WHITE
)))
275 val
.function
= GXcopy
;
276 val
.foreground
= COLOR_ToPhysical( NULL
, (dc
->w
.ROPmode
== R2_BLACK
) ?
277 RGB(0,0,0) : RGB(255,255,255) );
281 val
.function
= DC_XROPfunction
[dc
->w
.ROPmode
-1];
282 val
.foreground
= dc
->u
.x
.pen
.pixel
;
284 val
.background
= dc
->w
.backgroundPixel
;
285 val
.fill_style
= FillSolid
;
286 if ((dc
->u
.x
.pen
.style
!=PS_SOLID
) && (dc
->u
.x
.pen
.style
!=PS_INSIDEFRAME
))
288 XSetDashes( display
, dc
->u
.x
.gc
, 0,
289 dc
->u
.x
.pen
.dashes
, dc
->u
.x
.pen
.dash_len
);
290 val
.line_style
= (dc
->w
.backgroundMode
== OPAQUE
) ?
291 LineDoubleDash
: LineOnOffDash
;
293 else val
.line_style
= LineSolid
;
294 val
.line_width
= dc
->u
.x
.pen
.width
;
295 val
.cap_style
= CapRound
;
296 val
.join_style
= JoinBevel
;
297 XChangeGC( display
, dc
->u
.x
.gc
,
298 GCFunction
| GCForeground
| GCBackground
| GCLineWidth
|
299 GCLineStyle
| GCCapStyle
| GCJoinStyle
| GCFillStyle
, &val
);
304 /***********************************************************************
307 * Setup dc->u.x.gc for text drawing operations.
308 * Return FALSE if the font is null, TRUE otherwise.
310 BOOL
DC_SetupGCForText( DC
* dc
)
314 if (!dc
->u
.x
.font
.fstruct
)
316 fprintf( stderr
, "DC_SetupGCForText: fstruct is NULL. Please report this\n" );
320 if (dc
->w
.flags
& DC_DIRTY
) CLIPPING_UpdateGCRegion(dc
);
322 val
.function
= GXcopy
; /* Text is always GXcopy */
323 val
.foreground
= dc
->w
.textPixel
;
324 val
.background
= dc
->w
.backgroundPixel
;
325 val
.fill_style
= FillSolid
;
326 val
.font
= dc
->u
.x
.font
.fstruct
->fid
;
327 XChangeGC( display
, dc
->u
.x
.gc
,
328 GCFunction
| GCForeground
| GCBackground
| GCFillStyle
|
334 /***********************************************************************
337 BOOL
DC_CallHookProc(DC
* dc
, WORD code
, LPARAM lParam
)
340 FARPROC16 ptr
= GDI_GetDefDCHook();
342 dprintf_dc(stddeb
,"CallDCHook: code %04x\n", code
);
344 /* if 16-bit callback is, in fact, a thunk to DCHook simply call DCHook */
346 if( dc
->hookProc
&& !(dc
->w
.flags
& (DC_SAVED
| DC_MEMORY
)) )
347 bRet
= (dc
->hookProc
== ptr
) ?
348 DCHook(dc
->hSelf
, code
, dc
->dwHookData
, lParam
):
349 CallDCHookProc(dc
->hookProc
, dc
->hSelf
, code
, dc
->dwHookData
, lParam
);
354 /***********************************************************************
355 * GetDCState (GDI.179)
357 HDC
GetDCState( HDC hdc
)
362 if (!(dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
))) return 0;
363 if (!(handle
= GDI_AllocObject( sizeof(DC
), DC_MAGIC
))) return 0;
364 newdc
= (DC
*) GDI_HEAP_LIN_ADDR( handle
);
366 dprintf_dc(stddeb
, "GetDCState(%04x): returning %04x\n", hdc
, handle
);
368 memset( &newdc
->u
.x
, 0, sizeof(newdc
->u
.x
) );
369 memcpy( &newdc
->w
, &dc
->w
, sizeof(dc
->w
) );
370 memcpy( &newdc
->u
.x
.pen
, &dc
->u
.x
.pen
, sizeof(dc
->u
.x
.pen
) );
372 newdc
->hSelf
= (HDC
)handle
;
373 newdc
->saveLevel
= 0;
374 newdc
->w
.flags
|= DC_SAVED
;
376 newdc
->w
.hGCClipRgn
= 0;
377 newdc
->w
.hVisRgn
= CreateRectRgn( 0, 0, 0, 0 );
378 CombineRgn( newdc
->w
.hVisRgn
, dc
->w
.hVisRgn
, 0, RGN_COPY
);
381 newdc
->w
.hClipRgn
= CreateRectRgn( 0, 0, 0, 0 );
382 CombineRgn( newdc
->w
.hClipRgn
, dc
->w
.hClipRgn
, 0, RGN_COPY
);
388 /***********************************************************************
389 * SetDCState (GDI.180)
391 void SetDCState( HDC hdc
, HDC hdcs
)
394 HRGN hVisRgn
, hClipRgn
, hGCClipRgn
;
398 if (!(dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
))) return;
399 if (!(dcs
= (DC
*) GDI_GetObjPtr( hdcs
, DC_MAGIC
))) return;
400 if (!dcs
->w
.flags
& DC_SAVED
) return;
401 dprintf_dc(stddeb
, "SetDCState: %04x %04x\n", hdc
, hdcs
);
403 /* Save the regions, font & brush before overwriting everything */
404 hVisRgn
= dc
->w
.hVisRgn
;
405 hClipRgn
= dc
->w
.hClipRgn
;
406 hGCClipRgn
= dc
->w
.hGCClipRgn
;
408 hbrush
= dc
->w
.hBrush
;
409 memcpy( &dc
->w
, &dcs
->w
, sizeof(dc
->w
) );
410 memcpy( &dc
->u
.x
.pen
, &dcs
->u
.x
.pen
, sizeof(dc
->u
.x
.pen
) );
411 dc
->w
.flags
&= ~DC_SAVED
;
413 /* Restore the regions */
414 dc
->w
.hVisRgn
= hVisRgn
;
415 dc
->w
.hClipRgn
= hClipRgn
;
416 dc
->w
.hGCClipRgn
= hGCClipRgn
;
418 dc
->w
.hBrush
= hbrush
;
419 CombineRgn( dc
->w
.hVisRgn
, dcs
->w
.hVisRgn
, 0, RGN_COPY
);
420 SelectClipRgn( hdc
, dcs
->w
.hClipRgn
);
422 SelectObject( hdc
, dcs
->w
.hBrush
);
423 SelectObject( hdc
, dcs
->w
.hFont
);
427 /***********************************************************************
430 int SaveDC( HDC hdc
)
435 dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
438 dc
= (DC
*)GDI_GetObjPtr(hdc
, METAFILE_DC_MAGIC
);
440 MF_MetaParam0(dc
, META_SAVEDC
);
443 if (!(hdcs
= GetDCState( hdc
))) return 0;
444 dcs
= (DC
*) GDI_HEAP_LIN_ADDR( hdcs
);
445 dcs
->header
.hNext
= dc
->header
.hNext
;
446 dc
->header
.hNext
= hdcs
;
447 dprintf_dc(stddeb
, "SaveDC(%04x): returning %d\n", hdc
, dc
->saveLevel
+1 );
448 return ++dc
->saveLevel
;
452 /***********************************************************************
455 BOOL
RestoreDC( HDC hdc
, short level
)
459 dprintf_dc(stddeb
, "RestoreDC: %04x %d\n", hdc
, level
);
460 dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
463 dc
= (DC
*)GDI_GetObjPtr(hdc
, METAFILE_DC_MAGIC
);
464 if (!dc
) return FALSE
;
465 if (level
!= -1) return FALSE
;
466 MF_MetaParam1(dc
, META_RESTOREDC
, level
);
469 if (level
== -1) level
= dc
->saveLevel
;
470 if ((level
< 1) || (level
> (short)dc
->saveLevel
)) return FALSE
;
472 while ((short)dc
->saveLevel
>= level
)
474 HDC hdcs
= dc
->header
.hNext
;
475 if (!(dcs
= (DC
*) GDI_GetObjPtr( hdcs
, DC_MAGIC
))) return FALSE
;
476 dc
->header
.hNext
= dcs
->header
.hNext
;
477 if ((short)--dc
->saveLevel
< level
) SetDCState( hdc
, hdcs
);
484 /***********************************************************************
487 HDC
CreateDC( LPCSTR driver
, LPCSTR device
, LPCSTR output
, const DEVMODE
* initData
)
491 const DC_FUNCTIONS
*funcs
;
493 if (!(funcs
= DRIVER_FindDriver( driver
))) return 0;
495 handle
= GDI_AllocObject( sizeof(DC
), DC_MAGIC
);
496 if (!handle
) return 0;
497 dc
= (DC
*) GDI_HEAP_LIN_ADDR( handle
);
499 dprintf_dc(stddeb
, "CreateDC(%s %s %s): returning %04x\n",
500 driver
, device
, output
, handle
);
507 dc
->hookProc
= (SEGPTR
)0;
509 memcpy( &dc
->w
, &DC_defaultValues
, sizeof(DC_defaultValues
) );
512 if (dc
->funcs
->pCreateDC
&&
513 !dc
->funcs
->pCreateDC( dc
, driver
, device
, output
, initData
))
515 dprintf_dc( stddeb
, "CreateDC: creation aborted by device\n" );
516 GDI_HEAP_FREE( handle
);
526 /***********************************************************************
529 HDC
CreateIC( LPCSTR driver
, LPCSTR device
, LPCSTR output
, const DEVMODE
* initData
)
531 /* Nothing special yet for ICs */
532 return CreateDC( driver
, device
, output
, initData
);
536 /***********************************************************************
537 * CreateCompatibleDC (GDI.52)
539 HDC
CreateCompatibleDC( HDC hdc
)
544 const DC_FUNCTIONS
*funcs
;
546 if ((origDC
= (DC
*)GDI_GetObjPtr( hdc
, DC_MAGIC
))) funcs
= origDC
->funcs
;
547 else funcs
= DRIVER_FindDriver( "DISPLAY" );
548 if (!funcs
) return 0;
550 handle
= GDI_AllocObject( sizeof(DC
), DC_MAGIC
);
551 if (!handle
) return 0;
552 dc
= (DC
*) GDI_HEAP_LIN_ADDR( handle
);
554 dprintf_dc(stddeb
, "CreateCompatibleDC(%04x): returning %04x\n", hdc
, handle
);
556 /* Create default bitmap */
557 if (!(hbitmap
= CreateBitmap( 1, 1, 1, 1, NULL
)))
559 GDI_HEAP_FREE( handle
);
563 memcpy( &dc
->w
, &DC_defaultValues
, sizeof(DC_defaultValues
) );
570 dc
->hookProc
= (SEGPTR
)0;
571 dc
->w
.flags
= DC_MEMORY
;
572 dc
->w
.bitsPerPixel
= 1;
573 dc
->w
.hBitmap
= hbitmap
;
574 dc
->w
.hFirstBitmap
= hbitmap
;
576 if (dc
->funcs
->pCreateDC
&&
577 !dc
->funcs
->pCreateDC( dc
, NULL
, NULL
, NULL
, NULL
))
579 dprintf_dc( stddeb
, "CreateDC: creation aborted by device\n" );
580 DeleteObject( hbitmap
);
581 GDI_HEAP_FREE( handle
);
589 /***********************************************************************
592 BOOL
DeleteDC( HDC hdc
)
594 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
595 if (!dc
) return FALSE
;
597 dprintf_dc(stddeb
, "DeleteDC: %04x\n", hdc
);
599 while (dc
->saveLevel
)
602 HDC hdcs
= dc
->header
.hNext
;
603 if (!(dcs
= (DC
*) GDI_GetObjPtr( hdcs
, DC_MAGIC
))) break;
604 dc
->header
.hNext
= dcs
->header
.hNext
;
609 if (!(dc
->w
.flags
& DC_SAVED
))
611 SelectObject( hdc
, STOCK_BLACK_PEN
);
612 SelectObject( hdc
, STOCK_WHITE_BRUSH
);
613 SelectObject( hdc
, STOCK_SYSTEM_FONT
);
614 if (dc
->w
.flags
& DC_MEMORY
) DeleteObject( dc
->w
.hFirstBitmap
);
615 if (dc
->funcs
->pDeleteDC
) dc
->funcs
->pDeleteDC(dc
);
618 if (dc
->w
.hClipRgn
) DeleteObject( dc
->w
.hClipRgn
);
619 if (dc
->w
.hVisRgn
) DeleteObject( dc
->w
.hVisRgn
);
620 if (dc
->w
.hGCClipRgn
) DeleteObject( dc
->w
.hGCClipRgn
);
622 return GDI_FreeObject( hdc
);
626 /***********************************************************************
629 HDC
ResetDC( HDC hdc
, /* DEVMODE */ void *devmode
)
631 fprintf( stderr
, "ResetDC: empty stub!\n" );
636 /***********************************************************************
637 * GetDeviceCaps (GDI.80)
639 int GetDeviceCaps( HDC hdc
, WORD cap
)
641 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
644 if (cap
> sizeof(DeviceCaps
)-sizeof(WORD
)) return 0;
646 dprintf_dc(stddeb
, "GetDeviceCaps(%04x,%d): returning %d\n",
647 hdc
, cap
, *(WORD
*)(((char *)dc
->w
.devCaps
) + cap
) );
648 return *(WORD
*)(((char *)dc
->w
.devCaps
) + cap
);
652 /***********************************************************************
655 COLORREF
SetBkColor( HDC hdc
, COLORREF color
)
658 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
661 dc
= (DC
*)GDI_GetObjPtr(hdc
, METAFILE_DC_MAGIC
);
662 if (!dc
) return 0x80000000;
663 MF_MetaParam2(dc
, META_SETBKCOLOR
, HIWORD(color
), LOWORD(color
));
667 oldColor
= dc
->w
.backgroundColor
;
668 dc
->w
.backgroundColor
= color
;
669 dc
->w
.backgroundPixel
= COLOR_ToPhysical( dc
, color
);
674 /***********************************************************************
675 * SetTextColor (GDI.9)
677 COLORREF
SetTextColor( HDC hdc
, COLORREF color
)
680 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
683 dc
= (DC
*)GDI_GetObjPtr(hdc
, METAFILE_DC_MAGIC
);
684 if (!dc
) return 0x80000000;
685 MF_MetaParam2(dc
, META_SETTEXTCOLOR
, HIWORD(color
), LOWORD(color
));
689 oldColor
= dc
->w
.textColor
;
690 dc
->w
.textColor
= color
;
691 dc
->w
.textPixel
= COLOR_ToPhysical( dc
, color
);
696 /***********************************************************************
697 * SetTextAlign (GDI.346)
699 WORD
SetTextAlign( HDC hdc
, WORD textAlign
)
702 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
705 if (!(dc
= (DC
*)GDI_GetObjPtr( hdc
, METAFILE_DC_MAGIC
))) return 0;
706 MF_MetaParam1( dc
, META_SETTEXTALIGN
, textAlign
);
709 prevAlign
= dc
->w
.textAlign
;
710 dc
->w
.textAlign
= textAlign
;
715 /***********************************************************************
718 DWORD
GetDCOrg( HDC hdc
)
721 int x
, y
, w
, h
, border
, depth
;
723 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
725 if (dc
->w
.flags
& DC_MEMORY
) return 0;
726 XGetGeometry( display
, dc
->u
.x
.drawable
, &root
,
727 &x
, &y
, &w
, &h
, &border
, &depth
);
728 return MAKELONG( dc
->w
.DCOrgX
+ (WORD
)x
, dc
->w
.DCOrgY
+ (WORD
)y
);
732 /***********************************************************************
735 DWORD
SetDCOrg( HDC hdc
, short x
, short y
)
738 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
740 prevOrg
= dc
->w
.DCOrgX
| (dc
->w
.DCOrgY
<< 16);
747 /***********************************************************************
748 * SetDCHook (GDI.190)
750 BOOL
SetDCHook( HDC hDC
, FARPROC16 hookProc
, DWORD dwHookData
)
752 DC
*dc
= (DC
*)GDI_GetObjPtr( hDC
, DC_MAGIC
);
754 dprintf_dc( stddeb
, "SetDCHook: hookProc %08x, default is %08x\n",
755 (unsigned)hookProc
,(unsigned)GDI_GetDefDCHook() );
757 if (!dc
) return FALSE
;
758 dc
->hookProc
= hookProc
;
759 dc
->dwHookData
= dwHookData
;
764 /***********************************************************************
765 * GetDCHook (GDI.191)
767 DWORD
GetDCHook( HDC hDC
, FARPROC16
*phookProc
)
769 DC
*dc
= (DC
*)GDI_GetObjPtr( hDC
, DC_MAGIC
);
771 *phookProc
= dc
->hookProc
;
772 return dc
->dwHookData
;
776 /***********************************************************************
777 * SetHookFlags (GDI.192)
779 WORD
SetHookFlags(HDC hDC
, WORD flags
)
781 DC
* dc
= (DC
*)GDI_GetObjPtr( hDC
, DC_MAGIC
);
785 WORD wRet
= dc
->w
.flags
& DC_DIRTY
;
787 /* "Undocumented Windows" info is slightly
791 dprintf_dc(stddeb
,"SetHookFlags: hDC %04x, flags %04x\n",hDC
,flags
);
793 if( flags
& DCHF_INVALIDATEVISRGN
)
794 dc
->w
.flags
|= DC_DIRTY
;
795 else if( flags
& DCHF_VALIDATEVISRGN
|| !flags
)
796 dc
->w
.flags
&= ~DC_DIRTY
;