feat(modulo): improve wizard main buttons

This commit is contained in:
Federico Terzi 2021-06-13 14:39:24 +02:00
parent 2cfb1be487
commit ac3f6735f6
4 changed files with 38 additions and 2 deletions

View File

@ -85,6 +85,7 @@ class DerivedFrame : public WizardFrame
{
protected:
void check_timer_tick( wxTimerEvent& event );
void on_page_changed( wxBookCtrlEvent& event );
void welcome_start_clicked(wxCommandEvent &event);
void navigate_to_next_page_or_close();
@ -102,7 +103,7 @@ DerivedFrame::DerivedFrame(wxWindow *parent)
// Load the first page
int page = find_next_page(-1);
if (page >= 0) {
this->m_simplebook->ChangeSelection(page);
this->m_simplebook->SetSelection(page);
} else {
Close(true);
}
@ -112,7 +113,7 @@ void DerivedFrame::navigate_to_next_page_or_close() {
int current_page = this->m_simplebook->GetSelection();
int page = find_next_page(current_page);
if (page >= 0) {
this->m_simplebook->ChangeSelection(page);
this->m_simplebook->SetSelection(page);
} else {
Close(true);
}
@ -133,6 +134,37 @@ void DerivedFrame::check_timer_tick( wxTimerEvent& event ) {
}
}
void DerivedFrame::on_page_changed( wxBookCtrlEvent& event ) {
int current_page = this->m_simplebook->GetSelection();
switch (current_page) {
case WELCOME_PAGE_INDEX:
{
this->welcome_start_button->SetDefault();
break;
}
case MOVE_BUNDLE_PAGE_INDEX:
{
this->move_bundle_quit_button->SetDefault();
break;
}
case MIGRATE_PAGE_INDEX:
{
this->migrate_backup_and_migrate_button->SetDefault();
break;
}
case ADD_PATH_PAGE_INDEX:
{
this->add_path_continue_button->SetDefault();
break;
}
case ACCESSIBILITY_PAGE_INDEX:
{
this->accessibility_enable_button->SetDefault();
break;
}
}
}
bool WizardApp::OnInit()
{

View File

@ -123,6 +123,7 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnSimplebookPageChanged">on_page_changed</event>
<object class="simplebookpage" expanded="1">
<property name="label">a page</property>
<property name="select">0</property>

View File

@ -276,6 +276,7 @@ WizardFrame::WizardFrame( wxWindow* parent, wxWindowID id, const wxString& title
// Connect Events
this->Connect( wxID_ANY, wxEVT_TIMER, wxTimerEventHandler( WizardFrame::check_timer_tick ) );
m_simplebook->Connect( wxEVT_COMMAND_BOOKCTRL_PAGE_CHANGED, wxBookCtrlEventHandler( WizardFrame::on_page_changed ), NULL, this );
welcome_start_button->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WizardFrame::welcome_start_clicked ), NULL, this );
move_bundle_quit_button->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WizardFrame::move_bundle_quit_clicked ), NULL, this );
migrate_compatibility_mode_button->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WizardFrame::migrate_compatibility_mode_clicked ), NULL, this );
@ -288,6 +289,7 @@ WizardFrame::~WizardFrame()
{
// Disconnect Events
this->Disconnect( wxID_ANY, wxEVT_TIMER, wxTimerEventHandler( WizardFrame::check_timer_tick ) );
m_simplebook->Disconnect( wxEVT_COMMAND_BOOKCTRL_PAGE_CHANGED, wxBookCtrlEventHandler( WizardFrame::on_page_changed ), NULL, this );
welcome_start_button->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WizardFrame::welcome_start_clicked ), NULL, this );
move_bundle_quit_button->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WizardFrame::move_bundle_quit_clicked ), NULL, this );
migrate_compatibility_mode_button->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WizardFrame::migrate_compatibility_mode_clicked ), NULL, this );

View File

@ -79,6 +79,7 @@ class WizardFrame : public wxFrame
// Virtual event handlers, overide them in your derived class
virtual void check_timer_tick( wxTimerEvent& event ) { event.Skip(); }
virtual void on_page_changed( wxBookCtrlEvent& event ) { event.Skip(); }
virtual void welcome_start_clicked( wxCommandEvent& event ) { event.Skip(); }
virtual void move_bundle_quit_clicked( wxCommandEvent& event ) { event.Skip(); }
virtual void migrate_compatibility_mode_clicked( wxCommandEvent& event ) { event.Skip(); }