2022-02-16 00:53:01 -05:00
# 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 ) ;
2022-04-02 22:07:41 -04:00
Bind ( wxEVT_CLOSE_WINDOW , & welcome_to_rhocoin : : OnClose , this ) ;
2022-02-16 00:53:01 -05:00
assert ( singletonWelcome = = nullptr ) ;
singletonWelcome = this ;
2023-11-10 07:00:15 -05:00
singletonFrame - > SetMinClientSize ( sizer - > ComputeFittingClientSize ( singletonFrame ) ) ;
2022-02-16 00:53:01 -05:00
}
welcome_to_rhocoin : : ~ welcome_to_rhocoin ( ) {
assert ( singletonWelcome = = this ) ;
singletonWelcome = nullptr ;
}
2022-04-02 22:07:41 -04:00
void welcome_to_rhocoin : : OnClose ( wxCloseEvent & event ) {
// This event gives you the opportunity to clean up anything that needs explicit cleanup, albeit if you have done your work right nothing should need explicit cleanup,
// and to object to the closing in a "file not saved" type situation.
// https://docs.wxwidgets.org/trunk/classwx_close_event.html
DestroyChildren ( ) ;
Destroy ( ) ; //Default handler will destroy the window. This is our handler for the user calling close, replacing the default handler.
}