Add cmake support (not tested)
[kdeartwork.git] / kwin-styles / glow / glowclient.h
blob3c5905a72e034a2e2d43f3894098820d0c1f0692
1 /***************************************************************************
2 glowclient.h - description
3 -------------------
4 begin : Thu Sep 6 2001
5 copyright : (C) 2001 by Henning Burchardt
6 email : h_burchardt@gmx.net
7 ***************************************************************************/
9 /***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
18 #ifndef GLOW_CLIENT_H
19 #define GLOW_CLIENT_H
21 #include <vector>
22 #include <map>
23 #include <kdecoration.h>
24 #include <kdecorationfactory.h>
25 #include <kcommondecoration.h>
26 //Added by qt3to4:
27 #include <QPixmap>
28 #include <QPaintEvent>
29 #include <QGridLayout>
30 #include <QEvent>
31 #include <QBoxLayout>
32 #include <Q3ValueList>
33 #include <QShowEvent>
34 #include <QVBoxLayout>
35 #include <QResizeEvent>
36 #include <QMouseEvent>
38 class QPixmap;
39 class QBitmap;
40 class QTimer;
41 class QBoxLayout;
42 class QGridLayout;
43 class QVBoxLayout;
44 class QSpacerItem;
46 namespace Glow
49 class GlowButton;
50 class GlowButtonFactory;
52 //-----------------------------------------------------------------------------
53 // GlowTheme
54 //-----------------------------------------------------------------------------
56 struct GlowTheme
58 QSize buttonSize;
60 QString backgroundPixmap;
61 QString backgroundAlphaPixmap;
63 QString stickyOnPixmap;
64 QString stickyOffPixmap;
65 QString maximizeOnPixmap;
66 QString maximizeOffPixmap;
67 QString helpPixmap;
68 QString closePixmap;
69 QString iconifyPixmap;
71 QString stickyOnGlowPixmap;
72 QString stickyOffGlowPixmap;
73 QString maximizeOnGlowPixmap;
74 QString maximizeOffGlowPixmap;
75 QString helpGlowPixmap;
76 QString closeGlowPixmap;
77 QString iconifyGlowPixmap;
80 static GlowTheme default_glow_theme = {
81 QSize (17, 17),
82 "background.png", "background_alpha.png",
83 "stickyon.png", "stickyoff.png",
84 "maximizeon.png", "maximizeoff.png",
85 "help.png", "close.png", "iconify.png",
86 "stickyon_glow.png", "stickyoff_glow.png",
87 "maximizeon_glow.png", "maximizeoff_glow.png",
88 "help_glow.png", "close_glow.png", "iconify_glow.png" };
90 //-----------------------------------------------------------------------------
91 // GlowClientConfig
92 //-----------------------------------------------------------------------------
94 class GlowClientConfig
96 public:
97 GlowClientConfig();
99 void load (KDecorationFactory *factory);
101 QColor stickyButtonGlowColor;
102 QColor helpButtonGlowColor;
103 QColor iconifyButtonGlowColor;
104 QColor maximizeButtonGlowColor;
105 QColor closeButtonGlowColor;
106 bool showResizeHandle;
107 int titlebarGradientType;
108 QString themeName;
111 //-----------------------------------------------------------------------------
112 // GlowClientGlobals
113 //-----------------------------------------------------------------------------
115 class GlowClientGlobals : public KDecorationFactory
117 public:
118 enum PixmapType { StickyOn, StickyOff, Help, Iconify, MaximizeOn,
119 MaximizeOff, Close };
121 static GlowClientGlobals *instance();
123 ~GlowClientGlobals();
125 virtual KDecoration* createDecoration( KDecorationBridge* b );
126 virtual bool reset( unsigned long changed );
127 virtual bool supports( Ability ability );
128 Q3ValueList< GlowClientGlobals::BorderSize > borderSizes() const;
130 QString getPixmapName(PixmapType type, bool isActive);
132 GlowTheme * theme() const { return _theme; }
133 GlowClientConfig * config() const { return _config; }
134 GlowButtonFactory * buttonFactory() { return _button_factory; }
136 private:
137 static GlowClientGlobals *m_instance;
139 GlowTheme * _theme;
140 GlowClientConfig * _config;
141 GlowButtonFactory * _button_factory;
143 GlowClientGlobals();
144 void readConfig();
145 void readTheme ();
146 bool createPixmaps();
147 void deletePixmaps();
148 bool createPixmap(PixmapType type,bool isActive);
149 const QString getPixmapTypeName(PixmapType type);
152 //-----------------------------------------------------------------------------
153 // GlowClient
154 //-----------------------------------------------------------------------------
156 class GlowClient : public KDecoration
158 Q_OBJECT
159 public:
160 GlowClient( KDecorationBridge* b, KDecorationFactory* f );
161 ~GlowClient();
163 virtual void init();
164 virtual void borders( int&, int&, int&, int& ) const;
165 virtual void resize( const QSize& );
166 virtual QSize minimumSize() const;
168 protected:
169 virtual void resizeEvent( QResizeEvent * );
170 virtual void paintEvent( QPaintEvent * );
171 virtual void showEvent( QShowEvent * );
172 virtual void mouseDoubleClickEvent( QMouseEvent * );
173 virtual void maximizeChange();
174 virtual void activeChange();
175 virtual void iconChange();
176 virtual void desktopChange();
177 virtual void shadeChange();
178 virtual void captionChange();
179 virtual Position mousePosition(const QPoint &) const;
180 virtual bool eventFilter( QObject* o, QEvent* e );
182 private:
183 std::vector<GlowButton*> m_buttonList;
184 std::vector<GlowButton*> m_leftButtonList;
185 std::vector<GlowButton*> m_rightButtonList;
186 GlowButton *m_stickyButton;
187 GlowButton *m_helpButton;
188 GlowButton *m_minimizeButton;
189 GlowButton *m_maximizeButton;
190 GlowButton *m_closeButton;
191 QBoxLayout *m_leftButtonLayout;
192 QBoxLayout *m_rightButtonLayout;
193 QSpacerItem * _bottom_spacer;
194 QSpacerItem * _title_spacer;
195 QVBoxLayout * _main_layout;
197 void createButtons();
198 void updateButtonPositions();
200 * Before this method is called we have to update the button
201 * positions with updateButtonPositions() because the pixmaps
202 * depend on the position
204 void updateButtonPixmaps();
205 void resetLayout();
206 void doShape();
207 bool isLeft(GlowButton *button);
208 bool isRight(GlowButton *button);
210 protected slots:
211 void slotMaximize();
214 } // namespace
216 #endif