]>
Commit | Line | Data |
---|---|---|
a02a5cfc KO |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: src/msw/uiaction.cpp | |
3 | // Purpose: wxUIActionSimulator implementation | |
4 | // Author: Kevin Ollivier | |
5 | // Modified by: | |
6 | // Created: 2010-03-06 | |
7 | // RCS-ID: $Id: menu.cpp 54129 2008-06-11 19:30:52Z SC $ | |
8 | // Copyright: (c) Kevin Ollivier | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #include "wx/wxprec.h" | |
13 | ||
9b7e0226 | 14 | #if wxUSE_UIACTIONSIMULATOR |
a02a5cfc KO |
15 | |
16 | #include "wx/uiaction.h" | |
17 | ||
9b7e0226 | 18 | #include "wx/msw/wrapwin.h" |
a02a5cfc KO |
19 | |
20 | DWORD EventTypeForMouseButton(int button, bool isDown) | |
21 | { | |
22 | switch (button) | |
23 | { | |
24 | case wxMOUSE_BTN_LEFT: | |
25 | if (isDown) | |
26 | return MOUSEEVENTF_LEFTDOWN; | |
27 | else | |
28 | return MOUSEEVENTF_LEFTUP; | |
29 | case wxMOUSE_BTN_RIGHT: | |
30 | if (isDown) | |
31 | return MOUSEEVENTF_RIGHTDOWN; | |
32 | else | |
33 | return MOUSEEVENTF_RIGHTUP; | |
34 | case wxMOUSE_BTN_MIDDLE: | |
35 | if (isDown) | |
36 | return MOUSEEVENTF_MIDDLEDOWN; | |
37 | else | |
38 | return MOUSEEVENTF_MIDDLEUP; | |
9b7e0226 | 39 | |
a02a5cfc KO |
40 | default: |
41 | wxFAIL_MSG("Unsupported button passed in."); | |
42 | return -1; | |
43 | } | |
44 | } | |
45 | ||
46 | bool wxUIActionSimulator::MouseDown(int button) | |
47 | { | |
48 | POINT p; | |
49 | GetCursorPos(&p); | |
50 | mouse_event(EventTypeForMouseButton(button, true), p.x, p.y, 0, 0); | |
51 | return true; | |
52 | } | |
53 | ||
54 | bool wxUIActionSimulator::MouseMove(long x, long y) | |
9b7e0226 | 55 | { |
a02a5cfc KO |
56 | mouse_event(MOUSEEVENTF_MOVE, x, y, 0, 0); |
57 | return true; | |
58 | } | |
59 | ||
60 | bool wxUIActionSimulator::MouseUp(int button) | |
61 | { | |
62 | POINT p; | |
63 | GetCursorPos(&p); | |
64 | mouse_event(EventTypeForMouseButton(button, false), p.x, p.y, 0, 0); | |
65 | return true; | |
66 | } | |
67 | ||
68 | bool wxUIActionSimulator::Key(int keycode, bool isDown, bool shiftDown, bool cmdDown, bool altDown) | |
69 | { | |
70 | DWORD flags = 0; | |
71 | if (!isDown) | |
72 | flags = KEYEVENTF_KEYUP; | |
73 | keybd_event(keycode, 0, flags, 0); | |
74 | return true; | |
75 | } | |
76 | ||
9b7e0226 | 77 | #endif // wxUSE_UIACTIONSIMULATOR |