Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Examples  

gadget::MouseEvent Class Reference

Mouse event class. More...

#include <MouseEvent.h>

Inheritance diagram for gadget::MouseEvent:

Inheritance graph
[legend]
Collaboration diagram for gadget::MouseEvent:

Collaboration graph
[legend]
List of all members.

Public Methods

 MouseEvent (const gadget::EventType type, const gadget::Keys button, int x, int y, int globalX, int globalY, int state, unsigned long time)
 Initializes data members. More...

 MouseEvent ()
 Default constructor needed in order to use the templated EventFactory without modification. More...

const gadget::KeysgetButton () const
 Get the mouse button that was pressed while generating this event. More...

const int & getX () const
 Returns the X corrdinate of the mouse pointer relative to the window. More...

const int & getY () const
 Returns the Y corrdinate of the mouse pointer relative to the window. More...

const int & getGlobalX () const
 Returns the X corrdinate of the mouse pointer relative to the root window (i.e., the desktop). More...

const int & getGlobalY () const
 Returns the Y corrdinate of the mouse pointer relative to the root window (i.e., the desktop). More...

const int & getState () const
 Returns the state of the mouse buttons and keyboard modifier keys (CTRL, ALT, and SHIFT). More...

virtual vpr::ReturnStatus writeObject (vpr::ObjectWriter *writer)
 Serializes this event using the given ObjectWriter. More...

virtual vpr::ReturnStatus readObject (vpr::ObjectReader *reader)
 De-serializes this event using the given ObjectReader. More...


Detailed Description

Mouse event class.

This captures the state of the mouse when any mouse event occurs. This includes button presses, button releases, and mouse motion.

Definition at line 55 of file MouseEvent.h.


Constructor & Destructor Documentation

gadget::MouseEvent::MouseEvent const gadget::EventType    type,
const gadget::Keys    button,
int    x,
int    y,
int    globalX,
int    globalY,
int    state,
unsigned long    time
 

Initializes data members.

Parameters:
button  The button that generated the event.
x  The X coordinate of the mouse within the window.
y  The Y coordinate of the mouse within the window.
globalX  The X coordiante of the mouse relative to the root window (i.e., the desktop).
globalY  The Y coordiante of the mouse relative to the root window (i.e., the desktop).
state  The mask of mouse buttons and any modifiers being pressed. This should be constructed using the bitwise OR of gadget::ModifierMask and gadget::ButtonMask values.
time  The time at which this event occurred. This should be as accurate as possible, preferabbly acquired from the operating system or windowing system event data structure. The time at which the event was processed is not an acceptable value.
See also:
gadget::ModifierMask, gadget::ButtonMask

Definition at line 41 of file MouseEvent.cpp.

00044    : gadget::Event(type, time)
00045    , mButton(button)
00046    , mRelativeX(x)
00047    , mRelativeY(y)
00048    , mGlobalX(globalX)
00049    , mGlobalY(globalY)
00050    , mState(state)
00051 {
00052 }

gadget::MouseEvent::MouseEvent  
 

Default constructor needed in order to use the templated EventFactory without modification.

The EventFactory was needed to allow the correct subtype of Event, MouseEvent in this case, to be created during de-serialization.

Definition at line 54 of file MouseEvent.cpp.

References gadget::NO_MBUTTON, and gadget::NoEvent.

00055    : gadget::Event(NoEvent, 0)
00056    , mButton(gadget::NO_MBUTTON)
00057    , mRelativeX(0)
00058    , mRelativeY(0)
00059    , mGlobalX(0)
00060    , mGlobalY(0)
00061    , mState(0)
00062 {
00063 }


Member Function Documentation

const gadget::Keys& gadget::MouseEvent::getButton   const [inline]
 

Get the mouse button that was pressed while generating this event.

Definition at line 95 of file MouseEvent.h.

00096    {
00097       return mButton;
00098    }

const int& gadget::MouseEvent::getX   const [inline]
 

Returns the X corrdinate of the mouse pointer relative to the window.

Definition at line 103 of file MouseEvent.h.

00104    {
00105       return mRelativeX;
00106    }

const int& gadget::MouseEvent::getY   const [inline]
 

Returns the Y corrdinate of the mouse pointer relative to the window.

Definition at line 111 of file MouseEvent.h.

00112    {
00113       return mRelativeY;
00114    }

const int& gadget::MouseEvent::getGlobalX   const [inline]
 

Returns the X corrdinate of the mouse pointer relative to the root window (i.e., the desktop).

Definition at line 120 of file MouseEvent.h.

00121    {
00122       return mGlobalX;
00123    }

const int& gadget::MouseEvent::getGlobalY   const [inline]
 

Returns the Y corrdinate of the mouse pointer relative to the root window (i.e., the desktop).

Definition at line 129 of file MouseEvent.h.

00130    {
00131       return mGlobalY;
00132    }

const int& gadget::MouseEvent::getState   const [inline]
 

Returns the state of the mouse buttons and keyboard modifier keys (CTRL, ALT, and SHIFT).

See also:
gadget::ModifierMask, gadget::ButtonMask

Definition at line 140 of file MouseEvent.h.

00141    {
00142       return mState;
00143    }

vpr::ReturnStatus gadget::MouseEvent::writeObject vpr::ObjectWriter *    writer [virtual]
 

Serializes this event using the given ObjectWriter.

Reimplemented from gadget::Event.

Definition at line 66 of file MouseEvent.cpp.

References gadget::Event::mType.

00067 {
00068    writer->writeUint16(mType);
00069 
00070    // Serialize all member variables
00071    writer->writeUint32(mButton);
00072    writer->writeUint32(mRelativeX);
00073    writer->writeUint32(mRelativeY);
00074    writer->writeUint32(mGlobalX);
00075    writer->writeUint32(mGlobalY);
00076    writer->writeUint32(mState);
00077    
00078    return vpr::ReturnStatus::Succeed;
00079 }

vpr::ReturnStatus gadget::MouseEvent::readObject vpr::ObjectReader *    reader [virtual]
 

De-serializes this event using the given ObjectReader.

Reimplemented from gadget::Event.

Definition at line 82 of file MouseEvent.cpp.

00083 {
00084    // We have already read the type in EventWindoe to decide
00085    // if we should construct a KeyEvent or a MouseEvent
00086    //mType = reader->readUint16();
00087 
00088    // De-Serialize all member variables
00089    mButton = (gadget::Keys)reader->readUint32();
00090    mRelativeX = reader->readUint32();
00091    mRelativeY = reader->readUint32();
00092    mGlobalX = reader->readUint32();
00093    mGlobalY = reader->readUint32();
00094    mState = reader->readUint32();
00095    return vpr::ReturnStatus::Succeed;
00096 }


The documentation for this class was generated from the following files:
Generated on Sun May 2 14:26:57 2004 for Gadgeteer by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002