@@ -28,6 +28,8 @@ static StrConstant userDataNiceList = "niceList"
2828
2929static StrConstant oneTimeInitUserData = "oneTimeInit"
3030
31+ static StrConstant selectAll = "<ALL>"
32+
3133Function /S GetPanel ()
3234 return panel
3335End
@@ -135,6 +137,7 @@ Function/S generateModuleList()
135137 debugPrint ( "called" )
136138
137139 string niceList = getModuleList ()
140+ niceList = AddListItem ( selectAll, niceList)
138141
139142 PopupMenu $ moduleCtrl, win=$ panel, userData ( $ userDataNiceList) = niceList
140143
@@ -144,11 +147,30 @@ End
144147// Callback for the procedure popup, returns a nicified list
145148// Stores both the nicified list and the raw list as user data
146149Function /S generateProcedureList ()
147- debugPrint ( "called" )
148-
149- string module = getCurrentItem ( module=1 )
150- string procList = getProcList ( module)
151- string niceList = nicifyProcedureList ( procList)
150+ string module, modules, procList, niceList
151+ variable numModules, i
152+
153+ module = getCurrentItem ( module = 1 )
154+ if ( ! cmpstr ( module, selectAll))
155+ procList = ""
156+ niceList = ""
157+ modules = getModuleList ()
158+ numModules = ItemsInList ( modules)
159+ for ( i = 0; i < numModules; i += 1 )
160+ module = StringFromList ( i , modules)
161+ procList += getProcList ( module)
162+ if ( isProcGlobal ( module))
163+ niceList += getProcList ( module)
164+ else
165+ niceList += getProcList ( module, addModule = 1 )
166+ endif
167+ endfor
168+ else
169+ procList = getProcList ( module)
170+ niceList = procList
171+ endif
172+ niceList = ProcedureListRemoveModule ( niceList)
173+ niceList = ProcedureListRemoveEnding ( niceList)
152174
153175 PopupMenu $ procCtrl, win=$ panel, userData ( $ userDataRawList) = procList, userData ( $ userDataNiceList) = niceList
154176
@@ -208,25 +230,26 @@ Function isInitialized()
208230 return getGlobalVar ( "initialized" ) == 1
209231End
210232
211- // Returns the currently selected item from the panel defined by the optional arguments.
212- // Exactly one optional argument must be given.
213- //
214- // module: Module from ProcGlobal/Independent Module list
215- // procedure: "myProcedure.ipf [moduleName]"
216- // procedureWithModule: "myProcedure.ipf"
217- // index: Zero-based index into main listbox
218- Function /S getCurrentItem ( [ module, procedure,procedureWithoutModule, index] )
219- variable module, procedureWithoutModule, procedure, index
233+ /// Returns the currently selected item from the panel defined by the optional arguments.
234+ ///
235+ /// Exactly one optional argument must be given.
236+ ///
237+ /// @param module [optional] Module from ProcGlobal/Independent Module list
238+ /// @param procedure [optional] "myProcedure.ipf [moduleName]"
239+ /// @param index [optional] Zero-based index into main listbox
240+ ///
241+ /// @returns the currently selected item
242+ Function /S getCurrentItem ( [ module, procedure, index] )
243+ variable module, procedure, index
220244
221- string procName
245+ string procName, rawList
222246
223- module = ParamIsDefault ( module) ? 0 : 1
224- procedureWithoutModule = ParamIsDefault ( procedureWithoutModule) ? 0 : 1
225- procedure = ParamIsDefault ( procedure) ? 0 : 1
226- index = ParamIsDefault ( index) ? 0 : 1
247+ module = ParamIsDefault ( module) ? 0 : 1
248+ procedure = ParamIsDefault ( procedure) ? 0 : 1
249+ index = ParamIsDefault ( index) ? 0 : 1
227250
228251 // only one optional argument allowed
229- if ( module + procedure + procedureWithoutModule + index != 1 )
252+ if ( module + procedure + index != 1 )
230253 return "_error_"
231254 endif
232255
@@ -242,28 +265,51 @@ Function/S getCurrentItem([module, procedure,procedureWithoutModule, index])
242265 if ( V_Value >= 0 )
243266 return num2str ( V_Value)
244267 endif
245- elseif ( procedure || procedureWithoutModule)
246-
268+ elseif ( procedure)
247269 ControlInfo / W=$ panel $ procCtrl
248270 V_Value -= 1 // 1-based index
249- string rawList = GetUserData ( panel, procCtrl, userDataRawList)
250271
272+ rawList = GetUserData ( panel, procCtrl, userDataRawList)
251273 if ( V_Value < 0 || V_Value >= ItemsInList ( rawList))
252274 return "_error_"
253275 endif
254276
255- procName = StringFromList ( V_Value, rawList)
256-
257- if ( procedureWithoutModule)
258- return RemoveEverythingAfter ( procName, " [" )
259- endif
260-
277+ procName = StringFromList ( V_Value, rawList)
261278 return procName
262279 endif
263280
264281 return "_error_"
265282End
266283
284+ /// Get the basic procedure name from a full procedure name
285+ ///
286+ /// @param fullName "myProcedure.ipf [moduleName]"
287+ ///
288+ /// @returns myProcedure.ipf without module definition
289+ Function /S ProcedureWithoutModule ( fullName)
290+ string fullName
291+
292+ return RemoveEverythingAfter ( fullName, " [" )
293+ End
294+
295+ /// Get the module name from a full procedure name
296+ ///
297+ /// @param fullName "myProcedure.ipf [moduleName]"
298+ ///
299+ /// @returns moduleName without procedure specification
300+ Function /S ModuleWithoutProcedure ( fullName)
301+ string fullName
302+
303+ string module, procedure
304+
305+ SplitString / E= "(.*)\ \[ (\w +)\] " fullName, procedure, module
306+ if ( V_flag != 2 )
307+ return ""
308+ endif
309+
310+ return module
311+ End
312+
267313// Returns the currently selected item from the panel defined by the optional arguments.
268314// Argument is returned as number in current list
269315// Exactly one optional argument must be given.
@@ -304,7 +350,7 @@ Function getCurrentItemAsNumeric([module, procedure, index, indexTop])
304350 return -1 // error
305351End
306352
307- // Updates the the given popup menu
353+ // Updates the given popup menu
308354// Tries to preserve the currently selected item
309355Function updatePopup ( ctrlName)
310356 string ctrlName
@@ -320,7 +366,7 @@ Function updatePopup(ctrlName)
320366
321367 ControlUpdate / W=$ panel $ ctrlName
322368
323- list = GetUserData ( panel, procCtrl, userDataNiceList)
369+ list = GetUserData ( panel, procCtrl, userDataNiceList)
324370
325371 if ( ItemsInList ( list) == 1 )
326372 PopupMenu $ ctrlName win=$ panel, disable=2
@@ -329,10 +375,10 @@ Function updatePopup(ctrlName)
329375 endif
330376
331377 // try to restore the previously selected item if it differs from the current one
332- variable newIndex = WhichListItem ( itemText, list) + 1
378+ variable newIndex = WhichListItem ( itemText, list) + 1
333379
334380 if ( newIndex != index) // only update if required, as the update triggers the list generating function
335- if ( newIndex > 0 )
381+ if ( newIndex > 0 )
336382 PopupMenu $ ctrlName win=$ panel, mode= newIndex
337383 else
338384 PopupMenu $ ctrlName win=$ panel, mode=1
0 commit comments