2 * X-specific shortcuts to speed up WM code.
3 * No coordinate transformations except origin translation.
5 * Copyright 1993, 1994 Alexandre Julliard
12 #include <X11/Intrinsic.h>
19 #define MAX_DRAWLINES 8
22 /**********************************************************************
25 * Draw multiple unconnected lines (limited by MAX_DRAWLINES).
27 BOOL32
GRAPH_DrawLines( HDC32 hdc
, LPPOINT32 pXY
, INT32 N
, HPEN32 hPen
)
32 assert( N
<= MAX_DRAWLINES
);
33 if( (dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
)) )
37 if( hPen
) hPrevPen
= SelectObject32( hdc
, hPen
);
38 if( DC_SetupGCForPen( dc
) )
40 XSegment l
[MAX_DRAWLINES
];
43 for( i
= 0; i
< N
; i
++ )
46 l
[i
].x1
= pXY
[j
].x
+ dc
->w
.DCOrgX
;
47 l
[i
].x2
= pXY
[j
+ 1].x
+ dc
->w
.DCOrgX
;
48 l
[i
].y1
= pXY
[j
].y
+ dc
->w
.DCOrgY
;
49 l
[i
].y2
= pXY
[j
+ 1].y
+ dc
->w
.DCOrgY
;
51 TSXDrawSegments( display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
, l
, N
);
54 if( hPrevPen
) SelectObject32( hdc
, hPrevPen
);
59 /**********************************************************************
63 * Short-cut function to blit a bitmap into a device.
64 * Faster than CreateCompatibleDC() + SelectBitmap() + BitBlt() + DeleteDC().
66 BOOL32
GRAPH_DrawBitmap( HDC32 hdc
, HBITMAP32 hbitmap
,
67 INT32 xdest
, INT32 ydest
, INT32 xsrc
, INT32 ysrc
,
68 INT32 width
, INT32 height
, BOOL32 bMono
)
73 if (!(dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
))) return FALSE
;
74 if (!(bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
)))
77 xdest
+= dc
->w
.DCOrgX
; ydest
+= dc
->w
.DCOrgY
;
79 TSXSetFunction( display
, dc
->u
.x
.gc
, GXcopy
);
80 if (bmp
->bitmap
.bmBitsPixel
== 1)
82 TSXSetForeground( display
, dc
->u
.x
.gc
, dc
->w
.backgroundPixel
);
83 TSXSetBackground( display
, dc
->u
.x
.gc
, dc
->w
.textPixel
);
84 TSXCopyPlane( display
, bmp
->pixmap
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
,
85 xsrc
, ysrc
, width
, height
, xdest
, ydest
, 1 );
87 else if (bmp
->bitmap
.bmBitsPixel
== dc
->w
.bitsPerPixel
)
93 if( COLOR_GetMonoPlane(&plane
) )
95 TSXSetForeground( display
, dc
->u
.x
.gc
, dc
->w
.backgroundPixel
);
96 TSXSetBackground( display
, dc
->u
.x
.gc
, dc
->w
.textPixel
);
100 TSXSetForeground( display
, dc
->u
.x
.gc
, dc
->w
.textPixel
);
101 TSXSetBackground( display
, dc
->u
.x
.gc
, dc
->w
.backgroundPixel
);
103 TSXCopyPlane( display
, bmp
->pixmap
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
,
104 xsrc
, ysrc
, width
, height
, xdest
, ydest
, plane
);
107 TSXCopyArea( display
, bmp
->pixmap
, dc
->u
.x
.drawable
,
108 dc
->u
.x
.gc
, xsrc
, ysrc
, width
, height
, xdest
, ydest
);
112 GDI_HEAP_UNLOCK( hbitmap
);
116 GDI_HEAP_UNLOCK( hbitmap
);
121 /**********************************************************************
122 * GRAPH_DrawReliefRect
124 * Used in the standard control code for button edge drawing.
126 void GRAPH_DrawReliefRect( HDC32 hdc
, const RECT32
*rect
, INT32 highlight_size
,
127 INT32 shadow_size
, BOOL32 pressed
)
130 GRAPH_DrawGenericReliefRect(hdc
, rect
, highlight_size
, shadow_size
,
131 GetSysColorBrush32(COLOR_BTNSHADOW
),
132 GetSysColorBrush32(COLOR_BTNHIGHLIGHT
));
134 GRAPH_DrawGenericReliefRect(hdc
, rect
, highlight_size
, shadow_size
,
135 GetSysColorBrush32(COLOR_BTNHIGHLIGHT
),
136 GetSysColorBrush32(COLOR_BTNSHADOW
));
142 /******************************************************************************
143 * GRAPH_DrawGenericReliefRect
145 * Creates a rectangle with the specified highlight and shadow colors.
146 * Adapted from DrawReliefRect (which is somewhat misnamed).
148 void GRAPH_DrawGenericReliefRect(
151 INT32 highlight_size
,
161 if (!(dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
))) return;
163 OffsetRect32( &r
, dc
->w
.DCOrgX
, dc
->w
.DCOrgY
);
164 h
= rect
->bottom
- rect
->top
; w
= rect
->right
- rect
->left
;
166 hPrevBrush
= SelectObject32(hdc
, highlight
);
168 if ( DC_SetupGCForBrush( dc
) )
172 TSXSetFunction( display
, dc
->u
.x
.gc
, GXcopy
);
173 for (i
= 0; i
< highlight_size
; i
++)
175 TSXFillRectangle( display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
,
176 r
.left
+ i
, r
.top
, 1, h
- i
);
177 TSXFillRectangle( display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
,
178 r
.left
, r
.top
+ i
, w
- i
, 1 );
182 SelectObject32( hdc
, shadow
);
183 if ( DC_SetupGCForBrush( dc
) )
187 TSXSetFunction( display
, dc
->u
.x
.gc
, GXcopy
);
188 for (i
= 0; i
< shadow_size
; i
++)
190 TSXFillRectangle( display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
,
191 r
.right
- i
- 1, r
.top
+ i
, 1, h
- i
);
192 TSXFillRectangle( display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
,
193 r
.left
+ i
, r
.bottom
- i
- 1, w
- i
, 1 );
197 SelectObject32( hdc
, hPrevBrush
);
202 /**********************************************************************
203 * GRAPH_DrawRectangle
205 void GRAPH_DrawRectangle( HDC32 hdc
, INT32 x
, INT32 y
,
206 INT32 w
, INT32 h
, HPEN32 hPen
)
210 if( (dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
)) )
214 if( hPen
) hPrevPen
= SelectObject32( hdc
, hPen
);
215 if( DC_SetupGCForPen( dc
) )
216 TSXDrawRectangle( display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
,
217 x
+ dc
->w
.DCOrgX
, y
+ dc
->w
.DCOrgY
, w
- 1, h
- 1);
218 if( hPrevPen
) SelectObject32( hdc
, hPrevPen
);
222 /**********************************************************************
223 * GRAPH_SelectClipMask
225 BOOL32
GRAPH_SelectClipMask( HDC32 hdc
, HBITMAP32 hMonoBitmap
, INT32 x
, INT32 y
)
227 BITMAPOBJ
*bmp
= NULL
;
230 if (!(dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
))) return FALSE
;
233 if ( !(bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hMonoBitmap
, BITMAP_MAGIC
))
234 || bmp
->bitmap
.bmBitsPixel
!= 1 ) return FALSE
;
236 TSXSetClipOrigin( display
, dc
->u
.x
.gc
, dc
->w
.DCOrgX
+ x
, dc
->w
.DCOrgY
+ y
);
239 TSXSetClipMask( display
, dc
->u
.x
.gc
, (bmp
) ? bmp
->pixmap
: None
);
241 GDI_HEAP_UNLOCK( hMonoBitmap
);