File indexing completed on 2024-03-24 15:43:25

0001 //
0002 // C++ Interface: cgaugebaritem
0003 //
0004 // Description: 
0005 //
0006 /*
0007 Copyright 2004-2011 Tomas Mecir <kmuddy@kmuddy.com>
0008 
0009 This program is free software; you can redistribute it and/or
0010 modify it under the terms of the GNU General Public License as
0011 published by the Free Software Foundation; either version 2 of 
0012 the License, or (at your option) any later version.
0013 
0014 This program is distributed in the hope that it will be useful,
0015 but WITHOUT ANY WARRANTY; without even the implied warranty of
0016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0017 GNU General Public License for more details.
0018 
0019 You should have received a copy of the GNU General Public License
0020 along with this program.  If not, see <http://www.gnu.org/licenses/>.
0021 */
0022 
0023 #ifndef CGAUGEBARITEM_H
0024 #define CGAUGEBARITEM_H
0025 
0026 #include <qwidget.h>
0027 
0028 //the "real" gauge displayer
0029 class cGaugeBarItemPrivate;
0030 class QLabel;
0031 
0032 /**
0033 One item in the gauge bar. Contains a label and the gauge.
0034 
0035 @author Tomas Mecir
0036 */
0037 class cGaugeBarItem : public QWidget
0038 {
0039 Q_OBJECT
0040 public:
0041   /** constructor */
0042   cGaugeBarItem (QWidget *parent = nullptr);
0043   /** destructor */
0044   ~cGaugeBarItem () override;
0045   void setText (const QString &caption);
0046   QString text () const;
0047   void setValue (int value);
0048   int value () const;
0049   void setColor (const QColor &color);
0050   QColor color () const;
0051 protected:
0052   QLabel *label;
0053   cGaugeBarItemPrivate *gaugepriv;
0054 };
0055 
0056 class cGaugeBarItemPrivate: public QWidget
0057 {
0058 Q_OBJECT
0059 public:
0060   /** constructor */
0061   cGaugeBarItemPrivate (QWidget *parent = nullptr);
0062   /** destructor */
0063   ~cGaugeBarItemPrivate () override;
0064   void setValue (int value);
0065   int value () const;
0066   void setColor (const QColor &color);
0067   QColor color () const;
0068 
0069   QSize sizeHint () const override;
0070 protected:
0071   void paintEvent (QPaintEvent *) override;
0072 
0073   int val;
0074   QColor col;
0075 };
0076 
0077 #endif