LunaSysMgr
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
textbox.h
Go to the documentation of this file.
1
/* @@@LICENSE
2
*
3
* Copyright (c) 2011-2012 Hewlett-Packard Development Company, L.P.
4
*
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
* you may not use this file except in compliance with the License.
7
* You may obtain a copy of the License at
8
*
9
* http://www.apache.org/licenses/LICENSE-2.0
10
*
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
16
*
17
* LICENSE@@@ */
18
19
20
21
22
#ifndef TEXTBOX_H_
23
#define TEXTBOX_H_
24
25
#include "
thingpaintable.h
"
26
#include <QString>
27
#include <QPointer>
28
#include <QFont>
29
#include <QTextLayout>
30
31
class
PixmapObject
;
32
33
namespace
TextBoxHorizontalAlignment
34
{
35
enum
Enum
36
{
37
INVALID
,
38
Left
,
39
Right
,
40
Center
41
};
42
}
43
44
namespace
TextBoxVerticalAlignment
45
{
46
enum
Enum
47
{
48
INVALID
,
49
Top
,
50
Bottom
,
51
Center
52
};
53
}
54
55
class
TextBox
:
public
ThingPaintable
56
{
57
Q_OBJECT
58
Q_INTERFACES(
QGraphicsItem
)
59
60
Q_PROPERTY(QString
innertext
READ
innerText
WRITE
setInnerText
RESET
resetInnerText
NOTIFY
signalInnerTextChanged
)
61
62
public:
63
64
static const
char
*
InnerTextPropertyName
;
//keep in sync with Q_PROPERTY
65
66
TextBox
(
PixmapObject
* p_backgroundPmo,const QRectF& geom);
67
TextBox
(
PixmapObject
* p_backgroundPmo,const QRectF& geom,const QString& inner_text);
68
virtual ~
TextBox
();
69
70
virtual
void
paint
(QPainter *painter, const QStyleOptionGraphicsItem *option=0,QWidget *widget=0);
71
virtual
void
paintOffscreen
(QPainter *painter);
72
73
virtual QString
innerText
() const;
74
virtual
void
setInnerText
(const QString& v);
75
virtual
void
resetInnerText
();
76
77
//TODO: temporary; remove when a better system (like styles) goes in place
78
static QFont
staticLabelFontForTextBox
();
79
80
Q_SIGNALS:
81
82
void
signalInnerTextChanged
(const QString&);
83
84
protected:
85
86
//PREREQUISITE: m_geom must be valid, at least its size()
87
//RESULT: m_innerTextMaxGeom will be valid
88
virtual
void
recalculateMaxTextGeomForCurrentGeom
();
89
90
// PREREQUISITE: m_innerTextMaxGeom must be valid, at least its size()
91
// RESULT: m_textLayoutObject will have the correct layout, m_innerTextGeom will be set correctly for the current inner text,
92
virtual
void
redoInnerTextLayout
();
//run this after the geometry changes. This is absolutely necessary
93
// ALSO run this after the inner text changes. don't ask, just do it. Not necessary now, but it most likely will be later
94
95
// PREREQUISITE: m_geom , m_innerTextMaxGeom and m_innerTextGeom are set
96
// RESULT: m_innerTextPosICS and m_innerTextPosPntCS are set
97
virtual
void
recalculateInnerTextPosition
();
98
99
protected:
100
101
QString
m_innerText
;
102
QPointer<
PixmapObject
>
m_qp_background
;
103
104
//text layout for the label
105
QPointF
m_innerTextPosICS
;
// position in ICS, and corresponds to m_labelGeom
106
QPoint
m_innerTextPosPntCS
;
// same, but precomputed to offscreen painter coords relative to 0,0 at top left
107
QRect
m_innerTextMaxGeom
;
// precomputed by recalculateLabelBoundsForCurrentGeom()
108
109
QRect
m_innerTextGeom
;
//precomputed by redoLabelTextLayout(); this one is the CURRENT text box (always <= m_innerTextMaxGeom)
110
QTextLayout
m_textLayoutObject
;
111
QPointer<
PixmapObject
>
m_qp_prerenderedInnerTextPixmap
;
112
113
};
114
115
#endif
/* TEXTBOX_H_ */
luna-sysmgr
Src
lunaui
launcher
elements
static
textbox.h
Generated on Fri Jun 21 2013 00:53:53 for LunaSysMgr by
1.8.3.1