File indexing completed on 2024-04-28 05:46:50

0001 /*****************************************************************************
0002  *   Copyright 2003 - 2010 Craig Drummond <craig.p.drummond@gmail.com>       *
0003  *   Copyright 2013 - 2015 Yichao Yu <yyc1992@gmail.com>                     *
0004  *                                                                           *
0005  *   This program is free software; you can redistribute it and/or modify    *
0006  *   it under the terms of the GNU Lesser General Public License as          *
0007  *   published by the Free Software Foundation; either version 2.1 of the    *
0008  *   License, or (at your option) version 3, or any later version accepted   *
0009  *   by the membership of KDE e.V. (or its successor approved by the         *
0010  *   membership of KDE e.V.), which shall act as a proxy defined in          *
0011  *   Section 6 of version 3 of the license.                                  *
0012  *                                                                           *
0013  *   This program is distributed in the hope that it will be useful,         *
0014  *   but WITHOUT ANY WARRANTY; without even the implied warranty of          *
0015  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU       *
0016  *   Lesser General Public License for more details.                         *
0017  *                                                                           *
0018  *   You should have received a copy of the GNU Lesser General Public        *
0019  *   License along with this library. If not,                                *
0020  *   see <http://www.gnu.org/licenses/>.                                     *
0021  *****************************************************************************/
0022 
0023 #ifndef QTC_UTILS_OPTIONS_H
0024 #define QTC_UTILS_OPTIONS_H
0025 
0026 #include "number.h"
0027 
0028 enum class Shading {
0029     Simple,
0030     HSL,
0031     HSV,
0032     HCY,
0033 };
0034 
0035 enum EScrollbar {
0036     SCROLLBAR_KDE,
0037     SCROLLBAR_WINDOWS,
0038     SCROLLBAR_PLATINUM,
0039     SCROLLBAR_NEXT,
0040     SCROLLBAR_NONE
0041 };
0042 
0043 enum EAppearance {
0044     APPEARANCE_CUSTOM1,
0045     APPEARANCE_CUSTOM2,
0046     APPEARANCE_CUSTOM3,
0047     APPEARANCE_CUSTOM4,
0048     APPEARANCE_CUSTOM5,
0049     APPEARANCE_CUSTOM6,
0050     APPEARANCE_CUSTOM7,
0051     APPEARANCE_CUSTOM8,
0052     APPEARANCE_CUSTOM9,
0053     APPEARANCE_CUSTOM10,
0054     APPEARANCE_CUSTOM11,
0055     APPEARANCE_CUSTOM12,
0056     APPEARANCE_CUSTOM13,
0057     APPEARANCE_CUSTOM14,
0058     APPEARANCE_CUSTOM15,
0059     APPEARANCE_CUSTOM16,
0060     APPEARANCE_CUSTOM17,
0061     APPEARANCE_CUSTOM18,
0062     APPEARANCE_CUSTOM19,
0063     APPEARANCE_CUSTOM20,
0064     APPEARANCE_CUSTOM21,
0065     APPEARANCE_CUSTOM22,
0066     APPEARANCE_CUSTOM23,
0067 
0068     NUM_CUSTOM_GRAD,
0069 
0070     APPEARANCE_FLAT = NUM_CUSTOM_GRAD,
0071     APPEARANCE_RAISED,
0072     APPEARANCE_DULL_GLASS,
0073     APPEARANCE_SHINY_GLASS,
0074     APPEARANCE_AGUA,
0075     APPEARANCE_SOFT_GRADIENT,
0076     APPEARANCE_GRADIENT,
0077     APPEARANCE_HARSH_GRADIENT,
0078     APPEARANCE_INVERTED,
0079     APPEARANCE_DARK_INVERTED,
0080     APPEARANCE_SPLIT_GRADIENT,
0081     APPEARANCE_BEVELLED,
0082     APPEARANCE_FADE, /* Only for poupmenu items! */
0083     APPEARANCE_STRIPED = APPEARANCE_FADE, /* Only for windows  and menus */
0084     APPEARANCE_NONE = APPEARANCE_FADE, /* Only for titlebars */
0085     APPEARANCE_FILE, /* Only for windows  and menus */
0086     APPEARANCE_LV_BEVELLED, /* To be used only with qtcGetGradient */
0087     APPEARANCE_AGUA_MOD,
0088     APPEARANCE_LV_AGUA,
0089     NUM_STD_APP = (APPEARANCE_LV_AGUA - NUM_CUSTOM_GRAD) + 1
0090 };
0091 
0092 enum EFrame {
0093     FRAME_NONE,
0094     FRAME_PLAIN,
0095     FRAME_LINE,
0096     FRAME_SHADED,
0097     FRAME_FADED
0098 };
0099 
0100 enum EGradientBorder {
0101     GB_NONE,
0102     GB_LIGHT,
0103     GB_3D,
0104     GB_3D_FULL,
0105     GB_SHINE
0106 };
0107 
0108 enum ECornerBits {
0109     CORNER_TL = 1 << 0,
0110     CORNER_TR = 1 << 1,
0111     CORNER_BR = 1 << 2,
0112     CORNER_BL = 1 << 3,
0113 
0114     ROUNDED_NONE = 0,
0115     ROUNDED_TOP = CORNER_TL | CORNER_TR,
0116     ROUNDED_BOTTOM = CORNER_BL | CORNER_BR,
0117     ROUNDED_LEFT = CORNER_TL | CORNER_BL,
0118     ROUNDED_RIGHT = CORNER_TR | CORNER_BR,
0119     ROUNDED_TOPRIGHT = CORNER_TR,
0120     ROUNDED_BOTTOMRIGHT = CORNER_BR,
0121     ROUNDED_TOPLEFT = CORNER_TL,
0122     ROUNDED_BOTTOMLEFT = CORNER_BL,
0123     ROUNDED_ALL = CORNER_TL | CORNER_TR | CORNER_BR | CORNER_BL,
0124 };
0125 
0126 QTC_ALWAYS_INLINE static inline bool
0127 qtcUseBorder(EGradientBorder border)
0128 {
0129     return QtCurve::noneOf(border, GB_SHINE, GB_NONE);
0130 }
0131 
0132 QTC_ALWAYS_INLINE static inline bool
0133 qtcNoFrame(EFrame frame)
0134 {
0135     return QtCurve::oneOf(frame, FRAME_NONE, FRAME_LINE);
0136 }
0137 
0138 QTC_ALWAYS_INLINE static inline bool
0139 qtcIsFlatBgnd(EAppearance appear)
0140 {
0141     return QtCurve::oneOf(appear, APPEARANCE_FLAT, APPEARANCE_RAISED);
0142 }
0143 
0144 QTC_ALWAYS_INLINE static inline bool
0145 qtcIsFlat(EAppearance appear)
0146 {
0147     return qtcIsFlatBgnd(appear) || appear == APPEARANCE_FADE;
0148 }
0149 
0150 /**
0151  * Number of scrollbar buttons.
0152  **/
0153 QTC_ALWAYS_INLINE static inline int
0154 qtcScrollbarButtonNum(EScrollbar type)
0155 {
0156     switch (type) {
0157     default:
0158     case SCROLLBAR_KDE:
0159         return 3;
0160     case SCROLLBAR_WINDOWS:
0161     case SCROLLBAR_PLATINUM:
0162     case SCROLLBAR_NEXT:
0163         return 2;
0164     case SCROLLBAR_NONE:
0165         return 0;
0166     }
0167 }
0168 
0169 /**
0170  * Number of scrollbar button we leave space for.
0171  * Some applications (e.g. choqok) use the minimum size of scrollbar to
0172  * determine the height of input area. Setting a lower limit on this makes
0173  * sure that the calculated minimum size is not too small.
0174  * See https://github.com/QtCurve/qtcurve-qt4/issues/7
0175  * and https://bugs.kde.org/show_bug.cgi?id=317690
0176  **/
0177 QTC_ALWAYS_INLINE static inline int
0178 qtcScrollbarButtonNumSize(EScrollbar type)
0179 {
0180     return qtcMax(qtcScrollbarButtonNum(type), 2);
0181 }
0182 
0183 /**
0184  * shadow size control for X11.
0185  **/
0186 
0187 void
0188 qtcX11SetShadowSize(int);
0189 int
0190 qtcX11ShadowSize();
0191 
0192 namespace QtCurve {
0193 namespace Config {
0194 
0195 template<typename T> T loadValue(const char *str, T def);
0196 
0197 #define _QTC_CONFIG_DEF_LOAD_VALUE(type, str, def)              \
0198     type loadValue<type>(const char *str, type def)
0199 
0200 #define QTC_CONFIG_DEF_LOAD_VALUE(type)                 \
0201     template _QTC_CONFIG_DEF_LOAD_VALUE(type, str, def)
0202 
0203 #ifndef __QTC_UTILS_OPTIONS_INTERNAL__
0204 extern QTC_CONFIG_DEF_LOAD_VALUE(Shading);
0205 extern QTC_CONFIG_DEF_LOAD_VALUE(EScrollbar);
0206 extern QTC_CONFIG_DEF_LOAD_VALUE(EFrame);
0207 #undef _QTC_CONFIG_DEF_LOAD_VALUE
0208 #undef QTC_CONFIG_DEF_LOAD_VALUE
0209 #endif
0210 
0211 }
0212 
0213 }
0214 
0215 
0216 #endif