From b2af005db21bd8fd068cb79b2ae700953128af2c Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Sun, 1 Jan 2012 18:29:30 -0600 Subject: Move PerlQt --- PerlTQt/tutorials/t9/LCDRange.pm | 43 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 PerlTQt/tutorials/t9/LCDRange.pm (limited to 'PerlTQt/tutorials/t9/LCDRange.pm') diff --git a/PerlTQt/tutorials/t9/LCDRange.pm b/PerlTQt/tutorials/t9/LCDRange.pm new file mode 100644 index 0000000..ab63af0 --- /dev/null +++ b/PerlTQt/tutorials/t9/LCDRange.pm @@ -0,0 +1,43 @@ +package LCDRange; +use strict; +use TQt; +use TQt::isa qw(TQt::VBox); +use TQt::slots + setValue => ['int'], + setRange => ['int', 'int']; +use TQt::signals + valueChanged => ['int']; +use TQt::attributes qw( + slider +); + +sub NEW { + shift->SUPER::NEW(@_); + + my $lcd = TQt::LCDNumber(2, this, "lcd"); + + slider = TQt::Slider(&Horizontal, this, "slider"); + slider->setRange(0, 99); + slider->setValue(0); + $lcd->connect(slider, TQT_SIGNAL('valueChanged(int)'), TQT_SLOT('display(int)')); + this->connect(slider, TQT_SIGNAL('valueChanged(int)'), TQT_SIGNAL('valueChanged(int)')); + + setFocusProxy(slider); +} + +sub value { slider->value } + +sub setValue { slider->setValue(shift) } + +sub setRange { + my($minVal, $maxVal) = @_; + if($minVal < 0 || $maxVal > 99 || $minVal > $maxVal) { + warn "LCDRange::setRange($minVal,$maxVal)\n" . + "\tRange must be 0..99\n" . + "\tand minVal must not be greater than maxVal\n"; + return; + } + slider->setRange($minVal, $maxVal); +} + +1; -- cgit v1.2.1