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 #ifndef __PRM_Template__
00026 #define __PRM_Template__
00027
00028 #include "PRM_API.h"
00029 #include <UT/UT_IntArray.h>
00030 #include <UT/UT_PtrArray.h>
00031 #include <UT/UT_String.h>
00032 #include "PRM_Callback.h"
00033 #include "PRM_DisableList.h"
00034 #include "PRM_Name.h"
00035 #include "PRM_Type.h"
00036
00037 #define PRM_TYPE_IS_SWITCHER(type) (type.isSwitcher())
00038
00039 #define PRM_IS_JOIN(parm) (parm.getTypeExtended() == PRM_TYPE_TOGGLE_JOIN || \
00040 parm.getTypeExtended() == PRM_TYPE_JOIN_PAIR)
00041
00042 class PRM_ChoiceList;
00043 class PRM_Range;
00044 class PRM_Default;
00045 class PRM_Template;
00046 class PRM_SpareData;
00047
00048 PRM_API extern PRM_ChoiceList PRMtoggleMenu;
00049
00050 class PRM_API PRM_Template
00051 {
00052 public:
00053
00054
00055
00056
00057
00058 enum PRM_Export
00059 {
00060 PRM_EXPORT_MIN,
00061 PRM_EXPORT_MED,
00062 PRM_EXPORT_MAX,
00063 PRM_EXPORT_TBX
00064 };
00065
00066 enum
00067 {
00068
00069
00070
00071
00072 MAX_VECTOR_SIZE = 31
00073 };
00074
00075
00076 PRM_Template(PRM_Type thetype = PRM_LIST_TERMINATOR,
00077 int thevectorsize = 1,
00078 PRM_Name *thenameptr = 0,
00079 PRM_Default *thedefaults = 0,
00080 PRM_ChoiceList *thechoicelistptr = 0,
00081 PRM_Range *therangeptr = 0,
00082 PRM_Callback thecallbackfunc = 0,
00083 PRM_SpareData *thespareptr = 0,
00084 int theparmgroup = 1,
00085 const char *thehelptext = 0,
00086 PRM_DisableList *thedisableptr = 0);
00087
00088
00089 PRM_Template(PRM_Type thetype,
00090 PRM_Export theexportlevel,
00091 int thevectorsize = 1,
00092 PRM_Name *thenameptr = 0,
00093 PRM_Default *thedefaults = 0,
00094 PRM_ChoiceList *thechoicelistptr = 0,
00095 PRM_Range *therangeptr = 0,
00096 PRM_Callback thecallbackfunc = 0,
00097 PRM_SpareData *thespareptr = 0,
00098 int theparmgroup = 1,
00099 const char *thehelptext = 0,
00100 PRM_DisableList *thedisableptr = 0);
00101
00102
00103 PRM_Template(PRM_Type thetype,
00104 PRM_TypeExtended thetype_ext,
00105 int thevectorsize = 1,
00106 PRM_Name *thenameptr = 0,
00107 PRM_Default *thedefaults = 0,
00108 PRM_ChoiceList *thechoicelistptr = 0,
00109 PRM_Range *therangeptr = 0,
00110 PRM_Callback thecallbackfunc = 0,
00111 PRM_SpareData *thespareptr = 0,
00112 int theparmgroup = 1,
00113 const char *thehelptext = 0,
00114 PRM_DisableList *thedisableptr = 0);
00115
00116
00117 PRM_Template(PRM_Type thetype,
00118 PRM_TypeExtended thetype_ext,
00119 PRM_Export theexportlevel,
00120 int thevectorsize = 1,
00121 PRM_Name *thenameptr = 0,
00122 PRM_Default *thedefaults = 0,
00123 PRM_ChoiceList *thechoicelistptr = 0,
00124 PRM_Range *therangeptr = 0,
00125 PRM_Callback thecallbackfunc = 0,
00126 PRM_SpareData *thespareptr = 0,
00127 int theparmgroup = 1,
00128 const char *thehelptext = 0,
00129 PRM_DisableList *thedisableptr = 0);
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146 PRM_Template(PRM_MultiType thetype,
00147 PRM_Template *thetemplates,
00148 PRM_Export theexportlevel,
00149 float multisize,
00150 PRM_Name *thenameptr,
00151 PRM_Default *thedefaultsize = 0,
00152 PRM_Range *thedefaultrange = 0,
00153 PRM_SpareData *thespareptr = 0,
00154 const char *thehelptext = 0,
00155 PRM_DisableList *thedisableptr = 0,
00156 PRM_Callback thecallbackfunc = 0
00157 );
00158
00159 PRM_Template(PRM_MultiType thetype,
00160 PRM_Template *thetemplates,
00161 float multisize,
00162 PRM_Name *thenameptr,
00163 PRM_Default *thedefaultsize = 0,
00164 PRM_Range *thedefaultrange = 0,
00165 PRM_SpareData *thespareptr = 0,
00166 const char *thehelptext = 0,
00167 PRM_DisableList *thedisableptr = 0,
00168 PRM_Callback thecallbackfunc = 0
00169 );
00170 PRM_Template(const PRM_Template &src);
00171 ~PRM_Template();
00172
00173 const PRM_Template &operator=(const PRM_Template &src);
00174
00175 void initialize(PRM_Type thetype,
00176 PRM_TypeExtended thetype_ext,
00177 PRM_Export theexportlevel,
00178 int thevectorsize,
00179 PRM_Name *thenameptr,
00180 PRM_Default *thedefaults,
00181 PRM_ChoiceList *thechoicelistptr,
00182 PRM_Range *therangeptr,
00183 PRM_Callback thecallbackfunc,
00184 PRM_SpareData *thespareptr,
00185 int theparmgroup,
00186 const char *thehelptext,
00187 PRM_DisableList *thedisableptr);
00188
00189 void initMulti(PRM_MultiType thetype,
00190 PRM_Template *thetemplates,
00191 PRM_Export theexportlevel,
00192 float multisize,
00193 PRM_Name *thenameptr,
00194 PRM_Default *thedefaultsize,
00195 PRM_Range *thedefaultrange,
00196 PRM_Callback thecallbackfunc,
00197 PRM_SpareData *thespareptr,
00198 const char *thehelptext,
00199 PRM_DisableList *thedisableptr
00200 );
00201
00202
00203
00204 void assign(const PRM_Template &src, int thevectorsize,
00205 PRM_Default *thedefaults);
00206
00207 const PRM_Type &getType() const { return myType; }
00208 PRM_MultiType getMultiType() const { return myMultiType; }
00209 bool isMultiType() const;
00210 bool isRampType() const;
00211 bool isRampTypeColor() const;
00212 PRM_TypeExtended getTypeExtended() const { return myTypeExtended; }
00213 int getVectorSize() const { return myVectorSize; }
00214 float getMultiSize() const { return myMultiSize; }
00215 void setNamePtr(PRM_Name *name) { myNamePtr = name; }
00216 PRM_Name *getNamePtr() { return myNamePtr; }
00217 const PRM_Name *getNamePtr() const { return myNamePtr; }
00218 PRM_SpareData *getSparePtr() { return mySparePtr; }
00219 const PRM_SpareData *getSparePtr() const { return mySparePtr; }
00220 PRM_SpareData *getOrCreateSparePtr();
00221 PRM_DisableList *getDisablePtr() { return myDisablePtr; }
00222 const PRM_DisableList*getDisablePtr() const { return myDisablePtr; }
00223 const PRM_ChoiceList *getChoiceListPtr() const
00224 {
00225 const PRM_ChoiceList *list;
00226 if (!myChoiceListPtr &&
00227 (myType & PRM_TYPE_ORDINAL) &&
00228 (myType & PRM_TYPE_TOGGLE))
00229 list = &PRMtoggleMenu;
00230 else
00231 list = myChoiceListPtr;
00232 return list;
00233 }
00234 PRM_ChoiceList *getChoiceListPtr()
00235 {
00236 PRM_ChoiceList *list;
00237 if (!myChoiceListPtr &&
00238 (myType & PRM_TYPE_ORDINAL) &&
00239 (myType & PRM_TYPE_TOGGLE))
00240 list = &PRMtoggleMenu;
00241 else
00242 list = myChoiceListPtr;
00243 return list;
00244 }
00245 void setChoiceListPtr(PRM_ChoiceList *list)
00246 {
00247 myChoiceListPtr = list;
00248 }
00249 const PRM_Range *getRangePtr() const { return myRangePtr; }
00250 PRM_Range *getRangePtr() { return myRangePtr; }
00251 PRM_Callback getCallback() const { return myCallbackFunc; }
00252 void setCallback(PRM_Callback callback)
00253 { myCallbackFunc = callback; }
00254 const UT_String &getHelpText() const { return myHelpText; }
00255 unsigned int getAutoScopeField();
00256
00257 const PRM_Template *getMultiParmTemplate() const
00258 { return myMultiParmTemplate; }
00259 PRM_Template *getMultiParmTemplate()
00260 { return myMultiParmTemplate; }
00261 void setMultiParmTemplate(PRM_Template *tplate)
00262 { myMultiParmTemplate = tplate; }
00263 int getMultiStartOffset() const;
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274 static bool matchMultiInstance(const char *name,
00275 const char *multi_name,
00276 int start_offset,
00277 int &index,
00278 const UT_IntArray *instance_index);
00279
00280 PRM_Default *getDefault(int index)
00281 {
00282 return (index >= 0 && index < myVectorSize)
00283 ? myDefaults(index) : 0;
00284 }
00285 const PRM_Default *getDefault(int index) const
00286 {
00287 return (index >= 0 && index < myVectorSize)
00288 ? myDefaults(index) : 0;
00289 }
00290 PRM_Default *getFactoryDefaults() const
00291 {
00292 return myFactoryDefaults;
00293 }
00294 void setFactoryDefaults(PRM_Default *defaults)
00295 {
00296 myFactoryDefaults = defaults;
00297 }
00298 void restoreFactoryDefaults();
00299 void setFloatDefault(int index, float v);
00300 void setOrdinalDefault(int index, int v);
00301 void setStringDefault(int index, const char *v);
00302 void setDefault(int index, const PRM_Default &d);
00303
00304
00305
00306
00307
00308
00309
00310 void setNoResim(bool noresim);
00311 void setNoCook(bool nocook);
00312
00313
00314
00315
00316 bool setNoCook(const PRM_SpareData *spare,
00317 bool force=false);
00318 void setBaseParm(bool baseparm);
00319 void setInvisible(bool invisible);
00320 void setJoinNext(bool joinnext);
00321
00322 void setTypeExtended(PRM_TypeExtended type_ext)
00323 { myTypeExtended = type_ext; }
00324
00325 PRM_Export exportLevel() const
00326 { return (PRM_Export)myExportLevel; }
00327 void setExportLevel(PRM_Export level)
00328 { myExportLevel = (unsigned char)level; }
00329 int getParmGroup() const { return (int)myParmGroup; }
00330
00331
00332 int findParmIndex(const char *thechannelname);
00333
00334 void getChannelToken(UT_String &thestrref,
00335 int theindex) const;
00336 void getChannelLabel(UT_String &thestrref,
00337 int theindex) const;
00338 void getToken(UT_String &thestrref) const
00339 {
00340 thestrref = myNamePtr->getToken();
00341 }
00342 void getLabel(UT_String &thestrref) const
00343 {
00344 thestrref = myNamePtr->getLabel();
00345 }
00346
00347 int getExpressionFlag() const
00348 {
00349 return myNamePtr->getExpressionFlag();
00350 }
00351
00352
00353
00354 const char *getToken() const
00355 {
00356 return myNamePtr->getToken();
00357 }
00358 const char *getLabel() const
00359 {
00360 return myNamePtr->getLabel();
00361 }
00362 unsigned getTokenHash() const
00363 {
00364 return myNamePtr->getHash();
00365 }
00366
00367
00368
00369
00370
00371
00372
00373
00374 static int countTemplates(
00375 const PRM_Template *templates,
00376 bool for_switcher = false,
00377 bool for_joins = false,
00378 bool for_rows = false);
00379
00380
00381 static int getTemplateIndexByToken(
00382 const PRM_Template *templates,
00383 const char * token);
00384
00385
00386
00387 static const PRM_Template *getEndOfSwitcher(
00388 const PRM_Template *templates);
00389
00390
00391 static void getSwitcherStats(
00392 const PRM_Template *templates,
00393 UT_IntArray &numswitchersonpages,
00394 UT_IntArray &numnonswitchersonpages);
00395
00396 static bool getEnclosingSwitcherFolder(
00397 const PRM_Template *tplates,
00398 const int index,
00399 int &switcher, int &folder);
00400
00401
00402
00403 bool isAutomaticallyGeneratedChoiceList() const;
00404
00405
00406
00407 int findSwitcherFolderWithLabel(
00408 const char *label) const;
00409
00410 private:
00411 void clearOurData();
00412 void buildChannelNames() const;
00413 void buildChannelName(UT_String &str, int index) const;
00414 void setAutoScopeField();
00415
00416 PRM_Type myType;
00417 PRM_MultiType myMultiType;
00418 PRM_TypeExtended myTypeExtended;
00419 int myVectorSize;
00420 PRM_Name *myNamePtr;
00421 UT_PtrArray<PRM_Default *> myDefaults;
00422 PRM_Default *myFactoryDefaults;
00423 PRM_ChoiceList *myChoiceListPtr;
00424 PRM_Range *myRangePtr;
00425 PRM_Callback myCallbackFunc;
00426 PRM_SpareData *mySparePtr;
00427 PRM_DisableList *myDisablePtr;
00428 unsigned char myExportLevel;
00429 unsigned char myParmGroup;
00430 unsigned int myAutoScopeField;
00431 PRM_Template *myMultiParmTemplate;
00432 float myMultiSize;
00433 UT_String myHelpText;
00434 mutable char **myChannelNames;
00435 };
00436
00437 #endif