papyrus logo

stroke.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2004 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 PAPYRUSSTROKE_H
00021 #define PAPYRUSSTROKE_H
00022 
00023 #include <cmath>
00024 #include <papyrus/renderable.h>
00025 #include <papyrus/drawable.h>
00026 #include <papyrus/paint.h>
00027 
00028 namespace Papyrus
00029 {
00030 
00031   class RGBA;
00032 
00036   class Stroke : public Renderable
00037   {
00038     protected:
00039 
00040       Stroke ( double width,
00041                Cairo::LineCap cap,
00042                Cairo::LineJoin join
00043              );
00044 
00045       Stroke ( Paint::pointer paint,
00046                double width,
00047                Cairo::LineCap cap,
00048                Cairo::LineJoin join
00049              );
00050 
00051     public:
00052       PAPYRUS_RENDERABLE(Stroke);
00053 
00054       static pointer create ( Paint::pointer paint = Paint::pointer(),
00055                               double width = 1.0,
00056                               Cairo::LineCap cap = Cairo::LINE_CAP_BUTT,
00057                               Cairo::LineJoin join = Cairo::LINE_JOIN_MITER
00058                             );
00059 
00060       static pointer create ( double width,
00061                               Cairo::LineCap cap = Cairo::LINE_CAP_BUTT,
00062                               Cairo::LineJoin join = Cairo::LINE_JOIN_MITER
00063                             );
00064 
00065       static pointer create ( Cairo::RefPtr<Cairo::Pattern> pattern,
00066                               double width = 1.0,
00067                               Cairo::LineCap cap = Cairo::LINE_CAP_BUTT,
00068                               Cairo::LineJoin join = Cairo::LINE_JOIN_MITER
00069                             );
00070 
00071       static pointer create ( const RGBA& rgba,
00072                               double width = 1.0,
00073                               Cairo::LineCap cap = Cairo::LINE_CAP_BUTT,
00074                               Cairo::LineJoin join = Cairo::LINE_JOIN_MITER
00075                             );
00076 
00077       static pointer create ( const Glib::ustring& color,
00078                               double width = 1.0,
00079                               Cairo::LineCap cap = Cairo::LINE_CAP_BUTT,
00080                               Cairo::LineJoin join = Cairo::LINE_JOIN_MITER
00081                             );
00082 
00083       virtual ~Stroke();
00084 
00085       Stroke& operator= ( const Stroke& other );
00086 
00087       bool operator== ( const Stroke& other ) const;
00088 
00089       bool operator!= ( const Stroke& other ) const;
00090 
00091       const std::valarray< double >& dash_array();
00092 
00093       double dash_offset();
00094 
00095       void set_dash ( const std::valarray< double > dashes = std::valarray<double>(), double offset = 0.0 );
00096 
00097       Cairo::LineCap cap();
00098 
00099       void set_cap ( Cairo::LineCap cap = Cairo::LINE_CAP_BUTT );
00100 
00102       void set_cap( const Glib::ustring& c );
00103 
00104       Cairo::LineJoin join();
00105 
00106       void set_join ( Cairo::LineJoin join = Cairo::LINE_JOIN_MITER );
00107 
00109       void set_join( const Glib::ustring& c );
00110 
00111       double width();
00112 
00113       void set_width ( double width = 1.0 );
00114 
00115       double miter_limit();
00116 
00117       void set_miter_limit ( double limit = INFINITY );
00118 
00119       Paint::pointer paint();
00120 
00121       void set_paint ( Paint::pointer paint = Paint::pointer() );
00122 
00123       virtual void render ( Context& cairo ) const;
00124 
00125       sigc::signal<void> signal_paint_changed();
00126       sigc::signal<void> signal_width_changed();
00127       sigc::signal<void> signal_cap_changed();
00128       sigc::signal<void> signal_join_changed();
00129       sigc::signal<void> signal_miter_limit_changed();
00130       sigc::signal<void> signal_dash_changed();
00131 
00132     protected:
00133       Paint::pointer m_paint;
00134       double m_width;
00135       Cairo::LineCap m_cap;
00136       Cairo::LineJoin m_join;
00137       double m_miter_limit;
00138       std::valarray<double> m_dash_array;
00139       double m_dash_offset;
00140 
00141       sigc::signal<void> m_signal_paint_changed;
00142       sigc::signal<void> m_signal_width_changed;
00143       sigc::signal<void> m_signal_cap_changed;
00144       sigc::signal<void> m_signal_join_changed;
00145       sigc::signal<void> m_signal_miter_limit_changed;
00146       sigc::signal<void> m_signal_dash_changed;
00147 
00148       sigc::connection m_paint_changed_connection;
00149       void on_paint_changed();
00150 
00151   };
00152 
00153 }
00154 
00155 #endif

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