Krita Source Code Documentation
Loading...
Searching...
No Matches
KoShapeAnchor Class Reference

#include <KoShapeAnchor.h>

+ Inheritance diagram for KoShapeAnchor:

Classes

class  PlacementStrategy
 
class  TextLocation
 

Public Types

enum  AnchorType { AnchorAsCharacter , AnchorToCharacter , AnchorParagraph , AnchorPage }
 
enum  HorizontalPos {
  HCenter , HFromInside , HFromLeft , HInside ,
  HLeft , HOutside , HRight
}
 
enum  HorizontalRel {
  HChar , HPage , HPageContent , HPageStartMargin ,
  HPageEndMargin , HFrame , HFrameContent , HFrameEndMargin ,
  HFrameStartMargin , HParagraph , HParagraphContent , HParagraphEndMargin ,
  HParagraphStartMargin
}
 
enum  VerticalPos {
  VBelow , VBottom , VFromTop , VMiddle ,
  VTop
}
 
enum  VerticalRel {
  VBaseline , VChar , VFrame , VFrameContent ,
  VLine , VPage , VPageContent , VParagraph ,
  VParagraphContent , VText
}
 

Public Member Functions

AnchorType anchorType () const
 
bool flowWithText () const
 return if flow-with-text (odf attribute)
 
HorizontalPos horizontalPos () const
 return the current vertical-pos
 
HorizontalRel horizontalRel () const
 return the current vertical-rel
 
 KoShapeAnchor (KoShape *shape)
 
const QPointF & offset () const
 return the offset of the shape from the anchor.
 
int pageNumber () const
 return the page number of the shape (valid with page anchoring, -1 indicates auto).
 
PlacementStrategyplacementStrategy () const
 Get placement strategy which is used to position shape linked to text anchor.
 
QDebug printDebug (QDebug dbg) const
 
 Private (KoShape *s)
 
void setAnchorType (AnchorType type)
 
void setHorizontalPos (HorizontalPos)
 set the current vertical-pos
 
void setHorizontalRel (HorizontalRel)
 set the current vertical-rel
 
void setOffset (const QPointF &offset)
 set the new offset of the shape. Causes a new layout soon.
 
void setPlacementStrategy (PlacementStrategy *placementStrategy)
 
void setTextLocation (TextLocation *textLocation)
 
void setVerticalPos (VerticalPos)
 set the current horizontal-pos
 
void setVerticalRel (VerticalRel)
 set the current horizontal-rel
 
KoShapeshape () const
 
TextLocationtextLocation () const
 Get extra data structure that is what is actually inside a text document.
 
VerticalPos verticalPos () const
 return the current horizontal-pos
 
VerticalRel verticalRel () const
 return the current horizontal-rel
 
QString wrapInfluenceOnPosition () const
 return the wrap influence on position
 
virtual ~KoShapeAnchor ()
 

Public Attributes

KoShapeAnchor::AnchorType anchorType
 
bool flowWithText
 
KoShapeAnchor::HorizontalPos horizontalPos
 
KoShapeAnchor::HorizontalRel horizontalRel
 
QPointF offset
 
int pageNumber
 
KoShapeAnchor::PlacementStrategyplacementStrategy
 
KoShape *const shape
 
KoShapeAnchor::TextLocationtextLocation
 
KoShapeAnchor::VerticalPos verticalPos
 
KoShapeAnchor::VerticalRel verticalRel
 
QString wrapInfluenceOnPosition
 

Private Attributes

Private *const d
 
- Private Attributes inherited from Private
KisCanvas2canvas
 
int displayedFrame
 
int intendedFrame
 

Additional Inherited Members

- Private Member Functions inherited from Private
 Private (KisCanvas2 *c)
 

Detailed Description

This class is the object that explains how a shape is anchored to something.

The anchored shape will be positioned (in supporting applications) based on the properties defined in this class.

This class can be used in three different ways: -page anchor -as-char -char, paragraph anchor

If it's a page anchor it just provide the info about how the shape relates to a page with a specific page number.

For the other types of anchoring it has to have a TextLocation in a QTextDocument. This TextLocation can either be an inline character (type as-char) or a position (type char or paragraph) The KoShapeAnchor and TextLocation connects the anchored-shape to the text flow so the anchored shape can be repositioned on the canvas if new text is inserted or removed before the anchor character.

For as-char, char and paragraph use cases:

See also
KoAnchorInlineObject
KoAnchorTextRange which are both implemented as subclasses of TextLocation

The position of the shape relative to the anchor is called the offset.

See also
PlacementStrategy for more information about the layout of anchors/shapes.

Definition at line 21 of file KoShapeAnchor.cpp.

Member Enumeration Documentation

◆ AnchorType

Enumerator
AnchorAsCharacter 
AnchorToCharacter 
AnchorParagraph 
AnchorPage 

Definition at line 132 of file KoShapeAnchor.h.

◆ HorizontalPos

Enumerator
HCenter 
HFromInside 
HFromLeft 
HInside 
HLeft 
HOutside 
HRight 

Definition at line 85 of file KoShapeAnchor.h.

◆ HorizontalRel

Enumerator
HChar 
HPage 
HPageContent 
HPageStartMargin 
HPageEndMargin 
HFrame 
HFrameContent 
HFrameEndMargin 
HFrameStartMargin 
HParagraph 
HParagraphContent 
HParagraphEndMargin 
HParagraphStartMargin 

Definition at line 95 of file KoShapeAnchor.h.

◆ VerticalPos

Enumerator
VBelow 
VBottom 
VFromTop 
VMiddle 
VTop 

Definition at line 111 of file KoShapeAnchor.h.

◆ VerticalRel

Enumerator
VBaseline 
VChar 
VFrame 
VFrameContent 
VLine 
VPage 
VPageContent 
VParagraph 
VParagraphContent 
VText 

Definition at line 119 of file KoShapeAnchor.h.

119 { //NOTE: update KWAnchoringProperties if you change this
120 VBaseline,
121 VChar,
122 VFrame,
124 VLine,
125 VPage,
129 VText
130 };

Constructor & Destructor Documentation

◆ KoShapeAnchor()

KoShapeAnchor::KoShapeAnchor ( KoShape * shape)
explicit

Constructor for an in-place anchor.

Parameters
shapethe anchored shape that this anchor links to.

Definition at line 63 of file KoShapeAnchor.cpp.

64 : d(new Private(shape))
65{
66}
KoShape *const shape
Private *const d

◆ ~KoShapeAnchor()

KoShapeAnchor::~KoShapeAnchor ( )
virtual

Definition at line 68 of file KoShapeAnchor.cpp.

69{
70 if (d->placementStrategy != 0) {
71 delete d->placementStrategy;
72 }
73 delete d;
74}

References d.

Member Function Documentation

◆ anchorType()

AnchorType KoShapeAnchor::anchorType ( ) const

Returns the type of the anchor.

The text:anchor-type attribute specifies how a frame is bound to a text document. The anchor position is the point at which a frame is bound to a text document. The defined values for the text:anchor-type attribute are;

  • as-char There is no anchor position. The drawing shape behaves like a character.
  • char The character after the drawing shape element.
  • frame The parent text box that the current drawing shape element is contained in. FIXME we don't support type frame
  • page The page that has the same physical page number as the value of the text:anchor-page-number attribute that is attached to the drawing shape element.
  • paragraph The paragraph that the current drawing shape element is contained in.

◆ flowWithText()

bool KoShapeAnchor::flowWithText ( ) const

return if flow-with-text (odf attribute)

◆ horizontalPos()

HorizontalPos KoShapeAnchor::horizontalPos ( ) const

return the current vertical-pos

◆ horizontalRel()

HorizontalRel KoShapeAnchor::horizontalRel ( ) const

return the current vertical-rel

◆ offset()

const QPointF & KoShapeAnchor::offset ( ) const

return the offset of the shape from the anchor.

◆ pageNumber()

int KoShapeAnchor::pageNumber ( ) const

return the page number of the shape (valid with page anchoring, -1 indicates auto).

◆ placementStrategy()

PlacementStrategy * KoShapeAnchor::placementStrategy ( ) const

Get placement strategy which is used to position shape linked to text anchor.

◆ printDebug()

QDebug KoShapeAnchor::printDebug ( QDebug dbg) const
inline

Definition at line 39 of file KoShapeAnchor.cpp.

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 }
QString name() const
Definition KoShape.cpp:1150

◆ Private()

KoShapeAnchor::Private ( KoShape * s)
inline

Definition at line 24 of file KoShapeAnchor.cpp.

25 : shape(s)
30 , flowWithText(true)
33 , pageNumber(-1)
34 , textLocation(0)
35 {
36 }
KoShapeAnchor::AnchorType anchorType
KoShapeAnchor::PlacementStrategy * placementStrategy
KoShapeAnchor::HorizontalRel horizontalRel
KoShapeAnchor::VerticalRel verticalRel
KoShapeAnchor::TextLocation * textLocation
KoShapeAnchor::VerticalPos verticalPos
KoShapeAnchor::HorizontalPos horizontalPos

◆ setAnchorType()

void KoShapeAnchor::setAnchorType ( KoShapeAnchor::AnchorType type)

Set how the anchor behaves

Definition at line 151 of file KoShapeAnchor.cpp.

152{
153 d->anchorType = type;
154 if (type == AnchorAsCharacter) {
155 d->horizontalRel = HChar;
156 d->horizontalPos = HLeft;
157 }
158}

References AnchorAsCharacter, d, HChar, and HLeft.

◆ setHorizontalPos()

void KoShapeAnchor::setHorizontalPos ( HorizontalPos hp)

set the current vertical-pos

Definition at line 86 of file KoShapeAnchor.cpp.

87{
88 d->horizontalPos = hp;
89}

References d.

◆ setHorizontalRel()

void KoShapeAnchor::setHorizontalRel ( HorizontalRel hr)

set the current vertical-rel

Definition at line 96 of file KoShapeAnchor.cpp.

97{
98 d->horizontalRel = hr;
99}

References d.

◆ setOffset()

void KoShapeAnchor::setOffset ( const QPointF & offset)

set the new offset of the shape. Causes a new layout soon.

Definition at line 146 of file KoShapeAnchor.cpp.

147{
148 d->offset = offset;
149}

References d, and offset.

◆ setPlacementStrategy()

void KoShapeAnchor::setPlacementStrategy ( PlacementStrategy * placementStrategy)

Set placement strategy which is used to position shape linked to text anchor We take owner ship and will make sure the strategy is deleted

Definition at line 175 of file KoShapeAnchor.cpp.

176{
177 if (placementStrategy != d->placementStrategy) {
178 delete d->placementStrategy;
179
180 d->placementStrategy = placementStrategy;
181 }
182}

References d, and placementStrategy.

◆ setTextLocation()

void KoShapeAnchor::setTextLocation ( TextLocation * textLocation)

Set extra data structure that is what is actually inside a text document We do NOT take ownership (may change in the future)

Definition at line 165 of file KoShapeAnchor.cpp.

166{
167 d->textLocation = textLocation;
168}

References d, and textLocation.

◆ setVerticalPos()

void KoShapeAnchor::setVerticalPos ( VerticalPos vp)

set the current horizontal-pos

Definition at line 106 of file KoShapeAnchor.cpp.

107{
108 d->verticalPos = vp;
109}

References d.

◆ setVerticalRel()

void KoShapeAnchor::setVerticalRel ( VerticalRel vr)

set the current horizontal-rel

Definition at line 116 of file KoShapeAnchor.cpp.

117{
118 d->verticalRel = vr;
119}

References d.

◆ shape()

KoShape * KoShapeAnchor::shape ( ) const

Return the shape that is linked to from the text anchor.

◆ textLocation()

TextLocation * KoShapeAnchor::textLocation ( ) const

Get extra data structure that is what is actually inside a text document.

◆ verticalPos()

VerticalPos KoShapeAnchor::verticalPos ( ) const

return the current horizontal-pos

◆ verticalRel()

VerticalRel KoShapeAnchor::verticalRel ( ) const

return the current horizontal-rel

◆ wrapInfluenceOnPosition()

QString KoShapeAnchor::wrapInfluenceOnPosition ( ) const

return the wrap influence on position

Member Data Documentation

◆ anchorType

KoShapeAnchor::AnchorType KoShapeAnchor::anchorType

Definition at line 57 of file KoShapeAnchor.cpp.

◆ d

Private* const KoShapeAnchor::d
private

Definition at line 237 of file KoShapeAnchor.h.

◆ flowWithText

bool KoShapeAnchor::flowWithText

Definition at line 56 of file KoShapeAnchor.cpp.

◆ horizontalPos

KoShapeAnchor::HorizontalPos KoShapeAnchor::horizontalPos

Definition at line 53 of file KoShapeAnchor.cpp.

◆ horizontalRel

KoShapeAnchor::HorizontalRel KoShapeAnchor::horizontalRel

Definition at line 54 of file KoShapeAnchor.cpp.

◆ offset

const QPointF & KoShapeAnchor::offset

Definition at line 50 of file KoShapeAnchor.cpp.

◆ pageNumber

int KoShapeAnchor::pageNumber

Definition at line 59 of file KoShapeAnchor.cpp.

◆ placementStrategy

KoShapeAnchor::PlacementStrategy * KoShapeAnchor::placementStrategy

Definition at line 58 of file KoShapeAnchor.cpp.

◆ shape

KoShape * KoShapeAnchor::shape

Definition at line 49 of file KoShapeAnchor.cpp.

◆ textLocation

KoShapeAnchor::TextLocation * KoShapeAnchor::textLocation

Definition at line 60 of file KoShapeAnchor.cpp.

◆ verticalPos

KoShapeAnchor::VerticalPos KoShapeAnchor::verticalPos

Definition at line 51 of file KoShapeAnchor.cpp.

◆ verticalRel

KoShapeAnchor::VerticalRel KoShapeAnchor::verticalRel

Definition at line 52 of file KoShapeAnchor.cpp.

◆ wrapInfluenceOnPosition

QString KoShapeAnchor::wrapInfluenceOnPosition

Definition at line 55 of file KoShapeAnchor.cpp.


The documentation for this class was generated from the following files: