You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
911 B
49 lines
911 B
13 years ago
|
package CannonField;
|
||
|
use strict;
|
||
13 years ago
|
use TQt;
|
||
|
use TQt::isa qw(TQt::Widget);
|
||
|
use TQt::signals
|
||
13 years ago
|
angleChanged => ['int'];
|
||
13 years ago
|
use TQt::slots
|
||
13 years ago
|
setAngle => ['int'];
|
||
13 years ago
|
use TQt::attributes qw(
|
||
13 years ago
|
ang
|
||
|
);
|
||
|
use POSIX qw(atan);
|
||
|
|
||
|
sub angle () { ang }
|
||
|
|
||
|
sub NEW {
|
||
|
shift->SUPER::NEW(@_);
|
||
|
|
||
|
ang = 45;
|
||
13 years ago
|
setPalette(TQt::Palette(TQt::Color(250, 250, 200)));
|
||
13 years ago
|
}
|
||
|
|
||
|
sub setAngle {
|
||
|
my $degrees = shift;
|
||
|
$degrees = 5 if $degrees < 5;
|
||
|
$degrees = 70 if $degrees > 70;
|
||
|
return if ang == $degrees;
|
||
|
ang = $degrees;
|
||
|
repaint();
|
||
|
emit angleChanged(ang);
|
||
|
}
|
||
|
|
||
|
sub paintEvent {
|
||
13 years ago
|
my $p = TQt::Painter(this);
|
||
13 years ago
|
$p->setBrush(&blue);
|
||
|
$p->setPen(&NoPen);
|
||
|
|
||
|
$p->translate(0, rect()->bottom);
|
||
13 years ago
|
$p->drawPie(TQt::Rect(-35, -35, 70, 70), 0, 90*16);
|
||
13 years ago
|
$p->rotate(- ang);
|
||
13 years ago
|
$p->drawRect(TQt::Rect(33, -4, 15, 8));
|
||
13 years ago
|
}
|
||
|
|
||
|
sub sizePolicy {
|
||
13 years ago
|
TQt::SizePolicy(&TQt::SizePolicy::Expanding, &TQt::SizePolicy::Expanding);
|
||
13 years ago
|
}
|
||
|
|
||
|
1;
|