-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgui.h
130 lines (99 loc) · 2.67 KB
/
gui.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
/*
COPYRIGHT (C) 2024 ETHAN CHAN
ALL RIGHTS RESERVED. UNAUTHORIZED COPYING, MODIFICATION, DISTRIBUTION, OR USE
OF THIS SOFTWARE WITHOUT PRIOR PERMISSION IS STRICTLY PROHIBITED.
THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM,
OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
PROJECT NAME: DieKnow
FILENAME: src/gui.h
DESCRIPTION: GUI interface to DieKnow API
AUTHOR: Ethan Chan
DATE: 2024-11-13
VERSION: 1.0.1
*/
#ifndef GUI_H
#define GUI_H
#define NOMINMAX
#include <windows.h>
#include <commctrl.h>
#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
#include "api.h"
#include "system.h"
#include "settings.h"
// Or more correctly, widget dimensions
const int BUTTON_WIDTH = 200;
const int BUTTON_HEIGHT = 35;
// Space between widgets as padding
const int PADDING = 10;
namespace Widgets {
enum Widget {
RUNNING = 0,
TASKKILL,
EXIT,
DIRECTORY,
INTERVAL_LABEL,
INTERVAL,
INTERVAL_SET,
STATE,
EXECUTABLES_KILLED,
WINDOWS,
OPEN_EXPLORER,
SYSTEM_INFORMATION,
TAKE_SNAPSHOT,
RESTORE_SNAPSHOT
};
} // namespace Widgets
extern "C" {
DK_API void create_window();
}
void tooltip(HWND hwnd, HWND control, const char* text);
const char* get_selected(HWND listbox);
class Application {
public:
// Used to call `WM_SETFONT`
std::vector<HWND> widgets;
// Used to determine whether or not to refresh the listbox
std::vector<std::string> previous_executables;
std::vector<System::Window> previous_windows;
std::vector<System::Window> snapshot;
HWND hwnd;
HWND state;
HWND windows;
HWND restore_snapshot;
static COLORREF GREEN;
static COLORREF RED;
bool is_restoring = false;
Application();
void manage_command(
Application* app,
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
);
// Use `static` to allow it to be called as an event by Windows API
static LRESULT CALLBACK WindowProc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
);
void restore_snapshots();
void hide_snapshots();
inline void update(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
);
void update_windows(const std::vector<System::Window>& current_windows);
};
#endif // GUI_H