|
1 | | -#pragma rtGlobals=3 |
2 | | -#pragma version=1.0 |
3 | | -#pragma IgorVersion = 6.3.0 |
4 | | -#pragma IndependentModule=CodeBrowserModule |
5 | | - |
6 | | -// This file was created by () byte physics Thomas Braun, support@byte-physics.de |
7 | | -// (c) 2013 |
8 | | - |
9 | | -static Constant kPrefsVersion = 100 |
10 | | -static StrConstant kPackageName = "CodeBrowser" |
11 | | -static StrConstant kPrefsFileName = "CodeBrowser.bin" |
12 | | -static Constant kPrefsRecordID = 0 |
13 | | - |
14 | | -Structure CodeBrowserPrefs |
15 | | - uint32 version // Preferences structure version number. 100 means 1.00. |
16 | | - double panelCoords[4] // left, top, right, bottom |
17 | | - uint32 reserved[100] // Reserved for future use |
18 | | -EndStructure |
19 | | - |
20 | | -// DefaultPackagePrefsStruct(prefs) |
21 | | -// Sets prefs structure to default values. |
22 | | -static Function DefaultPackagePrefsStruct(prefs) |
23 | | - STRUCT CodeBrowserPrefs &prefs |
24 | | - |
25 | | - prefs.version = kPrefsVersion |
26 | | - |
27 | | - STRUCT RECT dims |
28 | | - GetScreenDimensions(dims) |
29 | | - prefs.panelCoords[0] = dims.left + 0.7 * dims.right |
30 | | - prefs.panelCoords[1] = dims.top + 35 |
31 | | - prefs.panelCoords[2] = 0.95 * dims.right |
32 | | - prefs.panelCoords[3] = 0.90 * dims.bottom |
33 | | - |
34 | | - Variable i |
35 | | - for(i=0; i<100; i+=1) |
36 | | - prefs.reserved[i] = 0 |
37 | | - endfor |
38 | | -End |
39 | | - |
40 | | -// Fill package prefs structures to match state of panel. |
41 | | -static Function SyncPackagePrefsStruct(prefs) |
42 | | - STRUCT CodeBrowserPrefs &prefs |
43 | | - |
44 | | - // Panel does exists. Set prefs to match panel settings. |
45 | | - prefs.version = kPrefsVersion |
46 | | - |
47 | | - GetWindow $GetPanel() wsize |
48 | | - // NewPanel uses device coordinates. We therefore need to scale from |
49 | | - // points (returned by GetWindow) to device units for windows created |
50 | | - // by NewPanel. |
51 | | - Variable scale = ScreenResolution / 72 |
52 | | - prefs.panelCoords[0] = V_left * scale |
53 | | - prefs.panelCoords[1] = V_top * scale |
54 | | - prefs.panelCoords[2] = V_right * scale |
55 | | - prefs.panelCoords[3] = V_bottom * scale |
56 | | -End |
57 | | - |
58 | | -// InitPackagePrefsStruct(prefs) |
59 | | -// Sets prefs structures to match state of panel or to default values if panel does not exist. |
60 | | -Function FillPackagePrefsStruct(prefs) |
61 | | - STRUCT CodeBrowserPrefs &prefs |
62 | | - |
63 | | - DoWindow $GetPanel() |
64 | | - if (V_flag == 0) |
65 | | - // Panel does not exist. Set prefs struct to default. |
66 | | - DefaultPackagePrefsStruct(prefs) |
67 | | - else |
68 | | - // Panel does exists. Sync prefs struct to match panel state. |
69 | | - SyncPackagePrefsStruct(prefs) |
70 | | - endif |
71 | | -End |
72 | | - |
73 | | -Function LoadPackagePrefsFromDisk(prefs) |
74 | | - STRUCT CodeBrowserPrefs &prefs |
75 | | - |
76 | | - // This loads preferences from disk if they exist on disk. |
77 | | - LoadPackagePreferences kPackageName, kPrefsFileName, kPrefsRecordID, prefs |
78 | | - |
79 | | - // If error or prefs not found or not valid, initialize them. |
80 | | - if (V_flag!=0 || V_bytesRead==0 || prefs.version!=kPrefsVersion) |
81 | | - FillPackagePrefsStruct(prefs) // Set based on panel if it exists or set to default values. |
82 | | - SavePackagePrefsToDisk(prefs) // Create initial prefs record. |
83 | | - endif |
84 | | -End |
85 | | - |
86 | | -Function SavePackagePrefsToDisk(prefs) |
87 | | - STRUCT CodeBrowserPrefs &prefs |
88 | | - |
89 | | - SavePackagePreferences kPackageName, kPrefsFileName, kPrefsRecordID, prefs |
90 | | -End |
| 1 | +#pragma rtGlobals=3 |
| 2 | +#pragma version=1.0 |
| 3 | +#pragma IgorVersion = 6.3.0 |
| 4 | +#pragma IndependentModule=CodeBrowserModule |
| 5 | + |
| 6 | +// This file was created by () byte physics Thomas Braun, support@byte-physics.de |
| 7 | +// (c) 2013 |
| 8 | + |
| 9 | +static Constant kPrefsVersion = 100 |
| 10 | +static StrConstant kPackageName = "CodeBrowser" |
| 11 | +static StrConstant kPrefsFileName = "CodeBrowser.bin" |
| 12 | +static Constant kPrefsRecordID = 0 |
| 13 | + |
| 14 | +Structure CodeBrowserPrefs |
| 15 | + uint32 version // Preferences structure version number. 100 means 1.00. |
| 16 | + double panelCoords[4] // left, top, right, bottom |
| 17 | + uint32 reserved[100] // Reserved for future use |
| 18 | +EndStructure |
| 19 | + |
| 20 | +// DefaultPackagePrefsStruct(prefs) |
| 21 | +// Sets prefs structure to default values. |
| 22 | +static Function DefaultPackagePrefsStruct(prefs) |
| 23 | + STRUCT CodeBrowserPrefs &prefs |
| 24 | + |
| 25 | + prefs.version = kPrefsVersion |
| 26 | + |
| 27 | + STRUCT RECT dims |
| 28 | + GetScreenDimensions(dims) |
| 29 | + prefs.panelCoords[0] = dims.left + 0.7 * dims.right |
| 30 | + prefs.panelCoords[1] = dims.top + 35 |
| 31 | + prefs.panelCoords[2] = 0.95 * dims.right |
| 32 | + prefs.panelCoords[3] = 0.90 * dims.bottom |
| 33 | + |
| 34 | + Variable i |
| 35 | + for(i=0; i<100; i+=1) |
| 36 | + prefs.reserved[i] = 0 |
| 37 | + endfor |
| 38 | +End |
| 39 | + |
| 40 | +// Fill package prefs structures to match state of panel. |
| 41 | +static Function SyncPackagePrefsStruct(prefs) |
| 42 | + STRUCT CodeBrowserPrefs &prefs |
| 43 | + |
| 44 | + // Panel does exists. Set prefs to match panel settings. |
| 45 | + prefs.version = kPrefsVersion |
| 46 | + |
| 47 | + GetWindow $GetPanel() wsize |
| 48 | + // NewPanel uses device coordinates. We therefore need to scale from |
| 49 | + // points (returned by GetWindow) to device units for windows created |
| 50 | + // by NewPanel. |
| 51 | + Variable scale = ScreenResolution / 72 |
| 52 | + prefs.panelCoords[0] = V_left * scale |
| 53 | + prefs.panelCoords[1] = V_top * scale |
| 54 | + prefs.panelCoords[2] = V_right * scale |
| 55 | + prefs.panelCoords[3] = V_bottom * scale |
| 56 | +End |
| 57 | + |
| 58 | +// InitPackagePrefsStruct(prefs) |
| 59 | +// Sets prefs structures to match state of panel or to default values if panel does not exist. |
| 60 | +Function FillPackagePrefsStruct(prefs) |
| 61 | + STRUCT CodeBrowserPrefs &prefs |
| 62 | + |
| 63 | + DoWindow $GetPanel() |
| 64 | + if (V_flag == 0) |
| 65 | + // Panel does not exist. Set prefs struct to default. |
| 66 | + DefaultPackagePrefsStruct(prefs) |
| 67 | + else |
| 68 | + // Panel does exists. Sync prefs struct to match panel state. |
| 69 | + SyncPackagePrefsStruct(prefs) |
| 70 | + endif |
| 71 | +End |
| 72 | + |
| 73 | +Function LoadPackagePrefsFromDisk(prefs) |
| 74 | + STRUCT CodeBrowserPrefs &prefs |
| 75 | + |
| 76 | + // This loads preferences from disk if they exist on disk. |
| 77 | + LoadPackagePreferences kPackageName, kPrefsFileName, kPrefsRecordID, prefs |
| 78 | + |
| 79 | + // If error or prefs not found or not valid, initialize them. |
| 80 | + if (V_flag!=0 || V_bytesRead==0 || prefs.version!=kPrefsVersion) |
| 81 | + FillPackagePrefsStruct(prefs) // Set based on panel if it exists or set to default values. |
| 82 | + SavePackagePrefsToDisk(prefs) // Create initial prefs record. |
| 83 | + endif |
| 84 | +End |
| 85 | + |
| 86 | +Function SavePackagePrefsToDisk(prefs) |
| 87 | + STRUCT CodeBrowserPrefs &prefs |
| 88 | + |
| 89 | + SavePackagePreferences kPackageName, kPrefsFileName, kPrefsRecordID, prefs |
| 90 | +End |
0 commit comments