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( print_ctx
*ctx
, HBRUSH hbrush
, const struct brush_pattern
*pattern
)
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( ctx
->hdc
);
41 switch(logbrush
.lbStyle
) {
44 PSDRV_CreateColor(ctx
, &ctx
->brush
.color
, logbrush
.lbColor
);
51 PSDRV_CreateColor(ctx
, &ctx
->brush
.color
, logbrush
.lbColor
);
56 ctx
->brush
.pattern
= *pattern
;
60 FIXME("Unrecognized brush style %d\n", logbrush
.lbStyle
);
64 ctx
->brush
.set
= FALSE
;
69 /***********************************************************************
70 * SetDCBrushColor (WINEPS.@)
72 COLORREF CDECL
PSDRV_SetDCBrushColor( print_ctx
*ctx
, COLORREF color
)
74 if (GetCurrentObject( ctx
->hdc
, OBJ_BRUSH
) == GetStockObject( DC_BRUSH
))
76 PSDRV_CreateColor( ctx
, &ctx
->brush
.color
, color
);
77 ctx
->brush
.set
= FALSE
;
83 /**********************************************************************
88 static BOOL
PSDRV_SetBrush( print_ctx
*ctx
)
93 if (!GetObjectA( GetCurrentObject(ctx
->hdc
,OBJ_BRUSH
), sizeof(logbrush
), &logbrush
))
95 ERR("Can't get BRUSHOBJ\n");
99 switch (logbrush
.lbStyle
) {
102 PSDRV_WriteSetColor(ctx
, &ctx
->brush
.color
);
113 ctx
->brush
.set
= TRUE
;
118 /**********************************************************************
123 static BOOL
PSDRV_Fill(print_ctx
*ctx
, BOOL EO
)
126 return PSDRV_WriteFill(ctx
);
128 return PSDRV_WriteEOFill(ctx
);
132 /**********************************************************************
137 static BOOL
PSDRV_Clip(print_ctx
*ctx
, BOOL EO
)
140 return PSDRV_WriteClip(ctx
);
142 return PSDRV_WriteEOClip(ctx
);
145 /**********************************************************************
150 BOOL
PSDRV_Brush(print_ctx
*ctx
, BOOL EO
)
158 if (!GetObjectA( GetCurrentObject(ctx
->hdc
,OBJ_BRUSH
), sizeof(logbrush
), &logbrush
))
160 ERR("Can't get BRUSHOBJ\n");
164 switch (logbrush
.lbStyle
) {
166 PSDRV_WriteGSave(ctx
);
169 PSDRV_WriteGRestore(ctx
);
173 PSDRV_WriteGSave(ctx
);
176 switch(logbrush
.lbHatch
) {
179 PSDRV_WriteGSave(ctx
);
181 PSDRV_WriteHatch(ctx
);
182 PSDRV_WriteStroke(ctx
);
183 PSDRV_WriteGRestore(ctx
);
184 if(logbrush
.lbHatch
== HS_VERTICAL
)
186 /* else fallthrough for HS_CROSS */
189 PSDRV_WriteGSave(ctx
);
191 PSDRV_WriteRotate(ctx
, 90.0);
192 PSDRV_WriteHatch(ctx
);
193 PSDRV_WriteStroke(ctx
);
194 PSDRV_WriteGRestore(ctx
);
199 PSDRV_WriteGSave(ctx
);
201 PSDRV_WriteRotate(ctx
, -45.0);
202 PSDRV_WriteHatch(ctx
);
203 PSDRV_WriteStroke(ctx
);
204 PSDRV_WriteGRestore(ctx
);
205 if(logbrush
.lbHatch
== HS_FDIAGONAL
)
207 /* else fallthrough for HS_DIAGCROSS */
210 PSDRV_WriteGSave(ctx
);
212 PSDRV_WriteRotate(ctx
, 45.0);
213 PSDRV_WriteHatch(ctx
);
214 PSDRV_WriteStroke(ctx
);
215 PSDRV_WriteGRestore(ctx
);
219 ERR("Unknown hatch style\n");
223 PSDRV_WriteGRestore(ctx
);
231 if(ctx
->pi
->ppd
->LanguageLevel
> 1) {
232 PSDRV_WriteGSave(ctx
);
233 ret
= PSDRV_WriteDIBPatternDict(ctx
, ctx
->brush
.pattern
.info
,
234 ctx
->brush
.pattern
.bits
.ptr
, ctx
->brush
.pattern
.usage
);
236 PSDRV_WriteGRestore(ctx
);
238 FIXME("Trying to set a pattern brush on a level 1 printer\n");