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
, const struct brush_pattern
*pattern
)
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
);
57 physDev
->brush
.pattern
= *pattern
;
61 FIXME("Unrecognized brush style %d\n", logbrush
.lbStyle
);
65 physDev
->brush
.set
= FALSE
;
70 /***********************************************************************
71 * SetDCBrushColor (WINEPS.@)
73 COLORREF
PSDRV_SetDCBrushColor( PHYSDEV dev
, COLORREF color
)
75 PSDRV_PDEVICE
*physDev
= get_psdrv_dev( dev
);
77 if (GetCurrentObject( dev
->hdc
, OBJ_BRUSH
) == GetStockObject( DC_BRUSH
))
79 PSDRV_CreateColor( dev
, &physDev
->brush
.color
, color
);
80 physDev
->brush
.set
= FALSE
;
86 /**********************************************************************
91 static BOOL
PSDRV_SetBrush( PHYSDEV dev
)
93 PSDRV_PDEVICE
*physDev
= get_psdrv_dev( dev
);
97 if (!GetObjectA( GetCurrentObject(dev
->hdc
,OBJ_BRUSH
), sizeof(logbrush
), &logbrush
))
99 ERR("Can't get BRUSHOBJ\n");
103 switch (logbrush
.lbStyle
) {
106 PSDRV_WriteSetColor(dev
, &physDev
->brush
.color
);
117 physDev
->brush
.set
= TRUE
;
122 /**********************************************************************
127 static BOOL
PSDRV_Fill(PHYSDEV dev
, BOOL EO
)
130 return PSDRV_WriteFill(dev
);
132 return PSDRV_WriteEOFill(dev
);
136 /**********************************************************************
141 static BOOL
PSDRV_Clip(PHYSDEV dev
, BOOL EO
)
144 return PSDRV_WriteClip(dev
);
146 return PSDRV_WriteEOClip(dev
);
149 /**********************************************************************
154 BOOL
PSDRV_Brush(PHYSDEV dev
, BOOL EO
)
156 PSDRV_PDEVICE
*physDev
= get_psdrv_dev( dev
);
160 if(physDev
->pathdepth
)
163 if (!GetObjectA( GetCurrentObject(dev
->hdc
,OBJ_BRUSH
), sizeof(logbrush
), &logbrush
))
165 ERR("Can't get BRUSHOBJ\n");
169 switch (logbrush
.lbStyle
) {
171 PSDRV_WriteGSave(dev
);
174 PSDRV_WriteGRestore(dev
);
178 PSDRV_WriteGSave(dev
);
181 switch(logbrush
.lbHatch
) {
184 PSDRV_WriteGSave(dev
);
186 PSDRV_WriteHatch(dev
);
187 PSDRV_WriteStroke(dev
);
188 PSDRV_WriteGRestore(dev
);
189 if(logbrush
.lbHatch
== HS_VERTICAL
)
191 /* else fallthrough for HS_CROSS */
194 PSDRV_WriteGSave(dev
);
196 PSDRV_WriteRotate(dev
, 90.0);
197 PSDRV_WriteHatch(dev
);
198 PSDRV_WriteStroke(dev
);
199 PSDRV_WriteGRestore(dev
);
204 PSDRV_WriteGSave(dev
);
206 PSDRV_WriteRotate(dev
, -45.0);
207 PSDRV_WriteHatch(dev
);
208 PSDRV_WriteStroke(dev
);
209 PSDRV_WriteGRestore(dev
);
210 if(logbrush
.lbHatch
== HS_FDIAGONAL
)
212 /* else fallthrough for HS_DIAGCROSS */
215 PSDRV_WriteGSave(dev
);
217 PSDRV_WriteRotate(dev
, 45.0);
218 PSDRV_WriteHatch(dev
);
219 PSDRV_WriteStroke(dev
);
220 PSDRV_WriteGRestore(dev
);
224 ERR("Unknown hatch style\n");
228 PSDRV_WriteGRestore(dev
);
236 if(physDev
->pi
->ppd
->LanguageLevel
> 1) {
237 PSDRV_WriteGSave(dev
);
238 ret
= PSDRV_WriteDIBPatternDict(dev
, physDev
->brush
.pattern
.info
,
239 physDev
->brush
.pattern
.bits
.ptr
, physDev
->brush
.pattern
.usage
);
241 PSDRV_WriteGRestore(dev
);
243 FIXME("Trying to set a pattern brush on a level 1 printer\n");