Skip to content

Commit f033c62

Browse files
author
Matthias Kastner
committed
Checkbox for Sorting: CodeBrowser_gui.ipf
Checkbox Event calls updateListBoxHook() normal flow on update: updatePanel -> updateListBoxHook -> parseAllProcedureWindows updatePanel not needed. panel exists is checkbox event was raised actual Sorting in CodeBrowser.ipf parseAllProcedureWindows() calls returnCheckBoxAlpha() to get state via a ControlInfo call. returnCheckBoxAlpha() requires Panel/Checkbox to exist otherwise fall back to sorting enabled. Saving Checkbox State in package preferences CodeBrowser_preferences.ipf FillPackagePrefsStruct --> SyncPackagePrefsStruct or DefaultPackagePrefsStruct called via hook preparePanelClose (experiment exit, panel kill)
1 parent 07d60d3 commit f033c62

File tree

3 files changed

+46
-5
lines changed

3 files changed

+46
-5
lines changed

procedures/CodeBrowser.ipf

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,11 @@ Function/S parseAllProcedureWindows()
405405

406406
macList = getDecoratedMacroList(procedureWithoutModule)
407407

408-
list = SortList(funcList + macList,";",4)
408+
if (returnCheckBoxSort())
409+
list = SortList(funcList + macList,";",4) //option 4: Case-insensitive sort
410+
else
411+
list = funcList + macList
412+
endif
409413

410414
Wave/T decls = getDeclWave()
411415
Wave/D lines = getLineWave()

procedures/CodeBrowser_gui.ipf

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@
99
static Constant popupLength = 240
1010
static Constant moduleCtrlTop = 10
1111
static Constant procCtrlTop = 40
12+
static Constant SortCtrlTop = 70
1213
static Constant border = 5
13-
static Constant topSpaceList = 80
14+
static Constant topSpaceList = 90
1415

1516
static StrConstant panel = "CodeBrowser"
1617
static StrConstant moduleCtrl = "popupNamespace"
1718
static StrConstant procCtrl = "popupProcedure"
1819
static StrConstant listCtrl = "list1"
20+
static StrConstant sortCtrl = "checkboxSort"
1921
static StrConstant userDataRawList = "rawList"
2022
static StrConstant userDataNiceList = "niceList"
2123

@@ -59,6 +61,9 @@ Function createPanel()
5961
ListBox $listCtrl, win=$panel,mode=5,selCol=1, widths={4,40}, keySelectCol=1
6062
ListBox $listCtrl, win=$panel,listWave=getDeclWave()
6163

64+
CheckBox $sortCtrl, win=$panel, pos={30,SortCtrlTop},size={40,20},value=prefs.panelCheckboxSort
65+
CheckBox $sortCtrl, win=$panel, title="sort"
66+
CheckBox $sortCtrl, win=$panel, proc=$(module + "#checkboxSort")
6267
SetWindow $panel, hook(mainHook)=$(module + "#panelHook")
6368
DoUpdate/W=$panel
6469

@@ -118,6 +123,7 @@ Function resizePanel()
118123
left = (width - V_Width) / 2.0
119124
PopupMenu $moduleCtrl, win=$panel,pos={left,moduleCtrlTop}
120125
PopupMenu $procCtrl, win=$panel,pos={left+8,procCtrlTop}
126+
CheckBox $sortCtrl, win=$panel,pos={left+66,SortCtrlTop}
121127
End
122128

123129
// Must be called after every change which might affect the panel contents
@@ -305,6 +311,32 @@ Function popupProcedures(pa) : PopupMenuControl
305311
return 0
306312
End
307313

314+
Function checkboxSort(cba) : CheckBoxControl
315+
STRUCT WMCheckboxAction &cba
316+
317+
switch( cba.eventCode )
318+
case 2: // mouse up
319+
updateListBoxHook()
320+
break
321+
case -1: // control being killed
322+
break
323+
endswitch
324+
325+
return 0
326+
End
327+
328+
// returns 0 if checkbox is deselected or 1 if it is selected.
329+
Function returnCheckBoxSort()
330+
ControlInfo/W=$panel $sortCtrl
331+
if (V_flag == 2) // Checkbox found?
332+
return V_Value
333+
else
334+
//Fallback: Sorting as default behaviour
335+
return 1
336+
endif
337+
End
338+
339+
308340
Function listBoxProc(lba) : ListBoxControl
309341
STRUCT WMListboxAction &lba
310342

procedures/CodeBrowser_preferences.ipf

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@
66
// This file was created by () byte physics Thomas Braun, [email protected]
77
// (c) 2013
88

9-
static Constant kPrefsVersion = 100
9+
static Constant kPrefsVersion = 101
1010
static StrConstant kPackageName = "CodeBrowser"
1111
static StrConstant kPrefsFileName = "CodeBrowser.bin"
1212
static Constant kPrefsRecordID = 0
1313

1414
Structure CodeBrowserPrefs
1515
uint32 version // Preferences structure version number. 100 means 1.00.
1616
double panelCoords[4] // left, top, right, bottom
17-
uint32 reserved[100] // Reserved for future use
17+
uint32 panelCheckboxSort // status of checkbox in createPanel()
18+
uint32 reserved[99] // Reserved for future use
1819
EndStructure
1920

2021
// DefaultPackagePrefsStruct(prefs)
@@ -31,8 +32,10 @@ static Function DefaultPackagePrefsStruct(prefs)
3132
prefs.panelCoords[2] = 0.95 * dims.right
3233
prefs.panelCoords[3] = 0.90 * dims.bottom
3334

35+
prefs.panelCheckboxSort = 1
36+
3437
Variable i
35-
for(i=0; i<100; i+=1)
38+
for(i=0; i<99; i+=1)
3639
prefs.reserved[i] = 0
3740
endfor
3841
End
@@ -53,6 +56,8 @@ static Function SyncPackagePrefsStruct(prefs)
5356
prefs.panelCoords[1] = V_top * scale
5457
prefs.panelCoords[2] = V_right * scale
5558
prefs.panelCoords[3] = V_bottom * scale
59+
60+
prefs.panelCheckboxSort = returnCheckBoxSort()
5661
End
5762

5863
// InitPackagePrefsStruct(prefs)

0 commit comments

Comments
 (0)