Skip to content
Snippets Groups Projects
qwt_analog_clock.h 2.12 KiB
Newer Older
  • Learn to ignore specific revisions
  • pixhawk's avatar
    pixhawk committed
    /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
     * Qwt Widget Library
     * Copyright (C) 1997   Josef Wilgen
     * Copyright (C) 2002   Uwe Rathmann
     *
     * 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_ANALOG_CLOCK_H
    #define QWT_ANALOG_CLOCK_H
    
    #include "qwt_global.h"
    #include "qwt_dial.h"
    #include "qwt_dial_needle.h"
    
    Bryant's avatar
    Bryant committed
    #include <qdatetime.h>
    
    pixhawk's avatar
    pixhawk committed
    
    /*!
      \brief An analog clock
    
      \image html analogclock.png
    
      \par Example
    
    Bryant's avatar
    Bryant committed
      \code 
      #include <qwt_analog_clock.h>
    
    pixhawk's avatar
    pixhawk committed
    
      QwtAnalogClock *clock = new QwtAnalogClock(...);
      clock->scaleDraw()->setPenWidth(3);
      clock->setLineWidth(6);
      clock->setFrameShadow(QwtDial::Sunken);
      clock->setTime();
    
      // update the clock every second
      QTimer *timer = new QTimer(clock);
      timer->connect(timer, SIGNAL(timeout()), clock, SLOT(setCurrentTime()));
      timer->start(1000);
    
    
    Bryant's avatar
    Bryant committed
      \endcode
    
    pixhawk's avatar
    pixhawk committed
    
      \note The examples/dials example shows how to use QwtAnalogClock.
    */
    
    class QWT_EXPORT QwtAnalogClock: public QwtDial
    {
        Q_OBJECT
    
    public:
    
    pixhawk's avatar
    pixhawk committed
            Hand type
            \sa setHand(), hand()
        */
    
    Bryant's avatar
    Bryant committed
        enum Hand
        {
            //! Needle displaying the seconds
    
    pixhawk's avatar
    pixhawk committed
            SecondHand,
    
    Bryant's avatar
    Bryant committed
    
            //! Needle displaying the minutes
    
    pixhawk's avatar
    pixhawk committed
            MinuteHand,
    
    Bryant's avatar
    Bryant committed
    
            //! Needle displaying the hours
    
    pixhawk's avatar
    pixhawk committed
            HourHand,
    
    
    Bryant's avatar
    Bryant committed
            //! Number of needles
    
    pixhawk's avatar
    pixhawk committed
            NHands
        };
    
    
    Bryant's avatar
    Bryant committed
        explicit QwtAnalogClock( QWidget* parent = NULL );
    
    pixhawk's avatar
    pixhawk committed
        virtual ~QwtAnalogClock();
    
    
    Bryant's avatar
    Bryant committed
        void setHand( Hand, QwtDialNeedle * );
    
    pixhawk's avatar
    pixhawk committed
    
    
    Bryant's avatar
    Bryant committed
        const QwtDialNeedle *hand( Hand ) const;
        QwtDialNeedle *hand( Hand );
    
    public Q_SLOTS:
    
    pixhawk's avatar
    pixhawk committed
        void setCurrentTime();
    
    Bryant's avatar
    Bryant committed
        void setTime( const QTime & );
    
    pixhawk's avatar
    pixhawk committed
    
    protected:
    
    Bryant's avatar
    Bryant committed
        virtual void drawNeedle( QPainter *, const QPointF &,
            double radius, double direction, QPalette::ColorGroup ) const;
    
    pixhawk's avatar
    pixhawk committed
    
    
    Bryant's avatar
    Bryant committed
        virtual void drawHand( QPainter *, Hand, const QPointF &,
            double radius, double direction, QPalette::ColorGroup ) const;
    
    pixhawk's avatar
    pixhawk committed
    
    private:
    
    Bryant's avatar
    Bryant committed
        // use setHand instead
        void setNeedle( QwtDialNeedle * );
    
    pixhawk's avatar
    pixhawk committed
    
        QwtDialNeedle *d_hand[NHands];
    };
    
    #endif