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 PAPYRUSSHAPE_H 00021 #define PAPYRUSSHAPE_H 00022 00023 #include <papyrus/enums.h> 00024 #include <papyrus/drawable.h> 00025 #include <papyrus/fill.h> 00026 #include <papyrus/rgba.h> 00027 #include <papyrus/stroke.h> 00028 00029 namespace Papyrus 00030 { 00031 00047 class Shape : public Drawable 00048 { 00049 protected: 00050 00052 Shape ( const Glib::ustring& id=Glib::ustring(), Fill::pointer fill = Fill::pointer(), Stroke::pointer stroke = Stroke::pointer() ); 00053 00054 public: 00055 PAPYRUS_RENDERABLE(Shape); 00056 00058 virtual ~Shape(); 00059 00060 virtual void set( const AttributeValueMap& avmap ); 00061 00066 virtual void draw ( Context& cairo ) const; 00067 00073 virtual void draw_shape ( Context& cairo ) const = 0; 00074 00080 virtual void draw_stroke_path ( Context& cairo ) const; 00081 00083 Fill::pointer fill(); 00084 00086 void set_fill ( Fill::pointer fill ); 00087 00092 void set_fill ( Paint::pointer paint ); 00093 00098 void set_fill ( Cairo::RefPtr<Cairo::Pattern> pattern ); 00099 00104 void set_fill( const RGBA& color ); 00105 00110 void set_fill( const Glib::ustring& fill ); 00111 00119 void set_fill_paint( const Glib::ustring& paint_name ); 00120 00122 Stroke::pointer stroke(); 00123 00127 void set_stroke ( Stroke::pointer stroke ); 00128 00133 void set_stroke ( Paint::pointer paint ); 00134 00139 void set_stroke ( Cairo::RefPtr<Cairo::Pattern> pattern ); 00140 00145 void set_stroke ( const RGBA& color ); 00146 00151 void set_stroke ( const Glib::ustring& stroke ); 00152 00160 void set_stroke_paint( const Glib::ustring& paint_name ); 00161 00162 void operator=( const Shape& other ); 00163 00164 protected: 00168 Fill::pointer m_fill; 00169 Stroke::pointer m_stroke; 00170 mutable Cairo::Path* m_fill_path; 00171 mutable Cairo::Path* m_stroke_path; 00172 00173 sigc::connection m_fill_changed_connection; 00174 sigc::connection m_stroke_changed_connection; 00175 00176 virtual void on_fill_changed(); 00177 00178 virtual void on_stroke_changed(); 00179 00180 virtual void shape_changed ( unsigned which=FILL|STROKE ); 00181 00182 Glib::ustring svg_fill(); 00183 00184 }; 00185 00186 } 00187 00188 #endif