1 /*****************************************************************************
2 * Copyright 2003 - 2010 Craig Drummond <craig.p.drummond@gmail.com> *
3 * Copyright 2013 - 2015 Yichao Yu <yyc1992@gmail.com> *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU Lesser General Public License as *
7 * published by the Free Software Foundation; either version 2.1 of the *
8 * License, or (at your option) version 3, or any later version accepted *
9 * by the membership of KDE e.V. (or its successor approved by the *
10 * membership of KDE e.V.), which shall act as a proxy defined in *
11 * Section 6 of version 3 of the license. *
12 * *
13 * This program is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16 * Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public *
19 * License along with this library. If not, *
20 * see <http://www.gnu.org/licenses/>. *
21 *****************************************************************************/
22
23 #ifndef QTC_UTILS_OPTIONS_H
24 #define QTC_UTILS_OPTIONS_H
25
26 #include "number.h"
27
28 enum class Shading {
29 Simple,
30 HSL,
31 HSV,
32 HCY,
33 };
34
35 enum EScrollbar {
36 SCROLLBAR_KDE,
37 SCROLLBAR_WINDOWS,
38 SCROLLBAR_PLATINUM,
39 SCROLLBAR_NEXT,
40 SCROLLBAR_NONE
41 };
42
43 enum EAppearance {
44 APPEARANCE_CUSTOM1,
45 APPEARANCE_CUSTOM2,
46 APPEARANCE_CUSTOM3,
47 APPEARANCE_CUSTOM4,
48 APPEARANCE_CUSTOM5,
49 APPEARANCE_CUSTOM6,
50 APPEARANCE_CUSTOM7,
51 APPEARANCE_CUSTOM8,
52 APPEARANCE_CUSTOM9,
53 APPEARANCE_CUSTOM10,
54 APPEARANCE_CUSTOM11,
55 APPEARANCE_CUSTOM12,
56 APPEARANCE_CUSTOM13,
57 APPEARANCE_CUSTOM14,
58 APPEARANCE_CUSTOM15,
59 APPEARANCE_CUSTOM16,
60 APPEARANCE_CUSTOM17,
61 APPEARANCE_CUSTOM18,
62 APPEARANCE_CUSTOM19,
63 APPEARANCE_CUSTOM20,
64 APPEARANCE_CUSTOM21,
65 APPEARANCE_CUSTOM22,
66 APPEARANCE_CUSTOM23,
67
68 NUM_CUSTOM_GRAD,
69
70 APPEARANCE_FLAT = NUM_CUSTOM_GRAD,
71 APPEARANCE_RAISED,
72 APPEARANCE_DULL_GLASS,
73 APPEARANCE_SHINY_GLASS,
74 APPEARANCE_AGUA,
75 APPEARANCE_SOFT_GRADIENT,
76 APPEARANCE_GRADIENT,
77 APPEARANCE_HARSH_GRADIENT,
78 APPEARANCE_INVERTED,
79 APPEARANCE_DARK_INVERTED,
80 APPEARANCE_SPLIT_GRADIENT,
81 APPEARANCE_BEVELLED,
82 APPEARANCE_FADE, /* Only for poupmenu items! */
83 APPEARANCE_STRIPED = APPEARANCE_FADE, /* Only for windows and menus */
84 APPEARANCE_NONE = APPEARANCE_FADE, /* Only for titlebars */
85 APPEARANCE_FILE, /* Only for windows and menus */
86 APPEARANCE_LV_BEVELLED, /* To be used only with qtcGetGradient */
87 APPEARANCE_AGUA_MOD,
88 APPEARANCE_LV_AGUA,
89 NUM_STD_APP = (APPEARANCE_LV_AGUA - NUM_CUSTOM_GRAD) + 1
90 };
91
92 enum EFrame {
93 FRAME_NONE,
94 FRAME_PLAIN,
95 FRAME_LINE,
96 FRAME_SHADED,
97 FRAME_FADED
98 };
99
100 enum EGradientBorder {
101 GB_NONE,
102 GB_LIGHT,
103 GB_3D,
104 GB_3D_FULL,
105 GB_SHINE
106 };
107
108 enum ECornerBits {
109 CORNER_TL = 1 << 0,
110 CORNER_TR = 1 << 1,
111 CORNER_BR = 1 << 2,
112 CORNER_BL = 1 << 3,
113
114 ROUNDED_NONE = 0,
115 ROUNDED_TOP = CORNER_TL | CORNER_TR,
116 ROUNDED_BOTTOM = CORNER_BL | CORNER_BR,
117 ROUNDED_LEFT = CORNER_TL | CORNER_BL,
118 ROUNDED_RIGHT = CORNER_TR | CORNER_BR,
119 ROUNDED_TOPRIGHT = CORNER_TR,
120 ROUNDED_BOTTOMRIGHT = CORNER_BR,
121 ROUNDED_TOPLEFT = CORNER_TL,
122 ROUNDED_BOTTOMLEFT = CORNER_BL,
123 ROUNDED_ALL = CORNER_TL | CORNER_TR | CORNER_BR | CORNER_BL,
124 };
125
126 QTC_ALWAYS_INLINE static inline bool
qtcUseBorder(EGradientBorder border)127 qtcUseBorder(EGradientBorder border)
128 {
129 return QtCurve::noneOf(border, GB_SHINE, GB_NONE);
130 }
131
132 QTC_ALWAYS_INLINE static inline bool
qtcNoFrame(EFrame frame)133 qtcNoFrame(EFrame frame)
134 {
135 return QtCurve::oneOf(frame, FRAME_NONE, FRAME_LINE);
136 }
137
138 QTC_ALWAYS_INLINE static inline bool
qtcIsFlatBgnd(EAppearance appear)139 qtcIsFlatBgnd(EAppearance appear)
140 {
141 return QtCurve::oneOf(appear, APPEARANCE_FLAT, APPEARANCE_RAISED);
142 }
143
144 QTC_ALWAYS_INLINE static inline bool
qtcIsFlat(EAppearance appear)145 qtcIsFlat(EAppearance appear)
146 {
147 return qtcIsFlatBgnd(appear) || appear == APPEARANCE_FADE;
148 }
149
150 /**
151 * Number of scrollbar buttons.
152 **/
153 QTC_ALWAYS_INLINE static inline int
qtcScrollbarButtonNum(EScrollbar type)154 qtcScrollbarButtonNum(EScrollbar type)
155 {
156 switch (type) {
157 default:
158 case SCROLLBAR_KDE:
159 return 3;
160 case SCROLLBAR_WINDOWS:
161 case SCROLLBAR_PLATINUM:
162 case SCROLLBAR_NEXT:
163 return 2;
164 case SCROLLBAR_NONE:
165 return 0;
166 }
167 }
168
169 /**
170 * Number of scrollbar button we leave space for.
171 * Some applications (e.g. choqok) use the minimum size of scrollbar to
172 * determine the height of input area. Setting a lower limit on this makes
173 * sure that the calculated minimum size is not too small.
174 * See https://github.com/QtCurve/qtcurve-qt4/issues/7
175 * and https://bugs.kde.org/show_bug.cgi?id=317690
176 **/
177 QTC_ALWAYS_INLINE static inline int
qtcScrollbarButtonNumSize(EScrollbar type)178 qtcScrollbarButtonNumSize(EScrollbar type)
179 {
180 return qtcMax(qtcScrollbarButtonNum(type), 2);
181 }
182
183 /**
184 * shadow size control for X11.
185 **/
186
187 void
188 qtcX11SetShadowSize(int);
189 int
190 qtcX11ShadowSize();
191
192 namespace QtCurve {
193 namespace Config {
194
195 template<typename T> T loadValue(const char *str, T def);
196
197 #define _QTC_CONFIG_DEF_LOAD_VALUE(type, str, def) \
198 type loadValue<type>(const char *str, type def)
199
200 #define QTC_CONFIG_DEF_LOAD_VALUE(type) \
201 template _QTC_CONFIG_DEF_LOAD_VALUE(type, str, def)
202
203 #ifndef __QTC_UTILS_OPTIONS_INTERNAL__
204 extern QTC_CONFIG_DEF_LOAD_VALUE(Shading);
205 extern QTC_CONFIG_DEF_LOAD_VALUE(EScrollbar);
206 extern QTC_CONFIG_DEF_LOAD_VALUE(EFrame);
207 #undef _QTC_CONFIG_DEF_LOAD_VALUE
208 #undef QTC_CONFIG_DEF_LOAD_VALUE
209 #endif
210
211 }
212
213 }
214
215
216 #endif
217