kchart

KDChartEnums.cpp
1#include "KDChartEnums.h"
2
4{
5 switch( type ) {
6 case PosTopLeft:
7 return "TopLeft";
8 case PosTopCenter:
9 return "TopCenter";
10 case PosTopRight:
11 return "TopRight";
12 case PosCenterLeft:
13 return "CenterLeft";
14 case PosCenter:
15 return "Center";
16 case PosCenterRight:
17 return "CenterRight";
18 case PosBottomLeft:
19 return "BottomLeft";
20 case PosBottomCenter:
21 return "BottomCenter";
22 case PosBottomRight:
23 return "BottomRight";
24 default: // should not happen
25 tqDebug( "Unknown content position" );
26 return "TopLeft";
27 }
28}
29
31{
32 if( string == "TopLeft" )
33 return PosTopLeft;
34 else if( string == "TopCenter" )
35 return PosTopCenter;
36 else if( string == "TopRight" )
37 return PosTopRight;
38 else if( string == "CenterLeft" )
39 return PosCenterLeft;
40 else if( string == "Center" )
41 return PosCenter;
42 else if( string == "CenterRight" )
43 return PosCenterRight;
44 else if( string == "BottomLeft" )
45 return PosBottomLeft;
46 else if( string == "BottomCenter" )
47 return PosBottomCenter;
48 else if( string == "BottomRight" )
49 return PosBottomRight;
50 else // default, should not happen
51 return PosTopLeft;
52}
53
54TQPoint KDChartEnums::positionFlagToPoint( const TQRect& rect,
55 PositionFlag pos )
56{
57 TQPoint pt;
58 if( rect.isValid() ) {
59 switch( pos ) {
60 case KDChartEnums::PosTopLeft:
61 pt = rect.topLeft();
62 break;
63 case KDChartEnums::PosTopCenter:
64 pt.setY( rect.top() );
65 pt.setX( rect.center().x() );
66 break;
67 case KDChartEnums::PosTopRight:
68 pt = rect.topRight();
69 break;
70 case KDChartEnums::PosCenterLeft:
71 pt.setY( rect.center().y() );
72 pt.setX( rect.left() );
73 break;
74 case KDChartEnums::PosCenter:
75 pt = rect.center();
76 break;
77 case KDChartEnums::PosCenterRight:
78 pt.setY( rect.center().y() );
79 pt.setX( rect.right() );
80 break;
81 case KDChartEnums::PosBottomLeft:
82 pt = rect.bottomLeft();
83 break;
84 case KDChartEnums::PosBottomCenter:
85 pt.setY( rect.bottom() );
86 pt.setX( rect.center().x() );
87 break;
88 case KDChartEnums::PosBottomRight:
89 pt = rect.bottomRight();
90 break;
91 }
92 }
93 return pt;
94}
95
96#ifndef KDCHART_MASTER_CVS
97#include "KDChartEnums.moc"
98#endif
Definition of global enums.
static PositionFlag stringToPositionFlag(const TQString &string)
Converts the specified string to a content position enum value.
static TQPoint positionFlagToPoint(const TQRect &rect, PositionFlag pos)
Returns the point representing a position of a rectangle.
PositionFlag
The general position flag to specify a point of an area, for example this could be the anchor point w...
static TQString positionFlagToString(PositionFlag type)
Converts the specified content position enum to a string representation.