kled.h
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 * $Id$ 00021 *************************************************************************/ 00022 00023 #ifndef _KLED_H_ 00024 #define _KLED_H_ 00025 00026 #include <tqwidget.h> 00027 #include <tdelibs_export.h> 00028 00029 class TQColor; 00045 class TDEUI_EXPORT KLed : public TQWidget 00046 { 00047 Q_OBJECT 00048 TQ_ENUMS( State Shape Look ) 00049 TQ_PROPERTY( State state READ state WRITE setState ) 00050 TQ_PROPERTY( Shape shape READ shape WRITE setShape ) 00051 TQ_PROPERTY( Look look READ look WRITE setLook ) 00052 TQ_PROPERTY( TQColor color READ color WRITE setColor ) 00053 TQ_PROPERTY( TQColor offColor READ color WRITE setOffColor ) 00054 TQ_PROPERTY( int darkFactor READ darkFactor WRITE setDarkFactor ) 00055 00056 public: 00057 00062 enum State { Off, On }; 00063 00068 enum Shape { Rectangular, Circular }; 00069 00090 enum Look { Flat, Raised, Sunken }; 00091 00096 KLed(TQWidget *parent=0, const char *name=0); 00107 KLed(const TQColor &col, TQWidget *parent=0, const char *name=0); 00108 00123 KLed(const TQColor& col, KLed::State state, KLed::Look look, KLed::Shape shape, 00124 TQWidget *parent=0, const char *name=0); 00125 00126 00131 ~KLed(); 00132 00139 State state() const; 00140 00141 Shape shape() const; 00142 00149 TQColor color() const; 00150 00157 TQColor offColor() const; 00158 00165 Look look() const; 00166 00173 int darkFactor() const; 00174 00184 void setState( State state ); 00185 00189 void setShape(Shape s); 00198 void toggleState() KDE_DEPRECATED; 00199 00213 void setColor(const TQColor& color); 00214 00230 void setOffColor(const TQColor& color); 00231 00244 void setDarkFactor(int darkfactor); 00245 00276 void setLook( Look look ); 00277 00278 virtual TQSize sizeHint() const; 00279 virtual TQSize minimumSizeHint() const; 00280 00281 public slots: 00282 00288 void toggle(); 00289 00296 void on(); 00297 00304 void off(); 00305 00306 protected: 00310 virtual void paintFlat(); 00314 virtual void paintRound(); 00318 virtual void paintSunken(); 00322 virtual void paintRect(); 00327 virtual void paintRectFrame(bool raised); 00328 00329 void paintEvent( TQPaintEvent * ); 00330 00334 int ensureRoundLed(); 00335 00340 bool paintCachedPixmap(); 00341 00342 private: 00343 State led_state; 00344 TQColor led_color; 00345 TQColor led_off_color; 00346 Look led_look; 00347 Shape led_shape; 00348 00349 protected: 00350 virtual void virtual_hook( int id, void* data ); 00351 private: 00352 class KLedPrivate; 00353 KLedPrivate *d; 00354 }; 00355 00356 #endif