Style fixes in the MSW gestures code
No real changes, just reformat code and comments to fit in 80 column lines.
This commit is contained in:
@@ -3227,51 +3227,42 @@ wxWindowMSW::MSWHandleMessage(WXLRESULT *result,
|
|||||||
// dwID field is used to determine the type of gesture
|
// dwID field is used to determine the type of gesture
|
||||||
switch ( gestureInfo.dwID )
|
switch ( gestureInfo.dwID )
|
||||||
{
|
{
|
||||||
// Pan gesture
|
|
||||||
case GID_PAN:
|
case GID_PAN:
|
||||||
{
|
|
||||||
// (x,y) is the current position of the pan
|
// (x,y) is the current position of the pan
|
||||||
processed = HandlePanGesture(x, y, gestureInfo.dwFlags);
|
processed = HandlePanGesture(x, y, gestureInfo.dwFlags);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
// Zoom gesture
|
|
||||||
case GID_ZOOM:
|
case GID_ZOOM:
|
||||||
{
|
// (x,y) is the mid-point of 2 fingers and ullArgument
|
||||||
// (x,y) is the mid-point of 2 fingers
|
// contains the distance between the fingers in its lower
|
||||||
// ullArgument field is a 64-bit unsigned integer, but the relevant information
|
// half
|
||||||
// is in it's lower 4 bytes and represents distance between the fingers
|
processed = HandleZoomGesture
|
||||||
// this is used to extract those lower 4 bytes
|
(
|
||||||
DWORD fingerDistance = (DWORD)((gestureInfo.ullArguments) & 0x00000000ffffffff);
|
x, y,
|
||||||
processed = HandleZoomGesture(x, y, fingerDistance, gestureInfo.dwFlags);
|
static_cast<DWORD>(gestureInfo.ullArguments),
|
||||||
|
gestureInfo.dwFlags
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
// Rotate gesture
|
|
||||||
case GID_ROTATE:
|
case GID_ROTATE:
|
||||||
{
|
// (x,y) is the center point of rotation and ullArguments
|
||||||
// (x,y) is the center point of rotation
|
// contains the angle of rotation
|
||||||
// Again, we need the lower 4 bytes and this will used as an argument
|
processed = HandleRotateGesture
|
||||||
// to obtain the angle to rotate
|
(
|
||||||
DWORD angleArgument = (DWORD)((gestureInfo.ullArguments) & 0x00000000ffffffff);
|
x, y,
|
||||||
processed = HandleRotateGesture(x, y, angleArgument, gestureInfo.dwFlags);
|
static_cast<DWORD>(gestureInfo.ullArguments),
|
||||||
|
gestureInfo.dwFlags
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
// Two Finger tap gesture
|
|
||||||
case GID_TWOFINGERTAP:
|
case GID_TWOFINGERTAP:
|
||||||
{
|
|
||||||
processed = HandleTwoFingerTap(x, y, gestureInfo.dwFlags);
|
processed = HandleTwoFingerTap(x, y, gestureInfo.dwFlags);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
// Press and Tap gesture
|
|
||||||
case GID_PRESSANDTAP:
|
case GID_PRESSANDTAP:
|
||||||
{
|
|
||||||
processed = HandlePressAndTap(x, y, gestureInfo.dwFlags);
|
processed = HandlePressAndTap(x, y, gestureInfo.dwFlags);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ( processed )
|
if ( processed )
|
||||||
{
|
{
|
||||||
@@ -3827,9 +3818,15 @@ bool wxWindowMSW::MSWCreate(const wxChar *wclass,
|
|||||||
// Configure to receive all gestures
|
// Configure to receive all gestures
|
||||||
GESTURECONFIG gestureConfig = {0, GC_ALLGESTURES, 0};
|
GESTURECONFIG gestureConfig = {0, GC_ALLGESTURES, 0};
|
||||||
|
|
||||||
// This functions sets the configuration to the window. Second argument is reserved to be 0.
|
if ( !GestureFuncs::SetGestureConfig()
|
||||||
// Third argument is the number of elements in gestureConfig array, currently equal to 1
|
(
|
||||||
if ( !GestureFuncs::SetGestureConfig()(m_hWnd, 0, 1, &gestureConfig, sizeof(GESTURECONFIG)) )
|
m_hWnd,
|
||||||
|
0, // Reserved, must be always 0.
|
||||||
|
1, // Number of gesture configurations.
|
||||||
|
&gestureConfig, // Pointer to the first one.
|
||||||
|
sizeof(GESTURECONFIG) // Size of each configuration.
|
||||||
|
)
|
||||||
|
)
|
||||||
{
|
{
|
||||||
wxLogLastError("SetGestureConfig");
|
wxLogLastError("SetGestureConfig");
|
||||||
}
|
}
|
||||||
@@ -5688,7 +5685,9 @@ bool wxWindowMSW::HandlePanGesture(int x, int y, WXDWORD flags)
|
|||||||
return HandleWindowEvent(event);
|
return HandleWindowEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxWindowMSW::HandleZoomGesture(int x, int y, WXDWORD fingerDistance, WXDWORD flags)
|
bool wxWindowMSW::HandleZoomGesture(int x, int y,
|
||||||
|
WXDWORD fingerDistance,
|
||||||
|
WXDWORD flags)
|
||||||
{
|
{
|
||||||
// wxEVT_GESTURE_ZOOM
|
// wxEVT_GESTURE_ZOOM
|
||||||
wxZoomGestureEvent event(GetId());
|
wxZoomGestureEvent event(GetId());
|
||||||
@@ -5696,8 +5695,8 @@ bool wxWindowMSW::HandleZoomGesture(int x, int y, WXDWORD fingerDistance, WXDWOR
|
|||||||
// These are used to calculate the center of the zoom and zoom factor
|
// These are used to calculate the center of the zoom and zoom factor
|
||||||
static int s_previousLocationX, s_previousLocationY, s_intialFingerDistance;
|
static int s_previousLocationX, s_previousLocationY, s_intialFingerDistance;
|
||||||
|
|
||||||
// This flag indicates that the gesture has just started
|
// This flag indicates that the gesture has just started, store the current
|
||||||
// Store the current point and distance between the fingers for future calculations
|
// point and distance between the fingers for future calculations.
|
||||||
if ( flags & GF_BEGIN )
|
if ( flags & GF_BEGIN )
|
||||||
{
|
{
|
||||||
s_previousLocationX = x;
|
s_previousLocationX = x;
|
||||||
@@ -5711,15 +5710,16 @@ bool wxWindowMSW::HandleZoomGesture(int x, int y, WXDWORD fingerDistance, WXDWOR
|
|||||||
event.SetGestureEnd();
|
event.SetGestureEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate center point of the zoom
|
// Calculate center point of the zoom. Human beings are not very good at
|
||||||
// Human beings are not very good at moving two fingers at exactly the same rate outwards/inwards
|
// moving two fingers at exactly the same rate outwards/inwards and there
|
||||||
// There is usually some error, which can cause the center to shift slightly
|
// is usually some error, which can cause the center to shift slightly. So,
|
||||||
// So, it is recommended to take the average of center of fingers in the current and last positions
|
// it is recommended to take the average of center of fingers in the
|
||||||
|
// current and last positions.
|
||||||
wxPoint pt;
|
wxPoint pt;
|
||||||
pt.x = (s_previousLocationX + x) / 2;
|
pt.x = (s_previousLocationX + x) / 2;
|
||||||
pt.y = (s_previousLocationY + y) / 2;
|
pt.y = (s_previousLocationY + y) / 2;
|
||||||
|
|
||||||
double zoomFactor = (double) fingerDistance / (double) s_intialFingerDistance;
|
const double zoomFactor = (double) fingerDistance / s_intialFingerDistance;
|
||||||
|
|
||||||
event.SetZoomFactor(zoomFactor);
|
event.SetZoomFactor(zoomFactor);
|
||||||
event.SetEventObject(this);
|
event.SetEventObject(this);
|
||||||
@@ -5735,7 +5735,9 @@ bool wxWindowMSW::HandleZoomGesture(int x, int y, WXDWORD fingerDistance, WXDWOR
|
|||||||
return HandleWindowEvent(event);
|
return HandleWindowEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxWindowMSW::HandleRotateGesture(int x, int y, WXDWORD angleArgument, WXDWORD flags)
|
bool wxWindowMSW::HandleRotateGesture(int x, int y,
|
||||||
|
WXDWORD angleArgument,
|
||||||
|
WXDWORD flags)
|
||||||
{
|
{
|
||||||
// wxEVT_GESTURE_ROTATE
|
// wxEVT_GESTURE_ROTATE
|
||||||
wxRotateGestureEvent event(GetId());
|
wxRotateGestureEvent event(GetId());
|
||||||
@@ -5748,13 +5750,15 @@ bool wxWindowMSW::HandleRotateGesture(int x, int y, WXDWORD angleArgument, WXDWO
|
|||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Use angleArgument to obtain the cumulative angle since the gesture was first
|
// Use angleArgument to obtain the cumulative angle since the gesture
|
||||||
// started. This angle is in radians
|
// was first started. This angle is in radians and MSW returns negative
|
||||||
// MSW returns negative angle for clockwise rotation and positive otherwise
|
// angle for clockwise rotation and positive otherwise, so, multiply
|
||||||
// So, multiply angle by -1 for positive angle for clockwise and negative in case of counterclockwise
|
// angle by -1 for positive angle for clockwise and negative in case of
|
||||||
|
// counterclockwise.
|
||||||
double angle = -GID_ROTATE_ANGLE_FROM_ARGUMENT(angleArgument);
|
double angle = -GID_ROTATE_ANGLE_FROM_ARGUMENT(angleArgument);
|
||||||
|
|
||||||
// If the rotation is anti-clockwise convert the angle to its corresponding positive value in a clockwise sense.
|
// If the rotation is anti-clockwise convert the angle to its
|
||||||
|
// corresponding positive value in a clockwise sense.
|
||||||
if ( angle < 0 )
|
if ( angle < 0 )
|
||||||
{
|
{
|
||||||
angle += 2 * M_PI;
|
angle += 2 * M_PI;
|
||||||
|
Reference in New Issue
Block a user