2018-04-09 17:03:37 +02:00
#include "AboutDialog.hpp"
2018-11-26 14:41:58 +01:00
#include "I18N.hpp"
2018-04-09 17:03:37 +02:00
2018-11-26 14:41:58 +01:00
#include "libslic3r/Utils.hpp"
2019-02-06 09:49:32 +01:00
#include "GUI_App.hpp"
2019-02-11 14:14:35 +01:00
#include "wxExtensions.hpp"
2018-04-09 17:03:37 +02:00
namespace Slic3r {
namespace GUI {
AboutDialogLogo :: AboutDialogLogo ( wxWindow * parent )
: wxPanel ( parent , wxID_ANY , wxDefaultPosition , wxDefaultSize )
{
this -> SetBackgroundColour ( * wxWHITE );
this -> logo = wxBitmap ( from_u8 ( Slic3r :: var ( "Slic3r_192px.png" )), wxBITMAP_TYPE_PNG );
this -> SetMinSize ( this -> logo . GetSize ());
this -> Bind ( wxEVT_PAINT , & AboutDialogLogo :: onRepaint , this );
}
void AboutDialogLogo :: onRepaint ( wxEvent & event )
{
wxPaintDC dc ( this );
dc . SetBackgroundMode ( wxTRANSPARENT );
wxSize size = this -> GetSize ();
int logo_w = this -> logo . GetWidth ();
int logo_h = this -> logo . GetHeight ();
dc . DrawBitmap ( this -> logo , ( size . GetWidth () - logo_w ) / 2 , ( size . GetHeight () - logo_h ) / 2 , true );
event . Skip ();
}
AboutDialog :: AboutDialog ()
2019-04-18 15:22:10 +02:00
: DPIDialog ( NULL , wxID_ANY , wxString :: Format ( _ ( L ( "About %s" )), SLIC3R_APP_NAME ), wxDefaultPosition ,
2019-04-18 15:05:17 +02:00
wxDefaultSize , /*wxCAPTION*/ wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER )
2018-04-09 17:03:37 +02:00
{
2019-04-18 15:05:17 +02:00
SetFont ( wxGetApp (). normal_font ());
2018-05-16 13:56:03 +02:00
wxColour bgr_clr = wxSystemSettings :: GetColour ( wxSYS_COLOUR_WINDOW );
SetBackgroundColour ( bgr_clr );
2018-04-09 17:03:37 +02:00
wxBoxSizer * hsizer = new wxBoxSizer ( wxHORIZONTAL );
2018-05-16 13:56:03 +02:00
auto main_sizer = new wxBoxSizer ( wxVERTICAL );
main_sizer -> Add ( hsizer , 0 , wxEXPAND | wxALL , 20 );
2018-04-09 17:03:37 +02:00
// logo
2019-04-18 15:05:17 +02:00
m_logo_bitmap = PrusaBitmap ( this , "Slic3r_192px.png" , 192 );
m_logo = new wxStaticBitmap ( this , wxID_ANY , m_logo_bitmap . bmp ());
// auto *logo = new wxStaticBitmap(this, wxID_ANY, create_scaled_bitmap(this, "Slic3r_192px.png", 192));
hsizer -> Add ( m_logo , 1 , wxALIGN_CENTER_VERTICAL );
2018-04-09 17:03:37 +02:00
2019-02-11 14:14:35 +01:00
wxBoxSizer * vsizer = new wxBoxSizer ( wxVERTICAL );
hsizer -> Add ( vsizer , 2 , wxEXPAND | wxLEFT , 20 );
2018-04-09 17:03:37 +02:00
// title
{
2019-04-15 16:14:19 +02:00
wxStaticText * title = new wxStaticText ( this , wxID_ANY , SLIC3R_APP_NAME , wxDefaultPosition , wxDefaultSize );
2019-04-18 15:05:17 +02:00
wxFont title_font = GUI :: wxGetApp (). bold_font (); // wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
// title_font.SetWeight(wxFONTWEIGHT_BOLD);
2018-04-09 17:03:37 +02:00
title_font . SetFamily ( wxFONTFAMILY_ROMAN );
title_font . SetPointSize ( 24 );
title -> SetFont ( title_font );
2018-05-16 13:56:03 +02:00
vsizer -> Add ( title , 0 , wxALIGN_LEFT | wxTOP , 10 );
2018-04-09 17:03:37 +02:00
}
// version
{
2018-05-02 13:20:36 +02:00
auto version_string = _ ( L ( "Version" )) + " " + std :: string ( SLIC3R_VERSION );
2018-04-09 17:03:37 +02:00
wxStaticText * version = new wxStaticText ( this , wxID_ANY , version_string . c_str (), wxDefaultPosition , wxDefaultSize );
2019-04-18 15:05:17 +02:00
wxFont version_font = GetFont (); //wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
2018-04-09 17:03:37 +02:00
#ifdef __WXMSW__
2019-04-18 15:05:17 +02:00
version_font . SetPointSize ( /*9*/ version_font . GetPointSize () - 1 );
2018-04-09 17:03:37 +02:00
#else
version_font . SetPointSize ( 11 );
#endif
version -> SetFont ( version_font );
vsizer -> Add ( version , 0 , wxALIGN_LEFT | wxBOTTOM , 10 );
}
// text
2019-04-18 15:05:17 +02:00
m_html = new wxHtmlWindow ( this , wxID_ANY , wxDefaultPosition , wxDefaultSize , wxHW_SCROLLBAR_AUTO /*NEVER*/ );
2018-04-09 17:03:37 +02:00
{
2019-04-18 15:05:17 +02:00
m_html -> SetMinSize ( wxSize ( - 1 , 16 * wxGetApp (). em_unit ()));
wxFont font = GetFont (); //GUI::wxGetApp().normal_font(); // wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
2018-05-16 13:56:03 +02:00
const auto text_clr = wxSystemSettings :: GetColour ( wxSYS_COLOUR_WINDOWTEXT );
auto text_clr_str = wxString :: Format ( wxT ( "#%02X%02X%02X" ), text_clr . Red (), text_clr . Green (), text_clr . Blue ());
auto bgr_clr_str = wxString :: Format ( wxT ( "#%02X%02X%02X" ), bgr_clr . Red (), bgr_clr . Green (), bgr_clr . Blue ());
const int fs = font . GetPointSize () - 1 ;
int size [] = { fs , fs , fs , fs , fs , fs , fs };
2019-04-18 15:05:17 +02:00
m_html -> SetFonts ( font . GetFaceName (), font . GetFaceName (), size );
m_html -> SetBorders ( 2 );
2018-05-16 13:56:03 +02:00
const auto text = wxString :: Format (
2018-04-09 17:03:37 +02:00
"<html>"
2018-05-16 13:56:03 +02:00
"<body bgcolor= %s link= %s>"
"<font color=%s>"
2019-03-04 15:34:22 +01:00
"Copyright © 2016-2019 Prusa Research. <br />"
"Copyright © 2011-2018 Alessandro Ranellucci. <br />"
2018-04-09 17:03:37 +02:00
"<a href= \" http://slic3r.org/ \" >Slic3r</a> is licensed under the "
"<a href= \" http://www.gnu.org/licenses/agpl-3.0.html \" >GNU Affero General Public License, version 3</a>."
2018-05-16 13:56:03 +02:00
"<br /><br />"
2018-04-09 17:03:37 +02:00
"Contributions by Henrik Brix Andersen, Nicolas Dandrimont, Mark Hindess, Petr Ledvina, Joseph Lenox, Y. Sapir, Mike Sheldrake, Vojtech Bubnik and numerous others. "
"Manual by Gary Hodgson. Inspired by the RepRap community. <br />"
"Slic3r logo designed by Corey Daniels, <a href= \" http://www.famfamfam.com/lab/icons/silk/ \" >Silk Icon Set</a> designed by Mark James. "
"</font>"
"</body>"
2018-05-16 13:56:03 +02:00
"</html>" , bgr_clr_str , text_clr_str , text_clr_str );
2019-04-18 15:05:17 +02:00
m_html -> SetPage ( text );
vsizer -> Add ( m_html , 1 , wxEXPAND | wxBOTTOM , 10 );
m_html -> Bind ( wxEVT_HTML_LINK_CLICKED , & AboutDialog :: onLinkClicked , this );
2018-04-09 17:03:37 +02:00
}
wxStdDialogButtonSizer * buttons = this -> CreateStdDialogButtonSizer ( wxCLOSE );
this -> SetEscapeId ( wxID_CLOSE );
this -> Bind ( wxEVT_BUTTON , & AboutDialog :: onCloseDialog , this , wxID_CLOSE );
vsizer -> Add ( buttons , 0 , wxEXPAND | wxRIGHT | wxBOTTOM , 3 );
2019-01-15 10:24:58 +01:00
// this->Bind(wxEVT_LEFT_DOWN, &AboutDialog::onCloseDialog, this);
2019-01-21 15:40:41 +01:00
// logo->Bind(wxEVT_LEFT_DOWN, &AboutDialog::onCloseDialog, this);
2018-05-16 13:56:03 +02:00
SetSizer ( main_sizer );
main_sizer -> SetSizeHints ( this );
2018-04-09 17:03:37 +02:00
}
2019-04-18 15:05:17 +02:00
void AboutDialog :: on_dpi_changed ( const wxRect & suggested_rect )
{
m_logo_bitmap . rescale ();
m_logo -> SetBitmap ( m_logo_bitmap . bmp ());
const wxFont & font = GetFont ();
const int fs = font . GetPointSize () - 1 ;
int font_size [] = { fs , fs , fs , fs , fs , fs , fs };
m_html -> SetFonts ( font . GetFaceName (), font . GetFaceName (), font_size );
const int & em = em_unit ();
m_html -> SetMinSize ( wxSize ( - 1 , 16 * em ));
m_html -> Refresh ();
const wxSize & size = wxSize ( 65 * em , 30 * em );
SetMinSize ( size );
SetSize ( size );
Refresh ();
}
2018-04-09 17:03:37 +02:00
void AboutDialog :: onLinkClicked ( wxHtmlLinkEvent & event )
{
wxLaunchDefaultBrowser ( event . GetLinkInfo (). GetHref ());
event . Skip ( false );
}
void AboutDialog :: onCloseDialog ( wxEvent & )
{
this -> EndModal ( wxID_CLOSE );
this -> Close ();
}
} // namespace GUI
} // namespace Slic3r