add more spacing
[personal-kdebase.git] / workspace / kwin / clients / plastik / plastikbutton.h
blob395f628c66c67d8f77d43dd9b8e772a402ed03cc
1 /* Plastik KWin window decoration
2 Copyright (C) 2003-2005 Sandro Giessl <sandro@giessl.com>
4 based on the window decoration "Web":
5 Copyright (C) 2001 Rik Hemsley (rikkus) <rik@kde.org>
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; see the file COPYING. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA.
23 #ifndef PLASTIKBUTTON_H
24 #define PLASTIKBUTTON_H
26 #include <QImage>
27 #include "plastik.h"
29 #include <kcommondecoration.h>
31 class QTimer;
33 namespace KWinPlastik {
35 class PlastikClient;
37 class PlastikButton : public KCommonDecorationButton
39 Q_OBJECT
40 public:
41 PlastikButton(ButtonType type, PlastikClient *parent);
42 ~PlastikButton();
44 void reset(unsigned long changed);
45 PlastikClient * client() { return m_client; }
47 protected slots:
48 void animate();
50 protected:
51 void paintEvent(QPaintEvent *);
53 private:
54 void enterEvent(QEvent *e);
55 void leaveEvent(QEvent *e);
56 void drawButton(QPainter *painter);
58 private:
59 PlastikClient *m_client;
60 ButtonIcon m_iconType;
61 bool hover;
63 QTimer *animTmr;
64 uint animProgress;
67 /**
68 * This class creates bitmaps which can be used as icons on buttons. The icons
69 * are "hardcoded".
70 * Over the previous "Gimp->xpm->QImage->recolor->SmoothScale->QPixmap" solution
71 * it has the important advantage that icons are more scalable and at the same
72 * time sharp and not blurred.
74 class IconEngine
76 public:
77 static QBitmap icon(ButtonIcon icon, int size);
79 private:
80 enum Object {
81 HorizontalLine,
82 VerticalLine,
83 DiagonalLine,
84 CrossDiagonalLine
87 static void drawObject(QPainter &p, Object object, int x, int y, int length, int lineWidth);
90 } // namespace KWinPlastik
92 #endif // PLASTIKBUTTON_H