Main Page | Class List | File List | Class Members

CMouseSimple Class Reference

Very simple mouse class. More...

#include <CMouseSimple.h>

List of all members.

Public Types

enum  

Public Member Functions

 CMouseSimple ()
 ~CMouseSimple ()
int GetNumButtons (void) const
 Get the number of buttons on the mouse.
bool GetButton (int button)
 Get the state of a button.
bool SetButton (int button, bool state)
 Set the statet of a button.
int GetMouseXi (void) const
 Get mouse X coord as an int in screen space.
int GetMouseYi (void) const
 Get mouse Y coord as an int in screen space.
float GetMouseXf (void) const
 Get mouse X coord as a float in screen space.
float GetMouseYf (void) const
 Get mouse Y coord as a float in screen space.
void SetMouseXY (int x, int y)
 Set mouse screen coordinate (from GLUT function).
int GetDragTime (int button)
 Get the length of time a mouse button has been down.
bool ButtonClick (int button)
 Check if a button has just been clicked.
void UnClickButton (int button)
 Reset a clicked button.
void SetLimitRegion (int x1, int y1, int x2, int y2)
 Set a region to limit the mouse into.
bool LimitMouseToRegion (void)
 Limit the mouse to a previously set limit region.
void SetScreenSize (int w, int h)
 Set the screen size, required for float value calculations.


Detailed Description

Very simple mouse class.

This mouse class is really only used as a data collection point for GLUT functions. Only mouse position and button states are stored here, along with some timing for drags and such... Created from InitGL() and written to by the glutMotion...() functions, read by any class or object that needs to.

Definition at line 58 of file CMouseSimple.h.


Member Enumeration Documentation

anonymous enum
 

Enumeration for some default mouse buttons. Values are assumed to be correct.

Definition at line 65 of file CMouseSimple.h.


Constructor & Destructor Documentation

CMouseSimple::CMouseSimple  ) 
 

Create a simple mouse object. Query GLUT for the number of buttons on the mouse and allocate button states.

Determine number of buttons, and allocate bool flags for these.

Fix for Mac single button: Add 1 to the reported number of mouse buttons so that the CTRL key correctly gives a mouse button 2.

Set Default screen or window size.

Set all buttons to off now.

Definition at line 104 of file CMouseSimple.cpp.

References SetLimitRegion(), SetMouseXY(), and SetScreenSize().

Here is the call graph for this function:

CMouseSimple::~CMouseSimple  ) 
 

Destructor.

Definition at line 135 of file CMouseSimple.cpp.


Member Function Documentation

bool CMouseSimple::ButtonClick int  button  ) 
 

Check if a button has just been clicked.

Check if a button has been clicked.

Parameters:
button Number of the button to check.
Returns:
Boolean The clicked state of the ckecked button. If button is wrong false is returned.

Definition at line 254 of file CMouseSimple.cpp.

bool CMouseSimple::GetButton int  button  ) 
 

Get the state of a button.

Get a button's state.

Parameters:
button Number of the button to get.
Returns:
Boolean state of the button.

Definition at line 151 of file CMouseSimple.cpp.

int CMouseSimple::GetDragTime int  button  ) 
 

Get the length of time a mouse button has been down.

Check if drag has occured.

Parameters:
button Number of the button to check.
Returns:
Integer The time the button has been down.

Definition at line 232 of file CMouseSimple.cpp.

bool CMouseSimple::LimitMouseToRegion void   ) 
 

Limit the mouse to a previously set limit region.

"Clip" the mouse to inside the limit region.

Returns:
Boolean true is limited not limited is false.

Definition at line 309 of file CMouseSimple.cpp.

References SetMouseXY().

Here is the call graph for this function:

bool CMouseSimple::SetButton int  button,
bool  state
 

Set the statet of a button.

Set a button's state.

Parameters:
button Number of the button to set.
state State to set the button to.
Returns:
Boolean old state of the button.

Definition at line 169 of file CMouseSimple.cpp.

void CMouseSimple::SetLimitRegion int  x1,
int  y1,
int  x2,
int  y2
 

Set a region to limit the mouse into.

Set the limited region directly, using ints.

Parameters:
x1 Left edge
y1 Top edge.
x2 Right edge.
y2 Bottom edge.

Definition at line 292 of file CMouseSimple.cpp.

Referenced by CMouseSimple().

void CMouseSimple::SetMouseXY int  x,
int  y
 

Set mouse screen coordinate (from GLUT function).

Set the mouse position (data only).

Parameters:
x X coordinate of the mouse.
y Y coordinate of the mouse.

Definition at line 197 of file CMouseSimple.cpp.

Referenced by CMouseSimple(), and LimitMouseToRegion().

void CMouseSimple::SetScreenSize int  w,
int  h
 

Set the screen size, required for float value calculations.

Set the screen size, this MUST ABSOLUTELY BE DONE BEFORE THE MOUSE OBJECT IS USED!.

Parameters:
w Width of the display.
h Height of the display.

Definition at line 214 of file CMouseSimple.cpp.

Referenced by CMouseSimple().

void CMouseSimple::UnClickButton int  button  ) 
 

Reset a clicked button.

Reset a button's drag timer.

Parameters:
button Number of the button to reset.

Definition at line 275 of file CMouseSimple.cpp.


The documentation for this class was generated from the following files:
Generated on Tue Dec 14 23:44:39 2004 for CMouseSimple by  doxygen 1.3.9.1