diff options
Diffstat (limited to 'cairomm/pattern.h')
-rw-r--r-- | cairomm/pattern.h | 160 |
1 files changed, 146 insertions, 14 deletions
diff --git a/cairomm/pattern.h b/cairomm/pattern.h index 1ebbc87..dd2bb15 100644 --- a/cairomm/pattern.h +++ b/cairomm/pattern.h @@ -18,6 +18,7 @@ #ifndef __CAIROMM_PATTERN_H #define __CAIROMM_PATTERN_H +#include <cairomm/surface.h> #include <cairomm/enums.h> #include <cairo/cairo.h> @@ -35,7 +36,7 @@ typedef cairo_filter_t Filter; class Pattern { public: - Pattern(); + //Use derived constructors. /** Create a C++ wrapper for the C instance. * @param cobject The C instance. @@ -56,21 +57,8 @@ public: */ Pattern& operator=(const Pattern& src); - static Pattern create_rgb(double red, double green, double blue); - static Pattern create_rgba(double red, double green, double blue, double alpha); - - static Pattern create_for_surface(cairo_surface_t *surface); - static Pattern create_linear(double x0, double y0, double x1, double y1); - static Pattern create_radial(double cx0, double cy0, double radius0, double cx1, double cy1, double radius1); - - void add_color_stop_rgb(double offset, double red, double green, double blue); - void add_color_stop_rgba(double offset, double red, double green, double blue, double alpha); void set_matrix(const cairo_matrix_t &matrix); void get_matrix(cairo_matrix_t &matrix) const; - void set_extend(Extend extend); - Extend get_extend() const; - void set_filter(Filter filter); - Filter get_filter() const; typedef cairo_pattern_t cobject; inline cobject* cobj() { return m_cobject; } @@ -83,9 +71,153 @@ public: #endif //DOXYGEN_IGNORE_THIS protected: + //Used by derived types only. + Pattern(); + cobject* m_cobject; }; +class SolidPattern : public Pattern +{ +public: + + static SolidPattern create_rgb(double red, double green, double blue); + static SolidPattern create_rgba(double red, double green, double blue, double alpha); + + /** Create a C++ wrapper for the C instance. + * @param cobject The C instance. + * @param has_reference Whether we already have a reference. Otherwise, the constructor will take an extra reference. + */ + explicit SolidPattern(cairo_pattern_t* cobject, bool has_reference = false); + + /** Create a second reference to the Pattern. + * Changing this instance will change the original instance. + */ + SolidPattern(const SolidPattern& src); + + //TODO?: SolidPattern(cairo_pattern_t *target); + virtual ~SolidPattern(); + + /** Create a second reference to the Pattern. + * Changing this instance will change the original instance. + */ + SolidPattern& operator=(const SolidPattern& src); +}; + +class SurfacePattern : public Pattern +{ +public: + + explicit SurfacePattern(Surface& surface); + + /** Create a C++ wrapper for the C instance. + * @param cobject The C instance. + * @param has_reference Whether we already have a reference. Otherwise, the constructor will take an extra reference. + */ + explicit SurfacePattern(cairo_pattern_t* cobject, bool has_reference = false); + + /** Create a second reference to the Pattern. + * Changing this instance will change the original instance. + */ + SurfacePattern(const SurfacePattern& src); + + //TODO?: SurfacePattern(cairo_pattern_t *target); + virtual ~SurfacePattern(); + + /** Create a second reference to the Pattern. + * Changing this instance will change the original instance. + */ + SurfacePattern& operator=(const SurfacePattern& src); + + void set_extend(Extend extend); + Extend get_extend() const; + void set_filter(Filter filter); + Filter get_filter() const; +}; + +class Gradient : public Pattern +{ +public: + //Use derived constructors. + + /** Create a C++ wrapper for the C instance. + * @param cobject The C instance. + * @param has_reference Whether we already have a reference. Otherwise, the constructor will take an extra reference. + */ + explicit Gradient(cairo_pattern_t* cobject, bool has_reference = false); + + /** Create a second reference to the Pattern. + * Changing this instance will change the original instance. + */ + Gradient(const Gradient& src); + + //TODO?: Gradient(cairo_pattern_t *target); + virtual ~Gradient(); + + /** Create a second reference to the Pattern. + * Changing this instance will change the original instance. + */ + Gradient& operator=(const Gradient& src); + + void add_color_stop_rgb(double offset, double red, double green, double blue); + void add_color_stop_rgba(double offset, double red, double green, double blue, double alpha); + +protected: + Gradient(); +}; + +class LinearGradient : public Gradient +{ +public: + + LinearGradient(double x0, double y0, double x1, double y1); + + /** Create a C++ wrapper for the C instance. + * @param cobject The C instance. + * @param has_reference Whether we already have a reference. Otherwise, the constructor will take an extra reference. + */ + explicit LinearGradient(cairo_pattern_t* cobject, bool has_reference = false); + + /** Create a second reference to the Pattern. + * Changing this instance will change the original instance. + */ + LinearGradient(const LinearGradient& src); + + //TODO?: LinearGradient(cairo_pattern_t *target); + virtual ~LinearGradient(); + + /** Create a second reference to the Pattern. + * Changing this instance will change the original instance. + */ + LinearGradient& operator=(const LinearGradient& src); +}; + +class RadialGradient : public Gradient +{ +public: + + RadialGradient(double cx0, double cy0, double radius0, double cx1, double cy1, double radius1); + + /** Create a C++ wrapper for the C instance. + * @param cobject The C instance. + * @param has_reference Whether we already have a reference. Otherwise, the constructor will take an extra reference. + */ + explicit RadialGradient(cairo_pattern_t* cobject, bool has_reference = false); + + /** Create a second reference to the Pattern. + * Changing this instance will change the original instance. + */ + RadialGradient(const RadialGradient& src); + + //TODO?: RadialGradient(cairo_pattern_t *target); + virtual ~RadialGradient(); + + /** Create a second reference to the Pattern. + * Changing this instance will change the original instance. + */ + RadialGradient& operator=(const RadialGradient& src); +}; + } // namespace Cairo #endif //__CAIROMM_PATTERN_H |