Krita Source Code Documentation
Loading...
Searching...
No Matches
KoShapeAnchor.cpp
Go to the documentation of this file.
1/* This file is part of the KDE project
2 * SPDX-FileCopyrightText: 2007, 2009-2010 Thomas Zander <zander@kde.org>
3 * SPDX-FileCopyrightText: 2010 KO GmbH <cbo@kogmbh.com>
4 * SPDX-FileCopyrightText: 2011 Matus Hanzes <matus.hanzes@ixonos.com>
5 * SPDX-FileCopyrightText: 2013 C. Boemann <cbo@boemann.dk>
6 *
7 * SPDX-License-Identifier: LGPL-2.0-or-later
8 */
9
10#include "KoShapeAnchor.h"
11
12#include <KoShapeContainer.h>
13#include <KoXmlWriter.h>
14#include <KoXmlNS.h>
17
18#include <QPointF>
19#include <FlakeDebug.h>
20
21class Q_DECL_HIDDEN KoShapeAnchor::Private
22{
23public:
25 : shape(s)
26 , verticalPos(KoShapeAnchor::VTop)
27 , verticalRel(KoShapeAnchor::VLine)
28 , horizontalPos(KoShapeAnchor::HLeft)
29 , horizontalRel(KoShapeAnchor::HChar)
30 , flowWithText(true)
31 , anchorType(KoShapeAnchor::AnchorToCharacter)
32 , placementStrategy(0)
33 , pageNumber(-1)
34 , textLocation(0)
35 {
36 }
37
38
39 QDebug printDebug(QDebug dbg) const
40 {
41#ifndef NDEBUG
42 dbg.space() << "KoShapeAnchor" << this;
43 dbg.space() << "offset:" << offset;
44 dbg.space() << "shape:" << shape->name();
45#endif
46 return dbg.space();
47 }
48
49 KoShape * const shape;
50 QPointF offset;
61};
62
64 : d(new Private(shape))
65{
66}
67
69{
70 if (d->placementStrategy != 0) {
71 delete d->placementStrategy;
72 }
73 delete d;
74}
75
77{
78 return d->shape;
79}
80
82{
83 return d->anchorType;
84}
85
87{
88 d->horizontalPos = hp;
89}
90
92{
93 return d->horizontalPos;
94}
95
97{
98 d->horizontalRel = hr;
99}
100
102{
103 return d->horizontalRel;
104}
105
107{
108 d->verticalPos = vp;
109}
110
112{
113 return d->verticalPos;
114}
115
117{
118 d->verticalRel = vr;
119}
120
122{
123 return d->verticalRel;
124}
125
127{
128 return d->wrapInfluenceOnPosition;
129}
130
132{
133 return d->flowWithText;
134}
135
137{
138 return d->pageNumber;
139}
140
141const QPointF &KoShapeAnchor::offset() const
142{
143 return d->offset;
144}
145
146void KoShapeAnchor::setOffset(const QPointF &offset)
147{
148 d->offset = offset;
149}
150
152{
153 d->anchorType = type;
154 if (type == AnchorAsCharacter) {
155 d->horizontalRel = HChar;
156 d->horizontalPos = HLeft;
157 }
158}
159
161{
162 return d->textLocation;
163}
164
166{
167 d->textLocation = textLocation;
168}
169
171{
172 return d->placementStrategy;
173}
174
176{
177 if (placementStrategy != d->placementStrategy) {
178 delete d->placementStrategy;
179
180 d->placementStrategy = placementStrategy;
181 }
182}
void setHorizontalPos(HorizontalPos)
set the current vertical-pos
void setVerticalRel(VerticalRel)
set the current horizontal-rel
KoShapeAnchor::AnchorType anchorType
Private(KoShape *s)
void setOffset(const QPointF &offset)
set the new offset of the shape. Causes a new layout soon.
virtual ~KoShapeAnchor()
KoShapeAnchor::PlacementStrategy * placementStrategy
KoShape *const shape
KoShapeAnchor::HorizontalRel horizontalRel
KoShapeAnchor::VerticalRel verticalRel
QDebug printDebug(QDebug dbg) const
QString wrapInfluenceOnPosition
KoShapeAnchor::TextLocation * textLocation
void setVerticalPos(VerticalPos)
set the current horizontal-pos
KoShapeAnchor::VerticalPos verticalPos
void setHorizontalRel(HorizontalRel)
set the current vertical-rel
void setTextLocation(TextLocation *textLocation)
KoShapeAnchor(KoShape *shape)
void setPlacementStrategy(PlacementStrategy *placementStrategy)
KoShapeAnchor::HorizontalPos horizontalPos
Private *const d
void setAnchorType(AnchorType type)