1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295
|
/****************************************************************
**
** Attal : Lords of Doom
**
** askWidget.h
** Classes for asking values to user
**
** Version : $Id: askWidget.h,v 1.5 2004/05/09 15:13:41 audoux Exp $
**
** Author(s) : Pascal Audoux
**
** Date : 07/01/2003
**
** Licence :
** 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, 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.
**
****************************************************************/
#ifndef ASKWIDGET_H
#define ASKWIDGET_H
// generic include files
// include files for QT
#include <qcheckbox.h>
#include <qlineedit.h>
#include <qspinbox.h>
#include <qstring.h>
#include <qwidget.h>
// application specific include files
class QComboBox;
class QLabel;
class QListBox;
class QListBoxItem;
class QPixmap;
class QPushButton;
/** Usefull widget for asking a string */
class AskString : public QWidget
{
public:
/** Constructor */
AskString( QString text = "", QWidget * parent = 0, const char * name = 0 );
/** Set the text of the question */
void setText( QString text );
/** \return Returns the value asked (a string) */
QString getValue() { return _value->text(); }
/** Sets the value */
void setValue( QString value ) { _value->setText( value ); }
/** Sets the width of the lineedit */
void setValueSize( int size ) { _value->setFixedWidth( size ); }
private:
QLineEdit * _value;
QLabel * _label;
};
/** Usefull widget for asking a boolean */
class AskBool : public QWidget
{
Q_OBJECT
public:
/** Constructor */
AskBool( QString text = "", QWidget * parent = 0, const char * name = 0 );
/** Set the text of the question */
void setText( QString text );
/** \return Returns the value */
bool getValue() { return _value->isChecked(); }
/** Sets the value */
void setValue( bool value ) { _value->setChecked( value ); }
signals:
void sig_changed();
private:
QCheckBox * _value;
};
/** Usefull widget for asking an int */
class AskInt : public QWidget
{
public:
/** Constructor */
AskInt( QString text = "", QWidget * parent = 0, const char * name = 0 );
/** Sets text of the question */
void setText( QString text );
/** \return Returns the value */
int getValue() { return _value->value(); }
/** Sets the value */
void setValue( int value ) { _value->setValue( value ); }
/** Sets the 'min' value */
void setMinValue( int val ) { _value->setMinValue( val ); }
/** Sets the 'max' value */
void setMaxValue( int val ) { _value->setMaxValue( val ); }
private:
QSpinBox * _value;
QLabel * _label;
};
/** Usefull widget for asking a case in an enum */
class AskCombo : public QWidget
{
Q_OBJECT
public:
/** Constructor */
AskCombo( QString text = "", QWidget * parent = 0, const char * name = 0 );
/** Clears the combo */
void clear();
/** Sets the text of the question */
void setText( const QString & text );
/** Inserts an item in the combo */
void insertItem( const QString & item );
/** \return Returns current item */
int currentItem();
/** Sets current item to num */
void setCurrentItem( int num );
signals:
void sig_activated( int );
private:
QLabel * _label;
QComboBox * _combo;
};
/** Useful widget for asking a pixmap */
class AskPixmap : public QWidget
{
Q_OBJECT
public:
/** Constructor */
AskPixmap( bool display, const QString & destination, QString text = "", QWidget * parent = 0, const char * name = 0 );
/** Destructor */
~AskPixmap();
/** \return Returns the value (path to the pixmap) */
QString getValue() { return _value; }
/** Sets path to the pixmap */
void setValue( const QString & value );
/** \return Returns destination of the pixmap */
QString getDestination() { return _destination; }
/** Sets destination of the pixmap */
void setDestination( const QString & destination );
/** Save pixmap to the destination */
void save();
public slots:
/** Slot for loading the pixmap */
void slot_loadPixmap();
private:
void updateDisplay();
QPixmap * _pix;
QString _value, _destination;
QPushButton * _butLoad;
bool _display;
};
class AskList : public QWidget
{
Q_OBJECT
public:
/** Constructor */
AskList( QWidget * parent = 0, const char * name = 0 );
void setLabel( const QString & label );
/** Sets limit of the list. 0 means no limit */
void setLimit( int limit );
/** Returns the current number of items */
uint count();
void clear();
public slots:
/** Slot for adding a new item */
void slot_new();
/** Slot for deleting the current item */
void slot_del();
/** Slot for putting the current item up */
void slot_up();
/** Slot for putting the current item down */
void slot_down();
/** Slot for changing the value of an item */
void slot_change( QListBoxItem * item );
protected:
virtual QString askValue( const QString & val, bool & ok );
int _limit;
QListBox * _list;
QLabel * _label;
QPushButton * _pbNew, * _pbDel, * _pbUp, * _pbDown;
};
class AskStringList : public AskList
{
public:
AskStringList( QWidget * parent = 0, const char * name = 0 );
void addValue( const QString & value );
void setValue( uint num, const QString & value );
QString getValue( uint num );
protected:
//virtual QString askValue();
};
class AskIntList : public AskList
{
public:
AskIntList( QWidget * parent = 0, const char * name = 0 );
void addValue( int value );
void setValue( uint num, int value );
int getValue( uint num );
void setMinValue( int value );
void setMaxValue( int value );
protected:
virtual QString askValue( const QString & value, bool & ok );
int _min, _max;
};
class AskColor : public QWidget
{
Q_OBJECT
public:
AskColor( const QString & text = "", QWidget * parent = 0, const char * name = 0 );
void setText( const QString & text );
void setValue( const QColor & color );
QColor getValue();
public slots:
void slot_color();
protected:
QLabel * _label;
QPushButton * _colorButton;
QColor _color;
};
#endif // ASKWIDGET_H
|