ACF $AcfVersion:0$
CLabelShape.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-2.1-or-later OR GPL-2.0-or-later OR GPL-3.0-or-later OR LicenseRef-ACF-Commercial
2#pragma once
3
4
5// ACF includes
6#include <i2d/CLabel.h>
8#include <iview/CPinShape.h>
9
10namespace iview
11{
12
13
14class CLabelShape: public CPinShape, virtual public ITextLabelParams
15{
16public:
19
22 const istd::CIndex2d& offset = istd::CIndex2d(20, -20));
23
24 virtual bool IsPositionVisible() const;
25 virtual void SetPositionVisible(bool visible = true);
26 virtual bool IsBackgroundTransparent() const;
27 virtual void SetBackgroundTransparent(bool state = true);
28 virtual bool IsEditableOffset() const;
29 virtual void SetEditableOffset(bool editable = true);
30
31 // reimplemented (ITextLabelParams)
32 virtual TextAlign GetTextAlign() const override;
33 virtual void SetTextAlign(TextAlign align) override;
34 virtual const istd::CIndex2d& GetDrawOffset() const override;
35 virtual void SetDrawOffset(const istd::CIndex2d& offset) override;
36
37 // reimplemented (iview::IMouseActionObserver)
38 virtual bool OnMouseButton(istd::CIndex2d position, Qt::MouseButton buttonType, bool downFlag) override;
39 virtual bool OnMouseMove(istd::CIndex2d position) override;
40
41 // reimplemented (iview::IVisualizable)
42 virtual void Draw(QPainter& drawContext) const override;
43
44 // reimplemented (imod::IObserver)
45 virtual bool OnModelAttached(imod::IModel* modelPtr, istd::IChangeable::ChangeSet& changeMask) override;
46
47 // reimplemented (iview::ITouchable)
48 virtual TouchState IsTouched(istd::CIndex2d position) const override;
49
50protected:
57
58 void CalculateTextOriginSize(i2d::CRect& textBox) const;
59
60 // reimplemented (iview::CInteractiveShapeBase)
61 virtual i2d::CRect CalcBoundingBox() const override;
62
63private:
64 istd::CIndex2d m_referenceOffset;
65 TextAlign m_textAlign;
66 mutable istd::CIndex2d m_drawOffset;
67 bool m_isPositionVisible;
68 bool m_isBackgroundTransparent;
69 bool m_isEditableOffset;
70 EditMode m_editMode;
71
72 bool m_isAlignFixed;
73};
74
75
77{
78 return m_isPositionVisible;
79}
80
81
82inline void CLabelShape::SetPositionVisible(bool visible)
83{
84 m_isPositionVisible = visible;
85}
86
87
89{
90 return m_isBackgroundTransparent;
91}
92
93
95{
96 m_isBackgroundTransparent = state;
97}
98
99
101{
102 return m_isEditableOffset;
103}
104
105
106inline void CLabelShape::SetEditableOffset(bool editable)
107{
108 m_isEditableOffset = editable;
109}
110
111
112// reimplemented (ITextLabelParams)
113
115{
116 return m_textAlign;
117}
118
119
121{
122 m_textAlign = align;
123}
124
125
127{
128 return m_drawOffset;
129}
130
131
133{
134 m_drawOffset = offset;
135}
136
137
138} // namespace iview
139
140
141
142
Simple rectangle with integer bounds.
Definition CRect.h:22
Common interface for model objects, that supports Model/Observer design pattern.
Definition IModel.h:25
Index implementation for addressing elements in 2D-space.
Definition CIndex2d.h:21
Set of change flags (its IDs).
Definition IChangeable.h:36
virtual void SetBackgroundTransparent(bool state=true)
Definition CLabelShape.h:94
virtual void SetPositionVisible(bool visible=true)
Definition CLabelShape.h:82
virtual bool OnModelAttached(imod::IModel *modelPtr, istd::IChangeable::ChangeSet &changeMask) override
Callback invoked when an observable model is about to be attached to this observer.
virtual bool IsPositionVisible() const
Definition CLabelShape.h:76
CPinShape BaseClass
Definition CLabelShape.h:17
void CalculateTextOriginSize(i2d::CRect &textBox) const
virtual void Draw(QPainter &drawContext) const override
Draw this shape using draw context.
virtual TextAlign GetTextAlign() const override
Get text alignment modein label shape.
virtual void SetTextAlign(TextAlign align) override
Set text alignment mode.
virtual bool IsEditableOffset() const
virtual i2d::CRect CalcBoundingBox() const override
Calculate bounding box.
virtual void SetEditableOffset(bool editable=true)
virtual bool IsBackgroundTransparent() const
Definition CLabelShape.h:88
CLabelShape(TextAlign align=TAL_RIGHT_TOP, const istd::CIndex2d &offset=istd::CIndex2d(20, -20))
virtual bool OnMouseButton(istd::CIndex2d position, Qt::MouseButton buttonType, bool downFlag) override
It is called, when mouse button is pushed down or up on this object.
virtual const istd::CIndex2d & GetDrawOffset() const override
Get the drawing offset for the label.
virtual TouchState IsTouched(istd::CIndex2d position) const override
Check, if any shape is touched.
virtual void SetDrawOffset(const istd::CIndex2d &offset) override
Set the drawing offset for the label.
CInteractiveShapeBase ShapeBaseClass
Definition CLabelShape.h:18
virtual bool OnMouseMove(istd::CIndex2d position) override
It is called, when mouse is moved.
Interface for text label drawing parameters.
TextAlign
Text alignment mode.
TouchState
Enumeration for possible shape touch states.
Definition ITouchable.h:25
In this library is defined 2D view concept and standard visualisation objects.