1 /*****************************************************************************
2  *   Copyright 2007 - 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 __QTCURVESHADOWCONFIGURATION_H__
24 #define __QTCURVESHADOWCONFIGURATION_H__
25 
26 #include <QPalette>
27 #ifdef midColor
28 #undef midColor
29 #endif
30 
31 class KConfig;
32 
33 namespace QtCurve {
34 namespace KWin {
35 
36 class ShadowConfig {
37 public:
38     enum ColorType {
39         CT_FOCUS = 0,
40         CT_HOVER = 1,
41         CT_SELECTION = 2,
42         CT_TITLEBAR = 3,
43         CT_GRAY = 4,
44         CT_CUSTOM = 5
45     };
46 
47     enum ShadowType {
48         SH_ACTIVE = 0,
49         SH_INACTIVE = 1
50     };
51 
52     enum {
53         MIN_SIZE = 10,
54         MAX_SIZE = 100,
55         MIN_OFFSET = 0,
56         MAX_OFFSET = 20
57     };
58 
59     ShadowConfig(QPalette::ColorGroup);
60 
61     void                 defaults();
62     void                 load(KConfig *cfg);
63     void                 save(KConfig *cfg);
64 
colorGroup()65     QPalette::ColorGroup colorGroup() const           { return m_colorGroup; }
shadowSize()66     int                  shadowSize() const           { return m_size; }
setShadowSize(int v)67     void                 setShadowSize(int v)         { m_size = v; }
horizontalOffset()68     int                  horizontalOffset() const     { return m_hOffset; }
setHorizontalOffset(int v)69     void                 setHorizontalOffset(int v)   { m_hOffset = v; }
verticalOffset()70     int                  verticalOffset() const       { return m_vOffset; }
setVerticalOffset(int v)71     void                 setVerticalOffset(int v)     { m_vOffset = v; }
setColor(const QColor & c)72     void                 setColor(const QColor &c)    { m_color=c; }
color()73     const QColor &       color() const                { return m_color; }
colorType()74     ColorType            colorType() const            { return (ColorType)m_colorType; }
75     void                 setColorType(ColorType ct);
shadowType()76     ShadowType           shadowType() const           { return (ShadowType)m_shadowType; }
setShadowType(ShadowType st)77     void                 setShadowType(ShadowType st) { m_shadowType=st; }
78 
79     // Keep compatible with Oxygen Shadow Cache code...
innerColor()80     const QColor &       innerColor() const           { return m_color; }
midColor()81     const QColor &       midColor() const             { return m_color; }
outerColor()82     const QColor &       outerColor() const           { return m_color; }
83 
84     bool operator == (const ShadowConfig& other) const
85     {
86         return  m_colorGroup == other.m_colorGroup &&
87                 m_size == other.m_size &&
88                 m_hOffset == other.m_hOffset &&
89                 m_vOffset == other.m_vOffset &&
90                 m_color == other.m_color &&
91                 m_shadowType == other.m_shadowType;
92     }
93 
94 private:
95     QPalette::ColorGroup m_colorGroup;
96     int                  m_size,
97                          m_hOffset,
98                          m_vOffset,
99                          m_colorType,
100                          m_shadowType;
101     QColor               m_color;
102 };
103 
104 }
105 }
106 
107 #endif
108