1 /*
2  * Copyright (C) 2001-2015 Klaralvdalens Datakonsult AB.  All rights reserved.
3  *
4  * This file is part of the KD Chart library.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef KCHARTRULERATTRIBUTES_H
21 #define KCHARTRULERATTRIBUTES_H
22 
23 #include <QMetaType>
24 #include "KChartGlobal.h"
25 #include "KChartEnums.h"
26 
27 QT_BEGIN_NAMESPACE
28 class QPen;
29 QT_END_NAMESPACE
30 
31 namespace KChart {
32 
33 /**
34   * @brief A set of attributes controlling the appearance of axis rulers
35   */
36 class KCHART_EXPORT RulerAttributes
37 {
38 public:
39 	RulerAttributes();
40 	RulerAttributes( const RulerAttributes& );
41 	RulerAttributes &operator= ( const RulerAttributes& );
42 
43     ~RulerAttributes();
44 
45     /**
46       * Sets the pen used to draw the tick marks
47       */
48     void setTickMarkPen( const QPen& pen );
49     QPen tickMarkPen() const;
50 
51     /**
52       * Sets the pen used to draw major tick marks
53       */
54     void setMajorTickMarkPen( const QPen& pen );
55     bool majorTickMarkPenIsSet() const;
56     QPen majorTickMarkPen() const;
57 
58     /**
59       * Sets the pen used to draw minor tick marks
60       */
61     void setMinorTickMarkPen( const QPen& pen );
62     bool minorTickMarkPenIsSet() const;
63     QPen minorTickMarkPen() const;
64 
65     /**
66       * Sets the pen used to draw the tick mark at a specific value
67       *
68       * Note: This will not paint a tick mark at the specified value
69       * if it wasn't already drawn before.
70       */
71     void setTickMarkPen( qreal value, const QPen& pen );
72     QPen tickMarkPen( qreal value ) const;
73     typedef QMap<qreal, QPen> TickMarkerPensMap;
74     TickMarkerPensMap tickMarkPens() const;
75 
76     bool hasTickMarkPenAt( qreal value) const;
77 
78     /**
79       * Color setter method provided for convenience
80       */
81     void setTickMarkColor( const QColor& color );
82     QColor tickMarkColor() const;
83 
84     /**
85       * Shows or hides minor tick marks
86       */
87     void setShowMinorTickMarks( bool show );
88     bool showMinorTickMarks() const;
89 
90     /**
91      * Set the ruler line pen to @p pen
92      */
93     void setRulerLinePen(const QPen &pen);
94     /** @return the ruler line pen
95      */
96     QPen rulerLinePen() const;
97 
98     void setShowRulerLine( bool show );
99     bool showRulerLine() const;
100 
101     /**
102       * Shows or hides major tick marks
103       */
104     void setShowMajorTickMarks( bool show );
105     bool showMajorTickMarks() const;
106 
107     /**
108      * Sets the length of major tick marks
109      */
110     void setMajorTickMarkLength( int length );
111     int majorTickMarkLength() const;
112     bool majorTickMarkLengthIsSet() const;
113 
114     /**
115      * Sets the length of minor tick marks
116      */
117     void setMinorTickMarkLength( int length );
118     int minorTickMarkLength() const;
119     bool minorTickMarkLengthIsSet() const;
120 
121     /**
122      * Set margin that should be used between the labels and the ticks. By
123      * default the value is -1, which means that half of the label's font
124      * height/width should be used as margin.
125      */
126     void setLabelMargin(int margin);
127     int labelMargin() const;
128 
129     /**
130      * Shows or hides the first tick. This is usually where the axes cross.
131      * The tick itself may be obscured by the other axis, but the label will be visible.
132      */
133     void setShowFirstTick( bool show );
134     bool showFirstTick() const;
135 
136     bool operator==( const RulerAttributes& ) const;
137     inline bool operator!=( const RulerAttributes& other ) const { return !operator==(other); }
138 
139 private:
140     KCHART_DECLARE_PRIVATE_BASE_VALUE( RulerAttributes )
141 }; // End of class RulerAttributes
142 
143 }
144 
145 #if !defined(QT_NO_DEBUG_STREAM)
146 KCHART_EXPORT QDebug operator<<(QDebug, const KChart::RulerAttributes& );
147 #endif /* QT_NO_DEBUG_STREAM */
148 
149 KCHART_DECLARE_SWAP_SPECIALISATION( KChart::RulerAttributes )
150 
151 QT_BEGIN_NAMESPACE
152 Q_DECLARE_TYPEINFO( KChart::RulerAttributes, Q_MOVABLE_TYPE );
153 QT_END_NAMESPACE
154 
155 Q_DECLARE_METATYPE( KChart::RulerAttributes )
156 
157 #endif // KCHARTRULERATTRIBUTES_H
158