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
|
/* SuSE KWin window decoration
Copyright (C) 2005 Gerd Fleischer <[email protected]>
Copyright (C) 2003 Sandro Giessl <[email protected]>
based on the window decoration "Web":
Copyright (C) 2001 Rik Hemsley (rikkus) <[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 St, Fifth Floor,
Boston, MA 02110-1301 USA.
*/
#ifndef SUSE2BUTTON_H
#define SUSE2BUTTON_H
#include <qbutton.h>
#include <qpixmap.h>
#include <kcommondecoration.h>
#include "SUSE2.h"
class QTimer;
namespace KWinSUSE2 {
static const uint TIMERINTERVAL = 50; // msec
static const uint ANIMATIONSTEPS = 4;
class SUSE2Client;
class SUSE2Button : public KCommonDecorationButton
{
Q_OBJECT
public:
SUSE2Button(ButtonType type, SUSE2Client *parent, const char *name);
~SUSE2Button();
void reset(unsigned long changed);
SUSE2Client *client() { return m_client; }
protected slots:
void animate();
private:
void enterEvent(QEvent *e);
void leaveEvent(QEvent *e);
void drawButton(QPainter *painter);
void drawPlastikBtn(QPainter *painter);
void drawLipstikBtn(QPainter *painter);
void renderBtnContour(QPainter *p, const QRect &r);
void renderBtnSurface(QPainter *p, const QRect &r);
void renderPixel(QPainter *p, const QPoint &pos, const int alpha, const QColor &color,
const int pixelPos, const int active);
void renderGradient(QPainter *p, const QRect &r, const QColor &c1, const QColor &c2,
const int gradient, const int active);
private:
SUSE2Client *m_client;
ButtonIcon m_iconType;
bool hover;
QTimer *animTmr;
uint animProgress;
QPixmap *lipstikCache[8+3*(ANIMATIONSTEPS+1)][2];
};
/**
* This class creates bitmaps which can be used as icons on buttons. The icons
* are "hardcoded".
* Over the previous "Gimp->xpm->QImage->recolor->SmoothScale->QPixmap" solution
* it has the important advantage that icons are more scalable and at the same
* time sharp and not blurred.
*/
class IconEngine
{
public:
static QBitmap icon(ButtonIcon icon, int size);
private:
enum Object {
HorizontalLine,
VerticalLine,
DiagonalLine,
CrossDiagonalLine
};
static void drawObject(QPainter &p, Object object, int x, int y, int length, int lineWidth);
};
} // namespace KWinSUSE2
#endif
// kate: space-indent on; indent-width 4; replace-tabs on;
|