All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TextItem.h
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file TextItem.h
22 
23  \brief Class that represents text. This object is of type QGraphicsTextItem. He is directly editable via user interaction.
24  His transformation matrix is inverted, that is, the inverse of the matrix of the scene, so its coordinate system is screen (pixel),
25  but its position in the scene remains in millimeters.
26  This is also son of ItemObserver, so it can become observer of a model (Observable). "View" part of MVC component.
27 
28  \ingroup layout
29 */
30 
31 #ifndef __TERRALIB_LAYOUT_INTERNAL_TEXT_ITEM_H
32 #define __TERRALIB_LAYOUT_INTERNAL_TEXT_ITEM_H
33 
34 // TerraLib
35 #include "../../core/pattern/mvc/ItemObserver.h"
36 #include "ObjectItem.h"
37 #include "../../core/Config.h"
38 #include "ParentItem.h"
39 
40 // Qt
41 #include <QGraphicsTextItem>
42 #include <QImage>
43 #include <QColor>
44 #include <QVariant>
45 #include <QPointF>
46 #include <QRectF>
47 
48 class QTextTable;
49 class QGraphicsSceneMouseEvent;
50 class QKeyEvent;
51 class QGraphicsSceneContextMenuEvent;
52 
53 namespace te
54 {
55  namespace layout
56  {
57  class Observable;
58 
59  /*!
60  \brief Class that represents text. This object is of type QGraphicsTextItem. He is directly editable via user interaction.
61  His transformation matrix is inverted, that is, the inverse of the matrix of the scene, so its coordinate system is screen (pixel),
62  but its position in the scene remains in millimeters.
63  Drawing starting point is llx, lly.
64  He is also the son of ItemObserver, so it can become observer of a model (Observable). "View" part of MVC component.
65 
66  \ingroup layout
67 
68  \sa te::layout::ItemObserver
69  */
70  class TELAYOUTEXPORT TextItem : public ParentItem<QGraphicsTextItem>
71  {
72  Q_OBJECT //for slots/signals
73 
74  public:
75 
76  /*!
77  \brief Constructor
78 
79  \param controller "Controller" part of MVC component
80  \param o "Model" part of MVC component
81  */
82  TextItem( ItemController* controller, Observable* o );
83 
84  /*!
85  \brief Destructor
86  */
87  virtual ~TextItem();
88 
89  /*!
90  \brief Reimplemented from ItemObserver
91  */
92  virtual void updateObserver( ContextItem context );
93 
94  /*!
95  \brief Reimplemented from QGraphicsTextItem
96  */
97  virtual void paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 );
98 
99  virtual void refreshDocument();
100 
101  /*!
102  \brief
103 
104  \return
105  */
106  virtual bool isEditable();
107 
108  /*!
109  \brief
110 
111  \param
112  */
113  virtual void setEditable(bool editable);
114 
115  /*!
116  \brief Reimplemented from QGraphicsItem
117  */
118  virtual QRectF boundingRect() const;
119 
120  /*!
121  \brief Reimplemented from ItemObserver
122  */
123  virtual te::color::RGBAColor** getRGBAColorImage(int &w, int &h);
124 
125  protected:
126 
127  /*!
128  \brief Reimplemented from QGraphicsTextItem
129  */
130  virtual QVariant itemChange ( GraphicsItemChange change, const QVariant & value );
131 
132  /*!
133  \brief Reimplemented from QGraphicsTextItem
134  */
135  virtual void keyPressEvent ( QKeyEvent * event );
136 
137  /*!
138  \brief Reimplemented from QGraphicsTextItem
139  */
140  virtual void mouseDoubleClickEvent ( QGraphicsSceneMouseEvent * event );
141 
142  /*!
143  \brief Reimplemented from QGraphicsTextItem
144  */
145  virtual void mouseMoveEvent ( QGraphicsSceneMouseEvent * event );
146 
147  /*!
148  \brief Reimplemented from QGraphicsTextItem
149  */
150  virtual void mousePressEvent ( QGraphicsSceneMouseEvent * event );
151 
152  /*!
153  \brief Reimplemented from QGraphicsTextItem
154  */
155  virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
156 
157  virtual void init();
158 
159  virtual QImage createImage();
160 
161  /*!
162  \brief Reimplemented from ItemObserver
163  */
164  virtual te::gm::Coord2D getPosition();
165 
166  virtual void getDocumentSizeMM(double &w, double &h);
167 
168  virtual void resetEdit();
169 
170  virtual void updateTextConfig();
171 
174  QTextTable* m_table;
175  bool m_move;
176  };
177  }
178 }
179 
180 #endif
Abstract class to represent an observable. "Model" part of MVC component.
Definition: Observable.h:56
Class responsible for maintaining the drawing context of a MVC component. It is always used by the "M...
Definition: ContextItem.h:49
#define TELAYOUTEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:99
QTextTable * m_table
Definition: TextItem.h:174
An utility struct for representing 2D coordinates.
Definition: Coord2D.h:40
Abstract class to represent a controller. "Controller" part of MVC component. All classes representin...
Abstract class that represents a graphic item. This object is of type QGraphicsObject.
QColor m_backgroundColor
Definition: TextItem.h:172
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
Definition: RGBAColor.h:57
Abstract class that represents a graphic item. Its coordinate system is the same of scene (millimeter...
Definition: ParentItem.h:86
Abstract class that represents a graphic item. Its coordinate system is the same of scene (millimeter...
Class that represents text. This object is of type QGraphicsTextItem. He is directly editable via use...
Definition: TextItem.h:70