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

cmdinstance.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 
00003  File:    cmdinstance.h
00004  Created: by Aidan Lane, November 26, 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 __CMDINSTANCE_H__
00033 #define __CMDINSTANCE_H__
00034 
00035 
00036 #include <qobject.h>
00037 #include <qstring.h>
00038 #include <qstringlist.h>
00039 #include <qptrlist.h>
00040 #include <qmap.h>
00041 #include <qpushbutton.h>
00042 #include <qlabel.h>
00043 #include <qcheckbox.h>
00044 #include <qhbox.h>
00045 
00046 #include "cmdtreenode.h"
00047 #include "varinstance.h"
00048 #include "cmdselector.h"
00049 
00050 
00062 class CmdInstance : public QObject
00063 {
00064     Q_OBJECT    // make QT's signal/slot system work
00065 
00066 public:
00067     CmdInstance( CmdTreeNode* cmd = NULL, bool autoInitParams = true );
00068     CmdInstance( CmdTreeNode* cmd, const QStringList& paramValues );
00069     ~CmdInstance();
00070 
00071     // getters
00072     CmdTreeNode* cmd() { return myCmd; }
00073     const QStringList& paramValues() const { return myParamValues; }
00074     const QMap<uint,VarInstance*>& externVarsMap() const { return myExternVarsMap; }
00075     bool isEnabled() const { return myEnabledStatus; }
00076 
00077     // setters
00078     void setCmd( CmdTreeNode* cmd, bool autoInitParams = true );
00079     void setParamValues( const QStringList& paramValues ) { myParamValues = paramValues; }
00080     void setEnabled( bool enable ) { myEnabledStatus = enable; }
00081     
00082     // other
00083     void exec() const;
00084     void initParamValues();
00085     QString toString() const;
00086     void updateParamValues();
00087 
00088     // editor widget components
00089     QHBox* createEditorWidget( QWidget* parent );
00090     QHBox* getEditorWidget() { return cmdEditorBox; }
00091     void setCmdSelector( CmdSelector* selector ) { myCmdSelector = selector; }
00092     CmdSelector* cmdSelectoror() const { return myCmdSelector; }
00093     void setEditorBackgroundColour( const QColor& colour );
00094 
00095     void updateParamWidgets();  // update only their values
00096 
00097 signals:
00098     void cmdInstanceChanged( CmdInstance* instance );
00099     void cmdEnabledStatusChanged( CmdInstance* instance );
00100     void cmdParamChanged( CmdInstance* instance );
00101     void varInstanceCreated( CmdInstance* instance, VarInstance* varInst );
00102 
00103 public slots:
00104     void cmdSelectionChanged( CmdTreeNode* cmd );
00105 
00106 private slots:
00107     void cmdSelectorClicked();
00108     void cmdEnableCheckBoxToggled( bool on );
00109     void paramValueChanged();
00110     void editorWidgetCleanup();
00111 
00112 private:
00113     void sharedInit();
00114     void createParamWidgets();
00115 
00116     CmdTreeNode* myCmd;
00117     QStringList myParamValues;
00118 
00119     bool myEnabledStatus;
00120 
00121     // Value = parameter index, Key = variable instance
00122     QMap<uint,VarInstance*> myExternVarsMap;
00123 
00124     // The command selector pop-up widget - used by the editor
00125     CmdSelector* myCmdSelector;
00126 
00127     // The following are used for command selection and editing
00128     QHBox*            cmdEditorBox;
00129     QCheckBox*        cmdEnabledCheckBox;
00130     QLabel*           cmdSpacerLabel;
00131     QPushButton*      cmdSelectorButton;
00132     QLabel*           cmdOpenBraceLabel;
00133     QLabel*           cmdCloseBraceLabel;
00134     QHBox*            cmdParamsBox;
00135     QPtrList<QWidget> cmdParamWidgets;
00136 };
00137 
00138 #endif  // __CMDINSTANCE_H__

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