| 1 | // Copyright (C) 2016 The Qt Company Ltd. | 
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only | 
| 3 |  | 
| 4 | //  W A R N I N G | 
| 5 | //  ------------- | 
| 6 | // | 
| 7 | // This file is not part of the Qt Chart API.  It exists purely as an | 
| 8 | // implementation detail.  This header file may change from version to | 
| 9 | // version without notice, or even be removed. | 
| 10 | // | 
| 11 | // We mean it. | 
| 12 |  | 
| 13 | #ifndef CHARTTHEMESYSTEM_P_H | 
| 14 | #define CHARTTHEMESYSTEM_P_H | 
| 15 |  | 
| 16 | #include <private/charttheme_p.h> | 
| 17 | #include <QtCharts/private/qchartglobal_p.h> | 
| 18 | #ifdef Q_OS_WIN | 
| 19 | #include <windows.h> | 
| 20 | #include <stdio.h> | 
| 21 | #endif | 
| 22 |  | 
| 23 | QT_BEGIN_NAMESPACE | 
| 24 |  | 
| 25 | class Q_CHARTS_EXPORT ChartThemeSystem: public ChartTheme | 
| 26 | { | 
| 27 | public: | 
| 28 |     // System theme not used at the moment (the user is not able to select this theme) | 
| 29 |     ChartThemeSystem() : ChartTheme(QChart::ChartThemeLight /*QChart::ChartThemeSystem*/) | 
| 30 |     { | 
| 31 | #if defined(Q_OS_WIN) | 
| 32 |         // We could also use theme specific window frame color as a series base color (it would give more | 
| 33 |         // variation to the base colors in addition to the blue and black used now) | 
| 34 |  | 
| 35 |         // First series base color from COLOR_HIGHLIGHT | 
| 36 |         DWORD colorHighlight; | 
| 37 |         colorHighlight = GetSysColor(COLOR_HIGHLIGHT); | 
| 38 |         m_seriesColors.append(QColor(GetRValue(colorHighlight), | 
| 39 |                                      GetGValue(colorHighlight), | 
| 40 |                                      GetBValue(colorHighlight))); | 
| 41 |  | 
| 42 |         // Second series base color from COLOR_WINDOWFRAME | 
| 43 |         DWORD colorWindowFrame; | 
| 44 |         colorWindowFrame = GetSysColor(COLOR_WINDOWFRAME); | 
| 45 |         m_seriesColors.append(QColor(GetRValue(colorWindowFrame), | 
| 46 |                                      GetGValue(colorWindowFrame), | 
| 47 |                                      GetBValue(colorWindowFrame))); | 
| 48 |  | 
| 49 |         // Third series base color from the middle of the COLOR_ACTIVECAPTION / | 
| 50 |         // COLOR_GRADIENTACTIVECAPTION gradient | 
| 51 |         DWORD colorGradientActiveCaptionLeft; | 
| 52 |         colorGradientActiveCaptionLeft = GetSysColor(COLOR_ACTIVECAPTION); | 
| 53 |         DWORD colorGradientActiveCaptionRight; | 
| 54 |         colorGradientActiveCaptionRight = GetSysColor(COLOR_GRADIENTACTIVECAPTION); | 
| 55 |         QLinearGradient g; | 
| 56 |         QColor start = QColor(GetRValue(colorGradientActiveCaptionLeft), | 
| 57 |                               GetGValue(colorGradientActiveCaptionLeft), | 
| 58 |                               GetBValue(colorGradientActiveCaptionLeft)); | 
| 59 |         g.setColorAt(0.0, start); | 
| 60 |         QColor end = QColor(GetRValue(colorGradientActiveCaptionRight), | 
| 61 |                             GetGValue(colorGradientActiveCaptionRight), | 
| 62 |                             GetBValue(colorGradientActiveCaptionRight)); | 
| 63 |         g.setColorAt(1.0, end); | 
| 64 |         m_seriesColors.append(ChartThemeManager::colorAt(g, 0.5)); | 
| 65 |  | 
| 66 |         // Generate gradients from the base colors | 
| 67 |         m_seriesGradients = ChartThemeManager::generateSeriesGradients(m_seriesColors); | 
| 68 |  | 
| 69 |         // Background fill color from COLOR_WINDOW | 
| 70 |         QLinearGradient backgroundGradient; | 
| 71 |         DWORD colorWindow; | 
| 72 |         colorWindow = GetSysColor(COLOR_WINDOW); | 
| 73 |         backgroundGradient.setColorAt(0.0, QColor(GetRValue(colorWindow), | 
| 74 |                                       GetGValue(colorWindow), | 
| 75 |                                       GetBValue(colorWindow))); | 
| 76 |         backgroundGradient.setColorAt(1.0, QColor(GetRValue(colorWindow), | 
| 77 |                                       GetGValue(colorWindow), | 
| 78 |                                       GetBValue(colorWindow))); | 
| 79 |         // Axes and other | 
| 80 |         m_axisLinePen = QPen(0xd6d6d6); | 
| 81 |         m_axisLinePen.setWidth(1); | 
| 82 |         m_labelBrush = QBrush(QRgb(0x404044)); | 
| 83 |         m_gridLinePen = QPen(QRgb(0xe2e2e2)); | 
| 84 |         m_gridLinePen.setWidth(1); | 
| 85 |         m_minorGridLinePen = QPen(QRgb(0xe2e2e2)); | 
| 86 |         m_minorGridLinePen.setWidth(1); | 
| 87 |         m_minorGridLinePen.setStyle(Qt::DashLine); | 
| 88 |         m_backgroundShades = BackgroundShadesNone; | 
| 89 |  | 
| 90 | #elif defined(Q_OS_LINUX) | 
| 91 |         // Using a hard coded theme for Linux system theme | 
| 92 |         m_seriesColors << QRgb(0x60a6e6); | 
| 93 |         m_seriesColors << QRgb(0x92ca66); | 
| 94 |         m_seriesColors << QRgb(0xeba85f); | 
| 95 |         m_seriesColors << QRgb(0xfc5751); | 
| 96 |         m_seriesGradients = ChartThemeManager::generateSeriesGradients(colors: m_seriesColors); | 
| 97 |  | 
| 98 |         // Background | 
| 99 |         QLinearGradient backgroundGradient; | 
| 100 |         backgroundGradient.setColorAt(pos: 0.0, color: QRgb(0xffffff)); | 
| 101 |         backgroundGradient.setColorAt(pos: 1.0, color: QRgb(0xffffff)); | 
| 102 |         backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode); | 
| 103 |         m_chartBackgroundGradient = backgroundGradient; | 
| 104 |  | 
| 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(0x404044)); | 
| 112 |         m_minorGridLinePen.setWidth(1); | 
| 113 |         m_minorGridLinePen.setStyle(Qt::DashLine); | 
| 114 |         m_backgroundShades = BackgroundShadesNone; | 
| 115 |  | 
| 116 | #elif defined(Q_OS_MAC) | 
| 117 |         // Using a hard coded theme for OSX system theme; the colors match the OSX 10.7 colors | 
| 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(m_seriesColors); | 
| 123 |  | 
| 124 |         // Background | 
| 125 |         QLinearGradient backgroundGradient; | 
| 126 |         backgroundGradient.setColorAt(0.0, QRgb(0xffffff)); | 
| 127 |         backgroundGradient.setColorAt(1.0, 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(0xe2e2e2)); | 
| 138 |         m_minorGridLinePen.setWidth(1); | 
| 139 |         m_minorGridLinePen.setStyle(Qt::DashLine); | 
| 140 |         m_backgroundShades = BackgroundShadesNone; | 
| 141 |  | 
| 142 | #else | 
| 143 |         // Hard coded theme | 
| 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 | #endif | 
| 168 |     } | 
| 169 | }; | 
| 170 |  | 
| 171 | QT_END_NAMESPACE | 
| 172 |  | 
| 173 | #endif // CHARTTHEMESYSTEM_P_H | 
| 174 |  |