aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormertz2002-07-02 08:23:50 +0000
committermertz2002-07-02 08:23:50 +0000
commit8c57c1d46b0760e75d35e3a36e3698ec6e0b9983 (patch)
treefe57ab6a32457a3f3ecd8e7d30c1290025c3b994
parentec013dfe0f3ed5e38b42740af0827dc51b83687d (diff)
downloadtkzinc-8c57c1d46b0760e75d35e3a36e3698ec6e0b9983.zip
tkzinc-8c57c1d46b0760e75d35e3a36e3698ec6e0b9983.tar.gz
tkzinc-8c57c1d46b0760e75d35e3a36e3698ec6e0b9983.tar.bz2
tkzinc-8c57c1d46b0760e75d35e3a36e3698ec6e0b9983.tar.xz
initial release
-rw-r--r--Perl/demos/Tk/demos/zinc_lib/textInput.pl96
1 files changed, 96 insertions, 0 deletions
diff --git a/Perl/demos/Tk/demos/zinc_lib/textInput.pl b/Perl/demos/Tk/demos/zinc_lib/textInput.pl
new file mode 100644
index 0000000..eb84832
--- /dev/null
+++ b/Perl/demos/Tk/demos/zinc_lib/textInput.pl
@@ -0,0 +1,96 @@
+#!/usr/bin/perl -w
+# $Id$
+# This simple demo has been developped by C. Mertz <mertz@cena.fr>
+
+
+use Tk;
+use Tk::Zinc;
+use strict;
+
+use Tk::ZincText; # the module for facilitating text input with zinc
+
+package textInput; # for avoiding symbol re-use between different demos
+
+my $mw = MainWindow->new();
+
+###########################################
+# Text zone
+###########################################
+
+my $text = $mw->Scrolled(qw/Text -relief sunken -borderwidth 2 -setgrid true
+ -height 4 -scrollbars e/);
+$text->pack(qw/-expand yes -fill both/);
+
+$text->insert('0.0',
+'This toy-appli demonstrates the use of the
+Tk::ZincText module. This module is designed for
+facilitating text input "a la emacs" on text items or on
+fields of items such as tracks, waypoints or tabulars.');
+
+
+###########################################
+# Zinc
+##########################################
+my $zinc = $mw->Zinc(-width => 500, -height => 300,
+ -font => "10x20",
+ -borderwidth => 3, -relief => 'sunken',
+ )->pack;
+
+new ZincText ($zinc); # for mapping text input bindings on item with a 'text' tag.
+
+
+### creating a tabular with 3 fields, 2 of them being editable
+my $labelformat1 = "130x100 x130x20+0+0 x130x20+0+20 x130x20+0+40";
+
+my $x=120;
+my $y=6;
+my $track = $zinc->add('track',1, 3,
+ -position => [$x,$y],
+ -speedvector => [40, 10],
+ -labeldistance => 30,
+ -labelformat => $labelformat1,
+ -tags => 'text',
+ );
+# moving the track, to display past positions
+foreach my $i (0..5) { $zinc->coords("$track",[$x+$i*10,$y+$i*2]); }
+
+$zinc->itemconfigure($track, 0,
+ -border => "contour",
+ -text => "not editable",
+ -sensitive => 0,
+ );
+$zinc->itemconfigure($track, 1,
+ -border => "contour",
+ -text => "editable",
+ -sensitive => 1,
+ );
+$zinc->itemconfigure($track, 2,
+ -border => "contour",
+ -text => "editable too",
+ -alignment => "center",
+ -sensitive => 1,
+ );
+
+# creating a text item, tagged with 'text', but not editable because
+# it is not sensitive
+$zinc->add('text', 1,
+ -position => [220,160],
+ -text => "this text is not
+editable because it is
+not sensitive",
+ -sensitive => 0,
+ -tags => ['text'],
+ );
+
+# creating an editable text item
+$zinc->add('text', 1,
+ -position => [50,230],
+ -text => "this text IS
+editable",
+ -sensitive => 1,
+ -tags => ['text'],
+ );
+
+
+
+Tk::MainLoop;