libs/flake

KoShapeContainer Class Reference

This is the base class that all Flake group-shapes are based on. More...

#include <KoShapeContainer.h>

Inheritance diagram for KoShapeContainer:

List of all members.

Public Member Functions

 KoShapeContainer (KoShapeContainerModel *model)
 KoShapeContainer ()
virtual ~KoShapeContainer ()
void addChild (KoShape *shape)
bool childClipped (const KoShape *child) const
int childCount () const
QList< KoShape * > childShapes () const
bool isChildLocked (const KoShape *child) const
KoShapeContainerModelmodel () const
virtual void paint (QPainter &painter, const KoViewConverter &converter)
virtual void paintComponent (QPainter &painter, const KoViewConverter &converter)=0
void removeChild (KoShape *shape)
void setClipping (const KoShape *child, bool clipping)
virtual void update () const

Protected Member Functions

 KoShapeContainer (KoShapeContainerPrivate &)
virtual void childCountChanged ()

Detailed Description

This is the base class that all Flake group-shapes are based on.

Extending from this class allows you to have child-shapes. Like the KoShape class, this shape is a visible class with a position and a size. It can paint itself as well if you implement the paintComponent() method.

The most important feature of this class is that you can make other KoShape classes to be children of this container.

The effect of grouping those shapes is that their position is relative to the position of the container. Move the container and all children move with it.

Each child can optionally be said to be 'clipped' by the container. This feature will give the effect that if the child has a size and position outside the container, parts outside the container will not be shown. This is especially useful for showing cutouts of content, like images, without changing the actual content.

For so called clipped children any modification made to the container is propagated to the child. This includes rotation as well as scaling and shearing.

Maintaining the list of children can be done using the supplied methods addChild() and removeChild(). However, they only forward their requests to the data model KoShapeContainerModel and if you provide a custom implementation of that model any means can be used to maintain a list of children, as long as you will take care to register them with the appropriate shape manager.

An example usage where a custom model might be useful is when you have a container for text areas which are split into columns. If you resize the container and the width of the individual columns gets too small, the model can choose to remove a child or add one when the width allows another column.

Definition at line 69 of file KoShapeContainer.h.


Constructor & Destructor Documentation

KoShapeContainer::KoShapeContainer (  ) 

Default constructor; this constructs a container a default model that does what you expect.

Definition at line 41 of file KoShapeContainer.cpp.

KoShapeContainer::KoShapeContainer ( KoShapeContainerModel model  )  [explicit]

Constructor with custom model to be used for maintaining the list of children.

For all the normal cases you don't need a custom model. Only when you want to respond to moves of the container to do something special, or disable one of the features the container normally has (like clipping). Use the default constructor in those cases.

Parameters:
model the custom model to be used for maintaining the list of children.

Definition at line 46 of file KoShapeContainer.cpp.

KoShapeContainer::~KoShapeContainer (  )  [virtual]

Destructor for the shape container.

All children will be orphaned by calling a KoShape::setParent(0)

Definition at line 53 of file KoShapeContainer.cpp.

KoShapeContainer::KoShapeContainer ( KoShapeContainerPrivate &   )  [protected]

constructor


Member Function Documentation

void KoShapeContainer::addChild ( KoShape shape  ) 

Add a child to this container.

Parameters:
shape the child to be managed in the container.

Definition at line 62 of file KoShapeContainer.cpp.

bool KoShapeContainer::childClipped ( const KoShape child  )  const

Returns if the argument child has its 'clipping' property set.

Returns:
if the argument child has its 'clipping' property set.
Parameters:
child the child for which the property will be returned.

Definition at line 179 of file KoShapeContainer.cpp.

int KoShapeContainer::childCount (  )  const

Return the current number of children registered.

Returns:
the current number of children registered.

Definition at line 93 of file KoShapeContainer.cpp.

virtual void KoShapeContainer::childCountChanged (  )  [inline, protected, virtual]

This hook is for inheriting classes that need to do something on adding/removing of children.

This method will be called just after the child has been added/removed. The default implementation is empty.

Definition at line 168 of file KoShapeContainer.h.

QList< KoShape * > KoShapeContainer::childShapes (  )  const

Create and return an iterator over all child shapes.

Returns:
an interator over all child shapes.

Definition at line 196 of file KoShapeContainer.cpp.

bool KoShapeContainer::isChildLocked ( const KoShape child  )  const

Return wheather the child has the effective state of being locked for user modifications.

This method is deferred to the model, which should call the KoShape::isGeometryProtected() on the child.

Parameters:
child the shape that the user wants to move.

Definition at line 101 of file KoShapeContainer.cpp.

KoShapeContainerModel * KoShapeContainer::model (  )  const

return the model for this container

Definition at line 205 of file KoShapeContainer.cpp.

void KoShapeContainer::paint ( QPainter painter,
const KoViewConverter converter 
) [virtual]

reimplemented

Implements KoShape.

Definition at line 117 of file KoShapeContainer.cpp.

virtual void KoShapeContainer::paintComponent ( QPainter painter,
const KoViewConverter converter 
) [pure virtual]

Paint the component Implement this method to allow the shape to paint itself, just like the KoShape::paint() method does.

Parameters:
painter used for painting the shape
converter to convert between internal and view coordinates.
See also:
applyConversion()

Implemented in KoShapeGroup, and KoShapeLayer.

void KoShapeContainer::removeChild ( KoShape shape  ) 

Remove a child to be completely separated from the container.

Parameters:
shape the child to be removed.

Definition at line 77 of file KoShapeContainer.cpp.

void KoShapeContainer::setClipping ( const KoShape child,
bool  clipping 
)

Set the argument child to have its 'clipping' property set.

Parameters:
child the child for which the property will be changed.
clipping the property

Definition at line 109 of file KoShapeContainer.cpp.

void KoShapeContainer::update (  )  const [virtual]

reimplemented

Reimplemented from KoShape.

Definition at line 187 of file KoShapeContainer.cpp.


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