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

varinstance.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 
00003  File:    varinstance.h
00004  Created: by Aidan Lane, January  08, 2004
00005  Updated: by Aidan Lane, February 26, 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 __VARINSTANCE_H__
00033 #define __VARINSTANCE_H__
00034 
00035 
00036 #include <qobject.h>
00037 #include <qstring.h>
00038 #include <qstringlist.h>
00039 #include <qlabel.h>
00040 #include <qhbox.h>
00041 
00042 #include "cmdparam.h"
00043 
00044 
00063 class VarInstance : public QObject
00064 {
00065     Q_OBJECT    // make QT's signal/slot system work
00066 
00067 public:
00068     VarInstance( const QString& name, CmdParam* cmdParam = NULL,
00069         bool autoInitElements = true );
00070     VarInstance( const QString& name, CmdParam* cmdParam,
00071         const QStringList& elementValues );
00072     
00073     // getters
00074     const QString& varName() const { return myVarName; }
00075     CmdParam* cmdParam() { return myCmdParam; }
00076     const QStringList& elementValues() const { return myElementValues; }
00077     // Note: There is no setter for myElementTypeName, as it is dictated by
00078     // myCmdParam, hence it is set by the setCmdParam method.
00079     const QString& elementTypeName() const { return myElementTypeName; }
00080 
00081     // setters
00082     void setVarName( const QString& name ) { myVarName = name; }
00083     void setCmdParam( CmdParam* cmdParam, bool autoInitElements = true );
00084     void setElementValues( const QStringList& values );
00085 
00086     // other
00087     void initElementValues();
00088     QString toString() const;
00089 
00090     // editor widget components
00091     QHBox* createEditorWidget( QWidget* parent );
00092     QHBox* getEditorWidget() { return varEditorBox; }
00093     void updateEditorWidget();
00094     void setEditorBackgroundColour( const QColor& colour );
00095 
00096 signals:
00097     void varElementChanged();
00098 
00099 private slots:
00100     void editorWidgetCleanup();
00101     void elementValueChanged();
00102 
00103 private:
00104     void sharedInit();
00105 
00106     QString     myVarName;
00107     CmdParam*   myCmdParam;
00108     QStringList myElementValues;
00109     QString     myElementTypeName;
00110 
00111     // The following are used for variable editing
00112     QHBox*            varEditorBox;
00113     QLabel*           varFrontLabel;
00114     QLabel*           varEndLabel;
00115     QPtrList<QWidget> varElementWidgets;
00116 };
00117 
00118 
00119 #endif  // __VARINSTANCE_H__

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