• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

kdeui

KLed Class Reference

An LED widget. More...

#include <kled.h>

Inheritance diagram for KLed:

Inheritance graph
[legend]

List of all members.


Public Types

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

Public Slots

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

Public Member Functions

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

Protected Member Functions

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

Properties

QColor color
int darkFactor
Look look
Shape shape
State state

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::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.

LED look.

Enumerator:
Flat 
Raised 
Sunken 

Definition at line 89 of file kled.h.

enum KLed::Shape

Shades of the lamp.

LED shape

Enumerator:
Rectangular 
Circular 

Definition at line 67 of file kled.h.

enum KLed::State

Status of the light is on/off.

LED on/off.

Enumerator:
Off 
On 

Definition at line 61 of file kled.h.


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 50 of file kled.cpp.

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

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

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. Constructor

Definition at line 67 of file kled.cpp.

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.

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. Constructor

Definition at line 83 of file kled.cpp.

KLed::~KLed (  ) 

Destructor.

Destructor

Definition at line 101 of file kled.cpp.


Member Function Documentation

QColor KLed::color (  )  const

Returns the color of the widget.

See also:
Color Returns LED color.

int KLed::darkFactor (  )  const

Returns the factor to darken the LED.

See also:
setDarkFactor() Returns dark factor

int KLed::ensureRoundLed (  )  [protected]

Compute LED width.

Definition at line 163 of file kled.cpp.

Look KLed::look (  )  const

Returns the look of the widget.

See also:
Look Returns LED look.

QSize KLed::minimumSizeHint ( void   )  const [virtual]

Reimplemented from QWidget.

Definition at line 636 of file kled.cpp.

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 624 of file kled.cpp.

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 618 of file kled.cpp.

bool KLed::paintCachedPixmap (  )  [protected]

Paint the cached antialiased pixmap corresponding to the state if any.

Returns:
true if the pixmap was painted, false if it hasn't been created yet

Definition at line 179 of file kled.cpp.

void KLed::paintEvent ( QPaintEvent *   )  [protected]

Reimplemented from QWidget.

Definition at line 109 of file kled.cpp.

void KLed::paintFlat (  )  [protected, virtual]

Paints a circular, flat LED.

Definition at line 199 of file kled.cpp.

void KLed::paintRect (  )  [protected, virtual]

Paints a rectangular, flat LED.

Definition at line 459 of file kled.cpp.

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

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

Definition at line 490 of file kled.cpp.

void KLed::paintRound (  )  [protected, virtual]

Paints a circular, raised LED.

Definition at line 257 of file kled.cpp.

void KLed::paintSunken (  )  [protected, virtual]

Paints a circular, sunken LED.

Definition at line 352 of file kled.cpp.

void KLed::setColor ( const QColor &  color  ) 

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.

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

Definition at line 572 of file kled.cpp.

void KLed::setDarkFactor ( int  darkfactor  ) 

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.

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

Definition at line 584 of file kled.cpp.

void KLed::setLook ( Look  look  ) 

Sets the color of the widget.

The Color is shown with the KLed::On state. darkcolor is explicidly used for the off state of the LED. Normally you don't have to use this method, the setColor(const QColor& color) is sufficient for the task.

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

See also:
Color setColor()
Parameters:
color New color of the LED used for on state.
darkcolor Dark color of the LED used for off state. Sets the light and dark LED color. void setColor(const QColor& color, const QColor& darkcolor); 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.

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

Definition at line 600 of file kled.cpp.

void KLed::setShape ( KLed::Shape  s  ) 

Set the shape of the LED to s.

Definition at line 562 of file kled.cpp.

void KLed::setState ( State  state  ) 

Sets the state of the widget to On or Off.

The widget will be painted immediately.

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

Definition at line 546 of file kled.cpp.

Shape KLed::shape (  )  const

QSize KLed::sizeHint ( void   )  const [virtual]

Reimplemented from QWidget.

Definition at line 630 of file kled.cpp.

State KLed::state (  )  const

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

See also:
State Returns LED state.

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 610 of file kled.cpp.

void KLed::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. Toggles LED on->off / off->on.

Deprecated:
, use toggle() instead.

Definition at line 556 of file kled.cpp.

void KLed::virtual_hook ( int  id,
void *  data 
) [protected, virtual]

Definition at line 641 of file kled.cpp.


Property Documentation

QColor KLed::color [read, write]

Definition at line 52 of file kled.h.

int KLed::darkFactor [read, write]

Definition at line 53 of file kled.h.

KLed::Look KLed::look [read, write]

Definition at line 51 of file kled.h.

KLed::Shape KLed::shape [read, write]

Definition at line 50 of file kled.h.

KLed::State KLed::state [read, write]

Definition at line 49 of file kled.h.


The documentation for this class was generated from the following files:
  • kled.h
  • kled.cpp

kdeui

Skip menu "kdeui"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • dcop
  • DNSSD
  • interfaces
  • Kate
  • kconf_update
  • KDECore
  • KDED
  • kdefx
  • KDEsu
  • kdeui
  • KDocTools
  • KHTML
  • KImgIO
  • KInit
  • kio
  • kioslave
  • KJS
  • KNewStuff
  • KParts
  • KUtils
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal