diff options
Diffstat (limited to 'src/MTools/Widget/MRadioBouton.pm')
-rw-r--r-- | src/MTools/Widget/MRadioBouton.pm | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/src/MTools/Widget/MRadioBouton.pm b/src/MTools/Widget/MRadioBouton.pm new file mode 100644 index 0000000..630f0f6 --- /dev/null +++ b/src/MTools/Widget/MRadioBouton.pm @@ -0,0 +1,108 @@ +package MTools::Widget::MRadioBouton; +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU LGPL Libray 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 Library General Public License for more details. +# +# You should have received a copy of the GNU Library 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/lgpl.html +# +################################################################## + +use strict; +use MTools; +use MTools::MGroup; +use MTools::MSwitch; +use MTools::MState; + +use vars qw /@ISA/; + +BEGIN +{ + @ISA = qw /MTools::MGroup/; +} + +sub new { + my ($class, %options) = @_; + my $self = new MTools::MGroup ($options {parent}); + + bless $self, $class; + + my $on = $options {g_on}; + my $off = $options {g_off}; + + $self -> recordEvent ('RELEASE'); + $self -> recordEvent ('PRESS'); + $self -> recordProperty ('selected', 0); + + my @gon; + push (@gon, $on); + my @goff; + push (@goff, $off); + + if (defined $options {g_text}) + { + $self -> recordProperty ('text', $options {text}); + my $txt = minstance ($options {g_text}, $self); + push (@gon, $txt); + push (@goff, $txt); + plink ([$self, 'text'], [$txt, '-text']); + } + $self -> mconfigure (-atomic => 1); + my $sw = new MTools::MSwitch ( + $self, + on => \@gon, + off => \@goff, + ); + my $st = new MTools::MState ( + current_state => 'on', + events => { + press => [$self, '<Button-1>'], + press2 => [$self, 'PRESS'], + release => [$self, 'RELEASE'], + }, + transitions => { + on => { + press => { + to => 'off', + notify => 'PRESSED', + }, + press2 => { + to => 'off', + notify => 'PRESSED', + }, + }, + off => { + release => { + to => 'on', + notify => 'RELEASED', + }, + }, + }, + switchs => [$sw], + ); + + $st -> binding ('PRESSED', sub { + $self -> mconfigure ('selected', 1); + }); + + $st -> binding ('RELEASED', sub { + $self -> mconfigure ('selected', 0); + }); + + $self -> propagate ($st, 'PRESSED'); + + + return $self; +} + + +1; + |