aboutsummaryrefslogtreecommitdiff
path: root/Perl/demos/Tk/demos/zinc_lib/demo.pl
blob: 40ea0da8ac881875354a069f395f2d841aae2926 (plain)
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/usr/bin/perl
# $Id$
# This software is under CENA Copyright.
# However, the copyright has been retained under GPL licence
# This demo launcher has been initially developped by Daniel Etienne <etienne@cena.fr>
# and modified by Christophe Mertz <mertz@cena.fr>
# Feel free to contribute and please read our call to help below : "We need You!"

BEGIN {
    unshift(@INC, "/usr/share/doc/zinc-perl/examples/");
}

use strict;
use Tk;
use SeeCode;

my @examples =
    (
     "Examples of items" => "items.pl",
     "All Options and their types of all items" => "all_options.pl",
     "Examples of line style and line termination" => "lines.pl",
     "Groups and Priorities" => "groups_priority.pl",
     "Interactions on graphical objects" => "",
     "Simple Interactions on a track item" => "simple_interaction_track.pl",
     "Maps, uses and creations" => "",
     "Transformations examples" => "",
     "Clipping examples (with simple or multiple contours)" => "clipping.pl",
     "Curves with mutliple contours examples" => "contours.pl",
     "A simple graphical button based on pixmaps" => "",
     "A simple graphical button based on openGL (needs openGL)" => "",
     "A Zinc Goodie: \"ZincDebug.pm\"" => "",
     "Axial color variation on the X axis (needs openGL)" => "color-x.pl",
     "Axial color variation on the Y axis (needs openGL)" => "color-y.pl",
     "Circular color variation (needs openGL)" => "color-circular.pl",
     "The triangles item (needs openGL)" => "triangles.pl", 
     "A simple animated application \"the Wheel of Fortune\". It is\n".
     "An example of the use of groups, clipping and transformations"  => "wheelOfFortune.pl",
     "A simple radar display" => "simpleradar.pl",
     );

my $defaultfont = '-adobe-helvetica-bold-r-normal-*-120-*-*-*-*-*-*';
my $mw = MainWindow->new();
$mw->title("Zinc Demonstrations");
my $frame1 = $mw->Frame(-width => 520, -height => 400,-borderwidth => 3,
			-relief => 'sunken')->pack(-padx => 5, -pady => 5,
						   -ipadx => 10, -ipady => 10);

my $demoCounter=1;
for (my $i = 0; $i < @examples-1; $i += 2) {
    my $demoTitle = $examples[$i];
    if ($examples[$i+1] ne "") {
	$demoTitle = $demoCounter . ". " . $demoTitle;
	$demoCounter++;
    }
    else {
	$demoTitle = "x. " . $demoTitle;
    }
    
    my $lb =
	$frame1->Label(-text => $demoTitle,
		       -width => 55,
		       -anchor => 'w',
		       -justify => 'left',
		       )->grid(-column => 1, -row => ($i+1)/2, -pady => 10);
    if ($examples[$i+1] ne "") {
	my $cmd = Tk::findINC($examples[$i+1]);
	$frame1->Button(-text => "Run",
			-command => sub {
			    $lb->configure(-foreground => 'gray40');
			    system("/usr/bin/perl $cmd &");
			},
			)->grid(-column => 2, -row => ($i+1)/2);
    }
    else {
	$frame1->Button(-text => "ToBeDone",
			-state => "disable",
			)->grid(-column => 2, -row => ($i+1)/2);
    }
}	

my $frame2 = $mw->Frame()->pack(-expand => 1, -side => 'bottom', -fill => 'both',
				-ipady => 5);


$frame2->Button(-text => 'We need You!',
		-width => 8, -height => 1,
		-command => \&we_need_you,
		)->pack(-side => 'top', -expand => 1);

$frame2->Button(-text => 'Quit',
		-width => 8, -height => 1,
		-command => sub {exit;},
		)->pack(-side => 'top', -expand => 1);

sub we_need_you {
    my $WNY = MainWindow->new();  # WNY means We Need You!
    $WNY->title("We need You!");
        # Create a top-level window that displays a call for help!

    my $t = $WNY->Scrolled(qw/Text -relief sunken -borderwidth 2 -setgrid true
			   -height 30 -scrollbars e/);
    $t->pack(qw/-expand yes -fill both/);

    $t->insert('0.0',
'The TkZinc widget has been developped by the CENA for its own
need of prototyping environment. It is now heavily used by more
than a dozen living projects involving advanced HMI. As we
are convinced in the interest of Freee Software, Zinc is free
Software under LGPL.
Zinc is available at http://www.openatc.org/zinc or
http://freshmeat.net/projects/zincisnotcanvas/

People in charge of Zinc at CENA are good in producing good code.
They are not so good in producing extensive documentation and
examples.

This simple demo is a first try to demontrate the hidden power
behind Zinc.

If you feel happy with Zinc, feel free to contribute too!
One simple way is by producing simple samples like these
available in demo.pl

Please send us your production at pii-contact@cena.fr and
we will add it in the next release of Zinc.

        The CENA community of Zinc developpers and users.
');

    $t->mark(qw/set insert 0.0/);
    my $frame = $WNY->Frame()->pack(-expand => 1, -side => 'bottom', -fill => 'both',
				-ipady => 5);
    $frame->Button(-text => 'Quit',
		    -width => 8, -height => 1,
		    -command => sub {$WNY->destroy;},
		    )->pack(-side => 'top', -expand => 1);
    

} # end we_need_you


MainLoop;