Add missing cairomm lib from previous commit.
[ardour.git] / libs / cairomm / cairomm / pattern.h
1 /* Copyright (C) 2005 The cairomm Development Team
2  *
3  * This library is free software; you can redistribute it and/or
4  * modify it under the terms of the GNU Library General Public
5  * License as published by the Free Software Foundation; either
6  * version 2 of the License, or (at your option) any later version.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11  * Library General Public License for more details.
12  *
13  * You should have received a copy of the GNU Library General Public
14  * License along with this library; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16  * 02110-1301, USA.
17  */
18
19 #ifndef __CAIROMM_PATTERN_H
20 #define __CAIROMM_PATTERN_H
21
22 #include <cairomm/surface.h>
23 #include <cairomm/enums.h>
24 #include <cairo.h>
25
26
27 namespace Cairo
28 {
29
30 /**
31  * This is a reference-counted object that should be used via Cairo::RefPtr.
32  */
33 class Pattern
34 {
35 protected:
36   //Use derived constructors.
37
38   //TODO?: Pattern(cairo_pattern_t *target);
39
40 public:
41
42   /** Create a C++ wrapper for the C instance. This C++ instance should then be given to a RefPtr.
43    * @param cobject The C instance.
44    * @param has_reference Whether we already have a reference. Otherwise, the constructor will take an extra reference.
45    */
46   explicit Pattern(cairo_pattern_t* cobject, bool has_reference = false);
47
48   virtual ~Pattern();
49
50   void set_matrix(const cairo_matrix_t &matrix);
51   void get_matrix(cairo_matrix_t &matrix) const;
52   PatternType get_type() const;
53
54   typedef cairo_pattern_t cobject;
55   inline cobject* cobj() { return m_cobject; }
56   inline const cobject* cobj() const { return m_cobject; }
57
58   #ifndef DOXYGEN_IGNORE_THIS
59   ///For use only by the cairomm implementation.
60   inline ErrorStatus get_status() const
61   { return cairo_pattern_status(const_cast<cairo_pattern_t*>(cobj())); }
62   #endif //DOXYGEN_IGNORE_THIS
63
64   void reference() const;
65   void unreference() const;
66
67 protected:
68   //Used by derived types only.
69   Pattern();
70
71   cobject* m_cobject;
72 };
73
74 class SolidPattern : public Pattern
75 {
76 protected:
77
78 public:
79
80   /** Create a C++ wrapper for the C instance.
81    * @param cobject The C instance.
82    * @param has_reference Whether we already have a reference. Otherwise, the constructor will take an extra reference.
83    */
84   explicit SolidPattern(cairo_pattern_t* cobject, bool has_reference = false);
85
86   static RefPtr<SolidPattern> create_rgb(double red, double green, double blue);
87   static RefPtr<SolidPattern> create_rgba(double red, double green, double blue, double alpha);
88
89   //TODO?: SolidPattern(cairo_pattern_t *target);
90   virtual ~SolidPattern();
91 };
92
93 class SurfacePattern : public Pattern
94 {
95 protected:
96
97   explicit SurfacePattern(const RefPtr<Surface>& surface);
98
99   //TODO?: SurfacePattern(cairo_pattern_t *target);
100
101 public:
102
103   /** Create a C++ wrapper for the C instance. This C++ instance should then be given to a RefPtr.
104    * @param cobject The C instance.
105    * @param has_reference Whether we already have a reference. Otherwise, the constructor will take an extra reference.
106    */
107   explicit SurfacePattern(cairo_pattern_t* cobject, bool has_reference = false);
108
109
110   virtual ~SurfacePattern();
111
112   static RefPtr<SurfacePattern> create(const RefPtr<Surface>& surface);
113
114   void set_extend(Extend extend);
115   Extend get_extend() const;
116   void set_filter(Filter filter);
117   Filter get_filter() const;
118 };
119
120 class Gradient : public Pattern
121 {
122 protected:
123   //Use derived constructors.
124
125   //TODO?: Gradient(cairo_pattern_t *target);
126
127 public:
128
129   /** Create a C++ wrapper for the C instance. This C++ instance should then be given to a RefPtr.
130    * @param cobject The C instance.
131    * @param has_reference Whether we already have a reference. Otherwise, the constructor will take an extra reference.
132    */
133   explicit Gradient(cairo_pattern_t* cobject, bool has_reference = false);
134
135   virtual ~Gradient();
136
137   void add_color_stop_rgb(double offset, double red, double green, double blue);
138   void add_color_stop_rgba(double offset, double red, double green, double blue, double alpha);
139
140 protected:
141   Gradient();
142 };
143
144 class LinearGradient : public Gradient
145 {
146 protected:
147
148   LinearGradient(double x0, double y0, double x1, double y1);
149
150 public:
151
152   /** Create a C++ wrapper for the C instance. This C++ instance should then be given to a RefPtr.
153    * @param cobject The C instance.
154    * @param has_reference Whether we already have a reference. Otherwise, the constructor will take an extra reference.
155    */
156   explicit LinearGradient(cairo_pattern_t* cobject, bool has_reference = false);
157
158   //TODO?: LinearGradient(cairo_pattern_t *target);
159   virtual ~LinearGradient();
160
161   static RefPtr<LinearGradient> create(double x0, double y0, double x1, double y1);
162 };
163
164 class RadialGradient : public Gradient
165 {
166 protected:
167
168   RadialGradient(double cx0, double cy0, double radius0, double cx1, double cy1, double radius1);
169
170 public:
171
172   /** Create a C++ wrapper for the C instance. This C++ instance should then be given to a RefPtr.
173    * @param cobject The C instance.
174    * @param has_reference Whether we already have a reference. Otherwise, the constructor will take an extra reference.
175    */
176   explicit RadialGradient(cairo_pattern_t* cobject, bool has_reference = false);
177
178
179   //TODO?: RadialGradient(cairo_pattern_t *target);
180   virtual ~RadialGradient();
181
182   static RefPtr<RadialGradient> create(double cx0, double cy0, double radius0, double cx1, double cy1, double radius1);
183 };
184
185 } // namespace Cairo
186
187 #endif //__CAIROMM_PATTERN_H
188
189 // vim: ts=2 sw=2 et