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
00063 void set_matrix(const cairo_matrix_t& matrix);
00064 void get_matrix(cairo_matrix_t& matrix) const;
00065 PatternType get_type() const;
00066
00067 typedef cairo_pattern_t cobject;
00068 inline cobject* cobj() { return m_cobject; }
00069 inline const cobject* cobj() const { return m_cobject; }
00070
00071 #ifndef DOXYGEN_IGNORE_THIS
00073 inline ErrorStatus get_status() const
00074 { return cairo_pattern_status(const_cast<cairo_pattern_t*>(cobj())); }
00075 #endif //DOXYGEN_IGNORE_THIS
00076
00077 void reference() const;
00078 void unreference() const;
00079
00080 protected:
00081
00082 Pattern();
00083
00084 cobject* m_cobject;
00085 };
00086
00087 class SolidPattern : public Pattern
00088 {
00089 protected:
00090
00091 public:
00092
00097 explicit SolidPattern(cairo_pattern_t* cobject, bool has_reference = false);
00098
00109 void get_rgba (double& red, double& green,
00110 double& blue, double& alpha) const;
00111
00112
00113 static RefPtr<SolidPattern> create_rgb(double red, double green, double blue);
00114
00115
00116 static RefPtr<SolidPattern> create_rgba(double red, double green,
00117 double blue, double alpha);
00118
00119
00120 virtual ~SolidPattern();
00121 };
00122
00123 class SurfacePattern : public Pattern
00124 {
00125 protected:
00126
00127 explicit SurfacePattern(const RefPtr<Surface>& surface);
00128
00129
00130
00131 public:
00132
00137 explicit SurfacePattern(cairo_pattern_t* cobject, bool has_reference = false);
00138
00144 RefPtr<const Surface> get_surface () const;
00145
00151 RefPtr<Surface> get_surface ();
00152
00153 virtual ~SurfacePattern();
00154
00155 static RefPtr<SurfacePattern> create(const RefPtr<Surface>& surface);
00156
00157 void set_extend(Extend extend);
00158 Extend get_extend() const;
00159 void set_filter(Filter filter);
00160 Filter get_filter() const;
00161 };
00162
00163 class Gradient : public Pattern
00164 {
00165 protected:
00166
00167
00168
00169
00170 public:
00171
00176 explicit Gradient(cairo_pattern_t* cobject, bool has_reference = false);
00177
00178 virtual ~Gradient();
00179
00194 void add_color_stop_rgb(double offset, double red, double green, double blue);
00195
00211 void add_color_stop_rgba(double offset, double red, double green, double blue, double alpha);
00212
00213
00214
00215
00216
00217
00218 std::vector<ColorStop> get_color_stops() const;
00219
00220
00221 protected:
00222 Gradient();
00223 };
00224
00225 class LinearGradient : public Gradient
00226 {
00227 protected:
00228
00229 LinearGradient(double x0, double y0, double x1, double y1);
00230
00231 public:
00232
00237 explicit LinearGradient(cairo_pattern_t* cobject, bool has_reference = false);
00238
00249 void get_linear_points(double &x0, double &y0,
00250 double &x1, double &y1) const;
00251
00252
00253 virtual ~LinearGradient();
00254
00255 static RefPtr<LinearGradient> create(double x0, double y0, double x1, double y1);
00256 };
00257
00258 class RadialGradient : public Gradient
00259 {
00260 protected:
00261
00262 RadialGradient(double cx0, double cy0, double radius0, double cx1, double cy1, double radius1);
00263
00264 public:
00265
00270 explicit RadialGradient(cairo_pattern_t* cobject, bool has_reference = false);
00271
00285 void get_radial_circles(double& x0, double& y0, double& r0,
00286 double& x1, double& y1, double& r1) const;
00287
00288
00289 virtual ~RadialGradient();
00290
00291 static RefPtr<RadialGradient> create(double cx0, double cy0, double radius0, double cx1, double cy1, double radius1);
00292 };
00293
00294 }
00295
00296 #endif //__CAIROMM_PATTERN_H
00297
00298