Qwt User's Guide  5.2.3
qwt_analog_clock.h
1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
2  * Qwt Widget Library
3  * Copyright (C) 1997 Josef Wilgen
4  * Copyright (C) 2002 Uwe Rathmann
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the Qwt License, Version 1.0
8  *****************************************************************************/
9 
10 #ifndef QWT_ANALOG_CLOCK_H
11 #define QWT_ANALOG_CLOCK_H
12 
13 #include <qdatetime.h>
14 #include "qwt_global.h"
15 #include "qwt_dial.h"
16 #include "qwt_dial_needle.h"
17 
45 class QWT_EXPORT QwtAnalogClock: public QwtDial
46 {
47  Q_OBJECT
48 
49 public:
55  enum Hand
56  {
57  SecondHand,
58  MinuteHand,
59  HourHand,
60 
61  NHands
62  };
63 
64  explicit QwtAnalogClock(QWidget* parent = NULL);
65 #if QT_VERSION < 0x040000
66  explicit QwtAnalogClock(QWidget* parent, const char *name);
67 #endif
68  virtual ~QwtAnalogClock();
69 
70  virtual void setHand(Hand, QwtDialNeedle *);
71  const QwtDialNeedle *hand(Hand) const;
72  QwtDialNeedle *hand(Hand);
73 
74 public slots:
75  void setCurrentTime();
76  void setTime(const QTime & = QTime::currentTime());
77 
78 protected:
79  virtual QwtText scaleLabel(double) const;
80 
81  virtual void drawNeedle(QPainter *, const QPoint &,
82  int radius, double direction, QPalette::ColorGroup) const;
83 
84  virtual void drawHand(QPainter *, Hand, const QPoint &,
85  int radius, double direction, QPalette::ColorGroup) const;
86 
87 private:
88  virtual void setNeedle(QwtDialNeedle *);
89  void initClock();
90 
91  QwtDialNeedle *d_hand[NHands];
92 };
93 
94 #endif