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
|
import ("smg", "Global"); % Global namespace
static variable Button_Color = 3;
static variable Box_Color = 2;
static variable Normal_Color = 1;
smg_define_color (Button_Color, "white", "green");
smg_define_color (Box_Color, "yellow", "blue");
smg_define_color (Normal_Color, "green", "red");
static define display_button (name, r, c)
{
smg_gotorc (r, c);
smg_set_color (Button_Color);
smg_write_string (" " + name + " ");
smg_set_color (Normal_Color);
}
static define draw_centered_string (s, r, c, dc)
{
variable len;
len = strlen (s);
smg_gotorc (r, c + (dc - len)/2);
smg_write_string (s);
}
static define get_yes_no_cancel (question)
{
variable r, c, dr, dc;
dc = strlen (question) + 5;
dr = 7;
% We also need room for the yes-no-cancel buttons
if (dc < 32) dc = 36;
r = (Smg_Screen_Rows - dr)/2;
c = (Smg_Screen_Cols - dc)/2;
smg_set_color (Box_Color);
smg_draw_box (r, c, dr, dc);
smg_set_color (Normal_Color);
r += 2;
draw_centered_string (question + "?", r, c, dc);
r += 2;
display_button ("Yes", r, c + 4);
display_button ("No", r, c + 14);
display_button ("Cancel", r, c + 24);
}
smg_write_to_status_line ("smg-module demo");
smg_init_smg ();
smg_set_color(Normal_Color);
smg_erase_eos ();
get_yes_no_cancel ("This demo will exit in 5 seconds");
smg_refresh ();
sleep (5);
smg_write_to_status_line ("");
%smg_reset_smg ();
exit(0);
|