Commit 9bf975cb authored by Thomas Zander's avatar Thomas Zander

Add feature to KoShape::absolutePosition

svn path=/trunk/koffice/; revision=646453
parent 1f04ffa7
......@@ -54,6 +54,15 @@ public:
ShapeOnTop ///< return the shape highest z-ordering, regardless of selection.
};
/// position. See KoShape::absolutePosition()
enum Position {
TopLeftCorner,
TopRightCorner,
BottomLeftCorner,
BottomRightCorner,
CenteredPositon
};
private:
KoFlake();
......
......@@ -416,8 +416,24 @@ const QPainterPath KoShape::outline() const {
return path;
}
QPointF KoShape::absolutePosition() const {
return d->matrix.map(QPointF(size().width() / 2.0 , size().height() / 2.0));
QPointF KoShape::absolutePosition(KoFlake::Position anchor) const {
QPointF point;
switch(anchor) {
case KoFlake::TopLeftCorner: break;
case KoFlake::TopRightCorner:
point = QPointF(size().width(), 0.0);
break;
case KoFlake::BottomLeftCorner:
point = QPointF(0.0, size().height());
break;
case KoFlake::BottomRightCorner:
point = QPointF(size().width(), size().height());
break;
case KoFlake::CenteredPositon:
point = QPointF(size().width() / 2.0, size().height() / 2.0);
break;
}
return d->matrix.map(point);
}
void KoShape::setAbsolutePosition(QPointF newPosition) {
......
......@@ -23,6 +23,7 @@
#define KOSHAPE_H
#include "KoInsets.h"
#include "KoFlake.h"
#include <QMatrix>
#include <QVector>
......@@ -448,10 +449,10 @@ public:
/**
* Return the position of this shape regardless of rotation/skew/scaling and regardless of
* this shape having a parent (being in a group) or not.<br>
* The returned value is the center of the shape.
* @param anchor The place on the (unaltered) shape that you want the position of.
* @return the point that is the absolute, centered position of this shape.
*/
QPointF absolutePosition() const;
QPointF absolutePosition(KoFlake::Position anchor = KoFlake::CenteredPositon) const;
/**
* Move this shape to an absolute position where the end location will be the same
......@@ -558,7 +559,7 @@ protected:
* @see saveOdf()
*/
virtual const char * odfTagName() const { return ""; }
/**
* @brief Save the data that is special by each shape
*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment