You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
196 lines
0 B
196 lines
0 B
15 years ago
|
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||
|
* Qwt Widget Library
|
||
|
* Copyright (C) 1997 Josef Wilgen
|
||
|
* Copyright (C) 2002 Uwe Rathmann
|
||
14 years ago
|
*
|
||
15 years ago
|
* This library is free software; you can redistribute it and/or
|
||
|
* modify it under the terms of the Qwt License, Version 1.0
|
||
|
*****************************************************************************/
|
||
|
|
||
|
#ifndef QWT_DIAL_NEEDLE_H
|
||
|
#define QWT_DIAL_NEEDLE_H 1
|
||
|
|
||
|
#include <qpalette.h>
|
||
|
#include "qwt_global.h"
|
||
|
|
||
|
class QPainter;
|
||
|
class QPoint;
|
||
|
|
||
|
/*!
|
||
|
\brief Base class for needles that can be used in a QwtDial.
|
||
|
|
||
14 years ago
|
QwtDialNeedle is a pointer that indicates a value by pointing
|
||
|
to a specific direction.
|
||
|
|
||
|
Qwt is missing a set of good looking needles.
|
||
15 years ago
|
Contributions are very welcome.
|
||
|
|
||
|
\sa QwtDial, QwtCompass
|
||
|
*/
|
||
|
|
||
|
class QWT_EXPORT QwtDialNeedle
|
||
|
{
|
||
|
public:
|
||
|
QwtDialNeedle();
|
||
|
virtual ~QwtDialNeedle();
|
||
|
|
||
|
/*!
|
||
|
Draw the needle
|
||
|
|
||
|
\param painter Painter
|
||
|
\param center Center of the dial, start position for the needle
|
||
|
\param length Length of the needle
|
||
|
\param direction Direction of the needle, in degrees counter clockwise
|
||
|
\param cg Color group, used for painting
|
||
|
*/
|
||
14 years ago
|
virtual void draw(QPainter *painter, const QPoint ¢er,
|
||
|
int length, double direction,
|
||
|
QPalette::ColorGroup cg = QPalette::Active) const = 0;
|
||
15 years ago
|
|
||
|
virtual void setPalette(const QPalette &);
|
||
14 years ago
|
const QPalette &palette() const;
|
||
15 years ago
|
|
||
|
protected:
|
||
14 years ago
|
static void drawKnob(QPainter *, const QPoint &pos,
|
||
|
int width, const QBrush &, bool sunken);
|
||
15 years ago
|
|
||
|
private:
|
||
|
QPalette d_palette;
|
||
|
};
|
||
|
|
||
|
/*!
|
||
|
\brief A needle for dial widgets
|
||
|
|
||
|
The following colors are used:
|
||
|
- QColorGroup::Mid\n
|
||
|
Pointer
|
||
|
- QColorGroup::base\n
|
||
|
Knob
|
||
|
|
||
|
\sa QwtDial, QwtCompass
|
||
|
*/
|
||
|
|
||
|
class QWT_EXPORT QwtDialSimpleNeedle: public QwtDialNeedle
|
||
|
{
|
||
|
public:
|
||
|
//! Style of the needle
|
||
14 years ago
|
enum Style {
|
||
15 years ago
|
Arrow,
|
||
|
Ray
|
||
|
};
|
||
|
|
||
14 years ago
|
QwtDialSimpleNeedle(Style, bool hasKnob = true,
|
||
|
const QColor &mid = Qt::gray, const QColor &base = Qt::darkGray);
|
||
15 years ago
|
|
||
14 years ago
|
virtual void draw(QPainter *, const QPoint &, int length,
|
||
|
double direction, QPalette::ColorGroup = QPalette::Active) const;
|
||
15 years ago
|
|
||
14 years ago
|
static void drawArrowNeedle(QPainter *,
|
||
|
const QPalette&, QPalette::ColorGroup,
|
||
|
const QPoint &, int length, int width, double direction,
|
||
|
bool hasKnob);
|
||
15 years ago
|
|
||
14 years ago
|
static void drawRayNeedle(QPainter *,
|
||
|
const QPalette&, QPalette::ColorGroup,
|
||
|
const QPoint &, int length, int width, double direction,
|
||
|
bool hasKnob);
|
||
15 years ago
|
|
||
|
void setWidth(int width);
|
||
|
int width() const;
|
||
|
|
||
|
private:
|
||
|
Style d_style;
|
||
|
bool d_hasKnob;
|
||
|
int d_width;
|
||
|
};
|
||
|
|
||
|
/*!
|
||
|
\brief A magnet needle for compass widgets
|
||
|
|
||
|
A magnet needle points to two opposite directions indicating
|
||
|
north and south.
|
||
|
|
||
|
The following colors are used:
|
||
|
- QColorGroup::Light\n
|
||
|
Used for pointing south
|
||
|
- QColorGroup::Dark\n
|
||
|
Used for pointing north
|
||
|
- QColorGroup::Base\n
|
||
|
Knob (ThinStyle only)
|
||
|
|
||
|
\sa QwtDial, QwtCompass
|
||
|
*/
|
||
|
|
||
|
class QWT_EXPORT QwtCompassMagnetNeedle: public QwtDialNeedle
|
||
|
{
|
||
|
public:
|
||
|
//! Style of the needle
|
||
14 years ago
|
enum Style {
|
||
15 years ago
|
TriangleStyle,
|
||
|
ThinStyle
|
||
|
};
|
||
|
QwtCompassMagnetNeedle(Style = TriangleStyle,
|
||
14 years ago
|
const QColor &light = Qt::white, const QColor &dark = Qt::red);
|
||
15 years ago
|
|
||
14 years ago
|
virtual void draw(QPainter *, const QPoint &, int length,
|
||
|
double direction, QPalette::ColorGroup = QPalette::Active) const;
|
||
15 years ago
|
|
||
14 years ago
|
static void drawTriangleNeedle(QPainter *,
|
||
|
const QPalette &, QPalette::ColorGroup,
|
||
|
const QPoint &, int length, double direction);
|
||
15 years ago
|
|
||
|
static void drawThinNeedle(QPainter *,
|
||
14 years ago
|
const QPalette &, QPalette::ColorGroup,
|
||
|
const QPoint &, int length, double direction);
|
||
15 years ago
|
|
||
|
protected:
|
||
|
static void drawPointer(QPainter *painter, const QBrush &brush,
|
||
14 years ago
|
int colorOffset, const QPoint ¢er,
|
||
|
int length, int width, double direction);
|
||
15 years ago
|
|
||
|
private:
|
||
|
Style d_style;
|
||
|
};
|
||
|
|
||
|
/*!
|
||
|
\brief An indicator for the wind direction
|
||
|
|
||
|
QwtCompassWindArrow shows the direction where the wind comes from.
|
||
|
|
||
|
- QColorGroup::Light\n
|
||
|
Used for Style1, or the light half of Style2
|
||
|
- QColorGroup::Dark\n
|
||
|
Used for the dark half of Style2
|
||
|
|
||
|
\sa QwtDial, QwtCompass
|
||
|
*/
|
||
|
|
||
|
class QWT_EXPORT QwtCompassWindArrow: public QwtDialNeedle
|
||
|
{
|
||
|
public:
|
||
|
//! Style of the arrow
|
||
14 years ago
|
enum Style {
|
||
15 years ago
|
Style1,
|
||
|
Style2
|
||
|
};
|
||
|
|
||
|
QwtCompassWindArrow(Style, const QColor &light = Qt::white,
|
||
14 years ago
|
const QColor &dark = Qt::gray);
|
||
15 years ago
|
|
||
|
virtual void draw(QPainter *, const QPoint &, int length,
|
||
14 years ago
|
double direction, QPalette::ColorGroup = QPalette::Active) const;
|
||
15 years ago
|
|
||
14 years ago
|
static void drawStyle1Needle(QPainter *,
|
||
|
const QPalette &, QPalette::ColorGroup,
|
||
|
const QPoint &, int length, double direction);
|
||
15 years ago
|
|
||
14 years ago
|
static void drawStyle2Needle(QPainter *,
|
||
|
const QPalette &, QPalette::ColorGroup,
|
||
|
const QPoint &, int length, double direction);
|
||
15 years ago
|
|
||
|
private:
|
||
|
Style d_style;
|
||
|
};
|
||
|
|
||
|
#endif // QWT_DIAL_NEEDLE_H
|