ReloadDialog.pm 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. # A tiny dialog to select how to reload an object that has additional parts or modifiers.
  2. package Slic3r::GUI::ReloadDialog;
  3. use strict;
  4. use warnings;
  5. use utf8;
  6. use Wx qw(:button :dialog :id :misc :sizer :choicebook wxTAB_TRAVERSAL);
  7. use Wx::Event qw(EVT_CLOSE);
  8. use base 'Wx::Dialog';
  9. sub new {
  10. my $class = shift;
  11. my ($parent,$default_selection) = @_;
  12. my $self = $class->SUPER::new($parent, -1, "Additional parts and modifiers detected", wxDefaultPosition, [350,100], wxDEFAULT_DIALOG_STYLE);
  13. # label
  14. my $text = Wx::StaticText->new($self, -1, "Additional parts and modifiers are loaded in the current model. \n\nHow do you want to proceed?", wxDefaultPosition, wxDefaultSize);
  15. # selector
  16. $self->{choice} = my $choice = Wx::Choice->new($self, -1, wxDefaultPosition, wxDefaultSize, []);
  17. $choice->Append("Reload all linked files");
  18. $choice->Append("Reload main file, copy added parts & modifiers");
  19. $choice->Append("Reload main file, discard added parts & modifiers");
  20. $choice->SetSelection($default_selection);
  21. # checkbox
  22. $self->{checkbox} = my $checkbox = Wx::CheckBox->new($self, -1, "Don't ask again");
  23. my $vsizer = Wx::BoxSizer->new(wxVERTICAL);
  24. my $hsizer = Wx::BoxSizer->new(wxHORIZONTAL);
  25. $vsizer->Add($text, 0, wxEXPAND | wxALL, 10);
  26. $vsizer->Add($choice, 0, wxEXPAND | wxALL, 10);
  27. $hsizer->Add($checkbox, 1, wxEXPAND | wxALL, 10);
  28. $hsizer->Add($self->CreateButtonSizer(wxOK | wxCANCEL), 0, wxEXPAND | wxALL, 10);
  29. $vsizer->Add($hsizer, 0, wxEXPAND | wxALL, 0);
  30. $self->SetSizer($vsizer);
  31. $self->SetMinSize($self->GetSize);
  32. $vsizer->SetSizeHints($self);
  33. # needed to actually free memory
  34. EVT_CLOSE($self, sub {
  35. $self->EndModal(wxID_CANCEL);
  36. $self->Destroy;
  37. });
  38. return $self;
  39. }
  40. sub GetSelection {
  41. my ($self) = @_;
  42. return $self->{choice}->GetSelection;
  43. }
  44. sub GetHideOnNext {
  45. my ($self) = @_;
  46. return $self->{checkbox}->GetValue;
  47. }
  48. 1;