KD Chart 2
[rev.2.5.1]
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Macros
Pages
src
KDChart
KDChartHeaderFooter.cpp
Go to the documentation of this file.
1
/****************************************************************************
2
** Copyright (C) 2001-2013 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 "
KDChartHeaderFooter.h
"
24
#include "KDChartHeaderFooter_p.h"
25
26
#include "
KDChartChart.h
"
27
#include <
KDChartTextAttributes.h
>
28
#include <QFont>
29
#include <QPainter>
30
#include <QAbstractTextDocumentLayout>
31
#include <QTextDocumentFragment>
32
#include <QTextBlock>
33
#include <QtDebug>
34
#include <QLabel>
35
#include "
KDTextDocument.h
"
36
37
#include <KDABLibFakes>
38
39
using namespace
KDChart;
40
41
HeaderFooter::Private::Private() :
42
type( Header ),
43
position(
Position
::North )
44
{
45
}
46
47
HeaderFooter::Private::~Private()
48
{
49
}
50
51
#define d d_func()
52
53
HeaderFooter::HeaderFooter
(
Chart
* parent ) :
54
TextArea
( new Private() )
55
{
56
setParent
( parent );
57
init();
58
}
59
60
HeaderFooter::~HeaderFooter
()
61
{
62
emit
destroyedHeaderFooter
(
this
);
63
}
64
65
void
HeaderFooter::setParent
(
QObject
* parent )
66
{
67
QObject::setParent( parent );
68
setParentWidget
( qobject_cast<QWidget*>( parent ) );
69
if
( parent && !
autoReferenceArea
() )
70
setAutoReferenceArea
( parent );
71
}
72
73
void
HeaderFooter::init()
74
{
75
TextAttributes
ta;
76
ta.
setPen
( QPen(Qt::black) );
77
ta.
setFont
( QFont( QLatin1String(
"helvetica"
), 10, QFont::Bold,
false
) );
78
79
Measure
m( 35.0 );
80
m.setRelativeMode(
autoReferenceArea
(),
KDChartEnums::MeasureOrientationMinimum
);
81
ta.
setFontSize
( m );
82
83
m.setValue( 8.0 );
84
m.setCalculationMode(
KDChartEnums::MeasureCalculationModeAbsolute
);
85
ta.
setMinimalFontSize
( m );
86
87
setTextAttributes
( ta );
88
}
89
93
HeaderFooter
*
HeaderFooter::clone
()
const
94
{
95
HeaderFooter
* headerFooter =
new
HeaderFooter
(
new
Private( *
d
), 0 );
96
headerFooter->
setType
(
type
() );
97
headerFooter->
setPosition
(
position
() );
98
headerFooter->
setText
(
text
() );
99
headerFooter->
setTextAttributes
(
textAttributes
() );
100
return
headerFooter;
101
}
102
103
bool
HeaderFooter::compare
(
const
HeaderFooter
& other )
const
104
{
105
return
(
type
() == other.
type
()) &&
106
(
position
() == other.
position
()) &&
107
// also compare members inherited from the base class:
108
(
autoReferenceArea
() == other.
autoReferenceArea
()) &&
109
(
text
() == other.
text
()) &&
110
(
textAttributes
() == other.
textAttributes
());
111
}
112
113
void
HeaderFooter::setType
(
HeaderFooterType
type )
114
{
115
if
(
d
->type != type ) {
116
d
->type =
type
;
117
emit
positionChanged
(
this
);
118
}
119
}
120
121
HeaderFooter::HeaderFooterType
HeaderFooter::type
()
const
122
{
123
return
d
->type;
124
}
125
126
void
HeaderFooter::setPosition
(
Position
position )
127
{
128
if
(
d
->position != position ) {
129
d
->position =
position
;
130
emit
positionChanged
(
this
);
131
}
132
}
133
134
Position
HeaderFooter::position
()
const
135
{
136
return
d
->position;
137
}
Klarälvdalens Datakonsult AB (KDAB)
Qt-related services and products
http://www.kdab.com/
http://www.kdab.com/products/kd-chart/