kgameprogress.h
00001 /* This file is part of the KDE libraries 00002 Copyright (C) 1996 Martynas Kunigelis 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License version 2 as published by the Free Software Foundation. 00007 00008 This library is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 Library General Public License for more details. 00012 00013 You should have received a copy of the GNU Library General Public License 00014 along with this library; see the file COPYING.LIB. If not, write to 00015 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00016 Boston, MA 02110-1301, USA. 00017 */ 00018 /***************************************************************************** 00019 * * 00020 * KGameProgress -- progress indicator widget for KDE by Martynas Kunigelis * 00021 * * 00022 *****************************************************************************/ 00023 00024 #ifndef _KPROGRES_H 00025 #define _KPROGRES_H "$Id$" 00026 00027 #include <tqframe.h> 00028 #include <tqrangecontrol.h> 00029 #include <kdemacros.h> 00050 class KDE_EXPORT KGameProgress : public TQFrame, public TQRangeControl 00051 { 00052 Q_OBJECT 00053 TQ_OBJECT 00054 Q_ENUMS( BarStyle ) 00055 TQ_PROPERTY( int value READ value WRITE setValue) 00056 TQ_PROPERTY( BarStyle barStyle READ barStyle WRITE setBarStyle ) 00057 TQ_PROPERTY( TQColor barColor READ barColor WRITE setBarColor ) 00058 TQ_PROPERTY( TQPixmap barPixmap READ barPixmap WRITE setBarPixmap ) 00059 TQ_PROPERTY( Orientation orientation READ orientation WRITE setOrientation ) 00060 TQ_PROPERTY( bool textEnabled READ textEnabled WRITE setTextEnabled ) 00061 00062 public: 00069 enum BarStyle { Solid, Blocked }; 00070 00074 KGameProgress(TQWidget *parent=0, const char *name=0); 00075 00079 KGameProgress(Orientation orient, TQWidget *parent=0, const char *name=0); 00080 00084 KGameProgress(int minValue, int maxValue, int value, Orientation, 00085 TQWidget *parent=0, const char *name=0); 00086 00090 ~KGameProgress(); 00091 00097 void setBarStyle(BarStyle style); 00098 00102 void setBarColor(const TQColor &); 00103 00107 void setBarPixmap(const TQPixmap &); 00108 00114 void setOrientation(Orientation); 00115 00120 void setTextEnabled(bool); 00121 00127 BarStyle barStyle() const; 00128 00133 const TQColor &barColor() const; 00134 00140 const TQPixmap *barPixmap() const; 00141 00147 int value() const { return TQRangeControl::value(); } 00153 Orientation orientation() const; 00154 00161 bool textEnabled() const; 00162 00165 virtual TQSize sizeHint() const; 00166 00169 virtual TQSize minimumSizeHint() const; 00170 00173 virtual TQSizePolicy sizePolicy() const; 00174 00179 TQString format() const; 00180 00181 public slots: 00182 00191 void setFormat(const TQString & format); 00192 00198 void setValue(int value); 00199 00207 void advance(int prog); 00208 00209 signals: 00213 void percentageChanged(int); 00214 00215 protected: 00218 void valueChange(); 00221 void rangeChange(); 00224 void styleChange( TQStyle& ); 00227 void paletteChange( const TQPalette & ); 00230 void drawContents( TQPainter * ); 00231 00232 private slots: 00233 void paletteChange(); 00234 00235 private: 00236 TQPixmap *bar_pixmap; 00237 bool use_supplied_bar_color; 00238 TQColor bar_color; 00239 TQColor bar_text_color; 00240 TQColor text_color; 00241 TQRect fr; 00242 BarStyle bar_style; 00243 Orientation orient; 00244 bool text_enabled; 00245 TQString format_; 00246 void initialize(); 00247 int recalcValue(int); 00248 void drawText(TQPainter *); 00249 void adjustStyle(); 00250 00251 class KGameProgressPrivate; 00252 KGameProgressPrivate *d; 00253 }; 00254 00255 00256 #endif