00001 /* 00002 * PROPRIETARY INFORMATION. This software is proprietary to 00003 * Side Effects Software Inc., and is not to be reproduced, 00004 * transmitted, or disclosed in any way without written permission. 00005 * 00006 * Produced by: 00007 * Side Effects Software Inc 00008 * 477 Richmond Street West 00009 * Toronto, Ontario 00010 * Canada M5V 3E7 00011 * 416-504-9876 00012 * 00013 * NAME: PI_EditScriptedOp.h ( OP Library, C++) 00014 * 00015 * COMMENTS: Provides a data structure for holding all the information 00016 * required to edit the various facets of a PI_ScriptOperator. 00017 * Also contains code to write a .ds file given just a pointer 00018 * to a OP_ScriptOperator. 00019 */ 00020 00021 #ifndef __PI_EditScriptedOp__ 00022 #define __PI_EditScriptedOp__ 00023 00024 #include "PI_API.h" 00025 #include <UT/UT_String.h> 00026 #include <UT/UT_StringArray.h> 00027 #include <UT/UT_PtrArray.h> 00028 #include <UT/UT_SymbolTable.h> 00029 #include "PI_EditScriptedParms.h" 00030 00031 class OP_ScriptOperator; 00032 class OP_SpecificData; 00033 00034 class PI_API PI_EditScriptedOpHandle 00035 { 00036 public: 00037 PI_EditScriptedOpHandle(const char *type); 00038 PI_EditScriptedOpHandle(const PI_EditScriptedOpHandle &src); 00039 ~PI_EditScriptedOpHandle(); 00040 00041 int save(ostream &os); 00042 void addPIName(const char *name); 00043 int bindChannel(const char *piname, const char *chname); 00044 bool hasBinding() const; 00045 00046 UT_String myName; 00047 UT_String myType; 00048 00049 // Only used by type handles... 00050 UT_String myDefault; 00051 00052 // Only used by persistant handles... 00053 UT_String myOrigName; 00054 00055 // Our binding array... 00056 UT_StringArray myPINames; 00057 UT_StringArray myChannelNames; 00058 00059 static const UT_StringArray &getValidTypes(); 00060 }; 00061 00062 class PI_API PI_EditScriptedOp 00063 { 00064 public: 00065 PI_EditScriptedOp(OP_ScriptOperator *op, OP_Node *node); 00066 PI_EditScriptedOp(const PI_EditScriptedOp &source); 00067 virtual ~PI_EditScriptedOp(); 00068 00069 // Save the entire operator definition to it's current OTL. 00070 int save(OP_SpecificData *opspecific = 0); 00071 // Save the dialog script to a stream. 00072 int save(ostream &os, 00073 OP_SpecificData *opspecific = 0); 00074 00075 // Access our parm information. 00076 PI_EditScriptedParms &getParms(); 00077 const PI_EditScriptedParms &getParms() const; 00078 00079 // Get handle binding information. 00080 int getNHandles() const; 00081 PI_EditScriptedOpHandle *getHandle(int i); 00082 00083 // Add, remove, and reorder handles. 00084 void addHandle(PI_EditScriptedOpHandle *handle); 00085 bool moveHandles(int first, int last, int offset); 00086 bool removeHandles(int first, int last); 00087 00088 // Set the basic information about the operator type. 00089 void setLabel(const char *newlabel) 00090 { myLabel.harden(newlabel); } 00091 void setName(const char *newname) 00092 { myName.harden(newname); } 00093 void setScript(const char *newscript) 00094 { myScript.harden(newscript); } 00095 void setInputLabel(int idx, const char *label); 00096 00097 // Get some basic information about the operator type. 00098 int getShopFlag() const { return myShopFlag; } 00099 int getVopFlag() const { return myVopFlag; } 00100 int getObjFlag() const { return myObjFlag; } 00101 const char *getInputLabel(int idx) const; 00102 00103 const OP_ScriptOperator *getOp() const { return myOp; } 00104 00105 // Handle our warning string. 00106 void clearWarning() { myWarning = ""; } 00107 const UT_String &getWarning() const { return myWarning; } 00108 00109 // Save a block of data into the stream in a format suitable for a 00110 // dialog script file. This means that the string is written as a 00111 // series of quoted strings which when concatenated together recreate 00112 // the original string. 00113 static void saveBlock(ostream &os, const char *block, 00114 const char *indent = "\t"); 00115 00116 private: 00117 int saveUnboundSelectors(ostream &os); 00118 int saveReservedSelectors(ostream &os); 00119 void saveHelp(ostream &os); 00120 00121 OP_ScriptOperator *myOp; 00122 PI_EditScriptedParms myParms; 00123 UT_PtrArray<PI_EditScriptedOpHandle *> myHandles; 00124 00125 // These guys are copies of the Op's value. Note this is what 00126 // is used for saving, NOT the op's value, so adjust them 00127 // to save properly. (You may want to change the Op value too 00128 // so everyone is synched nicely.) 00129 UT_String myName; 00130 UT_String myScript; 00131 UT_String myLabel; 00132 UT_String myHelp; 00133 int myShopFlag; 00134 int myVopFlag; 00135 int myObjFlag; 00136 UT_String myWarning; 00137 UT_StringArray myInputLabels; 00138 }; 00139 00140 #endif 00141
1.5.9