kgameprogress.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _KPROGRES_H
00025 #define _KPROGRES_H "$Id: kgameprogress.h 465369 2005-09-29 14:33:08Z mueller $"
00026
00027 #include <qframe.h>
00028 #include <qrangecontrol.h>
00029 #include <kdemacros.h>
00050 class KDE_EXPORT KGameProgress : public QFrame, public QRangeControl
00051 {
00052 Q_OBJECT
00053 Q_ENUMS( BarStyle )
00054 Q_PROPERTY( int value READ value WRITE setValue)
00055 Q_PROPERTY( BarStyle barStyle READ barStyle WRITE setBarStyle )
00056 Q_PROPERTY( QColor barColor READ barColor WRITE setBarColor )
00057 Q_PROPERTY( QPixmap barPixmap READ barPixmap WRITE setBarPixmap )
00058 Q_PROPERTY( Orientation orientation READ orientation WRITE setOrientation )
00059 Q_PROPERTY( bool textEnabled READ textEnabled WRITE setTextEnabled )
00060
00061 public:
00068 enum BarStyle { Solid, Blocked };
00069
00073 KGameProgress(QWidget *parent=0, const char *name=0);
00074
00078 KGameProgress(Orientation orient, QWidget *parent=0, const char *name=0);
00079
00083 KGameProgress(int minValue, int maxValue, int value, Orientation,
00084 QWidget *parent=0, const char *name=0);
00085
00089 ~KGameProgress();
00090
00096 void setBarStyle(BarStyle style);
00097
00101 void setBarColor(const QColor &);
00102
00106 void setBarPixmap(const QPixmap &);
00107
00113 void setOrientation(Orientation);
00114
00119 void setTextEnabled(bool);
00120
00126 BarStyle barStyle() const;
00127
00132 const QColor &barColor() const;
00133
00139 const QPixmap *barPixmap() const;
00140
00146 int value() const { return QRangeControl::value(); }
00152 Orientation orientation() const;
00153
00160 bool textEnabled() const;
00161
00164 virtual QSize sizeHint() const;
00165
00168 virtual QSize minimumSizeHint() const;
00169
00172 virtual QSizePolicy sizePolicy() const;
00173
00178 QString format() const;
00179
00180 public slots:
00181
00190 void setFormat(const QString & format);
00191
00197 void setValue(int value);
00198
00206 void advance(int prog);
00207
00208 signals:
00212 void percentageChanged(int);
00213
00214 protected:
00217 void valueChange();
00220 void rangeChange();
00223 void styleChange( QStyle& );
00226 void paletteChange( const QPalette & );
00229 void drawContents( QPainter * );
00230
00231 private slots:
00232 void paletteChange();
00233
00234 private:
00235 QPixmap *bar_pixmap;
00236 bool use_supplied_bar_color;
00237 QColor bar_color;
00238 QColor bar_text_color;
00239 QColor text_color;
00240 QRect fr;
00241 BarStyle bar_style;
00242 Orientation orient;
00243 bool text_enabled;
00244 QString format_;
00245 void initialize();
00246 int recalcValue(int);
00247 void drawText(QPainter *);
00248 void adjustStyle();
00249
00250 class KGameProgressPrivate;
00251 KGameProgressPrivate *d;
00252 };
00253
00254
00255 #endif
|