F:/KPlato/koffice/libs/flake/KoShape.h

Aller à la documentation de ce fichier.
00001 /* This file is part of the KDE project
00002    Copyright (C) 2006 Thorsten Zachmann <zachmann@kde.org>
00003    Copyright (C) 2006 Casper Boemann Rasmussen <cbr@boemann.dk>
00004    Copyright (C) 2006 Thomas Zander <zander@kde.org>
00005 
00006    This library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Library General Public
00008    License as published by the Free Software Foundation; either
00009    version 2 of the License, or (at your option) any later version.
00010 
00011    This library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Library General Public License for more details.
00015 
00016    You should have received a copy of the GNU Library General Public License
00017    along with this library; see the file COPYING.LIB.  If not, write to
00018    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019  * Boston, MA 02110-1301, USA.
00020 */
00021 
00022 #ifndef KOSHAPE_H
00023 #define KOSHAPE_H
00024 
00025 #include <QMatrix>
00026 #include <QVector>
00027 #include <QSet>
00028 #include <QBrush>
00029 
00030 #include <koffice_export.h>
00031 
00032 class QPainter;
00033 class QRectF;
00034 class QPainterPath;
00035 class QVariant;
00036 
00037 class KoSelection;
00038 class KoPointerEvent;
00039 class KoShapeContainer;
00040 class KoShapeBorderModel;
00041 class KoShapeManager;
00042 class KoShapeUserData;
00043 class KoViewConverter;
00044 
00071 class FLAKE_EXPORT KoShape
00072 {
00073 public:
00077     KoShape();
00078 
00082     virtual ~KoShape();
00083 
00097     virtual void paint(QPainter &painter, const KoViewConverter &converter) = 0;
00098 
00107     virtual void paintDecorations(QPainter &painter, const KoViewConverter &converter, bool selected);
00108 
00116     void scale( double sx, double sy );
00117 
00121     double scaleX() const { return m_scaleX; }
00122 
00126     double scaleY() const { return m_scaleY; }
00127 
00135     void rotate( double angle );
00136 
00140     double rotation() const { return m_angle; }
00141 
00150     void shear( double sx, double sy );
00151 
00156     double shearX() const { return m_shearX; }
00157 
00162     double shearY() const { return m_shearY; }
00163 
00173     virtual void resize( const QSizeF &size );
00174 
00180     virtual QSizeF size() const { return m_size; }
00181 
00187     virtual void setPosition( const QPointF &position );
00188 
00194     virtual QPointF position() const { return m_pos; }
00195 
00201     virtual bool hitTest( const QPointF &position ) const;
00202 
00210     virtual QRectF boundingRect() const;
00211 
00222     void addConnectionPoint( const QPointF &point ) { m_connectors.append( point ); }
00223 
00230     QList<QPointF> connectors() const { return m_connectors.toList(); }
00231 
00239     void setBackground ( const QBrush & brush ) { m_backgroundBrush = brush; }
00240 
00248     const QBrush& background () { return m_backgroundBrush; }
00249 
00256     virtual bool hasTransparency();
00257 
00265     int zIndex() const;
00266 
00278     void setZIndex(int zIndex) { m_zIndex = zIndex; }
00279 
00286     void setVisible(bool on) { m_visible = on; }
00293     bool isVisible() const { return m_visible; }
00294 
00300     void setSelectable(bool selectable) { m_selectable = selectable; }
00305     bool isSelectable() const { return m_selectable; }
00306 
00312     void setLocked(bool locked) { m_locked = locked; }
00318     bool isLocked() const { return m_locked; }
00319 
00324     KoShapeContainer *parent() const { return m_parent; }
00325 
00330     void setParent(KoShapeContainer *parent);
00331 
00339     virtual void repaint() const;
00340 
00350     void repaint(const QRectF &shape) const;
00351 
00363     void repaint(double x, double y, double width, double height) const;
00364 
00370     static bool compareShapeZIndex(KoShape *g1, KoShape *g2);
00371 
00375     void recalcMatrix();
00376 
00384     virtual const QPainterPath outline() const;
00385 
00390     KoShapeBorderModel *border() { return m_border; }
00391 
00396     void setBorder(KoShapeBorderModel *border) { m_border = border; }
00397 
00404     void setKeepAspectRatio(bool keepAspect) { m_keepAspect = keepAspect; }
00405 
00412     bool keepAspectRatio() const { return m_keepAspect; }
00413 
00420     QPointF absolutePosition() const;
00421 
00435     void setAbsolutePosition(QPointF newPosition);
00436 
00445     void moveBy(double distanceX, double distanceY);
00446 
00453     void setUserData(KoShapeUserData *userData);
00457     KoShapeUserData *userData() const;
00458 
00464     const QString & shapeId() const { return m_shapeId; }
00471     void setShapeId(const QString &id) { m_shapeId = id; }
00472 
00478     QMatrix transformationMatrix(const KoViewConverter *converter) const;
00479 
00486     virtual void copySettings(const KoShape *shape);
00487 
00495     static void applyConversion(QPainter &painter, const KoViewConverter &converter);
00496 
00497 protected:
00498     QMatrix m_invMatrix; 
00499     QBrush m_backgroundBrush; 
00500     KoShapeBorderModel *m_border; 
00501 
00505     virtual void updateTree();
00506 
00508     enum ChangeType {
00509         PositionChanged, 
00510         RotationChanged, 
00511         ScaleChanged,   
00512         ShearChanged,   
00513         SizeChanged,    
00514         ParentChanged   
00515     };
00516 
00522     virtual void shapeChanged(ChangeType type) { Q_UNUSED(type); }
00523 
00524 private:
00525     double m_scaleX;
00526     double m_scaleY;
00527     double m_angle; // degrees
00528     double m_shearX;
00529     double m_shearY;
00530 
00531     QSizeF m_size; // size in pt
00532     QPointF m_pos; // position (top left) in pt
00533     QString m_shapeId;
00534 
00535     QMatrix m_matrix;
00536 
00537     QVector<QPointF> m_connectors; // in pt
00538 
00539     int m_zIndex;
00540     KoShapeContainer *m_parent;
00541 
00542     bool m_visible, m_locked, m_keepAspect, m_selectable;
00543 
00544 
00545     QSet<KoShapeManager *> m_shapeManagers;
00546 
00547 private:
00548     friend class KoShapeManager;
00549     void addShapeManager( KoShapeManager * manager ) { m_shapeManagers.insert( manager ); }
00550     void removeShapeManager( KoShapeManager * manager ) { m_shapeManagers.remove( manager ); }
00551     KoShapeUserData *m_userData;
00552 };
00553 
00554 #endif

Généré le Wed Nov 22 23:40:59 2006 pour KPlato par  doxygen 1.5.1-p1