image.anubis
1.6 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
The Anubis/Paradize Project.
The image widget.
Copyright (c) Alain Prouté 2004-2005.
Authors: Alain Prouté
Olivier Duvernois
In this file the 'image' widget is defined. The image widget is created either from an
'HostImage', or from the path of a JPEG file. If the JPEG file is not found an 'alert'
is generated.
read widgets3/widget.anubis
read widget.anubis
public define Widget
create_image
(
HostImage i
).
public define Widget
create_image
(
String path_to_JPEG_file
).
--- That's all for the public part ! --------------------------------------------------
public define Widget
create_image
(
HostImage im
) =
if size(im) is (w,h) then
create_widget
(
(WidgetPositionToolBox ptb) |-> unique,
(One u) |-> (w,h),
(WidgetDrawToolBox dtb) |-> draw(dtb)(im,position(0,0)),
(One u) |-> create_image(im),
(Int32 w1, Int32 h1) |-> unique,
(WidgetEventToolBox etb, WidgetNormalEvent e) |-> not_handled([]),
[]
).
public define Widget
create_image
(
String path
) =
if read_image_from_JPEG_file(path) is
{
cannot_open_file then print("Cannot open file "+path+".\n"); alert,
decompress_error then print("Error while decompressing "+path+".\n"); alert,
ok(jpeg_image) then
create_image(to_host_image(jpeg_image,1))
}.