1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
|
///////////////////////////////////////////////////////////////////////
// -------------------
// DeKorator window decoration for KDE
// -------------------
// Copyright (C) 2005 moty rahamim <[email protected]>
//
// Based on Example-0.8, some ideas and code have been taken from plastik and KCMicons
//
// Example window decoration for KDE
// Copyright (c) 2003, 2004 David Johnson <[email protected]>
//
// Plastik KWin window decoration
// Copyright (C) 2003-2005 Sandro Giessl <[email protected]>
//
// KCMicons for KDE
// Copyright (c) 2000 Antonio Larrosa <[email protected]>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file COPYING. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301, USA.
///////////////////////////////////////////////////////////////////////
#ifndef DEKORATORCLIENT_H
#define DEKORATORCLIENT_H
#include <qbutton.h>
#include <qbitmap.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qpainter.h>
#include <qtooltip.h>
#include <qpixmap.h>
#include <qapplication.h>
#include <qtimer.h>
#include <qcursor.h>
#include <kdecoration.h>
#include <kdecorationfactory.h>
#include <kconfig.h>
#include <kdeversion.h>
#include <kglobal.h>
#include <kglobalsettings.h>
#include <klocale.h>
#include <kiconeffect.h>
#include <kimageeffect.h>
#include "shadow.h"
class QSpacerItem;
class QPoint;
namespace DeKorator
{
class DeKoratorClient;
enum decoType {
topLeftCorner = 0,
leftButtons,
leftTitle,
midTitle,
rightTitle,
rightButtons,
topRightCorner,
topLeftFrame,
midLeftFrame,
buttomLeftFrame,
leftButtomFrame,
midButtomFrame,
rightButtomFrame,
topRightFrame,
midRightFrame,
buttomRightFrame,
decoCount
};
enum buttonTypeAll {
restore = 0,
help,
max,
min,
close,
sticky,
stickydown,
above,
abovedown,
below,
belowdown,
shade,
shadedown,
menu,
buttonTypeAllCount
};
enum ButtonType {
ButtonHelp = 0,
ButtonMax,
ButtonMin,
ButtonClose,
ButtonMenu,
ButtonSticky,
ButtonAbove,
ButtonBelow,
ButtonShade,
ButtonTypeCount
};
enum pixType {
normal = 0,
actCol,
inActCol,
orig,
pixTypeCount
};
enum buttonState {
regular = 0,
hover,
press,
buttonStateCount
};
// DeKoratorFactory /////////////////////////////////////////////////////////////
class DeKoratorFactory: public KDecorationFactory
{
public:
DeKoratorFactory();
virtual ~DeKoratorFactory();
virtual KDecoration *createDecoration( KDecorationBridge *b );
virtual bool reset( unsigned long changed );
static void colorizePixmap( QPixmap *pix, QColor col, QString colorizeMethod );
static bool initialized();
QBitmap topLeftCornerBitmap_, topMidBitmap_, topRightCornerBitmap_, buttomLeftCornerBitmap_, buttomMidBitmap_, buttomRightCornerBitmap_;
private:
bool readConfig();
void loadPixmaps();
void colorizeDecoPixmaps( bool isActive );
void colorizeButtonsPixmaps( bool isActive );
void initPixmaps();
void chooseRightPixmaps();
void determineSizes();
void prepareDecoWithBgCol();
private:
static bool colorizeActFrames_;
static bool colorizeInActFrames_;
static bool needInit_;
static bool needReload_;
static QString framesPath_;
static QString buttonsPath_;
static QString masksPath_;
public:
static bool initialized_;
static bool useCustomButtonsColors_;
static bool customColorsActiveButtons_;
static bool customColorsInActiveButtons_;
static bool colorizeActButtons_;
static bool colorizeInActButtons_;
static QColor cusBtnCol_[ buttonTypeAllCount ];
};
inline bool DeKoratorFactory::initialized()
{
return initialized_;
}
// DeKoratorButton //////////////////////////////////////////////////////////////
class DeKoratorButton : public QButton
{
Q_OBJECT
public:
DeKoratorButton( bool isLeft, int buttonWidth, int buttonHeight, DeKoratorClient *parent = 0, const char *name = 0,
const QString &tip = NULL, ButtonType type = ButtonHelp, buttonTypeAll btnType = restore );
~DeKoratorButton();
void setPixmap( buttonTypeAll btnType );
QSize sizeHint() const;
ButtonState lastMousePress() const;
void reset();
protected slots:
void animate();
private:
void enterEvent( QEvent *e );
void leaveEvent( QEvent *e );
void mousePressEvent( QMouseEvent *e );
void mouseReleaseEvent( QMouseEvent *e );
void drawButton( QPainter *painter );
QImage* chooseRightHoverEffect( QImage *img, QString res );
private:
bool isLeft_;
int buttonWidth_;
DeKoratorClient *client_;
ButtonType type_;
//QPixmap *decoPix_, *decoPixPress_, *decoPixHover_, *decoPixInAct_;
ButtonState lastmouse_;
int decoPixHeight_;
bool hover_;
QTimer *animTmr;
uint animProgress;
QPixmap *btnPixAct_, *btnPixInAct_;
buttonTypeAll btnType_;
int s;
};
inline Qt::ButtonState DeKoratorButton::lastMousePress() const
{
return lastmouse_;
}
inline void DeKoratorButton::reset()
{
repaint( FALSE );
}
// DeKoratorClient //////////////////////////////////////////////////////////////
class DeKoratorClient : public KDecoration
{
Q_OBJECT
public:
DeKoratorClient( KDecorationBridge *b, KDecorationFactory *f );
virtual ~DeKoratorClient();
virtual void init();
virtual void activeChange();
virtual void desktopChange();
virtual void captionChange();
virtual void iconChange();
virtual void maximizeChange();
virtual void shadeChange();
virtual void borders( int &l, int &r, int &t, int &b ) const;
virtual void resize( const QSize &size );
virtual QSize minimumSize() const;
virtual Position mousePosition( const QPoint &point ) const;
private:
void addButtons( QBoxLayout* layout, const QString& buttons, bool isLeft );
bool eventFilter( QObject *obj, QEvent *e );
void mouseDoubleClickEvent( QMouseEvent *e );
void wheelEvent( QWheelEvent *e );
void paintEvent( QPaintEvent *e );
void resizeEvent( QResizeEvent * );
void showEvent( QShowEvent * );
void doShape();
void updateCaptionBuffer();
private slots:
void maxButtonPressed();
void menuButtonPressed();
void aboveButtonPressed();
void belowButtonPressed();
void shadeButtonPressed();
void keepAboveChange( bool );
void keepBelowChange( bool );
void menuButtonReleased();
private:
DeKoratorButton *button[ ButtonTypeCount ];
QVBoxLayout *mainLayout_;
QHBoxLayout *titleLayout_ ;
QHBoxLayout *midLayout_;
QSpacerItem *leftTitleBarSpacer_, *titleBarSpacer_, *rightTitleBarSpacer_, *leftSpacer_, *rightSpacer_, *bottomSpacer_;
bool closing_;
QPixmap *captionBufferPix_;
bool captionBufferDirty_;
QImage activeShadowImg_, inActiveShadowImg_;
QRegion mask_;
bool sizeChanged;
QSize oldSize_;
public:
DeKoratorFactory *decoFactory_;
};
} // namespace DeKorator
#endif // DEKORATORCLIENT_H
|