sptk2 logo
SPTK Home Page
CThemeColorCollection.h
1/*
2╔══════════════════════════════════════════════════════════════════════════════╗
3║ SIMPLY POWERFUL TOOLKIT (SPTK) ║
4╟──────────────────────────────────────────────────────────────────────────────╢
5║ copyright © 1999-2022 Alexey Parshin. All rights reserved. ║
6║ email alexeyp@gmail.com ║
7╚══════════════════════════════════════════════════════════════════════════════╝
8┌──────────────────────────────────────────────────────────────────────────────┐
9│ This library is free software; you can redistribute it and/or modify it │
10│ under the terms of the GNU Library General Public License as published by │
11│ the Free Software Foundation; either version 2 of the License, or (at your │
12│ option) any later version. │
13│ │
14│ This library is distributed in the hope that it will be useful, but │
15│ WITHOUT ANY WARRANTY; without even the implied warranty of │
16│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library │
17│ General Public License for more details. │
18│ │
19│ You should have received a copy of the GNU Library General Public License │
20│ along with this library; if not, write to the Free Software Foundation, │
21│ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. │
22│ │
23│ Please report all bugs and problems to alexeyp@gmail.com. │
24└──────────────────────────────────────────────────────────────────────────────┘
25*/
26
27#pragma once
28
29#include <FL/Fl.H>
30#include <FL/Enumerations.H>
31#include <sptk5/xdoc/Node.h>
32#include <sptk5/gui/CThemeImageState.h>
33#include <map>
34#include <string>
35#include <sptk5/xdoc/Document.h>
36
37namespace sptk {
38
48{
53
58
63
68
69};
70
71#define THM_MAX_COLOR_INDEX 4
72
77{
82
87
92
97
102
107
109
110#define THM_MAX_COLOR_STATE 5
111
112using gtk_color_function = Fl_Color (*)(const String& expression);
113
115{
116 static std::map<String, gtk_color_function>* m_gtkColorFunctionMap;
117 static std::map<String, Fl_Color> m_colorMap;
118 Fl_Color m_colors[THM_MAX_COLOR_INDEX][MAX_IMAGE_STATES];
119
120 static Fl_Color gtkColorFunction(const String& expression);
121
122 void loadColor(const xdoc::SNode& colorNode, CThemeColorIndex colorIndex);
123
124 void loadColorMap(xdoc::Document& gtkTheme, const String& colorMapXPath);
125
126 static Fl_Color passby(const String& expression);
127
128 static Fl_Color lighter(const String& expression);
129
130 static Fl_Color darker(const String& expression);
131
132 static Fl_Color shade(const String& expression);
133
134 static Fl_Color mix(const String& expression);
135
136public:
141
145 void loadFromSptkTheme(xdoc::Document& gtkTheme);
146
150 void loadFromGtkTheme(xdoc::Document& gtkTheme);
151
155 Fl_Color color(CThemeColorIndex colorIndex, CThemeColorState state) const
156 {
157 return m_colors[colorIndex][state];
158 }
159
163 Fl_Color fgColor(CThemeColorState state) const
164 {
165 return m_colors[THM_FOREGROUND_COLOR][state];
166 }
167
171 Fl_Color bgColor(CThemeColorState state) const
172 {
173 return m_colors[THM_BACKGROUND_COLOR][state];
174 }
175
179 Fl_Color baseColor(CThemeColorState state) const
180 {
181 return m_colors[THM_BASE_COLOR][state];
182 }
183
187 Fl_Color textColor(CThemeColorState state) const
188 {
189 return m_colors[THM_TEXT_COLOR][state];
190 }
191};
192
196}
Definition: CThemeColorCollection.h:115
CThemeColorCollection() noexcept
Constructor.
Fl_Color textColor(CThemeColorState state) const
Returns text color.
Definition: CThemeColorCollection.h:187
Fl_Color fgColor(CThemeColorState state) const
Returns foreground color.
Definition: CThemeColorCollection.h:163
Fl_Color baseColor(CThemeColorState state) const
Returns base color.
Definition: CThemeColorCollection.h:179
Fl_Color bgColor(CThemeColorState state) const
Returns background color.
Definition: CThemeColorCollection.h:171
Definition: String.h:49
Definition: Document.h:34
CThemeColorState
Definition: CThemeColorCollection.h:77
CThemeColorIndex
Definition: CThemeColorCollection.h:48
@ THM_COLOR_INSENSITIVE
Definition: CThemeColorCollection.h:106
@ THM_COLOR_ACTIVE
Definition: CThemeColorCollection.h:101
@ THM_COLOR_NORMAL
Definition: CThemeColorCollection.h:86
@ THM_COLOR_PRELIGHT
Definition: CThemeColorCollection.h:91
@ THM_COLOR_UNDEFINED
Definition: CThemeColorCollection.h:81
@ THM_COLOR_SELECTED
Definition: CThemeColorCollection.h:96
@ THM_TEXT_COLOR
Definition: CThemeColorCollection.h:67
@ THM_FOREGROUND_COLOR
Definition: CThemeColorCollection.h:52
@ THM_BACKGROUND_COLOR
Definition: CThemeColorCollection.h:57
@ THM_BASE_COLOR
Definition: CThemeColorCollection.h:62

Fri Oct 14 2022 09:58:31: SPTK 5.4.1