Tried another kludge for the Xmd.h problem.
[wine/multimedia.git] / graphics / psdrv / brush.c
blob2579e4c9e49aa31ef7e9d7d502d628d77e9cdbfe
1 /*
2 * PostScript brush handling
4 * Copyright 1998 Huw D M Davies
6 */
8 #include "windows.h"
9 #include "psdrv.h"
10 #include "brush.h"
11 #include "debug.h"
12 #include "gdi.h"
14 /***********************************************************************
15 * PSDRV_BRUSH_SelectObject
17 HBRUSH32 PSDRV_BRUSH_SelectObject( DC * dc, HBRUSH32 hbrush, BRUSHOBJ * brush )
19 HBRUSH32 prevbrush = dc->w.hBrush;
20 PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev;
22 TRACE(psdrv, "hbrush = %08x\n", hbrush);
23 dc->w.hBrush = hbrush;
25 switch(brush->logbrush.lbStyle) {
27 case BS_SOLID:
28 PSDRV_CreateColor(physDev, &physDev->brush.color,
29 brush->logbrush.lbColor);
30 break;
32 case BS_NULL:
33 break;
35 case BS_HATCHED:
36 PSDRV_CreateColor(physDev, &physDev->brush.color,
37 brush->logbrush.lbColor);
38 break;
40 case BS_PATTERN:
41 FIXME(psdrv, "Unsupported brush style %d\n", brush->logbrush.lbStyle);
42 break;
44 default:
45 FIXME(psdrv, "Unrecognized brush style %d\n", brush->logbrush.lbStyle);
46 break;
49 physDev->brush.set = FALSE;
50 return prevbrush;
54 /**********************************************************************
56 * PSDRV_SetBrush
59 static BOOL32 PSDRV_SetBrush(DC *dc)
61 PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev;
62 BRUSHOBJ *brush = (BRUSHOBJ *)GDI_GetObjPtr( dc->w.hBrush, BRUSH_MAGIC );
64 if(!brush) {
65 ERR(psdrv, "Can't get BRUSHOBJ\n");
66 return FALSE;
69 switch (brush->logbrush.lbStyle) {
70 case BS_SOLID:
71 case BS_HATCHED:
72 PSDRV_WriteSetColor(dc, &physDev->brush.color);
73 break;
75 case BS_NULL:
76 break;
78 default:
79 return FALSE;
80 break;
83 physDev->brush.set = TRUE;
84 return TRUE;
88 /**********************************************************************
90 * PSDRV_Fill
93 static BOOL32 PSDRV_Fill(DC *dc, BOOL32 EO)
95 if(!EO)
96 return PSDRV_WriteFill(dc);
97 else
98 return PSDRV_WriteEOFill(dc);
102 /**********************************************************************
104 * PSDRV_Clip
107 static BOOL32 PSDRV_Clip(DC *dc, BOOL32 EO)
109 if(!EO)
110 return PSDRV_WriteClip(dc);
111 else
112 return PSDRV_WriteEOClip(dc);
115 /**********************************************************************
117 * PSDRV_Brush
120 BOOL32 PSDRV_Brush(DC *dc, BOOL32 EO)
122 BRUSHOBJ *brush = (BRUSHOBJ *)GDI_GetObjPtr( dc->w.hBrush, BRUSH_MAGIC );
124 if(!brush) {
125 ERR(psdrv, "Can't get BRUSHOBJ\n");
126 return FALSE;
129 switch (brush->logbrush.lbStyle) {
130 case BS_SOLID:
131 PSDRV_SetBrush(dc);
132 PSDRV_WriteGSave(dc);
133 PSDRV_Fill(dc, EO);
134 PSDRV_WriteGRestore(dc);
135 return TRUE;
136 break;
138 case BS_HATCHED:
139 PSDRV_SetBrush(dc);
141 switch(brush->logbrush.lbHatch) {
142 case HS_VERTICAL:
143 case HS_CROSS:
144 PSDRV_WriteGSave(dc);
145 PSDRV_Clip(dc, EO);
146 PSDRV_WriteHatch(dc);
147 PSDRV_WriteStroke(dc);
148 PSDRV_WriteGRestore(dc);
149 if(brush->logbrush.lbHatch == HS_VERTICAL)
150 break;
151 /* else fallthrough for HS_CROSS */
153 case HS_HORIZONTAL:
154 PSDRV_WriteGSave(dc);
155 PSDRV_Clip(dc, EO);
156 PSDRV_WriteRotate(dc, 90.0);
157 PSDRV_WriteHatch(dc);
158 PSDRV_WriteStroke(dc);
159 PSDRV_WriteGRestore(dc);
160 break;
162 case HS_FDIAGONAL:
163 case HS_DIAGCROSS:
164 PSDRV_WriteGSave(dc);
165 PSDRV_Clip(dc, EO);
166 PSDRV_WriteRotate(dc, -45.0);
167 PSDRV_WriteHatch(dc);
168 PSDRV_WriteStroke(dc);
169 PSDRV_WriteGRestore(dc);
170 if(brush->logbrush.lbHatch == HS_FDIAGONAL)
171 break;
172 /* else fallthrough for HS_DIAGCROSS */
174 case HS_BDIAGONAL:
175 PSDRV_WriteGSave(dc);
176 PSDRV_Clip(dc, EO);
177 PSDRV_WriteRotate(dc, 45.0);
178 PSDRV_WriteHatch(dc);
179 PSDRV_WriteStroke(dc);
180 PSDRV_WriteGRestore(dc);
181 break;
183 default:
184 ERR(psdrv, "Unknown hatch style\n");
185 return FALSE;
187 return TRUE;
188 break;
190 case BS_NULL:
191 return TRUE;
192 break;
194 default:
195 return FALSE;
196 break;