Skip to content

Commit 7e36571

Browse files
Matthias Kastnert-b
authored andcommitted
Support for WM <Resize Controls>
Resize Controls * Added preferences of panel elements * Added Hook for directing panel changes to <Resize Controls> * Added two fixed GuideLines ** first guide sets bottom of controls and top of list ** second guide control sets bottom of list. Package Prefs: * resize from package prefs: ** separated creation and resizing of panel ** after creation, panel is resized to stored Package Prefs. * PackagePrefs supports igor7 panel resolution. * <Resize Controls> needs a minimum size: ** Updated PackagePrefs Default and Constants
1 parent abff960 commit 7e36571

File tree

4 files changed

+111
-75
lines changed

4 files changed

+111
-75
lines changed

procedures/CodeBrowser.ipf

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -991,15 +991,13 @@ static Function setCheckSum(procedure)
991991
Variable returnValue, timer
992992

993993
timer = timerStart()
994-
procText = ""
995-
// added for compatibility reasons to tb/parsing. change on merge.
996-
#if (exists("Codebrowser#getProcedureText") == 6)
994+
997995
procText = getProcedureText(procedure.module, procedure.name)
998-
#else
999996
procText = ProcedureText("", 0, procedure.fullname)
1000-
#endif
1001997
returnValue = setGlobalStr("parsingChecksum", Hash(procText, 1))
998+
1002999
setCheckSumTime(timerStop(timer))
1000+
10031001
return (returnValue == 1)
10041002
End
10051003

procedures/CodeBrowser_gui.ipf

Lines changed: 69 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,19 @@
33
#pragma IgorVersion = 6.3.0
44
#pragma IndependentModule=CodeBrowserModule
55

6+
#include <Resize Controls>
67
// This file was created by () byte physics Thomas Braun, [email protected]
78
// (c) 2013
89

9-
static Constant popupLength = 240
10+
Constant panelWidth = 278
11+
Constant panelHeight = 170
12+
Constant panelLeft = 50
13+
Constant panelTop = 50
14+
static Constant panelTopHeight= 90
15+
static Constant panelBorder = 5
1016
static Constant moduleCtrlTop = 10
1117
static Constant procCtrlTop = 40
1218
static Constant SortCtrlTop = 70
13-
static Constant border = 5
14-
static Constant topSpaceList = 90
1519

1620
static StrConstant panel = "CodeBrowser"
1721
static StrConstant moduleCtrl = "popupNamespace"
@@ -29,46 +33,87 @@ End
2933

3034
// Creates the main panel
3135
Function createPanel()
36+
STRUCT CodeBrowserPrefs prefs
37+
LoadPackagePrefsFromDisk(prefs)
3238

3339
DoWindow $panel
3440
if(V_flag != 0)
41+
DebugPrint("Panel Exists")
3542
DoWindow/F $panel
3643
return NaN
3744
endif
3845

39-
STRUCT CodeBrowserPrefs prefs
40-
LoadPackagePrefsFromDisk(prefs)
46+
// define position
47+
Variable panelLeft = 0, panelTop = 0
48+
NewPanel/N=$panel /K=1/W=(panelLeft,panelTop,panelLeft+panelWidth,panelTop+panelHeight) // left,top,right,bottom
49+
String module = GetIndependentModuleName()
4150

42-
variable left = prefs.panelCoords[0]
43-
variable top = prefs.panelCoords[1]
44-
variable right = prefs.panelCoords[2]
45-
variable bottom = prefs.panelCoords[3]
51+
PopupMenu $moduleCtrl, win=$panel,pos={panelBorder,moduleCtrlTop}, size={panelWidth-2*panelBorder,20}, bodywidth=200
52+
PopupMenu $moduleCtrl, win=$panel,title="Namespace"
53+
PopupMenu $moduleCtrl, win=$panel,proc=$(module + "#popupModules"),value=#module + "#generateModuleList()"
4654

47-
NewPanel/N=$panel /K=1/W=(left,top,right,bottom)
55+
PopupMenu $moduleCtrl, userdata(ResizeControlsInfo)= A"!!,@c!!#;-!!#B>J,hm&z!!#](Aon#azzzzzzzzzzzzzz!!#`-A7TLfzz"
56+
PopupMenu $moduleCtrl, userdata(ResizeControlsInfo) += A"zzzzzzzzzzzz!!#u:Du]k<zzzzzzzzzzz"
57+
PopupMenu $moduleCtrl, userdata(ResizeControlsInfo) += A"zzz!!#N3Bk1ct<C]S6zzzzzzzzzzzzz!!!"
4858

49-
string module = GetIndependentModuleName()
59+
PopupMenu $procCtrl, win=$panel,pos={panelBorder,procCtrlTop}, size={panelWidth-2*panelBorder,20}, bodywidth=200
60+
PopupMenu $procCtrl, win=$panel,title="Procedure"
61+
PopupMenu $procCtrl, win=$panel,proc=$(module + "#popupProcedures"),value=#module + "#generateProcedureList()"
5062

51-
PopupMenu $moduleCtrl, win=$panel,pos={30,moduleCtrlTop}, size={popupLength,20}, bodywidth=200
52-
PopupMenu $moduleCtrl, win=$panel,title="Namespace"
53-
PopupMenu $moduleCtrl, win=$panel,proc=$(module + "#popupModules"),value=#module + "#generateModuleList()"
63+
PopupMenu $procCtrl, userdata(ResizeControlsInfo)= A"!!,B9!!#>.!!#B:J,hm&z!!#](Aon#azzzzzzzzzzzzzz!!#`-A7TLfzz"
64+
PopupMenu $procCtrl, userdata(ResizeControlsInfo) += A"zzzzzzzzzzzz!!#u:Du]k<zzzzzzzzzzz"
65+
PopupMenu $procCtrl, userdata(ResizeControlsInfo) += A"zzz!!#N3Bk1ct<C]S6zzzzzzzzzzzzz!!!"
66+
67+
DefineGuide/W=$panel UGH0={FT,panelTopHeight}
68+
DefineGuide/W=$panel UGH1={FB,panelBorder}
5469

55-
PopupMenu $procCtrl, win=$panel,pos={30,procCtrlTop}, size={popupLength,20}, bodywidth=200
56-
PopupMenu $procCtrl, win=$panel,title="Procedure"
57-
PopupMenu $procCtrl, win=$panel,proc=$(module + "#popupProcedures"),value=#module + "#generateProcedureList()"
70+
ListBox $listCtrl, win=$panel,pos={panelBorder,panelTopHeight + panelBorder}, size={panelWidth-2*panelBorder,panelHeight-panelTopHeight-2*panelBorder}
71+
ListBox $listCtrl, win=$panel,proc=$(module + "#ListBoxProc")
72+
ListBox $listCtrl, win=$panel,mode=5,selCol=1, widths={4,40}, keySelectCol=1
73+
ListBox $listCtrl, win=$panel,listWave=getDeclWave()
5874

59-
ListBox $listCtrl, win=$panel,pos={border,topSpaceList}, size={300,800}
60-
ListBox $listCtrl, win=$panel,proc=$(module + "#ListBoxProc")
61-
ListBox $listCtrl, win=$panel,mode=5,selCol=1, widths={4,40}, keySelectCol=1
62-
ListBox $listCtrl, win=$panel,listWave=getDeclWave()
75+
ListBox $listCtrl, userdata(ResizeControlsInfo)= A"!!,?X!!#@\"!!#B@!!#?Ez!!#](Aon\"Qzzzzzzzzzzzzzz!!#o2B4uAezz"
76+
ListBox $listCtrl, userdata(ResizeControlsInfo) += A"zzzzzzzzzzzz!!#N3Bk1ct<C]S6zzzzzzzzzz"
77+
ListBox $listCtrl, userdata(ResizeControlsInfo) += A"zzz!!#N3Bk1ct<C]S7zzzzzzzzzzzzz!!!"
6378

64-
CheckBox $sortCtrl, win=$panel, pos={30,SortCtrlTop},size={40,20},value=prefs.panelCheckboxSort
79+
CheckBox $sortCtrl, win=$panel, pos={panelBorder+70,SortCtrlTop},size={40,20},value=prefs.panelCheckboxSort
6580
CheckBox $sortCtrl, win=$panel, title="sort"
6681
CheckBox $sortCtrl, win=$panel, proc=$(module + "#checkboxSort")
82+
83+
CheckBox $sortCtrl, userdata(ResizeControlsInfo)= A"!!,EP!!#?E!!#=o!!#<(z!!#`-A7TLfzzzzzzzzzzzzzz!!#o2B4uAezz"
84+
CheckBox $sortCtrl, userdata(ResizeControlsInfo) += A"zzzzzzzzzzzz!!#u:DuaGl<C]S6zzzzzzzzzz"
85+
CheckBox $sortCtrl, userdata(ResizeControlsInfo) += A"zzz!!#N3Bk1ct<C]S6zzzzzzzzzzzzz!!!"
86+
6787
SetWindow $panel, hook(mainHook)=$(module + "#panelHook")
68-
DoUpdate/W=$panel
6988

89+
SetWindow $panel, userdata(ResizeControlsInfo)= A"!!*'\"z!!#BE!!#A9zzzzzzzzzzzzzzzzzzzzz"
90+
SetWindow $panel, userdata(ResizeControlsInfo) += A"zzzzzzzzzzzzzzzzzzzzzzzzz"
91+
SetWindow $panel, userdata(ResizeControlsInfo) += A"zzzzzzzzzzzzzzzzzzz!!!"
92+
SetWindow $panel, userdata(ResizeControlsGuides)= "UGH0;UGH1;"
93+
SetWindow $panel, userdata(ResizeControlsInfoUGH0)= A":-hTC3`S[@0KW?-:-)m'A7]4jDg-86E][6':dmEFF(KAR85E,T>#.mm5tj<o4&A^O8Q88W:-(Bh/het@7o`,K756hm<'*TM8OQ!&3]g5.9MeM`8Q88W:-(Bh3r"
94+
SetWindow $panel, userdata(ResizeControlsInfoUGH1)= A":-hTC3`S[@0frH.:-)m'A7]4jDg-86E][6':dmEFF(KAR85E,T>#.mm5tj<o4&A^O8Q88W:-(*g0J5%54%E:B6q&gk7RB1,<CoSI1-.Kp78-NR;b9q[:JNr.3r"
95+
96+
SetWindow $panel, userdata(oneTimeInit)= "1"
97+
98+
resizeToPackagePrefs()
99+
DoUpdate/W=$panel
70100
initializePanel()
71-
resizePanel()
101+
End
102+
103+
Function resizeToPackagePrefs()
104+
STRUCT CodeBrowserPrefs prefs
105+
LoadPackagePrefsFromDisk(prefs)
106+
107+
Variable prefsLeft = prefs.panelCoords[0]
108+
Variable prefsTop = prefs.panelCoords[1]
109+
Variable prefsRight = prefs.panelCoords[2]
110+
Variable prefsBottom = prefs.panelCoords[3]
111+
112+
DoWindow $panel
113+
if(V_flag == 0)
114+
createPanel()
115+
endif
116+
MoveWindow/W=$panel prefsLeft, prefsTop, prefsRight, prefsBottom
72117
End
73118

74119
// Callback for the modules popup
@@ -97,35 +142,6 @@ Function/S generateProcedureList()
97142
return niceList
98143
End
99144

100-
// Resize the panel controls
101-
Function resizePanel()
102-
103-
DoWindow $panel
104-
if(V_flag == 0)
105-
return NaN
106-
endif
107-
108-
variable width, height, left, listBoxWidth, listBoxHeight
109-
GetWindow $panel, wsizeDC
110-
width = V_right - V_left
111-
height = V_bottom - V_top
112-
113-
listBoxWidth = width - 2*border
114-
listBoxHeight = height - border - topSpaceList
115-
116-
if(listBoxHeight < 40)
117-
return NaN
118-
endif
119-
120-
ListBox $listCtrl, win=$panel,size={listBoxWidth,listBoxHeight}
121-
122-
ControlInfo/W=$panel $moduleCtrl
123-
left = (width - V_Width) / 2.0
124-
PopupMenu $moduleCtrl, win=$panel,pos={left,moduleCtrlTop}
125-
PopupMenu $procCtrl, win=$panel,pos={left+8,procCtrlTop}
126-
CheckBox $sortCtrl, win=$panel,pos={left+66,SortCtrlTop}
127-
End
128-
129145
// Must be called after every change which might affect the panel contents
130146
// Installed as AfterCompiledHook
131147
Function updatePanel()

procedures/CodeBrowser_hooks.ipf

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,13 @@ Function panelHook(s)
7171
endif
7272
initializePanel()
7373
markAsInitialized()
74-
hookResult = 1
7574
break
7675
case 2: // kill
7776
preparePanelClose()
7877
hookResult = 1
7978
break
8079
case 6: // resize
81-
resizePanel()
82-
hookResult = 1
80+
hookResult = ResizeControls#ResizeControlsHook(s)
8381
break
8482
endswitch
8583

procedures/CodeBrowser_preferences.ipf

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

9-
static Constant kPrefsVersion = 101
9+
static Constant kPrefsVersion = 102
1010
static StrConstant kPackageName = "CodeBrowser"
1111
static StrConstant kPrefsFileName = "CodeBrowser.bin"
1212
static Constant kPrefsRecordID = 0
@@ -22,15 +22,19 @@ EndStructure
2222
// Sets prefs structure to default values.
2323
static Function DefaultPackagePrefsStruct(prefs)
2424
STRUCT CodeBrowserPrefs &prefs
25+
Variable scale
2526

2627
prefs.version = kPrefsVersion
2728

28-
STRUCT RECT dims
29-
GetScreenDimensions(dims)
30-
prefs.panelCoords[0] = dims.left + 0.7 * dims.right
31-
prefs.panelCoords[1] = dims.top + 35
32-
prefs.panelCoords[2] = 0.95 * dims.right
33-
prefs.panelCoords[3] = 0.90 * dims.bottom
29+
#if (IgorVersion() >= 7.0)
30+
scale = ScreenResolution / PanelResolution(GetPanel())
31+
#else
32+
scale = ScreenResolution / 72
33+
#endif
34+
prefs.panelCoords[0] = panelLeft * scale
35+
prefs.panelCoords[1] = panelTop * scale
36+
prefs.panelCoords[2] = (panelLeft + panelWidth) * scale
37+
prefs.panelCoords[3] = (panelTop + panelHeight) * scale
3438

3539
prefs.panelCheckboxSort = 1
3640

@@ -43,15 +47,17 @@ End
4347
// Fill package prefs structures to match state of panel.
4448
static Function SyncPackagePrefsStruct(prefs)
4549
STRUCT CodeBrowserPrefs &prefs
46-
50+
Variable scale
4751
// Panel does exists. Set prefs to match panel settings.
4852
prefs.version = kPrefsVersion
4953

50-
GetWindow $GetPanel() wsize
51-
// NewPanel uses device coordinates. We therefore need to scale from
52-
// points (returned by GetWindow) to device units for windows created
53-
// by NewPanel.
54-
Variable scale = ScreenResolution / 72
54+
GetWindow $GetPanel() wsize // returns points
55+
56+
#if (IgorVersion() >= 7.0)
57+
scale = ScreenResolution / PanelResolution(GetPanel())
58+
#else
59+
scale = ScreenResolution / 72
60+
#endif
5561
prefs.panelCoords[0] = V_left * scale
5662
prefs.panelCoords[1] = V_top * scale
5763
prefs.panelCoords[2] = V_right * scale
@@ -77,7 +83,7 @@ End
7783

7884
Function LoadPackagePrefsFromDisk(prefs)
7985
STRUCT CodeBrowserPrefs &prefs
80-
86+
Variable scale
8187
// This loads preferences from disk if they exist on disk.
8288
LoadPackagePreferences kPackageName, kPrefsFileName, kPrefsRecordID, prefs
8389

@@ -86,10 +92,28 @@ Function LoadPackagePrefsFromDisk(prefs)
8692
FillPackagePrefsStruct(prefs) // Set based on panel if it exists or set to default values.
8793
SavePackagePrefsToDisk(prefs) // Create initial prefs record.
8894
endif
95+
96+
97+
#if (IgorVersion() >= 7.0)
98+
scale = ScreenResolution / PanelResolution(GetPanel())
99+
#else
100+
scale = ScreenResolution / 72
101+
#endif
102+
prefs.panelCoords[0] /= scale
103+
prefs.panelCoords[1] /= scale
104+
prefs.panelCoords[2] /= scale
105+
prefs.panelCoords[3] /= scale
106+
89107
End
90108

91109
Function SavePackagePrefsToDisk(prefs)
92110
STRUCT CodeBrowserPrefs &prefs
93111

94112
SavePackagePreferences kPackageName, kPrefsFileName, kPrefsRecordID, prefs
95113
End
114+
115+
// Used to test SavePackagePreferences /KILL flag added in Igor Pro 6.10B04.
116+
Function KillPackagePrefs()
117+
STRUCT CodeBrowserPrefs prefs
118+
SavePackagePreferences /KILL kPackageName, kPrefsFileName, kPrefsRecordID, prefs
119+
End

0 commit comments

Comments
 (0)