00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __CAIROMM_PATTERN_H
00020 #define __CAIROMM_PATTERN_H
00021
00022 #include <cairomm/surface.h>
00023 #include <cairomm/enums.h>
00024 #include <cairo.h>
00025
00026
00027 namespace Cairo
00028 {
00029 struct ColorStop
00030 {
00031 double offset;
00032 double red, green, blue, alpha;
00033 };
00034
00035 class Matrix;
00036
00040 class Pattern
00041 {
00042 protected:
00043
00044
00045
00046
00047 public:
00048
00053 explicit Pattern(cairo_pattern_t* cobject, bool has_reference = false);
00054
00055 virtual ~Pattern();
00056
00057 void set_matrix(const Matrix& matrix);
00058 void get_matrix(Matrix& matrix) const;
00061 Matrix get_matrix() const;
00062 PatternType get_type() const;
00063
00064 typedef cairo_pattern_t cobject;
00065 inline cobject* cobj() { return m_cobject; }
00066 inline const cobject* cobj() const { return m_cobject; }
00067
00068 #ifndef DOXYGEN_IGNORE_THIS
00070 inline ErrorStatus get_status() const
00071 { return cairo_pattern_status(const_cast<cairo_pattern_t*>(cobj())); }
00072 #endif //DOXYGEN_IGNORE_THIS
00073
00074 void reference() const;
00075 void unreference() const;
00076
00077 protected:
00078
00079 Pattern();
00080
00081 cobject* m_cobject;
00082 };
00083
00084 class SolidPattern : public Pattern
00085 {
00086 protected:
00087
00088 public:
00089
00094 explicit SolidPattern(cairo_pattern_t* cobject, bool has_reference = false);
00095
00106 void get_rgba (double& red, double& green,
00107 double& blue, double& alpha) const;
00108
00109
00110 static RefPtr<SolidPattern> create_rgb(double red, double green, double blue);
00111
00112
00113 static RefPtr<SolidPattern> create_rgba(double red, double green,
00114 double blue, double alpha);
00115
00116
00117 virtual ~SolidPattern();
00118 };
00119
00120 class SurfacePattern : public Pattern
00121 {
00122 protected:
00123
00124 explicit SurfacePattern(const RefPtr<Surface>& surface);
00125
00126
00127
00128 public:
00129
00134 explicit SurfacePattern(cairo_pattern_t* cobject, bool has_reference = false);
00135
00141 RefPtr<const Surface> get_surface () const;
00142
00148 RefPtr<Surface> get_surface ();
00149
00150 virtual ~SurfacePattern();
00151
00152 static RefPtr<SurfacePattern> create(const RefPtr<Surface>& surface);
00153
00154 void set_extend(Extend extend);
00155 Extend get_extend() const;
00156 void set_filter(Filter filter);
00157 Filter get_filter() const;
00158 };
00159
00160 class Gradient : public Pattern
00161 {
00162 protected:
00163
00164
00165
00166
00167 public:
00168
00173 explicit Gradient(cairo_pattern_t* cobject, bool has_reference = false);
00174
00175 virtual ~Gradient();
00176
00191 void add_color_stop_rgb(double offset, double red, double green, double blue);
00192
00208 void add_color_stop_rgba(double offset, double red, double green, double blue, double alpha);
00209
00210
00211
00212
00213
00214
00215 std::vector<ColorStop> get_color_stops() const;
00216
00217
00218 protected:
00219 Gradient();
00220 };
00221
00222 class LinearGradient : public Gradient
00223 {
00224 protected:
00225
00226 LinearGradient(double x0, double y0, double x1, double y1);
00227
00228 public:
00229
00234 explicit LinearGradient(cairo_pattern_t* cobject, bool has_reference = false);
00235
00246 void get_linear_points(double &x0, double &y0,
00247 double &x1, double &y1) const;
00248
00249
00250 virtual ~LinearGradient();
00251
00252 static RefPtr<LinearGradient> create(double x0, double y0, double x1, double y1);
00253 };
00254
00255 class RadialGradient : public Gradient
00256 {
00257 protected:
00258
00259 RadialGradient(double cx0, double cy0, double radius0, double cx1, double cy1, double radius1);
00260
00261 public:
00262
00267 explicit RadialGradient(cairo_pattern_t* cobject, bool has_reference = false);
00268
00282 void get_radial_circles(double& x0, double& y0, double& r0,
00283 double& x1, double& y1, double& r1) const;
00284
00285
00286 virtual ~RadialGradient();
00287
00288 static RefPtr<RadialGradient> create(double cx0, double cy0, double radius0, double cx1, double cy1, double radius1);
00289 };
00290
00291 }
00292
00293 #endif //__CAIROMM_PATTERN_H
00294
00295