git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63644 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
79 lines
1.9 KiB
C++
79 lines
1.9 KiB
C++
/////////////////////////////////////////////////////////////////////////////
|
|
// Name: src/msw/uiaction.cpp
|
|
// Purpose: wxUIActionSimulator implementation
|
|
// Author: Kevin Ollivier
|
|
// Modified by:
|
|
// Created: 2010-03-06
|
|
// RCS-ID: $Id: menu.cpp 54129 2008-06-11 19:30:52Z SC $
|
|
// Copyright: (c) Kevin Ollivier
|
|
// Licence: wxWindows licence
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
#include "wx/wxprec.h"
|
|
|
|
#ifndef WX_PRECOMP
|
|
#include "wx/defs.h"
|
|
#endif
|
|
|
|
#include "wx/uiaction.h"
|
|
|
|
#include <windows.h>
|
|
|
|
DWORD EventTypeForMouseButton(int button, bool isDown)
|
|
{
|
|
switch (button)
|
|
{
|
|
case wxMOUSE_BTN_LEFT:
|
|
if (isDown)
|
|
return MOUSEEVENTF_LEFTDOWN;
|
|
else
|
|
return MOUSEEVENTF_LEFTUP;
|
|
case wxMOUSE_BTN_RIGHT:
|
|
if (isDown)
|
|
return MOUSEEVENTF_RIGHTDOWN;
|
|
else
|
|
return MOUSEEVENTF_RIGHTUP;
|
|
case wxMOUSE_BTN_MIDDLE:
|
|
if (isDown)
|
|
return MOUSEEVENTF_MIDDLEDOWN;
|
|
else
|
|
return MOUSEEVENTF_MIDDLEUP;
|
|
|
|
default:
|
|
wxFAIL_MSG("Unsupported button passed in.");
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
bool wxUIActionSimulator::MouseDown(int button)
|
|
{
|
|
POINT p;
|
|
GetCursorPos(&p);
|
|
mouse_event(EventTypeForMouseButton(button, true), p.x, p.y, 0, 0);
|
|
return true;
|
|
}
|
|
|
|
bool wxUIActionSimulator::MouseMove(long x, long y)
|
|
{
|
|
mouse_event(MOUSEEVENTF_MOVE, x, y, 0, 0);
|
|
return true;
|
|
}
|
|
|
|
bool wxUIActionSimulator::MouseUp(int button)
|
|
{
|
|
POINT p;
|
|
GetCursorPos(&p);
|
|
mouse_event(EventTypeForMouseButton(button, false), p.x, p.y, 0, 0);
|
|
return true;
|
|
}
|
|
|
|
bool wxUIActionSimulator::Key(int keycode, bool isDown, bool shiftDown, bool cmdDown, bool altDown)
|
|
{
|
|
DWORD flags = 0;
|
|
if (!isDown)
|
|
flags = KEYEVENTF_KEYUP;
|
|
keybd_event(keycode, 0, flags, 0);
|
|
return true;
|
|
}
|
|
|