KReport

KReportScriptLabel.cpp
1/* This file is part of the KDE project
2 * Copyright (C) 2007-2008 by Adam Pigg (adam@piggz.co.uk)
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "KReportScriptLabel.h"
19
20#include <QSizeF>
21#include <QPointF>
22
23namespace Scripting
24{
25Label::Label(KReportItemLabel *l)
26{
27 m_label = l;
28}
29
30
31Label::~Label()
32{
33}
34
35QString Label::caption() const
36{
37 return m_label->text();
38}
39
40void Label::setCaption(const QString& c)
41{
42 m_label->setText(c);
43}
44
45int Label::horizontalAlignment() const
46{
47 const QString a = m_label->m_horizontalAlignment->value().toString().toLower();
48
49 if (a == QLatin1String("left")) {
50 return -1;
51 }
52 if (a == QLatin1String("center")) {
53 return 0;
54 }
55 if (a == QLatin1String("right")) {
56 return 1;
57 }
58 return -1;
59}
60void Label::setHorizonalAlignment(int a)
61{
62 switch (a) {
63 case -1:
64 m_label->m_horizontalAlignment->setValue(QLatin1String("left"));
65 break;
66 case 0:
67 m_label->m_horizontalAlignment->setValue(QLatin1String("center"));
68 break;
69 case 1:
70 m_label->m_horizontalAlignment->setValue(QLatin1String("right"));
71 break;
72 default:
73 m_label->m_horizontalAlignment->setValue(QLatin1String("left"));
74 break;
75 }
76}
77
78int Label::verticalAlignment() const
79{
80 const QString a = m_label->m_horizontalAlignment->value().toString().toLower();
81
82 if (a == QLatin1String("top")) {
83 return -1;
84 }
85 if (a == QLatin1String("middle")) {
86 return 0;
87 }
88 if (a == QLatin1String("bottom")) {
89 return 1;
90 }
91 return -1;
92}
93void Label::setVerticalAlignment(int a)
94{
95 switch (a) {
96 case -1:
97 m_label->m_verticalAlignment->setValue(QLatin1String("top"));
98 break;
99 case 0:
100 m_label->m_verticalAlignment->setValue(QLatin1String("middle"));
101 break;
102 case 1:
103 m_label->m_verticalAlignment->setValue(QLatin1String("bottom"));
104 break;
105 default:
106 m_label->m_verticalAlignment->setValue(QLatin1String("middle"));
107 break;
108 }
109}
110
111QColor Label::backgroundColor() const
112{
113 return m_label->m_backgroundColor->value().value<QColor>();
114}
115void Label::setBackgroundColor(const QColor& c)
116{
117 m_label->m_backgroundColor->setValue(c);
118}
119
120QColor Label::foregroundColor() const
121{
122 return m_label->m_foregroundColor->value().value<QColor>();
123}
124void Label::setForegroundColor(const QColor& c)
125{
126 m_label->m_foregroundColor->setValue(c);
127}
128
129int Label::backgroundOpacity() const
130{
131 return m_label->m_backgroundOpacity->value().toInt();
132}
133void Label::setBackgroundOpacity(int o)
134{
135 m_label->m_backgroundOpacity->setValue(o);
136}
137
138QColor Label::lineColor() const
139{
140 return m_label->m_lineColor->value().value<QColor>();
141}
142void Label::setLineColor(const QColor& c)
143{
144 m_label->m_lineColor->setValue(c);
145}
146
147int Label::lineWeight() const
148{
149 return m_label->m_lineWeight->value().toInt();
150}
151void Label::setLineWeight(int w)
152{
153 m_label->m_lineWeight->setValue(w);
154}
155
156int Label::lineStyle() const
157{
158 return m_label->m_lineStyle->value().toInt();
159}
160void Label::setLineStyle(int s)
161{
162 if (s < 0 || s > 5) {
163 s = 1;
164 }
165 m_label->m_lineStyle->setValue(s);
166}
167
168QPointF Label::position() const
169{
170 return m_label->position();
171}
172void Label::setPosition(const QPointF &p)
173{
174 m_label->setPosition(p);
175}
176
177QSizeF Label::size() const
178{
179 return m_label->size();
180}
181void Label::setSize(const QSizeF &s)
182{
183 m_label->setSize(s);
184}
185}
186
QVariant value() const
bool setValue(const QVariant &value, ValueOptions options=ValueOptions())
void setSize(const QSizeF &ptSize)
Sets size for the element.
QPointF position() const
Return the position in points.
void setPosition(const QPointF &ptPos)
Sets position for the element.
QSizeF size() const
Return the size in points.
Field item script interface.
QString toLower() const const
int toInt(bool *ok) const const
QString toString() const const
T value() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:21:31 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.