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 SelectObject( dc
->hSelf
, dc
->w
.hPen
);
189 SelectObject( dc
->hSelf
, dc
->w
.hBrush
);
190 SelectObject( 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
) );
382 memcpy( &newdc
->u
.x
.pen
, &dc
->u
.x
.pen
, sizeof(dc
->u
.x
.pen
) );
384 newdc
->hSelf
= (HDC32
)handle
;
385 newdc
->saveLevel
= 0;
386 newdc
->w
.flags
|= DC_SAVED
;
388 newdc
->w
.hGCClipRgn
= 0;
389 newdc
->w
.hVisRgn
= CreateRectRgn( 0, 0, 0, 0 );
390 CombineRgn( newdc
->w
.hVisRgn
, dc
->w
.hVisRgn
, 0, RGN_COPY
);
393 newdc
->w
.hClipRgn
= CreateRectRgn( 0, 0, 0, 0 );
394 CombineRgn( newdc
->w
.hClipRgn
, dc
->w
.hClipRgn
, 0, RGN_COPY
);
400 /***********************************************************************
401 * SetDCState (GDI.180)
403 void SetDCState( HDC16 hdc
, HDC16 hdcs
)
406 HRGN32 hVisRgn
, hClipRgn
, hGCClipRgn
;
410 if (!(dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
))) return;
411 if (!(dcs
= (DC
*) GDI_GetObjPtr( hdcs
, DC_MAGIC
))) return;
412 if (!dcs
->w
.flags
& DC_SAVED
) return;
413 dprintf_dc(stddeb
, "SetDCState: %04x %04x\n", hdc
, hdcs
);
415 /* Save the regions, font & brush before overwriting everything */
416 hVisRgn
= dc
->w
.hVisRgn
;
417 hClipRgn
= dc
->w
.hClipRgn
;
418 hGCClipRgn
= dc
->w
.hGCClipRgn
;
420 hbrush
= dc
->w
.hBrush
;
421 memcpy( &dc
->w
, &dcs
->w
, sizeof(dc
->w
) );
422 memcpy( &dc
->u
.x
.pen
, &dcs
->u
.x
.pen
, sizeof(dc
->u
.x
.pen
) );
423 dc
->w
.flags
&= ~DC_SAVED
;
425 /* Restore the regions */
426 dc
->w
.hVisRgn
= hVisRgn
;
427 dc
->w
.hClipRgn
= hClipRgn
;
428 dc
->w
.hGCClipRgn
= hGCClipRgn
;
430 dc
->w
.hBrush
= hbrush
;
431 CombineRgn( dc
->w
.hVisRgn
, dcs
->w
.hVisRgn
, 0, RGN_COPY
);
432 SelectClipRgn( hdc
, dcs
->w
.hClipRgn
);
434 SelectObject( hdc
, dcs
->w
.hBrush
);
435 SelectObject( hdc
, dcs
->w
.hFont
);
439 /***********************************************************************
442 int SaveDC( HDC16 hdc
)
447 dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
450 dc
= (DC
*)GDI_GetObjPtr(hdc
, METAFILE_DC_MAGIC
);
452 MF_MetaParam0(dc
, META_SAVEDC
);
455 if (!(hdcs
= GetDCState( hdc
))) return 0;
456 dcs
= (DC
*) GDI_HEAP_LIN_ADDR( hdcs
);
457 dcs
->header
.hNext
= dc
->header
.hNext
;
458 dc
->header
.hNext
= hdcs
;
459 dprintf_dc(stddeb
, "SaveDC(%04x): returning %d\n", hdc
, dc
->saveLevel
+1 );
460 return ++dc
->saveLevel
;
464 /***********************************************************************
467 BOOL
RestoreDC( HDC16 hdc
, short level
)
471 dprintf_dc(stddeb
, "RestoreDC: %04x %d\n", hdc
, level
);
472 dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
475 dc
= (DC
*)GDI_GetObjPtr(hdc
, METAFILE_DC_MAGIC
);
476 if (!dc
) return FALSE
;
477 if (level
!= -1) return FALSE
;
478 MF_MetaParam1(dc
, META_RESTOREDC
, level
);
481 if (level
== -1) level
= dc
->saveLevel
;
482 if ((level
< 1) || (level
> (short)dc
->saveLevel
)) return FALSE
;
484 while ((short)dc
->saveLevel
>= level
)
486 HDC16 hdcs
= dc
->header
.hNext
;
487 if (!(dcs
= (DC
*) GDI_GetObjPtr( hdcs
, DC_MAGIC
))) return FALSE
;
488 dc
->header
.hNext
= dcs
->header
.hNext
;
489 if ((short)--dc
->saveLevel
< level
) SetDCState( hdc
, hdcs
);
496 /***********************************************************************
499 HDC16
CreateDC( LPCSTR driver
, LPCSTR device
, LPCSTR output
, const DEVMODE
* initData
)
502 const DC_FUNCTIONS
*funcs
;
504 if (!(funcs
= DRIVER_FindDriver( driver
))) return 0;
505 if (!(dc
= DC_AllocDC( funcs
))) return 0;
508 dprintf_dc(stddeb
, "CreateDC(%s %s %s): returning %04x\n",
509 driver
, device
, output
, dc
->hSelf
);
511 if (dc
->funcs
->pCreateDC
&&
512 !dc
->funcs
->pCreateDC( dc
, driver
, device
, output
, initData
))
514 dprintf_dc( stddeb
, "CreateDC: creation aborted by device\n" );
515 GDI_HEAP_FREE( dc
->hSelf
);
524 /***********************************************************************
527 HDC16
CreateIC( LPCSTR driver
, LPCSTR device
, LPCSTR output
, const DEVMODE
* initData
)
529 /* Nothing special yet for ICs */
530 return CreateDC( driver
, device
, output
, initData
);
534 /***********************************************************************
535 * CreateCompatibleDC (GDI.52)
537 HDC16
CreateCompatibleDC( HDC16 hdc
)
541 const DC_FUNCTIONS
*funcs
;
543 if ((origDC
= (DC
*)GDI_GetObjPtr( hdc
, DC_MAGIC
))) funcs
= origDC
->funcs
;
544 else funcs
= DRIVER_FindDriver( "DISPLAY" );
545 if (!funcs
) return 0;
547 if (!(dc
= DC_AllocDC( funcs
))) return 0;
549 dprintf_dc(stddeb
, "CreateCompatibleDC(%04x): returning %04x\n",
552 /* Create default bitmap */
553 if (!(hbitmap
= CreateBitmap( 1, 1, 1, 1, NULL
)))
555 GDI_HEAP_FREE( dc
->hSelf
);
558 dc
->w
.flags
= DC_MEMORY
;
559 dc
->w
.bitsPerPixel
= 1;
560 dc
->w
.hBitmap
= hbitmap
;
561 dc
->w
.hFirstBitmap
= hbitmap
;
563 if (dc
->funcs
->pCreateDC
&&
564 !dc
->funcs
->pCreateDC( dc
, NULL
, NULL
, NULL
, NULL
))
566 dprintf_dc( stddeb
, "CreateDC: creation aborted by device\n" );
567 DeleteObject( hbitmap
);
568 GDI_HEAP_FREE( dc
->hSelf
);
577 /***********************************************************************
580 BOOL
DeleteDC( HDC16 hdc
)
582 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
583 if (!dc
) return FALSE
;
585 dprintf_dc(stddeb
, "DeleteDC: %04x\n", hdc
);
587 while (dc
->saveLevel
)
590 HDC16 hdcs
= dc
->header
.hNext
;
591 if (!(dcs
= (DC
*) GDI_GetObjPtr( hdcs
, DC_MAGIC
))) break;
592 dc
->header
.hNext
= dcs
->header
.hNext
;
597 if (!(dc
->w
.flags
& DC_SAVED
))
599 SelectObject( hdc
, STOCK_BLACK_PEN
);
600 SelectObject( hdc
, STOCK_WHITE_BRUSH
);
601 SelectObject( hdc
, STOCK_SYSTEM_FONT
);
602 if (dc
->w
.flags
& DC_MEMORY
) DeleteObject( dc
->w
.hFirstBitmap
);
603 if (dc
->funcs
->pDeleteDC
) dc
->funcs
->pDeleteDC(dc
);
606 if (dc
->w
.hClipRgn
) DeleteObject( dc
->w
.hClipRgn
);
607 if (dc
->w
.hVisRgn
) DeleteObject( dc
->w
.hVisRgn
);
608 if (dc
->w
.hGCClipRgn
) DeleteObject( dc
->w
.hGCClipRgn
);
610 return GDI_FreeObject( hdc
);
614 /***********************************************************************
617 HDC16
ResetDC( HDC16 hdc
, /* DEVMODE */ void *devmode
)
619 fprintf( stderr
, "ResetDC: empty stub!\n" );
624 /***********************************************************************
625 * GetDeviceCaps (GDI.80)
627 int GetDeviceCaps( HDC16 hdc
, WORD cap
)
629 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
632 if (cap
> sizeof(DeviceCaps
)-sizeof(WORD
)) return 0;
634 dprintf_dc(stddeb
, "GetDeviceCaps(%04x,%d): returning %d\n",
635 hdc
, cap
, *(WORD
*)(((char *)dc
->w
.devCaps
) + cap
) );
636 return *(WORD
*)(((char *)dc
->w
.devCaps
) + cap
);
640 /***********************************************************************
641 * SetBkColor (GDI.1) (GDI32.305)
643 COLORREF
SetBkColor( HDC32 hdc
, COLORREF color
)
646 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
649 dc
= (DC
*)GDI_GetObjPtr(hdc
, METAFILE_DC_MAGIC
);
650 if (!dc
) return 0x80000000;
651 MF_MetaParam2(dc
, META_SETBKCOLOR
, HIWORD(color
), LOWORD(color
));
655 oldColor
= dc
->w
.backgroundColor
;
656 dc
->w
.backgroundColor
= color
;
657 dc
->w
.backgroundPixel
= COLOR_ToPhysical( dc
, color
);
662 /***********************************************************************
663 * SetTextColor (GDI.9) (GDI32.338)
665 COLORREF
SetTextColor( HDC32 hdc
, COLORREF color
)
668 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
671 dc
= (DC
*)GDI_GetObjPtr(hdc
, METAFILE_DC_MAGIC
);
672 if (!dc
) return 0x80000000;
673 MF_MetaParam2(dc
, META_SETTEXTCOLOR
, HIWORD(color
), LOWORD(color
));
677 oldColor
= dc
->w
.textColor
;
678 dc
->w
.textColor
= color
;
679 dc
->w
.textPixel
= COLOR_ToPhysical( dc
, color
);
684 /***********************************************************************
685 * SetTextAlign (GDI.346)
687 WORD
SetTextAlign( HDC16 hdc
, WORD textAlign
)
690 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
693 if (!(dc
= (DC
*)GDI_GetObjPtr( hdc
, METAFILE_DC_MAGIC
))) return 0;
694 MF_MetaParam1( dc
, META_SETTEXTALIGN
, textAlign
);
697 prevAlign
= dc
->w
.textAlign
;
698 dc
->w
.textAlign
= textAlign
;
703 /***********************************************************************
706 DWORD
GetDCOrg( HDC16 hdc
)
709 int x
, y
, w
, h
, border
, depth
;
711 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
713 if (dc
->w
.flags
& DC_MEMORY
) return 0;
714 XGetGeometry( display
, dc
->u
.x
.drawable
, &root
,
715 &x
, &y
, &w
, &h
, &border
, &depth
);
716 return MAKELONG( dc
->w
.DCOrgX
+ (WORD
)x
, dc
->w
.DCOrgY
+ (WORD
)y
);
720 /***********************************************************************
723 DWORD
SetDCOrg( HDC16 hdc
, short x
, short y
)
726 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
728 prevOrg
= dc
->w
.DCOrgX
| (dc
->w
.DCOrgY
<< 16);
735 /***********************************************************************
736 * SetDCHook (GDI.190)
738 BOOL16
SetDCHook( HDC16 hdc
, FARPROC16 hookProc
, DWORD dwHookData
)
740 DC
*dc
= (DC
*)GDI_GetObjPtr( hdc
, DC_MAGIC
);
742 dprintf_dc( stddeb
, "SetDCHook: hookProc %08x, default is %08x\n",
743 (UINT32
)hookProc
, (UINT32
)DCHook
);
745 if (!dc
) return FALSE
;
746 dc
->hookProc
= hookProc
;
747 dc
->dwHookData
= dwHookData
;
752 /***********************************************************************
753 * GetDCHook (GDI.191)
755 DWORD
GetDCHook( HDC16 hdc
, FARPROC16
*phookProc
)
757 DC
*dc
= (DC
*)GDI_GetObjPtr( hdc
, DC_MAGIC
);
759 *phookProc
= dc
->hookProc
;
760 return dc
->dwHookData
;
764 /***********************************************************************
765 * SetHookFlags (GDI.192)
767 WORD
SetHookFlags(HDC16 hDC
, WORD flags
)
769 DC
* dc
= (DC
*)GDI_GetObjPtr( hDC
, DC_MAGIC
);
773 WORD wRet
= dc
->w
.flags
& DC_DIRTY
;
775 /* "Undocumented Windows" info is slightly
779 dprintf_dc(stddeb
,"SetHookFlags: hDC %04x, flags %04x\n",hDC
,flags
);
781 if( flags
& DCHF_INVALIDATEVISRGN
)
782 dc
->w
.flags
|= DC_DIRTY
;
783 else if( flags
& DCHF_VALIDATEVISRGN
|| !flags
)
784 dc
->w
.flags
&= ~DC_DIRTY
;