/
Mouse.h
140 lines (118 loc) · 4.65 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
/* 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 MOUSECURSOR
{
MOUSECURSOR_ARROW,
MOUSECURSOR_HAND,
MOUSECURSOR_TEXT,
MOUSECURSOR_HELP,
MOUSECURSOR_BUSY,
MOUSECURSOR_CROSS,
MOUSECURSOR_PEN,
MOUSECURSOR_CUSTOM
};
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() const;
bool GetCursorState() const {return m_CursorState; }
void DestroyCustomCursor();
bool HasActionCommand(MOUSEACTION action) const { return !m_MouseActions[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 m_MouseActions[MOUSE_LMB_UP]; }
const std::wstring& GetLeftDownAction() const { return m_MouseActions[MOUSE_LMB_DOWN]; }
const std::wstring& GetLeftDoubleClickAction() const { return m_MouseActions[MOUSE_LMB_DBLCLK]; }
const std::wstring& GetMiddleUpAction() const { return m_MouseActions[MOUSE_MMB_UP]; }
const std::wstring& GetMiddleDownAction() const { return m_MouseActions[MOUSE_MMB_DOWN]; }
const std::wstring& GetMiddleDoubleClickAction() const { return m_MouseActions[MOUSE_MMB_DBLCLK]; }
const std::wstring& GetRightUpAction() const { return m_MouseActions[MOUSE_RMB_UP]; }
const std::wstring& GetRightDownAction() const { return m_MouseActions[MOUSE_RMB_DOWN]; }
const std::wstring& GetRightDoubleClickAction() const { return m_MouseActions[MOUSE_RMB_DBLCLK]; }
const std::wstring& GetX1UpAction() const { return m_MouseActions[MOUSE_X1MB_UP]; }
const std::wstring& GetX1DownAction() const { return m_MouseActions[MOUSE_X1MB_DOWN]; }
const std::wstring& GetX1DoubleClickAction() const { return m_MouseActions[MOUSE_X1MB_DBLCLK]; }
const std::wstring& GetX2UpAction() const { return m_MouseActions[MOUSE_X2MB_UP]; }
const std::wstring& GetX2DownAction() const { return m_MouseActions[MOUSE_X2MB_DOWN]; }
const std::wstring& GetX2DoubleClickAction() const { return m_MouseActions[MOUSE_X2MB_DBLCLK]; }
const std::wstring& GetMouseScrollUpAction() const { return m_MouseActions[MOUSE_MW_UP]; }
const std::wstring& GetMouseScrollDownAction() const { return m_MouseActions[MOUSE_MW_DOWN]; }
const std::wstring& GetMouseScrollLeftAction() const { return m_MouseActions[MOUSE_MW_LEFT]; }
const std::wstring& GetMouseScrollRightAction() const { return m_MouseActions[MOUSE_MW_RIGHT]; }
const std::wstring& GetOverAction() const { return m_MouseActions[MOUSE_OVER]; }
const std::wstring& GetLeaveAction() const { return m_MouseActions[MOUSE_LEAVE]; }
private:
void ReplaceMouseVariables(std::wstring& result) const;
std::wstring m_MouseActions[MOUSEACTION_COUNT];
MOUSECURSOR m_CursorType;
HCURSOR m_CustomCursor;
bool m_CursorState;
Skin* m_Skin;
Meter* m_Meter;
};
#endif