papyrus logo

Papyrus::Shape Class Reference

Papyrus::Shape inherits the concepts of spatial placement and meaningful affine transforms from its parent Papyrus::Drawable, and extends it with the concept of stroking and filling. More...

#include <shape.h>

Inheritance diagram for Papyrus::Shape:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 PAPYRUS_RENDERABLE (Shape)
virtual ~Shape ()
 Destructor.
virtual void set (const AttributeValueMap &avmap)
virtual void draw (Context &cairo) const
 Implement Drawable's virtual draw method that takes care of filling and stroking the shape when the fill and/or stroke patterns are present.
virtual void draw_shape (Context &cairo) const =0
 Children should provide their own implementations of this pure virtual method.
virtual void draw_stroke_path (Context &cairo) const
 The default implementation calls upon draw_shape() to create the path, but a child should provide their own implementation if the draw_shape() is not sufficient for stroking.
Fill::pointer fill ()
 The pattern that will be used to fill this shape.
void set_fill (Fill::pointer fill)
 Sets the pattern that will be used to fill this shape.
void set_fill (Paint::pointer paint)
 Creates a new Fill object for the paint and replaces the current fill with the new fill object.
void set_fill (Cairo::RefPtr< Cairo::Pattern > pattern)
 Creates a new Fill object for the pattern and replaces the current fill with the new fill object.
void set_fill (const RGBA &color)
 Creates a new Fill object for the color and replaces the current fill with the new fill object.
void set_fill (const Glib::ustring &fill)
 Creates a new Fill object for the color and replaces the current fill with the new fill object.
void set_fill_paint (const Glib::ustring &paint_name)
 Sets only the fill paint (not other fill characteristics) to the named paint.
Stroke::pointer stroke ()
 The Stroke that will be used to draw the stroke.
void set_stroke (Stroke::pointer stroke)
 Sets the stroke style that will be used to stroke this shape.
void set_stroke (Paint::pointer paint)
 Creates a new Stroke object for the paint and replaces the current stroke with the new stroke object.
void set_stroke (Cairo::RefPtr< Cairo::Pattern > pattern)
 Creates a new Stroke object for the pattern and replaces the current stroke with the new stroke object.
void set_stroke (const RGBA &color)
 Creates a new Stroke object for the pattern and replaces the current stroke with the new stroke object.
void set_stroke (const Glib::ustring &stroke)
 Creates a new Stroke object for the pattern and replaces the current stroke with the new stroke object.
void set_stroke_paint (const Glib::ustring &paint_name)
 Sets only the stroke paint (not other stroke characteristics) to the named paint.
void operator= (const Shape &other)

Protected Member Functions

 Shape (const Glib::ustring &id=Glib::ustring(), Fill::pointer fill=Fill::pointer(), Stroke::pointer stroke=Stroke::pointer())
 Constructor that accepts a fill and stroke.
virtual void on_fill_changed ()
virtual void on_stroke_changed ()
virtual void shape_changed (unsigned which=FILL|STROKE)
Glib::ustring svg_fill ()

Protected Attributes

Fill::pointer m_fill
 The fill and stroke patterns for this shape.
Stroke::pointer m_stroke
Cairo::Path * m_fill_path
Cairo::Path * m_stroke_path
sigc::connection m_fill_changed_connection
sigc::connection m_stroke_changed_connection

Detailed Description

Papyrus::Shape inherits the concepts of spatial placement and meaningful affine transforms from its parent Papyrus::Drawable, and extends it with the concept of stroking and filling.

When inheriting from Papyrus::Shape you should provide a child specific implementation of the draw_shape() method (and not the draw() method from Papyrus::Drawable). This method should use cairo methods to draw the structure of your shape that will be filled with the pattern set by calling the set_fill() method.

In most cases, providing a child specific implementation of the draw_shape() method will be sufficient. However, if your child needs specific methods to perform outlining you should also override the stroke() method.

Author:
Rick L Vinyard Jr

Constructor & Destructor Documentation

Papyrus::Shape::Shape ( const Glib::ustring &  id = Glib::ustring(),
Fill::pointer  fill = Fill::pointer(),
Stroke::pointer  stroke = Stroke::pointer() 
) [protected]

Constructor that accepts a fill and stroke.

References m_fill, m_fill_changed_connection, m_stroke, m_stroke_changed_connection, on_fill_changed(), and on_stroke_changed().

Papyrus::Shape::~Shape (  )  [virtual]

Destructor.

References m_fill_path, and m_stroke_path.


Member Function Documentation

void Papyrus::Shape::draw ( Context cairo  )  const [virtual]

Implement Drawable's virtual draw method that takes care of filling and stroking the shape when the fill and/or stroke patterns are present.

Implements Papyrus::Drawable.

Reimplemented in Papyrus::Bezierline, and Papyrus::Polyline.

References draw_shape(), draw_stroke_path(), Papyrus::Context::fill(), fill(), m_fill, m_fill_path, Papyrus::Drawable::m_parent, m_stroke, m_stroke_path, Papyrus::Context::stroke(), and stroke().

virtual void Papyrus::Shape::draw_shape ( Context cairo  )  const [pure virtual]

Children should provide their own implementations of this pure virtual method.

A child should create the necessary path that will be filled by the draw() method.

Implemented in Papyrus::Annulus, Papyrus::Arc, Papyrus::Beziergon, Papyrus::Bezierline, Papyrus::Circle, Papyrus::Marker, Papyrus::Path, Papyrus::Polygon, Papyrus::Polyline, Papyrus::Rectangle, and Papyrus::Text.

Referenced by draw(), and draw_stroke_path().

void Papyrus::Shape::draw_stroke_path ( Context cairo  )  const [virtual]

The default implementation calls upon draw_shape() to create the path, but a child should provide their own implementation if the draw_shape() is not sufficient for stroking.

References draw_shape().

Referenced by draw(), Papyrus::Polyline::draw(), and Papyrus::Bezierline::draw().

Fill::pointer Papyrus::Shape::fill (  ) 

The pattern that will be used to fill this shape.

References m_fill.

Referenced by draw().

void Papyrus::Shape::on_fill_changed (  )  [protected, virtual]

References Papyrus::Drawable::redraw().

Referenced by set_fill(), and Shape().

void Papyrus::Shape::on_stroke_changed (  )  [protected, virtual]
void Papyrus::Shape::operator= ( const Shape other  ) 
Papyrus::Shape::PAPYRUS_RENDERABLE ( Shape   ) 

Reimplemented from Papyrus::Drawable.

void Papyrus::Shape::set ( const AttributeValueMap avmap  )  [virtual]
void Papyrus::Shape::set_fill ( const Glib::ustring &  fill  ) 

Creates a new Fill object for the color and replaces the current fill with the new fill object.

References Papyrus::Fill::create(), Papyrus::Group::lookup_paint(), Papyrus::Drawable::m_parent, and set_fill().

void Papyrus::Shape::set_fill ( const RGBA color  ) 

Creates a new Fill object for the color and replaces the current fill with the new fill object.

References Papyrus::Fill::create(), and set_fill().

void Papyrus::Shape::set_fill ( Cairo::RefPtr< Cairo::Pattern >  pattern  ) 

Creates a new Fill object for the pattern and replaces the current fill with the new fill object.

References Papyrus::Fill::create(), and set_fill().

void Papyrus::Shape::set_fill ( Paint::pointer  paint  ) 

Creates a new Fill object for the paint and replaces the current fill with the new fill object.

References Papyrus::Fill::create(), and set_fill().

void Papyrus::Shape::set_fill ( Fill::pointer  fill  ) 

Sets the pattern that will be used to fill this shape.

References m_fill, m_fill_changed_connection, and on_fill_changed().

Referenced by set(), set_fill(), and set_fill_paint().

void Papyrus::Shape::set_fill_paint ( const Glib::ustring &  paint_name  ) 

Sets only the fill paint (not other fill characteristics) to the named paint.

Shapes do not inherently have a set of paints, therefore they must look to their parents. If they do not have a parent, this will have no effect.

References Papyrus::Fill::create(), m_fill, Papyrus::Drawable::m_parent, and set_fill().

void Papyrus::Shape::set_stroke ( const Glib::ustring &  stroke  ) 

Creates a new Stroke object for the pattern and replaces the current stroke with the new stroke object.

References Papyrus::Stroke::create(), and set_stroke().

void Papyrus::Shape::set_stroke ( const RGBA color  ) 

Creates a new Stroke object for the pattern and replaces the current stroke with the new stroke object.

References Papyrus::Stroke::create(), and set_stroke().

void Papyrus::Shape::set_stroke ( Cairo::RefPtr< Cairo::Pattern >  pattern  ) 

Creates a new Stroke object for the pattern and replaces the current stroke with the new stroke object.

References Papyrus::Stroke::create(), and set_stroke().

void Papyrus::Shape::set_stroke ( Paint::pointer  paint  ) 

Creates a new Stroke object for the paint and replaces the current stroke with the new stroke object.

References Papyrus::Stroke::create(), and set_stroke().

void Papyrus::Shape::set_stroke ( Stroke::pointer  stroke  ) 

Sets the stroke style that will be used to stroke this shape.

References m_stroke, m_stroke_changed_connection, and on_stroke_changed().

Referenced by Papyrus::Marker::Marker(), set(), set_stroke(), and set_stroke_paint().

void Papyrus::Shape::set_stroke_paint ( const Glib::ustring &  paint_name  ) 

Sets only the stroke paint (not other stroke characteristics) to the named paint.

Shapes do not inherently have a set of paints, therefore they must look to their parents. If they do not have a parent, this will have no effect.

References Papyrus::Stroke::create(), Papyrus::Drawable::m_parent, m_stroke, and set_stroke().

void Papyrus::Shape::shape_changed ( unsigned  which = FILL|STROKE  )  [protected, virtual]
Stroke::pointer Papyrus::Shape::stroke (  ) 

The Stroke that will be used to draw the stroke.

References m_stroke.

Referenced by draw().

Glib::ustring Papyrus::Shape::svg_fill (  )  [protected]

Member Data Documentation

The fill and stroke patterns for this shape.

Referenced by draw(), Papyrus::Polyline::draw(), Papyrus::Bezierline::draw(), fill(), operator=(), set_fill(), set_fill_paint(), Shape(), and svg_fill().

sigc::connection Papyrus::Shape::m_fill_changed_connection [protected]

Referenced by set_fill(), and Shape().

Cairo::Path* Papyrus::Shape::m_fill_path [mutable, protected]

Referenced by draw(), operator=(), shape_changed(), and ~Shape().

sigc::connection Papyrus::Shape::m_stroke_changed_connection [protected]

Referenced by set_stroke(), and Shape().

Cairo::Path* Papyrus::Shape::m_stroke_path [mutable, protected]

Referenced by draw(), operator=(), shape_changed(), and ~Shape().


The documentation for this class was generated from the following files:

Generated on Fri Apr 16 12:41:09 2010 for papyrus by doxygen 1.6.1