KReport

KReportBoundedTextItem.h
1/* This file is part of the KDE project
2 Copyright (C) 2014 Adam Pigg <adam@piggz.co.uk>
3 Copyright (C) 2016 Jarosław Staniek <staniek@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library 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 GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20
21#ifndef KREPORT_BOUNDEDTEXTITEM_H
22#define KREPORT_BOUNDEDTEXTITEM_H
23
24#include <QGraphicsTextItem>
25#include <QFont>
26
27/**
28 * @brief Subclass of QGraphicsTextItem which simply forces
29 * its boundingRect to be the same as its parent.
30 * By default a QGraphicsTextItem will size to its text and
31 * we want it to size to the parent item.
32 *
33 */
35{
37
38public:
40 QRectF boundingRect() const override;
41 void paint(QPainter *painter, const QStyleOptionGraphicsItem *o, QWidget *w) override;
42 void setBackgroudColor(const QColor &bc);
43 void setForegroundColor(const QColor &fc);
44
45 //! @return background opacity, 0..1.0
46 qreal backgroudOpacity() const;
47
48 //! Sets background opacity, 0..1.0
49 void setBackgroudOpacity(qreal opacity);
50
51 void setDisplayFont(const QFont &f);
52
53
54protected:
55 void keyReleaseEvent ( QKeyEvent * event ) override;
56
57private:
58 QColor m_backgroundColor;
59 QColor m_foregroundColor;
60 QFont m_font;
61
62 qreal m_backgroundOpacity;
63
65 void exitEditMode();
66
67};
68
69#endif // KREPORT_BOUNDEDTEXTITEM_H
Subclass of QGraphicsTextItem which simply forces its boundingRect to be the same as its parent.
void setBackgroudOpacity(qreal opacity)
Sets background opacity, 0..1.0.
virtual bool event(QEvent *ev) override
Q_OBJECTQ_OBJECT
Q_SIGNALSQ_SIGNALS
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:06:04 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.