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 typedef PapyrusPointer<Shape> pointer; 00056 00058 virtual ~Shape(); 00059 00060 virtual void set( const AttributeValueMap& avmap ); 00061 00066 virtual void draw ( Cairo::RefPtr<Cairo::Context> cairo ) const; 00067 00073 virtual void draw_shape ( Cairo::RefPtr<Cairo::Context> cairo ) const = 0; 00074 00080 virtual void draw_stroke_path ( Cairo::RefPtr<Cairo::Context> cairo ) const; 00081 00083 Fill::pointer fill(); 00084 00086 void set_fill ( Fill::pointer fill ); 00087 00092 void set_fill ( Paint 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 00128 void set_stroke ( Stroke::pointer stroke ); 00129 00134 void set_stroke ( Paint paint ); 00135 00140 void set_stroke ( Cairo::RefPtr<Cairo::Pattern> pattern ); 00141 00146 void set_stroke ( const RGBA& color ); 00147 00152 void set_stroke ( const Glib::ustring& stroke ); 00153 00161 void set_stroke_paint( const Glib::ustring& paint_name ); 00162 00163 void operator=( const Shape& other ); 00164 00165 PAPYRUS_CLASS_NAME ( "Shape" ); 00166 00167 protected: 00171 Fill::pointer m_fill; 00172 Stroke::pointer m_stroke; 00173 mutable Cairo::Path* m_fill_path; 00174 mutable Cairo::Path* m_stroke_path; 00175 00176 sigc::connection m_fill_changed_connection; 00177 sigc::connection m_stroke_changed_connection; 00178 00179 virtual void on_fill_changed(); 00180 00181 virtual void on_stroke_changed(); 00182 00183 virtual void shape_changed ( unsigned which=FILL|STROKE ); 00184 00185 Glib::ustring svg_fill(); 00186 00187 }; 00188 00189 } 00190 00191 #endif