2 * PostScript brush handling
4 * Copyright 1998 Huw D M Davies
9 #include "debugtools.h"
12 DEFAULT_DEBUG_CHANNEL(psdrv);
14 /***********************************************************************
15 * PSDRV_BRUSH_SelectObject
17 HBRUSH PSDRV_BRUSH_SelectObject( DC * dc, HBRUSH hbrush )
20 HBRUSH prevbrush = dc->hBrush;
21 PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev;
23 if (!GetObjectA( hbrush, sizeof(logbrush), &logbrush )) return 0;
25 TRACE("hbrush = %08x\n", hbrush);
28 switch(logbrush.lbStyle) {
31 PSDRV_CreateColor(physDev, &physDev->brush.color, logbrush.lbColor);
38 PSDRV_CreateColor(physDev, &physDev->brush.color, logbrush.lbColor);
42 FIXME("Unsupported brush style %d\n", logbrush.lbStyle);
46 FIXME("Unrecognized brush style %d\n", logbrush.lbStyle);
50 physDev->brush.set = FALSE;
55 /**********************************************************************
60 static BOOL PSDRV_SetBrush(DC *dc)
64 PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev;
66 if (!GetObjectA( dc->hBrush, sizeof(logbrush), &logbrush ))
68 ERR("Can't get BRUSHOBJ\n");
72 switch (logbrush.lbStyle) {
75 PSDRV_WriteSetColor(dc, &physDev->brush.color);
86 physDev->brush.set = TRUE;
91 /**********************************************************************
96 static BOOL PSDRV_Fill(DC *dc, BOOL EO)
99 return PSDRV_WriteFill(dc);
101 return PSDRV_WriteEOFill(dc);
105 /**********************************************************************
110 static BOOL PSDRV_Clip(DC *dc, BOOL EO)
113 return PSDRV_WriteClip(dc);
115 return PSDRV_WriteEOClip(dc);
118 /**********************************************************************
123 BOOL PSDRV_Brush(DC *dc, BOOL EO)
127 PSDRV_PDEVICE *physDev = dc->physDev;
129 if (!GetObjectA( dc->hBrush, sizeof(logbrush), &logbrush ))
131 ERR("Can't get BRUSHOBJ\n");
135 switch (logbrush.lbStyle) {
138 PSDRV_WriteGSave(dc);
140 PSDRV_WriteGRestore(dc);
146 switch(logbrush.lbHatch) {
149 PSDRV_WriteGSave(dc);
151 PSDRV_WriteHatch(dc);
152 PSDRV_WriteStroke(dc);
153 PSDRV_WriteGRestore(dc);
154 if(logbrush.lbHatch == HS_VERTICAL)
156 /* else fallthrough for HS_CROSS */
159 PSDRV_WriteGSave(dc);
161 PSDRV_WriteRotate(dc, 90.0);
162 PSDRV_WriteHatch(dc);
163 PSDRV_WriteStroke(dc);
164 PSDRV_WriteGRestore(dc);
169 PSDRV_WriteGSave(dc);
171 PSDRV_WriteRotate(dc, -45.0);
172 PSDRV_WriteHatch(dc);
173 PSDRV_WriteStroke(dc);
174 PSDRV_WriteGRestore(dc);
175 if(logbrush.lbHatch == HS_FDIAGONAL)
177 /* else fallthrough for HS_DIAGCROSS */
180 PSDRV_WriteGSave(dc);
182 PSDRV_WriteRotate(dc, 45.0);
183 PSDRV_WriteHatch(dc);
184 PSDRV_WriteStroke(dc);
185 PSDRV_WriteGRestore(dc);
189 ERR("Unknown hatch style\n");
202 GetObjectA(logbrush.lbHatch, sizeof(BITMAP), &bm);
203 TRACE("BS_PATTERN %dx%d %d bpp\n", bm.bmWidth, bm.bmHeight,
205 bits = HeapAlloc(PSDRV_Heap, 0, bm.bmWidthBytes * bm.bmHeight);
206 GetBitmapBits(logbrush.lbHatch, bm.bmWidthBytes * bm.bmHeight, bits);
208 if(physDev->pi->ppd->LanguageLevel > 1) {
209 PSDRV_WriteGSave(dc);
210 PSDRV_WritePatternDict(dc, &bm, bits);
212 PSDRV_WriteGRestore(dc);
214 FIXME("Trying to set a pattern brush on a level 1 printer\n");
217 HeapFree(PSDRV_Heap, 0, bits);