1 /* Copyright (C) 2005 The cairomm Development Team
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.
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.
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
19 #ifndef __CAIROMM_PATTERN_H
20 #define __CAIROMM_PATTERN_H
22 #include <cairomm/surface.h>
23 #include <cairomm/enums.h>
31 * This is a reference-counted object that should be used via Cairo::RefPtr.
36 //Use derived constructors.
38 //TODO?: Pattern(cairo_pattern_t *target);
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.
46 explicit Pattern(cairo_pattern_t* cobject, bool has_reference = false);
50 void set_matrix(const cairo_matrix_t &matrix);
51 void get_matrix(cairo_matrix_t &matrix) const;
52 PatternType get_type() const;
54 typedef cairo_pattern_t cobject;
55 inline cobject* cobj() { return m_cobject; }
56 inline const cobject* cobj() const { return m_cobject; }
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
64 void reference() const;
65 void unreference() const;
68 //Used by derived types only.
74 class SolidPattern : public Pattern
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.
84 explicit SolidPattern(cairo_pattern_t* cobject, bool has_reference = false);
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);
89 //TODO?: SolidPattern(cairo_pattern_t *target);
90 virtual ~SolidPattern();
93 class SurfacePattern : public Pattern
97 explicit SurfacePattern(const RefPtr<Surface>& surface);
99 //TODO?: SurfacePattern(cairo_pattern_t *target);
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.
107 explicit SurfacePattern(cairo_pattern_t* cobject, bool has_reference = false);
110 virtual ~SurfacePattern();
112 static RefPtr<SurfacePattern> create(const RefPtr<Surface>& surface);
114 void set_extend(Extend extend);
115 Extend get_extend() const;
116 void set_filter(Filter filter);
117 Filter get_filter() const;
120 class Gradient : public Pattern
123 //Use derived constructors.
125 //TODO?: Gradient(cairo_pattern_t *target);
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.
133 explicit Gradient(cairo_pattern_t* cobject, bool has_reference = false);
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);
144 class LinearGradient : public Gradient
148 LinearGradient(double x0, double y0, double x1, double y1);
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.
156 explicit LinearGradient(cairo_pattern_t* cobject, bool has_reference = false);
158 //TODO?: LinearGradient(cairo_pattern_t *target);
159 virtual ~LinearGradient();
161 static RefPtr<LinearGradient> create(double x0, double y0, double x1, double y1);
164 class RadialGradient : public Gradient
168 RadialGradient(double cx0, double cy0, double radius0, double cx1, double cy1, double radius1);
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.
176 explicit RadialGradient(cairo_pattern_t* cobject, bool has_reference = false);
179 //TODO?: RadialGradient(cairo_pattern_t *target);
180 virtual ~RadialGradient();
182 static RefPtr<RadialGradient> create(double cx0, double cy0, double radius0, double cx1, double cy1, double radius1);
187 #endif //__CAIROMM_PATTERN_H