e2d::core::Mouse Class Reference

List of all members.


Detailed Description

To either recognize which mouse button is being pressed, or know the exact position of the mouse pointer in the game window, you can use this class.

Note:
The mouse wheel is treated like a button, and it triggers both the Implementation::OnMouseButtonUp and Implementation::OnMouseButtonDown events at the sime time when activated.

Public Member Functions

bool CheckButtonState (int button)
 Checks button state.
RectGetPosition ()
 Returns the mouse position in the game window.
RectGetRelativePosition ()
 Returns the mouse relative position in the game window.
void SetButtonState (bool pressed, int button)
 Sets button state.
void SetPosition (int x, int y)
 Sets the mouse position.
void SetRelativePosition (int x, int y)
 Sets the mouse relative position.
void ShowCursor (bool show)
 Toggle whether or not the cursor is shown on the screen.

Static Public Member Functions

static MouseGetInstance (void)
 Gets an object for this class.

Static Public Attributes

static const int LEFT_BUTTON = 1
 Left mouse button.
static const int MIDDLE_BUTTON = 2
 Middle mouse button.
static const int RIGHT_BUTTON = 3
 Right mouse button.
static const int WHEEL_FARTHER = 4
 Mouse wheel pushed forward.
static const int WHEEL_CLOSER = 5
 Mouse wheel pulled backward.

Member Function Documentation

Mouse * e2d::core::Mouse::GetInstance ( void   )  [static]

This class is a Singleton. If you want an instance of this class to work with, get it via this method.

bool e2d::core::Mouse::CheckButtonState ( int  button  ) 

With this method you are able to verify if a button is being or not pressed on the mouse.

Parameters:
button The button you want to check the state of.
Returns:
true if the button is being pressed; false otherwise.

Rect & e2d::core::Mouse::GetPosition (  ) 

Returns:
Mouse position in the game window

Rect & e2d::core::Mouse::GetRelativePosition (  ) 

Relative position means the difference between the current position and and the position just before the last mouse movement. This method returns this delta.

Returns:
Relative mouse position

void e2d::core::Mouse::SetButtonState ( bool  pressed,
int  button 
)

With this method you can set a button state yourself. Note that if a button is not pressed and you set its state to pressed, it will remain in a state of pressed even if the button is not really being pressed on the mouse. But, if the real button is pressed and then released, then it will switch to the state of unpressed.

Parameters:
pressed Set it to true if you want the button to be seen as pressed, and set it to false otherwise.
button The button you want to change the state.

void e2d::core::Mouse::SetPosition ( int  x,
int  y 
)

This method is called by EventHandler to set the current mouse position. It won't move the mouse through the screen.

Parameters:
x New mouse position in the X axis.
y New mouse position in the Y axis.

void e2d::core::Mouse::SetRelativePosition ( int  x,
int  y 
)

This method is called by EventHandler to set the current mouse position. It won't move the mouse through the screen.

Parameters:
x New mouse relative position in the X axis.
y New mouse relative position in the Y axis.

void e2d::core::Mouse::ShowCursor ( bool  show  ) 

Toggle whether or not the cursor is shown on the screen.

Parameters:
show true shows the mouse cursor, false hides it.


Generated on Tue Dec 8 10:32:44 2009 for Easy2D by  doxygen 1.5.6