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   protected:
00047 
00049       Shape( Cairo::RefPtr<Cairo::Pattern> fill = Cairo::RefPtr<Cairo::Pattern>() );
00050 
00052       Shape( Cairo::RefPtr<Cairo::Pattern> fill, const LineStyle& outline );
00053 
00054   public:
00055     typedef PapyrusSmartPointer<Shape> pointer;
00056 
00058     virtual ~Shape();
00059 
00064     virtual void draw( Cairo::RefPtr<Cairo::Context> cairo );
00065 
00071     virtual void draw_shape( Cairo::RefPtr<Cairo::Context> cairo ) = 0;
00072 
00078     virtual void draw_outline( Cairo::RefPtr<Cairo::Context> cairo );
00079 
00081     Cairo::RefPtr<Cairo::Pattern> fill();
00082 
00084     void set_fill( Cairo::RefPtr<Cairo::Pattern> fill = Cairo::RefPtr<Cairo::Pattern>() );
00085 
00087     LineStyle& outline();
00088 
00093     void set_outline( const LineStyle& outline, bool use_outline = true );
00094 
00099     void set_outline( Cairo::RefPtr<Cairo::Pattern> pattern, bool use_outline = true );
00100 
00102     bool use_outline();
00103 
00108     void set_use_outline( bool use_outline );
00109 
00110     PAPYRUS_CLASS_NAME("Shape");
00111 
00112     protected:
00116     Cairo::RefPtr<Cairo::Pattern> m_fill;
00117     LineStyle m_outline;
00118     bool m_use_outline;
00119     Cairo::Path* m_fill_path;
00120     Cairo::Path* m_outline_path;
00121 
00122     sigc::connection m_outline_changed_connection;
00123     Region m_internal_extents;
00124 
00128     virtual void set_extents( const Region& extents );
00129 
00130     virtual void on_outline_changed();
00131 
00132     virtual void shape_changed( unsigned which=FILL|OUTLINE );
00133 
00134 
00135   };
00136 
00137 }
00138 
00139 #endif

Generated on Sun Mar 11 10:01:28 2007 by  doxygen 1.5.1