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
);
55 GDI_HEAP_UNLOCK( hdc
);
60 /**********************************************************************
64 * Short-cut function to blit a bitmap into a device.
65 * Faster than CreateCompatibleDC() + SelectBitmap() + BitBlt() + DeleteDC().
67 BOOL32
GRAPH_DrawBitmap( HDC32 hdc
, HBITMAP32 hbitmap
,
68 INT32 xdest
, INT32 ydest
, INT32 xsrc
, INT32 ysrc
,
69 INT32 width
, INT32 height
, BOOL32 bMono
)
75 if (!(dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
))) return FALSE
;
76 if (!(bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
)))
78 GDI_HEAP_UNLOCK( hdc
);
82 xdest
+= dc
->w
.DCOrgX
; ydest
+= dc
->w
.DCOrgY
;
84 TSXSetFunction( display
, dc
->u
.x
.gc
, GXcopy
);
85 if (bmp
->bitmap
.bmBitsPixel
== 1)
87 TSXSetForeground( display
, dc
->u
.x
.gc
, dc
->u
.x
.backgroundPixel
);
88 TSXSetBackground( display
, dc
->u
.x
.gc
, dc
->u
.x
.textPixel
);
89 TSXCopyPlane( display
, bmp
->pixmap
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
,
90 xsrc
, ysrc
, width
, height
, xdest
, ydest
, 1 );
92 else if (bmp
->bitmap
.bmBitsPixel
== dc
->w
.bitsPerPixel
)
98 if( COLOR_GetMonoPlane(&plane
) )
100 TSXSetForeground(display
, dc
->u
.x
.gc
, dc
->u
.x
.backgroundPixel
);
101 TSXSetBackground(display
, dc
->u
.x
.gc
, dc
->u
.x
.textPixel
);
105 TSXSetForeground(display
, dc
->u
.x
.gc
, dc
->u
.x
.textPixel
);
106 TSXSetBackground(display
, dc
->u
.x
.gc
, dc
->u
.x
.backgroundPixel
);
108 TSXCopyPlane( display
, bmp
->pixmap
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
,
109 xsrc
, ysrc
, width
, height
, xdest
, ydest
, plane
);
113 TSXCopyArea( display
, bmp
->pixmap
, dc
->u
.x
.drawable
,
114 dc
->u
.x
.gc
, xsrc
, ysrc
, width
, height
, xdest
, ydest
);
122 GDI_HEAP_UNLOCK( hdc
);
123 GDI_HEAP_UNLOCK( hbitmap
);
128 /**********************************************************************
129 * GRAPH_DrawReliefRect
131 * Used in the standard control code for button edge drawing.
133 void GRAPH_DrawReliefRect( HDC32 hdc
, const RECT32
*rect
, INT32 highlight_size
,
134 INT32 shadow_size
, BOOL32 pressed
)
137 GRAPH_DrawGenericReliefRect(hdc
, rect
, highlight_size
, shadow_size
,
138 GetSysColorBrush32(COLOR_BTNSHADOW
),
139 GetSysColorBrush32(COLOR_BTNHIGHLIGHT
));
141 GRAPH_DrawGenericReliefRect(hdc
, rect
, highlight_size
, shadow_size
,
142 GetSysColorBrush32(COLOR_BTNHIGHLIGHT
),
143 GetSysColorBrush32(COLOR_BTNSHADOW
));
149 /******************************************************************************
150 * GRAPH_DrawGenericReliefRect
152 * Creates a rectangle with the specified highlight and shadow colors.
153 * Adapted from DrawReliefRect (which is somewhat misnamed).
155 void GRAPH_DrawGenericReliefRect(
158 INT32 highlight_size
,
168 if (!(dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
))) return;
170 OffsetRect32( &r
, dc
->w
.DCOrgX
, dc
->w
.DCOrgY
);
171 h
= rect
->bottom
- rect
->top
; w
= rect
->right
- rect
->left
;
173 hPrevBrush
= SelectObject32(hdc
, highlight
);
175 if ( DC_SetupGCForBrush( dc
) )
179 TSXSetFunction( display
, dc
->u
.x
.gc
, GXcopy
);
180 for (i
= 0; i
< highlight_size
; i
++)
182 TSXFillRectangle( display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
,
183 r
.left
+ i
, r
.top
, 1, h
- i
);
184 TSXFillRectangle( display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
,
185 r
.left
, r
.top
+ i
, w
- i
, 1 );
189 SelectObject32( hdc
, shadow
);
190 if ( DC_SetupGCForBrush( dc
) )
194 TSXSetFunction( display
, dc
->u
.x
.gc
, GXcopy
);
195 for (i
= 0; i
< shadow_size
; i
++)
197 TSXFillRectangle( display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
,
198 r
.right
- i
- 1, r
.top
+ i
, 1, h
- i
);
199 TSXFillRectangle( display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
,
200 r
.left
+ i
, r
.bottom
- i
- 1, w
- i
, 1 );
204 SelectObject32( hdc
, hPrevBrush
);
205 GDI_HEAP_UNLOCK( hdc
);
210 /**********************************************************************
211 * GRAPH_DrawRectangle
213 void GRAPH_DrawRectangle( HDC32 hdc
, INT32 x
, INT32 y
,
214 INT32 w
, INT32 h
, HPEN32 hPen
)
218 if( (dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
)) )
222 if( hPen
) hPrevPen
= SelectObject32( hdc
, hPen
);
223 if( DC_SetupGCForPen( dc
) )
224 TSXDrawRectangle( display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
,
225 x
+ dc
->w
.DCOrgX
, y
+ dc
->w
.DCOrgY
, w
- 1, h
- 1);
226 if( hPrevPen
) SelectObject32( hdc
, hPrevPen
);
227 GDI_HEAP_UNLOCK( hdc
);
231 /**********************************************************************
232 * GRAPH_SelectClipMask
234 BOOL32
GRAPH_SelectClipMask( HDC32 hdc
, HBITMAP32 hMonoBitmap
, INT32 x
, INT32 y
)
236 BITMAPOBJ
*bmp
= NULL
;
239 if (!(dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
))) return FALSE
;
242 if ( !(bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hMonoBitmap
, BITMAP_MAGIC
))
243 || bmp
->bitmap
.bmBitsPixel
!= 1 )
245 GDI_HEAP_UNLOCK( hdc
);
248 TSXSetClipOrigin( display
, dc
->u
.x
.gc
, dc
->w
.DCOrgX
+ x
, dc
->w
.DCOrgY
+ y
);
251 TSXSetClipMask( display
, dc
->u
.x
.gc
, (bmp
) ? bmp
->pixmap
: None
);
253 GDI_HEAP_UNLOCK( hdc
);
254 GDI_HEAP_UNLOCK( hMonoBitmap
);