-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhw4-1-3.html
170 lines (155 loc) · 4.63 KB
/
hw4-1-3.html
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
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Tree Data Structure</title>
<style>
canvas {border: 1px solid black}
</style>
</head>
<body>
you can see the tree structure by 'developer tools' menu.
<canvas id="canvas" width="1000" height="1000"></canvas>
<script src="js/myGUI.js"></script>
<script src="js/MyTree.js"></script>
<script>
var tree = create_root();
tree.add_node('main window',
{
function: 'createWindow',
parameters:
{
posX: 50,
posY: 50,
width: 800,
height: 600,
title: 'Main Window'
}
}); //assign to root
tree.add_node('textbox',
{
function: 'createTextBox',
parameters:
{
posX: 100,
posY: 100,
width: 700,
height: 100,
font: 'serif',
size: '20px',
text: 'my textbox my textbox my textbox my textbox'
}
},
'main window');
tree.add_node('menu1',
{
function: 'createMenu',
parameters:
{
posX: 100,
posY: 250,
width: 100,
height: 50,
items: ['item1', 'item2', '...', 'itmeN'],
title: 'MY_MENU',
font: 'serif',
size: '20px'
}
},
'main window');
tree.add_node('button1',
{
function: 'createButton',
parameters:
{
posX: 100,
posY: 550,
width: 100,
height: 50,
font: 'serif',
size: '20px',
text: 'Button1'
}
},
'main window');
tree.add_node('button2',
{
function: 'createButton',
parameters:
{
posX: 250,
posY: 550,
width: 100,
height: 50,
font: 'serif',
size: '20px',
text: 'Button2'
}
},
'main window');
tree.add_node('button3',
{
function: 'createButton',
parameters:
{
posX: 400,
posY: 550,
width: 100,
height: 50,
font: 'serif',
size: '20px',
text: 'Button3'
}
},
'main window');
tree.add_node('window1-1 by button1',
{
function: 'createWindow',
parameters:
{
posX: 400,
posY: 300,
width: 300,
height: 200,
title: 'Window1-1 by Button1'
}
},
'button1');
tree.add_node('textbox of window1-1',
{
function: 'createTextBox',
parameters:
{
posX: 420,
posY: 350,
width: 260,
height: 50,
font: 'serif',
size: '20px',
text: 'textbox of window1-1'
}
},
'window1-1 by button1');
tree.add_node('button1-1',
{
function: 'createButton',
parameters:
{
posX: 500,
posY: 420,
width: 100,
height: 50,
font: 'serif',
size: '20px',
text: 'Button1-1'
}
},
'window1-1 by button1');
console.log(tree);
/* render the graphic nodes by this function */
tree.render();
document.addEventListener("DOMContentLoaded", function(){init(tree)}, false);
</script>
</body>
</html>