window.anubis
6.97 KB
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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
The Anubis/Paradize Project.
The window widget.
Copyright (c) Alain Prouté 2004-2005.
Authors: Alain Prouté
Olivier Duvernois
read widget.anubis
read tools.anubis
read table.anubis
read simple_window.anubis
read scrollbar.anubis
read box.anubis
read resizer.anubis
read tickets_holder.anubis
This 'window' widget is a combination of several 'atomic' widgets. Actually, the window
widget is a table designed as follows:
+-----------------------+---+
| | |
| | |
| | |
| | |
| | |
| 1 | 2 |
| | |
| | |
| | |
| | |
| | |
+-----------------------+---+
| 3 | 4 |
+-----------------------+---+
where cell 1 contains a simple window, cells 2 and 3 scrollbars, and cell 4 is empty.
However, the vertical scrollbar or the horizontal scrollbar may be absent. We also
provide a function for creating a window whoses scrollbars appear automatically
depending on the size of the window and the size of the content. Use one of the
following for creating a window:
create_window_both for creating a window with two scrollbars
create_window_vertical for creating a window with only a vertical scrollbar
create_window_horizontal for creating a window with only an horizontal scrollbar
create_window_automatic for creating a window with automatic scrollbars
public define Widget
create_window_both
(
WidgetParameters parameters,
Var(Int32) width, // dimensions of cell 1
Var(Int32) height,
Widget content // content of simple window in cell 1
).
public define Widget
create_window_vertical
(
WidgetParameters parameters,
Var(Int32) width,
Var(Int32) height,
Widget content
).
public define Widget
create_window_horizontal
(
WidgetParameters parameters,
Var(Int32) width,
Var(Int32) height,
Widget content
).
public define Widget
create_window_automatic
(
WidgetParameters parameters,
Var(Int32) width,
Var(Int32) height,
Widget content
).
--- That's all for the public part ! --------------------------------------------------
public define Widget
create_window_both
(
WidgetParameters parms,
Var(Int32) width_v,
Var(Int32) height_v,
Widget content
) =
if get_size(content)(unique) is (cont_w,cont_h) then
with win_x_v = var((Int32)0),
win_y_v = var((Int32)0),
v_domain_v = var((Int32)(*height_v)-24),
h_domain_v = var((Int32)(*width_v)-24),
cont_w_v = var((Int32)cont_w),
cont_h_v = var((Int32)cont_h),
w_v = var((Int32)12),
create_tickets_holder([
ticket_holder(register_monitor(height_v,(One u) |-> v_domain_v <- (*height_v)-24)),
ticket_holder(register_monitor(width_v ,(One u) |-> h_domain_v <- (*width_v )-24)),
],
create_table(borders(parms,0,0),
0,0,
[
[
cell(center,center,
create_simple_window(width_v,height_v,win_x_v,win_y_v,content)),
cell(center,center,
create_vertical_scrollbar(parms,v_domain_v,w_v,cont_h_v,win_y_v,height_v))
],
[
cell(center,center,
create_horizontal_scrollbar(parms,h_domain_v,w_v,cont_w_v,win_x_v,width_v)),
cell(center,center,
create_resizer(parms,width_v,height_v,w_v))
]
])).
public define Widget
create_window_vertical
(
WidgetParameters parms,
Var(Int32) width_v,
Var(Int32) height_v,
Widget content
) =
if get_size(content)(unique) is (cont_w,cont_h) then
with win_x_v = var((Int32)0),
win_y_v = var((Int32)0),
v_domain_v = var((Int32)(*height_v)-24),
h_domain_v = var((Int32)(*width_v)-24),
cont_w_v = var((Int32)cont_w),
cont_h_v = var((Int32)cont_h),
w_v = var((Int32)12),
create_table(borders(parms,0,0),
0,0,
[
[
cell(center,center,
create_simple_window(width_v,height_v,win_x_v,win_y_v,content)),
cell(center,center,
create_vertical_scrollbar(parms,v_domain_v,w_v,cont_h_v,win_y_v,height_v))
]
]).
public define Widget
create_window_horizontal
(
WidgetParameters parms,
Var(Int32) width_v,
Var(Int32) height_v,
Widget content
) =
if get_size(content)(unique) is (cont_w,cont_h) then
with win_x_v = var((Int32)0),
win_y_v = var((Int32)0),
v_domain_v = var((Int32)(*height_v)-24),
h_domain_v = var((Int32)(*width_v)-24),
cont_w_v = var((Int32)cont_w),
cont_h_v = var((Int32)cont_h),
w_v = var((Int32)12),
create_table(borders(parms,0,0),
0,0,
[
[
cell(center,center,
create_simple_window(width_v,height_v,win_x_v,win_y_v,content)),
],
[
cell(center,center,
create_horizontal_scrollbar(parms,h_domain_v,w_v,cont_w_v,win_x_v,width_v))
]
]).
public define Widget
create_window_automatic
(
WidgetParameters parms,
Var(Int32) width,
Var(Int32) height,
Widget content
) =
if get_size(content)(unique) is (mw,mh) then
if (*width < mw)
then if (*height < mh)
then // content is both too wide and too high
create_box(relief(parms),2,
create_window_both(parms,var((Int32)(*width)-30),var((Int32)(*height)-30),content))
else // content is just too wide
create_box(relief(parms),2,
create_window_horizontal(parms,var((Int32)(*width)-30),var((Int32)mh),content))
else if (*height < mh)
then // content is just too high
create_box(relief(parms),2,
create_window_vertical(parms,var((Int32)mw),var((Int32)(*height)-30),content))
else // content fits
content.