Thread OO-Button-Modul: für SDL (ab geht um OO) (37 answers)
Opened by master at 2006-03-31 19:08

renee
 2006-04-03 12:20
#64256 #64256
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package SDL::X::SimpleButton;

sub new {
my ($class,@params) = @_;
my $self = {};
bless($self,$class);

for(qw(ID APP X IMG IMGHV)){
$self->{$_} = shift(@params);
}
$self->{HV} = 0;

$self->draw($self->{IMG});

return($self);
}


sub draw{
my ($self,$img) = @_;

my $frame_rect = SDL::Rect->new(-height => $img->height(),-width => $img->width(),-x => 0, -y => 0);
my $dest_rect = SDL::Rect->new(-height => $img->height(),-width => $img->width(),
-x => $self->{X},-y => $self->{Y},);

$img->blit( $frame_rect, $self->{APP}, $dest_rect );
$self->{APP}->update( $dest_rect );
$self->{APP}->flip;
return 1;
}

sub check{
my ($self,$mx,$my,$event) = @_;

my $img = $self->{IMG};

#Hover - Effekt
if($mx > $self->{X} &&
$mx < ($self->{X}+ $img->width) &&
$my > $self->{Y} &&
$my < ($self->{Y}+ $img->height) ){

if(not $self->{HV}) {
$self->{HV}=1;
$self->draw($self->{IMGHV});
}
if($event->button == 1 ) {
return $self->{ID};
}
}
else{
if($self->{HV}) {
$self->{HV}=0;
$self->draw($self->{IMG});
}
return 0;
}

}

1;
\n\n

<!--EDIT|renee|1144052691-->
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/

View full thread OO-Button-Modul: für SDL (ab geht um OO)