-Fixed MESSAGE functions that were thunking down to 16 bits implementation.
[wine] / graphics / psdrv / brush.c
1 /*
2  *      PostScript brush handling
3  *
4  * Copyright 1998  Huw D M Davies
5  *
6  */
7
8 #include "windows.h"
9 #include "psdrv.h"
10 #include "brush.h"
11 #include "debug.h"
12 #include "gdi.h"
13
14 /***********************************************************************
15  *           PSDRV_BRUSH_SelectObject
16  */
17 HBRUSH32 PSDRV_BRUSH_SelectObject( DC * dc, HBRUSH32 hbrush, BRUSHOBJ * brush )
18 {
19     HBRUSH32 prevbrush = dc->w.hBrush;
20     PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev;
21
22     TRACE(psdrv, "hbrush = %08x\n", hbrush);
23     dc->w.hBrush = hbrush;
24
25     switch(brush->logbrush.lbStyle) {
26
27     case BS_SOLID:
28         PSDRV_CreateColor(physDev, &physDev->brush.color, 
29                           brush->logbrush.lbColor);
30         break;
31
32     case BS_NULL:
33         break;
34
35     case BS_HATCHED:
36         PSDRV_CreateColor(physDev, &physDev->brush.color, 
37                           brush->logbrush.lbColor);
38         break;
39
40     case BS_PATTERN:
41         FIXME(psdrv, "Unsupported brush style %d\n", brush->logbrush.lbStyle);
42         break;
43
44     default:
45         FIXME(psdrv, "Unrecognized brush style %d\n", brush->logbrush.lbStyle);
46         break;
47     }
48
49     physDev->brush.set = FALSE;
50     return prevbrush;
51 }
52
53
54 /**********************************************************************
55  *
56  *      PSDRV_SetBrush
57  *
58  */
59 static BOOL32 PSDRV_SetBrush(DC *dc)
60 {
61     PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev;
62     BRUSHOBJ *brush = (BRUSHOBJ *)GDI_GetObjPtr( dc->w.hBrush, BRUSH_MAGIC );
63
64     if(!brush) {
65         ERR(psdrv, "Can't get BRUSHOBJ\n");
66         return FALSE;
67     }
68     
69     switch (brush->logbrush.lbStyle) {
70     case BS_SOLID:
71     case BS_HATCHED:
72         PSDRV_WriteSetColor(dc, &physDev->brush.color);
73         break;
74
75     case BS_NULL:
76         break;
77
78     default:
79         return FALSE;
80         break;
81
82     }
83     physDev->brush.set = TRUE;
84     return TRUE;
85 }
86
87
88 /**********************************************************************
89  *
90  *      PSDRV_Fill
91  *
92  */
93 static BOOL32 PSDRV_Fill(DC *dc, BOOL32 EO)
94 {
95     if(!EO)
96         return PSDRV_WriteFill(dc);
97     else
98       return PSDRV_WriteEOFill(dc);
99 }
100
101
102 /**********************************************************************
103  *
104  *      PSDRV_Clip
105  *
106  */
107 static BOOL32 PSDRV_Clip(DC *dc, BOOL32 EO)
108 {
109     if(!EO)
110         return PSDRV_WriteClip(dc);
111     else
112         return PSDRV_WriteEOClip(dc);
113 }
114
115 /**********************************************************************
116  *
117  *      PSDRV_Brush
118  *
119  */
120 BOOL32 PSDRV_Brush(DC *dc, BOOL32 EO)
121 {
122     BRUSHOBJ *brush = (BRUSHOBJ *)GDI_GetObjPtr( dc->w.hBrush, BRUSH_MAGIC );
123
124     if(!brush) {
125         ERR(psdrv, "Can't get BRUSHOBJ\n");
126         return FALSE;
127     }
128
129     switch (brush->logbrush.lbStyle) {
130     case BS_SOLID:
131         PSDRV_SetBrush(dc);
132         PSDRV_WriteGSave(dc);
133         PSDRV_Fill(dc, EO);
134         PSDRV_WriteGRestore(dc);
135         return TRUE;
136         break;
137
138     case BS_HATCHED:
139         PSDRV_SetBrush(dc);
140
141         switch(brush->logbrush.lbHatch) {
142         case HS_VERTICAL:
143         case HS_CROSS:
144             PSDRV_WriteGSave(dc);
145             PSDRV_Clip(dc, EO);
146             PSDRV_WriteHatch(dc);
147             PSDRV_WriteStroke(dc);
148             PSDRV_WriteGRestore(dc);
149             if(brush->logbrush.lbHatch == HS_VERTICAL)
150                 break;
151             /* else fallthrough for HS_CROSS */
152
153         case HS_HORIZONTAL:
154             PSDRV_WriteGSave(dc);
155             PSDRV_Clip(dc, EO);
156             PSDRV_WriteRotate(dc, 90.0);
157             PSDRV_WriteHatch(dc);
158             PSDRV_WriteStroke(dc);
159             PSDRV_WriteGRestore(dc);
160             break;
161
162         case HS_FDIAGONAL:
163         case HS_DIAGCROSS:
164             PSDRV_WriteGSave(dc);
165             PSDRV_Clip(dc, EO);
166             PSDRV_WriteRotate(dc, -45.0);
167             PSDRV_WriteHatch(dc);
168             PSDRV_WriteStroke(dc);
169             PSDRV_WriteGRestore(dc);
170             if(brush->logbrush.lbHatch == HS_FDIAGONAL)
171                 break;
172             /* else fallthrough for HS_DIAGCROSS */
173             
174         case HS_BDIAGONAL:
175             PSDRV_WriteGSave(dc);
176             PSDRV_Clip(dc, EO);
177             PSDRV_WriteRotate(dc, 45.0);
178             PSDRV_WriteHatch(dc);
179             PSDRV_WriteStroke(dc);
180             PSDRV_WriteGRestore(dc);
181             break;
182
183         default:
184             ERR(psdrv, "Unknown hatch style\n");
185             return FALSE;
186         }
187         return TRUE;
188         break;
189
190     case BS_NULL:
191         return TRUE;
192         break;
193
194     default:
195         return FALSE;
196         break;
197     }
198 }
199
200
201
202