kchart

kchart_params.h
1/* This file is part of the KDE project
2 Copyright (C) 2001,2002,2003,2004 Laurent Montel <montel@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 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 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20
21#ifndef KCHART_PARAMS_H
22#define KCHART_PARAMS_H
23
24
25class KoXmlWriter;
26class KoGenStyles;
27class KoOasisLoadingContext;
28class KoStore;
29class KDChartParams;
30class DCOPObject;
31
32
34
35
36namespace KChart
37{
38
39class KChartPart;
40
41class KChartParams : public KDChartParams
42{
43 public:
44 typedef enum {
45 // From KDChart
46 NoType = KDChartParams::NoType,
47 Bar = KDChartParams::Bar,
48 Line = KDChartParams::Line,
49 Area = KDChartParams::Area,
50 Pie = KDChartParams::Pie,
51 HiLo = KDChartParams::HiLo,
52 Ring = KDChartParams::Ring,
53 Polar = KDChartParams::Polar,
54 BoxWhisker = KDChartParams::BoxWhisker
55
56 } ChartType;
57
58 // Data direction
59 typedef enum {
60 DataRows = 0,
61 DataColumns = 1
62 } DataDirection;
63
64
65 KChartParams( KChartPart *_part );
66 ~KChartParams();
67
68 KChartPart * part() const { return m_part; }
69
70 // ----------------------------------------------------------------
71 // Reimplementation of selected KDChartParams methods
72 ChartType chartType() const { return m_chartType; }
73 void setChartType( ChartType _type ) {
74 m_chartType = _type;
76 }
77
78 // Data in rows or columns.
79 DataDirection dataDirection() const { return m_dataDirection; }
80 void setDataDirection( DataDirection _dir ) {
81 m_dataDirection = _dir;
82 }
83
84 TQString chartTypeToString( ChartType _type) const;
85 ChartType stringToChartType( const TQString& string );
86
87
88 bool firstRowAsLabel() const { return m_firstRowAsLabel; }
89 void setFirstRowAsLabel( bool _val );
90 bool firstColAsLabel() const { return m_firstColAsLabel; }
91 void setFirstColAsLabel( bool _val );
92
93 // Data area
94 TQString dataArea() const { return m_dataArea; }
95 void setDataArea( TQString dataArea ) {
96 m_dataArea = dataArea;
97 }
98
99
100 // ----------------------------------------------------------------
101 // BAR CHART EXTENSIONS TO SUPPORT OPENDOCUMENT
102
103public slots:
104
105 void setBarNumLines( int _numLines ) {
106 m_barNumLines = _numLines;
107 emit changed();
108 }
109
110 int barNumLines() const {
111 return m_barNumLines;
112 }
113
114 // ----------------------------------------------------------------
115
116 public:
117
118 DCOPObject *dcopObject();
119
120 bool loadOasis( const TQDomElement &chartElem,
121 KoOasisLoadingContext &loadingContext,
122 TQString &errorMessage,
123 KoStore *store );
124 void saveOasis( KoXmlWriter* bodyWriter, KoGenStyles& mainStyles ) const;
125
126 private:
127 bool loadOasisPlotarea( const TQDomElement &plotareaElem,
128 KoOasisLoadingContext &loadingContext,
129 TQString &errorMessage );
130 bool loadOasisAxis( const TQDomElement &axisElem,
131 KoOasisLoadingContext &loadingContext,
132 TQString &errorMessage,
133 KDChartAxisParams::AxisPos axisPos );
134 void loadOasisFont( KoOasisLoadingContext& context, TQFont& font, TQColor& color );
135
136 void saveOasisPlotArea( KoXmlWriter* bodyWriter, KoGenStyles& mainStyles ) const;
137 void saveOasisAxis( KoXmlWriter* bodyWriter, KoGenStyles& mainStyles,
138 KDChartAxisParams::AxisPos axisPos,
139 const char* axisName ) const;
140 TQString saveOasisFont( KoGenStyles& mainStyles, const TQFont& font,
141 const TQColor& color ) const;
142
143 private:
144 KChartPart *m_part;
145
146 // Info about the chart itself.
147 ChartType m_chartType;
148
149 // Info about the data.
150 DataDirection m_dataDirection; // Rows or Columns
151 bool m_firstRowAsLabel;
152 bool m_firstColAsLabel;
153
154 TQString m_dataArea;
155
156 // Extensions to support OpenDocument
157 int m_barNumLines; // Number of lines in a bar chart.
158
159 DCOPObject *m_dcop;
160};
161
162} //KChart namespace
163
164#endif
Header for all common chart parameters.
Bundles the display parameters of a chart.
void setChartType(ChartType chartType)
Specifies the chart type.
TQRect dataArea() const
Returns the true data area rectangle as it was was calculate by KD Chart.
void changed()
This signal is emitted when any of the chart parameters has changed.
ChartType
The chart type.
ChartType chartType() const
Returns the chart type configured in this params object.