Main Page | Namespace List | Class Hierarchy | Compound List | File List | Compound Members | File Members | Related Pages

cmdparam.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 
00003  File:    cmdparam.h
00004  Created: by Aidan Lane, November 25, 2003
00005  Updated: by Aidan Lane, February 15, 2004
00006  
00007  This file is part of Glitch
00008  Copyright (C) 2003-2004  Monash University, Clayton Campus, Australia
00009  Created by Aidan Lane, under the supervision of Jon McCormack.
00010  
00011  This program was developed to aid the students studying the CSE3313
00012  Computer Graphics course at Monash University.
00013  
00014  This software may contain portions that are copyright (C) 1993,
00015  Silicon Graphics, Inc. All Rights Reserved.
00016  
00017  Glitch is free software; you can redistribute it and/or modify
00018  it under the terms of the GNU General Public License as published by
00019  the Free Software Foundation, version 2.
00020  
00021  Glitch is distributed in the hope that it will be useful,
00022  but WITHOUT ANY WARRANTY; without even the implied warranty of
00023  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00024  GNU General Public License for more details.
00025  
00026  You should have received a copy of the GNU General Public License
00027  along with this program; if not, write to the Free Software
00028  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00029 
00030 *****************************************************************************/
00031 
00032 #ifndef __CMDPARAM_H__
00033 #define __CMDPARAM_H__
00034 
00035 
00036 #include <qobject.h>
00037 #include <qwidget.h>
00038 #include <qstring.h>
00039 #include <qptrlist.h>
00040 
00041 #include "superptrlist.h"
00042 
00043 #define MAX_WIDGET_WIDTH 100
00044 
00045 
00058 class CmdParam : public QObject {
00059 
00060     Q_OBJECT    // make QT's signal/slot system work
00061 
00062 public:
00063     CmdParam( const char* formalVarName, const char* defaultValue,
00064         const char* exactTypeName = "unknown_type",
00065         SuperPtrList<CmdParam>* extVarElements = NULL )
00066         : myFormalVarName(formalVarName), myDefaultValue(defaultValue),
00067             myTypeName(exactTypeName), myExtVarElements(extVarElements) {}
00068     virtual ~CmdParam() {}
00069 
00070     // getters
00071     virtual const QString& formalVarName() const { return myFormalVarName; }
00072     virtual const QString& defaultValue() const { return myDefaultValue; }
00073     virtual const QString& typeName() const { return myTypeName; }
00074     virtual QPtrList<CmdParam>* extVarElements() { return myExtVarElements; }
00075     virtual int numExtVarElements() const
00076         { return (myExtVarElements==NULL) ? 0 : myExtVarElements->count(); }
00077 
00078     // setters
00079     virtual void setFormalVarName( const QString& name ) { myFormalVarName = name; }
00080     virtual void setDefaultValue( const QString& value ) { myDefaultValue = value; }
00081     virtual void setTypeName( const QString& name ) { myTypeName = name; }
00082     virtual void setExtVarElements( QPtrList<CmdParam>* extVarElements )
00083         { myExtVarElements = extVarElements; }
00084 
00099     virtual QWidget* createWidget( QWidget* parent, const char* name,
00100                     const QObject *slotOwner, const char* member ) = 0;
00101     //  -- note: widget in setWidgetValue refers to to the one created from the one above
00102     //  -- ... a sort of wrapper to support different types of widgets ...
00103     virtual void setWidgetValue( QWidget* widget, const QString& value ) = 0;
00104     virtual QString getWidgetValue( QWidget* widget ) = 0;
00105 
00113     virtual int maxWidgetWidth() const { return MAX_WIDGET_WIDTH; }
00114 
00123     virtual QString getStringRep( const QString& value ) const { return value; }
00124 
00125 protected:
00126     QString myFormalVarName;
00127     QString myDefaultValue;
00128     QString myTypeName;
00129     QPtrList<CmdParam>* myExtVarElements;
00130 };
00131 
00132 
00133 #endif  // __CMDPARAM_H__

Generated on Fri Feb 27 12:01:39 2004 for Glitch by doxygen 1.3.2