diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 80103c05aa..33b139d86b 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -5,7 +5,14 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR} ../polygon ) +set( COMMON_ABOUT_DLG_SRCS + dialog_about/AboutDialog_main.cpp + dialog_about/dialog_about.cpp + dialog_about/dialog_about_base.cpp +) + set(COMMON_SRCS + ${COMMON_ABOUT_DLG_SRCS} about_kicad.cpp base_screen.cpp base_struct.cpp diff --git a/common/basicframe.cpp b/common/basicframe.cpp index a40b12e7d4..e09d986e93 100644 --- a/common/basicframe.cpp +++ b/common/basicframe.cpp @@ -22,6 +22,8 @@ #include "macros.h" #include "bitmaps.h" +// Uncomment this line to use the new KiCad About dialog +#define USE_NEW_ABOUT_DIALOG /* * Class constructor for WinEDA_BasicFrame general options @@ -286,9 +288,14 @@ void WinEDA_BasicFrame::GetKicadHelp( wxCommandEvent& event ) */ void WinEDA_BasicFrame::GetKicadAbout( wxCommandEvent& WXUNUSED(event) ) { +#ifdef USE_NEW_ABOUT_DIALOG + bool ShowAboutDialog(wxWindow * parent); + ShowAboutDialog(this); +#else wxAboutDialogInfo info; InitKiCadAbout(info); wxAboutBox(info); +#endif } diff --git a/common/dialog_about/AboutDialog_main.cpp b/common/dialog_about/AboutDialog_main.cpp new file mode 100644 index 0000000000..2f4868bb09 --- /dev/null +++ b/common/dialog_about/AboutDialog_main.cpp @@ -0,0 +1,311 @@ +/*************************************************************** + * Name: AboutDialog_main.cpp + * Purpose: Code for Application Class + * Author: Rafael Sokolowski (rafael.sokolowski@web.de) + * Created: 2010-08-06 + * Copyright: Rafael Sokolowski () + * License: + **************************************************************/# include "dialog_about.h" +#include "aboutinfo.h" +#include + + +/* Used icons: + * lang_xx_xpm[]; // Icons of various national flags + * show_3d_xpm[]; // 3D icon + * edit_module_xpm[]; + * kicad_icon_xpm[]; // Icon of the application + */ +#include "bitmaps.h" + + +#include "build_version.h" + + +#include +WX_DEFINE_OBJARRAY( Contributors ); + +// Helper functions: +static wxString HtmlHyperlink( const wxString& url, const wxString& description = wxEmptyString ); +static wxString HtmlNewline( const unsigned int amount = 1 ); + + +/** + * Initializes the AboutAppInfo object with applicaion specific information. + * + * @info is the object which holds all information about the application + */ +static void InitKiCadAboutNew( AboutAppInfo& info ) +{ + /* set application specific icon */ + + // COULD BE: use another function call to get appropriate icon; its hardcoded because there is no top level window existing here + // do something like: + // wxTheApp->GetTopWindow()->GetIcon() ??? or... + // const wxTopLevelWindow * const tlw = wxDynamicCast(::wxGetApp().GetTopWindow(), wxTopLevelWindow); ??? + // if( tlw ) info.SetIcon( tlw->GetIcon() ); ??? + info.SetIcon( kicad_icon_xpm ); + + /* Set title */ + + // COULD BE: info.SetAppName( wxT( ".: " ) + wxGetApp().GetTitle() + wxT( " :." ) ); + info.SetAppName( wxT( ".: KiCad :." ) ); + + /* copyright information */ + info.SetCopyright( wxT( "(C) 1992-2010 KiCad Developers Team" ) ); + + /* KiCad build version */ + wxString version; + version << wxT( "Build: " ) << GetBuildVersion(); + info.SetBuildVersion( version ); + + /* wxWidgets version */ + wxString libVersion; + libVersion + << wxT( "wxWidgets " ) + << wxMAJOR_VERSION << wxT( "." ) + << wxMINOR_VERSION << wxT( "." ) + << wxRELEASE_NUMBER + + /* Unicode or Ansi version */ +#if wxUSE_UNICODE + << wxT( " Unicode " ); +#else + << wxT( " Ansi " ); +#endif + + + /* Operating System Information */ + +#if defined __WINDOWS__ + libVersion << wxT( "on Windows" ); + + /* Check for wxMAC */ +# elif defined __WXMAC__ + libVersion << wxT( "on Macintosh" ); + + /* Linux 64 bits */ +# elif defined _LP64 && __LINUX__ + libVersion << wxT( "on 64 Bits GNU/Linux" ); + + /* Linux 32 bits */ +# elif defined __LINUX__ + libVersion << wxT( "on 32 Bits GNU/Linux" ); + + /* OpenBSD */ +# elif defined __OpenBSD__ + libVersion << wxT( "on OpenBSD" ); + + /* FreeBSD */ +# elif defined __FreeBSD__ + libVersion << wxT( "on FreeBSD" ); + +#endif + + info.SetLibVersion( libVersion ); + + + /* info/description part HTML formatted */ + + wxString description; + + /* short description */ + description << wxT( "

" ); + description << wxT( "" ) << _( "Description" ) << wxT( "" ); // bold & underlined font for caption + + description << wxT( + "

The KiCad EDA Suite is a set of open source applications for the creation of electronic schematics and to design printed circuit boards.

" ); + + description << wxT( "

" ); + + /* websites */ + description << wxT( "

" ); + description << wxT( "" ) << _( "KiCad on the web" ) << wxT( "" ); // bold & underlined font for caption + + // bulletet list with some http links + description << wxT( "

" ); + + description << wxT( "

" ); + + description << wxT( "

" ); + description << wxT( "" ) << _( "Contribute to KiCad" ) << wxT( "" ); // bold & underlined font caption + + // bulletet list with some http links + description << wxT( "

" ); + + description << wxT( "

" ); + + info.SetDescription( description ); + + + /* License information also HTML formatted */ + wxString license; + license + << wxT( "
" ) + << HtmlNewline( 4 ) + << _( "The complete KiCad EDA Suite is released under the" ) << HtmlNewline( 2 ) + << HtmlHyperlink( wxT( "http://www.gnu.org/licenses" ), + _( "GNU General Public License version 2" ) ) + << wxT( "
" ); + + info.SetLicense( license ); + + + /* A contributor consists of the following information: + * Mandatory: + * - Name + * - EMail address + * Optional: + * - Category + * - Category specific icon + * + * All contributors of the same category will be enumerated under this category + * which should be represented by the same icon. + */ + + /* The developers */ + info.AddDeveloper( new Contributor( wxT( "Jean-Pierre Charras" ), + wxT( "jean-pierre.charras@gipsa-lab.inpg.fr" ) ) ); + info.AddDeveloper( new Contributor( wxT( "Dick Hollenbeck" ), wxT( "dick@softplc.com" ) ) ); + info.AddDeveloper( new Contributor( wxT( "Hauptmech" ), wxT( "hauptmech@gmail.com" ) ) ); + info.AddDeveloper( new Contributor( wxT( "Jerry Jacobs" ), + wxT( "xor.gate.engineering@gmail.com" ) ) ); + info.AddDeveloper( new Contributor( wxT( "Jonas Diemer" ), wxT( "diemer@gmx.de" ) ) ); + info.AddDeveloper( new Contributor( wxT( "KBool Library" ), + wxT( "http://boolean.klaasholwerda.nl/bool.html" ) ) ); + info.AddDeveloper( new Contributor( wxT( "Lorenzo Marcantonio" ), wxT( "lomarcan@tin.it" ) ) ); + info.AddDeveloper( new Contributor( wxT( "Marco Serantoni" ), wxT( "marco.serantoni@gmail.com" ) ) ); + info.AddDeveloper( new Contributor( wxT( "Rok Markovic" ), wxT( "rok@kanardia.eu" ) ) ); + info.AddDeveloper( new Contributor( wxT( "Tim Hanson" ), wxT( "sideskate@gmail.com" ) ) ); + info.AddDeveloper( new Contributor( wxT( "Vesa Solonen" ), wxT( "vesa.solonen@hut.fi" ) ) ); + info.AddDeveloper( new Contributor( wxT( "Wayne Stambaugh" ), wxT( "stambaughw@verizon.net" ) ) ); + + /* The document writers */ + info.AddDocWriter( new Contributor( wxT( "Jean-Pierre Charras" ), + wxT( "jean-pierre.charras@gipsa-lab.inpg.fr" ) ) ); + info.AddDocWriter( new Contributor( wxT( "Igor Plyatov" ), wxT( "plyatov@gmail.com" ) ) ); + + /* The translators + * As category the language to which the translation was done is used + * and as icon the national flag of the corresponding country. + */ + info.AddTranslator( new Contributor( wxT( "Martin Kratoška" ), wxT( "martin@ok1rr.com" ), + wxT( "Czech (CZ)" ), new wxBitmap( lang_cs_xpm ) ) ); + info.AddTranslator( new Contributor( wxT( "Jerry Jacobs" ), + wxT( "xor.gate.engineering@gmail.com" ), wxT( "Dutch (NL)" ), + new wxBitmap( lang_nl_xpm ) ) ); + info.AddTranslator( new Contributor( wxT( "Vesa Solonen" ), wxT( "vesa.solonen@hut.fi" ), + wxT( "Finnish (FI)" ), new wxBitmap( lang_fi_xpm ) ) ); + info.AddTranslator( new Contributor( wxT( "Jean-Pierre Charras" ), + wxT( "jean-pierre.charras@gipsa-lab.inpg.fr" ), + wxT( "French (FR)" ), new wxBitmap( lang_fr_xpm ) ) ); + info.AddTranslator( new Contributor( wxT( "Mateusz Skowroński" ), wxT( "skowri@gmail.com" ), + wxT( "Polish (PL)" ), new wxBitmap( lang_pl_xpm ) ) ); + info.AddTranslator( new Contributor( wxT( "Renie Marquet" ), wxT( "reniemarquet@uol.com.br" ), + wxT( "Portuguese (PT)" ), new wxBitmap( lang_pt_xpm ) ) ); + info.AddTranslator( new Contributor( wxT( "Igor Plyatov" ), wxT( "plyatov@gmail.com" ), + wxT( "Russian (RU)" ), new wxBitmap( lang_ru_xpm ) ) ); + info.AddTranslator( new Contributor( wxT( "Pedro Martin del Valle" ), wxT( "pkicad@yahoo.es" ), + wxT( "Spanish (ES)" ), new wxBitmap( lang_es_xpm ) ) ); + info.AddTranslator( new Contributor( wxT( "Iñigo Zuluaga" ), wxT( "inigo_zuluaga@yahoo.es" ), + wxT( "Spanish (ES)" ), new wxBitmap( lang_es_xpm ) ) ); + info.AddTranslator( new Contributor( wxT( "Rafael Sokolowski" ), + wxT( "rafael.sokolowski@web.de" ), wxT( "German (DE)" ), + new wxBitmap( lang_de_xpm ) ) ); + + /* TODO: are these all russian translators, placed them here now, or else align them below other language maintainer with mail adress */ + info.AddTranslator( new Contributor( wxT( "Remy Halvick" ), wxEmptyString, wxT( "Others" ) ) ); + info.AddTranslator( new Contributor( wxT( "David Briscoe" ), wxEmptyString, wxT( "Others" ) ) ); + info.AddTranslator( new Contributor( wxT( "Dominique Laigle" ), wxEmptyString, wxT( "Others" ) ) ); + info.AddTranslator( new Contributor( wxT( "Paul Burke" ), wxEmptyString, wxT( "Others" ) ) ); + + /* Programm credits for icons */ + info.AddArtist( new Contributor( wxT( "Iñigo Zuluagaz" ), wxT( "inigo_zuluaga@yahoo.es" ), + wxT( "Icons by" ), new wxBitmap( edit_module_xpm ) ) ); + info.AddArtist( new Contributor( wxT( "Renie Marquet" ), wxT( "reniemarquet@uol.com.br" ), + wxT( "3D modules by" ), new wxBitmap( show_3d_xpm ) ) ); + info.AddArtist( new Contributor( wxT( "Christophe Boschat" ), wxT( "nox454@hotmail.fr" ), + wxT( "3D modules by" ), new wxBitmap( show_3d_xpm ) ) ); +} + + +bool ShowAboutDialog( wxWindow* parent ) +{ + AboutAppInfo info; + + InitKiCadAboutNew( info ); + + dialog_about* dlg = new dialog_about( parent, info ); + dlg->SetIcon( info.GetIcon() ); + dlg->Show(); + + return true; +} + + +/////////////////////////////////////////////////////////////////////////////// +/// Helper functions +/////////////////////////////////////////////////////////////////////////////// + +/** + * Wraps the given url with a HTML anchor tag containing a hyperlink text reference + * to form a HTML hyperlink. + * + * @url the url that will be embedded in an anchor tag containing a hyperlink reference + * @description the optional describing text that will be represented as a hyperlink. + * If not specified the url will be used as hyperlink. + * @return a HTML conform hyperlink like description + */ +static wxString HtmlHyperlink( const wxString& url, const wxString& description ) +{ + wxString hyperlink = wxEmptyString; + + if( description.IsEmpty() ) + hyperlink << wxT( "" ) << url << wxT( "" ); + else + hyperlink << wxT( "" ) << description << wxT( "" ); + + return hyperlink; +} + + +/** + * Creates a HTML newline character sequence. + * + * @amount the amount of HTML newline tags to concatenate, default is to return just one
tag + * @return the concatenated amount of HTML newline tag(s)
+ */ +static wxString HtmlNewline( const unsigned int amount ) +{ + wxString newlineTags = wxEmptyString; + + for( size_t i = 0; i" ); + + return newlineTags; +} diff --git a/common/dialog_about/aboutinfo.h b/common/dialog_about/aboutinfo.h new file mode 100644 index 0000000000..51280f2921 --- /dev/null +++ b/common/dialog_about/aboutinfo.h @@ -0,0 +1,127 @@ +#ifndef ABOUTAPPINFO_H +#define ABOUTAPPINFO_H + +#include +#include +#include + +class Contributor; + +WX_DECLARE_OBJARRAY( Contributor, Contributors ); + + +/** + * An object of this class is meant to be used to store application specific information + * like who has contributed in which area of the application, the license, copyright + * and other descriptive information. + */ +class AboutAppInfo +{ +public: + AboutAppInfo() {}; + virtual ~AboutAppInfo() {}; + + void AddDeveloper( const Contributor* developer ) { if( developer != NULL ) + developers.Add( developer );} + void AddDocWriter( const Contributor* docwriter ) { if( docwriter != NULL ) + docwriters.Add( docwriter );} + void AddArtist( const Contributor* artist ) { if( artist != NULL ) + artists.Add( artist );} + void AddTranslator( const Contributor* translator ) { if( translator != NULL ) + translators.Add( translator );} + + Contributors GetDevelopers() { return developers; } + Contributors GetDocWriters() { return docwriters; } + Contributors GetArtists() { return artists; } + Contributors GetTranslators() { return translators; } + + void SetDescription( const wxString& text ) { description = text; } + wxString& GetDescription() { return description; } + + void SetLicense( const wxString& text ) { license = text; } + wxString& GetLicense() { return license; } + + void SetCopyright( const wxString& text ) { copyright = text; } + wxString GetCopyright() + { + wxString copyrightText = copyright; + +#if wxUSE_UNICODE + const wxString utf8_copyrightSign = wxString::FromUTF8( "\xc2\xa9" ); + copyrightText.Replace( _T( "(c)" ), utf8_copyrightSign ); + copyrightText.Replace( _T( "(C)" ), utf8_copyrightSign ); +#endif // wxUSE_UNICODE + + return copyrightText; + } + + + void SetAppName( const wxString& name ) { appName = name; } + wxString& GetAppName() { return appName; } + + void SetBuildVersion( const wxString& version ) { buildVersion = version; } + wxString& GetBuildVersion() { return buildVersion; } + + void SetLibVersion( const wxString& version ) { libVersion = version; } + wxString& GetLibVersion() { return libVersion; } + + void SetIcon( const wxIcon& icon ) { appIcon = icon; } + wxIcon& GetIcon() { return appIcon; } + +protected: +private: + Contributors developers; + Contributors docwriters; + Contributors artists; + Contributors translators; + + wxString description; + wxString license; + + wxString copyright; // Todo: copyright sign in unicode + wxString appName; + wxString buildVersion; + wxString libVersion; + + wxIcon appIcon; +}; + +/** + * A contributor, a person which was involved in the development of the application + * or which has contributed in any kind somehow to the project. + * + * A contributor consists of the following mandatory information: + * - Name + * - EMail address + * + * Each contributor can have optional information assigned like: + * - A category + * - A category specific icon + */ +class Contributor +{ +public: + Contributor( const wxString& name, + const wxString& email, + const wxString& category = wxEmptyString, + wxBitmap* icon = NULL ) : + m_checked( false ) + { m_name = name; m_email = email; m_category = category; m_icon = icon; } + virtual ~Contributor() {} + + wxString& GetName() { return m_name; } + wxString& GetEMail() { return m_email; } + wxString& GetCategory() { return m_category; } + wxBitmap* GetIcon() { return m_icon; } + void SetChecked( bool status ) { m_checked = status; } + bool IsChecked() { return m_checked; } +protected: +private: + wxString m_name; + wxString m_email; + wxString m_category; + wxBitmap* m_icon; + bool m_checked; +}; + +#endif // ABOUTAPPINFO_H diff --git a/common/dialog_about/dialog_about.cpp b/common/dialog_about/dialog_about.cpp new file mode 100644 index 0000000000..5b41ebeaf9 --- /dev/null +++ b/common/dialog_about/dialog_about.cpp @@ -0,0 +1,338 @@ +/*************************************************************** + * Name: dialog_about.cpp + * Purpose: Code for Application Frame + * Author: Rafael Sokolowski (rafael.sokolowski@web.de) + * Created: 2010-08-06 + * Copyright: Rafael Sokolowski () + * License: + **************************************************************/ +#include "dialog_about.h" + +/////////////////////////////////////////////////////////////////////////////// +/// Class dialog_about methods +/////////////////////////////////////////////////////////////////////////////// + +dialog_about::dialog_about(wxWindow *parent, AboutAppInfo& appInfo) + : dialog_about_base(parent), info(appInfo) +{ + picInformation = wxBitmap(info_xpm); + picDevelopers = wxBitmap(preference_xpm); + picDocWriters = wxBitmap(editor_xpm); + picArtists = wxBitmap(palette_xpm); + picTranslators = wxBitmap(language_xpm); + picLicense = wxBitmap(tools_xpm); + + m_bitmapApp->SetBitmap( info.GetIcon() ); + + m_staticTextAppTitle->SetLabel( info.GetAppName() ); + m_staticTextCopyright->SetLabel( info.GetCopyright() ); + m_staticTextBuildVersion->SetLabel( info.GetBuildVersion() ); + m_staticTextLibVersion->SetLabel( info.GetLibVersion() ); + + /* Affects m_titlepanel the parent of some wxStaticText. + * Changing the text afterwards makes it under Windows necessary to call 'Layout()' + * so that the new text gets properly layout. + */ +/* m_staticTextCopyright->GetParent()->Layout(); + m_staticTextBuildVersion->GetParent()->Layout(); + m_staticTextLibVersion->GetParent()->Layout(); +*/ + DeleteNotebooks(); + CreateNotebooks(); + GetSizer()->SetSizeHints(this); + m_auiNotebook->Update(); + + Centre(); +} + +dialog_about::~dialog_about() +{ +} + +wxFlexGridSizer* dialog_about::CreateFlexGridSizer() +{ + // three colums with vertical and horizontal extra space of two pixels + wxFlexGridSizer* fgSizer1 = new wxFlexGridSizer( 3, 2, 2 ); + fgSizer1->SetFlexibleDirection( wxHORIZONTAL ); + fgSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + + return fgSizer1; +} + +void dialog_about::DeleteNotebooks() +{ + for( size_t i=0; iGetPageCount(); ++i ) + m_auiNotebook->DeletePage(i); +} + +void dialog_about::CreateNotebooks() +{ + CreateNotebookHtmlPage( m_auiNotebook, _("Information"), picInformation, info.GetDescription() ); + + CreateNotebookPage( m_auiNotebook, _("Developers") , picDevelopers, info.GetDevelopers() ); + CreateNotebookPage( m_auiNotebook, _("Doc Writers"), picDocWriters, info.GetDocWriters() ); + + CreateNotebookPageByCategory( m_auiNotebook, _("Artists") , picArtists, info.GetArtists() ); + CreateNotebookPageByCategory( m_auiNotebook, _("Translators"), picTranslators, info.GetTranslators() ); + + CreateNotebookHtmlPage( m_auiNotebook, _("License"), picLicense, info.GetLicense() ); +} + +void dialog_about::CreateNotebookPage(wxAuiNotebook* parent, const wxString& caption, const wxBitmap& icon, const Contributors& contributors) +{ + wxBoxSizer* bSizer = new wxBoxSizer( wxHORIZONTAL ); + + wxScrolledWindow* m_scrolledWindow1 = new wxScrolledWindow( parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL ); + m_scrolledWindow1->SetScrollRate( 5, 5 ); + + /* Panel for additional space at the left, + * but can also be used to show an additional bitmap. + */ + wxPanel* panel1 = new wxPanel(m_scrolledWindow1); + + wxFlexGridSizer* fgSizer1 = CreateFlexGridSizer(); + + for ( size_t i=0; iGetIcon() ); + fgSizer1->Add( m_bitmap1, 0, wxALIGN_CENTER|wxLEFT|wxRIGHT, 5 ); + + // Name of contributor at second column + if ( contributor->GetName() != wxEmptyString ) + { + wxStaticText* m_staticText1 = new wxStaticText( m_scrolledWindow1, wxID_ANY, contributor->GetName(), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText1->Wrap( -1 ); + fgSizer1->Add( m_staticText1, 0, wxALIGN_LEFT|wxBOTTOM, 2 ); + } + else { + fgSizer1->AddSpacer(5); + } + + // Email address of contributor at third column + if ( contributor->GetEMail() != wxEmptyString ) + { + wxHyperlinkCtrl* hyperlink = CreateHyperlink( m_scrolledWindow1, contributor->GetEMail() ); + fgSizer1->Add( hyperlink, 0, wxALIGN_LEFT|wxBOTTOM, 2 ); + } + else { + fgSizer1->AddSpacer(5); + } + } + + bSizer->Add( panel1, 1, wxEXPAND|wxALL, 10 ); + bSizer->Add( fgSizer1, 7, wxEXPAND|wxALL, 10 ); // adjust width of panel with first int value + m_scrolledWindow1->SetSizer( bSizer ); + m_scrolledWindow1->Layout(); + bSizer->Fit( m_scrolledWindow1 ); + + parent->AddPage( m_scrolledWindow1, caption, false, icon ); +} + +void dialog_about::CreateNotebookPageByCategory(wxAuiNotebook* parent, const wxString& caption, const wxBitmap& icon, const Contributors& contributors) +{ + wxBoxSizer* bSizer = new wxBoxSizer( wxHORIZONTAL ); + + wxScrolledWindow* m_scrolledWindow1 = new wxScrolledWindow( parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL ); + m_scrolledWindow1->SetScrollRate( 5, 5 ); + + /* Panel for additional space at the left, + * but can also be used to show an additional bitmap. + */ + wxPanel* panel1 = new wxPanel(m_scrolledWindow1); + + wxFlexGridSizer* fgSizer1 = CreateFlexGridSizer(); + + for ( size_t i=0; iGetIcon(); + wxString category = contributor->GetCategory(); + + /* to construct the next row we expect to have + * a category and a contributor that was not considered up to now + */ + if ( ( category != wxEmptyString ) && !( contributor->IsChecked() ) ) + { + // Icon at first column + wxStaticBitmap* m_bitmap1 = CreateStaticBitmap( m_scrolledWindow1, icon ); + fgSizer1->Add( m_bitmap1, 0, wxALIGN_CENTER|wxLEFT|wxRIGHT, 5 ); + + // Category name at second column + wxStaticText* m_staticText1 = new wxStaticText( m_scrolledWindow1, wxID_ANY, contributor->GetCategory() + wxT(":"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText1->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) ); // bold font + m_staticText1->Wrap( -1 ); + fgSizer1->Add( m_staticText1, 0, wxALIGN_LEFT|wxBOTTOM, 2 ); + + // Nothing at third column + fgSizer1->AddSpacer(5); + + // Now, all contributors of the same category will follow + for ( size_t j=0; jGetCategory() == category ) + { + // First column is empty + fgSizer1->AddSpacer(5); + + // Name of contributor at second column + wxStaticText* m_staticText2 = new wxStaticText( m_scrolledWindow1, wxID_ANY, wxT(" • ") + contributor->GetName(), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText1->Wrap( -1 ); + fgSizer1->Add( m_staticText2, 0, wxALIGN_LEFT|wxBOTTOM, 2 ); + + // Email address of contributor at third column + if ( contributor->GetEMail() != wxEmptyString ) + { + wxHyperlinkCtrl* hyperlink = CreateHyperlink( m_scrolledWindow1, contributor->GetEMail() ); + fgSizer1->Add( hyperlink, 0, wxALIGN_LEFT|wxBOTTOM, 2 ); + } + else { + fgSizer1->AddSpacer(5); + } + + /* this contributor was added to the gui, + * thus can be ignored next time + */ + contributor->SetChecked( true ); + } + } + } + else { + continue; + } + } + + /* Now, lets list the remaining contributors that have not been considered + * because they were not assigned to any category. + */ + for ( size_t k=0; kIsChecked() ) + continue; + + // Icon at first column + wxStaticBitmap* m_bitmap1 = CreateStaticBitmap( m_scrolledWindow1, contributor->GetIcon() ); + fgSizer1->Add( m_bitmap1, 0, wxALIGN_CENTER|wxLEFT|wxRIGHT, 5 ); + + // Name of contributor at second column + if ( contributor->GetName() != wxEmptyString ) + { + wxStaticText* m_staticText1 = new wxStaticText( m_scrolledWindow1, wxID_ANY, contributor->GetName(), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText1->Wrap( -1 ); + fgSizer1->Add( m_staticText1, 0, wxALIGN_LEFT|wxBOTTOM, 2 ); + } + else { + fgSizer1->AddSpacer(5); + } + + // Email address of contributor at third column + if ( contributor->GetEMail() != wxEmptyString ) + { + wxHyperlinkCtrl* hyperlink = CreateHyperlink( m_scrolledWindow1, contributor->GetEMail() ); + fgSizer1->Add( hyperlink, 0, wxALIGN_LEFT|wxBOTTOM, 2 ); + } + else { + fgSizer1->AddSpacer(5); + } + } + + bSizer->Add( panel1, 1, wxEXPAND|wxALL, 10 ); + bSizer->Add( fgSizer1, 7, wxEXPAND|wxALL, 10 ); // adjust width of panel with first int value + m_scrolledWindow1->SetSizer( bSizer ); + m_scrolledWindow1->Layout(); + bSizer->Fit( m_scrolledWindow1 ); + + parent->AddPage( m_scrolledWindow1, caption, false, icon ); +} + +void dialog_about::CreateNotebookHtmlPage(wxAuiNotebook* parent, const wxString& caption, const wxBitmap& icon, const wxString& html) +{ + wxPanel* panel = new wxPanel( parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + + wxBoxSizer* bSizer = new wxBoxSizer( wxVERTICAL ); + + wxString htmlPage = wxEmptyString, htmlContent = html; + + // to have a unique look background color for HTML pages is set to the default as it is used for all the other widgets + wxString htmlColor = ( this->GetBackgroundColour() ).GetAsString( wxC2S_HTML_SYNTAX ); + + // beginning of html structure + htmlPage.Append( wxT("") ); + + htmlPage.Append( htmlContent ); + + // end of html structure indicated by closing tags + htmlPage.Append( wxT("") ); + + // the html page is going to be created with previously created html content + wxHtmlWindow* htmlWindow = new wxHtmlWindow( panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO|wxHW_NO_SELECTION ); + + // HTML font set to font properties as they are used for widgets to have an unique look under different platforms with HTML + wxFont font = this->GetFont(); + htmlWindow->SetStandardFonts( font.GetPointSize(), font.GetFaceName(), font.GetFaceName() ); + htmlWindow->SetPage( htmlPage ); + + // the HTML window shall not be used to open external links, thus this task is delegated to users default browser + htmlWindow->Connect( wxEVT_COMMAND_HTML_LINK_CLICKED, wxHtmlLinkEventHandler( dialog_about::OnHtmlLinkClicked ), NULL, this ); + + // no additional space around the html window as it is also the case by the other notebook pages + bSizer->Add( htmlWindow, 1, wxALL|wxEXPAND, 0 ); + panel->SetSizer( bSizer ); + panel->Layout(); + bSizer->Fit( panel ); + + parent->AddPage( panel, caption, false, icon ); +} + +wxHyperlinkCtrl* dialog_about::CreateHyperlink(wxScrolledWindow* parent, const wxString& email) +{ + wxHyperlinkCtrl* hyperlink = new wxHyperlinkCtrl( + parent, wxID_ANY, + wxT("<") + email + wxT(">"), /* the label */ + wxT("mailto:") + email + + wxT("?subject=KiCad - ") + + info.GetBuildVersion() + + wxT( " , ") + info.GetLibVersion() + ); /* the url */ + + return hyperlink; +} + +wxStaticBitmap* dialog_about::CreateStaticBitmap(wxScrolledWindow* parent, wxBitmap* icon) +{ + wxStaticBitmap* bitmap = new wxStaticBitmap( parent, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 ); + if ( icon ) + { + bitmap->SetBitmap( *icon ); + } + else { + bitmap->SetBitmap( right_xpm ); + } + return bitmap; +} + +/////////////////////////////////////////////////////////////////////////////// +/// Event handlers +/////////////////////////////////////////////////////////////////////////////// + +void dialog_about::OnClose(wxCloseEvent &event) +{ + Destroy(); +} + +void dialog_about::OnOkClick(wxCommandEvent &event) +{ + Destroy(); +} + +void dialog_about::OnHtmlLinkClicked( wxHtmlLinkEvent& event ) +{ + ::wxLaunchDefaultBrowser( event.GetLinkInfo().GetHref() ); +} diff --git a/common/dialog_about/dialog_about.h b/common/dialog_about/dialog_about.h new file mode 100644 index 0000000000..e36fcae145 --- /dev/null +++ b/common/dialog_about/dialog_about.h @@ -0,0 +1,77 @@ +/*************************************************************** + * Name: dialog_about.h + * Purpose: Defines Application Frame + * Author: Rafael Sokolowski (rafael.sokolowski@web.de) + * Created: 2010-08-06 + * Copyright: Rafael Sokolowski () + * License: + **************************************************************/ + +#ifndef DIALOG_ABOUT_H +#define DIALOG_ABOUT_H + +#include +#include +#include +#include + +#include "aboutinfo.h" +#include "dialog_about_base.h" + +/* Pixel information of icons in XPM format. + * All KiCad icons are linked into shared library 'libbitmaps.a'. + * Icons: + * preference_xpm[]; // Icon for 'Developers' tab + * editor_xpm[]; // Icon for 'Doc Writers' tab + * palette_xpm[]; // Icon for 'Artists' tab + * language_xpm[]; // Icon for 'Translators' tab + * right_xpm[]; // Right arrow icon for list items + * info_xpm[]; // Bulb for description tab + * tools_xpm[]; // Sheet of paper icon for license info tab + */ +#include "bitmaps.h" + +/** + * About dialog to show application specific information. + * Needs an AboutAppInfo object that contains the data to be displayed. + */ +class dialog_about : public dialog_about_base +{ +private: + + // Icons for the various tabs of wxAuiNotebook + wxBitmap picInformation, picDevelopers, picDocWriters, picArtists, picTranslators, + picLicense; + + AboutAppInfo info; + +public: + dialog_about( wxWindow* dlg, AboutAppInfo& appInfo ); + ~dialog_about(); +private: + void initDialog(); + virtual void OnClose( wxCloseEvent& event ); + virtual void OnOkClick( wxCommandEvent& event ); + virtual void OnHtmlLinkClicked( wxHtmlLinkEvent& event ); + + // Notebook pages + wxFlexGridSizer* CreateFlexGridSizer(); + void DeleteNotebooks(); + void CreateNotebooks(); + void CreateNotebookPage( wxAuiNotebook* parent, + const wxString& caption, + const wxBitmap& icon, + const Contributors& contributors ); + void CreateNotebookPageByCategory( wxAuiNotebook* parent, + const wxString& caption, + const wxBitmap& icon, + const Contributors& contributors ); + void CreateNotebookHtmlPage( wxAuiNotebook* parent, + const wxString& caption, + const wxBitmap& icon, + const wxString& html ); + + wxHyperlinkCtrl* CreateHyperlink( wxScrolledWindow* parent, const wxString& email ); + wxStaticBitmap* CreateStaticBitmap( wxScrolledWindow* parent, wxBitmap* icon ); +}; +#endif // DIALOG_ABOUT_H diff --git a/common/dialog_about/dialog_about_base.cpp b/common/dialog_about/dialog_about_base.cpp new file mode 100644 index 0000000000..30d41eb608 --- /dev/null +++ b/common/dialog_about/dialog_about_base.cpp @@ -0,0 +1,77 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Apr 16 2008) +// http://www.wxformbuilder.org/ +// +// PLEASE DO "NOT" EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#include "dialog_about_base.h" + +/////////////////////////////////////////////////////////////////////////// + +dialog_about_base::dialog_about_base( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style ) +{ + this->SetSizeHints( wxSize( -1,-1 ), wxDefaultSize ); + + wxBoxSizer* bSizer1; + bSizer1 = new wxBoxSizer( wxVERTICAL ); + + wxBoxSizer* bSizer3; + bSizer3 = new wxBoxSizer( wxHORIZONTAL ); + + m_bitmapApp = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 ); + bSizer3->Add( m_bitmapApp, 0, wxALIGN_CENTER|wxALL, 5 ); + + wxBoxSizer* b_apptitleSizer; + b_apptitleSizer = new wxBoxSizer( wxVERTICAL ); + + m_staticTextAppTitle = new wxStaticText( this, wxID_ANY, _("App Title"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE|wxST_NO_AUTORESIZE ); + m_staticTextAppTitle->Wrap( -1 ); + m_staticTextAppTitle->SetFont( wxFont( 14, 70, 90, 92, false, wxEmptyString ) ); + + b_apptitleSizer->Add( m_staticTextAppTitle, 0, wxALIGN_CENTER|wxALL|wxEXPAND, 5 ); + + m_staticTextCopyright = new wxStaticText( this, wxID_ANY, _("Copyright Info"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE|wxST_NO_AUTORESIZE ); + m_staticTextCopyright->Wrap( -1 ); + b_apptitleSizer->Add( m_staticTextCopyright, 0, wxALIGN_CENTER|wxALL|wxEXPAND, 1 ); + + m_staticTextBuildVersion = new wxStaticText( this, wxID_ANY, _("Build Version Info"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE|wxST_NO_AUTORESIZE ); + m_staticTextBuildVersion->Wrap( -1 ); + b_apptitleSizer->Add( m_staticTextBuildVersion, 0, wxALIGN_CENTER_HORIZONTAL|wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); + + m_staticTextLibVersion = new wxStaticText( this, wxID_ANY, _("Lib Version Info"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE|wxST_NO_AUTORESIZE ); + m_staticTextLibVersion->Wrap( -1 ); + b_apptitleSizer->Add( m_staticTextLibVersion, 0, wxALIGN_CENTER_HORIZONTAL|wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); + + bSizer3->Add( b_apptitleSizer, 1, wxEXPAND, 5 ); + + bSizer1->Add( bSizer3, 0, wxEXPAND, 5 ); + + wxStaticLine* m_staticline1; + m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + bSizer1->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 ); + + m_auiNotebook = new wxAuiNotebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxAUI_NB_SCROLL_BUTTONS|wxAUI_NB_TAB_FIXED_WIDTH|wxAUI_NB_WINDOWLIST_BUTTON ); + m_auiNotebook->SetMinSize( wxSize( 550,300 ) ); + + + bSizer1->Add( m_auiNotebook, 2, wxEXPAND | wxALL, 5 ); + + m_buttonOK = new wxButton( this, wxID_ANY, _("OK"), wxDefaultPosition, wxDefaultSize, 0 ); + m_buttonOK->SetDefault(); + bSizer1->Add( m_buttonOK, 0, wxALIGN_CENTER|wxALL, 5 ); + + this->SetSizer( bSizer1 ); + this->Layout(); + + // Connect Events + this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( dialog_about_base::OnClose ) ); + m_buttonOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( dialog_about_base::OnOkClick ), NULL, this ); +} + +dialog_about_base::~dialog_about_base() +{ + // Disconnect Events + this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( dialog_about_base::OnClose ) ); + m_buttonOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( dialog_about_base::OnOkClick ), NULL, this ); +} diff --git a/common/dialog_about/dialog_about_base.fbp b/common/dialog_about/dialog_about_base.fbp new file mode 100644 index 0000000000..cc30927e29 --- /dev/null +++ b/common/dialog_about/dialog_about_base.fbp @@ -0,0 +1,516 @@ + + + + + + C++ + 1 + UTF-8 + connect + dialog_about_base + 1000 + none + 1 + MyProject + + . + + 1 + 1 + 0 + + + + + 1 + + + + 0 + wxID_ANY + + -1,-1 + dialog_about_base + + 510,434 + wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxSTAY_ON_TOP + + About... + + + + + + + + OnClose + + + + + + + + + + + + + + + + + + + + + + + + + + + + + bSizer1 + wxVERTICAL + none + + 5 + wxEXPAND + 0 + + + bSizer3 + wxHORIZONTAL + none + + 5 + wxALIGN_CENTER|wxALL + 0 + + + + + 1 + + + 0 + wxID_ANY + + + m_bitmapApp + protected + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 1 + + + b_apptitleSizer + wxVERTICAL + none + + 5 + wxALIGN_CENTER|wxALL|wxEXPAND + 0 + + + + 1 + + ,90,92,14,70,0 + 0 + wxID_ANY + App Title + + + m_staticTextAppTitle + protected + + + wxALIGN_CENTRE|wxST_NO_AUTORESIZE + + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + wxALIGN_CENTER|wxALL|wxEXPAND + 0 + + + + 1 + + + 0 + wxID_ANY + Copyright Info + + + m_staticTextCopyright + protected + + + wxALIGN_CENTRE|wxST_NO_AUTORESIZE + + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALIGN_CENTER_HORIZONTAL|wxEXPAND|wxTOP|wxRIGHT|wxLEFT + 0 + + + + 1 + + + 0 + wxID_ANY + Build Version Info + + + m_staticTextBuildVersion + protected + + + wxALIGN_CENTRE|wxST_NO_AUTORESIZE + + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALIGN_CENTER_HORIZONTAL|wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND + 0 + + + + 1 + + + 0 + wxID_ANY + Lib Version Info + + + m_staticTextLibVersion + protected + + + wxALIGN_CENTRE|wxST_NO_AUTORESIZE + + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND | wxALL + 0 + + + + 1 + + + 0 + wxID_ANY + + + m_staticline1 + none + + + wxLI_HORIZONTAL + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND | wxALL + 2 + + + + 1 + + + 0 + wxID_ANY + + 550,300 + m_auiNotebook + protected + + + wxAUI_NB_SCROLL_BUTTONS|wxAUI_NB_TAB_FIXED_WIDTH|wxAUI_NB_WINDOWLIST_BUTTON + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALIGN_CENTER|wxALL + 0 + + + + 1 + 1 + + + 0 + wxID_ANY + OK + + + m_buttonOK + private + + + + + + + + + OnOkClick + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/common/dialog_about/dialog_about_base.h b/common/dialog_about/dialog_about_base.h new file mode 100644 index 0000000000..90e6914680 --- /dev/null +++ b/common/dialog_about/dialog_about_base.h @@ -0,0 +1,58 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Apr 16 2008) +// http://www.wxformbuilder.org/ +// +// PLEASE DO "NOT" EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#ifndef __dialog_about_base__ +#define __dialog_about_base__ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////// + +/////////////////////////////////////////////////////////////////////////////// +/// Class dialog_about_base +/////////////////////////////////////////////////////////////////////////////// +class dialog_about_base : public wxDialog +{ + private: + wxButton* m_buttonOK; + + protected: + wxStaticBitmap* m_bitmapApp; + wxStaticText* m_staticTextAppTitle; + wxStaticText* m_staticTextCopyright; + wxStaticText* m_staticTextBuildVersion; + wxStaticText* m_staticTextLibVersion; + wxAuiNotebook* m_auiNotebook; + + // Virtual event handlers, overide them in your derived class + virtual void OnClose( wxCloseEvent& event ){ event.Skip(); } + virtual void OnOkClick( wxCommandEvent& event ){ event.Skip(); } + + + public: + dialog_about_base( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("About..."), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 510,434 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxSTAY_ON_TOP ); + ~dialog_about_base(); + +}; + +#endif //__dialog_about_base__