Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

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
00015  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
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   //Use derived constructors.
00040 
00041   //TODO?: Pattern(cairo_pattern_t *target);
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   //Used by derived types only.
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   //TODO?: SolidPattern(cairo_pattern_t *target);
00092   virtual ~SolidPattern();
00093 };
00094 
00095 class SurfacePattern : public Pattern
00096 {
00097 protected:
00098 
00099   explicit SurfacePattern(const RefPtr<Surface>& surface);
00100 
00101   //TODO?: SurfacePattern(cairo_pattern_t *target);
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   //Use derived constructors.
00126 
00127   //TODO?: Gradient(cairo_pattern_t *target);
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   //TODO?: LinearGradient(cairo_pattern_t *target);
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   //TODO?: RadialGradient(cairo_pattern_t *target);
00182   virtual ~RadialGradient();
00183 
00184   static RefPtr<RadialGradient> create(double cx0, double cy0, double radius0, double cx1, double cy1, double radius1);
00185 };
00186 
00187 } // namespace Cairo
00188 
00189 #endif //__CAIROMM_PATTERN_H
00190 

Generated on Thu Feb 9 12:47:13 2006 for cairomm by  doxygen 1.4.4