svgui
1.9
|
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 #include "base/Debug.h" 00033 00034 class QColor; 00035 00036 class LEDButton : public QWidget 00037 { 00038 Q_OBJECT 00039 Q_PROPERTY(QColor color READ color WRITE setColor) 00040 Q_PROPERTY(int darkFactor READ darkFactor WRITE setDarkFactor) 00041 00042 public: 00043 LEDButton(QWidget *parent = 0); 00044 LEDButton(const QColor &col, QWidget *parent = 0); 00045 LEDButton(const QColor& col, bool state, QWidget *parent = 0); 00046 ~LEDButton(); 00047 00048 bool state() const; 00049 QColor color() const; 00050 int darkFactor() const; 00051 00052 virtual QSize sizeHint() const; 00053 virtual QSize minimumSizeHint() const; 00054 00055 signals: 00056 void stateChanged(bool); 00057 00058 void mouseEntered(); 00059 void mouseLeft(); 00060 00061 public slots: 00062 void toggle(); 00063 void on(); 00064 void off(); 00065 00066 void setState(bool); 00067 void toggleState(); 00068 void setColor(const QColor& color); 00069 void setDarkFactor(int darkfactor); 00070 00071 protected: 00072 void paintEvent(QPaintEvent *); 00073 void mousePressEvent(QMouseEvent *); 00074 void enterEvent(QEvent *); 00075 void leaveEvent(QEvent *); 00076 00077 bool led_state; 00078 QColor led_color; 00079 00080 class LEDButtonPrivate; 00081 LEDButtonPrivate *d; 00082 }; 00083 00084 #endif