// $Id: lprofgauge.h,v 1.2 2008/02/19 21:02:39 hvengel Exp $
//  Little cms Profiler
// Copyright (C) 2008 Hal Engel
//
// THIS SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
// EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
// WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
//
// IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
// INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
// OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
// WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
// LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
// OF THIS SOFTWARE.
//
// 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 3 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, see <http://www.gnu.org/licenses/>.
//
// Version 1.11

// This is derived from the following authors work which has be heavily 
// modified.

/***************************************************************************
 *   Copyright (C) 2008 by P. Sereno                                       *
 *   http://www.sereno-online.com                                          *
 *   http://www.qt4lab.org                                                 *
 *   http://www.qphoton.org                                                *
 *                                                                         *
 *   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 LPROFGAUGE_H
#define LPROFGAUGE_H

#include <Qt>
#include <QWidget>
#include <QtDesigner/QDesignerExportWidget>


class QColor;

class /* QDESIGNER_WIDGET_EXPORT */ LProfGauge : public QWidget
{
 Q_OBJECT
    Q_ENUMS( GaugeOrientation )
	Q_PROPERTY(double value READ value WRITE setValue);
	Q_PROPERTY(double minValue READ minValue WRITE setMinValue);
	Q_PROPERTY(double maxValue READ maxValue WRITE setMaxValue);
	Q_PROPERTY(GaugeOrientation orientation READ orientation WRITE setOrientation);
	Q_PROPERTY(bool alarmEnabled READ alarmEnabled WRITE enableAlarm);
	Q_PROPERTY(double alarmThreshold READ alarmThreshold WRITE setAlarmThreshold);
	Q_PROPERTY(int numTicks READ numTicks WRITE setNumTicks);
	Q_PROPERTY(int precision READ precision WRITE setPrecision);
        Q_PROPERTY(QColor gaugeColor READ color WRITE setColor);

public: 
    enum GaugeOrientation {Horizontal,Vertical};
    LProfGauge(QWidget *parent = 0);
    double value() const { return m_value; }
    double minValue() const { return m_minValue; }
    double maxValue() const { return m_maxValue; }
    GaugeOrientation orientation() const { return m_orientation; }
    bool alarmEnabled() const { return m_alarmEnabled; }
    double alarmThreshold() const { return m_alarmThreshold; }
    double numTicks() const { return m_numTicks; }
    int precision() const { return m_precision; }     
    QSize sizeHint() const {return QSize(20,180);}
    QSize minimumSizeHint() const {return sizeHint();}
    QColor color() const {return markerColor;}
    
public slots:
    void setValue(double);
    void setValue(int);
    void setMinValue(double);	
    void setMaxValue(double);
    void setOrientation(GaugeOrientation);
    void enableAlarm(bool);
    void setAlarmThreshold(double);
    void setAlarmThreshold(int);
    void setNumTicks(int);
    void setPrecision(int);
    void setColor(QColor);
    
protected:
  
    QColor markerColor;
    bool m_alarmEnabled;
    double m_alarmThreshold;
    double m_value,m_minValue,m_maxValue;
    int m_numTicks;
    int m_precision;
    GaugeOrientation m_orientation;
    void paintEvent(QPaintEvent *event);

    void mousePressEvent(QMouseEvent *);
    void mouseMoveEvent(QMouseEvent *);
    void mouseReleaseEvent(QMouseEvent *);

    int mousePressX,mousePressY;


signals:
   void thresholdAlarm(bool upper);

};

#endif
