kdeui Library API Documentation

KLed Class Reference

An LED widget. More...

#include <kled.h>

Inheritance diagram for KLed:

QWidget List of all members.

Public Types

enum  State { Off, On }
enum  Shape { Rectangular, Circular }
enum  Look { Flat, Raised, Sunken }

Public Slots

void toggle ()
void on ()
void off ()

Public Methods

 KLed (QWidget *parent=0, const char *name=0)
 KLed (const QColor &col, QWidget *parent=0, const char *name=0)
 KLed (const QColor &col, KLed::State state, KLed::Look look, KLed::Shape shape, QWidget *parent=0, const char *name=0)
 ~KLed ()
State state () const
Shape shape () const
QColor color () const
Look look () const
int darkFactor () const
void setState (State state)
void setShape (Shape s)
void toggleState () KDE_DEPRECATED
void setColor (const QColor &color)
void setDarkFactor (int darkfactor)
void setLook (Look look)
virtual QSize sizeHint () const
virtual QSize minimumSizeHint () const

Protected Methods

virtual void paintFlat ()
virtual void paintRound ()
virtual void paintSunken ()
virtual void paintRect ()
virtual void paintRectFrame (bool raised)
void paintEvent (QPaintEvent *)
virtual void virtual_hook (int id, void *data)

Detailed Description

An LED widget.

Displays a round or rectangular light emitting diode.

It is configurable to five colors, the two on/off states and three styles (or "looks");

It may display itself in a performant flat view, a round view with light spot or a round view sunken in the screen.

kled.png

KDE LED Widget

Author:
Joerg Habenicht, Richard J. Moore (rich@kde.org) 1998, 1999

Definition at line 45 of file kled.h.


Member Enumeration Documentation

enum KLed::State
 

Status of the light is on/off. LED on/off.

Definition at line 61 of file kled.h.

Referenced by KLed().

enum KLed::Shape
 

Shades of the lamp. LED shape.

Definition at line 67 of file kled.h.

Referenced by KLed(), and setShape().

enum KLed::Look
 

Displays a flat, round or sunken LED. LED look.

Displaying the LED flat is less time and color consuming, but not so nice to see.

The sunken LED itself is (certainly) smaller than the round LED because of the 3 shading circles and is most time consuming. Makes sense for LED > 15x15 pixels.

Timings:
( AMD K5/133, Diamond Stealth 64 PCI Graphics, widgetsize 29x29 )

  • flat Approximately 0.7 msec per paint
  • round Approximately 2.9 msec per paint
  • sunken Approximately 3.3 msec per paint
The widget will be updated on the next repaining event.

Definition at line 89 of file kled.h.

Referenced by KLed().


Constructor & Destructor Documentation

KLed::KLed QWidget   parent = 0,
const char *    name = 0
 

Constructs a green, round LED widget which will initially be turned on.

Definition at line 51 of file kled.cpp.

References QColor::dark(), and setColor().

KLed::KLed const QColor   col,
QWidget   parent = 0,
const char *    name = 0
 

Constructor with the ledcolor, the parent widget, and the name. Constructor.

The State will be defaulted On and the Look round.

Parameters:
col  Initial color of the LED.
parent  Will be handed over to QWidget.
name  Will be handed over to QWidget.

Definition at line 66 of file kled.cpp.

References QColor::dark(), and setColor().

KLed::KLed const QColor   col,
KLed::State    state,
KLed::Look    look,
KLed::Shape    shape,
QWidget   parent = 0,
const char *    name = 0
 

Constructor with the ledcolor, ledstate, ledlook, the parent widget, and the name. Constructor.

Differs from above only in the parameters, which configure all settings.

Parameters:
col  Initial color of the LED.
state  Sets the State.
look  Sets the Look.
shape  Sets the Shape (rectangular or circular)
parent  Will be handed over to QWidget.
name  Will be handed over to QWidget.

Definition at line 80 of file kled.cpp.

References QColor::dark(), Look, setColor(), Shape, and State.

KLed::~KLed  
 

Destructor Destructor.

Definition at line 96 of file kled.cpp.


Member Function Documentation

KLed::State KLed::state   const
 

Returns the current state of the widget (on/off). Returns LED state.

See also:
State

Definition at line 447 of file kled.cpp.

Referenced by setState().

QColor KLed::color   const
 

Returns the color of the widget Returns LED color.

See also:
Color

Definition at line 459 of file kled.cpp.

KLed::Look KLed::look   const
 

Returns the look of the widget. Returns LED look.

See also:
Look

Definition at line 465 of file kled.cpp.

Referenced by setLook().

int KLed::darkFactor   const
 

Returns the factor to darken the LED. Returns dark factor.

See also:
setDarkFactor()

Definition at line 519 of file kled.cpp.

void KLed::setState State    state
 

Sets the state of the widget to On or Off. Set LED state.

The widget will be painted immediately.

See also:
on() off() toggle() toggleState()
Parameters:
state  The LED state: on or off.

Definition at line 471 of file kled.cpp.

References state(), and QWidget::update().

Referenced by off(), and on().

void KLed::setShape Shape    s
 

Set the shape of the LED to s.

Definition at line 489 of file kled.cpp.

References Shape, and QWidget::update().

void KLed::toggleState  
 

Toggle the state of the LED from Off to On and vice versa. Toggles LED on->off / off->on.

The widget will be repainted when returning to the main event loop. @deprecated, use toggle() instead.

Definition at line 481 of file kled.cpp.

References QWidget::update().

Referenced by toggle().

void KLed::setColor const QColor   color
 

Set the color of the widget. Sets the LED color.

The Color is shown with the KLed::On state. The KLed::Off state is shown with QColor.dark() method

The widget calls the update() method, so it will be updated when entering the main event loop.

See also:
Color
Parameters:
color  New color of the LED.

Definition at line 499 of file kled.cpp.

References QColor::dark(), and QWidget::update().

Referenced by KLed().

void KLed::setDarkFactor int    darkfactor
 

Sets the factor to darken the LED in OFF state. sets the factor to darken the LED.

Same as QColor::dark(). "darkfactor should be greater than 100, else the LED gets lighter in OFF state. Defaults to 300.

See also:
QColor
Parameters:
darkfactor  sets the factor to darken the LED.

Definition at line 509 of file kled.cpp.

References QColor::dark(), and QWidget::update().

void KLed::setLook Look    look
 

Sets the look of the widget. Sets LED look.

The look may be flat, round or sunken. The widget calls the update() method, so it will be updated when entering the main event loop.

See also:
Look
Parameters:
look  New look of the LED.

Definition at line 525 of file kled.cpp.

References look(), and QWidget::update().

void KLed::toggle   [slot]
 

Toggles the state of the led from Off to On or vice versa.

The widget repaints itself immediately.

Definition at line 535 of file kled.cpp.

References toggleState().

void KLed::on   [slot]
 

Sets the state of the widget to On.

The widget will be painted immediately.

See also:
off() toggle() toggleState() setState()

Definition at line 541 of file kled.cpp.

References setState().

void KLed::off   [slot]
 

Sets the state of the widget to Off.

The widget will be painted immediately.

See also:
on() toggle() toggleState() setState()

Definition at line 547 of file kled.cpp.

References setState().

void KLed::paintFlat   [protected, virtual]
 

Paints a circular, flat LED.

Definition at line 156 of file kled.cpp.

References QPainter::begin(), QColor::dark(), QPainter::drawEllipse(), QPainter::end(), QPainter::setBrush(), QPen::setColor(), QBrush::setColor(), QPainter::setPen(), QBrush::setStyle(), and QPen::setWidth().

void KLed::paintRound   [protected, virtual]
 

Paints a circular, raised LED.

Definition at line 202 of file kled.cpp.

References QPainter::begin(), QColor::dark(), QPainter::drawEllipse(), QPainter::end(), QColor::light(), QPainter::setBrush(), QPen::setColor(), QBrush::setColor(), QPainter::setPen(), QBrush::setStyle(), and QPen::setWidth().

void KLed::paintSunken   [protected, virtual]
 

Paints a circular, sunken LED.

Definition at line 287 of file kled.cpp.

References QPainter::begin(), QColor::dark(), QPainter::drawArc(), QPainter::drawEllipse(), QPainter::end(), QColor::light(), QPainter::setBrush(), QPen::setColor(), QBrush::setColor(), QPainter::setPen(), QBrush::setStyle(), and QPen::setWidth().

void KLed::paintRect   [protected, virtual]
 

Paints a rectangular, flat LED.

Definition at line 384 of file kled.cpp.

References QColor::dark(), QPainter::drawLine(), QPainter::drawRect(), QWidget::height(), QPainter::setBrush(), QPainter::setPen(), and QWidget::width().

void KLed::paintRectFrame bool    raised [protected, virtual]
 

Paints a rectangular LED, either raised or sunken, depending on its argument.

Definition at line 415 of file kled.cpp.

References QPainter::drawLine(), QPainter::drawRect(), QPainter::fillRect(), QWidget::height(), QPainter::setPen(), and QWidget::width().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for kdeui Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sun May 16 22:02:18 2004 by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2003