Handler for mice connected to the system, if any. More...
#include <OSDLMouseHandler.h>
Public Member Functions | |
MouseHandler (bool useClassicalMice=true) | |
Constructs a new mouse handler. | |
virtual | ~MouseHandler () throw () |
Virtual destructor. | |
bool | hasDefaultMouse () const |
Returns whether a default mouse is available. | |
Mouse & | getDefaultMouse () |
Returns the default mouse, if any. | |
virtual void | linkToController (OSDL::MVC::Controller &controller) |
Links the default mouse to specified controller, so that any further mouse-related event will be sent to this controller. | |
virtual void | linkToController (MouseNumber index, OSDL::MVC::Controller &controller) |
Links the specified mouse to specified controller, so that any further mouse-related event will be sent to this controller. | |
virtual const std::string | toString (Ceylan::VerbosityLevels level=Ceylan::high) const |
Returns an user-friendly description of the state of this object. | |
Static Public Member Functions | |
static MouseNumber | GetAvailableMiceCount () |
Returns the number of available mice, i.e. | |
Protected Member Functions | |
virtual void | focusGained (const FocusEvent &mouseFocusEvent) const |
Called whenever a mouse focus is gained by the application. | |
virtual void | focusLost (const FocusEvent &mouseFocusEvent) const |
Called whenever a mouse focus is lost by the application. | |
virtual void | mouseMoved (const MouseMotionEvent &mouseMovedEvent) const |
Called whenever a mouse is moved, so that its controller, if any, is notified. | |
virtual void | buttonPressed (const MouseButtonEvent &mouseButtonPressedEvent) const |
Called whenever a mouse button was pressed, so that its controller, if any, is notified. | |
virtual void | buttonReleased (const MouseButtonEvent &mouseButtonReleasedEvent) const |
Called whenever a mouse button was released, so that its controller, if any, is notified. | |
virtual void | blank () |
Blanks this mouse handler, i.e. | |
virtual void | checkMouseAt (MouseNumber index) const |
Checks that the mouse at the specified index exists and is opened. | |
Protected Attributes | |
MouseNumber | _miceCount |
Records how many mice are known by this handler. | |
Mouse ** | _mice |
Records all known mice. | |
bool | _useClassicalMice |
Tells whether complex mice (if false) or classical mice (if true) should be created. | |
Private Member Functions | |
MouseHandler (const MouseHandler &source) | |
Copy constructor made private to ensure that it will never be called. | |
MouseHandler & | operator= (const MouseHandler &source) |
Assignment operator made private to ensure that it will never be called. | |
Friends | |
class | OSDL::Events::EventsModule |
Handler for mice connected to the system, if any.
Manages the mouse position, its up to three buttons, and a possible mouse wheel (up/down).
Definition at line 83 of file OSDLMouseHandler.h.
MouseHandler::MouseHandler | ( | bool | useClassicalMice = true |
) | [explicit] |
Constructs a new mouse handler.
useClassicalMice | tells whether detected mice should be managed as complex mice (powerful interface, but it requires the controller to take in charge this complexity) or classical mice (for usual needs, comes with preset behaviours which ease controller work). |
InputDeviceHandlerException | if the initialization of the mouse subsystem failed. |
Definition at line 68 of file OSDLMouseHandler.cc.
References _mice, _miceCount, _useClassicalMice, and GetAvailableMiceCount().
MouseHandler::~MouseHandler | ( | ) | throw () [virtual] |
OSDL::Events::MouseHandler::MouseHandler | ( | const MouseHandler & | source | ) | [explicit, private] |
Copy constructor made private to ensure that it will never be called.
The compiler should complain whenever this undefined constructor is called, implicitly or not.
void MouseHandler::blank | ( | ) | [protected, virtual] |
Blanks this mouse handler, i.e.
makes it forget all previously known mice.
Definition at line 333 of file OSDLMouseHandler.cc.
References _mice, and _miceCount.
Referenced by ~MouseHandler().
void MouseHandler::buttonPressed | ( | const MouseButtonEvent & | mouseButtonPressedEvent | ) | const [protected, virtual] |
Called whenever a mouse button was pressed, so that its controller, if any, is notified.
Definition at line 296 of file OSDLMouseHandler.cc.
References _mice, OSDL::Events::Mouse::buttonPressed(), and checkMouseAt().
Referenced by OSDL::Events::EventsModule::onMouseButtonPressed().
void MouseHandler::buttonReleased | ( | const MouseButtonEvent & | mouseButtonReleasedEvent | ) | const [protected, virtual] |
Called whenever a mouse button was released, so that its controller, if any, is notified.
Definition at line 314 of file OSDLMouseHandler.cc.
References _mice, OSDL::Events::Mouse::buttonReleased(), and checkMouseAt().
Referenced by OSDL::Events::EventsModule::onMouseButtonReleased().
void MouseHandler::checkMouseAt | ( | MouseNumber | index | ) | const [protected, virtual] |
Checks that the mouse at the specified index exists and is opened.
index | the index of the mouse to check. |
Definition at line 354 of file OSDLMouseHandler.cc.
References _mice, and _miceCount.
Referenced by buttonPressed(), buttonReleased(), focusGained(), focusLost(), and mouseMoved().
void MouseHandler::focusGained | ( | const FocusEvent & | mouseFocusEvent | ) | const [protected, virtual] |
Called whenever a mouse focus is gained by the application.
mouseFocusEvent | the mouse event about gained focus. |
Definition at line 245 of file OSDLMouseHandler.cc.
References _mice, checkMouseAt(), OSDL::Events::DefaultMouse, and OSDL::Events::Mouse::focusGained().
Referenced by OSDL::Events::EventsModule::onMouseFocusGained().
void MouseHandler::focusLost | ( | const FocusEvent & | mouseFocusEvent | ) | const [protected, virtual] |
Called whenever a mouse focus is lost by the application.
mouseFocusEvent | the mouse event about lost focus. |
Definition at line 262 of file OSDLMouseHandler.cc.
References _mice, checkMouseAt(), OSDL::Events::DefaultMouse, and OSDL::Events::Mouse::focusLost().
Referenced by OSDL::Events::EventsModule::onMouseFocusLost().
MouseNumber MouseHandler::GetAvailableMiceCount | ( | ) | [static] |
Returns the number of available mice, i.e.
the mice currently attached to the system.
Definition at line 226 of file OSDLMouseHandler.cc.
Referenced by linkToController(), and MouseHandler().
Mouse & MouseHandler::getDefaultMouse | ( | ) |
Returns the default mouse, if any.
MouseException | if no default mouse is available. |
Definition at line 128 of file OSDLMouseHandler.cc.
References _mice, _miceCount, and OSDL::Events::DefaultMouse.
bool MouseHandler::hasDefaultMouse | ( | ) | const |
Returns whether a default mouse is available.
Definition at line 119 of file OSDLMouseHandler.cc.
References _miceCount.
void MouseHandler::linkToController | ( | MouseNumber | index, | |
OSDL::MVC::Controller & | controller | |||
) | [virtual] |
Links the specified mouse to specified controller, so that any further mouse-related event will be sent to this controller.
Removes automatically any link previously defined between the mouse and any other controller.
index | the index of the mouse to link, in case there are other mice than the main default one. | |
controller | the OSDL controller which will be notified of mouse changes. |
MouseException | if the operation failed. |
Definition at line 150 of file OSDLMouseHandler.cc.
References _mice, _miceCount, GetAvailableMiceCount(), and OSDL::Video::Pixels::toString().
void MouseHandler::linkToController | ( | OSDL::MVC::Controller & | controller | ) | [virtual] |
Links the default mouse to specified controller, so that any further mouse-related event will be sent to this controller.
Removes automatically any link previously defined between the mouse and any other controller.
controller | the OSDL controller which will be notified of mouse changes. |
MouseException | if the operation failed. |
Definition at line 141 of file OSDLMouseHandler.cc.
References OSDL::Events::DefaultMouse.
void MouseHandler::mouseMoved | ( | const MouseMotionEvent & | mouseMovedEvent | ) | const [protected, virtual] |
Called whenever a mouse is moved, so that its controller, if any, is notified.
Definition at line 279 of file OSDLMouseHandler.cc.
References _mice, checkMouseAt(), and OSDL::Events::Mouse::mouseMoved().
Referenced by OSDL::Events::EventsModule::onMouseMotion().
MouseHandler& OSDL::Events::MouseHandler::operator= | ( | const MouseHandler & | source | ) | [private] |
Assignment operator made private to ensure that it will never be called.
The compiler should complain whenever this undefined operator is called, implicitly or not.
const string MouseHandler::toString | ( | Ceylan::VerbosityLevels | level = Ceylan::high |
) | const [virtual] |
Returns an user-friendly description of the state of this object.
level | the requested verbosity level. |
Definition at line 184 of file OSDLMouseHandler.cc.
References _mice, _miceCount, and OSDL::Video::Pixels::toString().
Referenced by OSDL::Events::EventsModule::toString().
friend class OSDL::Events::EventsModule [friend] |
Definition at line 92 of file OSDLMouseHandler.h.
Mouse** OSDL::Events::MouseHandler::_mice [protected] |
Records all known mice.
A dynamic array is preferred to a list for performance reasons.
(read it as Mouse * _mice[])
Definition at line 336 of file OSDLMouseHandler.h.
Referenced by blank(), buttonPressed(), buttonReleased(), checkMouseAt(), focusGained(), focusLost(), getDefaultMouse(), linkToController(), MouseHandler(), mouseMoved(), and toString().
MouseNumber OSDL::Events::MouseHandler::_miceCount [protected] |
Records how many mice are known by this handler.
Definition at line 323 of file OSDLMouseHandler.h.
Referenced by blank(), checkMouseAt(), getDefaultMouse(), hasDefaultMouse(), linkToController(), MouseHandler(), and toString().
bool OSDL::Events::MouseHandler::_useClassicalMice [protected] |
Tells whether complex mice (if false) or classical mice (if true) should be created.
Definition at line 345 of file OSDLMouseHandler.h.
Referenced by MouseHandler().