tickets_holder.anubis
2.41 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
The Anubis/Paradize Project.
The ticket holder widget.
Copyright (c) Alain Prouté 2004-2005.
Authors: Alain Prouté
read widget.anubis
read tools.anubis
This file defines the 'ticket holder' widget. This widget has a content but is
invisible by itself. It is identical to its content except that it offers the
possibility to hold a monitoring ticket (so that it is not garbage-collected while this
widget exists).
Monitoring tickets may be of various types. Hence, each ticket is first encapsulated
into a dummy function of type One -> One. This allows to make lists of tickets, since
tir particular type does not appear.
public type TicketHolder:
th(One -> One).
Put your tickets into ticket holders with:
public define TicketHolder
ticket_holder
(
MonitoringTicket($T) ticket
).
Now keep your tickets beside a widget (content) with:
public define Widget
create_tickets_holder
(
List(TicketHolder) tickets,
Widget content
).
--- That's all for the public part ! --------------------------------------------------
public define TicketHolder
ticket_holder
(
MonitoringTicket($T) ticket
) =
th((One u) |-> forget(ticket)).
The above function '(One u) |-> forget(ticket)' will never be executed. However, it
contains a reference to the monitoring ticket. Hence, since the function will be
referenced from within the new widget, the monitoring ticket is not
garbage-collected. It is garbage-collected only when the widget itself is
garbage-collected.
public define Widget
create_tickets_holder
(
List(TicketHolder) tickets,
Widget content
) =
create_widget(
/* set childs positions */
(WidgetPositionToolBox ptb) |->
set_position(content)(ptb,position(0,0)),
/* get size */
get_size(content),
/* redraw */
redraw(content),
/* Duplicate */
(One u) |-> create_tickets_holder(tickets,duplicate(content)(unique)),
/* Change size */
(Int32 w, Int32 h) |-> alert,
/* event handling */
main_event_handler(content),
/* monitoring */
[ ]
).