Handle wxEVT_WINDOW_CLOSE

This commit is contained in:
Joseph Lenox 2018-05-04 22:39:28 -05:00 committed by Joseph Lenox
parent 4e22bb3caf
commit c9e831b68c
2 changed files with 21 additions and 11 deletions

View File

@ -51,17 +51,14 @@ MainFrame::MainFrame(const wxString& title, const wxPoint& pos, const wxSize& si
this->Show();
this->Layout();
}
/*
# declare events
EVT_CLOSE($self, sub {
my (undef, $event) = @_;
if ($event->CanVeto) {
if (!$self->{plater}->prompt_unsaved_changes) {
$event->Veto;
// Set up event handlers.
this->Bind(wxEVT_CLOSE_WINDOW, [=](wxCloseEvent& e) {
if (e.CanVeto()) {
if (!this->plater->prompt_unsaved_changes()) {
e.Veto();
return;
}
/*
if ($self->{controller} && $self->{controller}->printing) {
my $confirm = Wx::MessageDialog->new($self, "You are currently printing. Do you want to stop printing and continue anyway?",
'Unfinished Print', wxICON_QUESTION | wxYES_NO | wxNO_DEFAULT);
@ -70,10 +67,21 @@ MainFrame::MainFrame(const wxString& title, const wxPoint& pos, const wxSize& si
return;
}
}
*/
// save window size
gui_config->save_window_pos(this, "main_frame");
// Propagate event
e.Skip();
}
});
/*
# declare events
EVT_CLOSE($self, sub {
my (undef, $event) = @_;
# save window size
wxTheApp->save_window_pos($self, "main_frame");
# propagate event
$event->Skip;

View File

@ -35,6 +35,8 @@ public:
Plater(wxWindow* parent, const wxString& title, std::shared_ptr<Settings> _settings);
void add();
/// Ask if there are any unsaved changes.
bool prompt_unsaved_changes() { return true; }
private:
std::shared_ptr<Slic3r::Print> print {std::make_shared<Print>(Slic3r::Print())};
std::shared_ptr<Slic3r::Model> model {std::make_shared<Model>(Slic3r::Model())};