-
Notifications
You must be signed in to change notification settings - Fork 5
/
View.cpp
235 lines (181 loc) · 5.74 KB
/
View.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
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
/******************************************************************************
* 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 <wx/wxprec.h>
#ifndef WX_PRECOMP
#include <wx/msgdlg.h>
#include <wx/notifmsg.h>
#endif
#include "AccountPage.h"
#include "AddressesPage.h"
#include "ConsolePage.h"
#include "ContextMenu.h"
#include "HistoryPage.h"
#include "MainFrame.h"
#include "MainPanel.h"
#include "MiningPage.h"
#include "Resources.h"
#include "StatusBarWallet.h"
#include "StatusBar.h"
#include "TransferPage.h"
#include "TaskBarIcon.h"
#include "ToolsFrame.h"
#include "ToolsPanel.h"
#include "VcashApp.h"
#include "View.h"
#include "WalletActions.h"
using namespace wxGUI;
// Account
void View::setBalance(const std::string &balance) {
accountPage->setBalance(balance);
}
void View::setUnconfirmed(const std::string &unconfirmed) {
accountPage->setUnconfirmed(unconfirmed);
}
void View::setStake(const std::string &stake) {
accountPage->setStake(stake);
}
void View::setImmature(const std::string &immature) {
accountPage->setImmature(immature);
}
// MainPanel
void View::showMainPage(MainPage page) {
mainPanel->showPage(page);
}
// Transfer
void View::setDestinationAddress(const std::string &address) {
transferPage->setDestinationAddress(address);
}
void View::setAmount(const std::string &amount) {
transferPage->setsetAmount(amount);
}
void View::setZerotime(bool state) {
transferPage->setZerotime(state);
}
void View::setChainblender(bool state) {
transferPage->setChainblender(state);
}
// Wallet state
// sets wallet state shown in view. Calls controller too
void View::setWalletStatus(WalletStatus walletStatus) {
walletLock->setWalletStatus(walletStatus);
}
// gets wallet state shown in view
WalletStatus View::getWalletStatus() {
return walletLock->getWalletStatus();
}
// Status bar
void View::setStatusBarMessage(const std::string &msg) {
statusBar->setMessage(wxString(msg));
}
void View::setStatusBarWorking(bool working) {
statusBar->setWorking(working);
}
// Mining state
// sets mining state shown in view. Calls controller too
void View::setMining(bool mining) {
miningPage->setMining(mining);
}
//sets mining hash rate
void View::setHash(const std::string &hashRate) {
miningPage->setHash(hashRate);
}
// sets mining state shown in view
bool View::getMining() {
return miningPage->getMining();
}
// Address book
void View::addAddress(const std::string &account, const std::string &address) {
addressesPage->addAddress(account, address);
}
void View::emboldenAddress(const std::string &address, bool bold) {
addressesPage->emboldenAddress(address, bold);
}
// Console
// apends a new line of text to console output
void View::appendToConsole(const std::string &text, bool bold) {
showToolsPage(ToolsPage::Console);
consolePage->appendToConsole(text, bold);
}
// History
void View::addTransaction(const std::string &txid, const std::time_t &date, const std::string &status,
const std::string &amount) {
historyPage->addTransaction(txid, date, status, amount);
}
void View::setColour(const std::string &txid, BulletColor color) {
historyPage->setColour(txid, color);
}
void View::setStatus(const std::string &txid, const std::string &status) {
historyPage->setStatus(txid, status);
}
// Statistics
void View::setTCP(const std::string &tcp) {
statisticsPage->setTCP(tcp);
}
void View::setUDP(const std::string &udp) {
statisticsPage->setUDP(udp);
}
void View::setEstimated(const std::string &estimated) {
statisticsPage->setEstimated(estimated);
}
void View::setTotal(const std::string &total) {
statisticsPage->setTotal(total);
}
void View::setDifficulty(const std::string &difficulty) {
statisticsPage->setDifficulty(difficulty);
}
void View::setSupply(const std::string &supply) {
statisticsPage->setSupply(supply);
}
void View::messageBox(const std::string &msg, const std::string &title, long style) {
wxMessageBox(msg, title, style, mainFrame);
}
void View::notificationBox(const std::string &msg, const std::string &title) {
wxNotificationMessage *notificationMessage = new wxNotificationMessage(wxString(title), wxString(msg), mainFrame);
#if (wxMAJOR_VERSION >= 3) && (wxMINOR_VERSION >= 1)
wxIcon icon;
icon.CopyFromBitmap(wxBitmap(Resources::vcashImage64));
notificationMessage->SetIcon(icon);
notificationMessage->SetParent(mainFrame);
#if defined (__WXMSW__)
wxNotificationMessage::UseTaskBarIcon(taskBarIcon);
#endif
#endif
notificationMessage->Show(2);
}
std::pair<bool, std::string> View::restoreHDSeed(VcashApp &vcashApp) {
return WalletActions::restoreHDSeed(vcashApp.controller, *mainFrame);
}
void View::runContextMenu(VcashApp &vcashApp, bool atClickPosition) {
wxPoint p = atClickPosition ? wxDefaultPosition : walletLock->GetPosition() + statusBar->GetPosition();
ContextMenu::runContextMenu(vcashApp, *mainFrame, p);
}
void View::showToolsFrame() {
toolsFrame->show();
}
void View::hideToolsFrame() {
toolsFrame->hide();
}
void View::showHideToolsFrame() {
toolsFrame->showHide();
}
void View::showToolsPage(ToolsPage page) {
toolsPanel->showPage(page);
}
void View::minimizeToTray() {
mainFrame->minimizeToTray();
}
void View::restoreFromTray() {
mainFrame->restoreFromTray();
}
void View::minimizeToRestoreFromTray() {
mainFrame->minimizeToRestoreFromTray();
}