~ubuntu-branches/ubuntu/gutsy/kdebase-workspace/gutsy

« back to all changes in this revision

Viewing changes to kwin/clients/plastik/plastikbutton.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2007-09-05 20:45:14 UTC
  • Revision ID: james.westby@ubuntu.com-20070905204514-632hhspl0nvrc84i
Tags: upstream-3.93.0
ImportĀ upstreamĀ versionĀ 3.93.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Plastik KWin window decoration
 
2
  Copyright (C) 2003-2005 Sandro Giessl <sandro@giessl.com>
 
3
 
 
4
  based on the window decoration "Web":
 
5
  Copyright (C) 2001 Rik Hemsley (rikkus) <rik@kde.org>
 
6
 
 
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.
 
11
 
 
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.
 
16
 
 
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.
 
21
 */
 
22
 
 
23
#ifndef PLASTIKBUTTON_H
 
24
#define PLASTIKBUTTON_H
 
25
 
 
26
#include <QImage>
 
27
#include "plastik.h"
 
28
 
 
29
#include <kcommondecoration.h>
 
30
 
 
31
class QTimer;
 
32
 
 
33
namespace KWinPlastik {
 
34
 
 
35
class PlastikClient;
 
36
 
 
37
class PlastikButton : public KCommonDecorationButton
 
38
{
 
39
    Q_OBJECT
 
40
public:
 
41
    PlastikButton(ButtonType type, PlastikClient *parent);
 
42
    ~PlastikButton();
 
43
 
 
44
    void reset(unsigned long changed);
 
45
    PlastikClient * client() { return m_client; }
 
46
 
 
47
protected slots:
 
48
    void animate();
 
49
 
 
50
protected:
 
51
    void paintEvent(QPaintEvent *);
 
52
 
 
53
private:
 
54
    void enterEvent(QEvent *e);
 
55
    void leaveEvent(QEvent *e);
 
56
    void drawButton(QPainter *painter);
 
57
 
 
58
private:
 
59
    PlastikClient *m_client;
 
60
    ButtonIcon m_iconType;
 
61
    bool hover;
 
62
 
 
63
    QTimer *animTmr;
 
64
    uint animProgress;
 
65
};
 
66
 
 
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.
 
73
 */
 
74
class IconEngine
 
75
{
 
76
    public:
 
77
        static QBitmap icon(ButtonIcon icon, int size);
 
78
 
 
79
    private:
 
80
        enum Object {
 
81
            HorizontalLine,
 
82
            VerticalLine,
 
83
            DiagonalLine,
 
84
            CrossDiagonalLine
 
85
        };
 
86
 
 
87
        static void drawObject(QPainter &p, Object object, int x, int y, int length, int lineWidth);
 
88
};
 
89
 
 
90
} // namespace KWinPlastik
 
91
 
 
92
#endif // PLASTIKBUTTON_H