Itseez/opencv — pull request #2122 by adishavit (2014-01-07 19:40:19+00:00)
Title: [HighGUI] Add Mouse Wheel Events on Windows

This feature adds support for handling mouse-wheel events on Windows.

It adds 2 new events:

1. `CV_EVENT_MOUSEWHEEL` : forward/backward scroll
2. `CV_EVENT_MOUSEHWHEEL`: Horizontal left/right scroll - available only on some mice.

A few things to note:
- Scrolling requires passing an extra parameter, `delta`, to the event handler. To preserve the existing `setMouseCallback()` API, I stuffed `delta` in the the hi-word of the `event` argument as a (signed) `short` (as it is done on Windows).
- Checking the mouse-wheel event can be done with the helpful macro `CV_GET_MOUSEWHEEL_EVENT(event)`
- Getting the wheel `delta` can be done with the helpful macro `CV_GET_WHEEL_DELTA(event)`.

Here's some test code that can be inserted into an `mouseCallback` function:
```cpp
if (CV_EVENT_MOUSEWHEEL == CV_GET_MOUSEWHEEL_EVENT(event) ||
CV_EVENT_MOUSEHWHEEL == CV_GET_MOUSEWHEEL_EVENT(event))
{
cout << Point(x,y) << " -> ";
int delta= CV_GET_WHEEL_DELTA(event);
cout << "delta= " << delta;
if (flags & CV_EVENT_FLAG_CTRLKEY)
cout << " + Ctrl";
if (flags & CV_EVENT_FLAG_SHIFTKEY)
cout << " + Shift";
if (flags & CV_EVENT_FLAG_ALTKEY)
cout << " + Alt";
if (flags & CV_EVENT_FLAG_LBUTTON)
cout << " + Left";
if (flags & CV_EVENT_FLAG_MBUTTON)
cout << " + Mid";
if (flags & CV_EVENT_FLAG_RBUTTON)
cout << " + Right";
cout << endl;
}
```
On Windows `delta` is usually incremented in (positive/negative) multiples of 120. This may be different with some higher resolution mice, and/or other OSs/platforms. At the moment there is no OpenCV const that specifies this unit.