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 )
32 PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
35 if (!GetObjectA( hbrush, sizeof(logbrush), &logbrush )) return 0;
37 TRACE("hbrush = %p\n", hbrush);
39 if (hbrush == GetStockObject( DC_BRUSH ))
40 logbrush.lbColor = GetDCBrushColor( dev->hdc );
42 switch(logbrush.lbStyle) {
45 PSDRV_CreateColor(dev, &physDev->brush.color, logbrush.lbColor);
52 PSDRV_CreateColor(dev, &physDev->brush.color, logbrush.lbColor);
60 FIXME("Unrecognized brush style %d\n", logbrush.lbStyle);
64 physDev->brush.set = FALSE;
69 /***********************************************************************
70 * SetDCBrushColor (WINEPS.@)
72 COLORREF PSDRV_SetDCBrushColor( PHYSDEV dev, COLORREF color )
74 PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
76 if (GetCurrentObject( dev->hdc, OBJ_BRUSH ) == GetStockObject( DC_BRUSH ))
78 PSDRV_CreateColor( dev, &physDev->brush.color, color );
79 physDev->brush.set = FALSE;
85 /**********************************************************************
90 static BOOL PSDRV_SetBrush( PHYSDEV dev )
92 PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
96 if (!GetObjectA( GetCurrentObject(dev->hdc,OBJ_BRUSH), sizeof(logbrush), &logbrush ))
98 ERR("Can't get BRUSHOBJ\n");
102 switch (logbrush.lbStyle) {
105 PSDRV_WriteSetColor(dev, &physDev->brush.color);
116 physDev->brush.set = TRUE;
121 /**********************************************************************
126 static BOOL PSDRV_Fill(PHYSDEV dev, BOOL EO)
129 return PSDRV_WriteFill(dev);
131 return PSDRV_WriteEOFill(dev);
135 /**********************************************************************
140 static BOOL PSDRV_Clip(PHYSDEV dev, BOOL EO)
143 return PSDRV_WriteClip(dev);
145 return PSDRV_WriteEOClip(dev);
148 /**********************************************************************
153 BOOL PSDRV_Brush(PHYSDEV dev, BOOL EO)
155 PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
159 if(physDev->pathdepth)
162 if (!GetObjectA( GetCurrentObject(dev->hdc,OBJ_BRUSH), sizeof(logbrush), &logbrush ))
164 ERR("Can't get BRUSHOBJ\n");
168 switch (logbrush.lbStyle) {
170 PSDRV_WriteGSave(dev);
173 PSDRV_WriteGRestore(dev);
177 PSDRV_WriteGSave(dev);
180 switch(logbrush.lbHatch) {
183 PSDRV_WriteGSave(dev);
185 PSDRV_WriteHatch(dev);
186 PSDRV_WriteStroke(dev);
187 PSDRV_WriteGRestore(dev);
188 if(logbrush.lbHatch == HS_VERTICAL)
190 /* else fallthrough for HS_CROSS */
193 PSDRV_WriteGSave(dev);
195 PSDRV_WriteRotate(dev, 90.0);
196 PSDRV_WriteHatch(dev);
197 PSDRV_WriteStroke(dev);
198 PSDRV_WriteGRestore(dev);
203 PSDRV_WriteGSave(dev);
205 PSDRV_WriteRotate(dev, -45.0);
206 PSDRV_WriteHatch(dev);
207 PSDRV_WriteStroke(dev);
208 PSDRV_WriteGRestore(dev);
209 if(logbrush.lbHatch == HS_FDIAGONAL)
211 /* else fallthrough for HS_DIAGCROSS */
214 PSDRV_WriteGSave(dev);
216 PSDRV_WriteRotate(dev, 45.0);
217 PSDRV_WriteHatch(dev);
218 PSDRV_WriteStroke(dev);
219 PSDRV_WriteGRestore(dev);
223 ERR("Unknown hatch style\n");
227 PSDRV_WriteGRestore(dev);
237 GetObjectA( (HBITMAP)logbrush.lbHatch, sizeof(BITMAP), &bm);
238 TRACE("BS_PATTERN %dx%d %d bpp\n", bm.bmWidth, bm.bmHeight,
240 bits = HeapAlloc(PSDRV_Heap, 0, bm.bmWidthBytes * bm.bmHeight);
241 GetBitmapBits( (HBITMAP)logbrush.lbHatch, bm.bmWidthBytes * bm.bmHeight, bits);
243 if(physDev->pi->ppd->LanguageLevel > 1) {
244 PSDRV_WriteGSave(dev);
245 PSDRV_WritePatternDict(dev, &bm, bits);
247 PSDRV_WriteGRestore(dev);
249 FIXME("Trying to set a pattern brush on a level 1 printer\n");
252 HeapFree(PSDRV_Heap, 0, bits);
258 BITMAPINFO *bmi = GlobalLock( (HGLOBAL)logbrush.lbHatch );
259 UINT usage = logbrush.lbColor;
260 TRACE("size %dx%dx%d\n", bmi->bmiHeader.biWidth,
261 bmi->bmiHeader.biHeight, bmi->bmiHeader.biBitCount);
262 if(physDev->pi->ppd->LanguageLevel > 1) {
263 PSDRV_WriteGSave(dev);
264 ret = PSDRV_WriteDIBPatternDict(dev, bmi, usage);
266 PSDRV_WriteGRestore(dev);
268 FIXME("Trying to set a pattern brush on a level 1 printer\n");
271 GlobalUnlock( (HGLOBAL)logbrush.lbHatch );