forked from rainmeter/rainmeter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTrayIcon.h
92 lines (70 loc) · 2.13 KB
/
TrayIcon.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
/* Copyright (C) 2004 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 RM_LIBRARY_TRAYICON_H_
#define RM_LIBRARY_TRAYICON_H_
#include <windows.h>
#include <ole2.h> // For Gdiplus.h.
#include <gdiplus.h>
#include <vector>
#define WM_TRAY_NOTIFYICON WM_USER + 101
#define TRAYICON_SIZE 16
enum TRAY_METER_TYPE
{
TRAY_METER_TYPE_NONE,
TRAY_METER_TYPE_HISTOGRAM,
TRAY_METER_TYPE_BITMAP
};
class ConfigParser;
class Measure;
class TrayIcon
{
public:
TrayIcon();
~TrayIcon();
TrayIcon(const TrayIcon& other) = delete;
TrayIcon& operator=(TrayIcon other) = delete;
void Initialize();
void ReadOptions(ConfigParser& parser);
HWND GetWindow() { return m_Window; }
bool IsTrayIconEnabled() { return m_IconEnabled; }
void SetTrayIcon(bool enabled, bool setTemporarily = false);
void ShowWelcomeNotification();
void ShowUpdateNotification(LPCWSTR newVersion);
void ShowInstallUpdateNotification(LPCWSTR newVersion);
protected:
static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
private:
enum TRAY_NOTIFICATION
{
TRAY_NOTIFICATION_NONE,
TRAY_NOTIFICATION_WELCOME,
TRAY_NOTIFICATION_UPDATE,
TRAY_NOTIFICATION_INSTALL_UPDATE
};
bool AddTrayIcon();
bool IsTrayIconReady();
void TryAddTrayIcon();
void CheckTrayIcon();
void RemoveTrayIcon();
void ModifyTrayIcon(double value);
HICON CreateTrayIcon(double value);
void ShowNotification(TRAY_NOTIFICATION id, const WCHAR* title, const WCHAR* text);
HICON m_Icon;
HWND m_Window;
Measure* m_Measure;
TRAY_METER_TYPE m_MeterType;
Gdiplus::Color m_Color1;
Gdiplus::Color m_Color2;
Gdiplus::Bitmap* m_Bitmap;
std::vector<HICON> m_Icons;
double m_Values[TRAYICON_SIZE];
int m_Pos;
TRAY_NOTIFICATION m_Notification;
bool m_TrayContextMenuEnabled;
bool m_IconEnabled;
};
#endif