1 /***************************************************************************
2 glowclient.h - description
5 copyright : (C) 2001 by Henning Burchardt
6 email : h_burchardt@gmx.net
7 ***************************************************************************/
9 /***************************************************************************
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. *
16 ***************************************************************************/
23 #include <kdecoration.h>
24 #include <kdecorationfactory.h>
25 #include <kcommondecoration.h>
28 #include <QPaintEvent>
29 #include <QGridLayout>
32 #include <Q3ValueList>
34 #include <QVBoxLayout>
35 #include <QResizeEvent>
36 #include <QMouseEvent>
50 class GlowButtonFactory
;
52 //-----------------------------------------------------------------------------
54 //-----------------------------------------------------------------------------
60 QString backgroundPixmap
;
61 QString backgroundAlphaPixmap
;
63 QString stickyOnPixmap
;
64 QString stickyOffPixmap
;
65 QString maximizeOnPixmap
;
66 QString maximizeOffPixmap
;
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
= {
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 //-----------------------------------------------------------------------------
92 //-----------------------------------------------------------------------------
94 class 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
;
111 //-----------------------------------------------------------------------------
113 //-----------------------------------------------------------------------------
115 class GlowClientGlobals
: public KDecorationFactory
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
; }
137 static GlowClientGlobals
*m_instance
;
140 GlowClientConfig
* _config
;
141 GlowButtonFactory
* _button_factory
;
146 bool createPixmaps();
147 void deletePixmaps();
148 bool createPixmap(PixmapType type
,bool isActive
);
149 const QString
getPixmapTypeName(PixmapType type
);
152 //-----------------------------------------------------------------------------
154 //-----------------------------------------------------------------------------
156 class GlowClient
: public KDecoration
160 GlowClient( KDecorationBridge
* b
, KDecorationFactory
* f
);
164 virtual void borders( int&, int&, int&, int& ) const;
165 virtual void resize( const QSize
& );
166 virtual QSize
minimumSize() const;
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
);
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();
207 bool isLeft(GlowButton
*button
);
208 bool isRight(GlowButton
*button
);