summaryrefslogtreecommitdiffstats
path: root/libkdchart/KDChartEnums.cpp
blob: 3f43e0b117859f168fe16c3e5a82fafcc1e2d554 (plain)
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
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include "KDChartEnums.h"

TQString KDChartEnums::positionFlagToString( PositionFlag type )
{
    switch( type ) {
    case PosTopLeft:
        return "TopLeft";
    case PosTopCenter:
        return "TopCenter";
    case PosTopRight:
        return "TopRight";
    case PosCenterLeft:
        return "CenterLeft";
    case PosCenter:
        return "Center";
    case PosCenterRight:
        return "CenterRight";
    case PosBottomLeft:
        return "BottomLeft";
    case PosBottomCenter:
        return "BottomCenter";
    case PosBottomRight:
        return "BottomRight";
    default: // should not happen
        tqDebug( "Unknown content position" );
        return "TopLeft";
    }
}

KDChartEnums::PositionFlag KDChartEnums::stringToPositionFlag( const TQString& string )
{
    if( string ==      "TopLeft" )
        return PosTopLeft;
    else if( string == "TopCenter" )
        return PosTopCenter;
    else if( string == "TopRight" )
        return PosTopRight;
    else if( string == "CenterLeft" )
        return PosCenterLeft;
    else if( string == "Center" )
        return PosCenter;
    else if( string == "CenterRight" )
        return PosCenterRight;
    else if( string == "BottomLeft" )
        return PosBottomLeft;
    else if( string == "BottomCenter" )
        return PosBottomCenter;
    else if( string == "BottomRight" )
        return PosBottomRight;
    else // default, should not happen
        return PosTopLeft;
}

TQPoint KDChartEnums::positionFlagToPoint( const TQRect& rect,
                                          PositionFlag pos )
{
    TQPoint pt;
    if( rect.isValid() ) {
        switch( pos ) {
        case KDChartEnums::PosTopLeft:
            pt = rect.topLeft();
            break;
        case KDChartEnums::PosTopCenter:
            pt.setY( rect.top() );
            pt.setX( rect.center().x() );
            break;
        case KDChartEnums::PosTopRight:
            pt = rect.topRight();
            break;
        case KDChartEnums::PosCenterLeft:
            pt.setY( rect.center().y() );
            pt.setX( rect.left() );
            break;
        case KDChartEnums::PosCenter:
            pt = rect.center();
            break;
        case KDChartEnums::PosCenterRight:
            pt.setY( rect.center().y() );
            pt.setX( rect.right() );
            break;
        case KDChartEnums::PosBottomLeft:
            pt = rect.bottomLeft();
            break;
        case KDChartEnums::PosBottomCenter:
            pt.setY( rect.bottom() );
            pt.setX( rect.center().x() );
            break;
        case KDChartEnums::PosBottomRight:
            pt = rect.bottomRight();
            break;
        }
    }
    return pt;
}

#ifndef KDCHART_MASTER_CVS
#include "KDChartEnums.moc"
#endif