shape.h

00001 /***************************************************************************
00002  *   Copyright (C) 2004 by Rick L. Vinyard, Jr.                            *
00003  *   rvinyard@cs.nmsu.edu                                                  *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU Lesser General Public License as        *
00007  *   published by the Free Software Foundation version 2.1.                *
00008  *                                                                         *
00009  *   This program is distributed in the hope that it will be useful,       *
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00012  *   GNU General Public License for more details.                          *
00013  *                                                                         *
00014  *   You should have received a copy of the GNU Lesser General Public      *
00015  *   License along with this library; if not, write to the                 *
00016  *   Free Software Foundation, Inc.,                                       *
00017  *   51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA              *
00018  ***************************************************************************/
00019 #ifndef PAPYRUSSHAPE_H
00020 #define PAPYRUSSHAPE_H
00021 
00022 #include <papyrus/enums.h>
00023 #include <papyrus/drawable.h>
00024 #include <papyrus/linestyle.h>
00025 
00026 namespace Papyrus
00027 {
00028 
00044   class Shape : public Drawable
00045   {
00046   public:
00047     typedef PapyrusSmartPointer<Shape> pointer;
00048 
00050     Shape( );
00051 
00053     Shape( Cairo::RefPtr<Cairo::Pattern> fill );
00054 
00056     Shape( Cairo::RefPtr<Cairo::Pattern> fill, const LineStyle& outline, bool use_outline = true );
00057 
00059     virtual ~Shape();
00060 
00065     virtual void draw( Cairo::RefPtr<Cairo::Context> cairo );
00066 
00072     virtual void draw_shape( Cairo::RefPtr<Cairo::Context> cairo ) = 0;
00073 
00079     virtual void draw_outline( Cairo::RefPtr<Cairo::Context> cairo );
00080 
00082     Cairo::RefPtr<Cairo::Pattern> fill();
00083 
00085     void set_fill( Cairo::RefPtr<Cairo::Pattern> fill = Cairo::RefPtr<Cairo::Pattern>() );
00086 
00088     LineStyle& outline();
00089 
00094     void set_outline( const LineStyle& outline, bool use_outline = true );
00095 
00100     void set_outline( Cairo::RefPtr<Cairo::Pattern> pattern, bool use_outline = true );
00101 
00103     bool use_outline();
00104 
00109     void set_use_outline( bool use_outline );
00110 
00111     PAPYRUS_CLASS_NAME("Shape");
00112 
00113     protected:
00117     Cairo::RefPtr<Cairo::Pattern> m_fill;
00118     LineStyle m_outline;
00119     bool m_use_outline;
00120     Cairo::Path* m_fill_path;
00121     Cairo::Path* m_outline_path;
00122 
00123     sigc::connection m_outline_changed_connection;
00124     Region m_internal_extents;
00125 
00129     virtual void set_extents( const Region& extents );
00130 
00131     virtual void on_outline_changed();
00132 
00133     virtual void shape_changed( unsigned which=FILL|OUTLINE );
00134 
00135 
00136   };
00137 
00138 }
00139 
00140 #endif

Generated on Sun Jan 7 22:53:57 2007 by  doxygen 1.5.1