Public Member Functions | Static Protected Member Functions

QwtDialNeedle Class Reference

Base class for needles that can be used in a QwtDial. More...

#include <qwt_dial_needle.h>

Inheritance diagram for QwtDialNeedle:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 QwtDialNeedle ()
 Constructor.
virtual ~QwtDialNeedle ()
 Destructor.
virtual void draw (QPainter *painter, const QPoint &center, int length, double direction, QPalette::ColorGroup cg=QPalette::Active) const =0
virtual void setPalette (const QPalette &)
const QPalette & palette () const

Static Protected Member Functions

static void drawKnob (QPainter *, const QPoint &pos, int width, const QBrush &, bool sunken)
 Draw the knob.

Detailed Description

Base class for needles that can be used in a QwtDial.

QwtDialNeedle is a pointer that indicates a value by pointing to a specific direction.

Qwt is missing a set of good looking needles. Contributions are very welcome.

See also:
QwtDial, QwtCompass

Definition at line 31 of file qwt_dial_needle.h.


Constructor & Destructor Documentation

QwtDialNeedle::QwtDialNeedle (  )

Constructor.

Definition at line 25 of file qwt_dial_needle.cpp.

                            :
    d_palette(QApplication::palette())
{
}
QwtDialNeedle::~QwtDialNeedle (  ) [virtual]

Destructor.

Definition at line 31 of file qwt_dial_needle.cpp.

{
}

Member Function Documentation

virtual void QwtDialNeedle::draw ( QPainter *  painter,
const QPoint &  center,
int  length,
double  direction,
QPalette::ColorGroup  cg = QPalette::Active 
) const [pure virtual]

Draw the needle

Parameters:
painterPainter
centerCenter of the dial, start position for the needle
lengthLength of the needle
directionDirection of the needle, in degrees counter clockwise
cgColor group, used for painting

Implemented in QwtDialSimpleNeedle, QwtCompassMagnetNeedle, and QwtCompassWindArrow.

Referenced by QwtAnalogClock::drawHand(), and QwtDial::drawNeedle().

void QwtDialNeedle::drawKnob ( QPainter *  painter,
const QPoint &  pos,
int  width,
const QBrush &  brush,
bool  sunken 
) [static, protected]

Draw the knob.

Definition at line 54 of file qwt_dial_needle.cpp.

Referenced by QwtDialSimpleNeedle::drawArrowNeedle(), QwtDialSimpleNeedle::drawRayNeedle(), and QwtCompassMagnetNeedle::drawThinNeedle().

{
    painter->save();

    QRect rect(0, 0, width, width);
    rect.moveCenter(pos);

    painter->setPen(Qt::NoPen);
    painter->setBrush(brush);
    painter->drawEllipse(rect);

    painter->setBrush(Qt::NoBrush);

    const int colorOffset = 20;

    int startAngle = 45;
    if ( sunken )
        startAngle += 180;

    QPen pen;
    pen.setWidth(1);

    pen.setColor(brush.color().dark(100 - colorOffset));
    painter->setPen(pen);
    painter->drawArc(rect, startAngle * 16, 180 * 16);

    pen.setColor(brush.color().dark(100 + colorOffset));
    painter->setPen(pen);
    painter->drawArc(rect, (startAngle + 180) * 16, 180 * 16);

    painter->restore();
}
const QPalette & QwtDialNeedle::palette (  ) const
void QwtDialNeedle::setPalette ( const QPalette &  palette ) [virtual]

Sets the palette for the needle.

Parameters:
paletteNew Palette

Definition at line 40 of file qwt_dial_needle.cpp.

References palette().

Referenced by QwtCompassMagnetNeedle::QwtCompassMagnetNeedle(), QwtCompassWindArrow::QwtCompassWindArrow(), and QwtDialSimpleNeedle::QwtDialSimpleNeedle().

{ 
    d_palette = palette; 
}

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines