Brought all packages under eye of strict, warnings and love of Carp, For
[sdlgit/SDL_perl.git] / lib / SDL / Cursor.pm
CommitLineData
8fde61e3 1# Cursor.pm
2#
3# Copyright (C) 2000,2002 David J. Goehrig
4#
5
6package SDL::Cursor;
7use strict;
084b921f 8use warnings;
9use Carp;
8fde61e3 10
11sub new {
12 my $proto = shift;
13 my $class = ref($proto) || $proto;
14 my %options = @_;
15
16 verify (%options, qw/ -data -mask -x -y /) if $SDL::DEBUG;
17
18 my $self = \SDL::NewCursor($options{-data},$options{-mask},
19 $options{-x},$options{-y});
20 bless $self, $class;
21 $self;
22}
23
24sub DESTROY ($) {
25 my $self = shift;
26 SDL::FreeCursor($$self);
27}
28
29sub warp ($$$) {
30 my ($self,$x,$y) = @_;
31 SDL::WarpMouse($x,$y);
32}
33
34sub use ($) {
35 my $self = shift;
36 SDL::SetCursor($$self);
37}
38
39sub get () {
40 SDL::GetCursor();
41}
42
43sub show ($;$) {
44 my ($self,$toggle) = @_;
45 SDL::ShowCursor($toggle);
46}
47
481;
49
50__END__;
51
52=pod
53
54
55
56=head1 NAME
57
58SDL::Cursor - a SDL perl extension
59
60=head1 SYNOPSIS
61
62 $cursor = SDL::Cursor->new(
63 -data => new SDL::Surface "cursor.png",
64 -mask => new SDL::Surface "mask.png",
65 -x => 0, -y => 0 );
66 $cusor->use;
67
68=head1 DESCRIPTION
69
70the SDL::Cursor module handles mouse cursors, and provide the developer to
71use custom made cursors. Note that the cursors can only be in black and
72white.
73
74=head1 METHODS
75
76=head2 new( -data => $surface_data, -mask => $surface_mask, x => $x, y => $y)
77
78Creates a new cursor. The <C>-data</C> and <C>-mask</C> parameters should be both black and white pictures. The height and width of these surfaces should be a multiple of 8. The <C>-x</C> and <C>-y</C> are the coordinates of the cursor 'hot spot'.
79
80=head2 warp($x, $y)
81
82Set the position of the cursor at the <C>$x</C>, <C>$y</C> coordinates in the application window.
83
84=head2 use()
85
86Set the cursor as the active cursor.
87
88=head2 get()
89
90When used statically <C>SDL::Cursor::get()</C>, it will return the instance of the current cursor in use. Called as a method, it will return itself.
91
92This method can be useful if you are dealing with several cursors.
93
94=head2 show($toggle)
95
96Set the visibility of the cursor. A false value will make the cursor
97invisible in the Application window. A true value will show it back.
98
99=head1 AUTHOR
100
101David J. Goehrig
102
103=head1 SEE ALSO
104
105L<perl> L<SDL::Surface>
106
107=cut