00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef __INTPARAM_H__
00033 #define __INTPARAM_H__
00034
00035
00036 #include <limits.h>
00037
00038 #include <qspinbox.h>
00039 #include <qvalidator.h>
00040
00041 #include "cmdparam.h"
00042
00043
00044 #define INTEGER_MIN INT_MIN
00045 #define INTEGER_MAX INT_MAX
00046 #define INTEGER_STEP 1
00047 #define INTEGER_MAX_WIDGET_WIDTH 100
00048
00049
00058 class IntParam : public CmdParam {
00059
00060 Q_OBJECT
00061
00062 public:
00063 IntParam( const char* formalVarName, const char* defaultValue,
00064 const char* exactTypeName = "GLint",
00065 int minValue = INTEGER_MIN, int maxValue = INTEGER_MAX,
00066 int stepValue = INTEGER_STEP,
00067 int maxWidgetWidth = INTEGER_MAX_WIDGET_WIDTH )
00068 : CmdParam( formalVarName, defaultValue, exactTypeName ),
00069 myMinValue(minValue), myMaxValue(maxValue), myStepValue(stepValue),
00070 myMaxWidgetWidth(maxWidgetWidth) {}
00071
00072
00073 virtual QWidget* createWidget( QWidget* parent, const char* name,
00074 const QObject *slotOwner, const char* member )
00075 {
00076 QSpinBox *w = new QSpinBox( myMinValue, myMaxValue, myStepValue,
00077 parent, name );
00078 connect( w, SIGNAL( valueChanged(int) ), slotOwner, member );
00079 return (QWidget*)w;
00080 }
00081
00082 virtual void setWidgetValue( QWidget* widget, const QString& value ) {
00083 if ( widget != NULL )
00084 ((QSpinBox*)widget)->setValue( value.toInt() );
00085 }
00086
00087 virtual QString getWidgetValue( QWidget* widget ) {
00088 return (widget!=NULL) ? QString::number( ((QSpinBox*)widget)->value() ) : QString::null;
00089 }
00090
00091 virtual int maxWidgetWidth() const {
00092 return INTEGER_MAX_WIDGET_WIDTH;
00093 }
00094
00095 private:
00096 int myMinValue;
00097 int myMaxValue;
00098 int myStepValue;
00099 int myMaxWidgetWidth;
00100 };
00101
00102
00103 #endif // __INTPARAM_H__