comparison toolboxes/graph_visualisation/lib/lefty/slides.lefty @ 0:e9a9cd732c1e tip

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