First commit of SDL_Perl-2.1.3
[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;
8
9sub new {
10 my $proto = shift;
11 my $class = ref($proto) || $proto;
12 my %options = @_;
13
14 verify (%options, qw/ -data -mask -x -y /) if $SDL::DEBUG;
15
16 my $self = \SDL::NewCursor($options{-data},$options{-mask},
17 $options{-x},$options{-y});
18 bless $self, $class;
19 $self;
20}
21
22sub DESTROY ($) {
23 my $self = shift;
24 SDL::FreeCursor($$self);
25}
26
27sub warp ($$$) {
28 my ($self,$x,$y) = @_;
29 SDL::WarpMouse($x,$y);
30}
31
32sub use ($) {
33 my $self = shift;
34 SDL::SetCursor($$self);
35}
36
37sub get () {
38 SDL::GetCursor();
39}
40
41sub show ($;$) {
42 my ($self,$toggle) = @_;
43 SDL::ShowCursor($toggle);
44}
45
461;
47
48__END__;
49
50=pod
51
52
53
54=head1 NAME
55
56SDL::Cursor - a SDL perl extension
57
58=head1 SYNOPSIS
59
60 $cursor = SDL::Cursor->new(
61 -data => new SDL::Surface "cursor.png",
62 -mask => new SDL::Surface "mask.png",
63 -x => 0, -y => 0 );
64 $cusor->use;
65
66=head1 DESCRIPTION
67
68the SDL::Cursor module handles mouse cursors, and provide the developer to
69use custom made cursors. Note that the cursors can only be in black and
70white.
71
72=head1 METHODS
73
74=head2 new( -data => $surface_data, -mask => $surface_mask, x => $x, y => $y)
75
76Creates 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'.
77
78=head2 warp($x, $y)
79
80Set the position of the cursor at the <C>$x</C>, <C>$y</C> coordinates in the application window.
81
82=head2 use()
83
84Set the cursor as the active cursor.
85
86=head2 get()
87
88When 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.
89
90This method can be useful if you are dealing with several cursors.
91
92=head2 show($toggle)
93
94Set the visibility of the cursor. A false value will make the cursor
95invisible in the Application window. A true value will show it back.
96
97=head1 AUTHOR
98
99David J. Goehrig
100
101=head1 SEE ALSO
102
103L<perl> L<SDL::Surface>
104
105=cut