class MASKING_DLL_DECLSPEC Mouse

The mouse input handling class.

Public Fields

[more]Point pos
The current position of the mouse cursor on the screen.
[more]int flags
The state of the mouse buttons.
[more]int z
The current position of the mouse wheel.

Public Methods

[more]void SetParent(ScreenUpdate* p)
Sets the mouse's parent screen zpdate driver.
[more]virtual void SetCursor(Cursor &cur)
Changes the current mouse cursor.
[more]virtual Cursor* GetCursor()
Returns a pointer to the currently active cursor
[more]virtual void Show()
Draws the cursor to the canvas.
[more]virtual void Hide()
Hides the mouse cursor.
[more]virtual void Update()
Updates the cursor (which can be animated) and the mouse position

Protected Fields

[more]Cursor* cur
A pointer to the currently selected cursor
[more]Bitmap back
The stored background of the cursor
[more]Point spritePos
Position of the main cursor sprite
[more]Point shadowPos
Position of the cursor shadow
[more]Point backPos
Position of the stored background
[more]ScreenUpdate* parent
A pointer to the screen update driver (canvas)
[more]bool hidden
True when the mouse cursor is hidden, false otherwise

Protected Methods

[more]virtual void Destroy()
Cleans up when the mouse functionality is no longer needed (ie.
[more]virtual void UpdateState()
Updates the state of the mouse system.
[more]virtual void CalculateGeometry()
Calculates the relative positions of the main cursor sprite, its shadow and the background


Documentation

The mouse input handling class. The mouse system is quite simple in MASkinG and there's lots of room for optimization. The mouse class hold variables for the current mouse position, cursor and the background of the cursor. The user is required to hide the mouse before every drawing operation and then show it again when they're finished. Actually the dialog manager does this already so you don't really need to worry about it. In fact you don't need to know this class even exists as the dialog manager either does all work for you or provides its own interface for doing things like changing the mouse cursor and so on.
oCursor* cur
A pointer to the currently selected cursor

oBitmap back
The stored background of the cursor

oPoint spritePos
Position of the main cursor sprite

oPoint shadowPos
Position of the cursor shadow

oPoint backPos
Position of the stored background

oScreenUpdate* parent
A pointer to the screen update driver (canvas)

obool hidden
True when the mouse cursor is hidden, false otherwise

ovirtual void Destroy()
Cleans up when the mouse functionality is no longer needed (ie. at the end of the program).

ovirtual void UpdateState()
Updates the state of the mouse system. This includes the position, button states and wheel position. The default driver simply mirrors the global Allegro mouse variables (mouse_x, mouse_y, mouse_b and mouse_z). If you want to modify the bahaviour of your mouse you should derive a new class from Mouse and overload this function so that it does whatever you want. For example you might want to invert the left and right buttons.

ovirtual void CalculateGeometry()
Calculates the relative positions of the main cursor sprite, its shadow and the background

ovoid SetParent(ScreenUpdate* p)
Sets the mouse's parent screen zpdate driver. This lets the mouse know who to ask to get the canvas bitmap where it can draw itself.

ovirtual void SetCursor(Cursor &cur)
Changes the current mouse cursor. First it hides the cursor, then makes the switch and the shows the new one.

ovirtual Cursor* GetCursor()
Returns a pointer to the currently active cursor

ovirtual void Show()
Draws the cursor to the canvas. Prior to that it makes a backup of what is behind the cursor so it is vital that the mouse has been hidden before calling this function.

ovirtual void Hide()
Hides the mouse cursor. It does so by restoring the previously saved backup of the cursor background in place of the cursor.

ovirtual void Update()
Updates the cursor (which can be animated) and the mouse position

oPoint pos
The current position of the mouse cursor on the screen. You should always read this value instead of relying directly on mouse_x and mouse_y. You should not change this value.

oint flags
The state of the mouse buttons. This variable mirrors the Allegro mouse_b variable but you should always read this value instead of using mouse_b directly.

oint z
The current position of the mouse wheel. Always use this value instead of using mouse_z directly.


This class has no child classes.

Alphabetic index Hierarchy of classes


Back to front page   |   page generated with DOC++