##// END OF EJS Templates
Added axis related modifiers to theme
Tero Ahola -
r548:426b0f7a9c96
parent child
Show More
@@ -197,16 +197,6 void ChartTheme::decorate(PiePresenter* item, QPieSeries* series, int index)
197 }
197 }
198 }
198 }
199
199
200
201 void ChartTheme::decorate(QChartAxis* axis, AxisItem* item)
202 {
203 //TODO: dummy defults for now
204 axis->setLabelsBrush(Qt::black);
205 axis->setLabelsPen(Qt::NoPen);
206 axis->setShadesPen(Qt::NoPen);
207 axis->setShadesOpacity(0.5);
208 }
209
210 void ChartTheme::decorate(SplineChartItem* item, QSplineSeries* series, int index)
200 void ChartTheme::decorate(SplineChartItem* item, QSplineSeries* series, int index)
211 {
201 {
212 Q_ASSERT(item);
202 Q_ASSERT(item);
@@ -234,6 +224,31 void ChartTheme::decorate(SplineChartItem* item, QSplineSeries* series, int inde
234 // presenter->m_markerPen = pen;
224 // presenter->m_markerPen = pen;
235 }
225 }
236
226
227 void ChartTheme::decorate(QChartAxis* axis, AxisItem* item)
228 {
229 Q_ASSERT(axis);
230 Q_ASSERT(item);
231
232 if (axis->isAxisVisible()) {
233 axis->setLabelsBrush(m_axisLabelBrush);
234 axis->setLabelsPen(m_axisLabelPen);
235 // TODO: check the axis type (x or y) should define whether to show the shades or not
236 if (m_backgroundShades == BackgroundShadesBoth
237 || m_backgroundShades == BackgroundShadesVertical /*&& x axis ?*/
238 || m_backgroundShades == BackgroundShadesHorizontal /* && y axis*/) {
239 axis->setShadesPen(m_backgroundShadesPen);
240 axis->setShadesBrush(m_backgroundShadesBrush);
241 } else {
242 // The shades not supposed to be shown for this axis, clear possible brush and pen
243 axis->setShadesPen(Qt::NoPen);
244 axis->setShadesBrush(Qt::NoBrush);
245 }
246 axis->setAxisPen(m_axisLinePen);
247 axis->setGridLinePen(m_gridLinePen);
248 axis->setLabelsFont(m_masterFont);
249 }
250 }
251
237 void ChartTheme::generateSeriesGradients()
252 void ChartTheme::generateSeriesGradients()
238 {
253 {
239 // Generate gradients in HSV color space
254 // Generate gradients in HSV color space
@@ -29,6 +29,14 class QAreaSeries;
29
29
30 class ChartTheme
30 class ChartTheme
31 {
31 {
32 public:
33 enum BackgroundShadesMode {
34 BackgroundShadesNone = 0,
35 BackgroundShadesVertical,
36 BackgroundShadesHorizontal,
37 BackgroundShadesBoth
38 };
39
32 protected:
40 protected:
33 explicit ChartTheme(QChart::ChartTheme id = QChart::ChartThemeDefault);
41 explicit ChartTheme(QChart::ChartTheme id = QChart::ChartThemeDefault);
34 public:
42 public:
@@ -44,8 +52,8 public:
44 void decorate(AreaChartItem* item, QAreaSeries* series, int index);
52 void decorate(AreaChartItem* item, QAreaSeries* series, int index);
45 void decorate(ScatterChartItem* presenter, QScatterSeries* series, int index);
53 void decorate(ScatterChartItem* presenter, QScatterSeries* series, int index);
46 void decorate(PiePresenter* item, QPieSeries* series, int index);
54 void decorate(PiePresenter* item, QPieSeries* series, int index);
47 void decorate(QChartAxis* axis,AxisItem* item);
48 void decorate(SplineChartItem* presenter, QSplineSeries* series, int index);
55 void decorate(SplineChartItem* presenter, QSplineSeries* series, int index);
56 void decorate(QChartAxis* axis, AxisItem* item);
49
57
50 public: // utils
58 public: // utils
51 void generateSeriesGradients();
59 void generateSeriesGradients();
@@ -58,13 +66,14 protected:
58 QList<QGradient> m_seriesGradients;
66 QList<QGradient> m_seriesGradients;
59 QLinearGradient m_backgroundGradient;
67 QLinearGradient m_backgroundGradient;
60
68
61 // TODO: Add something like the following to themes:
69 QFont m_masterFont;
62 // QPen axisLinePen;
70 QPen m_axisLinePen;
63 // QPen backgroundHorizontalGridPen;
71 QBrush m_axisLabelBrush;
64 // QPen backgroundVerticalGridPen;
72 QPen m_axisLabelPen;
65 // // FillAll, FillEverySecondRow, FillEverySecondColumn, FillEverySecondRowAndColumn, FillNone
73 QPen m_backgroundShadesPen;
66 // int backgroundType;
74 QBrush m_backgroundShadesBrush;
67 // QFont masterFont;
75 BackgroundShadesMode m_backgroundShades;
76 QPen m_gridLinePen;
68 };
77 };
69
78
70 QTCOMMERCIALCHART_END_NAMESPACE
79 QTCOMMERCIALCHART_END_NAMESPACE
@@ -12,17 +12,27 public:
12 ChartThemeDefault():ChartTheme(QChart::ChartThemeDefault)
12 ChartThemeDefault():ChartTheme(QChart::ChartThemeDefault)
13 {
13 {
14 #ifdef Q_OS_WIN
14 #ifdef Q_OS_WIN
15 // First series base color from COLOR_WINDOWFRAME
15 // TODO: use theme specific window frame color as a series base color (it would give more
16 DWORD colorWindowFrame;
16 // variation to the base colors in addition to the blue and black used now)
17 colorWindowFrame = GetSysColor(COLOR_WINDOWFRAME);
17 // TODO: COLOR_WINDOWTEXT for text color?
18 m_seriesColors.append(QColor(GetRValue(colorWindowFrame), GetGValue(colorWindowFrame),GetBValue(colorWindowFrame)));
18 // TODO: COLOR_INFOTEXT for tooltip text color?
19 // TODO: COLOR_INFOBK for tooltip background color?
19
20
20 // Second series base color from COLOR_HIGHLIGHT
21 // First series base color from COLOR_HIGHLIGHT
21 DWORD colorHighlight;
22 DWORD colorHighlight;
22 colorHighlight = GetSysColor(COLOR_HIGHLIGHT);
23 colorHighlight = GetSysColor(COLOR_HIGHLIGHT);
23 m_seriesColors.append(QColor(GetRValue(colorHighlight), GetGValue(colorHighlight),GetBValue(colorHighlight)));
24 m_seriesColors.append(QColor(GetRValue(colorHighlight),
25 GetGValue(colorHighlight),
26 GetBValue(colorHighlight)));
27
28 // Second series base color from COLOR_WINDOWFRAME
29 DWORD colorWindowFrame;
30 colorWindowFrame = GetSysColor(COLOR_WINDOWFRAME);
31 m_seriesColors.append(QColor(GetRValue(colorWindowFrame),
32 GetGValue(colorWindowFrame),
33 GetBValue(colorWindowFrame)));
24
34
25 // Thirs series base color from the middle of the COLOR_ACTIVECAPTION /
35 // Third series base color from the middle of the COLOR_ACTIVECAPTION /
26 // COLOR_GRADIENTACTIVECAPTION gradient
36 // COLOR_GRADIENTACTIVECAPTION gradient
27 DWORD colorGradientActiveCaptionLeft;
37 DWORD colorGradientActiveCaptionLeft;
28 colorGradientActiveCaptionLeft = GetSysColor(COLOR_ACTIVECAPTION);
38 colorGradientActiveCaptionLeft = GetSysColor(COLOR_ACTIVECAPTION);
@@ -52,43 +62,91 public:
52 backgroundGradient.setColorAt(1.0, QColor(GetRValue(colorWindow),
62 backgroundGradient.setColorAt(1.0, QColor(GetRValue(colorWindow),
53 GetGValue(colorWindow),
63 GetGValue(colorWindow),
54 GetBValue(colorWindow)));
64 GetBValue(colorWindow)));
65 // Axes and other
66 m_masterFont = QFont();
67 m_masterFont.setPointSizeF(10.0);
68 m_axisLinePen = QPen(Qt::black);
69 m_axisLinePen.setWidth(2);
70 m_axisLabelBrush = QBrush(Qt::black);
71 m_axisLabelPen = Qt::NoPen; // NoPen for performance reasons
72 m_backgroundShadesPen = Qt::NoPen;
73 m_backgroundShadesBrush = QBrush(QColor(0xaf, 0xaf, 0xaf, 0x50));
74 m_backgroundShades = BackgroundShadesVertical;
55
75
56 // TODO: COLOR_WINDOWTEXT for text color?
57 // TODO: COLOR_INFOTEXT for tooltip text color?
58 // TODO: COLOR_INFOBK for tooltip background color?
59 #elif defined(Q_OS_LINUX)
76 #elif defined(Q_OS_LINUX)
60 // TODO: replace this dummy theme with linux specific theme
77 // TODO: replace this dummy theme with linux specific theme
61 m_seriesColors << QRgb(0xff707070);
78 m_seriesColors << QRgb(0x60a6e6);
62 m_seriesColors << QRgb(0xffA0A0A0);
79 m_seriesColors << QRgb(0x92ca66);
80 m_seriesColors << QRgb(0xeba85f);
81 m_seriesColors << QRgb(0xfc5751);
63 generateSeriesGradients();
82 generateSeriesGradients();
64
83
65 QLinearGradient backgroundGradient;
84 QLinearGradient backgroundGradient;
66 backgroundGradient.setColorAt(0.0, QRgb(0xffffffff));
85 backgroundGradient.setColorAt(0.0, QRgb(0xffffff));
67 backgroundGradient.setColorAt(1.0, QRgb(0xffafafaf));
86 backgroundGradient.setColorAt(1.0, QRgb(0xe9e9e9));
68 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
87 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
69 m_backgroundGradient = backgroundGradient;
88 m_backgroundGradient = backgroundGradient;
70 #elif Q_OS_MAC
89
90 // Axes and other
91 m_masterFont = QFont();
92 m_masterFont.setPointSizeF(10.0);
93 m_axisLinePen = QPen(Qt::black);
94 m_axisLinePen.setWidth(2);
95 m_axisLabelBrush = QBrush(Qt::black);
96 m_axisLabelPen = Qt::NoPen; // NoPen for performance reasons
97 m_backgroundShadesPen = Qt::NoPen;
98 m_backgroundShadesBrush = QBrush(QColor(0xaf, 0xaf, 0xaf, 0x50));
99 m_backgroundShades = BackgroundShadesVertical;
100
101 #elif defined(Q_OS_MAC)
71 // TODO: replace this dummy theme with OSX specific theme
102 // TODO: replace this dummy theme with OSX specific theme
72 m_seriesColors << QRgb(0xff707070);
103 m_seriesColors << QRgb(0x60a6e6);
73 m_seriesColors << QRgb(0xffA0A0A0);
104 m_seriesColors << QRgb(0x92ca66);
105 m_seriesColors << QRgb(0xeba85f);
106 m_seriesColors << QRgb(0xfc5751);
74 generateSeriesGradients();
107 generateSeriesGradients();
75
108
76 QLinearGradient backgroundGradient;
109 QLinearGradient backgroundGradient;
77 backgroundGradient.setColorAt(0.0, QRgb(0xffffffff));
110 backgroundGradient.setColorAt(0.0, QRgb(0xffffff));
78 backgroundGradient.setColorAt(1.0, QRgb(0xffafafaf));
111 backgroundGradient.setColorAt(1.0, QRgb(0xe9e9e9));
79 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
112 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
80 m_backgroundGradient = backgroundGradient;
113 m_backgroundGradient = backgroundGradient;
114
115 // Axes and other
116 m_masterFont = QFont();
117 m_masterFont.setPointSizeF(10.0);
118 m_axisLinePen = QPen(Qt::black);
119 m_axisLinePen.setWidth(2);
120 m_axisLabelBrush = QBrush(Qt::black);
121 m_axisLabelPen = Qt::NoPen; // NoPen for performance reasons
122 m_backgroundShadesPen = Qt::NoPen;
123 m_backgroundShadesBrush = QBrush(QColor(0xaf, 0xaf, 0xaf, 0x50));
124 m_backgroundShades = BackgroundShadesVertical;
125
81 #else
126 #else
82 // TODO: replace this dummy theme with generic (not OS specific) theme
127 // TODO: replace this dummy theme with generic (not OS specific) theme
83 m_seriesColors << QRgb(0xff707070);
128 m_seriesColors << QRgb(0x60a6e6);
84 m_seriesColors << QRgb(0xffA0A0A0);
129 m_seriesColors << QRgb(0x92ca66);
130 m_seriesColors << QRgb(0xeba85f);
131 m_seriesColors << QRgb(0xfc5751);
85 generateSeriesGradients();
132 generateSeriesGradients();
86
133
87 QLinearGradient backgroundGradient;
134 QLinearGradient backgroundGradient;
88 backgroundGradient.setColorAt(0.0, QRgb(0xffffffff));
135 backgroundGradient.setColorAt(0.0, QRgb(0xffffff));
89 backgroundGradient.setColorAt(1.0, QRgb(0xffafafaf));
136 backgroundGradient.setColorAt(1.0, QRgb(0xafafaf));
90 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
137 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
91 m_backgroundGradient = backgroundGradient;
138 m_backgroundGradient = backgroundGradient;
139
140 // Axes and other
141 m_masterFont = QFont();
142 m_masterFont.setPointSizeF(10.0);
143 m_axisLinePen = QPen(Qt::black);
144 m_axisLinePen.setWidth(2);
145 m_axisLabelBrush = QBrush(Qt::black);
146 m_axisLabelPen = Qt::NoPen; // NoPen for performance reasons
147 m_backgroundShadesPen = Qt::NoPen;
148 m_backgroundShadesBrush = QBrush(QColor(0xaf, 0xaf, 0xaf, 0x50));
149 m_backgroundShades = BackgroundShadesVertical;
92 #endif
150 #endif
93 }
151 }
94 };
152 };
@@ -7,18 +7,29 class ChartThemeGrayscale: public ChartTheme
7 public:
7 public:
8 ChartThemeGrayscale():ChartTheme(QChart::ChartThemeGrayscale)
8 ChartThemeGrayscale():ChartTheme(QChart::ChartThemeGrayscale)
9 {
9 {
10 m_seriesColors << QRgb(0xff869299);
10 // Series colors
11 m_seriesColors << QRgb(0xffa5bdcc);
11 m_seriesColors << QRgb(0x869299);
12 m_seriesColors << QRgb(0xffe8fffc);
12 m_seriesColors << QRgb(0xa5bdcc);
13 m_seriesColors << QRgb(0xffccc2c2);
13 m_seriesColors << QRgb(0xe8fffc);
14
14 m_seriesColors << QRgb(0xccc2c2);
15 generateSeriesGradients();
15 generateSeriesGradients();
16
16
17 // Background
17 QLinearGradient backgroundGradient;
18 QLinearGradient backgroundGradient;
18 backgroundGradient.setColorAt(0.0, QRgb(0xffffffff));
19 backgroundGradient.setColorAt(0.0, QRgb(0xffffff));
19 backgroundGradient.setColorAt(1.0, QRgb(0xffe0e3e5));
20 backgroundGradient.setColorAt(1.0, QRgb(0xe0e3e5));
20 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
21 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
21 m_backgroundGradient = backgroundGradient;
22 m_backgroundGradient = backgroundGradient;
23
24 // Axes and other
25 m_masterFont = QFont();
26 m_axisLinePen = QPen(QRgb(0x0f0f0f));
27 m_axisLinePen.setWidth(2);
28 m_axisLabelBrush = QBrush(QRgb(0x3f3f3f));
29 m_axisLabelPen = Qt::NoPen; // NoPen for performance reasons
30 m_backgroundShadesPen = Qt::NoPen;
31 m_gridLinePen = QPen(QRgb(0x0f0f0f));
32 m_gridLinePen.setWidth(2);
22 }
33 }
23 };
34 };
24
35
@@ -7,18 +7,29 class ChartThemeIcy: public ChartTheme
7 public:
7 public:
8 ChartThemeIcy():ChartTheme(QChart::ChartThemeIcy)
8 ChartThemeIcy():ChartTheme(QChart::ChartThemeIcy)
9 {
9 {
10 m_seriesColors << QRgb(0xff0d2673);
10 // Series
11 m_seriesColors << QRgb(0xff2685bf);
11 m_seriesColors << QRgb(0x0d2673);
12 m_seriesColors << QRgb(0xff3dadd9);
12 m_seriesColors << QRgb(0x2685bf);
13 m_seriesColors << QRgb(0xff62c3d9);
13 m_seriesColors << QRgb(0x3dadd9);
14
14 m_seriesColors << QRgb(0x62c3d9);
15 generateSeriesGradients();
15 generateSeriesGradients();
16
16
17 // Background
17 QLinearGradient backgroundGradient;
18 QLinearGradient backgroundGradient;
18 backgroundGradient.setColorAt(0.0, QRgb(0xffebebeb));
19 backgroundGradient.setColorAt(0.0, QRgb(0xebebeb));
19 backgroundGradient.setColorAt(1.0, QRgb(0xfff8f9fb));
20 backgroundGradient.setColorAt(1.0, QRgb(0xf8f9fb));
20 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
21 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
21 m_backgroundGradient = backgroundGradient;
22 m_backgroundGradient = backgroundGradient;
23
24 // Axes and other
25 m_masterFont = QFont();
26 m_axisLinePen = QPen(QRgb(0x0f0f0f));
27 m_axisLinePen.setWidth(2);
28 m_axisLabelBrush = QBrush(QRgb(0x3f3f3f));
29 m_axisLabelPen = Qt::NoPen; // NoPen for performance reasons
30 m_backgroundShadesPen = Qt::NoPen;
31 m_gridLinePen = QPen(QRgb(0x0f0f0f));
32 m_gridLinePen.setWidth(2);
22 }
33 }
23 };
34 };
24
35
@@ -7,18 +7,29 class ChartThemeScientific: public ChartTheme
7 public:
7 public:
8 ChartThemeScientific():ChartTheme(QChart::ChartThemeScientific)
8 ChartThemeScientific():ChartTheme(QChart::ChartThemeScientific)
9 {
9 {
10 m_seriesColors << QRgb(0xFFFFAD00);
10 // Series
11 m_seriesColors << QRgb(0xFF596A75);
11 m_seriesColors << QRgb(0xFFAD00);
12 m_seriesColors << QRgb(0xFF202020);
12 m_seriesColors << QRgb(0x596A75);
13 m_seriesColors << QRgb(0xFF474747);
13 m_seriesColors << QRgb(0x202020);
14
14 m_seriesColors << QRgb(0x474747);
15 generateSeriesGradients();
15 generateSeriesGradients();
16
16
17 // Background
17 QLinearGradient backgroundGradient;
18 QLinearGradient backgroundGradient;
18 backgroundGradient.setColorAt(0.0, QRgb(0xfffffefc));
19 backgroundGradient.setColorAt(0.0, QRgb(0xfffefc));
19 backgroundGradient.setColorAt(1.0, QRgb(0xfffffefc));
20 backgroundGradient.setColorAt(1.0, QRgb(0xfffefc));
20 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
21 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
21 m_backgroundGradient = backgroundGradient;
22 m_backgroundGradient = backgroundGradient;
23
24 // Axes and other
25 m_masterFont = QFont();
26 m_axisLinePen = QPen(QRgb(0x0f0f0f));
27 m_axisLinePen.setWidth(2);
28 m_axisLabelBrush = QBrush(QRgb(0x3f3f3f));
29 m_axisLabelPen = Qt::NoPen; // NoPen for performance reasons
30 m_backgroundShadesPen = Qt::NoPen;
31 m_gridLinePen = QPen(QRgb(0x0f0f0f));
32 m_gridLinePen.setWidth(2);
22 }
33 }
23 };
34 };
24
35
@@ -7,19 +7,30 class ChartThemeVanilla: public ChartTheme
7 public:
7 public:
8 ChartThemeVanilla():ChartTheme(QChart::ChartThemeVanilla)
8 ChartThemeVanilla():ChartTheme(QChart::ChartThemeVanilla)
9 {
9 {
10 m_seriesColors << QRgb(0xffd9c574);
10 // Series
11 m_seriesColors << QRgb(0xffd6a896);
11 m_seriesColors << QRgb(0xd9c574);
12 m_seriesColors << QRgb(0xffa0a071);
12 m_seriesColors << QRgb(0xd6a896);
13 m_seriesColors << QRgb(0xffd2d234);
13 m_seriesColors << QRgb(0xa0a071);
14 m_seriesColors << QRgb(0xff88723a);
14 m_seriesColors << QRgb(0xd2d234);
15
15 m_seriesColors << QRgb(0x88723a);
16 generateSeriesGradients();
16 generateSeriesGradients();
17
17
18 // Background
18 QLinearGradient backgroundGradient;
19 QLinearGradient backgroundGradient;
19 backgroundGradient.setColorAt(0.0, QRgb(0xfffbf9f1));
20 backgroundGradient.setColorAt(0.0, QRgb(0xfbf9f1));
20 backgroundGradient.setColorAt(1.0, QRgb(0xfff5f0dc));
21 backgroundGradient.setColorAt(1.0, QRgb(0xf5f0dc));
21 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
22 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
22 m_backgroundGradient = backgroundGradient;
23 m_backgroundGradient = backgroundGradient;
24
25 // Axes and other
26 m_masterFont = QFont();
27 m_axisLinePen = QPen(QRgb(0x0f0f0f));
28 m_axisLinePen.setWidth(2);
29 m_axisLabelBrush = QBrush(QRgb(0xa0a071));
30 m_axisLabelPen = Qt::NoPen; // NoPen for performance reasons
31 m_backgroundShadesPen = Qt::NoPen;
32 m_gridLinePen = QPen(QRgb(0x0f0f0f));
33 m_gridLinePen.setWidth(2);
23 }
34 }
24 };
35 };
25
36
General Comments 0
You need to be logged in to leave comments. Login now