KD Chart 2  [rev.2.7]
KDChartTextArea.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 ** Copyright (C) 2001-2020 Klaralvdalens Datakonsult AB. All rights reserved.
3 **
4 ** This file is part of the KD Chart library.
5 **
6 ** Licensees holding valid commercial KD Chart licenses may use this file in
7 ** accordance with the KD Chart Commercial License Agreement provided with
8 ** the Software.
9 **
10 **
11 ** This file may be distributed and/or modified under the terms of the
12 ** GNU General Public License version 2 and version 3 as published by the
13 ** Free Software Foundation and appearing in the file LICENSE.GPL.txt included.
14 **
15 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17 **
18 ** Contact info@kdab.com if any conditions of this licensing are not
19 ** clear to you.
20 **
21 **********************************************************************/
22 
23 #include "KDChartTextArea.h"
24 #include "KDChartTextArea_p.h"
25 
26 #include <qglobal.h>
27 
28 #include <QPainter>
29 #include <QRect>
30 
31 #include <KDABLibFakes>
32 
33 
34 using namespace KDChart;
35 
36 TextArea::Private::Private() :
37  AbstractAreaBase::Private()
38 {
39  // this bloc left empty intentionally
40 }
41 
42 
43 TextArea::Private::~Private()
44 {
45  // this bloc left empty intentionally
46 }
47 
48 
50  : QObject()
53 {
54  // this bloc left empty intentionally
55 }
56 
58 {
59  // this bloc left empty intentionally
60 }
61 
62 
63 void TextArea::init()
64 {
65  // this bloc left empty intentionally
66 }
67 
68 void TextArea::paintIntoRect( QPainter& painter, const QRect& rect )
69 {
70  const QRect oldGeometry( geometry() );
71  if ( oldGeometry != rect )
72  setGeometry( rect );
73  painter.translate( rect.left(), rect.top() );
74  paintAll( painter );
75  painter.translate( -rect.left(), -rect.top() );
76  if ( oldGeometry != rect )
77  setGeometry( oldGeometry );
78 }
79 
80 void TextArea::paintAll( QPainter& painter )
81 {
82  // Paint the background and frame
83  paintBackground( painter, geometry() );
84  paintFrame( painter, geometry() );
85 
86  // temporarily adjust the widget size, to be sure all content gets calculated
87  // to fit into the inner rectangle
88  const QRect oldGeometry( areaGeometry() );
89  QRect inner( innerRect() );
90  inner.moveTo(
91  oldGeometry.left() + inner.left(),
92  oldGeometry.top() + inner.top() );
93  const bool needAdjustGeometry = oldGeometry != inner;
94  if ( needAdjustGeometry )
95  setGeometry( inner );
96  paint( &painter );
97  if ( needAdjustGeometry )
98  setGeometry( oldGeometry );
99  //qDebug() << "TextAreaWidget::paintAll() done.";
100 }
101 
103 {
104  return geometry();
105 }
106 
108 {
109  emit positionChanged( this );
110 }
111 
void setGeometry(const QRect &r) override
pure virtual in QLayoutItem
virtual void paintFrame(QPainter &painter, const QRect &rectangle)
Layout item showing a text.
Base class for AbstractArea and AbstractAreaWidget: An area in the chart with a background, a frame, etc.
QRect areaGeometry() const override
virtual void paintBackground(QPainter &painter, const QRect &rectangle)
void paintAll(QPainter &painter) override
Call paintAll, if you want the background and the frame to be drawn before the normal paint() is invo...
void paint(QPainter *) override
void positionHasChanged() override
QRect geometry() const override
pure virtual in QLayoutItem
Class only listed here to document inheritance of some KDChart classes.
void positionChanged(TextArea *)
virtual void paintIntoRect(QPainter &painter, const QRect &rect)
Draws the background and frame, then calls paint().

Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/

https://www.kdab.com/development-resources/qt-tools/kd-chart/