00001
#ifndef QLEDBAR_HPP
00002
#define QLEDBAR_HPP
00003
00004
#include <qcolor.h>
00005
#include <qevent.h>
00006
#include <qpixmap.h>
00007
#ifdef QT_THREAD_SUPPORT
00008
#include <qthread.h>
00009
#endif
00010
#include <qwidget.h>
00011
00012 class CLedBar:
public QWidget
00013 {
00014 Q_OBJECT
00015
public:
00016 enum Orientation {
00017
North,
00018
West,
00019
South,
00020
East
00021 };
00022
00023 enum BarMode {
00024
SolidBar,
00025
SegmentBar,
00026
00027 };
00028
00029
private:
00030
#ifdef QT_THREAD_SUPPORT
00031
QMutex Busy;
00032
#endif
00033
int Minimum, Maximum, Range, Value;
00034 Orientation BarOrientation;
00035
int BarLength;
00036
int BarWidth;
00037 BarMode m_BarMode;
00038
00039
int Segments;
00040
int Margin;
00041
00042
int StartOfSegment[21];
00043
int ValueForSegment[20];
00044 QColor ColorOfSegment[20];
00045
00046 QPixmap DrawingArea;
00047
00048
void BusyLock();
00049
void BusyUnlock();
00050
00051
void CalcBoundaries();
00052
00053
protected:
00054
void resizeEvent(QResizeEvent *);
00055
void paintEvent(QPaintEvent *);
00056
00057
public:
00058
CLedBar(Orientation orientation,
int min_range,
int max_range, BarMode bar_mode = SolidBar, QWidget *parent = 0,
const char *name = 0);
00059
00060
void SetBarMode(BarMode bar_mode);
00061
void SetSegments(
int segments,
const QColor *colors);
00062
void SetMargin(
int width);
00063
00064
00065
00066
public slots:
00067
void setValue(
int value);
00068 };
00069
00070
#endif