SpectMorph
Classes | Public Types | Public Slots | Public Member Functions | Protected Member Functions | Properties | List of all members
SpectMorph::Led Class Reference

An LED widget. More...

#include <smled.hh>

Inheritance diagram for SpectMorph::Led:

Classes

class  Private
 

Public Types

enum  State { Off, On }
 LED on/off. More...
 
enum  Shape { Rectangular, Circular }
 LED shape. More...
 
enum  Look { Flat, Raised, Sunken }
 LED look. More...
 

Public Slots

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

Public Member Functions

 Led (QWidget *parent=0)
 
 Led (const QColor &color, QWidget *parent=0)
 Constructor. More...
 
 Led (const QColor &color, Led::State state, Led::Look look, Led::Shape shape, QWidget *parent=0)
 Constructor. More...
 
 ~Led ()
 Destructor. More...
 
QColor color () const
 Returns LED color. More...
 
State state () const
 Returns LED state. More...
 
Look look () const
 Returns LED look. More...
 
Shape shape () const
 Returns LED shape. More...
 
int darkFactor () const
 Returns dark factor. More...
 
void setColor (const QColor &color)
 Sets the LED color. More...
 
void setState (State state)
 Set LED state. More...
 
void setLook (Look look)
 Sets LED look. More...
 
void setShape (Shape shape)
 Set LED shape. More...
 
void setDarkFactor (int darkFactor)
 Sets the factor to darken the LED. More...
 
virtual QSize sizeHint () const
 
virtual QSize minimumSizeHint () const
 

Protected Member Functions

virtual int ledWidth () const
 
virtual void paintFlat ()
 
virtual void paintRaised ()
 
virtual void paintSunken ()
 
virtual void paintRect ()
 
virtual void paintRectFrame (bool raised)
 
void paintEvent (QPaintEvent *)
 
void resizeEvent (QResizeEvent *)
 
bool paintCachedPixmap ()
 
void updateCachedPixmap ()
 
void paintLed (Shape shape, Look look)
 

Properties

State state
 
Shape shape
 
Look look
 
QColor color
 
int darkFactor
 

Detailed Description

An LED widget.

Displays a round or rectangular light emitting diode.

It is configurable to arbitrary 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@.nosp@m.kde..nosp@m.org) 1998, 1999

Member Enumeration Documentation

LED 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 shape.

Shades of the lamp.

LED on/off.

Status of the light is on/off.

Constructor & Destructor Documentation

Led::Led ( QWidget *  parent = 0)
explicit

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

Parameters
parentThe parent widget.
Led::Led ( const QColor &  color,
QWidget *  parent = 0 
)
explicit

Constructor.

Constructs a round LED widget with the supplied color which will initially be turned on.

Parameters
colorInitial color of the LED.
parentThe parent widget.
Led::Led ( const QColor &  color,
Led::State  state,
Led::Look  look,
Led::Shape  shape,
QWidget *  parent = 0 
)

Constructor.

Constructor with the color, state and look.

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

Parameters
colorInitial color of the LED.
stateSets the State.
lookSets the Look.
shapeSets the Shape (rectangular or circular).
parentThe parent widget.
Led::~Led ( )

Destructor.

Destroys the LED widget.

Member Function Documentation

QColor SpectMorph::Led::color ( ) const

Returns LED color.

Returns the current color of the widget.

See also
Color
int SpectMorph::Led::darkFactor ( ) const

Returns dark factor.

Returns the factor to darken the LED.

See also
setDarkFactor()
int Led::ledWidth ( ) const
protectedvirtual

Returns the width of the led.

Look SpectMorph::Led::look ( ) const

Returns LED look.

Returns the current look of the widget.

See also
Look
void Led::off ( )
slot

Sets the state of the widget to Off.

The widget will be painted immediately.

See also
on() toggle() setState()
void Led::on ( )
slot

Sets the state of the widget to On.

The widget will be painted immediately.

See also
off() toggle() setState()
bool Led::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
void Led::paintFlat ( )
protectedvirtual

Paints a circular, flat LED.

void Led::paintRaised ( )
protectedvirtual

Paints a circular, raised LED.

void Led::paintRect ( )
protectedvirtual

Paints a rectangular, flat LED.

void Led::paintRectFrame ( bool  raised)
protectedvirtual

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

void Led::paintSunken ( )
protectedvirtual

Paints a circular, sunken LED.

void Led::setColor ( const QColor &  color)

Sets the LED color.

Set the color of the widget.

The LED is shown with Color when in the Led::On state or with the darken Color (

See also
setDarkFactor) in Led::Off state.

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

See also
Color
Parameters
colorNew color of the LED.
void Led::setDarkFactor ( int  darkFactor)

Sets the factor to darken the LED.

Sets the factor to darken the LED in Led::Off state.

The

Parameters
darkFactorshould be greater than 100, otherwise the LED becomes lighter in Led::Off state.

Defaults to 300.

See also
QColor
Parameters
darkFactorSets the factor to darken the LED.
void Led::setLook ( Look  look)

Sets LED look.

Sets the look of the widget.

The look may be Flat, Raised or Sunken.

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

See also
Look
Parameters
lookNew look of the LED.
void Led::setShape ( Shape  shape)

Set LED shape.

Set the shape of the LED.

Parameters
shapeThe LED shape.
void Led::setState ( State  state)

Set LED state.

Sets the state of the widget to On or Off.

The widget will be painted immediately.

See also
on() off() toggle()
Parameters
stateThe LED state: on or off.
Shape SpectMorph::Led::shape ( ) const

Returns LED shape.

Returns the current shape of the widget.

See also
Shape
State SpectMorph::Led::state ( ) const

Returns LED state.

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

See also
State
void Led::toggle ( )
slot

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

The widget repaints itself immediately.


The documentation for this class was generated from the following files: