LEDButton.h

Go to the documentation of this file.
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
00002 
00003 /*
00004     Sonic Visualiser
00005     An audio file viewer and annotation editor.
00006     Centre for Digital Music, Queen Mary, University of London.
00007     
00008     This program is free software; you can redistribute it and/or
00009     modify it under the terms of the GNU General Public License as
00010     published by the Free Software Foundation; either version 2 of the
00011     License, or (at your option) any later version.  See the file
00012     COPYING included with this distribution for more information.
00013 */
00014 
00015 /*
00016     This is a modified version of a source file from the KDE
00017     libraries.  Copyright (c) 1998-2004 Jörg Habenicht, Richard J
00018     Moore and others, distributed under the GNU Lesser General Public
00019     License.
00020 
00021     Ported to Qt4 by Chris Cannam.
00022 
00023     The original KDE widget comes in round and rectangular and flat,
00024     raised, and sunken variants.  This version retains only the round
00025     sunken variant.  This version also implements a simple button API.
00026 */
00027 
00028 #ifndef _LED_BUTTON_H_
00029 #define _LED_BUTTON_H_
00030 
00031 #include <QWidget>
00032 
00033 class QColor;
00034 
00035 class LEDButton : public QWidget
00036 {
00037     Q_OBJECT
00038     Q_PROPERTY(QColor color READ color WRITE setColor)
00039     Q_PROPERTY(int darkFactor READ darkFactor WRITE setDarkFactor)
00040 
00041 public:
00042     LEDButton(QWidget *parent = 0);
00043     LEDButton(const QColor &col, QWidget *parent = 0);
00044     LEDButton(const QColor& col, bool state, QWidget *parent = 0);
00045     ~LEDButton();
00046 
00047     bool state() const;
00048     QColor color() const;
00049     int darkFactor() const;
00050 
00051     virtual QSize sizeHint() const;
00052     virtual QSize minimumSizeHint() const;
00053 
00054 signals:
00055     void stateChanged(bool);
00056 
00057     void mouseEntered();
00058     void mouseLeft();
00059 
00060 public slots:
00061     void toggle();
00062     void on();
00063     void off();
00064 
00065     void setState(bool);
00066     void toggleState();
00067     void setColor(const QColor& color);
00068     void setDarkFactor(int darkfactor);
00069 
00070 protected:
00071     void paintEvent(QPaintEvent *);
00072     void mousePressEvent(QMouseEvent *);
00073     void enterEvent(QEvent *);
00074     void leaveEvent(QEvent *);
00075 
00076     bool led_state;
00077     QColor led_color;
00078 
00079     class LEDButtonPrivate;
00080     LEDButtonPrivate *d;
00081 };
00082 
00083 #endif

Generated on Wed Feb 20 15:45:26 2008 for SonicVisualiser by  doxygen 1.5.1