2 * PostScript brush handling
4 * Copyright 1998 Huw D M Davies
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "wine/debug.h"
25 WINE_DEFAULT_DEBUG_CHANNEL(psdrv);
27 /***********************************************************************
28 * PSDRV_BRUSH_SelectObject
30 HBRUSH PSDRV_BRUSH_SelectObject( DC * dc, HBRUSH hbrush )
33 HBRUSH prevbrush = dc->hBrush;
34 PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev;
36 if (!GetObjectA( hbrush, sizeof(logbrush), &logbrush )) return 0;
38 TRACE("hbrush = %08x\n", hbrush);
41 switch(logbrush.lbStyle) {
44 PSDRV_CreateColor(physDev, &physDev->brush.color, logbrush.lbColor);
51 PSDRV_CreateColor(physDev, &physDev->brush.color, logbrush.lbColor);
55 FIXME("Unsupported brush style %d\n", logbrush.lbStyle);
59 FIXME("Unrecognized brush style %d\n", logbrush.lbStyle);
63 physDev->brush.set = FALSE;
68 /**********************************************************************
73 static BOOL PSDRV_SetBrush(DC *dc)
77 PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev;
79 if (!GetObjectA( dc->hBrush, sizeof(logbrush), &logbrush ))
81 ERR("Can't get BRUSHOBJ\n");
85 switch (logbrush.lbStyle) {
88 PSDRV_WriteSetColor(dc, &physDev->brush.color);
99 physDev->brush.set = TRUE;
104 /**********************************************************************
109 static BOOL PSDRV_Fill(DC *dc, BOOL EO)
112 return PSDRV_WriteFill(dc);
114 return PSDRV_WriteEOFill(dc);
118 /**********************************************************************
123 static BOOL PSDRV_Clip(DC *dc, BOOL EO)
126 return PSDRV_WriteClip(dc);
128 return PSDRV_WriteEOClip(dc);
131 /**********************************************************************
136 BOOL PSDRV_Brush(DC *dc, BOOL EO)
140 PSDRV_PDEVICE *physDev = dc->physDev;
142 if (!GetObjectA( dc->hBrush, sizeof(logbrush), &logbrush ))
144 ERR("Can't get BRUSHOBJ\n");
148 switch (logbrush.lbStyle) {
151 PSDRV_WriteGSave(dc);
153 PSDRV_WriteGRestore(dc);
159 switch(logbrush.lbHatch) {
162 PSDRV_WriteGSave(dc);
164 PSDRV_WriteHatch(dc);
165 PSDRV_WriteStroke(dc);
166 PSDRV_WriteGRestore(dc);
167 if(logbrush.lbHatch == HS_VERTICAL)
169 /* else fallthrough for HS_CROSS */
172 PSDRV_WriteGSave(dc);
174 PSDRV_WriteRotate(dc, 90.0);
175 PSDRV_WriteHatch(dc);
176 PSDRV_WriteStroke(dc);
177 PSDRV_WriteGRestore(dc);
182 PSDRV_WriteGSave(dc);
184 PSDRV_WriteRotate(dc, -45.0);
185 PSDRV_WriteHatch(dc);
186 PSDRV_WriteStroke(dc);
187 PSDRV_WriteGRestore(dc);
188 if(logbrush.lbHatch == HS_FDIAGONAL)
190 /* else fallthrough for HS_DIAGCROSS */
193 PSDRV_WriteGSave(dc);
195 PSDRV_WriteRotate(dc, 45.0);
196 PSDRV_WriteHatch(dc);
197 PSDRV_WriteStroke(dc);
198 PSDRV_WriteGRestore(dc);
202 ERR("Unknown hatch style\n");
215 GetObjectA(logbrush.lbHatch, sizeof(BITMAP), &bm);
216 TRACE("BS_PATTERN %dx%d %d bpp\n", bm.bmWidth, bm.bmHeight,
218 bits = HeapAlloc(PSDRV_Heap, 0, bm.bmWidthBytes * bm.bmHeight);
219 GetBitmapBits(logbrush.lbHatch, bm.bmWidthBytes * bm.bmHeight, bits);
221 if(physDev->pi->ppd->LanguageLevel > 1) {
222 PSDRV_WriteGSave(dc);
223 PSDRV_WritePatternDict(dc, &bm, bits);
225 PSDRV_WriteGRestore(dc);
227 FIXME("Trying to set a pattern brush on a level 1 printer\n");
230 HeapFree(PSDRV_Heap, 0, bits);