PresetEditorDialog.pm 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. package Slic3r::GUI::PresetEditorDialog;
  2. use strict;
  3. use warnings;
  4. use Wx qw(:dialog :id :misc :sizer :button :icon wxTheApp WXK_ESCAPE);
  5. use Wx::Event qw(EVT_CLOSE EVT_CHAR_HOOK);
  6. use base qw(Wx::Dialog Class::Accessor);
  7. use utf8;
  8. __PACKAGE__->mk_accessors(qw(preset_editor));
  9. sub new {
  10. my ($class, $parent) = @_;
  11. my $self = $class->SUPER::new($parent, -1, "Settings", wxDefaultPosition, [900,500],
  12. wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxDIALOG_EX_METAL);
  13. $self->preset_editor($self->preset_editor_class->new($self));
  14. $self->SetTitle($self->preset_editor->title);
  15. my $sizer = Wx::BoxSizer->new(wxVERTICAL);
  16. $sizer->Add($self->preset_editor, 1, wxEXPAND);
  17. $self->SetSizer($sizer);
  18. #$sizer->SetSizeHints($self);
  19. if (0) {
  20. my $buttons = $self->CreateStdDialogButtonSizer(wxCLOSE);
  21. $sizer->Add($buttons, 0, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 10);
  22. }
  23. wxTheApp->restore_window_pos($self, "preset_editor");
  24. EVT_CLOSE($self, sub {
  25. my (undef, $event) = @_;
  26. # save window size
  27. wxTheApp->save_window_pos($self, "preset_editor");
  28. # propagate event
  29. $event->Skip;
  30. });
  31. EVT_CHAR_HOOK($self, sub {
  32. my (undef, $event) = @_;
  33. if ($event->GetKeyCode == WXK_ESCAPE) {
  34. $self->Close;
  35. } else {
  36. $event->Skip;
  37. }
  38. });
  39. return $self;
  40. }
  41. package Slic3r::GUI::PresetEditorDialog::Printer;
  42. use base qw(Slic3r::GUI::PresetEditorDialog);
  43. sub preset_editor_class { "Slic3r::GUI::PresetEditor::Printer" }
  44. package Slic3r::GUI::PresetEditorDialog::Filament;
  45. use base qw(Slic3r::GUI::PresetEditorDialog);
  46. sub preset_editor_class { "Slic3r::GUI::PresetEditor::Filament" }
  47. package Slic3r::GUI::PresetEditorDialog::Print;
  48. use base qw(Slic3r::GUI::PresetEditorDialog);
  49. sub preset_editor_class { "Slic3r::GUI::PresetEditor::Print" }
  50. 1;