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
)
74 X11DRV_PHYSBITMAP
*pbitmap
;
76 if (!(dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
))) return FALSE
;
77 if (!(bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
)))
79 GDI_HEAP_UNLOCK( hdc
);
85 X11DRV_CreateBitmap( hbitmap
);
86 pbitmap
= bmp
->DDBitmap
->physBitmap
;
88 xdest
+= dc
->w
.DCOrgX
; ydest
+= dc
->w
.DCOrgY
;
90 TSXSetFunction( display
, dc
->u
.x
.gc
, GXcopy
);
91 if (bmp
->bitmap
.bmBitsPixel
== 1)
93 TSXSetForeground( display
, dc
->u
.x
.gc
, dc
->u
.x
.backgroundPixel
);
94 TSXSetBackground( display
, dc
->u
.x
.gc
, dc
->u
.x
.textPixel
);
95 TSXCopyPlane( display
, pbitmap
->pixmap
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
,
96 xsrc
, ysrc
, width
, height
, xdest
, ydest
, 1 );
98 else if (bmp
->bitmap
.bmBitsPixel
== dc
->w
.bitsPerPixel
)
104 if( COLOR_GetMonoPlane(&plane
) )
106 TSXSetForeground(display
, dc
->u
.x
.gc
, dc
->u
.x
.backgroundPixel
);
107 TSXSetBackground(display
, dc
->u
.x
.gc
, dc
->u
.x
.textPixel
);
111 TSXSetForeground(display
, dc
->u
.x
.gc
, dc
->u
.x
.textPixel
);
112 TSXSetBackground(display
, dc
->u
.x
.gc
, dc
->u
.x
.backgroundPixel
);
114 TSXCopyPlane( display
, pbitmap
->pixmap
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
,
115 xsrc
, ysrc
, width
, height
, xdest
, ydest
, plane
);
119 TSXCopyArea( display
, pbitmap
->pixmap
, dc
->u
.x
.drawable
,
120 dc
->u
.x
.gc
, xsrc
, ysrc
, width
, height
, xdest
, ydest
);
128 GDI_HEAP_UNLOCK( hdc
);
129 GDI_HEAP_UNLOCK( hbitmap
);
134 /**********************************************************************
135 * GRAPH_DrawReliefRect
137 * Used in the standard control code for button edge drawing.
139 void GRAPH_DrawReliefRect( HDC32 hdc
, const RECT32
*rect
, INT32 highlight_size
,
140 INT32 shadow_size
, BOOL32 pressed
)
143 GRAPH_DrawGenericReliefRect(hdc
, rect
, highlight_size
, shadow_size
,
144 GetSysColorBrush32(COLOR_BTNSHADOW
),
145 GetSysColorBrush32(COLOR_BTNHIGHLIGHT
));
147 GRAPH_DrawGenericReliefRect(hdc
, rect
, highlight_size
, shadow_size
,
148 GetSysColorBrush32(COLOR_BTNHIGHLIGHT
),
149 GetSysColorBrush32(COLOR_BTNSHADOW
));
155 /******************************************************************************
156 * GRAPH_DrawGenericReliefRect
158 * Creates a rectangle with the specified highlight and shadow colors.
159 * Adapted from DrawReliefRect (which is somewhat misnamed).
161 void GRAPH_DrawGenericReliefRect(
164 INT32 highlight_size
,
174 if (!(dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
))) return;
176 OffsetRect32( &r
, dc
->w
.DCOrgX
, dc
->w
.DCOrgY
);
177 h
= rect
->bottom
- rect
->top
; w
= rect
->right
- rect
->left
;
179 hPrevBrush
= SelectObject32(hdc
, highlight
);
181 if ( DC_SetupGCForBrush( dc
) )
185 TSXSetFunction( display
, dc
->u
.x
.gc
, GXcopy
);
186 for (i
= 0; i
< highlight_size
; i
++)
188 TSXFillRectangle( display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
,
189 r
.left
+ i
, r
.top
, 1, h
- i
);
190 TSXFillRectangle( display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
,
191 r
.left
, r
.top
+ i
, w
- i
, 1 );
195 SelectObject32( hdc
, shadow
);
196 if ( DC_SetupGCForBrush( dc
) )
200 TSXSetFunction( display
, dc
->u
.x
.gc
, GXcopy
);
201 for (i
= 0; i
< shadow_size
; i
++)
203 TSXFillRectangle( display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
,
204 r
.right
- i
- 1, r
.top
+ i
, 1, h
- i
);
205 TSXFillRectangle( display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
,
206 r
.left
+ i
, r
.bottom
- i
- 1, w
- i
, 1 );
210 SelectObject32( hdc
, hPrevBrush
);
211 GDI_HEAP_UNLOCK( hdc
);
216 /**********************************************************************
217 * GRAPH_DrawRectangle
219 void GRAPH_DrawRectangle( HDC32 hdc
, INT32 x
, INT32 y
,
220 INT32 w
, INT32 h
, HPEN32 hPen
)
224 if( (dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
)) )
228 if( hPen
) hPrevPen
= SelectObject32( hdc
, hPen
);
229 if( DC_SetupGCForPen( dc
) )
230 TSXDrawRectangle( display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
,
231 x
+ dc
->w
.DCOrgX
, y
+ dc
->w
.DCOrgY
, w
- 1, h
- 1);
232 if( hPrevPen
) SelectObject32( hdc
, hPrevPen
);
233 GDI_HEAP_UNLOCK( hdc
);
237 /**********************************************************************
238 * GRAPH_SelectClipMask
240 BOOL32
GRAPH_SelectClipMask( HDC32 hdc
, HBITMAP32 hMonoBitmap
, INT32 x
, INT32 y
)
242 BITMAPOBJ
*bmp
= NULL
;
244 X11DRV_PHYSBITMAP
*pbitmap
= NULL
;
246 if (!(dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
))) return FALSE
;
249 if ( !(bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hMonoBitmap
, BITMAP_MAGIC
))
250 || bmp
->bitmap
.bmBitsPixel
!= 1 )
252 GDI_HEAP_UNLOCK( hdc
);
258 X11DRV_CreateBitmap( hMonoBitmap
);
259 pbitmap
= bmp
->DDBitmap
->physBitmap
;
260 TSXSetClipOrigin( display
, dc
->u
.x
.gc
, dc
->w
.DCOrgX
+ x
, dc
->w
.DCOrgY
+ y
);
263 TSXSetClipMask( display
, dc
->u
.x
.gc
, (bmp
) ? pbitmap
->pixmap
: None
);
265 GDI_HEAP_UNLOCK( hdc
);
266 GDI_HEAP_UNLOCK( hMonoBitmap
);