-
Notifications
You must be signed in to change notification settings - Fork 5
/
TaskBarIcon.cpp
53 lines (45 loc) · 1.59 KB
/
TaskBarIcon.cpp
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
/******************************************************************************
* wxVcashGUI: a GUI for Vcash, a decentralized currency
* for the internet (https://vcash.info).
*
* Copyright (c) The Vcash Developers
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
******************************************************************************/
#include "ContextMenu.h"
#include "MainFrame.h"
#include "Resources.h"
#include "TaskBarIcon.h"
#include "VcashApp.h"
using namespace wxGUI;
TaskBarIcon::TaskBarIcon(VcashApp &vcashApp) : vcashApp(vcashApp), wxTaskBarIcon() {
SetIcon(Resources::vcashIcon, wxT("Vcash"));
Bind(wxEVT_TASKBAR_LEFT_DOWN, [this](wxTaskBarIconEvent &ev) {
this->vcashApp.view.minimizeToRestoreFromTray();
});
Bind(wxEVT_MENU, [this] (wxCommandEvent &ev) {
VcashApp &vcashApp = this->vcashApp;
ContextMenu::MenuEntry selection = static_cast<ContextMenu::MenuEntry>(ev.GetId());
vcashApp.view.restoreFromTray();
ContextMenu::processSelection(vcashApp, *vcashApp.view.mainFrame, selection);
});
}
bool TaskBarIcon::isEnabled() {
#if defined(__WXOSX__)
return false;
#else
return wxTaskBarIcon::IsAvailable();
#endif
}
void TaskBarIcon::disable() {
wxImage image = Resources::vcashImage64.ConvertToDisabled();
wxIcon icon;
icon.CopyFromBitmap(wxBitmap(image));
SetIcon(icon);
}
wxMenu* TaskBarIcon::CreatePopupMenu() {
return new ContextMenu(vcashApp);
}