meter.h

00001 /***************************************************************************
00002  *   Copyright (C) 2003 by Hans Karlsson                                   *
00003  *   karlsson.h@home.se                                                      *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  ***************************************************************************/
00010 #ifndef METER_H
00011 #define METER_H
00012 
00013 #include <qpixmap.h>
00014 #include <qpainter.h>
00015 #include <qstring.h>
00016 #include <qstringlist.h>
00017 #include <qobject.h>
00018 
00019 #include <qfileinfo.h>
00020 
00021 class karamba;
00022 
00023 class Meter : public QObject
00024 {
00025 Q_OBJECT
00026 public:
00027 
00028   Meter(karamba* k, int ix,int iy,int iw,int ih);
00029   Meter(karamba* k);
00030   virtual ~Meter();
00031   virtual int getX();
00032   virtual int getY();
00033   virtual int getWidth();
00034   virtual int getHeight();
00035   virtual void setX(int);
00036   virtual void setY(int);
00037   virtual void setWidth(int);
00038   virtual void setHeight(int);
00039 
00040   virtual void setSize(int ix, int iy, int iw, int ih);
00041 
00042   virtual void setMax(int max) { maxValue = max; };
00043   virtual void setMin(int min) { minValue = min; };
00044   virtual int getMax() { return minValue; };
00045   virtual int getMin() { return maxValue; };
00046 
00047   void setThemePath( QString );
00048 
00049   virtual void mUpdate(QPainter *)=0 ;
00050 
00051   virtual void setValue(int) {};
00052   virtual int getValue() { return -1; };
00053   virtual void setValue(QString) {};
00054   virtual QString getStringValue() const { return QString::null; };
00055   virtual void recalculateValue() {};
00056 
00057   virtual void setColor(QColor clr) { color = clr; };
00058   virtual QColor getColor() { return color; };
00059 
00060   virtual void show() { hidden = 0; };
00061   virtual void hide() { hidden = 1; };
00062 
00063   QRect getBoundingBox();
00064 
00065   // true when given coordinate point is inside the meters
00066   // active reagion and meter is enabled
00067   virtual bool insideActiveArea(int, int);
00068 
00069   // returns true when callback meterClicked should be called.
00070   virtual bool click( QMouseEvent* );
00071 
00072   void setEnabled(bool);
00073   bool isEnabled();
00074 
00075   /*
00076   void setOnClick( QString );
00077   void setOnMiddleClick( QString );
00078   */
00079 
00080 protected: // Protected attributes
00081   QString themePath;
00082 
00083   QRect boundingBox;
00084 
00085   // Actions to execute when clicked on meter
00086   QString leftButtonAction;
00087   QString middleButtonAction;
00088   QString rightButtonAction;
00089 
00090   bool clickable;
00091   int hidden;
00092   int minValue;
00093   int maxValue;
00094 
00095   QColor color;
00096   karamba* m_karamba;
00097 };
00098 
00099 #endif // METER_H
KDE Home | KDE Accessibility Home | Description of Access Keys