KDEUI
kled.h
Go to the documentation of this file.
00001 /* This file is part of the KDE libraries 00002 Copyright (C) 1998 Jörg Habenicht (j.habenicht@europemail.com) 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #ifndef KLED_H 00021 #define KLED_H 00022 00023 #include <kdeui_export.h> 00024 00025 #include <QtGui/QWidget> 00026 00027 class QColor; 00028 00044 class KDEUI_EXPORT KLed : public QWidget 00045 { 00046 Q_OBJECT 00047 Q_ENUMS( State Shape Look ) 00048 Q_PROPERTY( State state READ state WRITE setState ) 00049 Q_PROPERTY( Shape shape READ shape WRITE setShape ) 00050 Q_PROPERTY( Look look READ look WRITE setLook ) 00051 Q_PROPERTY( QColor color READ color WRITE setColor ) 00052 Q_PROPERTY( int darkFactor READ darkFactor WRITE setDarkFactor ) 00053 00054 public: 00055 00060 enum State { Off, On }; 00061 00066 enum Shape { Rectangular, Circular }; 00067 00088 enum Look { Flat, Raised, Sunken }; 00089 00096 explicit KLed( QWidget *parent = 0 ); 00097 00106 explicit KLed( const QColor &color, QWidget *parent = 0 ); 00107 00120 KLed( const QColor& color, KLed::State state, KLed::Look look, KLed::Shape shape, 00121 QWidget *parent = 0 ); 00122 00127 ~KLed(); 00128 00135 QColor color() const; 00136 00143 State state() const; 00144 00151 Look look() const; 00152 00159 Shape shape() const; 00160 00167 int darkFactor() const; 00168 00184 void setColor( const QColor& color ); 00185 00195 void setState( State state ); 00196 00210 void setLook( Look look ); 00211 00218 void setShape( Shape shape ); 00219 00233 void setDarkFactor( int darkFactor ); 00234 00235 virtual QSize sizeHint() const; 00236 virtual QSize minimumSizeHint() const; 00237 00238 public Q_SLOTS: 00239 00245 void toggle(); 00246 00253 void on(); 00254 00261 void off(); 00262 00263 protected: 00267 virtual int ledWidth() const; 00268 00272 virtual void paintFlat(); 00273 00277 virtual void paintRaised(); 00278 00282 virtual void paintSunken(); 00283 00287 virtual void paintRect(); 00288 00293 virtual void paintRectFrame( bool raised ); 00294 00295 void paintEvent( QPaintEvent* ); 00296 void resizeEvent( QResizeEvent* ); 00297 00302 bool paintCachedPixmap(); 00303 00308 void updateCachedPixmap(); 00309 00313 void paintLed(Shape shape, Look look); 00314 00315 private: 00316 class Private; 00317 Private * const d; 00318 }; 00319 00320 #endif
KDE 4.6 API Reference