00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __PRM_FileHistoryMenu__
00021 #define __PRM_FileHistoryMenu__
00022
00023 static void
00024 prmBuildHistoryMenu(PRM_Name *theMRUfiles, int thelistsize,
00025 FS_FileHistoryType filetype)
00026 {
00027 int i, max, numfiles;
00028 UT_String formattedName;
00029
00030 FS_FileHistoryManager *manager = FSgetFileHistoryManager();
00031 UT_ASSERT(manager);
00032
00033 numfiles = manager->numFilesInList(filetype);
00034
00035 max = (numfiles >= thelistsize) ? thelistsize-1 : numfiles;
00036 for (i = 0; i < max; i++)
00037 {
00038 manager->getFormattedFilenameFromList(i, filetype, formattedName);
00039
00040 theMRUfiles[i].setToken((const char *)manager
00041 ->getFilenameFromList(i, filetype));
00042 theMRUfiles[i].setLabel(formattedName);
00043 }
00044
00045 theMRUfiles[i].setToken(0);
00046 theMRUfiles[i].setLabel(0);
00047 }
00048
00049 static void
00050 prmBuildPICMRUList(void *, PRM_Name *theMRUfiles, int thelistsize,
00051 const PRM_SpareData *, PRM_Parm *)
00052 {
00053 prmBuildHistoryMenu(theMRUfiles, thelistsize, FS_FILEHISTORY_PIC);
00054 }
00055
00056 static void
00057 prmBuildGEOMRUList(void *, PRM_Name *theMRUfiles, int thelistsize,
00058 const PRM_SpareData *, PRM_Parm *)
00059 {
00060 prmBuildHistoryMenu(theMRUfiles, thelistsize, FS_FILEHISTORY_GEO);
00061 }
00062
00063 static void
00064 prmBuildRAMPMRUList(void *, PRM_Name *theMRUfiles, int thelistsize,
00065 const PRM_SpareData *, PRM_Parm *)
00066 {
00067 prmBuildHistoryMenu(theMRUfiles, thelistsize, FS_FILEHISTORY_RAMP);
00068 }
00069
00070 static void
00071 prmBuildCAPTMRUList(void *, PRM_Name *theMRUfiles, int thelistsize,
00072 const PRM_SpareData *, PRM_Parm *)
00073 {
00074 prmBuildHistoryMenu(theMRUfiles, thelistsize, FS_FILEHISTORY_CAPT);
00075 }
00076
00077 static void
00078 prmBuildCLIPMRUList(void *, PRM_Name *theMRUfiles, int thelistsize,
00079 const PRM_SpareData *, PRM_Parm *)
00080 {
00081 prmBuildHistoryMenu(theMRUfiles, thelistsize, FS_FILEHISTORY_CLIP);
00082 }
00083
00084 static void
00085 prmBuildPAINTMRUList(void *, PRM_Name *theMRUfiles, int thelistsize,
00086 const PRM_SpareData *, PRM_Parm *)
00087 {
00088 prmBuildHistoryMenu(theMRUfiles, thelistsize, FS_FILEHISTORY_PAINT);
00089 }
00090
00091 static void
00092 prmBuildLUTMRUList(void *, PRM_Name *theMRUfiles, int thelistsize,
00093 const PRM_SpareData *, PRM_Parm *)
00094 {
00095 prmBuildHistoryMenu(theMRUfiles, thelistsize, FS_FILEHISTORY_LUT);
00096 }
00097
00098 static void
00099 prmBuildCMDMRUList(void *, PRM_Name *theMRUfiles, int thelistsize,
00100 const PRM_SpareData *, PRM_Parm *)
00101 {
00102 prmBuildHistoryMenu(theMRUfiles, thelistsize, FS_FILEHISTORY_CMD);
00103 }
00104
00105 static void
00106 prmBuildMIDIMRUList(void *, PRM_Name *theMRUfiles, int thelistsize,
00107 const PRM_SpareData *, PRM_Parm *)
00108 {
00109 prmBuildHistoryMenu(theMRUfiles, thelistsize, FS_FILEHISTORY_MIDI);
00110 }
00111
00112 static void
00113 prmBuildTXTMRUList(void *, PRM_Name *theMRUfiles, int thelistsize,
00114 const PRM_SpareData *, PRM_Parm *)
00115 {
00116 prmBuildHistoryMenu(theMRUfiles, thelistsize, FS_FILEHISTORY_TXT);
00117 }
00118
00119 static void
00120 prmBuildI3DMRUList(void *, PRM_Name *theMRUfiles, int thelistsize,
00121 const PRM_SpareData *, PRM_Parm *)
00122 {
00123 prmBuildHistoryMenu(theMRUfiles, thelistsize, FS_FILEHISTORY_I3D);
00124 }
00125
00126 static void
00127 prmBuildCHANMRUList(void *, PRM_Name *theMRUfiles, int thelistsize,
00128 const PRM_SpareData *, PRM_Parm *)
00129 {
00130 prmBuildHistoryMenu(theMRUfiles, thelistsize, FS_FILEHISTORY_CHAN);
00131 }
00132
00133 static void
00134 prmBuildSIMMRUList(void *, PRM_Name *theMRUfiles, int thelistsize,
00135 const PRM_SpareData *, PRM_Parm *)
00136 {
00137 prmBuildHistoryMenu(theMRUfiles, thelistsize, FS_FILEHISTORY_SIM);
00138 }
00139
00140 static void
00141 prmBuildSIMDATAMRUList(void *, PRM_Name *theMRUfiles, int thelistsize,
00142 const PRM_SpareData *, PRM_Parm *)
00143 {
00144 prmBuildHistoryMenu(theMRUfiles, thelistsize, FS_FILEHISTORY_SIMDATA);
00145 }
00146
00147 static void
00148 prmBuildMISCMRUList(void *, PRM_Name *theMRUfiles, int thelistsize,
00149 const PRM_SpareData *, PRM_Parm *)
00150 {
00151 prmBuildHistoryMenu(theMRUfiles, thelistsize, FS_FILEHISTORY_MISC);
00152 }
00153
00154 static PRM_ChoiceGenFunc
00155 prmGetHistoryCallbackFunction(PRM_Type type)
00156 {
00157 PRM_ChoiceGenFunc callBackFunction;
00158
00159 switch (type.getPathType())
00160 {
00161 case PRM_Type::PRM_PATH_PIC:
00162 callBackFunction = prmBuildPICMRUList;
00163 break;
00164 case PRM_Type::PRM_PATH_GEO:
00165 callBackFunction = prmBuildGEOMRUList;
00166 break;
00167 case PRM_Type::PRM_PATH_CAPT:
00168 callBackFunction = prmBuildCAPTMRUList;
00169 break;
00170 case PRM_Type::PRM_PATH_RAMP:
00171 callBackFunction = prmBuildRAMPMRUList;
00172 break;
00173 case PRM_Type::PRM_PATH_CLIP:
00174 callBackFunction = prmBuildCLIPMRUList;
00175 break;
00176 case PRM_Type::PRM_PATH_PAINT:
00177 callBackFunction = prmBuildPAINTMRUList;
00178 break;
00179 case PRM_Type::PRM_PATH_LUT:
00180 callBackFunction = prmBuildLUTMRUList;
00181 break;
00182 case PRM_Type::PRM_PATH_CMDF:
00183 callBackFunction = prmBuildCMDMRUList;
00184 break;
00185 case PRM_Type::PRM_PATH_MIDI:
00186 callBackFunction = prmBuildMIDIMRUList;
00187 break;
00188 case PRM_Type::PRM_PATH_TXT:
00189 callBackFunction = prmBuildTXTMRUList;
00190 break;
00191 case PRM_Type::PRM_PATH_I3D:
00192 callBackFunction = prmBuildI3DMRUList;
00193 break;
00194 case PRM_Type::PRM_PATH_CHAN:
00195 callBackFunction = prmBuildCHANMRUList;
00196 break;
00197 case PRM_Type::PRM_PATH_SIM:
00198 callBackFunction = prmBuildSIMMRUList;
00199 break;
00200 case PRM_Type::PRM_PATH_SIMDATA:
00201 callBackFunction = prmBuildSIMDATAMRUList;
00202 break;
00203 default:
00204 callBackFunction = prmBuildMISCMRUList;
00205 break;
00206 };
00207
00208 return callBackFunction;
00209 }
00210
00211 PRM_ChoiceList *
00212 prmFindHistoryMenuBuilder(PRM_Type type)
00213 {
00214 return new PRM_ChoiceList((PRM_ChoiceListType)PRM_CHOICELIST_REPLACE,
00215 prmGetHistoryCallbackFunction(type));
00216 }
00217
00218 bool
00219 prmIsHistoryMenuBuilder(PRM_ChoiceList *choice_list, PRM_Type type)
00220 {
00221 return (choice_list && choice_list->getChoiceGenerator() &&
00222 choice_list->getChoiceGenerator()
00223 == prmGetHistoryCallbackFunction(type));
00224 }
00225
00226 #endif