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 #ifndef __PRM_ChoiceList__
00030 #define __PRM_ChoiceList__
00031
00032 #include "PRM_API.h"
00033 #include <UT/UT_String.h>
00034 #include <CH/CH_ExprLanguage.h>
00035 #include "PRM_ParmOwner.h"
00036
00037 class PRM_Name;
00038 class PRM_Item;
00039 class PRM_Parm;
00040 class PRM_ParmOwner;
00041 class PRM_SpareData;
00042
00043 enum PRM_ChoiceListType
00044 {
00045 PRM_CHOICELIST_REPLACE = 0x0001,
00046 PRM_CHOICELIST_TOGGLE = 0x0002,
00047
00048 PRM_CHOICELIST_APPEND = 0x0004,
00049 PRM_CHOICELIST_WILD = 0x0008,
00050
00051 PRM_CHOICELIST_EXCLUSIVE = 0x1000,
00052
00053
00054 PRM_CHOICELIST_SINGLE = PRM_CHOICELIST_REPLACE
00055 |PRM_CHOICELIST_EXCLUSIVE
00056 };
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068 typedef void (* PRM_ChoiceGenFunc)(void *thedata,
00069 PRM_Name *thechoicenames,
00070 int thelistsize,
00071 const PRM_SpareData *thespareptr,
00072 PRM_Parm *theparm);
00073 typedef void (* PRM_ChoiceItemGenFunc)(void *thedata,
00074 PRM_Item *thechoiceitems,
00075 int thelistsize,
00076 const PRM_SpareData *thespareptr,
00077 PRM_Parm *theparm);
00078
00079 class PRM_API PRM_ChoiceList
00080 {
00081 public:
00082
00083 PRM_ChoiceList(PRM_ChoiceListType thetype, PRM_Name *thechoicenames);
00084 PRM_ChoiceList(PRM_ChoiceListType thetype, PRM_ChoiceGenFunc thefunc);
00085
00086
00087 PRM_ChoiceList(PRM_ChoiceListType thetype, PRM_Item *thechoiceitem);
00088 PRM_ChoiceList(PRM_ChoiceListType thetype, PRM_ChoiceItemGenFunc thefunc);
00089
00090
00091 PRM_ChoiceList(PRM_ChoiceListType thetype, const char *thescript,
00092 CH_ScriptLanguage language = CH_HSCRIPT);
00093
00094
00095 bool usesItems() const { return myUseItems; }
00096
00097 void getChoiceNames(const PRM_Name *&thechoicenames,
00098 void *thedata = 0,
00099 const PRM_SpareData *theSparePtr = 0,
00100 PRM_Parm *theParm = 0) const;
00101
00102 void getChoiceItems(const PRM_Item *&thechoiceitems,
00103 void *thedata = 0,
00104 const PRM_SpareData *theSparePtr = 0,
00105 PRM_Parm *theParm = 0) const;
00106
00107 const UT_String &getScript() const;
00108 CH_ScriptLanguage getScriptLanguage() const;
00109 bool isDynamic() const;
00110
00111 PRM_ChoiceListType getType() const
00112 { return myType; }
00113 PRM_ChoiceGenFunc getChoiceGenerator() const
00114 { return myChoiceGenerator; }
00115 int getSize(PRM_ParmOwner *node) const;
00116
00117
00118
00119
00120
00121 void deleteChoices();
00122
00123 private:
00124 void getChoiceNamesFromScript(
00125 PRM_Name *names, int size,
00126 PRM_Parm *owner) const;
00127 void getChoiceNamesFromHscriptScript(
00128 PRM_Name *names, int size,
00129 PRM_ParmOwner &owner) const;
00130 void getChoiceNamesFromPythonScript(
00131 PRM_Name *names, int size,
00132 PRM_ParmOwner &owner) const;
00133
00134 PRM_ChoiceListType myType;
00135
00136 bool myUseItems;
00137 union
00138 {
00139 PRM_ChoiceGenFunc myChoiceGenerator;
00140 PRM_ChoiceItemGenFunc myChoiceItemGenerator;
00141 };
00142
00143 union
00144 {
00145 PRM_Name *myChoiceNames;
00146 PRM_Item *myChoiceItems;
00147 };
00148
00149 UT_String myScript;
00150 mutable bool myScriptRunningFlag;
00151 CH_ScriptLanguage myScriptLanguage;
00152 };
00153
00154 #endif
00155