papyrus logo

gradient.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2009 by Rick L. Vinyard, Jr.                            *
00003  *   rvinyard@cs.nmsu.edu                                                  *
00004  *                                                                         *
00005  *   This file is part of the papyrus library.                             *
00006  *                                                                         *
00007  *   papyrus is free software; you can redistribute it and/or modify       *
00008  *   it under the terms of the GNU Lesser General Public License           *
00009  *   version 3.0 as published by the Free Software Foundation.             *
00010  *                                                                         *
00011  *   papyrus is distributed in the hope that it will be useful,            *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU Lesser General Public License version 3.0 for more details.       *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Lesser General Public      *
00017  *   License along with the papyrus library. If not, see                   *
00018  *   <http://www.gnu.org/licenses/>.                                       *
00019  ***************************************************************************/
00020 #ifndef PAPYRUSGRADIENT_H
00021 #define PAPYRUSGRADIENT_H
00022 
00023 #include <papyrus/paint.h>
00024 #include <papyrus/rgba.h>
00025 
00026 namespace Papyrus
00027 {
00028 
00037   class Gradient : public Paint
00038   {
00039     protected:
00040       
00041       Gradient();
00042 
00043     public:
00044       
00045       typedef PapyrusPointer<Gradient> pointer;
00046       
00047       ~Gradient();
00048       
00049       GradientUnits units() const;
00050       
00051       void set_units( GradientUnits gu );
00052       
00053       GradientSpread spread() const;
00054       
00055       void set_spread( GradientSpread s );
00056       
00057       const Matrix& transform() const;
00058       
00059       Matrix& transform();
00060       
00061       void set_transform( const Matrix& m );
00062       
00063       Gradient::pointer parent();
00064       
00065       void set_parent( Gradient::pointer p );
00066 
00072     class Stop : public Object
00073       {
00074         public:
00075           
00076           Stop( );
00077 
00078           Stop ( const RGBA& rgba, double offset );
00079 
00080           Stop ( const RGBA& rgba, double offset, double alpha );
00081 
00082           Stop ( const Glib::ustring& id );
00083 
00084           Stop ( const Glib::ustring& id, const RGBA& rgba, double offset );
00085 
00086           Stop ( const Glib::ustring& id, const RGBA& rgba, double offset, double alpha );
00087 
00088           ~Stop();
00089 
00090           double offset() const;
00091 
00092           void set_offset ( double off );
00093 
00094           const RGBA& color() const;
00095 
00096           RGBA& color();
00097 
00098           void set_color ( const RGBA& rgba );
00099 
00100           void unset_color();
00101           
00102           double red() const;
00103           
00104           double green() const;
00105           
00106           double blue() const;
00107 
00108           double alpha() const;
00109 
00110           void set_alpha ( double opa );
00111 
00112         protected:
00113 
00114           bool m_offset_set, m_color_set, m_alpha_set;
00115 
00116           double m_offset;
00117 
00118           RGBA m_color;
00119 
00120           double m_alpha;
00121 
00122       };
00123       
00124     typedef std::vector<Stop> Stops;
00125     
00126     const Stops& stops() const;
00127     
00128     void push_front( const Stop& s );
00129     
00130     void push_back( const Stop& s );
00131     
00132     void insert( Stops::iterator pos, const Stop& s );
00133     
00134     void remove( Stops::iterator pos );
00135     
00136     void clear_stops();
00137 
00138     protected:
00139       
00140       GradientUnits m_units;
00141       
00142       GradientSpread m_spread;
00143       
00144       Matrix m_transform;
00145       
00146       Gradient::pointer m_parent;
00147       
00148       sigc::connection m_parent_changed_connection;
00149       
00150       Stops m_stops;
00151       
00152       void on_parent_changed();
00153       
00154       void on_transform_changed();
00155       
00156       
00157 
00158 
00159   };
00160 
00161 }
00162 
00163 #endif

Generated on Fri Apr 16 12:40:10 2010 for papyrus by doxygen 1.6.1