pattern.h

Go to the documentation of this file.
00001 /* Copyright (C) 2005 The cairomm Development Team
00002  *
00003  * This library is free software; you can redistribute it and/or
00004  * modify it under the terms of the GNU Library General Public
00005  * License as published by the Free Software Foundation; either
00006  * version 2 of the License, or (at your option) any later version.
00007  *
00008  * This library is distributed in the hope that it will be useful,
00009  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011  * Library General Public License for more details.
00012  *
00013  * You should have received a copy of the GNU Library General Public
00014  * License along with this library; if not, write to the Free Software
00015  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00016  * 02110-1301, USA.
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   //Use derived constructors.
00037 
00038   //TODO?: Pattern(cairo_pattern_t *target);
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   //Used by derived types only.
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   //TODO?: SolidPattern(cairo_pattern_t *target);
00090   virtual ~SolidPattern();
00091 };
00092 
00093 class SurfacePattern : public Pattern
00094 {
00095 protected:
00096 
00097   explicit SurfacePattern(const RefPtr<Surface>& surface);
00098 
00099   //TODO?: SurfacePattern(cairo_pattern_t *target);
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   //Use derived constructors.
00124 
00125   //TODO?: Gradient(cairo_pattern_t *target);
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   //TODO?: LinearGradient(cairo_pattern_t *target);
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   //TODO?: RadialGradient(cairo_pattern_t *target);
00180   virtual ~RadialGradient();
00181 
00182   static RefPtr<RadialGradient> create(double cx0, double cy0, double radius0, double cx1, double cy1, double radius1);
00183 };
00184 
00185 } // namespace Cairo
00186 
00187 #endif //__CAIROMM_PATTERN_H
00188 
00189 // vim: ts=2 sw=2 et

Generated on Tue Aug 22 04:01:06 2006 for cairomm by  doxygen 1.4.7