Debian Codegraph @

src/qled.h

raw symbols SCIP
1 /* LED class adapted from KDE to use under QT
2 *
3 Copyright (C) 1998 Jörg Habenicht ([email protected])
4 Copyright (C) 2010 Christoph Feck <[email protected]>
5 Copyright (C) 2011 Mario Stephan <[email protected]>
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library 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 library 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 Library General Public License for more details.
16
17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. 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 QLed_H
24 #define QLed_H
25
26 #include <QWidget>
27 #include <QPainter>
28
29 class QColor;
30 class QLed : public QWidget
31 {
32 Q_OBJECT
33 Q_ENUMS( State Shape Look )
34
35 public:
36
37 enum State { Off, On };
38
39 enum Shape { Rectangular, Circular };
40
41 enum Look { Flat, Raised, Sunken };
42
43 explicit QLed( QWidget *parent = 0 );
44
45 explicit QLed( const QColor &color, QWidget *parent = 0 );
46
47 QLed( const QColor& color, QLed::State state, QLed::Look look, QLed::Shape shape,
48 QWidget *parent = 0 );
49
50 ~QLed();
51
52 QColor color() const;
53
54 State state() const;
55
56 Look look() const;
57
58 Shape shape() const;
59
60 int darkFactor() const;
61
62 void setColor( const QColor& color );
63
64 void setState( State state );
65
66 void setLook( Look look );
67
68 void setShape( Shape shape );
69
70 void setDarkFactor( int darkFactor );
71
72 virtual QSize sizeHint() const;
73 virtual QSize minimumSizeHint() const;
74
75 public Q_SLOTS:
76
77 void toggle();
78
79 void on();
80
81 void off();
82
83 protected:
84 virtual int ledWidth() const;
85
86 virtual void paintFlat();
87
88 virtual void paintRaised();
89
90 virtual void paintSunken();
91
92 virtual void paintRect();
93
94 virtual void paintRectFrame( bool raised );
95
96 void paintEvent( QPaintEvent* );
97 void resizeEvent( QResizeEvent* );
98
99 bool paintCachedPixmap();
100
101 void updateCachedPixmap();
102
103 void paintLed(Shape shape, Look look);
104
105 private:
106 class Private;
107 Private * const d;
108 QColor overlayColors(const QColor &base, const QColor &paint,
109 QPainter::CompositionMode comp = QPainter::CompositionMode_SourceOver);
110 };
111
112 #endif