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>
20 #define MAX_DRAWLINES 8
23 /**********************************************************************
26 * Draw multiple unconnected lines (limited by MAX_DRAWLINES).
28 BOOL32
GRAPH_DrawLines( HDC32 hdc
, LPPOINT32 pXY
, INT32 N
, HPEN32 hPen
)
33 assert( N
<= MAX_DRAWLINES
);
34 if( (dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
)) )
37 X11DRV_PDEVICE
*physDev
= (X11DRV_PDEVICE
*)dc
->physDev
;
39 if( hPen
) hPrevPen
= SelectObject32( hdc
, hPen
);
40 if( X11DRV_SetupGCForPen( dc
) )
42 XSegment l
[MAX_DRAWLINES
];
45 for( i
= 0; i
< N
; i
++ )
48 l
[i
].x1
= pXY
[j
].x
+ dc
->w
.DCOrgX
;
49 l
[i
].x2
= pXY
[j
+ 1].x
+ dc
->w
.DCOrgX
;
50 l
[i
].y1
= pXY
[j
].y
+ dc
->w
.DCOrgY
;
51 l
[i
].y2
= pXY
[j
+ 1].y
+ dc
->w
.DCOrgY
;
53 TSXDrawSegments( display
, physDev
->drawable
, physDev
->gc
, l
, N
);
56 if( hPrevPen
) SelectObject32( hdc
, hPrevPen
);
57 GDI_HEAP_UNLOCK( hdc
);
62 /**********************************************************************
66 * Short-cut function to blit a bitmap into a device.
67 * Faster than CreateCompatibleDC() + SelectBitmap() + BitBlt() + DeleteDC().
69 BOOL32
GRAPH_DrawBitmap( HDC32 hdc
, HBITMAP32 hbitmap
,
70 INT32 xdest
, INT32 ydest
, INT32 xsrc
, INT32 ysrc
,
71 INT32 width
, INT32 height
, BOOL32 bMono
)
76 X11DRV_PHYSBITMAP
*pbitmap
;
77 X11DRV_PDEVICE
*physDev
;
79 if (!(dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
))) return FALSE
;
80 if (!(bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
)))
82 GDI_HEAP_UNLOCK( hdc
);
85 physDev
= (X11DRV_PDEVICE
*)dc
->physDev
;
89 X11DRV_CreateBitmap( hbitmap
);
90 pbitmap
= bmp
->DDBitmap
->physBitmap
;
92 xdest
+= dc
->w
.DCOrgX
; ydest
+= dc
->w
.DCOrgY
;
94 TSXSetFunction( display
, physDev
->gc
, GXcopy
);
95 if (bmp
->bitmap
.bmBitsPixel
== 1)
97 TSXSetForeground( display
, physDev
->gc
, physDev
->backgroundPixel
);
98 TSXSetBackground( display
, physDev
->gc
, physDev
->textPixel
);
99 TSXCopyPlane( display
, pbitmap
->pixmap
, physDev
->drawable
, physDev
->gc
,
100 xsrc
, ysrc
, width
, height
, xdest
, ydest
, 1 );
102 else if (bmp
->bitmap
.bmBitsPixel
== dc
->w
.bitsPerPixel
)
108 if( COLOR_GetMonoPlane(&plane
) )
110 TSXSetForeground( display
, physDev
->gc
,
111 physDev
->backgroundPixel
);
112 TSXSetBackground( display
, physDev
->gc
, physDev
->textPixel
);
116 TSXSetForeground( display
, physDev
->gc
, physDev
->textPixel
);
117 TSXSetBackground( display
, physDev
->gc
,
118 physDev
->backgroundPixel
);
120 TSXCopyPlane( display
, pbitmap
->pixmap
, physDev
->drawable
,
121 physDev
->gc
, xsrc
, ysrc
, width
, height
, xdest
, ydest
,
126 TSXCopyArea( display
, pbitmap
->pixmap
, physDev
->drawable
,
127 physDev
->gc
, xsrc
, ysrc
, width
, height
, xdest
,
136 GDI_HEAP_UNLOCK( hdc
);
137 GDI_HEAP_UNLOCK( hbitmap
);
142 /**********************************************************************
143 * GRAPH_DrawReliefRect
145 * Used in the standard control code for button edge drawing.
147 void GRAPH_DrawReliefRect( HDC32 hdc
, const RECT32
*rect
, INT32 highlight_size
,
148 INT32 shadow_size
, BOOL32 pressed
)
151 GRAPH_DrawGenericReliefRect(hdc
, rect
, highlight_size
, shadow_size
,
152 GetSysColorBrush32(COLOR_BTNSHADOW
),
153 GetSysColorBrush32(COLOR_BTNHIGHLIGHT
));
155 GRAPH_DrawGenericReliefRect(hdc
, rect
, highlight_size
, shadow_size
,
156 GetSysColorBrush32(COLOR_BTNHIGHLIGHT
),
157 GetSysColorBrush32(COLOR_BTNSHADOW
));
163 /******************************************************************************
164 * GRAPH_DrawGenericReliefRect
166 * Creates a rectangle with the specified highlight and shadow colors.
167 * Adapted from DrawReliefRect (which is somewhat misnamed).
169 void GRAPH_DrawGenericReliefRect(
172 INT32 highlight_size
,
181 X11DRV_PDEVICE
*physDev
;
183 if (!(dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
))) return;
184 physDev
= (X11DRV_PDEVICE
*)dc
->physDev
;
185 OffsetRect32( &r
, dc
->w
.DCOrgX
, dc
->w
.DCOrgY
);
186 h
= rect
->bottom
- rect
->top
; w
= rect
->right
- rect
->left
;
188 hPrevBrush
= SelectObject32(hdc
, highlight
);
190 if ( X11DRV_SetupGCForBrush( dc
) )
194 TSXSetFunction( display
, physDev
->gc
, GXcopy
);
195 for (i
= 0; i
< highlight_size
; i
++)
197 TSXFillRectangle( display
, physDev
->drawable
, physDev
->gc
,
198 r
.left
+ i
, r
.top
, 1, h
- i
);
199 TSXFillRectangle( display
, physDev
->drawable
, physDev
->gc
,
200 r
.left
, r
.top
+ i
, w
- i
, 1 );
204 SelectObject32( hdc
, shadow
);
205 if ( X11DRV_SetupGCForBrush( dc
) )
209 TSXSetFunction( display
, physDev
->gc
, GXcopy
);
210 for (i
= 0; i
< shadow_size
; i
++)
212 TSXFillRectangle( display
, physDev
->drawable
, physDev
->gc
,
213 r
.right
- i
- 1, r
.top
+ i
, 1, h
- i
);
214 TSXFillRectangle( display
, physDev
->drawable
, physDev
->gc
,
215 r
.left
+ i
, r
.bottom
- i
- 1, w
- i
, 1 );
219 SelectObject32( hdc
, hPrevBrush
);
220 GDI_HEAP_UNLOCK( hdc
);
225 /**********************************************************************
226 * GRAPH_DrawRectangle
228 void GRAPH_DrawRectangle( HDC32 hdc
, INT32 x
, INT32 y
,
229 INT32 w
, INT32 h
, HPEN32 hPen
)
233 if( (dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
)) )
236 X11DRV_PDEVICE
*physDev
= (X11DRV_PDEVICE
*)dc
->physDev
;
238 if( hPen
) hPrevPen
= SelectObject32( hdc
, hPen
);
239 if( X11DRV_SetupGCForPen( dc
) )
240 TSXDrawRectangle( display
, physDev
->drawable
, physDev
->gc
,
241 x
+ dc
->w
.DCOrgX
, y
+ dc
->w
.DCOrgY
, w
- 1, h
- 1);
242 if( hPrevPen
) SelectObject32( hdc
, hPrevPen
);
243 GDI_HEAP_UNLOCK( hdc
);
247 /**********************************************************************
248 * GRAPH_SelectClipMask
250 BOOL32
GRAPH_SelectClipMask( HDC32 hdc
, HBITMAP32 hMonoBitmap
, INT32 x
, INT32 y
)
252 BITMAPOBJ
*bmp
= NULL
;
254 X11DRV_PHYSBITMAP
*pbitmap
= NULL
;
255 X11DRV_PDEVICE
*physDev
;
257 if (!(dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
))) return FALSE
;
258 physDev
= (X11DRV_PDEVICE
*)dc
->physDev
;
261 if ( !(bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hMonoBitmap
, BITMAP_MAGIC
))
262 || bmp
->bitmap
.bmBitsPixel
!= 1 )
264 GDI_HEAP_UNLOCK( hdc
);
270 X11DRV_CreateBitmap( hMonoBitmap
);
271 pbitmap
= bmp
->DDBitmap
->physBitmap
;
272 TSXSetClipOrigin( display
, physDev
->gc
, dc
->w
.DCOrgX
+ x
,
276 TSXSetClipMask( display
, physDev
->gc
, (bmp
) ? pbitmap
->pixmap
: None
);
278 GDI_HEAP_UNLOCK( hdc
);
279 GDI_HEAP_UNLOCK( hMonoBitmap
);