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
00033 class Pattern
00034 {
00035 protected:
00036
00037
00038
00039
00040 public:
00041
00046 explicit Pattern(cairo_pattern_t* cobject, bool has_reference = false);
00047
00048 virtual ~Pattern();
00049
00050 void set_matrix(const cairo_matrix_t &matrix);
00051 void get_matrix(cairo_matrix_t &matrix) const;
00052 PatternType get_type() const;
00053
00054 typedef cairo_pattern_t cobject;
00055 inline cobject* cobj() { return m_cobject; }
00056 inline const cobject* cobj() const { return m_cobject; }
00057
00058 #ifndef DOXYGEN_IGNORE_THIS
00060 inline ErrorStatus get_status() const
00061 { return cairo_pattern_status(const_cast<cairo_pattern_t*>(cobj())); }
00062 #endif //DOXYGEN_IGNORE_THIS
00063
00064 void reference() const;
00065 void unreference() const;
00066
00067 protected:
00068
00069 Pattern();
00070
00071 cobject* m_cobject;
00072 };
00073
00074 class SolidPattern : public Pattern
00075 {
00076 protected:
00077
00078 public:
00079
00084 explicit SolidPattern(cairo_pattern_t* cobject, bool has_reference = false);
00085
00086 static RefPtr<SolidPattern> create_rgb(double red, double green, double blue);
00087 static RefPtr<SolidPattern> create_rgba(double red, double green, double blue, double alpha);
00088
00089
00090 virtual ~SolidPattern();
00091 };
00092
00093 class SurfacePattern : public Pattern
00094 {
00095 protected:
00096
00097 explicit SurfacePattern(const RefPtr<Surface>& surface);
00098
00099
00100
00101 public:
00102
00107 explicit SurfacePattern(cairo_pattern_t* cobject, bool has_reference = false);
00108
00109
00110 virtual ~SurfacePattern();
00111
00112 static RefPtr<SurfacePattern> create(const RefPtr<Surface>& surface);
00113
00114 void set_extend(Extend extend);
00115 Extend get_extend() const;
00116 void set_filter(Filter filter);
00117 Filter get_filter() const;
00118 };
00119
00120 class Gradient : public Pattern
00121 {
00122 protected:
00123
00124
00125
00126
00127 public:
00128
00133 explicit Gradient(cairo_pattern_t* cobject, bool has_reference = false);
00134
00135 virtual ~Gradient();
00136
00137 void add_color_stop_rgb(double offset, double red, double green, double blue);
00138 void add_color_stop_rgba(double offset, double red, double green, double blue, double alpha);
00139
00140 protected:
00141 Gradient();
00142 };
00143
00144 class LinearGradient : public Gradient
00145 {
00146 protected:
00147
00148 LinearGradient(double x0, double y0, double x1, double y1);
00149
00150 public:
00151
00156 explicit LinearGradient(cairo_pattern_t* cobject, bool has_reference = false);
00157
00158
00159 virtual ~LinearGradient();
00160
00161 static RefPtr<LinearGradient> create(double x0, double y0, double x1, double y1);
00162 };
00163
00164 class RadialGradient : public Gradient
00165 {
00166 protected:
00167
00168 RadialGradient(double cx0, double cy0, double radius0, double cx1, double cy1, double radius1);
00169
00170 public:
00171
00176 explicit RadialGradient(cairo_pattern_t* cobject, bool has_reference = false);
00177
00178
00179
00180 virtual ~RadialGradient();
00181
00182 static RefPtr<RadialGradient> create(double cx0, double cy0, double radius0, double cx1, double cy1, double radius1);
00183 };
00184
00185 }
00186
00187 #endif //__CAIROMM_PATTERN_H
00188
00189