class KLed

# class KLed | An LED widget. More...
Definition | `#include <kled.h>`
Inherits | QWidget (qt) [public ]
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

#### Public Types

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

#### Public Methods

- KLed (QWidget *parent=0, const char *name=0)
- KLed (const QColor &col=Qt::green, QWidget *parent=0, const char *name=0)
- KLed (const QColor& col, KLed::State st, 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 ()
- void setColor (const QColor& color)
- void setDarkFactor (int darkfactor)
- void setLook ( Look look )
- virtual QSize sizeHint () const
- virtual QSize minimumSizeHint () const

#### Public Slots

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

#### Protected Methods

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

## Detailed Description

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.

enum State { Off, On } | ### State

Status of the light is on/off.

enum Shape { Rectangular, Circular } | ### Shape

Shades of the lamp.

enum Look { Flat, Raised, Sunken } | ### Look

Displays a flat, round or sunken LED.

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.

KLed (QWidget *parent=0, const char *name=0) | ### KLed

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

KLed (const QColor &col=Qt::green, QWidget *parent=0, const char *name=0) | ### KLed

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

The State will be defaulted On and the Look round.

Parameters:

ledcolor | Initial color of the LED.
parent | Will be handed over to QWidget.
name | Will be handed over to QWidget.

KLed (const QColor& col, KLed::State st, KLed::Look look, KLed::Shape shape, QWidget *parent=0, const char *name=0) | ### KLed

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

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

Parameters:

ledcolor | Initial color of the LED.
state | Sets the State.
look | Sets the Look.
parent | Will be handed over to QWidget.
name | Will be handed over to QWidget.

~KLed () | ### ~KLed

Destructor

State state () | ### state

[const]

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

See also: State

Shape shape () | ### shape

[const]

QColor color () | ### color

[const]

Returns the color of the widget

See also: Color

Look look () | ### look

[const]

Returns the look of the widget.

See also: Look

int darkFactor () | ### darkFactor

[const]

Returns the factor to darken the LED.

See also: setDarkFactor()

void setState ( State state ) | ### setState

Sets the state of the widget to On or Off.

The widget will be painted immediately.

Parameters:

state | The LED state: on or off.

See also: on(), off(), toggle(), toggleState()

void setShape (Shape s) | ### setShape

Set the shape of the LED to `s`.

void toggleState () | ### toggleState

Toggle the state of the LED from Off to On and vice versa.

The widget will be repainted when returning to the main event loop.

void setColor (const QColor& color) | ### setColor

Set the color of the widget. 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.

Parameters:

color | New color of the LED.

See also: Color

void setDarkFactor (int darkfactor) | ### setDarkFactor

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

Parameters:

darkfactor | sets the factor to darken the LED.

See also: QColor

void setLook ( Look look ) | ### setLook

Sets the look of the widget.

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.

Parameters:

look | New look of the LED.

See also: Look

QSize sizeHint () | ### sizeHint

[const virtual]

QSize minimumSizeHint () | ### minimumSizeHint

[const virtual]

void toggle () | ### toggle

[slot]

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

The widget repaints itself immediately.

void on () | ### on

[slot]

Sets the state of the widget to On.

The widget will be painted immediately.

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

void off () | ### off

[slot]

Sets the state of the widget to Off.

The widget will be painted immediately.

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

void paintFlat () | ### paintFlat

[protected virtual]

Paints a circular, flat LED.

void paintRound () | ### paintRound

[protected virtual]

Paints a circular, raised LED.

void paintSunken () | ### paintSunken

[protected virtual]

Paints a circular, sunken LED.

void paintRect () | ### paintRect

[protected virtual]

Paints a rectangular, flat LED.

void paintRectFrame (bool raised) | ### paintRectFrame

[protected virtual]

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

void paintEvent ( QPaintEvent * ) | ### paintEvent

[protected]

void virtual_hook ( int id, void* data ) | ### virtual_hook

[protected virtual]

- Author: Joerg Habenicht, Richard J. Moore (rich@kde.org) 1998, 1999
- Generated: root on macppc.ports.openbsd.org on Sat Sep 6 10:36:37 2003, using kdoc 2.0a54.