Warning, file /office/calligra/libs/flake/KoShapeContainerModel.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* This file is part of the KDE project 0002 * Copyright (C) 2006-2007, 2010 Thomas Zander <zander@kde.org> 0003 * 0004 * This library is free software; you can redistribute it and/or 0005 * modify it under the terms of the GNU Library General Public 0006 * License as published by the Free Software Foundation; either 0007 * version 2 of the License, or (at your option) any later version. 0008 * 0009 * This library is distributed in the hope that it will be useful, 0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 * Library General Public License for more details. 0013 * 0014 * You should have received a copy of the GNU Library General Public License 0015 * along with this library; see the file COPYING.LIB. If not, write to 0016 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0017 * Boston, MA 02110-1301, USA. 0018 */ 0019 0020 #ifndef KOSHAPECONTAINERMODEL_H 0021 #define KOSHAPECONTAINERMODEL_H 0022 0023 #include "flake_export.h" 0024 0025 #include <KoShape.h> 0026 0027 #include <QList> 0028 #include <QPointF> 0029 0030 class KoShapeContainer; 0031 0032 /** 0033 * The interface for the container model. 0034 * This class has no implementation, but only pure virtual methods. You can find a 0035 * fully implemented model using KoShapeContainerDefaultModel. Extending this 0036 * class and implementing all methods allows you to implement a custom data-backend 0037 * for the KoShapeContainer. 0038 * @see KoShapeContainer, KoShapeContainerDefaultModel 0039 */ 0040 class FLAKE_EXPORT KoShapeContainerModel 0041 { 0042 public: 0043 /// default constructor 0044 KoShapeContainerModel(); 0045 0046 /// destructor 0047 virtual ~KoShapeContainerModel(); 0048 0049 /** 0050 * Add a shape to this models store. 0051 * @param shape the shape to be managed in the container. 0052 */ 0053 virtual void add(KoShape *shape) = 0; 0054 0055 /** 0056 * Remove a shape to be completely separated from the model. 0057 * @param shape the shape to be removed. 0058 */ 0059 virtual void remove(KoShape *shape) = 0; 0060 0061 /** 0062 * Set the argument shape to have its 'clipping' property set. 0063 * 0064 * A shape that is clipped by the container will have its visible portion 0065 * limited to the area where it intersects with the container. 0066 * If a shape is positioned or sized such that it would be painted outside 0067 * of the KoShape::outline() of its parent container, setting this property 0068 * to true will clip the shape painting to the container outline. 0069 * 0070 * @param shape the shape for which the property will be changed. 0071 * @param clipping the new value 0072 */ 0073 virtual void setClipped(const KoShape *shape, bool clipping) = 0; 0074 0075 /** 0076 * Returns if the argument shape has its 'clipping' property set. 0077 * 0078 * A shape that is clipped by the container will have its visible portion 0079 * limited to the area where it intersects with the container. 0080 * If a shape is positioned or sized such that it would be painted outside 0081 * of the KoShape::outline() of its parent container, setting this property 0082 * to true will clip the shape painting to the container outline. 0083 * 0084 * @return if the argument shape has its 'clipping' property set. 0085 * @param shape the shape for which the property will be returned. 0086 */ 0087 virtual bool isClipped(const KoShape *shape) const = 0; 0088 0089 /** 0090 * Set the shape to inherit the container transform. 0091 * 0092 * A shape that inherits the transform of the parent container will have its 0093 * share / rotation / skew etc be calculated as being the product of both its 0094 * own local transformation and also that of its parent container. 0095 * If you set this to true and rotate the container, the shape will get that 0096 * rotation as well automatically. 0097 * 0098 * @param shape the shape for which the property will be changed. 0099 * @param inherit the new value 0100 */ 0101 virtual void setInheritsTransform(const KoShape *shape, bool inherit) = 0; 0102 0103 /** 0104 * Returns if the shape inherits the container transform. 0105 * 0106 * A shape that inherits the transform of the parent container will have its 0107 * share / rotation / skew etc be calculated as being the product of both its 0108 * own local transformation and also that of its parent container. 0109 * If you set this to true and rotate the container, the shape will get that 0110 * rotation as well automatically. 0111 * 0112 * @return if the argument shape has its 'inherits transform' property set. 0113 * @param shape the shape for which the property will be returned. 0114 */ 0115 virtual bool inheritsTransform(const KoShape *shape) const = 0; 0116 0117 /** 0118 * Return wheather the child has the effective state of being locked for user modifications. 0119 * The model has to call KoShape::isGeometryProtected() and base its return value upon that, it can 0120 * additionally find rules on wheather the child is locked based on the container state. 0121 * @param child the shape that the user wants to move. 0122 */ 0123 virtual bool isChildLocked(const KoShape *child) const = 0; 0124 /** 0125 * Return the AllowedInteractions for @p child. 0126 */ 0127 virtual KoShape::AllowedInteractions allowedInteractions(const KoShape *child) const; 0128 /** 0129 * Return the current number of children registered. 0130 * @return the current number of children registered. 0131 */ 0132 virtual int count() const = 0; 0133 0134 /** 0135 * Return the list of all shapes of this model 0136 * @return the list of all shapes 0137 */ 0138 virtual QList<KoShape*> shapes() const = 0; 0139 0140 /** 0141 * This method is called as a notification that one of the properties of the 0142 * container changed. This can be one of size, position, rotation and skew. 0143 * Note that clipped children will automatically get all these changes, the model 0144 * does not have to do anything for that. 0145 * @param container the actual container that changed. 0146 * @param type this enum shows which change the container has had. 0147 */ 0148 virtual void containerChanged(KoShapeContainer *container, KoShape::ChangeType type) = 0; 0149 0150 /** 0151 * This method is called when the user tries to move a shape that is a shape of the 0152 * container this model represents. 0153 * The shape itself is not yet moved; it is proposed to be moved over the param move distance. 0154 * You can alter the value of the move to affect the actual distance moved. 0155 * The default implementation does nothing. 0156 * @param shape the shape of this container that the user is trying to move. 0157 * @param move the distance that the user proposes to move shape from the current position. 0158 */ 0159 virtual void proposeMove(KoShape *shape, QPointF &move); 0160 0161 /** 0162 * This method is called when one of the shape shapes has been modified. 0163 * When a shape shape is rotated, moved or scaled/skewed this method will be called 0164 * to inform the container of such a change. The change has already happened at the 0165 * time this method is called. 0166 * The base implementation notifies the grand parent of the shape that there was a 0167 * change in a shape. A reimplentation if this function should call this method when 0168 * overwriding the function. 0169 * 0170 * @param shape the shape that has been changed 0171 * @param type this enum shows which change the shape has had. 0172 */ 0173 virtual void childChanged(KoShape *shape, KoShape::ChangeType type); 0174 }; 0175 0176 #endif