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 );
2019-05-13 12:13:28 +02:00
this -> logo = wxBitmap ( from_u8 ( Slic3r :: var ( "PrusaSlicer_192px.png" )), wxBITMAP_TYPE_PNG );
2018-04-09 17:03:37 +02:00
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 ();
}
2019-05-16 16:55:10 +02:00
// -----------------------------------------
// CopyrightsDialog
// -----------------------------------------
CopyrightsDialog :: CopyrightsDialog ()
2020-03-04 09:24:13 +01:00
: DPIDialog ( NULL , wxID_ANY , from_u8 (( boost :: format ( "%1% - %2%" )
2020-03-02 09:41:54 +01:00
% SLIC3R_APP_NAME
% _utf8 ( L ( "Portions copyright" ))). str ()),
2019-05-16 16:55:10 +02:00
wxDefaultPosition , wxDefaultSize , wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER )
{
this -> SetFont ( wxGetApp (). normal_font ());
this -> SetBackgroundColour ( wxSystemSettings :: GetColour ( wxSYS_COLOUR_WINDOW ));
auto sizer = new wxBoxSizer ( wxVERTICAL );
fill_entries ();
m_html = new wxHtmlWindow ( this , wxID_ANY , wxDefaultPosition ,
wxSize ( 40 * em_unit (), 20 * em_unit ()), wxHW_SCROLLBAR_AUTO );
wxFont font = GetFont ();
const int fs = font . GetPointSize ();
const int fs2 = static_cast < int > ( 1.2f * fs );
int size [] = { fs , fs , fs , fs , fs2 , fs2 , fs2 };
m_html -> SetFonts ( font . GetFaceName (), font . GetFaceName (), size );
m_html -> SetBorders ( 2 );
m_html -> SetPage ( get_html_text ());
sizer -> Add ( m_html , 1 , wxEXPAND | wxALL , 15 );
m_html -> Bind ( wxEVT_HTML_LINK_CLICKED , & CopyrightsDialog :: onLinkClicked , this );
wxStdDialogButtonSizer * buttons = this -> CreateStdDialogButtonSizer ( wxCLOSE );
this -> SetEscapeId ( wxID_CLOSE );
this -> Bind ( wxEVT_BUTTON , & CopyrightsDialog :: onCloseDialog , this , wxID_CLOSE );
sizer -> Add ( buttons , 0 , wxEXPAND | wxRIGHT | wxBOTTOM , 3 );
SetSizer ( sizer );
sizer -> SetSizeHints ( this );
}
void CopyrightsDialog :: fill_entries ()
{
m_entries = {
{ "wxWidgets" , "2019 wxWidgets" , "https://www.wxwidgets.org/" },
2019-08-19 12:28:25 +02:00
{ "OpenGL" , "1997-2019 The Khronos™ Group Inc" , "https://www.opengl.org/" },
2019-05-16 16:55:10 +02:00
{ "GNU gettext" , "1998, 2019 Free Software Foundation, Inc." , "https://www.gnu.org/software/gettext/" },
2019-08-19 12:28:25 +02:00
{ "PoEdit" , "2019 Václav Slavík" , "https://poedit.net/" },
2019-05-16 16:55:10 +02:00
{ "ImGUI" , "2014-2019 Omar Cornut" , "https://github.com/ocornut/imgui" },
{ "Eigen" , "" , "http://eigen.tuxfamily.org" },
{ "ADMesh" , "1995, 1996 Anthony D. Martin; "
"2015, ADMesh contributors" , "https://admesh.readthedocs.io/en/latest/" },
{ "Anti-Grain Geometry"
, "2002-2005 Maxim Shemanarev (McSeem)" , "http://antigrain.com" },
{ "Boost" , "1998-2005 Beman Dawes, David Abrahams; "
"2004 - 2007 Rene Rivera" , "https://www.boost.org/" },
{ "Clipper" , "2010-2015 Angus Johnson " , "http://www.angusj.com " },
{ "GLEW (The OpenGL Extension Wrangler Library)" ,
"2002 - 2007, Milan Ikits; "
"2002 - 2007, Marcelo E.Magallon; "
"2002, Lev Povalahev" , "http://glew.sourceforge.net/" },
{ "Libigl" , "2013 Alec Jacobson and others" , "https://libigl.github.io/" },
{ "Poly2Tri" , "2009-2018, Poly2Tri Contributors" , "https://github.com/jhasse/poly2tri" },
{ "PolyPartition" , "2011 Ivan Fratric" , "https://github.com/ivanfratric/polypartition" },
{ "Qhull" , "1993-2015 C.B.Barber Arlington and "
"University of Minnesota" , "http://qhull.org/" },
{ "SemVer" , "2015-2017 Tomas Aparicio" , "https://semver.org/" },
{ "Nanosvg" , "2013-14 Mikko Mononen" , "https://github.com/memononen/nanosvg" },
{ "Miniz" , "2013-2014 RAD Game Tools and Valve Software; "
"2010-2014 Rich Geldreich and Tenacious Software LLC"
, "https://github.com/richgel999/miniz" },
{ "Expat" , "1998-2000 Thai Open Source Software Center Ltd and Clark Cooper"
"2001-2016 Expat maintainers" , "http://www.libexpat.org/" },
{ "AVRDUDE" , "2018 Free Software Foundation, Inc." , "http://savannah.nongnu.org/projects/avrdude" },
{ "Shinyprofiler" , "2007-2010 Aidin Abedi" , "http://code.google.com/p/shinyprofiler/" },
2019-07-31 17:38:06 +02:00
{ "Real-Time DXT1/DXT5 C compression library"
, "Based on original by fabian \" ryg \" giesen v1.04. "
"Custom version, modified by Yann Collet" , "https://github.com/Cyan4973/RygsDXTc" },
2019-05-16 16:55:10 +02:00
{ "Icons for STL and GCODE files."
2019-08-19 14:34:12 +02:00
, "Akira Yasuda" , "http://3dp0.com/icons-for-stl-and-gcode/" },
{ "AppImage packaging for Linux using AppImageKit"
, "2004-2019 Simon Peter and contributors" , "https://appimage.org/" }
2019-05-16 16:55:10 +02:00
};
}
wxString CopyrightsDialog :: get_html_text ()
{
wxColour bgr_clr = wxSystemSettings :: GetColour ( wxSYS_COLOUR_WINDOW );
const auto text_clr = wxSystemSettings :: GetColour ( wxSYS_COLOUR_WINDOWTEXT );
const auto text_clr_str = wxString :: Format ( wxT ( "#%02X%02X%02X" ), text_clr . Red (), text_clr . Green (), text_clr . Blue ());
const auto bgr_clr_str = wxString :: Format ( wxT ( "#%02X%02X%02X" ), bgr_clr . Red (), bgr_clr . Green (), bgr_clr . Blue ());
const wxString copyright_str = _ ( L ( "Copyright" )) + "© " ;
// TRN "Slic3r _is licensed under the_ License"
const wxString header_str = _ ( L ( "License agreements of all following programs (libraries) are part of application license agreement" ));
wxString text = wxString :: Format (
"<html>"
"<body bgcolor= %s link= %s>"
"<font color=%s>"
"<font size= \" 5 \" >%s.</font>"
"<br /><br />"
"<font size= \" 3 \" >"
, bgr_clr_str , text_clr_str
, text_clr_str
, header_str );
for ( auto & entry : m_entries ) {
text += wxString :: Format (
"<a href= \" %s \" >%s</a><br/>"
, entry . link , entry . lib_name );
if ( ! entry . copyright . empty ())
text += wxString :: Format (
"%s %s"
"<br/><br/>"
, copyright_str , entry . copyright );
}
text += wxString (
"</font>"
"</font>"
"</body>"
"</html>" );
return text ;
}
void CopyrightsDialog :: on_dpi_changed ( const wxRect & suggested_rect )
{
const wxFont & font = GetFont ();
const int fs = font . GetPointSize ();
const int fs2 = static_cast < int > ( 1.2f * fs );
int font_size [] = { fs , fs , fs , fs , fs2 , fs2 , fs2 };
m_html -> SetFonts ( font . GetFaceName (), font . GetFaceName (), font_size );
const int & em = em_unit ();
msw_buttons_rescale ( this , em , { wxID_CLOSE });
const wxSize & size = wxSize ( 40 * em , 20 * em );
m_html -> SetMinSize ( size );
m_html -> Refresh ();
SetMinSize ( size );
Fit ();
Refresh ();
}
void CopyrightsDialog :: onLinkClicked ( wxHtmlLinkEvent & event )
{
wxLaunchDefaultBrowser ( event . GetLinkInfo (). GetHref ());
event . Skip ( false );
}
void CopyrightsDialog :: onCloseDialog ( wxEvent & )
{
this -> EndModal ( wxID_CLOSE );
}
2018-04-09 17:03:37 +02:00
AboutDialog :: AboutDialog ()
2020-03-04 09:24:13 +01:00
: DPIDialog ( NULL , wxID_ANY , from_u8 (( boost :: format ( _utf8 ( L ( "About %s" ))) % SLIC3R_APP_NAME ). str ()), 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-05-13 12:13:28 +02:00
m_logo_bitmap = ScalableBitmap ( this , "PrusaSlicer_192px.png" , 192 );
2019-04-18 15:05:17 +02:00
m_logo = new wxStaticBitmap ( this , wxID_ANY , m_logo_bitmap . bmp ());
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-25 01:45:00 +02:00
wxFont title_font = GUI :: wxGetApp (). bold_font ();
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-25 01:45:00 +02:00
wxFont version_font = GetFont ();
2018-04-09 17:03:37 +02:00
#ifdef __WXMSW__
2019-04-25 01:45:00 +02:00
version_font . SetPointSize ( 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 ()));
2019-04-25 01:45:00 +02:00
wxFont font = GetFont ();
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 );
2020-03-02 09:41:54 +01:00
const std :: string copyright_str = _utf8 ( L ( "Copyright" ));
2019-05-09 16:38:44 +02:00
// TRN "Slic3r _is licensed under the_ License"
2020-03-02 09:41:54 +01:00
const std :: string is_lecensed_str = _utf8 ( L ( "is licensed under the" ));
const std :: string license_str = _utf8 ( L ( "GNU Affero General Public License, version 3" ));
const std :: string based_on_str = _utf8 ( L ( "PrusaSlicer is based on Slic3r by Alessandro Ranellucci and the RepRap community." ));
const std :: string contributors_str = _utf8 ( L ( "Contributions by Henrik Brix Andersen, Nicolas Dandrimont, Mark Hindess, Petr Ledvina, Joseph Lenox, Y. Sapir, Mike Sheldrake, Vojtech Bubnik and numerous others." ));
2020-03-04 09:24:13 +01:00
const auto text = from_u8 (
2020-03-02 09:41:54 +01:00
( boost :: format (
2018-04-09 17:03:37 +02:00
"<html>"
2020-03-02 09:41:54 +01:00
"<body bgcolor= %1% link= %2%>"
"<font color=%3%>"
"%4% © 2016-2019 Prusa Research. <br />"
"%5% © 2011-2018 Alessandro Ranellucci. <br />"
"<a href= \" http://slic3r.org/ \" >Slic3r</a> %6% "
"<a href= \" http://www.gnu.org/licenses/agpl-3.0.html \" >%7%</a>."
2018-05-16 13:56:03 +02:00
"<br /><br />"
2020-03-02 09:41:54 +01:00
"%8%"
2019-05-14 18:10:20 +02:00
"<br /><br />"
2020-03-02 09:41:54 +01:00
"%9%"
2018-04-09 17:03:37 +02:00
"</font>"
"</body>"
2020-03-02 09:41:54 +01:00
"</html>" ) % bgr_clr_str % text_clr_str % text_clr_str
% copyright_str % copyright_str
% is_lecensed_str
% license_str
% based_on_str
% contributors_str ). 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
}
2019-05-16 16:55:10 +02:00
2018-04-09 17:03:37 +02:00
wxStdDialogButtonSizer * buttons = this -> CreateStdDialogButtonSizer ( wxCLOSE );
2019-05-16 16:55:10 +02:00
m_copy_rights_btn_id = NewControlId ();
auto copy_rights_btn = new wxButton ( this , m_copy_rights_btn_id , _ ( L ( "Portions copyright" )) + dots );
buttons -> Insert ( 0 , copy_rights_btn , 0 , wxLEFT , 5 );
copy_rights_btn -> Bind ( wxEVT_BUTTON , & AboutDialog :: onCopyrightBtn , this );
2018-04-09 17:03:37 +02:00
this -> SetEscapeId ( wxID_CLOSE );
this -> Bind ( wxEVT_BUTTON , & AboutDialog :: onCloseDialog , this , wxID_CLOSE );
vsizer -> Add ( buttons , 0 , wxEXPAND | wxRIGHT | wxBOTTOM , 3 );
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 )
{
2019-04-25 01:45:00 +02:00
m_logo_bitmap . msw_rescale ();
2019-04-18 15:05:17 +02:00
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 ();
2019-05-16 16:55:10 +02:00
msw_buttons_rescale ( this , em , { wxID_CLOSE , m_copy_rights_btn_id });
2019-04-25 15:06:44 +02:00
2019-04-18 15:05:17 +02:00
m_html -> SetMinSize ( wxSize ( - 1 , 16 * em ));
m_html -> Refresh ();
const wxSize & size = wxSize ( 65 * em , 30 * em );
SetMinSize ( size );
2019-04-25 15:06:44 +02:00
Fit ();
2019-04-18 15:05:17 +02:00
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 );
}
2019-05-16 16:55:10 +02:00
void AboutDialog :: onCopyrightBtn ( wxEvent & )
{
CopyrightsDialog dlg ;
dlg . ShowModal ();
}
2018-04-09 17:03:37 +02:00
} // namespace GUI
} // namespace Slic3r