kchart

KDChartParams_frame.cpp
1/*
2 KDChart - a multi-platform charting engine
3 */
4
5/****************************************************************************
6 ** Copyright (C) 2001-2003 Klarälvdalens Datakonsult AB. All rights reserved.
7 **
8 ** This file is part of the KDChart library.
9 **
10 ** This file may be distributed and/or modified under the terms of the
11 ** GNU General Public License version 2 as published by the Free Software
12 ** Foundation and appearing in the file LICENSE.GPL included in the
13 ** packaging of this file.
14 **
15 ** Licensees holding valid commercial KDChart licenses may use this file in
16 ** accordance with the KDChart Commercial License Agreement provided with
17 ** the Software.
18 **
19 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
20 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21 **
22 ** See http://www.klaralvdalens-datakonsult.se/?page=products for
23 ** information about KDChart Commercial License Agreements.
24 **
25 ** Contact info@klaralvdalens-datakonsult.se if any conditions of this
26 ** licensing are not clear to you.
27 **
28 **********************************************************************/
29
30#include "KDChartParams.h"
31#include <KDXMLTools.h>
32
33
44
45
50{
51 _dataRow = 0;
52 _dataCol = 0;
53 _data3rd = 0;
54 _frame = 0;
55 resetFrame();
56 _outerGapX = 0;
57 _outerGapY = 0;
58 _innerGapX = 0;
59 _innerGapY = 0;
60 _addFrameWidthToLayout = true;
61 _addFrameHeightToLayout = true;
62}
63
64
79 uint dataRow,
80 uint dataCol,
81 uint data3rd,
82 const KDFrame& frame,
83 int outerGapX,
84 int outerGapY,
85 int innerGapX,
86 int innerGapY,
89 : _dataRow( dataRow ),
90 _dataCol( dataCol ),
91 _data3rd( data3rd ),
92 _frame( 0 ),
93 _outerGapX( outerGapX ),
94 _outerGapY( outerGapY ),
95 _innerGapX( innerGapX ),
96 _innerGapY( innerGapY ),
97 _addFrameWidthToLayout( addFrameWidthToLayout ),
98_addFrameHeightToLayout( addFrameHeightToLayout )
99{
100 resetFrame();
101 KDFrame::deepCopy(*_frame, frame);
102}
103
104
105
113
123 KDChartFrameSettings& settings,
124 uint& areaId )
125{
126 bool ok = true;
127 KDFrame tempFrame;
128 int tempId = KDChartEnums::AreaUNKNOWN;
129 int tempDataRow = 0; // these 3 need initialization since they were not
130 int tempDataCol = 0;// existent in previous releases of KDChart
131 int tempData3rd = 0;
132
133 int tempOuterGapX, tempOuterGapY, tempInnerGapX, tempInnerGapY;
134 bool tempAddFrameWidthToLayout, tempAddFrameHeightToLayout;
135 TQDomNode node = element.firstChild();
136 while( !node.isNull() ) {
137 TQDomElement element = node.toElement();
138 if( !element.isNull() ) { // was really an element
139 TQString tagName = element.tagName();
140 if( tagName == "Frame" ) {
141 ok = ok & KDFrame::readFrameNode( element, tempFrame );
142 } else if( tagName == "AreaId" ) {
143 ok = ok & KDXML::readIntNode( element, tempId );
144 } else if( tagName == "DataRow" ) {
145 ok = ok & KDXML::readIntNode( element, tempDataRow );
146 } else if( tagName == "DataCol" ) {
147 ok = ok & KDXML::readIntNode( element, tempDataCol );
148 } else if( tagName == "Data3rd" ) {
149 ok = ok & KDXML::readIntNode( element, tempData3rd );
150 } else if( tagName == "OuterGapX" ) {
151 ok = ok & KDXML::readIntNode( element, tempOuterGapX );
152 } else if( tagName == "OuterGapY" ) {
153 ok = ok & KDXML::readIntNode( element, tempOuterGapY );
154 } else if( tagName == "InnerGapX" ) {
155 ok = ok & KDXML::readIntNode( element, tempInnerGapX );
156 } else if( tagName == "InnerGapY" ) {
157 ok = ok & KDXML::readIntNode( element, tempInnerGapY );
158 } else if( tagName == "AddFrameWidthToLayout" ) {
159 ok = ok & KDXML::readBoolNode( element, tempAddFrameWidthToLayout );
160 } else if( tagName == "AddFrameHeightToLayout" ) {
161 ok = ok & KDXML::readBoolNode( element, tempAddFrameHeightToLayout );
162 } else {
163 tqDebug( "Unknown tag in frame settings" );
164 }
165 }
166 node = node.nextSibling();
167 }
168
169 if( ok ) {
170 settings.resetFrame();
171 KDFrame::deepCopy(*settings._frame, tempFrame);
172
173 settings._dataRow = tempDataRow;
174 settings._dataCol = tempDataCol;
175 settings._data3rd = tempData3rd;
176 settings._outerGapX = tempOuterGapX;
177 settings._outerGapY = tempOuterGapY;
178 settings._innerGapX = tempInnerGapX;
179 settings._innerGapY = tempInnerGapY;
180 settings._addFrameWidthToLayout = tempAddFrameWidthToLayout;
181 settings._addFrameHeightToLayout = tempAddFrameHeightToLayout;
182 areaId = tempId;
183 }
184
185 return ok;
186}
187
188
189
195
196
202
208
214
220
231
232
243
244
245
256 TQDomNode& parent,
257 const TQString& elementName,
259 uint areaId )
260{
261 TQDomElement frameSettingsElement = document.createElement( elementName );
262 parent.appendChild( frameSettingsElement );
263 if( settings->_frame )
264 KDFrame::createFrameNode( document, frameSettingsElement, "Frame",
265 *settings->_frame );
266 KDXML::createIntNode( document, frameSettingsElement, "AreaId",
267 areaId );
268 KDXML::createIntNode( document, frameSettingsElement, "DataRow",
269 settings->_dataRow );
270 KDXML::createIntNode( document, frameSettingsElement, "DataCol",
271 settings->_dataCol );
272 KDXML::createIntNode( document, frameSettingsElement, "Data3rd",
273 settings->_data3rd );
274 KDXML::createIntNode( document, frameSettingsElement, "OuterGapX",
275 settings->_outerGapX );
276 KDXML::createIntNode( document, frameSettingsElement, "OuterGapY",
277 settings->_outerGapY );
278 KDXML::createIntNode( document, frameSettingsElement, "InnerGapX",
279 settings->_innerGapX );
280 KDXML::createIntNode( document, frameSettingsElement, "InnerGapY",
281 settings->_innerGapY );
282 KDXML::createBoolNode( document, frameSettingsElement,
283 "AddFrameWidthToLayout",
284 settings->_addFrameWidthToLayout );
285 KDXML::createBoolNode( document, frameSettingsElement,
286 "AddFrameHeightToLayout",
287 settings->_addFrameHeightToLayout );
288}
Header for all common chart parameters.
Stores the frame settings for one of the chart areas:
int innerGapX() const
Return the X-distance between the frame and the inner area.
static bool readFrameSettingsNode(const TQDomElement &element, KDChartFrameSettings &settings, uint &areaId)
Reads data from a DOM element node that represents a frame settings object and fills a KDChartFrameSe...
int outerGapX() const
Return the X-distance between the frame and the surrounding parts of the chart.
int outerGapY() const
Return the Y-distance between the frame and the surrounding parts of the chart.
const KDFrame & frame() const
Return the KDFrame object used for drawing this areas frame.
static void createFrameSettingsNode(TQDomDocument &document, TQDomNode &parent, const TQString &elementName, const KDChartFrameSettings *settings, uint areaId)
Creates a DOM element node that represents a frame settings object for use in a DOM document.
int innerGapY() const
Return the Y-distance between the frame and the inner area.
bool addFrameHeightToLayout() const
Return whether the inner area will shrink the area AND its frame will occupy the same space of the ch...
bool addFrameWidthToLayout() const
Return whether the inner area will shrink the area AND its frame will occupy the same space of the ch...
The main class of KDFrame.
Definition KDFrame.h:88
static void createFrameNode(TQDomDocument &document, TQDomNode &parent, const TQString &elementName, const KDFrame &frame)
Creates a DOM element node that represents a frame for use in a DOM document.
Definition KDFrame.cpp:407
static bool readFrameNode(const TQDomElement &element, KDFrame &frame)
Reads data from a DOM element node that represents a frame object and fills a KDFrame object with the...
Definition KDFrame.cpp:475