-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDocking.js
207 lines (157 loc) · 4.94 KB
/
Docking.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
//WindowSystemObject (WSO) sample
//Copyright (C) Veretennikov A. B. 2004-2015
wso = new ActiveXObject("Scripting.WindowSystemObject")
wso.enableVisualStyles = true
form = wso.createForm()
form.clientWidth = 600
form.ClientHeight = 400
form.centerControl()
form.text = "Docking framework example"
var panels = []
form.docking.uniqueId = "Form1"
form.docking.dropTarget = true
form.autoSplit = true
function createDocument(name)
{
var doc = form.createFrame(10, 10, 100, 100)
doc.text = name
var edit = doc.createEdit(0,0,0,0,wso.translate("ES_MULTILINE"))
edit.align = wso.translate("AL_CLIENT")
edit.text = "Some text where"
doc.align = wso.translate("AL_CLIENT")
doc.docking.alwaysDockTab = true
doc.docking.dropTarget = true
doc.docking.uniqueId = name
panels[name] = doc
return doc
}
function createPanel(name) {
var panel = form.createFrame(10, 10, 150, 100)
panel.text = name
panel.align = wso.translate("AL_LEFT")
panel.docking.alwaysDockPage = true
panel.docking.dropTarget = true
panel.docking.uniqueId = name
panels[name] = panel
return panel
}
function createBottomPanel(name) {
var panel = form.createFrame(10, 10, 100, 100)
panel.text = name
panel.align = wso.translate("AL_BOTTOM")
panel.docking.alwaysDockPage = true
panel.docking.dropTarget = true
panel.docking.uniqueId = name
panels[name] = panel
return panel
}
function createContextPanel() {
var contextPanel = createPanel("Context")
var treeView = contextPanel.createTreeView(0, 0, 0, 0)
treeView.align = wso.translate("AL_CLIENT")
var root = treeView.items.add("Item 1")
for (i = 1; i < 5; i++) {
root.add("Item 1." + i)
}
root.expand()
return contextPanel
}
function createIndexPanel() {
var indexPanel = createPanel("Index")
var listBox = indexPanel.createListBox()
listBox.align = wso.translate("AL_CLIENT")
for (i = 1; i < 5; i++) {
listBox.add("Item 1." + i)
}
return indexPanel
}
doc1 = createDocument("Doc1")
for (i = 2; i < 4; i++) {
doc = createDocument("Doc" + i)
doc1.docking.dockAsNeighbour(doc, wso.translate("AL_CLIENT"))
}
doc1.parent.visible = true
searchPanel = createBottomPanel("Search")
consolePanel = createBottomPanel("Console")
with (consolePanel) {
with (createEdit(0, 0, 0, 0, wso.translate("ES_MULTILINE | ES_READONLY"))) {
align = wso.translate("AL_CLIENT")
add("Line 1")
add("Line 2")
add("Line 3")
}
}
with (searchPanel) {
with (createEdit(0, 0, 0, 0, wso.translate("ES_MULTILINE | ES_READONLY"))) {
align = wso.translate("AL_CLIENT")
add("Search result 1")
add("Search result 2")
add("Search result 3")
}
}
searchPanel.docking.dockAsNeighbour(consolePanel, wso.translate("AL_CLIENT"))
contextPanel = createContextPanel()
indexPanel = createIndexPanel()
contextPanel.docking.dockAsNeighbour(indexPanel, wso.translate("AL_CLIENT"))
helpPanel = createPanel("Help")
contextPanel.docking.dockAsNeighbour(helpPanel, wso.translate("AL_CLIENT"))
contextPanel.parent.visible = true
helpPanel.textOut(10, 10, "Some Help can be there")
file = form.menu.add("File")
file.add("Exit").onExecute = closeFormHandler
windows = form.menu.add("Windows")
for (name in panels) {
item = windows.add(name)
item.onExecute = showPanel
}
function showPanel(sender) {
panel = panels[sender.text]
while (true) {
panel.visible = true
if (panel.type == "Form")
break
panel = panel.parent
}
}
layout = form.menu.add("Layout")
layout.Add("Save").onExecute = saveLayout
layout.Add("Load").onExecute = loadLayout
form.Show()
wso.run()
function closeFormHandler(sender) {
sender.form.close()
}
function saveLayout() {
var text = wso.saveLayout()
var fso = new ActiveXObject("Scripting.FileSystemObject")
var file = fso.createTextFile(layoutFile())
file.writeLine(text)
file.close()
}
function loadLayout() {
var fileName = layoutFile()
var fso = new ActiveXObject("Scripting.FileSystemObject")
if (!fso.fileExists(fileName)) {
form.messageBox("File " + fileName + " does not exists")
return
}
var file = fso.OpenTextFile(fileName)
var text = file.ReadAll()
file.close()
wso.loadLayout(text)
}
function currentDir() {
var s = WScript.ScriptFullName;
s = s.substring(0, s.lastIndexOf("\\") + 1);
return s;
};
function layoutFile() {
return configurationFolder() + "DockingEx.txt"
}
function configurationFolder() {
var fso = new ActiveXObject("Scripting.FileSystemObject")
var path = fso.GetSpecialFolder(temporaryFolder = 2) + "\\WSOExamples"
if (!fso.FolderExists(path))
fso.CreateFolder(path)
return path + "\\"
}