1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the Qt Charts module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:GPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU
19** General Public License version 3 or (at your option) any later version
20** approved by the KDE Free Qt Foundation. The licenses are as published by
21** the Free Software Foundation and appearing in the file LICENSE.GPL3
22** included in the packaging of this file. Please review the following
23** information to ensure the GNU General Public License requirements will
24** be met: https://www.gnu.org/licenses/gpl-3.0.html.
25**
26** $QT_END_LICENSE$
27**
28****************************************************************************/
29
30// W A R N I N G
31// -------------
32//
33// This file is not part of the Qt Chart API. It exists purely as an
34// implementation detail. This header file may change from version to
35// version without notice, or even be removed.
36//
37// We mean it.
38
39#ifndef CHARTTHEMESYSTEM_P_H
40#define CHARTTHEMESYSTEM_P_H
41
42#include <private/charttheme_p.h>
43#include <QtCharts/private/qchartglobal_p.h>
44#ifdef Q_OS_WIN
45#include <windows.h>
46#include <stdio.h>
47#endif
48
49QT_CHARTS_BEGIN_NAMESPACE
50
51class Q_CHARTS_PRIVATE_EXPORT ChartThemeSystem: public ChartTheme
52{
53public:
54 // System theme not used at the moment (the user is not able to select this theme)
55 ChartThemeSystem() : ChartTheme(QChart::ChartThemeLight /*QChart::ChartThemeSystem*/)
56 {
57#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
58 // We could also use theme specific window frame color as a series base color (it would give more
59 // variation to the base colors in addition to the blue and black used now)
60
61 // First series base color from COLOR_HIGHLIGHT
62 DWORD colorHighlight;
63 colorHighlight = GetSysColor(COLOR_HIGHLIGHT);
64 m_seriesColors.append(QColor(GetRValue(colorHighlight),
65 GetGValue(colorHighlight),
66 GetBValue(colorHighlight)));
67
68 // Second series base color from COLOR_WINDOWFRAME
69 DWORD colorWindowFrame;
70 colorWindowFrame = GetSysColor(COLOR_WINDOWFRAME);
71 m_seriesColors.append(QColor(GetRValue(colorWindowFrame),
72 GetGValue(colorWindowFrame),
73 GetBValue(colorWindowFrame)));
74
75 // Third series base color from the middle of the COLOR_ACTIVECAPTION /
76 // COLOR_GRADIENTACTIVECAPTION gradient
77 DWORD colorGradientActiveCaptionLeft;
78 colorGradientActiveCaptionLeft = GetSysColor(COLOR_ACTIVECAPTION);
79 DWORD colorGradientActiveCaptionRight;
80 colorGradientActiveCaptionRight = GetSysColor(COLOR_GRADIENTACTIVECAPTION);
81 QLinearGradient g;
82 QColor start = QColor(GetRValue(colorGradientActiveCaptionLeft),
83 GetGValue(colorGradientActiveCaptionLeft),
84 GetBValue(colorGradientActiveCaptionLeft));
85 g.setColorAt(0.0, start);
86 QColor end = QColor(GetRValue(colorGradientActiveCaptionRight),
87 GetGValue(colorGradientActiveCaptionRight),
88 GetBValue(colorGradientActiveCaptionRight));
89 g.setColorAt(1.0, end);
90 m_seriesColors.append(ChartThemeManager::colorAt(g, 0.5));
91
92 // Generate gradients from the base colors
93 m_seriesGradients = ChartThemeManager::generateSeriesGradients(m_seriesColors);
94
95 // Background fill color from COLOR_WINDOW
96 QLinearGradient backgroundGradient;
97 DWORD colorWindow;
98 colorWindow = GetSysColor(COLOR_WINDOW);
99 backgroundGradient.setColorAt(0.0, QColor(GetRValue(colorWindow),
100 GetGValue(colorWindow),
101 GetBValue(colorWindow)));
102 backgroundGradient.setColorAt(1.0, QColor(GetRValue(colorWindow),
103 GetGValue(colorWindow),
104 GetBValue(colorWindow)));
105 // Axes and other
106 m_axisLinePen = QPen(0xd6d6d6);
107 m_axisLinePen.setWidth(1);
108 m_labelBrush = QBrush(QRgb(0x404044));
109 m_gridLinePen = QPen(QRgb(0xe2e2e2));
110 m_gridLinePen.setWidth(1);
111 m_minorGridLinePen = QPen(QRgb(0xe2e2e2));
112 m_minorGridLinePen.setWidth(1);
113 m_minorGridLinePen.setStyle(Qt::DashLine);
114 m_backgroundShades = BackgroundShadesNone;
115
116#elif defined(Q_OS_LINUX)
117 // Using a hard coded theme for Linux system theme
118 m_seriesColors << QRgb(0x60a6e6);
119 m_seriesColors << QRgb(0x92ca66);
120 m_seriesColors << QRgb(0xeba85f);
121 m_seriesColors << QRgb(0xfc5751);
122 m_seriesGradients = ChartThemeManager::generateSeriesGradients(colors: m_seriesColors);
123
124 // Background
125 QLinearGradient backgroundGradient;
126 backgroundGradient.setColorAt(pos: 0.0, color: QRgb(0xffffff));
127 backgroundGradient.setColorAt(pos: 1.0, color: QRgb(0xffffff));
128 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
129 m_chartBackgroundGradient = backgroundGradient;
130
131 // Axes and other
132 m_axisLinePen = QPen(0xd6d6d6);
133 m_axisLinePen.setWidth(1);
134 m_labelBrush = QBrush(QRgb(0x404044));
135 m_gridLinePen = QPen(QRgb(0xe2e2e2));
136 m_gridLinePen.setWidth(1);
137 m_minorGridLinePen = QPen(QRgb(0x404044));
138 m_minorGridLinePen.setWidth(1);
139 m_minorGridLinePen.setStyle(Qt::DashLine);
140 m_backgroundShades = BackgroundShadesNone;
141
142#elif defined(Q_OS_MAC)
143 // Using a hard coded theme for OSX system theme; the colors match the OSX 10.7 colors
144 m_seriesColors << QRgb(0x60a6e6);
145 m_seriesColors << QRgb(0x92ca66);
146 m_seriesColors << QRgb(0xeba85f);
147 m_seriesColors << QRgb(0xfc5751);
148 m_seriesGradients = ChartThemeManager::generateSeriesGradients(m_seriesColors);
149
150 // Background
151 QLinearGradient backgroundGradient;
152 backgroundGradient.setColorAt(0.0, QRgb(0xffffff));
153 backgroundGradient.setColorAt(1.0, QRgb(0xffffff));
154 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
155 m_chartBackgroundGradient = backgroundGradient;
156
157 // Axes and other
158 m_axisLinePen = QPen(0xd6d6d6);
159 m_axisLinePen.setWidth(1);
160 m_labelBrush = QBrush(QRgb(0x404044));
161 m_gridLinePen = QPen(QRgb(0xe2e2e2));
162 m_gridLinePen.setWidth(1);
163 m_minorGridLinePen = QPen(QRgb(0xe2e2e2));
164 m_minorGridLinePen.setWidth(1);
165 m_minorGridLinePen.setStyle(Qt::DashLine);
166 m_backgroundShades = BackgroundShadesNone;
167
168#else
169 // Hard coded theme
170 m_seriesColors << QRgb(0x60a6e6);
171 m_seriesColors << QRgb(0x92ca66);
172 m_seriesColors << QRgb(0xeba85f);
173 m_seriesColors << QRgb(0xfc5751);
174 m_seriesGradients = ChartThemeManager::generateSeriesGradients(m_seriesColors);
175
176 // Background
177 QLinearGradient backgroundGradient;
178 backgroundGradient.setColorAt(0.0, QRgb(0xffffff));
179 backgroundGradient.setColorAt(1.0, QRgb(0xffffff));
180 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
181 m_chartBackgroundGradient = backgroundGradient;
182
183 // Axes and other
184 m_axisLinePen = QPen(0xd6d6d6);
185 m_axisLinePen.setWidth(1);
186 m_labelBrush = QBrush(QRgb(0x404044));
187 m_gridLinePen = QPen(QRgb(0xe2e2e2));
188 m_gridLinePen.setWidth(1);
189 m_minorGridLinePen = QPen(QRgb(0xe2e2e2));
190 m_minorGridLinePen.setWidth(1);
191 m_minorGridLinePen.setStyle(Qt::DashLine);
192 m_backgroundShades = BackgroundShadesNone;
193#endif
194 }
195};
196
197QT_CHARTS_END_NAMESPACE
198
199#endif // CHARTTHEMESYSTEM_P_H
200

source code of qtcharts/src/charts/themes/chartthemesystem_p.h