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_SelectBrush (WINEPS.@)
30 HBRUSH
PSDRV_SelectBrush( PSDRV_PDEVICE
*physDev
, HBRUSH hbrush
)
34 if (!GetObjectA( hbrush
, sizeof(logbrush
), &logbrush
)) return 0;
36 TRACE("hbrush = %08x\n", hbrush
);
38 switch(logbrush
.lbStyle
) {
41 PSDRV_CreateColor(physDev
, &physDev
->brush
.color
, logbrush
.lbColor
);
48 PSDRV_CreateColor(physDev
, &physDev
->brush
.color
, logbrush
.lbColor
);
52 FIXME("Unsupported brush style %d\n", logbrush
.lbStyle
);
56 FIXME("Unrecognized brush style %d\n", logbrush
.lbStyle
);
60 physDev
->brush
.set
= FALSE
;
65 /**********************************************************************
70 static BOOL
PSDRV_SetBrush(PSDRV_PDEVICE
*physDev
)
75 if (!GetObjectA( GetCurrentObject(physDev
->hdc
,OBJ_BRUSH
), sizeof(logbrush
), &logbrush
))
77 ERR("Can't get BRUSHOBJ\n");
81 switch (logbrush
.lbStyle
) {
84 PSDRV_WriteSetColor(physDev
, &physDev
->brush
.color
);
95 physDev
->brush
.set
= TRUE
;
100 /**********************************************************************
105 static BOOL
PSDRV_Fill(PSDRV_PDEVICE
*physDev
, BOOL EO
)
108 return PSDRV_WriteFill(physDev
);
110 return PSDRV_WriteEOFill(physDev
);
114 /**********************************************************************
119 static BOOL
PSDRV_Clip(PSDRV_PDEVICE
*physDev
, BOOL EO
)
122 return PSDRV_WriteClip(physDev
);
124 return PSDRV_WriteEOClip(physDev
);
127 /**********************************************************************
132 BOOL
PSDRV_Brush(PSDRV_PDEVICE
*physDev
, BOOL EO
)
137 if (!GetObjectA( GetCurrentObject(physDev
->hdc
,OBJ_BRUSH
), sizeof(logbrush
), &logbrush
))
139 ERR("Can't get BRUSHOBJ\n");
143 switch (logbrush
.lbStyle
) {
145 PSDRV_SetBrush(physDev
);
146 PSDRV_WriteGSave(physDev
);
147 PSDRV_Fill(physDev
, EO
);
148 PSDRV_WriteGRestore(physDev
);
152 PSDRV_SetBrush(physDev
);
154 switch(logbrush
.lbHatch
) {
157 PSDRV_WriteGSave(physDev
);
158 PSDRV_Clip(physDev
, EO
);
159 PSDRV_WriteHatch(physDev
);
160 PSDRV_WriteStroke(physDev
);
161 PSDRV_WriteGRestore(physDev
);
162 if(logbrush
.lbHatch
== HS_VERTICAL
)
164 /* else fallthrough for HS_CROSS */
167 PSDRV_WriteGSave(physDev
);
168 PSDRV_Clip(physDev
, EO
);
169 PSDRV_WriteRotate(physDev
, 90.0);
170 PSDRV_WriteHatch(physDev
);
171 PSDRV_WriteStroke(physDev
);
172 PSDRV_WriteGRestore(physDev
);
177 PSDRV_WriteGSave(physDev
);
178 PSDRV_Clip(physDev
, EO
);
179 PSDRV_WriteRotate(physDev
, -45.0);
180 PSDRV_WriteHatch(physDev
);
181 PSDRV_WriteStroke(physDev
);
182 PSDRV_WriteGRestore(physDev
);
183 if(logbrush
.lbHatch
== HS_FDIAGONAL
)
185 /* else fallthrough for HS_DIAGCROSS */
188 PSDRV_WriteGSave(physDev
);
189 PSDRV_Clip(physDev
, EO
);
190 PSDRV_WriteRotate(physDev
, 45.0);
191 PSDRV_WriteHatch(physDev
);
192 PSDRV_WriteStroke(physDev
);
193 PSDRV_WriteGRestore(physDev
);
197 ERR("Unknown hatch style\n");
210 GetObjectA(logbrush
.lbHatch
, sizeof(BITMAP
), &bm
);
211 TRACE("BS_PATTERN %dx%d %d bpp\n", bm
.bmWidth
, bm
.bmHeight
,
213 bits
= HeapAlloc(PSDRV_Heap
, 0, bm
.bmWidthBytes
* bm
.bmHeight
);
214 GetBitmapBits(logbrush
.lbHatch
, bm
.bmWidthBytes
* bm
.bmHeight
, bits
);
216 if(physDev
->pi
->ppd
->LanguageLevel
> 1) {
217 PSDRV_WriteGSave(physDev
);
218 PSDRV_WritePatternDict(physDev
, &bm
, bits
);
219 PSDRV_Fill(physDev
, EO
);
220 PSDRV_WriteGRestore(physDev
);
222 FIXME("Trying to set a pattern brush on a level 1 printer\n");
225 HeapFree(PSDRV_Heap
, 0, bits
);