aboutsummaryrefslogtreecommitdiff
path: root/exemples/Selec.pm
diff options
context:
space:
mode:
Diffstat (limited to 'exemples/Selec.pm')
-rw-r--r--exemples/Selec.pm91
1 files changed, 91 insertions, 0 deletions
diff --git a/exemples/Selec.pm b/exemples/Selec.pm
new file mode 100644
index 0000000..28237ac
--- /dev/null
+++ b/exemples/Selec.pm
@@ -0,0 +1,91 @@
+package Selec;
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU GPL General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA,
+# or refer to http://www.gnu.org/copyleft/gpl.html
+#
+
+use strict;
+
+use MTools;
+
+use vars qw /@ISA/;
+
+use MTools::MGroup;
+
+use MTools::GUI::MRect;
+use MTools::GUI::MCircle;
+
+BEGIN
+{
+ @ISA = qw /MTools::MGroup/;
+}
+
+sub new {
+ my ($class, $parent, $style, $x, $y) = @_;
+ my $self = new MTools::MGroup ($parent);
+ bless $self, $class;
+
+ $self -> recordProperty ('barycentre_x' => 0);
+ $self -> recordProperty ('barycentre_y' => 0);
+ $self -> recordProperty ('x' => $x);
+ $self -> recordProperty ('y' => $y);
+ $self -> recordProperty ('selected' => 0);
+
+ my $obj;
+
+ if ($style eq 'rectangle')
+ {
+ $obj = new MTools::GUI::MRect ($self, $x - 5, $y -5, 10, 10, -filled => 1);
+ }
+ elsif ($style eq 'circle')
+ {
+ $obj = new MTools::GUI::MCircle ($self, $x, $y, 6, -filled => 1);
+ }
+ elsif ($style eq 'point')
+ {
+ $obj = new MTools::GUI::MCircle ($self, $x, $y, 3, -filled => 1);
+ }
+
+ $self -> plisten ('selected', sub {
+ my ($src, $key, $val) = @_;
+ if ($val)
+ {
+ $obj -> mconfigure (
+ -fillcolor => 'red',
+ -linecolor => 'red',
+ );
+ }
+ else
+ {
+ $obj -> mconfigure (
+ -fillcolor => 'black',
+ -linecolor => 'black',
+ );
+ }
+ });
+
+ return $self;
+}
+
+sub setSelected {
+ my ($self, $val) = @_;
+ $self -> mconfigure ('selected' => $val);
+}
+
+sub isSelected {
+ my ($self) = @_;
+ return $self -> mget ('selected');
+}
+
+1;