wolffd@0
|
1 load ('def.lefty');
|
wolffd@0
|
2 definit ();
|
wolffd@0
|
3 #
|
wolffd@0
|
4 # initialize window data
|
wolffd@0
|
5 #
|
wolffd@0
|
6 canvas = defcanvas;
|
wolffd@0
|
7 wrect = [0 = ['x' = 0; 'y' = 0;]; 1 = ['x' = 800; 'y' = 1000;];];
|
wolffd@0
|
8 lmargin = 100;
|
wolffd@0
|
9 width = 800;
|
wolffd@0
|
10 height = 1000;
|
wolffd@0
|
11 setwidgetattr (canvas, ['window' = wrect;]);
|
wolffd@0
|
12 fonts = [
|
wolffd@0
|
13 'timr' = [
|
wolffd@0
|
14 14 = 'timr14';
|
wolffd@0
|
15 18 = 'timr18';
|
wolffd@0
|
16 24 = 'timr24';
|
wolffd@0
|
17 ];
|
wolffd@0
|
18 'courr' = [
|
wolffd@0
|
19 14 = 'courr14';
|
wolffd@0
|
20 18 = 'courr18';
|
wolffd@0
|
21 24 = 'courr24';
|
wolffd@0
|
22 ];
|
wolffd@0
|
23 ];
|
wolffd@0
|
24 x2ps = [
|
wolffd@0
|
25 'timr24' = 'Times-Roman';
|
wolffd@0
|
26 'timr18' = 'Times-Roman';
|
wolffd@0
|
27 'timr14' = 'Times-Roman';
|
wolffd@0
|
28 'courr24' = 'Courier';
|
wolffd@0
|
29 'courr18' = 'Courier';
|
wolffd@0
|
30 'courr14' = 'Courier';
|
wolffd@0
|
31 ];
|
wolffd@0
|
32
|
wolffd@0
|
33 calc = function () {
|
wolffd@0
|
34 local i, j, cpos, tsiz, dist, slidep;
|
wolffd@0
|
35 tsiz = ['x' = 0; 'y' = 0;];
|
wolffd@0
|
36 for (i = 0; slides[i]; i = i + 1) {
|
wolffd@0
|
37 slidep = slides[i];
|
wolffd@0
|
38 if (slidep.skip) {
|
wolffd@0
|
39 tsiz.y = tsiz.y + slidep.skip;
|
wolffd@0
|
40 } else {
|
wolffd@0
|
41 for (j = 0; slidep.text[j]; j = j + 1) {
|
wolffd@0
|
42 if (j > 0)
|
wolffd@0
|
43 tsiz.y = tsiz.y + 5;
|
wolffd@0
|
44 if (~slidep.font)
|
wolffd@0
|
45 slidep.font = slides.font;
|
wolffd@0
|
46 if (~slidep.size)
|
wolffd@0
|
47 slidep.size = slides.size;
|
wolffd@0
|
48 if (~slidep.just)
|
wolffd@0
|
49 slidep.just = slides.just;
|
wolffd@0
|
50 slidep.tsiz[j] = textsize (canvas, slidep.text[j],
|
wolffd@0
|
51 fonts[slidep.font][slidep.size], 0);
|
wolffd@0
|
52 tsiz.y = tsiz.y + slidep.tsiz[j].y;
|
wolffd@0
|
53 }
|
wolffd@0
|
54 }
|
wolffd@0
|
55 }
|
wolffd@0
|
56 dist = (height - tsiz.y) / (i + 1);
|
wolffd@0
|
57 cpos = ['x' = lmargin; 'y' = height - dist;];
|
wolffd@0
|
58 for (i = 0; slides[i]; i = i + 1) {
|
wolffd@0
|
59 slidep = slides[i];
|
wolffd@0
|
60 if (slidep.skip) {
|
wolffd@0
|
61 cpos.y = cpos.y - slidep.skip - dist;
|
wolffd@0
|
62 } else {
|
wolffd@0
|
63 for (j = 0; slidep.text[j]; j = j + 1) {
|
wolffd@0
|
64 if (j > 0)
|
wolffd@0
|
65 cpos.y = cpos.y - 5;
|
wolffd@0
|
66 if (slidep.just == 0)
|
wolffd@0
|
67 slidep.tpos[j].x = cpos.x;
|
wolffd@0
|
68 else
|
wolffd@0
|
69 slidep.tpos[j].x = width / 2;
|
wolffd@0
|
70 cpos.y = cpos.y - slidep.tsiz[j].y;
|
wolffd@0
|
71 slidep.tpos[j].y = cpos.y;
|
wolffd@0
|
72 }
|
wolffd@0
|
73 cpos.y = cpos.y - dist;
|
wolffd@0
|
74 }
|
wolffd@0
|
75 }
|
wolffd@0
|
76 };
|
wolffd@0
|
77 redraw = function () {
|
wolffd@0
|
78 local i, j, slidep;
|
wolffd@0
|
79 for (i = 0; slides[i]; i = i + 1) {
|
wolffd@0
|
80 slidep = slides[i];
|
wolffd@0
|
81 if (~slidep.skip)
|
wolffd@0
|
82 for (j = 0; slidep.text[j]; j = j + 1)
|
wolffd@0
|
83 text (canvas, slidep, slidep.tpos[j], slidep.text[j],
|
wolffd@0
|
84 fonts[slidep.font][slidep.size], 0, slidep.just);
|
wolffd@0
|
85 }
|
wolffd@0
|
86 };
|
wolffd@0
|
87 dops = function () {
|
wolffd@0
|
88 local i, j, slidep, r;
|
wolffd@0
|
89
|
wolffd@0
|
90 r = [0 = ['x' = 0; 'y' = 0;]; 1 = ['x' = 8 * 300; 'y' = 10.5 * 300;];];
|
wolffd@0
|
91 canvas = createwidget (-1, ['type' = 'ps'; 'origin' = r[0]; 'size' = r[1]
|
wolffd@0
|
92 ;]);
|
wolffd@0
|
93 setwidgetattr (canvas, ['window' = wrect;]);
|
wolffd@0
|
94 for (i = 0; slides[i]; i = i + 1) {
|
wolffd@0
|
95 slidep = slides[i];
|
wolffd@0
|
96 if (~slidep.skip)
|
wolffd@0
|
97 for (j = 0; slidep.text[j]; j = j + 1)
|
wolffd@0
|
98 text (canvas, slidep, slidep.tpos[j], slidep.text[j],
|
wolffd@0
|
99 x2ps[fonts[slidep.font][slidep.size]],
|
wolffd@0
|
100 slidep.tsiz[j].y, slidep.just, 1);
|
wolffd@0
|
101 }
|
wolffd@0
|
102 destroywidget (canvas);
|
wolffd@0
|
103 canvas=defcanvas;
|
wolffd@0
|
104 };
|
wolffd@0
|
105 doit = function () {
|
wolffd@0
|
106 calc ();
|
wolffd@0
|
107 redraw ();
|
wolffd@0
|
108 dops ();
|
wolffd@0
|
109 };
|