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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "wine/debug.h"
25 WINE_DEFAULT_DEBUG_CHANNEL(psdrv);
27 /***********************************************************************
28 * SelectBrush (WINEPS.@)
30 HBRUSH PSDRV_SelectBrush( PHYSDEV dev, HBRUSH hbrush, HBITMAP bitmap,
31 const BITMAPINFO *info, void *bits, UINT usage )
33 PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
36 if (!GetObjectA( hbrush, sizeof(logbrush), &logbrush )) return 0;
38 TRACE("hbrush = %p\n", hbrush);
40 if (hbrush == GetStockObject( DC_BRUSH ))
41 logbrush.lbColor = GetDCBrushColor( dev->hdc );
43 switch(logbrush.lbStyle) {
46 PSDRV_CreateColor(dev, &physDev->brush.color, logbrush.lbColor);
53 PSDRV_CreateColor(dev, &physDev->brush.color, logbrush.lbColor);
58 physDev->brush.info = info;
59 physDev->brush.bits = bits;
60 physDev->brush.usage = usage;
64 FIXME("Unrecognized brush style %d\n", logbrush.lbStyle);
68 physDev->brush.set = FALSE;
73 /***********************************************************************
74 * SetDCBrushColor (WINEPS.@)
76 COLORREF PSDRV_SetDCBrushColor( PHYSDEV dev, COLORREF color )
78 PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
80 if (GetCurrentObject( dev->hdc, OBJ_BRUSH ) == GetStockObject( DC_BRUSH ))
82 PSDRV_CreateColor( dev, &physDev->brush.color, color );
83 physDev->brush.set = FALSE;
89 /**********************************************************************
94 static BOOL PSDRV_SetBrush( PHYSDEV dev )
96 PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
100 if (!GetObjectA( GetCurrentObject(dev->hdc,OBJ_BRUSH), sizeof(logbrush), &logbrush ))
102 ERR("Can't get BRUSHOBJ\n");
106 switch (logbrush.lbStyle) {
109 PSDRV_WriteSetColor(dev, &physDev->brush.color);
120 physDev->brush.set = TRUE;
125 /**********************************************************************
130 static BOOL PSDRV_Fill(PHYSDEV dev, BOOL EO)
133 return PSDRV_WriteFill(dev);
135 return PSDRV_WriteEOFill(dev);
139 /**********************************************************************
144 static BOOL PSDRV_Clip(PHYSDEV dev, BOOL EO)
147 return PSDRV_WriteClip(dev);
149 return PSDRV_WriteEOClip(dev);
152 /**********************************************************************
157 BOOL PSDRV_Brush(PHYSDEV dev, BOOL EO)
159 PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
163 if(physDev->pathdepth)
166 if (!GetObjectA( GetCurrentObject(dev->hdc,OBJ_BRUSH), sizeof(logbrush), &logbrush ))
168 ERR("Can't get BRUSHOBJ\n");
172 switch (logbrush.lbStyle) {
174 PSDRV_WriteGSave(dev);
177 PSDRV_WriteGRestore(dev);
181 PSDRV_WriteGSave(dev);
184 switch(logbrush.lbHatch) {
187 PSDRV_WriteGSave(dev);
189 PSDRV_WriteHatch(dev);
190 PSDRV_WriteStroke(dev);
191 PSDRV_WriteGRestore(dev);
192 if(logbrush.lbHatch == HS_VERTICAL)
194 /* else fallthrough for HS_CROSS */
197 PSDRV_WriteGSave(dev);
199 PSDRV_WriteRotate(dev, 90.0);
200 PSDRV_WriteHatch(dev);
201 PSDRV_WriteStroke(dev);
202 PSDRV_WriteGRestore(dev);
207 PSDRV_WriteGSave(dev);
209 PSDRV_WriteRotate(dev, -45.0);
210 PSDRV_WriteHatch(dev);
211 PSDRV_WriteStroke(dev);
212 PSDRV_WriteGRestore(dev);
213 if(logbrush.lbHatch == HS_FDIAGONAL)
215 /* else fallthrough for HS_DIAGCROSS */
218 PSDRV_WriteGSave(dev);
220 PSDRV_WriteRotate(dev, 45.0);
221 PSDRV_WriteHatch(dev);
222 PSDRV_WriteStroke(dev);
223 PSDRV_WriteGRestore(dev);
227 ERR("Unknown hatch style\n");
231 PSDRV_WriteGRestore(dev);
239 if(physDev->pi->ppd->LanguageLevel > 1) {
240 PSDRV_WriteGSave(dev);
241 ret = PSDRV_WriteDIBPatternDict(dev, physDev->brush.info,
242 physDev->brush.bits, physDev->brush.usage );
244 PSDRV_WriteGRestore(dev);
246 FIXME("Trying to set a pattern brush on a level 1 printer\n");