Commit | Line | Data |
8fde61e3 |
1 | # Cursor.pm |
2 | # |
3 | # Copyright (C) 2000,2002 David J. Goehrig |
4 | # |
5 | |
6 | package SDL::Cursor; |
7 | use strict; |
084b921f |
8 | use warnings; |
9 | use Carp; |
8fde61e3 |
10 | |
11 | sub 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 | |
24 | sub DESTROY ($) { |
25 | my $self = shift; |
26 | SDL::FreeCursor($$self); |
27 | } |
28 | |
29 | sub warp ($$$) { |
30 | my ($self,$x,$y) = @_; |
31 | SDL::WarpMouse($x,$y); |
32 | } |
33 | |
34 | sub use ($) { |
35 | my $self = shift; |
36 | SDL::SetCursor($$self); |
37 | } |
38 | |
39 | sub get () { |
40 | SDL::GetCursor(); |
41 | } |
42 | |
43 | sub show ($;$) { |
44 | my ($self,$toggle) = @_; |
45 | SDL::ShowCursor($toggle); |
46 | } |
47 | |
48 | 1; |
49 | |
50 | __END__; |
51 | |
52 | =pod |
53 | |
54 | |
55 | |
56 | =head1 NAME |
57 | |
58 | SDL::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 | |
70 | the SDL::Cursor module handles mouse cursors, and provide the developer to |
71 | use custom made cursors. Note that the cursors can only be in black and |
72 | white. |
73 | |
74 | =head1 METHODS |
75 | |
76 | =head2 new( -data => $surface_data, -mask => $surface_mask, x => $x, y => $y) |
77 | |
78 | Creates 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 | |
82 | Set the position of the cursor at the <C>$x</C>, <C>$y</C> coordinates in the application window. |
83 | |
84 | =head2 use() |
85 | |
86 | Set the cursor as the active cursor. |
87 | |
88 | =head2 get() |
89 | |
90 | When 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 | |
92 | This method can be useful if you are dealing with several cursors. |
93 | |
94 | =head2 show($toggle) |
95 | |
96 | Set the visibility of the cursor. A false value will make the cursor |
97 | invisible in the Application window. A true value will show it back. |
98 | |
99 | =head1 AUTHOR |
100 | |
101 | David J. Goehrig |
102 | |
103 | =head1 SEE ALSO |
104 | |
105 | L<perl> L<SDL::Surface> |
106 | |
107 | =cut |