ICF 3.1.1.10
Technical documentation of ICF Libraries
CLabelShape.h
Go to the documentation of this file.
1/********************************************************************************
2** This file is part of the ICF Framework. Copyright (C) Witold Gantzke & Kirill Lepskiy
3** ICF Framework may be used under the terms of the LGPL License v. 2.1 by the Free Software Foundation.
4********************************************************************************/
5
6#ifndef iview_CLabelShape_included
7#define iview_CLabelShape_included
8
9
10// ICF includes
11#include <i2d/CLabel.h>
13#include <iview/CPinShape.h>
14
15namespace iview
16{
17
18
19class CLabelShape: public CPinShape, virtual public ITextLabelParams
20{
21public:
24
27 const istd::CIndex2d& offset = istd::CIndex2d(20, -20));
28
29 virtual bool IsPositionVisible() const;
30 virtual void SetPositionVisible(bool visible = true);
31 virtual bool IsBackgroundTransparent() const;
32 virtual void SetBackgroundTransparent(bool state = true);
33 virtual bool IsEditableOffset() const;
34 virtual void SetEditableOffset(bool editable = true);
35
36 // reimplemented (ITextLabelParams)
37 virtual TextAlign GetTextAlign() const;
38 virtual void SetTextAlign(TextAlign align);
39 virtual const istd::CIndex2d& GetDrawOffset() const;
40 virtual void SetDrawOffset(const istd::CIndex2d& offset);
41
42 // reimplemented (iview::IMouseActionObserver)
43 virtual bool OnMouseButton(istd::CIndex2d position, Qt::MouseButton buttonType, bool downFlag);
44 virtual bool OnMouseMove(istd::CIndex2d position);
45
46 // reimplemented (iview::IVisualizable)
47 virtual void Draw(QPainter& drawContext) const;
48
49 // reimplemented (imod::IObserver)
50 virtual bool OnModelAttached(imod::IModel* modelPtr, istd::IChangeable::ChangeSet& changeMask);
51
52 // reimplemented (iview::ITouchable)
53 virtual TouchState IsTouched(istd::CIndex2d position) const;
54
55protected:
62
63 void CalculateTextOriginSize(i2d::CRect& textBox) const;
64
65 // reimplemented (iview::CInteractiveShapeBase)
66 virtual i2d::CRect CalcBoundingBox() const;
67
68private:
69 istd::CIndex2d m_referenceOffset;
70 TextAlign m_textAlign;
71 mutable istd::CIndex2d m_drawOffset;
72 bool m_isPositionVisible;
73 bool m_isBackgroundTransparent;
74 bool m_isEditableOffset;
75 EditMode m_editMode;
76
77 bool m_isAlignFixed;
78};
79
80
82{
83 return m_isPositionVisible;
84}
85
86
87inline void CLabelShape::SetPositionVisible(bool visible)
88{
89 m_isPositionVisible = visible;
90}
91
92
94{
95 return m_isBackgroundTransparent;
96}
97
98
100{
101 m_isBackgroundTransparent = state;
102}
103
104
106{
107 return m_isEditableOffset;
108}
109
110
111inline void CLabelShape::SetEditableOffset(bool editable)
112{
113 m_isEditableOffset = editable;
114}
115
116
117// reimplemented (ITextLabelParams)
118
120{
121 return m_textAlign;
122}
123
124
126{
127 m_textAlign = align;
128}
129
130
132{
133 return m_drawOffset;
134}
135
136
138{
139 m_drawOffset = offset;
140}
141
142
143} // namespace iview
144
145
146#endif // !iview_CLabelShape_included
147
148
Simple rectangle with integer bounds.
Definition CRect.h:26
Common interface for model objects, that supports Model/Observer design pattern.
Definition IModel.h:29
Index implementation for addressing elements in 2D-space.
Definition CIndex2d.h:25
Set of change flags (its IDs).
Definition IChangeable.h:38
Base class of shape implementation with user interaction.
virtual void SetBackgroundTransparent(bool state=true)
Definition CLabelShape.h:99
virtual void SetPositionVisible(bool visible=true)
Definition CLabelShape.h:87
virtual void SetDrawOffset(const istd::CIndex2d &offset)
Set the drawing offset for the label.
virtual bool IsPositionVisible() const
Definition CLabelShape.h:81
virtual void Draw(QPainter &drawContext) const
Draw this shape using draw context.
void CalculateTextOriginSize(i2d::CRect &textBox) const
virtual const istd::CIndex2d & GetDrawOffset() const
Get the drawing offset for the label.
virtual TextAlign GetTextAlign() const
Get text alignment modein label shape.
virtual TouchState IsTouched(istd::CIndex2d position) const
Check, if any shape is touched.
virtual i2d::CRect CalcBoundingBox() const
Calculate bounding box.
virtual bool IsEditableOffset() const
virtual void SetTextAlign(TextAlign align)
Set text alignment mode.
CInteractiveShapeBase ShapeBaseClass
Definition CLabelShape.h:23
virtual void SetEditableOffset(bool editable=true)
virtual bool IsBackgroundTransparent() const
Definition CLabelShape.h:93
virtual bool OnModelAttached(imod::IModel *modelPtr, istd::IChangeable::ChangeSet &changeMask)
This call back function will be called, if an observable object is about to be attached.
virtual bool OnMouseMove(istd::CIndex2d position)
It is called, when mouse is moved.
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)
It is called, when mouse button is pushed down or up on this object.
CPinShape BaseClass
Definition CLabelShape.h:22
Interface for text label drawing parameters.
TextAlign
Text alignment mode.
TouchState
Enumeration for possible shape touch states.
Definition ITouchable.h:30
In this library is defined 2D view concept and standard visualisation objects.

© Witold Gantzke and Kirill Lepskiy