blob: ce01ccb6fed1cf7428344dc44767a8849f40f633 [file] [log] [blame]
Evan Stadecc0a6762007-06-14 16:09:07 -07001/*
2 * Copyright (C) 2007 Google (Evan Stade)
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 */
18
19#include "windef.h"
20#include "wingdi.h"
Evan Stade4c5486f2007-07-31 19:15:48 -070021
22#include "objbase.h"
23
Evan Stadecc0a6762007-06-14 16:09:07 -070024#include "gdiplus.h"
25#include "gdiplus_private.h"
26
Evan Stadeb2b4b872007-07-19 18:23:04 -070027GpStatus WINGDIPAPI GdipCloneBrush(GpBrush *brush, GpBrush **clone)
28{
29 if(!brush || !clone)
30 return InvalidParameter;
31
Evan Stade8b2ce0f2007-07-23 20:24:24 -070032 switch(brush->bt){
33 case BrushTypeSolidColor:
34 *clone = GdipAlloc(sizeof(GpSolidFill));
35 if (!*clone) return OutOfMemory;
Evan Stadeb2b4b872007-07-19 18:23:04 -070036
Evan Stade8b2ce0f2007-07-23 20:24:24 -070037 memcpy(*clone, brush, sizeof(GpSolidFill));
Evan Stadeb2b4b872007-07-19 18:23:04 -070038
Evan Stade8b2ce0f2007-07-23 20:24:24 -070039 (*clone)->gdibrush = CreateBrushIndirect(&(*clone)->lb);
40 break;
41 default:
42 return NotImplemented;
43 }
Evan Stadeb2b4b872007-07-19 18:23:04 -070044
45 return Ok;
46}
47
Evan Stadecc0a6762007-06-14 16:09:07 -070048GpStatus WINGDIPAPI GdipCreateSolidFill(ARGB color, GpSolidFill **sf)
49{
50 COLORREF col = ARGB2COLORREF(color);
51
52 if(!sf) return InvalidParameter;
53
54 *sf = GdipAlloc(sizeof(GpSolidFill));
55 if (!*sf) return OutOfMemory;
56
Evan Stade7af2e972007-07-19 18:22:59 -070057 (*sf)->brush.lb.lbStyle = BS_SOLID;
58 (*sf)->brush.lb.lbColor = col;
59 (*sf)->brush.lb.lbHatch = 0;
60
Evan Stadecc0a6762007-06-14 16:09:07 -070061 (*sf)->brush.gdibrush = CreateSolidBrush(col);
62 (*sf)->brush.bt = BrushTypeSolidColor;
Evan Stade8b2ce0f2007-07-23 20:24:24 -070063 (*sf)->color = color;
Evan Stadecc0a6762007-06-14 16:09:07 -070064
65 return Ok;
66}
67
68GpStatus WINGDIPAPI GdipGetBrushType(GpBrush *brush, GpBrushType *type)
69{
70 if(!brush || !type) return InvalidParameter;
71
72 *type = brush->bt;
73
74 return Ok;
75}
76
77GpStatus WINGDIPAPI GdipDeleteBrush(GpBrush *brush)
78{
79 if(!brush) return InvalidParameter;
80
81 DeleteObject(brush->gdibrush);
82 GdipFree(brush);
83
84 return Ok;
85}
Evan Stade82abeee2007-07-23 20:24:13 -070086
87GpStatus WINGDIPAPI GdipGetSolidFillColor(GpSolidFill *sf, ARGB *argb)
88{
89 if(!sf || !argb)
90 return InvalidParameter;
91
Evan Stade8b2ce0f2007-07-23 20:24:24 -070092 *argb = sf->color;
93
94 return Ok;
Evan Stade82abeee2007-07-23 20:24:13 -070095}
96
97GpStatus WINGDIPAPI GdipSetSolidFillColor(GpSolidFill *sf, ARGB argb)
98{
99 if(!sf)
100 return InvalidParameter;
101
Evan Stade8b2ce0f2007-07-23 20:24:24 -0700102 sf->color = argb;
103 sf->brush.lb.lbColor = ARGB2COLORREF(argb);
104
105 DeleteObject(sf->brush.gdibrush);
106 sf->brush.gdibrush = CreateSolidBrush(sf->brush.lb.lbColor);
107
108 return Ok;
Evan Stade82abeee2007-07-23 20:24:13 -0700109}