Top Description Inners Fields Constructors Methods
org.lwjgl.input

public Class Cursor

extends Object
Class Inheritance
Imports
java.nio.IntBuffer, org.lwjgl.BufferChecks, .BufferUtils, .LWJGLException, .LWJGLUtil, .Sys

A class representing a native cursor. Instances of this class can be used with Mouse.setCursor(), if available.
Author
elias_naur
Version
$Revision$ $Id$

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
Cursor.CursorElement

A single cursor element, used when animating

Field Summary

Modifier and TypeField and Description
public static final int
CURSOR_8_BIT_ALPHA

8 bit alhpa native cursor

public static final int
CURSOR_ANIMATION

animation native cursor

public static final int
CURSOR_ONE_BIT_TRANSPARENCY

1 bit transparency for native cursor

private final Cursor.CursorElement[]
cursors

First element to display

private boolean
private int
index

Index into list of cursors

Constructor Summary

AccessConstructor and Description
public
Cursor(int
cursor image width
width
,
int
cursor image height
height
,
int
the x coordinate of the cursor hotspot
xHotspot
,
int
the y coordinate of the cursor hotspot
yHotspot
,
int
number of cursor images specified. Must be 1 if animations are not supported.
numImages
,
IntBuffer
A buffer containing the images. The origin is at the lower left corner, like OpenGL.
images
,
IntBuffer
An int buffer of animation frame delays, if numImages is greater than 1, else null
delays
)

Constructs a new Cursor, with the given parameters.

Method Summary

Modifier and TypeMethod and Description
private void
private static void
convertARGBtoABGR(IntBuffer
image to convert
imageBuffer
)

Convert an IntBuffer image of ARGB format into ABGR

private static Cursor.CursorElement[]
createCursors(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays)

Creates the actual cursor, using a platform specific class

public void
destroy()

Destroy the native cursor.

private static void
flipImage(int
Width of image
width
,
int
Height of images
height
,
int
index into source buffer to copy to
start_index
,
IntBuffer
Source images
images
,
IntBuffer
Destination images
images_copy
)

private static void
flipImages(int
Width of image
width
,
int
Height of images
height
,
int
How many images to flip
numImages
,
IntBuffer
Source images
images
,
IntBuffer
Destination images
images_copy
)

Flips the images so they're oriented according to opengl

public static int

Returns:

A bit mask with native cursor capabilities.
getCapabilities
()

Get the capabilities of the native cursor.

pack-priv Object
getHandle()

Gets the native handle associated with the cursor object.

public static int

Returns:

the maximum size of a native cursor
getMaxCursorSize
()

Gets the maximum size of a native cursor.

public static int

Returns:

the maximum size of a native cursor
getMinCursorSize
()

Gets the minimum size of a native cursor.

protected boolean

Returns:

true if the this cursor has timed out, false if not
hasTimedOut
()

Determines whether this cursor has timed out

protected void
nextCursor()

Changes to the next cursor

protected void
setTimeout()

Sets the timout property to the time it should be changed

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CURSOR_8_BIT_ALPHAback to summary
public static final int CURSOR_8_BIT_ALPHA

8 bit alhpa native cursor

CURSOR_ANIMATIONback to summary
public static final int CURSOR_ANIMATION

animation native cursor

CURSOR_ONE_BIT_TRANSPARENCYback to summary
public static final int CURSOR_ONE_BIT_TRANSPARENCY

1 bit transparency for native cursor

cursorsback to summary
private final Cursor.CursorElement[] cursors

First element to display

destroyedback to summary
private boolean destroyed
indexback to summary
private int index

Index into list of cursors

Constructor Detail

Cursorback to summary
public Cursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException

Constructs a new Cursor, with the given parameters. Mouse must have been created before you can create Cursor objects. Cursor images are in ARGB format, but only one bit transparancy is guaranteed to be supported. So to maximize portability, lwjgl applications should only create cursor images with 0x00 or 0xff as alpha values. The constructor will copy the images and delays, so there's no need to keep them around.

Parameters
width:int

cursor image width

height:int

cursor image height

xHotspot:int

the x coordinate of the cursor hotspot

yHotspot:int

the y coordinate of the cursor hotspot

numImages:int

number of cursor images specified. Must be 1 if animations are not supported.

images:IntBuffer

A buffer containing the images. The origin is at the lower left corner, like OpenGL.

delays:IntBuffer

An int buffer of animation frame delays, if numImages is greater than 1, else null

Exceptions
LWJGLException:
if the cursor could not be created for any reason

Method Detail

checkValidback to summary
private void checkValid()
convertARGBtoABGRback to summary
private static void convertARGBtoABGR(IntBuffer imageBuffer)

Convert an IntBuffer image of ARGB format into ABGR

Parameters
imageBuffer:IntBuffer

image to convert

createCursorsback to summary
private static Cursor.CursorElement[] createCursors(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException

Creates the actual cursor, using a platform specific class

destroyback to summary
public void destroy()

Destroy the native cursor. If the cursor is current, the current native cursor is set to null (the default OS cursor)

flipImageback to summary
private static void flipImage(int width, int height, int start_index, IntBuffer images, IntBuffer images_copy)
Parameters
width:int

Width of image

height:int

Height of images

start_index:int

index into source buffer to copy to

images:IntBuffer

Source images

images_copy:IntBuffer

Destination images

flipImagesback to summary
private static void flipImages(int width, int height, int numImages, IntBuffer images, IntBuffer images_copy)

Flips the images so they're oriented according to opengl

Parameters
width:int

Width of image

height:int

Height of images

numImages:int

How many images to flip

images:IntBuffer

Source images

images_copy:IntBuffer

Destination images

getCapabilitiesback to summary
public static int getCapabilities()

Get the capabilities of the native cursor. Return a bit mask of the native cursor capabilities. The CURSOR_ONE_BIT_TRANSPARANCY indicates support for cursors with one bit transparancy, the CURSOR_8_BIT_ALPHA indicates support for 8 bit alpha and CURSOR_ANIMATION indicates support for cursor animations.

Returns:int

A bit mask with native cursor capabilities.

getHandleback to summary
pack-priv Object getHandle()

Gets the native handle associated with the cursor object.

getMaxCursorSizeback to summary
public static int getMaxCursorSize()

Gets the maximum size of a native cursor. Can only be called if The Mouse is created and cursor caps includes at least CURSOR_ONE_BIT_TRANSPARANCY.

Returns:int

the maximum size of a native cursor

getMinCursorSizeback to summary
public static int getMinCursorSize()

Gets the minimum size of a native cursor. Can only be called if The Mouse is created and cursor caps includes at least CURSOR_ONE_BIT_TRANSPARANCY.

Returns:int

the maximum size of a native cursor

hasTimedOutback to summary
protected boolean hasTimedOut()

Determines whether this cursor has timed out

Returns:boolean

true if the this cursor has timed out, false if not

nextCursorback to summary
protected void nextCursor()

Changes to the next cursor

setTimeoutback to summary
protected void setTimeout()

Sets the timout property to the time it should be changed

org.lwjgl.input back to summary

private Class Cursor.CursorElement

extends Object
Class Inheritance

A single cursor element, used when animating

Field Summary

Modifier and TypeField and Description
pack-priv final Object
cursorHandle

Handle to cursor

pack-priv final long
delay

How long a delay this element should have

pack-priv long
timeout

Absolute time this element times out

Constructor Summary

AccessConstructor and Description
pack-priv
CursorElement(Object cursorHandle, long delay, long timeout)

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cursorHandleback to summary
pack-priv final Object cursorHandle

Handle to cursor

delayback to summary
pack-priv final long delay

How long a delay this element should have

timeoutback to summary
pack-priv long timeout

Absolute time this element times out

Constructor Detail

CursorElementback to summary
pack-priv CursorElement(Object cursorHandle, long delay, long timeout)