/***************************************************************************
 *   Copyright (C) 2007 by Andreas Krumnow   *
 *   andreas@krumnow.de   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#ifndef ZEIGERFELD_H
#define ZEIGERFELD_H

#define MAX_WINKEL 180

#include <QWidget>
#include <QTime>
#include <QTimer>
#include <QPainter>

/**
Version 0.1
Darstellung des Hintergrundes und des schwingenden Zeigers

	@author Andreas Krumnow <andreas@krumnow.de>
*/

class ZeigerFeld : public QWidget
{
Q_OBJECT
public:
    ZeigerFeld(QWidget *parent = 0);
    ~ZeigerFeld();
    QSize minimumSizeHint() const { return QSize(30, 10); }
    void setClockTempo(int t);

public slots:
    void startStop();
    void resetZeiger();
    void setMaxWinkel(int w);
    void move();

protected:
    void paintEvent(QPaintEvent *event);

private:
    int     tempo,  paneW, paneH, maxWinkel, curStepwidth;
    double  ausschlag, grad, cur_ms;
    bool    swinging;
    bool    from_left2right;
    QColor      *bkCol, *pendelCol;
    QPainter    *stift;
    QTimer      *clock;
    QString dbg_txt;

    void drawPendel(QPainter *stift);

public:
    bool isRunning(){return swinging;};
    void swing(bool b);
};

#endif