CLabelShape.h
Go to the documentation of this file.
1 #ifndef iview_CLabelShape_included
2 #define iview_CLabelShape_included
3 
4 
5 #include <i2d/CLabel.h>
6 
7 #include <iview/CPinShape.h>
8 
9 
10 namespace iview
11 {
12 
13 
14 class CLabelShape: public CPinShape
15 {
16 public:
19 
20  enum TextAlign
21  {
29  };
30 
32  TextAlign align = TAL_RIGHT_TOP,
33  const istd::CIndex2d& offset = istd::CIndex2d(20, -20));
34 
35  virtual TextAlign GetTextAlign() const;
36  virtual void SetTextAlign(TextAlign align);
37  virtual const istd::CIndex2d& GetDrawOffset() const;
38  virtual void SetDrawOffset(const istd::CIndex2d& offset);
39 
40  virtual bool IsPositionVisible() const;
41  virtual void SetPositionVisible(bool visible = true);
42  virtual bool IsBackgroundTransparent() const;
43  virtual void SetBackgroundTransparent(bool state = true);
44  virtual bool IsEditableOffset() const;
45  virtual void SetEditableOffset(bool editable = true);
46 
47  // reimplemented (iview::IMouseActionObserver)
48  virtual bool OnMouseButton(istd::CIndex2d position, Qt::MouseButton buttonType, bool downFlag);
49  virtual bool OnMouseMove(istd::CIndex2d position);
50 
51  // reimplemented (iview::IVisualizable)
52  virtual void Draw(QPainter& drawContext) const;
53 
54  // reimplemented (imod::IObserver)
55  virtual bool OnModelAttached(imod::IModel* modelPtr, istd::IChangeable::ChangeSet& changeMask);
56 
57  // reimplemented (iview::ITouchable)
58  virtual TouchState IsTouched(istd::CIndex2d position) const;
59 
60 protected:
61  enum EditMode
62  {
66  };
67 
68  void CalculateTextOriginSize(i2d::CRect& textBox) const;
69 
70  // reimplemented (iview::CInteractiveShapeBase)
71  virtual i2d::CRect CalcBoundingBox() const;
72 
73 private:
74  istd::CIndex2d m_referenceOffset;
75  TextAlign m_textAlign;
76  mutable istd::CIndex2d m_drawOffset;
77  bool m_isPositionVisible;
78  bool m_isBackgroundTransparent;
79  bool m_isEditableOffset;
80  EditMode m_editMode;
81 
82  bool m_isAlignFixed;
83 };
84 
85 
87 {
88  return m_textAlign;
89 }
90 
91 
93 {
94  m_textAlign = align;
95 }
96 
97 
99 {
100  return m_drawOffset;
101 }
102 
103 
104 inline void CLabelShape::SetDrawOffset(const istd::CIndex2d& offset)
105 {
106  m_drawOffset = offset;
107 }
108 
109 
111 {
112  return m_isPositionVisible;
113 }
114 
115 
116 inline void CLabelShape::SetPositionVisible(bool visible)
117 {
118  m_isPositionVisible = visible;
119 }
120 
121 
123 {
124  return m_isBackgroundTransparent;
125 }
126 
127 
129 {
130  m_isBackgroundTransparent = state;
131 }
132 
133 
134 inline bool CLabelShape::IsEditableOffset() const
135 {
136  return m_isEditableOffset;
137 }
138 
139 
140 inline void CLabelShape::SetEditableOffset(bool editable)
141 {
142  m_isEditableOffset = editable;
143 }
144 
145 
146 } // namespace iview
147 
148 
149 #endif // !iview_CLabelShape_included
150 
151 
virtual bool IsBackgroundTransparent() const
Definition: CLabelShape.h:122
CInteractiveShapeBase ShapeBaseClass
Definition: CLabelShape.h:18
virtual void Draw(QPainter &drawContext) const
Draw this shape using draw context.
Simple rectangle with integer bounds.
Definition: CRect.h:21
Index implementation for addressing elements in 2D-space.
Definition: CIndex2d.h:20
virtual bool IsPositionVisible() const
Definition: CLabelShape.h:110
virtual bool OnMouseMove(istd::CIndex2d position)
It is called, when mouse is moved.
CPinShape BaseClass
Definition: CLabelShape.h:17
virtual void SetEditableOffset(bool editable=true)
Definition: CLabelShape.h:140
virtual void SetBackgroundTransparent(bool state=true)
Definition: CLabelShape.h:128
virtual i2d::CRect CalcBoundingBox() const
Calculate bounding box.
virtual void SetTextAlign(TextAlign align)
Definition: CLabelShape.h:92
CLabelShape(TextAlign align=TAL_RIGHT_TOP, const istd::CIndex2d &offset=istd::CIndex2d(20,-20))
virtual void SetDrawOffset(const istd::CIndex2d &offset)
Definition: CLabelShape.h:104
TouchState
Enumeration for possible shape touch states.
Definition: ITouchable.h:24
virtual TouchState IsTouched(istd::CIndex2d position) const
Check, if any shape is touched.
void CalculateTextOriginSize(i2d::CRect &textBox) const
Common interface for model objects, that supports Model/Observer design pattern.
Definition: IModel.h:23
Set of change flags (its IDs).
Definition: IChangeable.h:30
virtual const istd::CIndex2d & GetDrawOffset() const
Definition: CLabelShape.h:98
virtual bool IsEditableOffset() const
Definition: CLabelShape.h:134
virtual TextAlign GetTextAlign() const
Definition: CLabelShape.h:86
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 OnMouseButton(istd::CIndex2d position, Qt::MouseButton buttonType, bool downFlag)
It is called, when mouse button is pushed down or up on this object.
virtual void SetPositionVisible(bool visible=true)
Definition: CLabelShape.h:116

© 2007-2017 Witold Gantzke and Kirill Lepskiy