forked from rainmeter/rainmeter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMouse.h
171 lines (145 loc) · 5.38 KB
/
Mouse.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
/* Copyright (C) 2012 Rainmeter Project Developers
*
* This Source Code Form is subject to the terms of the GNU General Public
* License; either version 2 of the License, or (at your option) any later
* version. If a copy of the GPL was not distributed with this file, You can
* obtain one at <https://www.gnu.org/licenses/gpl-2.0.html>. */
#ifndef __MOUSE_H__
#define __MOUSE_H__
enum MOUSEACTION
{
MOUSE_LMB_UP = 0,
MOUSE_LMB_DOWN,
MOUSE_LMB_DBLCLK,
MOUSE_MMB_UP,
MOUSE_MMB_DOWN,
MOUSE_MMB_DBLCLK,
MOUSE_RMB_UP,
MOUSE_RMB_DOWN,
MOUSE_RMB_DBLCLK,
MOUSE_X1MB_UP,
MOUSE_X1MB_DOWN,
MOUSE_X1MB_DBLCLK,
MOUSE_X2MB_UP,
MOUSE_X2MB_DOWN,
MOUSE_X2MB_DBLCLK,
MOUSE_MW_UP,
MOUSE_MW_DOWN,
MOUSE_MW_LEFT,
MOUSE_MW_RIGHT,
MOUSE_OVER,
MOUSE_LEAVE,
MOUSEACTION_COUNT
};
enum MOUSEACTIONSTATE
{
MOUSEACTION_ENABLED,
MOUSEACTION_DISABLED,
MOUSEACTION_CLEARED
};
enum MOUSECURSOR
{
MOUSECURSOR_ARROW,
MOUSECURSOR_HAND,
MOUSECURSOR_TEXT,
MOUSECURSOR_HELP,
MOUSECURSOR_BUSY,
MOUSECURSOR_CROSS,
MOUSECURSOR_PEN,
MOUSECURSOR_NO,
MOUSECURSOR_SIZE_ALL,
MOUSECURSOR_SIZE_NESW,
MOUSECURSOR_SIZE_NS,
MOUSECURSOR_SIZE_NWSE,
MOUSECURSOR_SIZE_WE,
MOUSECURSOR_UPARROW,
MOUSECURSOR_WAIT,
MOUSECURSOR_CUSTOM
};
struct MouseAction
{
std::wstring action;
MOUSEACTIONSTATE state;
MOUSEACTIONSTATE previousState;
MouseAction() : state(MOUSEACTION_ENABLED), previousState(MOUSEACTION_DISABLED) { }
};
class Mouse
{
public:
Mouse(Skin* skin, Meter* meter = nullptr);
~Mouse();
Mouse(const Mouse& other) = delete;
Mouse& operator=(Mouse other) = delete;
void ReadOptions(ConfigParser& parser, const WCHAR* section);
MOUSECURSOR GetCursorType() const { return m_CursorType; }
HCURSOR GetCursor(bool isButton = false) const;
bool GetCursorState() const { return m_CursorState; }
void DestroyCustomCursor();
void DisableMouseAction(const std::wstring& options);
void ClearMouseAction(const std::wstring& options);
void EnableMouseAction(const std::wstring& options);
void ToggleMouseAction(const std::wstring& options);
bool HasActionCommand(MOUSEACTION action) const { return !GetAction(action).empty(); }
std::wstring GetActionCommand(MOUSEACTION action) const;
bool HasButtonAction() const
{
return !(
GetLeftUpAction().empty() &&
GetLeftDownAction().empty() &&
GetLeftDoubleClickAction().empty() &&
GetMiddleUpAction().empty() &&
GetMiddleDownAction().empty() &&
GetMiddleDoubleClickAction().empty() &&
GetRightUpAction().empty() &&
GetRightDownAction().empty() &&
GetRightDoubleClickAction().empty() &&
GetX1UpAction().empty() &&
GetX1DownAction().empty() &&
GetX1DoubleClickAction().empty() &&
GetX2UpAction().empty() &&
GetX2DownAction().empty() &&
GetX2DoubleClickAction().empty()
);
}
bool HasScrollAction() const
{
return !(
GetMouseScrollUpAction().empty() &&
GetMouseScrollDownAction().empty() &&
GetMouseScrollLeftAction().empty() &&
GetMouseScrollRightAction().empty()
);
}
const std::wstring& GetLeftUpAction() const { return GetAction(MOUSE_LMB_UP); }
const std::wstring& GetLeftDownAction() const { return GetAction(MOUSE_LMB_DOWN); }
const std::wstring& GetLeftDoubleClickAction() const { return GetAction(MOUSE_LMB_DBLCLK); }
const std::wstring& GetMiddleUpAction() const { return GetAction(MOUSE_MMB_UP); }
const std::wstring& GetMiddleDownAction() const { return GetAction(MOUSE_MMB_DOWN); }
const std::wstring& GetMiddleDoubleClickAction() const { return GetAction(MOUSE_MMB_DBLCLK); }
const std::wstring& GetRightUpAction() const { return GetAction(MOUSE_RMB_UP); }
const std::wstring& GetRightDownAction() const { return GetAction(MOUSE_RMB_DOWN); }
const std::wstring& GetRightDoubleClickAction() const { return GetAction(MOUSE_RMB_DBLCLK); }
const std::wstring& GetX1UpAction() const { return GetAction(MOUSE_X1MB_UP); }
const std::wstring& GetX1DownAction() const { return GetAction(MOUSE_X1MB_DOWN); }
const std::wstring& GetX1DoubleClickAction() const { return GetAction(MOUSE_X1MB_DBLCLK); }
const std::wstring& GetX2UpAction() const { return GetAction(MOUSE_X2MB_UP); }
const std::wstring& GetX2DownAction() const { return GetAction(MOUSE_X2MB_DOWN); }
const std::wstring& GetX2DoubleClickAction() const { return GetAction(MOUSE_X2MB_DBLCLK); }
const std::wstring& GetMouseScrollUpAction() const { return GetAction(MOUSE_MW_UP); }
const std::wstring& GetMouseScrollDownAction() const { return GetAction(MOUSE_MW_DOWN); }
const std::wstring& GetMouseScrollLeftAction() const { return GetAction(MOUSE_MW_LEFT); }
const std::wstring& GetMouseScrollRightAction() const { return GetAction(MOUSE_MW_RIGHT); }
const std::wstring& GetOverAction() const { return GetAction(MOUSE_OVER); }
const std::wstring& GetLeaveAction() const { return GetAction(MOUSE_LEAVE); }
private:
void ReplaceMouseVariables(std::wstring& result) const;
const std::wstring& GetAction(MOUSEACTION action) const;
std::vector<MOUSEACTION> Translate(const std::wstring& options) const;
MouseAction m_MouseActions[MOUSEACTION_COUNT];
MOUSECURSOR m_CursorType;
HCURSOR m_CustomCursor;
bool m_CursorState;
Skin* m_Skin;
Meter* m_Meter;
};
#endif