An instance of Reference holds a reference to another drawable without becoming the parent of the other drawable. More...
#include <reference.h>
Public Member Functions | |
PAPYRUS_DRAWABLE (Reference) | |
~Reference () | |
Destructor. | |
virtual void | draw (Context &cairo) const |
Override of Drawable's virtual draw method that draws the referenced drawable. | |
Drawable::pointer | referenced () |
Returns the current referenced object, or a null smart pointer if no object is currently reference. | |
void | set_referenced (Drawable::pointer d) |
Sets the current referenced object. | |
void | clear_referenced () |
Removes the referenced object. | |
virtual Matrix | global_matrix () const |
Override of Drawable's global matrix to include the matrix of the referenced drawable. | |
virtual Glib::ustring | svg (unsigned depth=0) |
Static Public Member Functions | |
static pointer | create (Drawable::pointer ref=Drawable::pointer()) |
Accepts an object to reference, or sets to a null pointer if no object. | |
static pointer | create (const Glib::ustring &id, Drawable::pointer ref=Drawable::pointer()) |
Accepts an object to reference, or sets to a null pointer if no object and names the reference with an id string. | |
Protected Member Functions | |
Reference (const Glib::ustring &id, Drawable::pointer ref) | |
virtual Matrix | calculate_composed_matrix () const |
Extends Drawable's version to include the referenced object's matrix. | |
virtual Region | calculate_extents (const Matrix &m=Matrix::Identity, ExtentsPerformance ep=EXTENTS_QUICK) const |
Protected Attributes | |
Drawable::pointer | m_referenced |
The referenced object. | |
sigc::connection | m_connection_referenced_composed_matrix_invalidated |
Used to track connection to referenced drawable's matrix invalidation signal. |
An instance of Reference holds a reference to another drawable without becoming the parent of the other drawable.
The reference's transformation matrix is applied before calling the referenced object to perform drawing. Therefore, the same drawing object may appear differently if two or more Reference instances apply different transformation matrices before performing actual drawing.
This class was motivated by the SVG 'use' element.
As a container, a Reference only holds a single object. If you need more than one object, add them to groups and then add the group to the reference.
If you don't want the group to take ownership, add the items individually to instances of Reference, then add the instances to a Group.
Papyrus::Reference::Reference | ( | const Glib::ustring & | id, | |
Drawable::pointer | ref | |||
) | [protected] |
Papyrus::Reference::~Reference | ( | ) |
Destructor.
Matrix Papyrus::Reference::calculate_composed_matrix | ( | ) | const [protected, virtual] |
Extends Drawable's version to include the referenced object's matrix.
Reimplemented from Papyrus::Drawable.
References Papyrus::Drawable::apply_external_matrices(), Papyrus::Drawable::centroid_x(), Papyrus::Drawable::centroid_y(), Papyrus::Drawable::get_rotation(), Papyrus::Drawable::get_scale_x(), Papyrus::Drawable::get_scale_y(), Papyrus::Drawable::get_skew_x(), Papyrus::Drawable::get_skew_y(), m_referenced, Papyrus::Matrix::rotate(), Papyrus::Matrix::scale(), Papyrus::Matrix::set_identity(), Papyrus::Matrix::skew(), Papyrus::Matrix::translate(), Papyrus::Drawable::x(), and Papyrus::Drawable::y().
Region Papyrus::Reference::calculate_extents | ( | const Matrix & | m = Matrix::Identity , |
|
ExtentsPerformance | ep = EXTENTS_QUICK | |||
) | const [protected, virtual] |
Reimplemented from Papyrus::Drawable.
References m_referenced.
void Papyrus::Reference::clear_referenced | ( | ) |
Removes the referenced object.
References set_referenced().
Reference::pointer Papyrus::Reference::create | ( | const Glib::ustring & | id, | |
Drawable::pointer | ref = Drawable::pointer() | |||
) | [static] |
Accepts an object to reference, or sets to a null pointer if no object and names the reference with an id string.
References PAPYRUS_CREATE.
Reference::pointer Papyrus::Reference::create | ( | Drawable::pointer | ref = Drawable::pointer() |
) | [static] |
Accepts an object to reference, or sets to a null pointer if no object.
References PAPYRUS_CREATE.
void Papyrus::Reference::draw | ( | Context & | cairo | ) | const [virtual] |
Override of Drawable's virtual draw method that draws the referenced drawable.
Implements Papyrus::Drawable.
References m_referenced.
Matrix Papyrus::Reference::global_matrix | ( | ) | const [virtual] |
Override of Drawable's global matrix to include the matrix of the referenced drawable.
Reimplemented from Papyrus::Drawable.
References Papyrus::Drawable::composed_matrix(), Papyrus::Drawable::global_matrix(), Papyrus::Drawable::m_parent, and m_referenced.
Papyrus::Reference::PAPYRUS_DRAWABLE | ( | Reference | ) |
Drawable::pointer Papyrus::Reference::referenced | ( | ) |
Returns the current referenced object, or a null smart pointer if no object is currently reference.
References m_referenced.
void Papyrus::Reference::set_referenced | ( | Drawable::pointer | d | ) |
Sets the current referenced object.
Set to a null smart pointer to remove the referenced object.
References Papyrus::Drawable::invalidate_composed_matrix(), m_connection_referenced_composed_matrix_invalidated, m_referenced, and Papyrus::Drawable::redraw().
Referenced by clear_referenced().
Glib::ustring Papyrus::Reference::svg | ( | unsigned | depth = 0 |
) | [virtual] |
Reimplemented from Papyrus::Renderable.
References m_referenced, Papyrus::Renderable::svg_id(), Papyrus::Renderable::svg_spacing(), and Papyrus::Drawable::svg_transform().
sigc::connection Papyrus::Reference::m_connection_referenced_composed_matrix_invalidated [protected] |
Used to track connection to referenced drawable's matrix invalidation signal.
Referenced by Reference(), and set_referenced().
Drawable::pointer Papyrus::Reference::m_referenced [protected] |
The referenced object.
Referenced by calculate_composed_matrix(), calculate_extents(), draw(), global_matrix(), Reference(), referenced(), set_referenced(), and svg().