##// 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 200 void ChartTheme::decorate(SplineChartItem* item, QSplineSeries* series, int index)
211 201 {
212 202 Q_ASSERT(item);
@@ -234,6 +224,31 void ChartTheme::decorate(SplineChartItem* item, QSplineSeries* series, int inde
234 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 252 void ChartTheme::generateSeriesGradients()
238 253 {
239 254 // Generate gradients in HSV color space
@@ -29,6 +29,14 class QAreaSeries;
29 29
30 30 class ChartTheme
31 31 {
32 public:
33 enum BackgroundShadesMode {
34 BackgroundShadesNone = 0,
35 BackgroundShadesVertical,
36 BackgroundShadesHorizontal,
37 BackgroundShadesBoth
38 };
39
32 40 protected:
33 41 explicit ChartTheme(QChart::ChartTheme id = QChart::ChartThemeDefault);
34 42 public:
@@ -44,8 +52,8 public:
44 52 void decorate(AreaChartItem* item, QAreaSeries* series, int index);
45 53 void decorate(ScatterChartItem* presenter, QScatterSeries* series, int index);
46 54 void decorate(PiePresenter* item, QPieSeries* series, int index);
47 void decorate(QChartAxis* axis,AxisItem* item);
48 55 void decorate(SplineChartItem* presenter, QSplineSeries* series, int index);
56 void decorate(QChartAxis* axis, AxisItem* item);
49 57
50 58 public: // utils
51 59 void generateSeriesGradients();
@@ -58,13 +66,14 protected:
58 66 QList<QGradient> m_seriesGradients;
59 67 QLinearGradient m_backgroundGradient;
60 68
61 // TODO: Add something like the following to themes:
62 // QPen axisLinePen;
63 // QPen backgroundHorizontalGridPen;
64 // QPen backgroundVerticalGridPen;
65 // // FillAll, FillEverySecondRow, FillEverySecondColumn, FillEverySecondRowAndColumn, FillNone
66 // int backgroundType;
67 // QFont masterFont;
69 QFont m_masterFont;
70 QPen m_axisLinePen;
71 QBrush m_axisLabelBrush;
72 QPen m_axisLabelPen;
73 QPen m_backgroundShadesPen;
74 QBrush m_backgroundShadesBrush;
75 BackgroundShadesMode m_backgroundShades;
76 QPen m_gridLinePen;
68 77 };
69 78
70 79 QTCOMMERCIALCHART_END_NAMESPACE
@@ -12,17 +12,27 public:
12 12 ChartThemeDefault():ChartTheme(QChart::ChartThemeDefault)
13 13 {
14 14 #ifdef Q_OS_WIN
15 // First series base color from COLOR_WINDOWFRAME
16 DWORD colorWindowFrame;
17 colorWindowFrame = GetSysColor(COLOR_WINDOWFRAME);
18 m_seriesColors.append(QColor(GetRValue(colorWindowFrame), GetGValue(colorWindowFrame),GetBValue(colorWindowFrame)));
15 // TODO: use theme specific window frame color as a series base color (it would give more
16 // variation to the base colors in addition to the blue and black used now)
17 // TODO: COLOR_WINDOWTEXT for text color?
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 22 DWORD colorHighlight;
22 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 36 // COLOR_GRADIENTACTIVECAPTION gradient
27 37 DWORD colorGradientActiveCaptionLeft;
28 38 colorGradientActiveCaptionLeft = GetSysColor(COLOR_ACTIVECAPTION);
@@ -52,43 +62,91 public:
52 62 backgroundGradient.setColorAt(1.0, QColor(GetRValue(colorWindow),
53 63 GetGValue(colorWindow),
54 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 76 #elif defined(Q_OS_LINUX)
60 77 // TODO: replace this dummy theme with linux specific theme
61 m_seriesColors << QRgb(0xff707070);
62 m_seriesColors << QRgb(0xffA0A0A0);
78 m_seriesColors << QRgb(0x60a6e6);
79 m_seriesColors << QRgb(0x92ca66);
80 m_seriesColors << QRgb(0xeba85f);
81 m_seriesColors << QRgb(0xfc5751);
63 82 generateSeriesGradients();
64 83
65 84 QLinearGradient backgroundGradient;
66 backgroundGradient.setColorAt(0.0, QRgb(0xffffffff));
67 backgroundGradient.setColorAt(1.0, QRgb(0xffafafaf));
85 backgroundGradient.setColorAt(0.0, QRgb(0xffffff));
86 backgroundGradient.setColorAt(1.0, QRgb(0xe9e9e9));
68 87 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
69 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 102 // TODO: replace this dummy theme with OSX specific theme
72 m_seriesColors << QRgb(0xff707070);
73 m_seriesColors << QRgb(0xffA0A0A0);
103 m_seriesColors << QRgb(0x60a6e6);
104 m_seriesColors << QRgb(0x92ca66);
105 m_seriesColors << QRgb(0xeba85f);
106 m_seriesColors << QRgb(0xfc5751);
74 107 generateSeriesGradients();
75 108
76 109 QLinearGradient backgroundGradient;
77 backgroundGradient.setColorAt(0.0, QRgb(0xffffffff));
78 backgroundGradient.setColorAt(1.0, QRgb(0xffafafaf));
110 backgroundGradient.setColorAt(0.0, QRgb(0xffffff));
111 backgroundGradient.setColorAt(1.0, QRgb(0xe9e9e9));
79 112 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
80 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 126 #else
82 127 // TODO: replace this dummy theme with generic (not OS specific) theme
83 m_seriesColors << QRgb(0xff707070);
84 m_seriesColors << QRgb(0xffA0A0A0);
128 m_seriesColors << QRgb(0x60a6e6);
129 m_seriesColors << QRgb(0x92ca66);
130 m_seriesColors << QRgb(0xeba85f);
131 m_seriesColors << QRgb(0xfc5751);
85 132 generateSeriesGradients();
86 133
87 134 QLinearGradient backgroundGradient;
88 backgroundGradient.setColorAt(0.0, QRgb(0xffffffff));
89 backgroundGradient.setColorAt(1.0, QRgb(0xffafafaf));
135 backgroundGradient.setColorAt(0.0, QRgb(0xffffff));
136 backgroundGradient.setColorAt(1.0, QRgb(0xafafaf));
90 137 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
91 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 150 #endif
93 151 }
94 152 };
@@ -7,18 +7,29 class ChartThemeGrayscale: public ChartTheme
7 7 public:
8 8 ChartThemeGrayscale():ChartTheme(QChart::ChartThemeGrayscale)
9 9 {
10 m_seriesColors << QRgb(0xff869299);
11 m_seriesColors << QRgb(0xffa5bdcc);
12 m_seriesColors << QRgb(0xffe8fffc);
13 m_seriesColors << QRgb(0xffccc2c2);
14
10 // Series colors
11 m_seriesColors << QRgb(0x869299);
12 m_seriesColors << QRgb(0xa5bdcc);
13 m_seriesColors << QRgb(0xe8fffc);
14 m_seriesColors << QRgb(0xccc2c2);
15 15 generateSeriesGradients();
16 16
17 // Background
17 18 QLinearGradient backgroundGradient;
18 backgroundGradient.setColorAt(0.0, QRgb(0xffffffff));
19 backgroundGradient.setColorAt(1.0, QRgb(0xffe0e3e5));
19 backgroundGradient.setColorAt(0.0, QRgb(0xffffff));
20 backgroundGradient.setColorAt(1.0, QRgb(0xe0e3e5));
20 21 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
21 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 7 public:
8 8 ChartThemeIcy():ChartTheme(QChart::ChartThemeIcy)
9 9 {
10 m_seriesColors << QRgb(0xff0d2673);
11 m_seriesColors << QRgb(0xff2685bf);
12 m_seriesColors << QRgb(0xff3dadd9);
13 m_seriesColors << QRgb(0xff62c3d9);
14
10 // Series
11 m_seriesColors << QRgb(0x0d2673);
12 m_seriesColors << QRgb(0x2685bf);
13 m_seriesColors << QRgb(0x3dadd9);
14 m_seriesColors << QRgb(0x62c3d9);
15 15 generateSeriesGradients();
16 16
17 // Background
17 18 QLinearGradient backgroundGradient;
18 backgroundGradient.setColorAt(0.0, QRgb(0xffebebeb));
19 backgroundGradient.setColorAt(1.0, QRgb(0xfff8f9fb));
19 backgroundGradient.setColorAt(0.0, QRgb(0xebebeb));
20 backgroundGradient.setColorAt(1.0, QRgb(0xf8f9fb));
20 21 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
21 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 7 public:
8 8 ChartThemeScientific():ChartTheme(QChart::ChartThemeScientific)
9 9 {
10 m_seriesColors << QRgb(0xFFFFAD00);
11 m_seriesColors << QRgb(0xFF596A75);
12 m_seriesColors << QRgb(0xFF202020);
13 m_seriesColors << QRgb(0xFF474747);
14
10 // Series
11 m_seriesColors << QRgb(0xFFAD00);
12 m_seriesColors << QRgb(0x596A75);
13 m_seriesColors << QRgb(0x202020);
14 m_seriesColors << QRgb(0x474747);
15 15 generateSeriesGradients();
16 16
17 // Background
17 18 QLinearGradient backgroundGradient;
18 backgroundGradient.setColorAt(0.0, QRgb(0xfffffefc));
19 backgroundGradient.setColorAt(1.0, QRgb(0xfffffefc));
19 backgroundGradient.setColorAt(0.0, QRgb(0xfffefc));
20 backgroundGradient.setColorAt(1.0, QRgb(0xfffefc));
20 21 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
21 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 7 public:
8 8 ChartThemeVanilla():ChartTheme(QChart::ChartThemeVanilla)
9 9 {
10 m_seriesColors << QRgb(0xffd9c574);
11 m_seriesColors << QRgb(0xffd6a896);
12 m_seriesColors << QRgb(0xffa0a071);
13 m_seriesColors << QRgb(0xffd2d234);
14 m_seriesColors << QRgb(0xff88723a);
15
10 // Series
11 m_seriesColors << QRgb(0xd9c574);
12 m_seriesColors << QRgb(0xd6a896);
13 m_seriesColors << QRgb(0xa0a071);
14 m_seriesColors << QRgb(0xd2d234);
15 m_seriesColors << QRgb(0x88723a);
16 16 generateSeriesGradients();
17 17
18 // Background
18 19 QLinearGradient backgroundGradient;
19 backgroundGradient.setColorAt(0.0, QRgb(0xfffbf9f1));
20 backgroundGradient.setColorAt(1.0, QRgb(0xfff5f0dc));
20 backgroundGradient.setColorAt(0.0, QRgb(0xfbf9f1));
21 backgroundGradient.setColorAt(1.0, QRgb(0xf5f0dc));
21 22 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
22 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