1
0
forked from cheng/wallet
wallet/welcome_to_rhocoin.cpp

147 lines
3.9 KiB
C++

#include "stdafx.h"
template <typename T>class roFont : public wxFont {
public:
T* m_win;
roFont(T* win) :wxFont(win->GetFont()), m_win(win) {}
~roFont() { m_win->SetFont(*this); }
auto SetPointSize(int i) { wxFont::SetPointSize(i);
return m_win;
}
};
wxButton* welcome_to_rhocoin::AddButton(
wxString wxs,
void(Frame::* method)(wxCommandEvent&)
) {
auto button{
new wxButton(
this,
wxWindow::NewControlId(),
wxs,
wxDefaultPosition, wxDefaultSize, 0L, wxDefaultValidator,
wxs
)
};
Bind(wxEVT_BUTTON, method, singletonFrame, button->GetId());
return button;
}
// This routine exists to override wxWidgets overly clever translation of utf-8 to wxStrings.
wxButton* welcome_to_rhocoin::AddButton(
const char sz[],
void(Frame::* method)(wxCommandEvent&)
) {
return AddButton(_wx(sz), method);
}
welcome_to_rhocoin::welcome_to_rhocoin(
wxWindow* parent) : wxPanel(
parent,
myID_WELCOME_TO_ROCOIN,
wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL,
_wx(sz_NewWallet)
)
{ if (singletonWelcome != nullptr)singletonWelcome->Destroy();
auto sizer = new wxBoxSizer(wxVERTICAL); //Allocated on heap, eventually gets given to this window, which will delete it.
sizer->Add(
roFont(
new wxStaticText(
this,
wxID_ANY,
_wx(sz_welcome_to_rocoin),
wxDefaultPosition, wxDefaultSize,
wxALIGN_CENTRE_HORIZONTAL | wxTE_MULTILINE
)
).SetPointSize(32),
42, // make vertically stretchable
wxEXPAND | // make horizontally stretchable
wxALL, // and make border all around
2);
sizer->Add(
roFont(
new wxStaticText(
this,
wxID_ANY,
_wx(sz_please_select_from_three_options),
wxDefaultPosition, wxDefaultSize,
wxALIGN_CENTRE_HORIZONTAL | wxTE_MULTILINE
)
).SetPointSize(20),
12, // make vertically stretchable
wxEXPAND | // make horizontally stretchable
wxALL, // and make border all around
2);
auto sizerRow{ new wxGridSizer(3, 2, 2) };
sizerRow->Add(
new wxStaticText(
this,
wxID_ANY,
_wx(sz_create_a_new_wallet),
wxDefaultPosition, wxDefaultSize,
wxALIGN_CENTRE_HORIZONTAL | wxTE_MULTILINE
),
40, // make vertically stretchable
wxEXPAND | // make horizontally stretchable
wxALL, // and make border all around
2);
sizerRow->Add(
new wxStaticText(
this,
wxID_ANY,
_wx(sz_recreate_wallet_from_old_secret),
wxDefaultPosition, wxDefaultSize,
wxALIGN_CENTRE_HORIZONTAL | wxTE_MULTILINE
),
40, // make vertically stretchable
wxEXPAND | // make horizontally stretchable
wxALL, // and make border all around
2);
sizerRow->Add(
new wxStaticText(
this,
wxID_ANY,
_wx(sz_open_existing_wallet),
wxDefaultPosition, wxDefaultSize,
wxALIGN_CENTRE_HORIZONTAL | wxTE_MULTILINE
),
40,
wxEXPAND | // make horizontally stretchable
wxALL, // and make border all around
2);
sizer->Add(sizerRow, 20, wxEXPAND | wxALL, 2);
wxButton * btn_default;
sizerRow = new wxGridSizer(3, 2, 2);
sizerRow->Add(
btn_default=AddButton(sz_new_wallet, &Frame::OnSaveNew),
40, // make vertically stretchable
wxEXPAND | // make horizontally stretchable
wxALL, // and make border all around
2);
sizerRow->Add(
AddButton(sz_existing_secret, &Frame::RecreateWalletFromExistingSecret),
40, // make vertically stretchable
wxEXPAND | // make horizontally stretchable
wxALL, // and make border all around
4);
sizerRow->Add(
AddButton(sz_existing_wallet, &Frame::OnFileOpen),
40, // make vertically stretchable
wxEXPAND | // make horizontally stretchable
wxALL, // and make border all around
4);
sizer->Add(sizerRow, 40, wxEXPAND | wxALL, 2);
btn_default->SetDefault();
SetSizer(sizer);
assert(singletonWelcome == nullptr);
singletonWelcome = this;
}
welcome_to_rhocoin::~welcome_to_rhocoin() {
assert(singletonWelcome ==this);
singletonWelcome = nullptr;
}