Detailed Description
The QWSMouseHandler class implements a mouse driver in Qtopia Core.
A mouse driver handles events from system devices and generates mouse events. Custom mouse drivers can be added by subclassing the QMouseDriverPlugin class, using the QMouseDriverFactory class to dynamically load the driver into the application.
A QWSMouseHandler object will usually open some system device, and create a QSocketNotifier object for that device. The QSocketNotifier class provides support for monitoring activity on a file descriptor. When the socket notifier receives data, it will call the mouse handler's mouseChanged() function to send the event to the Qtopia Core server application for relaying to clients.
If you are creating a handler for a device that needs calibration or noise reduction, such as a touchscreen, use the QWSCalibratedMouseHandler subclass instead to take advantage of the calibrate() and clearCalibration() functions.
Note that when deriving from the QWSMouseHandler class, the resume() and suspend() functions must be reimplemented to control the flow of mouse input. The default implementation does nothing; reimplementations of these functions typically call the QSocketNotifier::setEnabled() function to enable or disable the socket notifier, respectively.
In addition, QWSMouseHandler provides the limitToScreen() function ensuring that the given position is within the screen's boundaries (changing the position if necessary), and the pos() function returning the current mouse position.
See also Pointer Handling, Mouse Calibration Example, and Qtopia Core.
Member Function Documentation
QWSMouseHandler::QWSMouseHandler ( const QString & driver = QString(), const QString & device = QString() )
Constructs a mouse handler which becomes the primary mouse handler.
Note that once created, mouse handlers are controlled by the system and should not be deleted. The driver and device arguments are passed by the QWS_MOUSE_PROTO environment variable.
QWSMouseHandler::~QWSMouseHandler () [virtual]
Destroys this mouse handler.
Do not call this function directly; it should only be called when the application terminates and from within Qtopia Core.
void QWSMouseHandler::calibrate ( const QWSPointerCalibrationData * data ) [virtual]
This virtual function allows subclasses of QWSMouseHandler to set the calibration information passed in the given data. The default implementation does nothing.
See also QWSCalibratedMouseHandler::calibrate() and clearCalibration().
void QWSMouseHandler::clearCalibration () [virtual]
This virtual function allows subclasses of QWSMouseHandler to clear the calibration information. The default implementation does nothing.
See also QWSCalibratedMouseHandler::clearCalibration() and calibrate().
void QWSMouseHandler::limitToScreen ( QPoint & position )
Ensures that the given position is within the screen's boundaries, changing the position if necessary.
See also pos().
void QWSMouseHandler::mouseChanged ( const QPoint & position, int state, int wheel = 0 )
Notifies the system of a new mouse event.
This function updates the current mouse position and sends the event to the Qtopia Core server application for delivery to the correct widget.
The given position is the global position of the mouse cursor. The state parameter is a bitmask of the Qt::MouseButton enum's values, indicating which mouse buttons are pressed. The wheel parameter is the delta value of the mouse wheel as returned by QWheelEvent::delta().
A subclass must call this function whenever it wants to deliver a new mouse event.
See also pos().
const QPoint & QWSMouseHandler::pos () const
Returns the current mouse position.
See also mouseChanged() and limitToScreen().
void QWSMouseHandler::resume () [pure virtual]
Resumes reading and handling mouse events.
Note that this function must be reimplemented in subclasses to control the flow of mouse input. The default implementation does nothing; reimplementations typically call the QSocketNotifier::setEnabled() function to enable the socket notifier.
See also suspend().
void QWSMouseHandler::suspend () [pure virtual]
Suspends reading and handling of mouse events.
Note that this function must be reimplemented in subclasses to control the flow of mouse input. The default implementation does nothing; reimplementations typically call the QSocketNotifier::setEnabled() function to disable the socket notifier.
See also resume().