00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __CAIROMM_PATTERN_H
00019 #define __CAIROMM_PATTERN_H
00020
00021 #include <cairomm/surface.h>
00022 #include <cairomm/enums.h>
00023 #include <cairo/cairo.h>
00024
00025
00026 namespace Cairo
00027 {
00028
00029 typedef cairo_extend_t Extend;
00030 typedef cairo_filter_t Filter;
00031
00036 class Pattern
00037 {
00038 protected:
00039
00040
00041
00042
00043 public:
00044
00049 explicit Pattern(cairo_pattern_t* cobject, bool has_reference = false);
00050
00051 virtual ~Pattern();
00052
00053 void set_matrix(const cairo_matrix_t &matrix);
00054 void get_matrix(cairo_matrix_t &matrix) const;
00055
00056 typedef cairo_pattern_t cobject;
00057 inline cobject* cobj() { return m_cobject; }
00058 inline const cobject* cobj() const { return m_cobject; }
00059
00060 #ifndef DOXYGEN_IGNORE_THIS
00061
00062 inline ErrorStatus get_status() const
00063 { return cairo_pattern_status(const_cast<cairo_pattern_t*>(cobj())); }
00064 #endif //DOXYGEN_IGNORE_THIS
00065
00066 void reference() const;
00067 void unreference() const;
00068
00069 protected:
00070
00071 Pattern();
00072
00073 cobject* m_cobject;
00074 };
00075
00076 class SolidPattern : public Pattern
00077 {
00078 protected:
00079
00080 public:
00081
00086 explicit SolidPattern(cairo_pattern_t* cobject, bool has_reference = false);
00087
00088 static RefPtr<SolidPattern> create_rgb(double red, double green, double blue);
00089 static RefPtr<SolidPattern> create_rgba(double red, double green, double blue, double alpha);
00090
00091
00092 virtual ~SolidPattern();
00093 };
00094
00095 class SurfacePattern : public Pattern
00096 {
00097 protected:
00098
00099 explicit SurfacePattern(const RefPtr<Surface>& surface);
00100
00101
00102
00103 public:
00104
00109 explicit SurfacePattern(cairo_pattern_t* cobject, bool has_reference = false);
00110
00111
00112 virtual ~SurfacePattern();
00113
00114 static RefPtr<SurfacePattern> create(const RefPtr<Surface>& surface);
00115
00116 void set_extend(Extend extend);
00117 Extend get_extend() const;
00118 void set_filter(Filter filter);
00119 Filter get_filter() const;
00120 };
00121
00122 class Gradient : public Pattern
00123 {
00124 protected:
00125
00126
00127
00128
00129 public:
00130
00135 explicit Gradient(cairo_pattern_t* cobject, bool has_reference = false);
00136
00137 virtual ~Gradient();
00138
00139 void add_color_stop_rgb(double offset, double red, double green, double blue);
00140 void add_color_stop_rgba(double offset, double red, double green, double blue, double alpha);
00141
00142 protected:
00143 Gradient();
00144 };
00145
00146 class LinearGradient : public Gradient
00147 {
00148 protected:
00149
00150 LinearGradient(double x0, double y0, double x1, double y1);
00151
00152 public:
00153
00158 explicit LinearGradient(cairo_pattern_t* cobject, bool has_reference = false);
00159
00160
00161 virtual ~LinearGradient();
00162
00163 static RefPtr<LinearGradient> create(double x0, double y0, double x1, double y1);
00164 };
00165
00166 class RadialGradient : public Gradient
00167 {
00168 protected:
00169
00170 RadialGradient(double cx0, double cy0, double radius0, double cx1, double cy1, double radius1);
00171
00172 public:
00173
00178 explicit RadialGradient(cairo_pattern_t* cobject, bool has_reference = false);
00179
00180
00181
00182 virtual ~RadialGradient();
00183
00184 static RefPtr<RadialGradient> create(double cx0, double cy0, double radius0, double cx1, double cy1, double radius1);
00185 };
00186
00187 }
00188
00189 #endif //__CAIROMM_PATTERN_H
00190