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 CDECL PSDRV_SelectBrush( PSDRV_PDEVICE *physDev, HBRUSH hbrush )
34 if (!GetObjectA( hbrush, sizeof(logbrush), &logbrush )) return 0;
36 TRACE("hbrush = %p\n", hbrush);
38 if (hbrush == GetStockObject( DC_BRUSH ))
39 logbrush.lbColor = GetDCBrushColor( physDev->hdc );
41 switch(logbrush.lbStyle) {
44 PSDRV_CreateColor(physDev, &physDev->brush.color, logbrush.lbColor);
51 PSDRV_CreateColor(physDev, &physDev->brush.color, logbrush.lbColor);
59 FIXME("Unrecognized brush style %d\n", logbrush.lbStyle);
63 physDev->brush.set = FALSE;
68 /***********************************************************************
69 * SetDCBrushColor (WINEPS.@)
71 COLORREF CDECL PSDRV_SetDCBrushColor( PSDRV_PDEVICE *physDev, COLORREF color )
73 if (GetCurrentObject( physDev->hdc, OBJ_BRUSH ) == GetStockObject( DC_BRUSH ))
75 PSDRV_CreateColor( physDev, &physDev->brush.color, color );
76 physDev->brush.set = FALSE;
82 /**********************************************************************
87 static BOOL PSDRV_SetBrush(PSDRV_PDEVICE *physDev)
92 if (!GetObjectA( GetCurrentObject(physDev->hdc,OBJ_BRUSH), sizeof(logbrush), &logbrush ))
94 ERR("Can't get BRUSHOBJ\n");
98 switch (logbrush.lbStyle) {
101 PSDRV_WriteSetColor(physDev, &physDev->brush.color);
112 physDev->brush.set = TRUE;
117 /**********************************************************************
122 static BOOL PSDRV_Fill(PSDRV_PDEVICE *physDev, BOOL EO)
125 return PSDRV_WriteFill(physDev);
127 return PSDRV_WriteEOFill(physDev);
131 /**********************************************************************
136 static BOOL PSDRV_Clip(PSDRV_PDEVICE *physDev, BOOL EO)
139 return PSDRV_WriteClip(physDev);
141 return PSDRV_WriteEOClip(physDev);
144 /**********************************************************************
149 BOOL PSDRV_Brush(PSDRV_PDEVICE *physDev, BOOL EO)
154 if(physDev->pathdepth)
157 if (!GetObjectA( GetCurrentObject(physDev->hdc,OBJ_BRUSH), sizeof(logbrush), &logbrush ))
159 ERR("Can't get BRUSHOBJ\n");
163 switch (logbrush.lbStyle) {
165 PSDRV_WriteGSave(physDev);
166 PSDRV_SetBrush(physDev);
167 PSDRV_Fill(physDev, EO);
168 PSDRV_WriteGRestore(physDev);
172 PSDRV_WriteGSave(physDev);
173 PSDRV_SetBrush(physDev);
175 switch(logbrush.lbHatch) {
178 PSDRV_WriteGSave(physDev);
179 PSDRV_Clip(physDev, EO);
180 PSDRV_WriteHatch(physDev);
181 PSDRV_WriteStroke(physDev);
182 PSDRV_WriteGRestore(physDev);
183 if(logbrush.lbHatch == HS_VERTICAL)
185 /* else fallthrough for HS_CROSS */
188 PSDRV_WriteGSave(physDev);
189 PSDRV_Clip(physDev, EO);
190 PSDRV_WriteRotate(physDev, 90.0);
191 PSDRV_WriteHatch(physDev);
192 PSDRV_WriteStroke(physDev);
193 PSDRV_WriteGRestore(physDev);
198 PSDRV_WriteGSave(physDev);
199 PSDRV_Clip(physDev, EO);
200 PSDRV_WriteRotate(physDev, -45.0);
201 PSDRV_WriteHatch(physDev);
202 PSDRV_WriteStroke(physDev);
203 PSDRV_WriteGRestore(physDev);
204 if(logbrush.lbHatch == HS_FDIAGONAL)
206 /* else fallthrough for HS_DIAGCROSS */
209 PSDRV_WriteGSave(physDev);
210 PSDRV_Clip(physDev, EO);
211 PSDRV_WriteRotate(physDev, 45.0);
212 PSDRV_WriteHatch(physDev);
213 PSDRV_WriteStroke(physDev);
214 PSDRV_WriteGRestore(physDev);
218 ERR("Unknown hatch style\n");
222 PSDRV_WriteGRestore(physDev);
232 GetObjectA( (HBITMAP)logbrush.lbHatch, sizeof(BITMAP), &bm);
233 TRACE("BS_PATTERN %dx%d %d bpp\n", bm.bmWidth, bm.bmHeight,
235 bits = HeapAlloc(PSDRV_Heap, 0, bm.bmWidthBytes * bm.bmHeight);
236 GetBitmapBits( (HBITMAP)logbrush.lbHatch, bm.bmWidthBytes * bm.bmHeight, bits);
238 if(physDev->pi->ppd->LanguageLevel > 1) {
239 PSDRV_WriteGSave(physDev);
240 PSDRV_WritePatternDict(physDev, &bm, bits);
241 PSDRV_Fill(physDev, EO);
242 PSDRV_WriteGRestore(physDev);
244 FIXME("Trying to set a pattern brush on a level 1 printer\n");
247 HeapFree(PSDRV_Heap, 0, bits);
253 BITMAPINFO *bmi = GlobalLock( (HGLOBAL)logbrush.lbHatch );
254 UINT usage = logbrush.lbColor;
255 TRACE("size %dx%dx%d\n", bmi->bmiHeader.biWidth,
256 bmi->bmiHeader.biHeight, bmi->bmiHeader.biBitCount);
257 if(physDev->pi->ppd->LanguageLevel > 1) {
258 PSDRV_WriteGSave(physDev);
259 ret = PSDRV_WriteDIBPatternDict(physDev, bmi, usage);
260 PSDRV_Fill(physDev, EO);
261 PSDRV_WriteGRestore(physDev);
263 FIXME("Trying to set a pattern brush on a level 1 printer\n");
266 GlobalUnlock( (HGLOBAL)logbrush.lbHatch );