##// END OF EJS Templates
Defined point sizes for fonts
Tero Ahola -
r717:a566cfd317a8
parent child
Show More
@@ -1,379 +1,380
1 1 #include "charttheme_p.h"
2 2 #include "qchart.h"
3 3 #include "qchartview.h"
4 4 #include "qlegend.h"
5 5 #include "qchartaxis.h"
6 6 #include <QTime>
7 7
8 8 //series
9 9 #include "qbarset.h"
10 10 #include "qbarseries.h"
11 11 #include "qstackedbarseries.h"
12 12 #include "qpercentbarseries.h"
13 13 #include "qlineseries.h"
14 14 #include "qareaseries.h"
15 15 #include "qscatterseries.h"
16 16 #include "qpieseries.h"
17 17 #include "qpieslice.h"
18 18 #include "qsplineseries.h"
19 19
20 20 //items
21 21 #include "axisitem_p.h"
22 22 #include "barchartitem_p.h"
23 23 #include "stackedbarchartitem_p.h"
24 24 #include "percentbarchartitem_p.h"
25 25 #include "linechartitem_p.h"
26 26 #include "areachartitem_p.h"
27 27 #include "scatterchartitem_p.h"
28 28 #include "piechartitem_p.h"
29 29 #include "splinechartitem_p.h"
30 30
31 31 //themes
32 32 #include "chartthemedefault_p.h"
33 33 #include "chartthemelight_p.h"
34 34 #include "chartthemebluecerulean_p.h"
35 35 #include "chartthemedark_p.h"
36 36 #include "chartthemebrownsand_p.h"
37 37 #include "chartthemebluencs_p.h"
38 38 #include "chartthemeicy_p.h"
39 39 #include "chartthemescientific_p.h"
40 40
41 41 QTCOMMERCIALCHART_BEGIN_NAMESPACE
42 42
43 43 ChartTheme::ChartTheme(QChart::ChartTheme id) :
44 m_masterFont(QFont()),
44 m_masterFont(QFont("arial", 12)),
45 m_labelFont(QFont("arial", 10)),
45 46 m_titleBrush(QColor(QRgb(0x000000))),
46 47 m_axisLinePen(QPen(QRgb(0x000000))),
47 48 m_axisLabelBrush(QColor(QRgb(0x000000))),
48 49 m_backgroundShadesPen(Qt::NoPen),
49 50 m_backgroundShadesBrush(Qt::NoBrush),
50 51 m_backgroundShades(BackgroundShadesNone),
51 52 m_gridLinePen(QPen(QRgb(0x000000)))
52 53 {
53 54 m_id = id;
54 55 qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
55 56 }
56 57
57 58
58 59 ChartTheme* ChartTheme::createTheme(QChart::ChartTheme theme)
59 60 {
60 61 switch(theme) {
61 62 case QChart::ChartThemeLight:
62 63 return new ChartThemeLight();
63 64 case QChart::ChartThemeBlueCerulean:
64 65 return new ChartThemeBlueCerulean();
65 66 case QChart::ChartThemeDark:
66 67 return new ChartThemeDark();
67 68 case QChart::ChartThemeBrownSand:
68 69 return new ChartThemeBrownSand();
69 70 case QChart::ChartThemeBlueNcs:
70 71 return new ChartThemeBlueNcs();
71 72 case QChart::ChartThemeIcy:
72 73 return new ChartThemeIcy();
73 74 case QChart::ChartThemeScientific:
74 75 return new ChartThemeScientific();
75 76 default:
76 77 return new ChartThemeDefault();
77 78 }
78 79 }
79 80
80 81 void ChartTheme::decorate(QChart* chart,bool force)
81 82 {
82 83 QPen pen;
83 84 QBrush brush;
84 85
85 86 if(brush == chart->backgroundBrush() || force)
86 87 {
87 88 if (m_backgroundShades == BackgroundShadesNone) {
88 89 chart->setBackgroundBrush(m_chartBackgroundGradient);
89 90 }
90 91 else {
91 92 chart->setBackgroundBrush(Qt::NoBrush);
92 93 }
93 94 }
94 95 chart->setTitleFont(m_masterFont);
95 96 chart->setTitleBrush(m_titleBrush);
96 97 }
97 98
98 99 void ChartTheme::decorate(QLegend* legend,bool force)
99 100 {
100 101 QPen pen;
101 102 QBrush brush;
102 103
103 104 if (pen == legend->pen() || force){
104 105 //TODO:: legend->setPen();
105 106 }
106 107
107 108
108 109 if (brush == legend->brush() || force) {
109 110 legend->setBrush(m_chartBackgroundGradient);
110 111 }
111 112 }
112 113
113 114 void ChartTheme::decorate(QAreaSeries* series, int index,bool force)
114 115 {
115 116 QPen pen;
116 117 QBrush brush;
117 118
118 119 if (pen == series->pen() || force){
119 120 pen.setColor(colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0.0));
120 121 pen.setWidthF(2);
121 122 series->setPen(pen);
122 123 }
123 124
124 125 if (brush == series->brush() || force) {
125 126 QBrush brush(m_seriesColors.at(index % m_seriesColors.size()));
126 127 series->setBrush(brush);
127 128 }
128 129 }
129 130
130 131
131 132 void ChartTheme::decorate(QLineSeries* series,int index,bool force)
132 133 {
133 134 QPen pen;
134 135 if(pen == series->pen() || force ){
135 136 pen.setColor(m_seriesColors.at(index%m_seriesColors.size()));
136 137 pen.setWidthF(2);
137 138 series->setPen(pen);
138 139 }
139 140 }
140 141
141 142 void ChartTheme::decorate(QBarSeries* series, int index, bool force)
142 143 {
143 144 QBrush brush;
144 145 QPen pen;
145 146 QList<QBarSet*> sets = series->barSets();
146 147
147 148 qreal takeAtPos = 0.5;
148 149 qreal step = 0.2;
149 150 if (sets.count() > 1 ) {
150 151 step = 1.0 / (qreal) sets.count();
151 152 if (sets.count() % m_seriesGradients.count())
152 153 step *= m_seriesGradients.count();
153 154 else
154 155 step *= (m_seriesGradients.count() - 1);
155 156 }
156 157
157 158 for (int i(0); i < sets.count(); i++) {
158 159 int colorIndex = (index + i) % m_seriesGradients.count();
159 160 if (i > 0 && i % m_seriesGradients.count() == 0) {
160 161 // There is no dedicated base color for each sets, generate more colors
161 162 takeAtPos += step;
162 163 if (takeAtPos == 1.0)
163 164 takeAtPos += step;
164 165 takeAtPos -= (int) takeAtPos;
165 166 }
166 167 qDebug() << "pos:" << takeAtPos;
167 168 if (brush == sets.at(i)->brush() || force )
168 169 sets.at(i)->setBrush(colorAt(m_seriesGradients.at(colorIndex), takeAtPos));
169 170
170 171 // Pick label color from the opposite end of the gradient.
171 172 // 0.3 as a boundary seems to work well.
172 173 if (takeAtPos < 0.3)
173 174 sets.at(i)->setFloatingValuePen(colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 1));
174 175 else
175 176 sets.at(i)->setFloatingValuePen(colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0));
176 177
177 178 if (pen == sets.at(i)->pen() || force) {
178 179 QColor c = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0.0);
179 180 sets.at(i)->setPen(c);
180 181 }
181 182 }
182 183 }
183 184
184 185 void ChartTheme::decorate(QScatterSeries* series, int index,bool force)
185 186 {
186 187 QPen pen;
187 188 QBrush brush;
188 189
189 190 if (pen == series->pen() || force) {
190 191 pen.setColor(colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0.0));
191 192 pen.setWidthF(2);
192 193 series->setPen(pen);
193 194 }
194 195
195 196 if (brush == series->brush() || force) {
196 197 QBrush brush(m_seriesColors.at(index % m_seriesColors.size()));
197 198 series->setBrush(brush);
198 199 }
199 200 }
200 201
201 202 void ChartTheme::decorate(QPieSeries* series, int index, bool force)
202 203 {
203 204 for (int i(0); i < series->slices().count(); i++) {
204 205
205 206 QColor penColor = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0.0);
206 207
207 208 // Get color for a slice from a gradient linearly, beginning from the start of the gradient
208 209 qreal pos = (qreal) (i + 1) / (qreal) series->count();
209 210 QColor brushColor = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), pos);
210 211
211 212 QPieSlice::DataPtr s = series->slices().at(i)->data_ptr();
212 213 PieSliceData data = s->m_data;
213 214
214 215 if (data.m_slicePen.isThemed() || force) {
215 216 data.m_slicePen = penColor;
216 217 data.m_slicePen.setThemed(true);
217 218 }
218 219
219 220 if (data.m_sliceBrush.isThemed() || force) {
220 221 data.m_sliceBrush = brushColor;
221 222 data.m_sliceBrush.setThemed(true);
222 223 }
223 224
224 225 if (data.m_labelPen.isThemed() || force) {
225 226 data.m_labelPen = QPen(m_titleBrush.color());
226 227 data.m_labelPen.setThemed(true);
227 228 }
228 229
229 230 if (data.m_labelFont.isThemed() || force) {
230 data.m_labelFont = m_masterFont;
231 data.m_labelFont = m_labelFont;
231 232 data.m_labelFont.setThemed(true);
232 233 }
233 234
234 235 if (s->m_data != data) {
235 236 s->m_data = data;
236 237 emit s->changed();
237 238 }
238 239 }
239 240 }
240 241
241 242 void ChartTheme::decorate(QSplineSeries* series, int index, bool force)
242 243 {
243 244 QPen pen;
244 245 if(pen == series->pen() || force){
245 246 pen.setColor(m_seriesColors.at(index%m_seriesColors.size()));
246 247 pen.setWidthF(2);
247 248 series->setPen(pen);
248 249 }
249 250 }
250 251
251 252 void ChartTheme::decorate(QChartAxis* axis,bool axisX, bool force)
252 253 {
253 254 QPen pen;
254 255 QBrush brush;
255 256 QFont font;
256 257
257 258 if (axis->isAxisVisible()) {
258 259
259 260 if(brush == axis->labelsBrush() || force){
260 261 axis->setLabelsBrush(m_axisLabelBrush);
261 262 }
262 263 if(pen == axis->labelsPen() || force){
263 264 axis->setLabelsPen(Qt::NoPen); // NoPen for performance reasons
264 265 }
265 266
266 267
267 268 if (axis->shadesVisible() || force) {
268 269
269 270 if(brush == axis->shadesBrush() || force){
270 271 axis->setShadesBrush(m_backgroundShadesBrush);
271 272 }
272 273
273 274 if(pen == axis->shadesPen() || force){
274 275 axis->setShadesPen(m_backgroundShadesPen);
275 276 }
276 277
277 278 if(force && (m_backgroundShades == BackgroundShadesBoth
278 279 || (m_backgroundShades == BackgroundShadesVertical && axisX)
279 280 || (m_backgroundShades == BackgroundShadesHorizontal && !axisX))){
280 281 axis->setShadesVisible(true);
281 282
282 283 }
283 284 }
284 285
285 286 if(pen == axis->axisPen() || force){
286 287 axis->setAxisPen(m_axisLinePen);
287 288 }
288 289
289 290 if(pen == axis->gridLinePen() || force){
290 291 axis->setGridLinePen(m_gridLinePen);
291 292 }
292 293
293 294 if(font == axis->labelsFont() || force){
294 axis->setLabelsFont(m_masterFont);
295 axis->setLabelsFont(m_labelFont);
295 296 }
296 297 }
297 298 }
298 299
299 300 void ChartTheme::generateSeriesGradients()
300 301 {
301 302 // Generate gradients in HSV color space
302 303 foreach (QColor color, m_seriesColors) {
303 304 QLinearGradient g;
304 305 qreal h = color.hsvHueF();
305 306 qreal s = color.hsvSaturationF();
306 307
307 308 // TODO: tune the algorithm to give nice results with most base colors defined in
308 309 // most themes. The rest of the gradients we can define manually in theme specific
309 310 // implementation.
310 311 QColor start = color;
311 312 start.setHsvF(h, 0.0, 1.0);
312 313 g.setColorAt(0.0, start);
313 314
314 315 g.setColorAt(0.5, color);
315 316
316 317 QColor end = color;
317 318 end.setHsvF(h, s, 0.25);
318 319 g.setColorAt(1.0, end);
319 320
320 321 m_seriesGradients << g;
321 322 }
322 323 }
323 324
324 325
325 326 QColor ChartTheme::colorAt(const QColor &start, const QColor &end, qreal pos)
326 327 {
327 328 Q_ASSERT(pos >=0.0 && pos <= 1.0);
328 329 qreal r = start.redF() + ((end.redF() - start.redF()) * pos);
329 330 qreal g = start.greenF() + ((end.greenF() - start.greenF()) * pos);
330 331 qreal b = start.blueF() + ((end.blueF() - start.blueF()) * pos);
331 332 QColor c;
332 333 c.setRgbF(r, g, b);
333 334 return c;
334 335 }
335 336
336 337 QColor ChartTheme::colorAt(const QGradient &gradient, qreal pos)
337 338 {
338 339 Q_ASSERT(pos >=0 && pos <= 1.0);
339 340
340 341 // another possibility:
341 342 // http://stackoverflow.com/questions/3306786/get-intermediate-color-from-a-gradient
342 343
343 344 QGradientStops stops = gradient.stops();
344 345 int count = stops.count();
345 346
346 347 // find previous stop relative to position
347 348 QGradientStop prev = stops.first();
348 349 for (int i=0; i<count; i++) {
349 350 QGradientStop stop = stops.at(i);
350 351 if (pos > stop.first)
351 352 prev = stop;
352 353
353 354 // given position is actually a stop position?
354 355 if (pos == stop.first) {
355 356 //qDebug() << "stop color" << pos;
356 357 return stop.second;
357 358 }
358 359 }
359 360
360 361 // find next stop relative to position
361 362 QGradientStop next = stops.last();
362 363 for (int i=count-1; i>=0; i--) {
363 364 QGradientStop stop = stops.at(i);
364 365 if (pos < stop.first)
365 366 next = stop;
366 367 }
367 368
368 369 //qDebug() << "prev" << prev.first << "pos" << pos << "next" << next.first;
369 370
370 371 qreal range = next.first - prev.first;
371 372 qreal posDelta = pos - prev.first;
372 373 qreal relativePos = posDelta / range;
373 374
374 375 //qDebug() << "range" << range << "posDelta" << posDelta << "relativePos" << relativePos;
375 376
376 377 return colorAt(prev.second, next.second, relativePos);
377 378 }
378 379
379 380 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,78 +1,79
1 1 #ifndef CHARTTHEME_H
2 2 #define CHARTTHEME_H
3 3
4 4 #include "qchartglobal.h"
5 5 #include "qchart.h"
6 6 #include <QColor>
7 7 #include <QGradientStops>
8 8
9 9 QTCOMMERCIALCHART_BEGIN_NAMESPACE
10 10
11 11 class ChartItem;
12 12 class QSeries;
13 13 class LineChartItem;
14 14 class QLineSeries;
15 15 class BarChartItem;
16 16 class QBarSeries;
17 17 class StackedBarChartItem;
18 18 class QStackedBarSeries;
19 19 class QPercentBarSeries;
20 20 class PercentBarChartItem;
21 21 class QScatterSeries;
22 22 class ScatterChartItem;
23 23 class PieChartItem;
24 24 class QPieSeries;
25 25 class SplineChartItem;
26 26 class QSplineSeries;
27 27 class AreaChartItem;
28 28 class QAreaSeries;
29 29
30 30 class ChartTheme
31 31 {
32 32 public:
33 33 enum BackgroundShadesMode {
34 34 BackgroundShadesNone = 0,
35 35 BackgroundShadesVertical,
36 36 BackgroundShadesHorizontal,
37 37 BackgroundShadesBoth
38 38 };
39 39
40 40 protected:
41 41 explicit ChartTheme(QChart::ChartTheme id = QChart::ChartThemeDefault);
42 42 public:
43 43 static ChartTheme* createTheme(QChart::ChartTheme theme);
44 44 QChart::ChartTheme id() const {return m_id;}
45 45 void decorate(QChart* chart,bool force = true);
46 46 void decorate(QLegend* legend,bool force = true);
47 47 void decorate(QBarSeries* series, int index,bool force = true);
48 48 void decorate(QLineSeries* series, int index,bool force = true);
49 49 void decorate(QAreaSeries* series, int index,bool force = true);
50 50 void decorate(QScatterSeries* series, int index,bool force = true);
51 51 void decorate(QPieSeries* series, int index,bool force = true);
52 52 void decorate(QSplineSeries* series, int index,bool force = true);
53 53 void decorate(QChartAxis* axis, bool axisX,bool force = true);
54 54
55 55 public: // utils
56 56 void generateSeriesGradients();
57 57 static QColor colorAt(const QColor &start, const QColor &end, qreal pos);
58 58 static QColor colorAt(const QGradient &gradient, qreal pos);
59 59
60 60 protected:
61 61 QChart::ChartTheme m_id;
62 62 QList<QColor> m_seriesColors;
63 63 QList<QGradient> m_seriesGradients;
64 64 QLinearGradient m_chartBackgroundGradient;
65 65
66 66 QFont m_masterFont;
67 QFont m_labelFont;
67 68 QBrush m_titleBrush;
68 69 QPen m_axisLinePen;
69 70 QBrush m_axisLabelBrush;
70 71 QPen m_backgroundShadesPen;
71 72 QBrush m_backgroundShadesBrush;
72 73 BackgroundShadesMode m_backgroundShades;
73 74 QPen m_gridLinePen;
74 75 };
75 76
76 77 QTCOMMERCIALCHART_END_NAMESPACE
77 78
78 79 #endif // CHARTTHEME_H
@@ -1,37 +1,36
1 1 #include "charttheme_p.h"
2 2
3 3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
4 4
5 5 class ChartThemeBlueCerulean: public ChartTheme
6 6 {
7 7 public:
8 8 ChartThemeBlueCerulean() : ChartTheme(QChart::ChartThemeBlueCerulean)
9 9 {
10 10 // Series colors
11 11 m_seriesColors << QRgb(0xc7e85b);
12 12 m_seriesColors << QRgb(0x1cb54f);
13 13 m_seriesColors << QRgb(0x5cbf9b);
14 14 m_seriesColors << QRgb(0x009fbf);
15 15 m_seriesColors << QRgb(0xee7392);
16 16 generateSeriesGradients();
17 17
18 18 // Background
19 19 QLinearGradient backgroundGradient(0.5, 0.0, 0.5, 1.0);
20 20 backgroundGradient.setColorAt(0.0, QRgb(0x056189));
21 21 backgroundGradient.setColorAt(1.0, QRgb(0x101a31));
22 22 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
23 23 m_chartBackgroundGradient = backgroundGradient;
24 24
25 25 // Axes and other
26 m_masterFont = QFont("arial");
27 26 m_titleBrush = QBrush(QRgb(0xffffff));
28 27 m_axisLinePen = QPen(QRgb(0xd6d6d6));
29 28 m_axisLinePen.setWidth(2);
30 29 m_axisLabelBrush = QBrush(QRgb(0xffffff));
31 30 m_gridLinePen = QPen(QRgb(0x84a2b0));
32 31 m_gridLinePen.setWidth(1);
33 32 m_backgroundShades = BackgroundShadesNone;
34 33 }
35 34 };
36 35
37 36 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,37 +1,36
1 1 #include "charttheme_p.h"
2 2
3 3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
4 4
5 5 class ChartThemeBlueNcs: public ChartTheme
6 6 {
7 7 public:
8 8 ChartThemeBlueNcs() : ChartTheme(QChart::ChartThemeBlueNcs)
9 9 {
10 10 // Series colors
11 11 m_seriesColors << QRgb(0x1db0da);
12 12 m_seriesColors << QRgb(0x1341a6);
13 13 m_seriesColors << QRgb(0x88d41e);
14 14 m_seriesColors << QRgb(0xff8e1a);
15 15 m_seriesColors << QRgb(0x398ca3);
16 16 generateSeriesGradients();
17 17
18 18 // Background
19 19 QLinearGradient backgroundGradient;
20 20 backgroundGradient.setColorAt(0.0, QRgb(0xffffff));
21 21 backgroundGradient.setColorAt(1.0, QRgb(0xffffff));
22 22 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
23 23 m_chartBackgroundGradient = backgroundGradient;
24 24
25 25 // Axes and other
26 m_masterFont = QFont("arial");
27 26 m_titleBrush = QBrush(QRgb(0x404044));
28 27 m_axisLinePen = QPen(QRgb(0xd6d6d6));
29 28 m_axisLinePen.setWidth(2);
30 29 m_axisLabelBrush = QBrush(QRgb(0x404044));
31 30 m_gridLinePen = QPen(QRgb(0xe2e2e2));
32 31 m_gridLinePen.setWidth(1);
33 32 m_backgroundShades = BackgroundShadesNone;
34 33 }
35 34 };
36 35
37 36 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,37 +1,36
1 1 #include "charttheme_p.h"
2 2
3 3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
4 4
5 5 class ChartThemeBrownSand: public ChartTheme
6 6 {
7 7 public:
8 8 ChartThemeBrownSand() : ChartTheme(QChart::ChartThemeBrownSand)
9 9 {
10 10 // Series colors
11 11 m_seriesColors << QRgb(0xb39b72);
12 12 m_seriesColors << QRgb(0xb3b376);
13 13 m_seriesColors << QRgb(0xc35660);
14 14 m_seriesColors << QRgb(0x536780);
15 15 m_seriesColors << QRgb(0x494345);
16 16 generateSeriesGradients();
17 17
18 18 // Background
19 19 QLinearGradient backgroundGradient;
20 20 backgroundGradient.setColorAt(0.0, QRgb(0xf3ece0));
21 21 backgroundGradient.setColorAt(1.0, QRgb(0xf3ece0));
22 22 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
23 23 m_chartBackgroundGradient = backgroundGradient;
24 24
25 25 // Axes and other
26 m_masterFont = QFont("arial");
27 26 m_titleBrush = QBrush(QRgb(0x404044));
28 27 m_axisLinePen = QPen(QRgb(0xb5b0a7));
29 28 m_axisLinePen.setWidth(2);
30 29 m_axisLabelBrush = QBrush(QRgb(0x404044));
31 30 m_gridLinePen = QPen(QRgb(0xd4cec3));
32 31 m_gridLinePen.setWidth(1);
33 32 m_backgroundShades = BackgroundShadesNone;
34 33 }
35 34 };
36 35
37 36 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,37 +1,36
1 1 #include "charttheme_p.h"
2 2
3 3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
4 4
5 5 class ChartThemeDark : public ChartTheme
6 6 {
7 7 public:
8 8 ChartThemeDark() : ChartTheme(QChart::ChartThemeDark)
9 9 {
10 10 // Series colors
11 11 m_seriesColors << QRgb(0x38ad6b);
12 12 m_seriesColors << QRgb(0x3c84a7);
13 13 m_seriesColors << QRgb(0xeb8817);
14 14 m_seriesColors << QRgb(0x7b7f8c);
15 15 m_seriesColors << QRgb(0xbf593e);
16 16 generateSeriesGradients();
17 17
18 18 // Background
19 19 QLinearGradient backgroundGradient(0.5, 0.0, 0.5, 1.0);
20 20 backgroundGradient.setColorAt(0.0, QRgb(0x2e303a));
21 21 backgroundGradient.setColorAt(1.0, QRgb(0x121218));
22 22 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
23 23 m_chartBackgroundGradient = backgroundGradient;
24 24
25 25 // Axes and other
26 m_masterFont = QFont("arial");
27 26 m_titleBrush = QBrush(QRgb(0xffffff));
28 27 m_axisLinePen = QPen(QRgb(0x86878c));
29 28 m_axisLinePen.setWidth(2);
30 29 m_axisLabelBrush = QBrush(QRgb(0xffffff));
31 30 m_gridLinePen = QPen(QRgb(0x86878c));
32 31 m_gridLinePen.setWidth(1);
33 32 m_backgroundShades = BackgroundShadesNone;
34 33 }
35 34 };
36 35
37 36 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,149 +1,145
1 1 #include "charttheme_p.h"
2 2 #ifdef Q_OS_WIN
3 3 #include <windows.h>
4 4 #include <stdio.h>
5 5 #endif
6 6
7 7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
8 8
9 9 class ChartThemeDefault: public ChartTheme
10 10 {
11 11 public:
12 12 ChartThemeDefault() : ChartTheme(QChart::ChartThemeDefault)
13 13 {
14 14 #ifdef Q_OS_WIN
15 15 // TODO: use theme specific window frame color as a series base color (it would give more
16 16 // variation to the base colors in addition to the blue and black used now)
17 17 // TODO: COLOR_WINDOWTEXT for text color?
18 18 // TODO: COLOR_INFOTEXT for tooltip text color?
19 19 // TODO: COLOR_INFOBK for tooltip background color?
20 20
21 21 // First series base color from COLOR_HIGHLIGHT
22 22 DWORD colorHighlight;
23 23 colorHighlight = GetSysColor(COLOR_HIGHLIGHT);
24 24 m_seriesColors.append(QColor(GetRValue(colorHighlight),
25 25 GetGValue(colorHighlight),
26 26 GetBValue(colorHighlight)));
27 27
28 28 // Second series base color from COLOR_WINDOWFRAME
29 29 DWORD colorWindowFrame;
30 30 colorWindowFrame = GetSysColor(COLOR_WINDOWFRAME);
31 31 m_seriesColors.append(QColor(GetRValue(colorWindowFrame),
32 32 GetGValue(colorWindowFrame),
33 33 GetBValue(colorWindowFrame)));
34 34
35 35 // Third series base color from the middle of the COLOR_ACTIVECAPTION /
36 36 // COLOR_GRADIENTACTIVECAPTION gradient
37 37 DWORD colorGradientActiveCaptionLeft;
38 38 colorGradientActiveCaptionLeft = GetSysColor(COLOR_ACTIVECAPTION);
39 39 DWORD colorGradientActiveCaptionRight;
40 40 colorGradientActiveCaptionRight = GetSysColor(COLOR_GRADIENTACTIVECAPTION);
41 41 QLinearGradient g;
42 42 QColor start = QColor(GetRValue(colorGradientActiveCaptionLeft),
43 43 GetGValue(colorGradientActiveCaptionLeft),
44 44 GetBValue(colorGradientActiveCaptionLeft));
45 45 g.setColorAt(0.0, start);
46 46 QColor end = QColor(GetRValue(colorGradientActiveCaptionRight),
47 47 GetGValue(colorGradientActiveCaptionRight),
48 48 GetBValue(colorGradientActiveCaptionRight));
49 49 g.setColorAt(1.0, end);
50 50 m_seriesColors.append(colorAt(g, 0.5));
51 51
52 52 // Generate gradients from the base colors
53 53 generateSeriesGradients();
54 54
55 55 // Background fill color from COLOR_WINDOW
56 56 QLinearGradient backgroundGradient;
57 57 DWORD colorWindow;
58 58 colorWindow = GetSysColor(COLOR_WINDOW);
59 59 backgroundGradient.setColorAt(0.0, QColor(GetRValue(colorWindow),
60 60 GetGValue(colorWindow),
61 61 GetBValue(colorWindow)));
62 62 backgroundGradient.setColorAt(1.0, QColor(GetRValue(colorWindow),
63 63 GetGValue(colorWindow),
64 64 GetBValue(colorWindow)));
65 65 // Axes and other
66 m_masterFont = QFont("arial");
67 66 m_axisLinePen = QPen(0xd6d6d6);
68 67 m_axisLinePen.setWidth(1);
69 68 m_axisLabelBrush = QBrush(QRgb(0x404044));
70 69 m_gridLinePen = QPen(QRgb(0xe2e2e2));
71 70 m_gridLinePen.setWidth(1);
72 71 m_backgroundShades = BackgroundShadesNone;
73 72
74 73 #elif defined(Q_OS_LINUX)
75 74 // TODO: replace this dummy theme with linux specific theme
76 75 m_seriesColors << QRgb(0x60a6e6);
77 76 m_seriesColors << QRgb(0x92ca66);
78 77 m_seriesColors << QRgb(0xeba85f);
79 78 m_seriesColors << QRgb(0xfc5751);
80 79 generateSeriesGradients();
81 80
82 81 // Background
83 82 QLinearGradient backgroundGradient;
84 83 backgroundGradient.setColorAt(0.0, QRgb(0xffffff));
85 84 backgroundGradient.setColorAt(1.0, QRgb(0xffffff));
86 85 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
87 86 m_chartBackgroundGradient = backgroundGradient;
88 87
89 88 // Axes and other
90 m_masterFont = QFont("arial");
91 89 m_axisLinePen = QPen(0xd6d6d6);
92 90 m_axisLinePen.setWidth(1);
93 91 m_axisLabelBrush = QBrush(QRgb(0x404044));
94 92 m_gridLinePen = QPen(QRgb(0xe2e2e2));
95 93 m_gridLinePen.setWidth(1);
96 94 m_backgroundShades = BackgroundShadesNone;
97 95
98 96 #elif defined(Q_OS_MAC)
99 97 // TODO: replace this dummy theme with OSX specific theme
100 98 m_seriesColors << QRgb(0x60a6e6);
101 99 m_seriesColors << QRgb(0x92ca66);
102 100 m_seriesColors << QRgb(0xeba85f);
103 101 m_seriesColors << QRgb(0xfc5751);
104 102 generateSeriesGradients();
105 103
106 104 // Background
107 105 QLinearGradient backgroundGradient;
108 106 backgroundGradient.setColorAt(0.0, QRgb(0xffffff));
109 107 backgroundGradient.setColorAt(1.0, QRgb(0xffffff));
110 108 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
111 109 m_chartBackgroundGradient = backgroundGradient;
112 110
113 111 // Axes and other
114 m_masterFont = QFont("arial");
115 112 m_axisLinePen = QPen(0xd6d6d6);
116 113 m_axisLinePen.setWidth(1);
117 114 m_axisLabelBrush = QBrush(QRgb(0x404044));
118 115 m_gridLinePen = QPen(QRgb(0xe2e2e2));
119 116 m_gridLinePen.setWidth(1);
120 117 m_backgroundShades = BackgroundShadesNone;
121 118
122 119 #else
123 120 // TODO: replace this dummy theme with generic (not OS specific) theme
124 121 m_seriesColors << QRgb(0x60a6e6);
125 122 m_seriesColors << QRgb(0x92ca66);
126 123 m_seriesColors << QRgb(0xeba85f);
127 124 m_seriesColors << QRgb(0xfc5751);
128 125 generateSeriesGradients();
129 126
130 127 // Background
131 128 QLinearGradient backgroundGradient;
132 129 backgroundGradient.setColorAt(0.0, QRgb(0xffffff));
133 130 backgroundGradient.setColorAt(1.0, QRgb(0xffffff));
134 131 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
135 132 m_chartBackgroundGradient = backgroundGradient;
136 133
137 134 // Axes and other
138 m_masterFont = QFont("arial");
139 135 m_axisLinePen = QPen(0xd6d6d6);
140 136 m_axisLinePen.setWidth(1);
141 137 m_axisLabelBrush = QBrush(QRgb(0x404044));
142 138 m_gridLinePen = QPen(QRgb(0xe2e2e2));
143 139 m_gridLinePen.setWidth(1);
144 140 m_backgroundShades = BackgroundShadesNone;
145 141 #endif
146 142 }
147 143 };
148 144
149 145 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,36 +1,35
1 1 #include "charttheme_p.h"
2 2
3 3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
4 4
5 5 class ChartThemeLight: public ChartTheme
6 6 {
7 7 public:
8 8 ChartThemeLight() : ChartTheme(QChart::ChartThemeLight)
9 9 {
10 10 // Series colors
11 11 m_seriesColors << QRgb(0x209fdf);
12 12 m_seriesColors << QRgb(0x99ca53);
13 13 m_seriesColors << QRgb(0xf6a625);
14 14 m_seriesColors << QRgb(0x6d5fd5);
15 15 m_seriesColors << QRgb(0xbf593e);
16 16 generateSeriesGradients();
17 17
18 18 // Background
19 19 QLinearGradient backgroundGradient;
20 20 backgroundGradient.setColorAt(0.0, QRgb(0xffffff));
21 21 backgroundGradient.setColorAt(1.0, QRgb(0xffffff));
22 22 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
23 23 m_chartBackgroundGradient = backgroundGradient;
24 24
25 25 // Axes and other
26 m_masterFont = QFont("arial");
27 26 m_axisLinePen = QPen(0xd6d6d6);
28 27 m_axisLinePen.setWidth(1);
29 28 m_axisLabelBrush = QBrush(QRgb(0x404044));
30 29 m_gridLinePen = QPen(QRgb(0xe2e2e2));
31 30 m_gridLinePen.setWidth(1);
32 31 m_backgroundShades = BackgroundShadesNone;
33 32 }
34 33 };
35 34
36 35 QTCOMMERCIALCHART_END_NAMESPACE
General Comments 0
You need to be logged in to leave comments. Login now