SpectMorph
|
An LED widget. More...
#include <smled.hh>
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 |
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.
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 )
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.
|
explicit |
Constructs a green, round LED widget which will initially be turned on.
parent | The parent widget. |
|
explicit |
Constructor.
Constructs a round LED widget with the supplied color which will initially be turned on.
color | Initial color of the LED. |
parent | The 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.
color | Initial color of the LED. |
state | Sets the State. |
look | Sets the Look. |
shape | Sets the Shape (rectangular or circular). |
parent | The parent widget. |
Led::~Led | ( | ) |
Destructor.
Destroys the LED widget.
QColor SpectMorph::Led::color | ( | ) | const |
Returns LED color.
Returns the current color of the widget.
int SpectMorph::Led::darkFactor | ( | ) | const |
|
protectedvirtual |
Returns the width of the led.
Look SpectMorph::Led::look | ( | ) | const |
|
slot |
Sets the state of the widget to Off.
The widget will be painted immediately.
|
slot |
Sets the state of the widget to On.
The widget will be painted immediately.
|
protected |
Paint the cached antialiased pixmap corresponding to the state if any
|
protectedvirtual |
Paints a circular, flat LED.
|
protectedvirtual |
Paints a circular, raised LED.
|
protectedvirtual |
Paints a rectangular, flat LED.
|
protectedvirtual |
Paints a rectangular LED, either raised or sunken, depending on its argument.
|
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 (
The widget calls the update() method, so it will be updated when entering the main event loop.
color | New 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
darkFactor | should be greater than 100, otherwise the LED becomes lighter in Led::Off state. |
Defaults to 300.
darkFactor | Sets 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.
look | New look of the LED. |
void Led::setShape | ( | Shape | shape | ) |
Set LED shape.
Set the shape of the LED.
shape | The LED shape. |
void Led::setState | ( | State | state | ) |
Shape SpectMorph::Led::shape | ( | ) | const |
State SpectMorph::Led::state | ( | ) | const |
|
slot |
Toggles the state of the led from Off to On or vice versa.
The widget repaints itself immediately.