00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef KOGRAPHICBASECONTAINER_H
00021 #define KOGRAPHICBASECONTAINER_H
00022
00023 #include "KoShape.h"
00024 #include "KoViewConverter.h"
00025
00026 #include <QList>
00027
00028 #include <koffice_export.h>
00029
00030 class QPainter;
00031 class QPointF;
00032
00040 class FLAKE_EXPORT KoShapeContainerModel {
00041 public:
00043 KoShapeContainerModel() {} ;
00044
00046 virtual ~KoShapeContainerModel() {} ;
00047
00052 virtual void add(KoShape *child) = 0;
00053
00058 virtual void remove(KoShape *child) = 0;
00059
00066 virtual void setClipping(const KoShape *child, bool clipping) = 0;
00067
00074 virtual bool childClipped(const KoShape *child) const = 0;
00075
00080 virtual int count() const = 0;
00081
00086 virtual QList<KoShape*> iterator() const = 0;
00087
00095 virtual void containerChanged(KoShapeContainer *container) = 0;
00096 };
00097
00132 class FLAKE_EXPORT KoShapeContainer : public KoShape {
00133
00134 public:
00135
00139 KoShapeContainer();
00140
00145 KoShapeContainer(KoShapeContainerModel *model);
00146
00148 virtual ~KoShapeContainer();
00149
00154 void addChild(KoShape *object);
00155
00160 void removeChild(KoShape *object);
00161
00166 int childCount() const;
00167
00173 void setClipping(const KoShape *child, bool clipping);
00174
00180 bool childClipped(const KoShape *child) const;
00181
00182 void paint(QPainter &painter, const KoViewConverter &converter);
00183
00193 virtual void paintComponent(QPainter &painter, const KoViewConverter &converter) = 0;
00194
00195 void repaint() const;
00196
00201 QList<KoShape*> iterator() const;
00202
00203 protected:
00210 virtual void childCountChanged() { }
00211
00212 private:
00215 class ChildrenData : public KoShapeContainerModel {
00216 public:
00217 ChildrenData();
00218 ~ChildrenData();
00219 void add(KoShape *child);
00220 void setClipping(const KoShape *child, bool clipping);
00221 bool childClipped(const KoShape *child) const;
00222 void remove(KoShape *child);
00223 int count() const;
00224 QList<KoShape*> iterator() const;
00225 void containerChanged(KoShapeContainer *container);
00226
00227 private:
00231 class Relation {
00232 public:
00233 Relation(KoShape *child);
00234 KoShape* child() { return m_child; }
00235 bool m_inside;
00236 private:
00237 KoShape *m_child;
00238 };
00239
00240 Relation* findRelation(const KoShape *child) const;
00241
00242 private:
00243 QList <Relation *> m_relations;
00244 };
00245 void shapeChanged(ChangeType type);
00246
00247 private:
00248 KoShapeContainerModel *m_children;
00249 };
00250
00251 #endif