AboutDialog.pm 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. package Slic3r::GUI::AboutDialog;
  2. use strict;
  3. use warnings;
  4. use utf8;
  5. use Wx qw(:font :html :misc :dialog :sizer :systemsettings :frame :id);
  6. use Wx::Event qw(EVT_HTML_LINK_CLICKED EVT_LEFT_DOWN EVT_BUTTON);
  7. use Wx::Print;
  8. use Wx::Html;
  9. use base 'Wx::Dialog';
  10. sub new {
  11. my $class = shift;
  12. my ($parent) = @_;
  13. my $self = $class->SUPER::new($parent, -1, 'About Slic3r', wxDefaultPosition, [600, 340], wxCAPTION);
  14. $self->SetBackgroundColour(Wx::wxWHITE);
  15. my $hsizer = Wx::BoxSizer->new(wxHORIZONTAL);
  16. $self->SetSizer($hsizer);
  17. # logo
  18. my $logo = Slic3r::GUI::AboutDialog::Logo->new($self, -1, wxDefaultPosition, wxDefaultSize);
  19. $logo->SetBackgroundColour(Wx::wxWHITE);
  20. $hsizer->Add($logo, 0, wxEXPAND | wxLEFT | wxRIGHT, 30);
  21. my $vsizer = Wx::BoxSizer->new(wxVERTICAL);
  22. $hsizer->Add($vsizer, 1, wxEXPAND, 0);
  23. # title
  24. my $title = Wx::StaticText->new($self, -1, $Slic3r::FORK_NAME, wxDefaultPosition, wxDefaultSize);
  25. my $title_font = Wx::SystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
  26. $title_font->SetWeight(wxFONTWEIGHT_BOLD);
  27. $title_font->SetFamily(wxFONTFAMILY_ROMAN);
  28. $title_font->SetPointSize(24);
  29. $title->SetFont($title_font);
  30. $vsizer->Add($title, 0, wxALIGN_LEFT | wxTOP, 30);
  31. # version
  32. my $version = Wx::StaticText->new($self, -1, "Version $Slic3r::VERSION", wxDefaultPosition, wxDefaultSize);
  33. my $version_font = Wx::SystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
  34. $version_font->SetPointSize(&Wx::wxMSW ? 9 : 11);
  35. $version->SetFont($version_font);
  36. $vsizer->Add($version, 0, wxALIGN_LEFT | wxBOTTOM, 10);
  37. # text
  38. my $text =
  39. '<html>' .
  40. '<body bgcolor="#ffffff" link="#808080">' .
  41. '<font color="#808080">' .
  42. 'Copyright &copy; 2016 Vojtech Bubnik, Prusa Research. <br />' .
  43. 'Copyright &copy; 2011-2016 Alessandro Ranellucci. <br />' .
  44. '<a href="http://slic3r.org/">Slic3r</a> is licensed under the ' .
  45. '<a href="http://www.gnu.org/licenses/agpl-3.0.html">GNU Affero General Public License, version 3</a>.' .
  46. '<br /><br /><br />' .
  47. 'Contributions by Henrik Brix Andersen, Nicolas Dandrimont, Mark Hindess, Petr Ledvina, Y. Sapir, Mike Sheldrake and numerous others. ' .
  48. 'Manual by Gary Hodgson. Inspired by the RepRap community. <br />' .
  49. 'Slic3r logo designed by Corey Daniels, <a href="http://www.famfamfam.com/lab/icons/silk/">Silk Icon Set</a> designed by Mark James. ' .
  50. '</font>' .
  51. '</body>' .
  52. '</html>';
  53. my $html = Wx::HtmlWindow->new($self, -1, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_NEVER);
  54. my $font = Wx::SystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
  55. my $size = &Wx::wxMSW ? 8 : 10;
  56. $html->SetFonts($font->GetFaceName, $font->GetFaceName, [$size, $size, $size, $size, $size, $size, $size]);
  57. $html->SetBorders(2);
  58. $html->SetPage($text);
  59. $vsizer->Add($html, 1, wxEXPAND | wxALIGN_LEFT | wxRIGHT | wxBOTTOM, 20);
  60. EVT_HTML_LINK_CLICKED($self, $html, \&link_clicked);
  61. my $buttons = $self->CreateStdDialogButtonSizer(wxOK);
  62. $self->SetEscapeId(wxID_CLOSE);
  63. EVT_BUTTON($self, wxID_CLOSE, sub {
  64. $self->EndModal(wxID_CLOSE);
  65. $self->Close;
  66. });
  67. $vsizer->Add($buttons, 0, wxEXPAND | wxRIGHT | wxBOTTOM, 3);
  68. EVT_LEFT_DOWN($self, sub { $self->Close });
  69. EVT_LEFT_DOWN($logo, sub { $self->Close });
  70. return $self;
  71. }
  72. sub link_clicked {
  73. my ($self, $event) = @_;
  74. Wx::LaunchDefaultBrowser($event->GetLinkInfo->GetHref);
  75. $event->Skip(0);
  76. }
  77. package Slic3r::GUI::AboutDialog::Logo;
  78. use Wx qw(:bitmap :dc);
  79. use Wx::Event qw(EVT_PAINT);
  80. use base 'Wx::Panel';
  81. sub new {
  82. my $class = shift;
  83. my $self = $class->SUPER::new(@_);
  84. $self->{logo} = Wx::Bitmap->new($Slic3r::var->("Slic3r_192px.png"), wxBITMAP_TYPE_PNG);
  85. $self->SetMinSize(Wx::Size->new($self->{logo}->GetWidth, $self->{logo}->GetHeight));
  86. EVT_PAINT($self, \&repaint);
  87. return $self;
  88. }
  89. sub repaint {
  90. my ($self, $event) = @_;
  91. my $dc = Wx::PaintDC->new($self);
  92. $dc->SetBackgroundMode(wxTRANSPARENT);
  93. my $size = $self->GetSize;
  94. my $logo_w = $self->{logo}->GetWidth;
  95. my $logo_h = $self->{logo}->GetHeight;
  96. $dc->DrawBitmap($self->{logo}, ($size->GetWidth - $logo_w) / 2, ($size->GetHeight - $logo_h) / 2, 1);
  97. $event->Skip;
  98. }
  99. 1;