1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
package Slic3r::GUI::SystemInfo;
use strict;
use warnings;
use utf8;
use Wx qw(:font :html :misc :dialog :sizer :systemsettings :frame :id wxTheClipboard);
use Wx::Event qw(EVT_HTML_LINK_CLICKED EVT_LEFT_DOWN EVT_BUTTON);
use Wx::Html;
use base 'Wx::Dialog';
sub new {
my ($class, %params) = @_;
my $self = $class->SUPER::new($params{parent}, -1, 'Slic3r++ - System Information', wxDefaultPosition, [600, 340],
wxDEFAULT_DIALOG_STYLE | wxMAXIMIZE_BOX | wxRESIZE_BORDER);
$self->{text_info} = $params{text_info};
$self->SetBackgroundColour(Wx::wxWHITE);
my $vsizer = Wx::BoxSizer->new(wxVERTICAL);
$self->SetSizer($vsizer);
# text
my $text =
'<html>' .
'<body bgcolor="#ffffff" link="#808080">' .
($params{slic3r_info} // '') .
($params{copyright_info} // '') .
($params{system_info} // '') .
($params{opengl_info} // '') .
'</body>' .
'</html>';
my $html = $self->{html} = Wx::HtmlWindow->new($self, -1, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO);
my $font = Wx::SystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
my $size = &Wx::wxMSW ? 8 : 10;
$html->SetFonts($font->GetFaceName, $font->GetFaceName, [$size * 1.5, $size * 1.4, $size * 1.3, $size, $size, $size, $size]);
$html->SetBorders(10);
$html->SetPage($text);
$vsizer->Add($html, 1, wxEXPAND | wxALIGN_LEFT | wxRIGHT | wxBOTTOM, 0);
EVT_HTML_LINK_CLICKED($self, $html, \&link_clicked);
my $buttons = $self->CreateStdDialogButtonSizer(wxOK);
my $btn_copy_to_clipboard = Wx::Button->new($self, -1, "Copy to Clipboard", wxDefaultPosition, wxDefaultSize);
$buttons->Insert(0, $btn_copy_to_clipboard, 0, wxLEFT, 5);
EVT_BUTTON($self, $btn_copy_to_clipboard, \©_to_clipboard);
$self->SetEscapeId(wxID_CLOSE);
EVT_BUTTON($self, wxID_CLOSE, sub {
$self->EndModal(wxID_CLOSE);
$self->Close;
});
# $vsizer->Add($buttons, 0, wxEXPAND | wxRIGHT | wxBOTTOM, 3);
$vsizer->Add($buttons, 0, wxEXPAND | wxALL, 5);
return $self;
}
sub link_clicked {
my ($self, $event) = @_;
Wx::LaunchDefaultBrowser($event->GetLinkInfo->GetHref);
$event->Skip(0);
}
sub copy_to_clipboard {
my ($self, $event) = @_;
my $data = $self->{text_info};
wxTheClipboard->Open;
wxTheClipboard->SetData(Wx::TextDataObject->new($data));
wxTheClipboard->Close;
}
1;
|