HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PRM_FileHistoryMenu.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: PRM_FileHistoryMenu.C (C++)
7  *
8  * COMMENTS:
9  *
10  */
11 
12 #ifndef __PRM_FileHistoryMenu__
13 #define __PRM_FileHistoryMenu__
14 
15 #include "PRM_ChoiceList.h"
16 #include "PRM_Name.h"
17 #include "PRM_Type.h"
18 
20 #include <UT/UT_Assert.h>
21 #include <UT/UT_String.h>
22 
23 
24 class PRM_SpareData;
25 class PRM_Parm;
26 
27 
28 static void
29 prmBuildHistoryMenu(PRM_Name *theMRUfiles, int thelistsize,
30  FS_FileHistoryType filetype)
31 {
32  int i, max, numfiles;
33  UT_String formattedName;
34 
36  UT_ASSERT(manager);
37 
38  numfiles = manager->numFilesInList(filetype);
39 
40  max = (numfiles >= thelistsize) ? thelistsize-1 : numfiles;
41  for (i = 0; i < max; i++)
42  {
43  manager->getFormattedFilenameFromList(i, filetype, formattedName);
44 
45  theMRUfiles[i].setToken((const char *)manager
46  ->getFilenameFromList(i, filetype));
47  theMRUfiles[i].setLabel(formattedName);
48  }
49 
50  theMRUfiles[i].setToken(0);
51  theMRUfiles[i].setLabel(0);
52 }
53 
54 static void
55 prmBuildPICMRUList(void *, PRM_Name *theMRUfiles, int thelistsize,
56  const PRM_SpareData *, const PRM_Parm *)
57 {
58  prmBuildHistoryMenu(theMRUfiles, thelistsize, FS_FILEHISTORY_PIC);
59 }
60 
61 static void
62 prmBuildGEOMRUList(void *, PRM_Name *theMRUfiles, int thelistsize,
63  const PRM_SpareData *, const PRM_Parm *)
64 {
65  prmBuildHistoryMenu(theMRUfiles, thelistsize, FS_FILEHISTORY_GEO);
66 }
67 
68 static void
69 prmBuildRAMPMRUList(void *, PRM_Name *theMRUfiles, int thelistsize,
70  const PRM_SpareData *, const PRM_Parm *)
71 {
72  prmBuildHistoryMenu(theMRUfiles, thelistsize, FS_FILEHISTORY_RAMP);
73 }
74 
75 static void
76 prmBuildCAPTMRUList(void *, PRM_Name *theMRUfiles, int thelistsize,
77  const PRM_SpareData *, const PRM_Parm *)
78 {
79  prmBuildHistoryMenu(theMRUfiles, thelistsize, FS_FILEHISTORY_CAPT);
80 }
81 
82 static void
83 prmBuildCLIPMRUList(void *, PRM_Name *theMRUfiles, int thelistsize,
84  const PRM_SpareData *, const PRM_Parm *)
85 {
86  prmBuildHistoryMenu(theMRUfiles, thelistsize, FS_FILEHISTORY_CLIP);
87 }
88 
89 static void
90 prmBuildPAINTMRUList(void *, PRM_Name *theMRUfiles, int thelistsize,
91  const PRM_SpareData *, const PRM_Parm *)
92 {
93  prmBuildHistoryMenu(theMRUfiles, thelistsize, FS_FILEHISTORY_PAINT);
94 }
95 
96 static void
97 prmBuildLUTMRUList(void *, PRM_Name *theMRUfiles, int thelistsize,
98  const PRM_SpareData *, const PRM_Parm *)
99 {
100  prmBuildHistoryMenu(theMRUfiles, thelistsize, FS_FILEHISTORY_LUT);
101 }
102 
103 static void
104 prmBuildCMDMRUList(void *, PRM_Name *theMRUfiles, int thelistsize,
105  const PRM_SpareData *, const PRM_Parm *)
106 {
107  prmBuildHistoryMenu(theMRUfiles, thelistsize, FS_FILEHISTORY_CMD);
108 }
109 
110 static void
111 prmBuildMIDIMRUList(void *, PRM_Name *theMRUfiles, int thelistsize,
112  const PRM_SpareData *, const PRM_Parm *)
113 {
114  prmBuildHistoryMenu(theMRUfiles, thelistsize, FS_FILEHISTORY_MIDI);
115 }
116 
117 static void
118 prmBuildTXTMRUList(void *, PRM_Name *theMRUfiles, int thelistsize,
119  const PRM_SpareData *, const PRM_Parm *)
120 {
121  prmBuildHistoryMenu(theMRUfiles, thelistsize, FS_FILEHISTORY_TXT);
122 }
123 
124 static void
125 prmBuildI3DMRUList(void *, PRM_Name *theMRUfiles, int thelistsize,
126  const PRM_SpareData *, const PRM_Parm *)
127 {
128  prmBuildHistoryMenu(theMRUfiles, thelistsize, FS_FILEHISTORY_I3D);
129 }
130 
131 static void
132 prmBuildCHANMRUList(void *, PRM_Name *theMRUfiles, int thelistsize,
133  const PRM_SpareData *, const PRM_Parm *)
134 {
135  prmBuildHistoryMenu(theMRUfiles, thelistsize, FS_FILEHISTORY_CHAN);
136 }
137 
138 static void
139 prmBuildSIMMRUList(void *, PRM_Name *theMRUfiles, int thelistsize,
140  const PRM_SpareData *, const PRM_Parm *)
141 {
142  prmBuildHistoryMenu(theMRUfiles, thelistsize, FS_FILEHISTORY_SIM);
143 }
144 
145 static void
146 prmBuildSIMDATAMRUList(void *, PRM_Name *theMRUfiles, int thelistsize,
147  const PRM_SpareData *, const PRM_Parm *)
148 {
149  prmBuildHistoryMenu(theMRUfiles, thelistsize, FS_FILEHISTORY_SIMDATA);
150 }
151 
152 static void
153 prmBuildDIRMRUList(void *, PRM_Name *theMRUfiles, int thelistsize,
154  const PRM_SpareData *, const PRM_Parm *)
155 {
156  prmBuildHistoryMenu(theMRUfiles, thelistsize, FS_FILEHISTORY_DIRECTORY);
157 }
158 
159 static void
160 prmBuildMISCMRUList(void *, PRM_Name *theMRUfiles, int thelistsize,
161  const PRM_SpareData *, const PRM_Parm *)
162 {
163  prmBuildHistoryMenu(theMRUfiles, thelistsize, FS_FILEHISTORY_MISC);
164 }
165 
166 static PRM_ChoiceGenFunc
167 prmGetHistoryCallbackFunction(PRM_Type type)
168 {
169  PRM_ChoiceGenFunc callBackFunction;
170 
171  switch (type.getPathType())
172  {
174  callBackFunction = prmBuildPICMRUList;
175  break;
177  callBackFunction = prmBuildGEOMRUList;
178  break;
180  callBackFunction = prmBuildCAPTMRUList;
181  break;
183  callBackFunction = prmBuildRAMPMRUList;
184  break;
186  callBackFunction = prmBuildCLIPMRUList;
187  break;
189  callBackFunction = prmBuildPAINTMRUList;
190  break;
192  callBackFunction = prmBuildLUTMRUList;
193  break;
195  callBackFunction = prmBuildCMDMRUList;
196  break;
198  callBackFunction = prmBuildMIDIMRUList;
199  break;
201  callBackFunction = prmBuildTXTMRUList;
202  break;
204  callBackFunction = prmBuildI3DMRUList;
205  break;
207  callBackFunction = prmBuildCHANMRUList;
208  break;
210  callBackFunction = prmBuildSIMMRUList;
211  break;
213  callBackFunction = prmBuildSIMDATAMRUList;
214  break;
216  callBackFunction = prmBuildDIRMRUList;
217  break;
218  default:
219  callBackFunction = prmBuildMISCMRUList;
220  break;
221  };
222 
223  return callBackFunction;
224 }
225 
226 static PRM_ChoiceList *
227 prmFindHistoryMenuBuilder(PRM_Type type)
228 {
230  prmGetHistoryCallbackFunction(type));
231 }
232 
233 static bool
234 prmIsHistoryMenuBuilder(PRM_ChoiceList *choice_list, PRM_Type type)
235 {
236  return (choice_list && choice_list->getChoiceGenerator() &&
237  choice_list->getChoiceGenerator()
238  == prmGetHistoryCallbackFunction(type));
239 }
240 
241 #endif
FS_FileHistoryType
void setToken(const char *s)
Sets the token, doing a deep copy.
Definition: PRM_Name.h:106
void getFormattedFilenameFromList(int index, FS_FileHistoryType filetype, UT_String &path) const
PRM_ChoiceListType
PRM_ChoiceGenFunc getChoiceGenerator() const
void(* PRM_ChoiceGenFunc)(void *thedata, PRM_Name *thechoicenames, int thelistsize, const PRM_SpareData *thespareptr, const PRM_Parm *theparm)
ImageBuf OIIO_API max(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
#define FSgetFileHistoryManager
const PRM_PathType & getPathType() const
Definition: PRM_Type.h:1163
int numFilesInList(FS_FileHistoryType filetype) const
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:156
type
Definition: core.h:1059
void setLabel(const char *s)
Sets the label, doing a deep copy.
Definition: PRM_Name.h:114