1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
|
/* -*- Mode: C++ -*-
KDChart - a multi-platform charting engine
*/
/****************************************************************************
** Copyright (C) 2001-2003 Klarälvdalens Datakonsult AB. All rights reserved.
**
** This file is part of the KDChart library.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** Licensees holding valid commercial KDChart licenses may use this file in
** accordance with the KDChart Commercial License Agreement provided with
** the Software.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.klaralvdalens-datakonsult.se/?page=products for
** information about KDChart Commercial License Agreements.
**
** Contact [email protected] if any conditions of this
** licensing are not clear to you.
**
**********************************************************************/
#ifndef __KDFRAMEPROFILESECTION__
#define __KDFRAMEPROFILESECTION__
#include <tqregion.h>
#include <tqpen.h>
#include <tqdom.h>
#include "KDChartGlobal.h"
/**
Settings for one profile section of one side of the frame.
*/
class KDCHART_EXPORT KDFrameProfileSection
{
public:
/**
Profile Direction Mode: specifying whether a part of a profile looks embossed or
engraved in comparison to the next outer part (or to the surrounding area, resp.).
\li \c DirPlain the part of the profile is neither embossed nor engraved.
\li \c DirRaising the part of the profile lookes embossed from the outer part.
\li \c DirSinking the part of the profile lookes engraved into the outer part.
\Note Since a frame border may consist of several parts you must specify the
direction mode for each of these parts. This is quite different from the
TQFrame::Shadow / TQFrame::Shape schema where you would select a predefined
profile. KDFrame lets you specify both the number of sections used
to compose frame border's profile and the look of each individual
section by calling \c addProfileSection() multiple times.
Some commonly used profiles are allready pre-defined for your convenience,
\c setSimpleProfile is used to select one of them, see \c setProfile
for an example how to do this.
\sa addProfileSection, setProfile, setSimpleProfile, SimpleProfile
*/
enum Direction { DirPlain, DirRaising, DirSinking };
/**
Converts the specified direction enum to a string representation.
\param dir the direction enum to convert
\return the string representation of the direction enum
*/
static TQString directionToString( Direction dir ) {
switch( dir ) {
case DirPlain:
return "Plain";
case DirRaising:
return "Raising";
case DirSinking:
return "Sinking";
default: // should not happen
return "Plain";
}
}
/**
Converts the specified string to a direction enum value.
\param string the string to convert
\return the direction enum value
*/
static Direction stringToDirection( const TQString& string ) {
if( string == "Plain" )
return DirPlain;
else if( string == "Raising" )
return DirRaising;
else if( string == "Sinking" )
return DirSinking;
else // default, should not happen
return DirPlain;
}
/**
Profile Curvature Mode: specifying the tqshape of a frame profile section.
(curvature setting will be ignored for \c DirPlain profiles)
\li \c CvtFlat looking like a evenly sloping surface.
\li \c CvtConvex looking like quarter of a torus.
\li \c CvtConcave looking like half of a groove.
*/
enum Curvature { CvtPlain, CvtConvex, CvtConcave };
/**
Converts the specified curvature enum to a string representation.
\param curv the curvature enum to convert
\return the string representation of the curvature enum
*/
static TQString curvatureToString( Curvature curv ) {
switch( curv ) {
case CvtPlain:
return "Plain";
case CvtConvex:
return "Convex";
case CvtConcave:
return "Concave";
default: // should not happen
return "Plain";
}
}
/**
Converts the specified string to a curvature enum value.
\param string the string to convert
\return the curvature enum value
*/
static Curvature stringToCurvature( const TQString& string ) {
if( string == "Plain" )
return CvtPlain;
else if( string == "Convex" )
return CvtConvex;
else if( string == "Concave" )
return CvtConcave;
else // default, should not happen
return CvtPlain;
}
/**
Ctor of KDFrameProfileSection.
\Note Instead of instantiating KDFrameProfileSection yourself
you would normally rather call \c KDFrame::addProfileSection()
*/
KDFrameProfileSection( Direction direction,
Curvature curvature,
int width,
TQPen pen )
: _direction( direction ),
_curvature( curvature ),
_width( width ),
_pen( pen ) {}
/**
Default ctor of FrameProfileSection.
\Note Instead of instantiating KDFrameProfileSection yourself,
you would normally rather call \c KDFrame::addProfileSection()
*/
KDFrameProfileSection() {
_direction = DirPlain;
_curvature = CvtPlain;
_width = 1;
_pen = TQPen( TQt::SolidLine );
}
/**
Destructor. Only defined to have it virtual.
*/
virtual ~KDFrameProfileSection();
/**
Creates a DOM element node that represents a frame profile
section for use in a DOM document.
\param document the DOM document to which the node will belong
\param parent the parent node to which the new node will be appended
\param elementName the name of the new node
\param section the section to be represented
*/
static void createFrameProfileSectionNode( TQDomDocument& document,
TQDomNode& parent,
const TQString& elementName,
const KDFrameProfileSection* section );
/**
Reads data from a DOM element node that represents a frame
profile section and fills a KDFrameProfileSection object with
the data.
\param element the DOM element to read from
\param section a pointer to the frame profile section object to
read the data into
*/
static bool readFrameProfileSectionNode( const TQDomElement& element,
KDFrameProfileSection* section );
Direction direction() const { return _direction; }
Curvature curvature() const { return _curvature; }
int width() const { return _width; }
TQPen pen() const { return _pen; }
private:
Direction _direction;
Curvature _curvature;
int _width;
TQPen _pen;
};
/**
Settings for all the profile sections of one side the frame.
\sa setProfile, profile
*/
typedef TQPtrList < KDFrameProfileSection > KDFrameProfile;
#endif
|