V-ARTContributions
Classes | Public Types | Public Member Functions | Protected Attributes | List of all members
VART::MouseControl Class Reference

Keeps track of mouse events and state. More...

#include <mousecontrol.h>

Classes

class  ClickHandler
 Click handler. More...
 
class  DragHandler
 
class  MotionHandler
 

Public Types

enum  ButtonID {
  LEFT, MIDDLE, RIGHT, WHEEL_UP,
  WHEEL_DOWN
}
 
enum  ModifierID { SHIFT, CONTROL, ALT }
 
enum  StateID { DOWN, UP }
 

Public Member Functions

 MouseControl ()
 Creates an unitialized mouse controller. More...
 
bool LastClickButtonIs (ButtonID btValue) const
 Checks if last event is relative to given button. More...
 
ButtonID GetLastClickButton () const
 Returns button relative to last event. More...
 
void SetLastClickButton (ButtonID btValue)
 Sets button relative to last event. More...
 
bool ModifierIsActive (ModifierID mdValue) const
 Checks if given modifier was active on last event. More...
 
void SetModifierState (ModifierID mdValue, bool state)
 Sets the modifier state on last event. More...
 
bool LastClickIsDown () const
 Checks whether state is DOWN. More...
 
StateID GetLastClickState () const
 Returns the button state of last click. More...
 
void SetLastClickState (StateID newState)
 Set the button state on last click. More...
 
int GetClickXPosition () const
 Returns the x positon of last click. More...
 
void SetClickXPosition (int newValue)
 Sets the x postion of last click. More...
 
int GetClickYPosition () const
 Returns the y positon of last click. More...
 
void SetClickYPosition (int newValue)
 Sets the y postion of last click. More...
 
void SetClickPosition (int newX, int newY)
 Sets the position of last click. More...
 
int GetCurrentX () const
 Returns the current x postion. More...
 
void SetCurrentX (int newValue)
 Sets the current x position. More...
 
int GetCurrentY () const
 Returns the current y postion. More...
 
void SetCurrentY (int newValue)
 Sets the current y position. More...
 
void SetCurrentPosititon (int newX, int newY)
 Set the current position. More...
 
int GetReleasedXPosition () const
 Returns the x positon of last button release. More...
 
void SetReleasedXPosition (int newValue)
 Sets the x postion of last button release. More...
 
int GetReleasedYPosition () const
 Returns the y positon of last button release. More...
 
void SetReleasedYPosition (int newValue)
 Sets the y postion of last button release. More...
 
void SetReleasedPosition (int newX, int newY)
 Sets the position of last button release. More...
 
void OnClick ()
 Activates click handler, if any. More...
 
void OnDrag ()
 Activates drag (motion with buttons pressed) handler, if any. More...
 
void OnMotion ()
 Activates motion (with no buttons pressed) handler, if any. More...
 
void SetClickHandler (ClickHandler *handlerPtr)
 Sets the click handler. More...
 
void SetDragHandler (DragHandler *handlerPtr)
 Sets the drag handler. More...
 
void SetMotionHandler (MotionHandler *handlerPtr)
 Sets the motion handler. More...
 
void SetOwner (ViewerGlutOGL *ownerPtr)
 Set the owner viewer. More...
 
void NewEvent (ButtonID btn, StateID newState)
 Registers new button event. More...
 
bool AnyButtonIsDown () const
 Checks whether any of LEFT, MIDDLE, RIGHT buttons are down. More...
 
bool ButtonIsDown (ButtonID btn) const
 Returns true if given button is down. More...
 
int GetYDrag () const
 
int GetXDrag () const
 

Protected Attributes

ButtonID button
 which button was last pressed or released More...
 
std::bitset< 3 > modifiers
 state of modifiers upon last button event More...
 
std::bitset< 5 > buttonsState
 state (down if set) of LEFT, MIDDLE, RIGHT, WHEEL_UP and WHEEL_DOWN buttons More...
 
StateID state
 state of button event (DOWN/UP) More...
 
int clickX
 Mouse X position for last button down event. More...
 
int clickY
 Mouse Y position for last button down event. More...
 
int currentX
 Current mouse X position. More...
 
int currentY
 Current mouse Y position. More...
 
int releasedX
 Mouse X position for last button up event. More...
 
int releasedY
 Mouse Y position for last button up event. More...
 
ViewerGlutOGLviewerPtr
 Pointer to the viewer that owns the mouse control. More...
 

Detailed Description

Keeps track of mouse events and state.

The mouse control class provides a common ground for mouse related classes. It provides a few nested classes that are used to handle mouse events.

Definition at line 17 of file mousecontrol.h.

Member Enumeration Documentation

Enumerator
LEFT 
MIDDLE 
RIGHT 
WHEEL_UP 
WHEEL_DOWN 

Definition at line 20 of file mousecontrol.h.

Enumerator
SHIFT 
CONTROL 
ALT 

Definition at line 21 of file mousecontrol.h.

Enumerator
DOWN 
UP 

Definition at line 22 of file mousecontrol.h.

Constructor & Destructor Documentation

VART::MouseControl::MouseControl ( )

Creates an unitialized mouse controller.

Definition at line 10 of file mousecontrol.cpp.

Member Function Documentation

bool VART::MouseControl::AnyButtonIsDown ( ) const
inline

Checks whether any of LEFT, MIDDLE, RIGHT buttons are down.

Definition at line 153 of file mousecontrol.h.

References buttonsState.

bool VART::MouseControl::ButtonIsDown ( ButtonID  btn) const
inline

Returns true if given button is down.

Definition at line 155 of file mousecontrol.h.

References buttonsState.

int VART::MouseControl::GetClickXPosition ( ) const
inline

Returns the x positon of last click.

Definition at line 104 of file mousecontrol.h.

References clickX.

int VART::MouseControl::GetClickYPosition ( ) const
inline

Returns the y positon of last click.

Definition at line 108 of file mousecontrol.h.

References clickY.

int VART::MouseControl::GetCurrentX ( ) const
inline

Returns the current x postion.

Definition at line 115 of file mousecontrol.h.

References currentX.

int VART::MouseControl::GetCurrentY ( ) const
inline

Returns the current y postion.

Definition at line 119 of file mousecontrol.h.

References currentY.

ButtonID VART::MouseControl::GetLastClickButton ( ) const
inline

Returns button relative to last event.

Definition at line 90 of file mousecontrol.h.

References button.

StateID VART::MouseControl::GetLastClickState ( ) const
inline

Returns the button state of last click.

Definition at line 100 of file mousecontrol.h.

References state.

int VART::MouseControl::GetReleasedXPosition ( ) const
inline

Returns the x positon of last button release.

Definition at line 126 of file mousecontrol.h.

References releasedX.

int VART::MouseControl::GetReleasedYPosition ( ) const
inline

Returns the y positon of last button release.

Definition at line 130 of file mousecontrol.h.

References releasedY.

int VART::MouseControl::GetXDrag ( ) const
inline

Returns X drag.

X drag is the current X coordinate minus X coordinate of last button press.

Definition at line 163 of file mousecontrol.h.

References clickX, and currentX.

int VART::MouseControl::GetYDrag ( ) const
inline

Returns Y drag.

Y drag is the current Y coordinate minus Y coordinate of last button press.

Definition at line 159 of file mousecontrol.h.

References clickY, and currentY.

bool VART::MouseControl::LastClickButtonIs ( ButtonID  btValue) const
inline

Checks if last event is relative to given button.

Definition at line 88 of file mousecontrol.h.

References button.

bool VART::MouseControl::LastClickIsDown ( ) const
inline

Checks whether state is DOWN.

Definition at line 98 of file mousecontrol.h.

References DOWN, and state.

bool VART::MouseControl::ModifierIsActive ( ModifierID  mdValue) const
inline

Checks if given modifier was active on last event.

Definition at line 94 of file mousecontrol.h.

References modifiers.

void VART::MouseControl::NewEvent ( ButtonID  btn,
StateID  newState 
)

Registers new button event.

Definition at line 53 of file mousecontrol.cpp.

void VART::MouseControl::OnClick ( )

Activates click handler, if any.

Definition at line 18 of file mousecontrol.cpp.

void VART::MouseControl::OnDrag ( )
inline

Activates drag (motion with buttons pressed) handler, if any.

Definition at line 139 of file mousecontrol.h.

References VART::MouseControl::DragHandler::OnDrag().

void VART::MouseControl::OnMotion ( )
inline

Activates motion (with no buttons pressed) handler, if any.

Definition at line 141 of file mousecontrol.h.

References VART::MouseControl::MotionHandler::OnMotion().

void VART::MouseControl::SetClickHandler ( ClickHandler handlerPtr)

Sets the click handler.

Definition at line 39 of file mousecontrol.cpp.

References VART::MouseControl::ClickHandler::mouseCtrlPtr, and VART::MouseControl::ClickHandler::viewerPtr.

void VART::MouseControl::SetClickPosition ( int  newX,
int  newY 
)
inline

Sets the position of last click.

Definition at line 112 of file mousecontrol.h.

References clickX, and clickY.

void VART::MouseControl::SetClickXPosition ( int  newValue)
inline

Sets the x postion of last click.

Definition at line 106 of file mousecontrol.h.

References clickX.

void VART::MouseControl::SetClickYPosition ( int  newValue)
inline

Sets the y postion of last click.

Definition at line 110 of file mousecontrol.h.

References clickY.

void VART::MouseControl::SetCurrentPosititon ( int  newX,
int  newY 
)
inline

Set the current position.

Definition at line 123 of file mousecontrol.h.

References currentX, and currentY.

void VART::MouseControl::SetCurrentX ( int  newValue)
inline

Sets the current x position.

Definition at line 117 of file mousecontrol.h.

References currentX.

void VART::MouseControl::SetCurrentY ( int  newValue)
inline

Sets the current y position.

Definition at line 121 of file mousecontrol.h.

References currentY.

void VART::MouseControl::SetDragHandler ( DragHandler handlerPtr)

Sets the drag handler.

Definition at line 32 of file mousecontrol.cpp.

References VART::MouseControl::DragHandler::mouseCtrlPtr, and VART::MouseControl::DragHandler::viewerPtr.

void VART::MouseControl::SetLastClickButton ( ButtonID  btValue)
inline

Sets button relative to last event.

Definition at line 92 of file mousecontrol.h.

References button.

void VART::MouseControl::SetLastClickState ( StateID  newState)
inline

Set the button state on last click.

Definition at line 102 of file mousecontrol.h.

References state.

void VART::MouseControl::SetModifierState ( ModifierID  mdValue,
bool  state 
)

Sets the modifier state on last event.

Definition at line 25 of file mousecontrol.cpp.

void VART::MouseControl::SetMotionHandler ( MotionHandler handlerPtr)

Sets the motion handler.

Definition at line 46 of file mousecontrol.cpp.

References VART::MouseControl::MotionHandler::mouseCtrlPtr, and VART::MouseControl::MotionHandler::viewerPtr.

void VART::MouseControl::SetOwner ( ViewerGlutOGL ownerPtr)
inline

Set the owner viewer.

Definition at line 149 of file mousecontrol.h.

References viewerPtr.

void VART::MouseControl::SetReleasedPosition ( int  newX,
int  newY 
)
inline

Sets the position of last button release.

Definition at line 134 of file mousecontrol.h.

References releasedX, and releasedY.

void VART::MouseControl::SetReleasedXPosition ( int  newValue)
inline

Sets the x postion of last button release.

Definition at line 128 of file mousecontrol.h.

References releasedX.

void VART::MouseControl::SetReleasedYPosition ( int  newValue)
inline

Sets the y postion of last button release.

Definition at line 132 of file mousecontrol.h.

References releasedY.

Member Data Documentation

ButtonID VART::MouseControl::button
protected

which button was last pressed or released

Definition at line 166 of file mousecontrol.h.

Referenced by GetLastClickButton(), LastClickButtonIs(), and SetLastClickButton().

std::bitset<5> VART::MouseControl::buttonsState
protected

state (down if set) of LEFT, MIDDLE, RIGHT, WHEEL_UP and WHEEL_DOWN buttons

Definition at line 170 of file mousecontrol.h.

Referenced by AnyButtonIsDown(), and ButtonIsDown().

int VART::MouseControl::clickX
protected

Mouse X position for last button down event.

Definition at line 174 of file mousecontrol.h.

Referenced by GetClickXPosition(), GetXDrag(), SetClickPosition(), and SetClickXPosition().

int VART::MouseControl::clickY
protected

Mouse Y position for last button down event.

Definition at line 176 of file mousecontrol.h.

Referenced by GetClickYPosition(), GetYDrag(), SetClickPosition(), and SetClickYPosition().

int VART::MouseControl::currentX
protected

Current mouse X position.

Definition at line 178 of file mousecontrol.h.

Referenced by GetCurrentX(), GetXDrag(), SetCurrentPosititon(), and SetCurrentX().

int VART::MouseControl::currentY
protected

Current mouse Y position.

Definition at line 180 of file mousecontrol.h.

Referenced by GetCurrentY(), GetYDrag(), SetCurrentPosititon(), and SetCurrentY().

std::bitset<3> VART::MouseControl::modifiers
protected

state of modifiers upon last button event

Definition at line 168 of file mousecontrol.h.

Referenced by ModifierIsActive().

int VART::MouseControl::releasedX
protected

Mouse X position for last button up event.

Definition at line 182 of file mousecontrol.h.

Referenced by GetReleasedXPosition(), SetReleasedPosition(), and SetReleasedXPosition().

int VART::MouseControl::releasedY
protected

Mouse Y position for last button up event.

Definition at line 184 of file mousecontrol.h.

Referenced by GetReleasedYPosition(), SetReleasedPosition(), and SetReleasedYPosition().

StateID VART::MouseControl::state
protected

state of button event (DOWN/UP)

Definition at line 172 of file mousecontrol.h.

Referenced by GetLastClickState(), LastClickIsDown(), and SetLastClickState().

ViewerGlutOGL* VART::MouseControl::viewerPtr
protected

Pointer to the viewer that owns the mouse control.

Definition at line 186 of file mousecontrol.h.

Referenced by SetOwner().


The documentation for this class was generated from the following files: