From 7f1ea9e54d9b441b60b5ca0daa07a9d3f4c84653 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Mon, 30 Mar 2015 18:42:39 +0200 Subject: [PATCH] New Footprint Library Wizard. --- CMakeLists.txt | 43 +- bitmaps_png/CMakeLists.txt | 1 + bitmaps_png/cpp_26/wizard_add_fplib_small.cpp | 137 + .../sources/wizard_add_fplib_small.svg | 715 ++++ cvpcb/CMakeLists.txt | 1 - include/bitmaps.h | 1 + pcbnew/CMakeLists.txt | 1 - pcbnew/dialogs/dialog_fp_lib_table.cpp | 77 +- pcbnew/dialogs/dialog_fp_lib_table_base.cpp | 12 +- pcbnew/dialogs/dialog_fp_lib_table_base.fbp | 176 +- pcbnew/dialogs/dialog_fp_lib_table_base.h | 6 +- pcbnew/dialogs/dialog_select_dirlist_base.cpp | 65 - pcbnew/dialogs/dialog_select_dirlist_base.fbp | 391 -- pcbnew/dialogs/dialog_select_dirlist_base.h | 60 - pcbnew/dialogs/wizard_add_fplib.cpp | 1439 ++++--- pcbnew/dialogs/wizard_add_fplib.h | 434 ++- pcbnew/dialogs/wizard_add_fplib_base.cpp | 387 +- pcbnew/dialogs/wizard_add_fplib_base.fbp | 3389 +++++++++-------- pcbnew/dialogs/wizard_add_fplib_base.h | 85 +- pcbnew/invoke_pcb_dialog.h | 17 + pcbnew/menubar_modedit.cpp | 6 +- pcbnew/menubar_pcbframe.cpp | 6 +- pcbnew/moduleframe.cpp | 12 +- pcbnew/pcbframe.cpp | 1 + pcbnew/pcbnew_config.cpp | 8 +- pcbnew/pcbnew_id.h | 1 + webviewer/CMakeLists.txt | 15 - webviewer/html_link_parser.cpp | 70 - webviewer/html_link_parser.h | 109 - webviewer/webviewer.cpp | 970 ----- 30 files changed, 4008 insertions(+), 4627 deletions(-) create mode 100644 bitmaps_png/cpp_26/wizard_add_fplib_small.cpp create mode 100644 bitmaps_png/sources/wizard_add_fplib_small.svg delete mode 100644 pcbnew/dialogs/dialog_select_dirlist_base.cpp delete mode 100644 pcbnew/dialogs/dialog_select_dirlist_base.fbp delete mode 100644 pcbnew/dialogs/dialog_select_dirlist_base.h delete mode 100644 webviewer/CMakeLists.txt delete mode 100644 webviewer/html_link_parser.cpp delete mode 100644 webviewer/html_link_parser.h delete mode 100644 webviewer/webviewer.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 1d7b8f3641..3c37ff3bd4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,26 +36,6 @@ option( KICAD_KEEPCASE ON ) -# The footprint library wizard uses wxWebview, which needs a system webkit to be built -# The default build option in wxWidgets is to build wxWebview, but it could be not built -# if web kit devel tools are missing -# So this option disable use of wxWebview, if building wxWebview creates issues -# see: -# http://docs.wxwidgets.org/3.0/classwx_web_view.html -# * No issues on Windows. -# * needs webkitgtk-devel package installed on Linux, and wxWidgets rebuilt with this package. -# * Seems also OK on OSX. -# This option has effect only if BUILD_GITHUB_PLUGIN is ON -# -# This option is set to OFF because Kicad developers cannot be sure the use of Webkit does no open -# a security issue when runnig Kicad. -# the probability is low, but not zero. -option( KICAD_USE_WEBKIT - "Use system web kit to build a web viewer in footprint library wizard to easily select github libraries (default ON)." - OFF - ) - - option( USE_WX_GRAPHICS_CONTEXT "Use wxGraphicsContext for rendering (default OFF). Warning, this is experimental" ) @@ -102,17 +82,6 @@ mark_as_advanced( KICAD_SKIP_BOOST ) # Normal builders should build Boost. option( BUILD_GITHUB_PLUGIN "Build the GITHUB_PLUGIN for pcbnew." ON ) -# When KICAD_USE_WEBKIT in on, the Kicad web viewer has access to the www. -# Kicad developers cannot be sure the use of Web viewer does no open a security issue when runnig Kicad. -# the probability is low, but not zero. -#so warn the user: -if( KICAD_USE_WEBKIT ) - message( STATUS "by setting KICAD_USE_WEBKIT ON, you are building a web viewer inside Kicad. -Kicad developers cannot be sure the Web access does no open a security issue, -when running a Web Viewer inside Kicad. The probability is low, but not zero. -You are warned" ) -endif() - # This can be set to a custom name to brag about a particular branch in the "About" dialog: set( KICAD_REPO_NAME "product" CACHE STRING "Name of the tree from which this build came." ) @@ -439,14 +408,7 @@ add_definitions( -DWX_COMPATIBILITY ) # See line 41 of CMakeModules/FindwxWidgets.cmake set( wxWidgets_CONFIG_OPTIONS --static=no ) -if( KICAD_USE_WEBKIT AND BUILD_GITHUB_PLUGIN ) - set( webkitlib "webview" ) - add_definitions( -DKICAD_USE_WEBKIT ) -else() - set( webkitlib "" ) -endif() - -find_package( wxWidgets 3.0.0 COMPONENTS gl aui adv html core net base xml ${webkitlib} stc REQUIRED ) +find_package( wxWidgets 3.0.0 COMPONENTS gl aui adv html core net base xml stc REQUIRED ) # Include wxWidgets macros. include( ${wxWidgets_USE_FILE} ) @@ -761,9 +723,6 @@ add_subdirectory( cvpcb ) add_subdirectory( eeschema ) add_subdirectory( gerbview ) add_subdirectory( lib_dxf ) -if( KICAD_USE_WEBKIT ) - add_subdirectory( webviewer ) -endif() add_subdirectory( pcbnew ) add_subdirectory( polygon ) add_subdirectory( pagelayout_editor ) diff --git a/bitmaps_png/CMakeLists.txt b/bitmaps_png/CMakeLists.txt index 04cf7e2ff4..6576614625 100644 --- a/bitmaps_png/CMakeLists.txt +++ b/bitmaps_png/CMakeLists.txt @@ -543,6 +543,7 @@ set( BMAPS_MID width_track width_vias window_close + wizard_add_fplib_small zip_tool zip zone_duplicate diff --git a/bitmaps_png/cpp_26/wizard_add_fplib_small.cpp b/bitmaps_png/cpp_26/wizard_add_fplib_small.cpp new file mode 100644 index 0000000000..42f8943e68 --- /dev/null +++ b/bitmaps_png/cpp_26/wizard_add_fplib_small.cpp @@ -0,0 +1,137 @@ + +/* Do not modify this file, it was automatically generated by the + * PNG2cpp CMake script, using a *.png file as input. + */ + +#include + +static const unsigned char png[] = { + 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, + 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x1a, 0x08, 0x06, 0x00, 0x00, 0x00, 0xa9, 0x4a, 0x4c, + 0xce, 0x00, 0x00, 0x07, 0x7e, 0x49, 0x44, 0x41, 0x54, 0x48, 0xc7, 0xa5, 0x56, 0x6b, 0x50, 0x93, + 0xe9, 0x15, 0x4e, 0xb5, 0x56, 0x2b, 0x20, 0x38, 0x28, 0x63, 0x87, 0x76, 0xa6, 0x63, 0xfd, 0xb1, + 0xe5, 0x47, 0xad, 0xda, 0xce, 0x56, 0x64, 0x67, 0x9d, 0x62, 0x71, 0x99, 0x56, 0x91, 0x9d, 0x81, + 0x1d, 0xca, 0x02, 0xae, 0xcb, 0x52, 0x06, 0xb9, 0x2a, 0x14, 0x65, 0x16, 0x17, 0x51, 0x61, 0x01, + 0x03, 0x04, 0x17, 0x08, 0x04, 0x02, 0x01, 0xc5, 0x22, 0x08, 0x04, 0x48, 0x02, 0x81, 0x90, 0x00, + 0x49, 0xc0, 0x70, 0x47, 0x90, 0x90, 0x90, 0x40, 0xf8, 0xc2, 0x45, 0x44, 0xee, 0x21, 0x5c, 0x73, + 0x7a, 0xde, 0x54, 0xb7, 0xb6, 0xd3, 0x0b, 0xdb, 0xbe, 0x33, 0x67, 0xbe, 0x6f, 0xbe, 0xf7, 0xf2, + 0x9c, 0xf3, 0x9c, 0xe7, 0x9c, 0xf7, 0xa3, 0xd1, 0xfe, 0x3e, 0x4e, 0x1f, 0x3a, 0x74, 0x28, 0x69, + 0xcf, 0x9e, 0x3d, 0xa7, 0xf0, 0xfd, 0x7b, 0xb4, 0xff, 0x6f, 0x7c, 0x1f, 0xc7, 0x07, 0x07, 0x0f, + 0x1e, 0x4c, 0xc2, 0xf7, 0x33, 0xe6, 0x2f, 0xbb, 0x77, 0xef, 0xfe, 0x3d, 0x3e, 0x4e, 0xa0, 0x7d, + 0xe4, 0xeb, 0xeb, 0xcb, 0x76, 0x77, 0x77, 0xcf, 0x46, 0x40, 0x3a, 0x02, 0x9e, 0xfc, 0x1f, 0x00, + 0x2c, 0xac, 0xad, 0xad, 0x3f, 0x41, 0xcb, 0xf6, 0xf2, 0xf2, 0xca, 0xbd, 0x70, 0xe1, 0x42, 0x39, + 0x02, 0xc6, 0x1f, 0x38, 0x70, 0x20, 0x88, 0x4c, 0x72, 0x9c, 0x9d, 0x9d, 0x99, 0x7b, 0xf7, 0xee, + 0xad, 0xb9, 0x7c, 0xf9, 0x72, 0xbf, 0x52, 0xa9, 0x14, 0xf7, 0xf6, 0xf6, 0x96, 0x9e, 0x3f, 0x7f, + 0x3e, 0xdb, 0xce, 0xce, 0xee, 0x36, 0xce, 0xff, 0x64, 0x27, 0x00, 0x96, 0x96, 0x96, 0x9e, 0x08, + 0x90, 0x1b, 0x12, 0x12, 0x52, 0x25, 0x16, 0x8b, 0x3b, 0xd0, 0x54, 0x7e, 0x7e, 0x7e, 0x43, 0x78, + 0x8e, 0x60, 0xff, 0xfe, 0xfd, 0x39, 0xb4, 0x5d, 0xbb, 0x76, 0x15, 0x6e, 0x6d, 0x6d, 0x71, 0x2a, + 0x2a, 0x2a, 0xf8, 0x69, 0x69, 0x69, 0x2a, 0xa9, 0x54, 0xaa, 0xcd, 0xc9, 0xc9, 0xd1, 0xc9, 0x64, + 0xb2, 0xe7, 0x8f, 0x1f, 0x3f, 0xae, 0x3f, 0x7a, 0xf4, 0x28, 0xd3, 0xc6, 0xc6, 0xc6, 0xed, 0xdf, + 0xd1, 0x89, 0x1e, 0x9f, 0x46, 0x8f, 0x8b, 0xfc, 0xfd, 0xfd, 0xe5, 0x35, 0x35, 0x35, 0xaa, 0x96, + 0x96, 0x16, 0x35, 0x97, 0xcb, 0xa5, 0x16, 0x16, 0x16, 0x34, 0x59, 0x59, 0x59, 0xaa, 0xcc, 0xcc, + 0x4c, 0x01, 0xce, 0x67, 0x12, 0xea, 0xd8, 0xeb, 0xeb, 0xeb, 0x1c, 0x9c, 0xe4, 0xa7, 0xa7, 0xa7, + 0x6b, 0x5e, 0xbd, 0x7a, 0x45, 0xcd, 0xcf, 0xcf, 0x8f, 0x09, 0x04, 0x02, 0x0a, 0xbf, 0x69, 0x1b, + 0x1a, 0x1a, 0x94, 0x17, 0x2f, 0x5e, 0xe4, 0x63, 0x74, 0x5f, 0x11, 0xcf, 0xdf, 0xc1, 0xb0, 0xc2, + 0x91, 0xe0, 0xe0, 0xe0, 0xd0, 0x56, 0x5a, 0x5a, 0x3a, 0x8c, 0x43, 0x23, 0x91, 0x48, 0xa8, 0xbe, + 0xbe, 0xbe, 0xf1, 0xd5, 0xd5, 0xd5, 0xd1, 0xc5, 0xc5, 0x45, 0x5d, 0x6a, 0x6a, 0xaa, 0x3a, 0x23, + 0x23, 0x83, 0x8f, 0x8e, 0xa6, 0xd3, 0x30, 0x17, 0xf9, 0x2b, 0x2b, 0x2b, 0x1c, 0x1e, 0x8f, 0x57, + 0x8b, 0x1e, 0x0c, 0x03, 0xc0, 0x08, 0x59, 0x34, 0x33, 0x33, 0x43, 0x21, 0x8d, 0x54, 0x55, 0x55, + 0xd5, 0x44, 0x57, 0x57, 0x97, 0xfa, 0xfa, 0xf5, 0xeb, 0x43, 0xe8, 0xd9, 0xc3, 0x37, 0x60, 0x3f, + 0x45, 0x9a, 0x44, 0xa1, 0xa1, 0xa1, 0x4a, 0x8a, 0xa2, 0x46, 0x70, 0x7e, 0x1c, 0x99, 0xd0, 0xa3, + 0x83, 0x3a, 0xb2, 0x77, 0x6d, 0x6d, 0x6d, 0x94, 0x9c, 0x83, 0x40, 0xc3, 0x68, 0x3c, 0x14, 0x45, + 0x32, 0x0d, 0x73, 0x93, 0x87, 0x93, 0x9c, 0xba, 0xba, 0xba, 0x1a, 0xe2, 0x01, 0x89, 0x68, 0x63, + 0x63, 0x43, 0x4b, 0x16, 0x1a, 0x0c, 0x86, 0xb1, 0x81, 0x81, 0x81, 0x49, 0x1f, 0x1f, 0x17, 0x43, + 0x67, 0x67, 0xa7, 0xee, 0xd6, 0xad, 0x5b, 0x4a, 0xf4, 0x4e, 0x84, 0x20, 0xbd, 0x85, 0x85, 0x85, + 0x2a, 0x8d, 0x46, 0x33, 0xe6, 0xef, 0xef, 0xb4, 0xea, 0xed, 0xfd, 0xa1, 0x71, 0x69, 0x69, 0x69, + 0x8c, 0xec, 0x21, 0x46, 0x80, 0xc8, 0x39, 0x89, 0x89, 0x89, 0xaa, 0x94, 0x94, 0x94, 0x5a, 0x5b, + 0x5b, 0xdb, 0x7b, 0xb4, 0x7d, 0xfb, 0xf6, 0xe5, 0xce, 0xce, 0xce, 0x72, 0x1a, 0x1b, 0x1b, 0xab, + 0x31, 0x47, 0xc3, 0x98, 0x2f, 0x4d, 0x7b, 0x7b, 0xfb, 0x24, 0x59, 0x38, 0x37, 0x37, 0x37, 0xbe, + 0xbd, 0xbd, 0x3d, 0x12, 0x1c, 0x7c, 0x74, 0x93, 0x4e, 0x3f, 0xb2, 0x1d, 0x10, 0xe0, 0xb4, 0x7a, + 0xf2, 0xe4, 0x2f, 0x0c, 0x61, 0x61, 0x61, 0x53, 0x77, 0xee, 0x5c, 0x9d, 0xbf, 0x76, 0xed, 0xc7, + 0x5b, 0x73, 0x73, 0x16, 0x70, 0xf3, 0xa6, 0xe7, 0x92, 0xd1, 0x68, 0x34, 0x1f, 0x3e, 0x35, 0x35, + 0x45, 0x75, 0x77, 0x77, 0x4f, 0x10, 0xc0, 0x84, 0x84, 0x84, 0x61, 0x3a, 0x9d, 0x5e, 0x83, 0x40, + 0x77, 0x69, 0xa8, 0x08, 0x26, 0x4e, 0x72, 0x90, 0x5f, 0x6e, 0x52, 0x52, 0xd2, 0x30, 0x82, 0x52, + 0x48, 0xdb, 0x28, 0x8a, 0x81, 0xea, 0xe9, 0xe9, 0xa1, 0xc8, 0xe6, 0xc8, 0x48, 0x27, 0x23, 0x80, + 0x25, 0x6c, 0x6c, 0x58, 0x02, 0x93, 0x69, 0x69, 0x0a, 0x08, 0x38, 0xb2, 0xa9, 0x54, 0x5a, 0x01, + 0xf9, 0x36, 0x31, 0x61, 0x01, 0x89, 0x89, 0x11, 0x8b, 0x3a, 0x9d, 0x8e, 0x22, 0x7b, 0x14, 0x0a, + 0xc5, 0x38, 0x32, 0x34, 0xfa, 0xfa, 0xf5, 0xeb, 0xf1, 0xf8, 0xf8, 0x78, 0x25, 0xe6, 0x9d, 0x8b, + 0x40, 0x77, 0x68, 0x28, 0xcb, 0x6c, 0xbd, 0x5e, 0xcf, 0x69, 0x6e, 0x6e, 0xe6, 0x26, 0x27, 0x27, + 0x2b, 0x31, 0x02, 0x0d, 0x89, 0x84, 0x00, 0x8c, 0x8c, 0x8c, 0xe8, 0xd1, 0x01, 0x7d, 0x74, 0xb4, + 0xd7, 0xf2, 0xc2, 0x82, 0x85, 0xf9, 0x60, 0x62, 0x46, 0xe3, 0x41, 0x10, 0x4b, 0xdc, 0xa0, 0x45, + 0xea, 0x02, 0x62, 0xb1, 0x0d, 0x24, 0x27, 0xdf, 0x9d, 0x45, 0x6a, 0xf5, 0x64, 0xcf, 0x1b, 0x31, + 0x8d, 0x9b, 0x4c, 0x26, 0x4d, 0x5c, 0x5c, 0x9c, 0x32, 0x35, 0x2d, 0x9d, 0x8f, 0x75, 0x79, 0x9b, + 0x86, 0x09, 0xce, 0x42, 0x6f, 0x38, 0xa8, 0xfb, 0x6a, 0xe4, 0xd3, 0x1c, 0xd1, 0xdb, 0x1c, 0x11, + 0x1a, 0xc9, 0x46, 0x06, 0x23, 0x65, 0x4e, 0x28, 0x3c, 0x60, 0x7a, 0x0b, 0xd4, 0xf7, 0xfc, 0x14, + 0x74, 0xf7, 0x48, 0x60, 0x74, 0x74, 0x14, 0x9e, 0x56, 0xe6, 0x40, 0x5e, 0x1e, 0x73, 0xe1, 0x9f, + 0x73, 0x34, 0x33, 0xf3, 0x8a, 0xca, 0xc8, 0x2d, 0x5e, 0xce, 0x2f, 0xa9, 0x5e, 0xfa, 0xb5, 0xa3, + 0x53, 0xa6, 0x99, 0xba, 0xc9, 0xc9, 0x49, 0x8e, 0x48, 0x24, 0xaa, 0x26, 0x2a, 0x21, 0x87, 0xa3, + 0xa4, 0xa7, 0xc7, 0xc7, 0xc7, 0xcd, 0x1e, 0xa2, 0xf4, 0x35, 0x21, 0x21, 0xae, 0x06, 0xad, 0xd6, + 0xea, 0xdb, 0x88, 0x88, 0xf5, 0xf4, 0x9e, 0x81, 0xae, 0xee, 0x26, 0x18, 0x1b, 0x1b, 0x83, 0x6c, + 0x66, 0x8c, 0xa9, 0xb4, 0x94, 0x39, 0x4b, 0xd6, 0xbf, 0x78, 0xf1, 0x62, 0x42, 0xde, 0xd6, 0x3e, + 0xc5, 0x6f, 0x6c, 0x33, 0x36, 0x77, 0xa9, 0xa1, 0xb5, 0x57, 0x03, 0x29, 0x19, 0x05, 0x93, 0x04, + 0x28, 0x07, 0x73, 0xc2, 0xc1, 0xc3, 0x6b, 0x88, 0x18, 0xde, 0x88, 0x40, 0x87, 0x54, 0x98, 0x25, + 0x1b, 0x16, 0x76, 0xd1, 0x30, 0x30, 0x60, 0x6d, 0x32, 0x1a, 0x6d, 0x40, 0xd1, 0xf1, 0xc1, 0x3f, + 0x80, 0xb5, 0xca, 0x58, 0x80, 0xf2, 0x86, 0x96, 0xd6, 0x02, 0x8c, 0xca, 0x6e, 0x2b, 0x3a, 0xda, + 0x77, 0x51, 0xad, 0x56, 0xeb, 0xea, 0x24, 0x6d, 0x06, 0x49, 0x97, 0x12, 0x1a, 0xdb, 0x07, 0xa0, + 0xba, 0x41, 0xbe, 0xf9, 0xc9, 0xa7, 0x9f, 0x57, 0x13, 0x79, 0xb3, 0x90, 0x53, 0xb3, 0xbc, 0x1f, + 0x3c, 0x78, 0x30, 0xfc, 0xae, 0x3c, 0x23, 0x22, 0xdc, 0x51, 0xd6, 0x7f, 0xa3, 0xac, 0x45, 0xea, + 0x0a, 0x1a, 0xed, 0x10, 0x1e, 0xea, 0x05, 0x2b, 0x2b, 0xb6, 0x48, 0xdd, 0xef, 0x40, 0xa5, 0xea, + 0x00, 0x4c, 0x3c, 0xc8, 0xe4, 0xb9, 0xd0, 0xdf, 0xbf, 0x1f, 0xfc, 0xfc, 0x6c, 0xb7, 0xe3, 0xe2, + 0xae, 0x2d, 0xf2, 0x1a, 0xa5, 0x6b, 0xb5, 0x4d, 0xed, 0xc0, 0x15, 0xb6, 0xc2, 0x37, 0x39, 0x45, + 0x7a, 0x14, 0xc3, 0xd7, 0xe6, 0x82, 0x45, 0x7e, 0xcd, 0x05, 0x8b, 0x0a, 0x51, 0x4f, 0x4c, 0x4c, + 0xe8, 0x5f, 0xbe, 0x7c, 0x49, 0xf5, 0xf6, 0xf6, 0xe8, 0x3f, 0xfb, 0xcc, 0xd1, 0x18, 0x13, 0xf3, + 0x9b, 0xb5, 0xa8, 0xa8, 0xf7, 0x36, 0xa2, 0xfe, 0x7c, 0x7a, 0x6b, 0x60, 0xb0, 0x1f, 0xd4, 0x6a, + 0x25, 0xb4, 0x3d, 0xe3, 0xc3, 0xe0, 0x60, 0x27, 0x20, 0xbd, 0xa0, 0xd5, 0x6a, 0x11, 0x5c, 0x62, + 0xca, 0xca, 0x4e, 0x5b, 0xc4, 0x02, 0xd7, 0xd5, 0x0a, 0x9b, 0x57, 0x05, 0x22, 0x19, 0x54, 0xd6, + 0x36, 0xae, 0xd1, 0x33, 0x98, 0x73, 0xe9, 0xe9, 0x0c, 0x81, 0xb9, 0x60, 0x11, 0x88, 0x8d, 0x35, + 0xc0, 0xa9, 0xad, 0xad, 0xe5, 0x61, 0x5f, 0x52, 0xe1, 0xbb, 0x56, 0x2e, 0x97, 0x53, 0xa8, 0xb6, + 0x49, 0x52, 0x13, 0x44, 0x41, 0x24, 0x4a, 0x74, 0x80, 0x62, 0x73, 0xf2, 0x37, 0x91, 0x56, 0x58, + 0x5e, 0x5e, 0x36, 0x1b, 0x3a, 0x08, 0x95, 0x95, 0x55, 0xc0, 0x17, 0x08, 0xa1, 0xa3, 0xb3, 0x73, + 0xbb, 0xe4, 0x09, 0x77, 0x5d, 0xd4, 0xd2, 0x0e, 0x65, 0xdc, 0x3a, 0x23, 0xe6, 0x5a, 0x8b, 0x39, + 0x57, 0x31, 0x18, 0x0c, 0x1e, 0x16, 0xf9, 0xfd, 0x6f, 0x9b, 0x2a, 0x36, 0x44, 0x5e, 0x78, 0x78, + 0xb8, 0xba, 0xbe, 0xbe, 0x9e, 0x42, 0x71, 0x50, 0x24, 0x2a, 0x52, 0x17, 0xfd, 0xfd, 0xfd, 0xd4, + 0xf4, 0xf4, 0xb4, 0x1e, 0xdb, 0xd4, 0x18, 0x11, 0x46, 0x78, 0x84, 0x9f, 0x49, 0x2a, 0x67, 0x40, + 0x15, 0x37, 0xd1, 0xc4, 0x2e, 0x64, 0xaf, 0x0d, 0x0c, 0xbe, 0x30, 0x09, 0x85, 0xcd, 0x50, 0x52, + 0xc6, 0x03, 0xb1, 0x4c, 0x01, 0xe5, 0x35, 0xc2, 0x0d, 0x54, 0xa3, 0x1e, 0x1d, 0xa7, 0x82, 0x83, + 0x83, 0xd5, 0xc8, 0x12, 0xe9, 0x75, 0xa9, 0xa4, 0x39, 0x16, 0x12, 0xea, 0xd0, 0xc3, 0x87, 0x65, + 0x65, 0x65, 0x02, 0x2c, 0x32, 0x85, 0xb7, 0xb7, 0xb7, 0x32, 0x37, 0x37, 0x57, 0x8d, 0xb4, 0x98, + 0x55, 0x84, 0x8a, 0x9c, 0x20, 0x02, 0x21, 0x7d, 0xcc, 0xc9, 0xe9, 0xcc, 0x4a, 0x6c, 0xec, 0xa1, + 0xad, 0xc0, 0xc0, 0x5f, 0xae, 0x0f, 0x8d, 0xe8, 0xa9, 0x9b, 0x49, 0x45, 0xeb, 0xe5, 0x55, 0x42, + 0x90, 0x48, 0x15, 0x18, 0x89, 0x10, 0xa3, 0x13, 0x6c, 0xf8, 0xf8, 0xf8, 0x8c, 0xde, 0xb8, 0x71, + 0x43, 0x11, 0x1b, 0x1b, 0xdb, 0x80, 0x51, 0x3d, 0x42, 0x20, 0x06, 0x0d, 0xf9, 0x8b, 0xc1, 0x36, + 0xc4, 0xb2, 0xb7, 0xb7, 0x67, 0xe2, 0xa5, 0xc7, 0x64, 0xb1, 0x58, 0x1c, 0x54, 0x52, 0x71, 0x41, + 0x41, 0x81, 0x08, 0x37, 0x28, 0x8b, 0x8b, 0x8b, 0x49, 0xde, 0x28, 0xa1, 0x50, 0x38, 0x8d, 0x54, + 0x8e, 0x9e, 0x3b, 0x77, 0x6e, 0xd1, 0xdd, 0xfd, 0x57, 0xab, 0xd1, 0xf1, 0xf7, 0x16, 0x83, 0x52, + 0xf8, 0x5b, 0x49, 0x25, 0x5d, 0xe0, 0xfb, 0xe5, 0x5f, 0x4c, 0x65, 0x08, 0x26, 0x12, 0x77, 0x80, + 0x54, 0xf6, 0x1c, 0x8a, 0x1f, 0x3d, 0x9a, 0xff, 0x91, 0xbd, 0x7d, 0xf1, 0xe1, 0xc3, 0x87, 0xef, + 0x62, 0xd7, 0x8f, 0xc2, 0x2e, 0xff, 0x87, 0xb7, 0x2d, 0x9f, 0xdc, 0x35, 0x76, 0x68, 0xef, 0xa3, + 0x42, 0x82, 0x89, 0xe4, 0x8f, 0x1f, 0x3f, 0x9e, 0x8d, 0xde, 0x14, 0x61, 0x63, 0x6c, 0x0d, 0x0a, + 0x0a, 0x52, 0x22, 0x1d, 0x5a, 0xbc, 0x0a, 0xf4, 0x78, 0x49, 0x2e, 0x46, 0x7e, 0x99, 0xf0, 0x3a, + 0x30, 0x89, 0xbf, 0xe9, 0xfb, 0x75, 0x13, 0xb8, 0xc5, 0x54, 0xc1, 0xa5, 0x9b, 0x95, 0xe0, 0x19, + 0x74, 0x6f, 0xe1, 0x99, 0xe2, 0xb9, 0xa9, 0xbe, 0xa1, 0x1b, 0x65, 0x3f, 0x08, 0x4f, 0xca, 0xca, + 0xfa, 0x2e, 0x87, 0x87, 0xdb, 0xfc, 0xb7, 0x1b, 0x73, 0x17, 0xda, 0xcf, 0x31, 0xda, 0xab, 0x08, + 0xca, 0x72, 0x75, 0x75, 0x2d, 0x73, 0x73, 0x73, 0x1b, 0x6a, 0x6d, 0x6d, 0x1d, 0x71, 0x74, 0xf1, + 0x34, 0xf8, 0x7e, 0x55, 0xbe, 0xe9, 0x7f, 0xbf, 0x05, 0xbe, 0xb8, 0x57, 0x01, 0xbf, 0xbd, 0x5a, + 0x08, 0x67, 0x03, 0xf2, 0x66, 0x8e, 0x9c, 0x70, 0x73, 0xc8, 0x2b, 0x28, 0xa8, 0x97, 0xca, 0x7b, + 0x4d, 0xbc, 0xba, 0x6e, 0x68, 0x6a, 0x1e, 0x80, 0x87, 0x25, 0x25, 0x32, 0xbc, 0xb5, 0xf7, 0xed, + 0xf8, 0x3f, 0x00, 0x6f, 0xd1, 0x8f, 0xac, 0xac, 0x6d, 0xf2, 0xde, 0x73, 0xfe, 0xd3, 0x4b, 0xef, + 0xd8, 0xa7, 0xa6, 0xb4, 0xa7, 0xfd, 0x10, 0xc5, 0xe0, 0xc3, 0xd9, 0x40, 0x16, 0x9c, 0x0b, 0x2d, + 0xd1, 0x1f, 0xbb, 0x94, 0xea, 0x42, 0x16, 0x7a, 0xc4, 0x79, 0xfc, 0x80, 0xc5, 0xce, 0x13, 0x8b, + 0xc4, 0xdd, 0xc0, 0xad, 0xed, 0x01, 0x49, 0x4b, 0x1f, 0xb0, 0xd8, 0x6c, 0xb1, 0x87, 0x87, 0xc7, + 0xee, 0x1d, 0xff, 0x75, 0x9c, 0xfc, 0x34, 0xeb, 0x49, 0x5c, 0x51, 0xb7, 0xa9, 0xbe, 0x83, 0x82, + 0x6b, 0x0c, 0x21, 0x38, 0x5d, 0xc9, 0x84, 0xf3, 0x61, 0xa5, 0x53, 0xc7, 0x2e, 0x65, 0xb8, 0xbc, + 0xbb, 0x2e, 0x22, 0x22, 0xe2, 0x87, 0x2c, 0x76, 0xbe, 0xac, 0xb1, 0xa9, 0x03, 0xeb, 0x4b, 0x0e, + 0x78, 0xe5, 0x6c, 0xa7, 0xd0, 0xe9, 0x71, 0x3b, 0x06, 0xfa, 0xf8, 0x46, 0x85, 0xbc, 0xb0, 0x7e, + 0x18, 0xbc, 0xe2, 0x05, 0xe0, 0xe8, 0xc7, 0x00, 0xd7, 0xeb, 0xe5, 0xeb, 0x0e, 0x9e, 0x0f, 0x22, + 0xff, 0xd5, 0x5a, 0x9f, 0xc8, 0x48, 0x8b, 0xfc, 0x02, 0xb6, 0x02, 0xa9, 0x06, 0xac, 0x49, 0x40, + 0xa0, 0xac, 0x1d, 0x03, 0x9d, 0xf2, 0xcb, 0x0e, 0xfd, 0x63, 0x5c, 0x8d, 0xe1, 0xc3, 0xc0, 0x3c, + 0x70, 0x8e, 0x78, 0x0a, 0xef, 0x7f, 0x5e, 0xd8, 0xfc, 0x9f, 0xd6, 0x5f, 0xb9, 0x72, 0xc5, 0xea, + 0x7e, 0x1a, 0xbd, 0x80, 0x9e, 0x96, 0x96, 0x4f, 0xde, 0xbf, 0xd3, 0x4f, 0xdb, 0x09, 0xaf, 0x6f, + 0x6e, 0x9f, 0x0d, 0x2a, 0x56, 0x3a, 0x7e, 0xc1, 0x79, 0xf6, 0x33, 0x8f, 0xd4, 0x63, 0xdf, 0x65, + 0xef, 0x5f, 0x01, 0x80, 0xfb, 0x59, 0x6e, 0xd0, 0xcc, 0xfa, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x49, + 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82, +}; + +const BITMAP_OPAQUE wizard_add_fplib_small_xpm[1] = {{ png, sizeof( png ), "wizard_add_fplib_small_xpm" }}; + +//EOF diff --git a/bitmaps_png/sources/wizard_add_fplib_small.svg b/bitmaps_png/sources/wizard_add_fplib_small.svg new file mode 100644 index 0000000000..70f01e2dc1 --- /dev/null +++ b/bitmaps_png/sources/wizard_add_fplib_small.svg @@ -0,0 +1,715 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cvpcb/CMakeLists.txt b/cvpcb/CMakeLists.txt index 2bb481b874..64ee8af53b 100644 --- a/cvpcb/CMakeLists.txt +++ b/cvpcb/CMakeLists.txt @@ -38,7 +38,6 @@ set( CVPCB_DIALOGS ../pcbnew/dialogs/dialog_fp_plugin_options_base.cpp ../pcbnew/dialogs/wizard_add_fplib_base.cpp ../pcbnew/dialogs/wizard_add_fplib.cpp - ../pcbnew/dialogs/dialog_select_dirlist_base.cpp ) set( CVPCB_SRCS diff --git a/include/bitmaps.h b/include/bitmaps.h index 50629964b9..e31fd104f9 100644 --- a/include/bitmaps.h +++ b/include/bitmaps.h @@ -540,6 +540,7 @@ EXTERN_BITMAP( width_track_xpm ) EXTERN_BITMAP( width_vias_xpm ) EXTERN_BITMAP( window_close_xpm ) EXTERN_BITMAP( wizard_add_fplib_icon_xpm ) +EXTERN_BITMAP( wizard_add_fplib_small_xpm ) EXTERN_BITMAP( zip_tool_xpm ) EXTERN_BITMAP( zip_xpm ) EXTERN_BITMAP( zone_duplicate_xpm ) diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt index 62bb9d1c1a..e6d0a07865 100644 --- a/pcbnew/CMakeLists.txt +++ b/pcbnew/CMakeLists.txt @@ -130,7 +130,6 @@ set( PCBNEW_DIALOGS dialogs/dialog_SVG_print_base.cpp dialogs/dialog_select_pretty_lib.cpp dialogs/dialog_select_pretty_lib_base.cpp - dialogs/dialog_select_dirlist_base.cpp dialogs/dialog_set_grid.cpp dialogs/dialog_set_grid_base.cpp dialogs/dialog_target_properties_base.cpp diff --git a/pcbnew/dialogs/dialog_fp_lib_table.cpp b/pcbnew/dialogs/dialog_fp_lib_table.cpp index 986b9367e6..1f3b4d6f83 100644 --- a/pcbnew/dialogs/dialog_fp_lib_table.cpp +++ b/pcbnew/dialogs/dialog_fp_lib_table.cpp @@ -802,44 +802,46 @@ int DIALOG_FP_LIB_TABLE::m_pageNdx = 0; void DIALOG_FP_LIB_TABLE::OnClickLibraryWizard( wxCommandEvent& event ) { - wxArrayString envVariableList; + WIZARD_FPLIB_TABLE dlg( this ); - // Build the environment variables in use: - for( int ii = 0; ii < m_path_subs_grid->GetTable()->GetRowsCount(); ii ++ ) - envVariableList.Add( m_path_subs_grid->GetCellValue( wxGridCellCoords( ii, 0 ) ) ); - - WIZARD_FPLIB_TABLE dlg( this, envVariableList ); - - if( ! dlg.RunWizard( dlg.GetFirstPage() ) ) + if( !dlg.RunWizard( dlg.GetFirstPage() ) ) return; // Aborted by user - wxGrid* libgrid = m_cur_grid; - FP_TBL_MODEL* tbl = (FP_TBL_MODEL*) libgrid->GetTable(); + const std::vector& libs = dlg.GetLibraries(); + bool global_scope = dlg.GetLibScope() == WIZARD_FPLIB_TABLE::GLOBAL; + wxGrid* libgrid = global_scope ? m_global_grid : m_project_grid; + FP_TBL_MODEL* tbl = (FP_TBL_MODEL*) libgrid->GetTable(); - // Import fp library list - int idx = 0; - wxArrayString libDescr; // Will contain nickname, URI, plugin - - while( dlg.GetLibDescr( idx++, libDescr ) ) + for( std::vector::const_iterator it = libs.begin(); + it != libs.end(); ++it ) { - if( ! libDescr[0].IsEmpty() && m_cur_grid->AppendRows( 1 ) ) + if( it->GetStatus() == WIZARD_FPLIB_TABLE::LIBRARY::INVALID ) + continue; + + if( libgrid->AppendRows( 1 ) ) { int last_row = libgrid->GetNumberRows() - 1; // Add the nickname: currently make it from filename - tbl->SetValue( last_row, COL_NICKNAME, libDescr[0] ); - // Add the full path: - tbl->SetValue( last_row, COL_URI, libDescr[1] ); + tbl->SetValue( last_row, COL_NICKNAME, it->GetDescription() ); + + // Add the path: + tbl->SetValue( last_row, COL_URI, it->GetAutoPath( dlg.GetLibScope() ) ); + // Add the plugin name: - tbl->SetValue( last_row, COL_TYPE, libDescr[2] ); + tbl->SetValue( last_row, COL_TYPE, it->GetPluginName() ); libgrid->MakeCellVisible( last_row, 0 ); libgrid->SetGridCursor( last_row, 0 ); } - - libDescr.Clear(); } + // Switch to the current scope tab + if( global_scope ) + m_auinotebook->SetSelection( 0 ); + else + m_auinotebook->SetSelection( 1 ); + libgrid->SelectRow( libgrid->GetGridCursorRow() ); } @@ -852,3 +854,34 @@ int InvokePcbLibTableEditor( wxTopLevelWindow* aParent, FP_LIB_TABLE* aGlobal, F return dialogRet; } + + +int InvokeFootprintWizard( wxTopLevelWindow* aParent, FP_LIB_TABLE* aGlobal, FP_LIB_TABLE* aProject ) +{ + WIZARD_FPLIB_TABLE dlg( aParent ); + + if( !dlg.RunWizard( dlg.GetFirstPage() ) ) + return 0; // Aborted by user + + const std::vector& libs = dlg.GetLibraries(); + WIZARD_FPLIB_TABLE::LIB_SCOPE scope = dlg.GetLibScope(); + FP_LIB_TABLE* fp_tbl = ( scope == WIZARD_FPLIB_TABLE::GLOBAL ? aGlobal : aProject ); + + if( fp_tbl ) + { + for( std::vector::const_iterator it = libs.begin(); + it != libs.end(); ++it ) + { + if( it->GetStatus() == WIZARD_FPLIB_TABLE::LIBRARY::INVALID ) + continue; + + FP_LIB_TABLE::ROW row( it->GetDescription(), + it->GetAutoPath( scope ), + it->GetPluginName(), + wxEmptyString ); // options + fp_tbl->InsertRow( row ); + } + } + + return scope; +} diff --git a/pcbnew/dialogs/dialog_fp_lib_table_base.cpp b/pcbnew/dialogs/dialog_fp_lib_table_base.cpp index 00dcde2a62..9b1f611110 100644 --- a/pcbnew/dialogs/dialog_fp_lib_table_base.cpp +++ b/pcbnew/dialogs/dialog_fp_lib_table_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jun 5 2014) +// C++ code generated with wxFormBuilder (version Mar 9 2015) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -130,14 +130,14 @@ DIALOG_FP_LIB_TABLE_BASE::DIALOG_FP_LIB_TABLE_BASE( wxWindow* parent, wxWindowID wxBoxSizer* bSizer51; bSizer51 = new wxBoxSizer( wxHORIZONTAL ); + m_buttonWizard = new wxButton( this, wxID_ANY, _("Append with Wizard"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer51->Add( m_buttonWizard, 0, wxALL, 5 ); + m_append_button = new wxButton( this, wxID_ANY, _("Append Library"), wxDefaultPosition, wxDefaultSize, 0 ); m_append_button->SetToolTip( _("Add a PCB library row to this table") ); bSizer51->Add( m_append_button, 0, wxALL, 5 ); - m_buttonWizard = new wxButton( this, wxID_ANY, _("Append with Wizard"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizer51->Add( m_buttonWizard, 0, wxALL, 5 ); - m_delete_button = new wxButton( this, wxID_ANY, _("Remove Library"), wxDefaultPosition, wxDefaultSize, 0 ); m_delete_button->SetToolTip( _("Remove a PCB library from this library table") ); @@ -228,8 +228,8 @@ DIALOG_FP_LIB_TABLE_BASE::DIALOG_FP_LIB_TABLE_BASE( wxWindow* parent, wxWindowID this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_FP_LIB_TABLE_BASE::onCancelCaptionButtonClick ) ); this->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( DIALOG_FP_LIB_TABLE_BASE::onKeyDown ) ); m_auinotebook->Connect( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, wxAuiNotebookEventHandler( DIALOG_FP_LIB_TABLE_BASE::pageChangedHandler ), NULL, this ); - m_append_button->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_LIB_TABLE_BASE::appendRowHandler ), NULL, this ); m_buttonWizard->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_LIB_TABLE_BASE::OnClickLibraryWizard ), NULL, this ); + m_append_button->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_LIB_TABLE_BASE::appendRowHandler ), NULL, this ); m_delete_button->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_LIB_TABLE_BASE::deleteRowHandler ), NULL, this ); m_move_up_button->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_LIB_TABLE_BASE::moveUpHandler ), NULL, this ); m_move_down_button->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_LIB_TABLE_BASE::moveDownHandler ), NULL, this ); @@ -244,8 +244,8 @@ DIALOG_FP_LIB_TABLE_BASE::~DIALOG_FP_LIB_TABLE_BASE() this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_FP_LIB_TABLE_BASE::onCancelCaptionButtonClick ) ); this->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( DIALOG_FP_LIB_TABLE_BASE::onKeyDown ) ); m_auinotebook->Disconnect( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, wxAuiNotebookEventHandler( DIALOG_FP_LIB_TABLE_BASE::pageChangedHandler ), NULL, this ); - m_append_button->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_LIB_TABLE_BASE::appendRowHandler ), NULL, this ); m_buttonWizard->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_LIB_TABLE_BASE::OnClickLibraryWizard ), NULL, this ); + m_append_button->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_LIB_TABLE_BASE::appendRowHandler ), NULL, this ); m_delete_button->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_LIB_TABLE_BASE::deleteRowHandler ), NULL, this ); m_move_up_button->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_LIB_TABLE_BASE::moveUpHandler ), NULL, this ); m_move_down_button->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_LIB_TABLE_BASE::moveDownHandler ), NULL, this ); diff --git a/pcbnew/dialogs/dialog_fp_lib_table_base.fbp b/pcbnew/dialogs/dialog_fp_lib_table_base.fbp index 7499807f2b..32d1a98fc4 100644 --- a/pcbnew/dialogs/dialog_fp_lib_table_base.fbp +++ b/pcbnew/dialogs/dialog_fp_lib_table_base.fbp @@ -1031,94 +1031,6 @@ bSizer51 wxHORIZONTAL none - - 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Append Library - - 0 - - - 0 - - 1 - m_append_button - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - Add a PCB library row to this table - - wxFILTER_NONE - wxDefaultValidator - - - - - appendRowHandler - - - - - - - - - - - - - - - - - - - - - - - - - 5 wxALL @@ -1207,6 +1119,94 @@ + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Append Library + + 0 + + + 0 + + 1 + m_append_button + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + Add a PCB library row to this table + + wxFILTER_NONE + wxDefaultValidator + + + + + appendRowHandler + + + + + + + + + + + + + + + + + + + + + + + + + 5 wxALL diff --git a/pcbnew/dialogs/dialog_fp_lib_table_base.h b/pcbnew/dialogs/dialog_fp_lib_table_base.h index 576479f078..0ba7e63a68 100644 --- a/pcbnew/dialogs/dialog_fp_lib_table_base.h +++ b/pcbnew/dialogs/dialog_fp_lib_table_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jun 5 2014) +// C++ code generated with wxFormBuilder (version Mar 9 2015) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -51,8 +51,8 @@ class DIALOG_FP_LIB_TABLE_BASE : public DIALOG_SHIM wxStaticText* m_staticText4; wxStaticText* m_PrjTableFilename; wxGrid* m_project_grid; - wxButton* m_append_button; wxButton* m_buttonWizard; + wxButton* m_append_button; wxButton* m_delete_button; wxButton* m_move_up_button; wxButton* m_move_down_button; @@ -66,8 +66,8 @@ class DIALOG_FP_LIB_TABLE_BASE : public DIALOG_SHIM virtual void onCancelCaptionButtonClick( wxCloseEvent& event ) = 0; virtual void onKeyDown( wxKeyEvent& event ) = 0; virtual void pageChangedHandler( wxAuiNotebookEvent& event ) = 0; - virtual void appendRowHandler( wxCommandEvent& event ) = 0; virtual void OnClickLibraryWizard( wxCommandEvent& event ) = 0; + virtual void appendRowHandler( wxCommandEvent& event ) = 0; virtual void deleteRowHandler( wxCommandEvent& event ) = 0; virtual void moveUpHandler( wxCommandEvent& event ) = 0; virtual void moveDownHandler( wxCommandEvent& event ) = 0; diff --git a/pcbnew/dialogs/dialog_select_dirlist_base.cpp b/pcbnew/dialogs/dialog_select_dirlist_base.cpp deleted file mode 100644 index 3e262208a1..0000000000 --- a/pcbnew/dialogs/dialog_select_dirlist_base.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jun 5 2014) -// http://www.wxformbuilder.org/ -// -// PLEASE DO "NOT" EDIT THIS FILE! -/////////////////////////////////////////////////////////////////////////// - -#include "dialog_select_dirlist_base.h" - -/////////////////////////////////////////////////////////////////////////// - -DIALOG_SELECT_DIRLIST_BASE::DIALOG_SELECT_DIRLIST_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) -{ - this->SetSizeHints( wxSize( 400,300 ), wxDefaultSize ); - - wxBoxSizer* bSizerMain; - bSizerMain = new wxBoxSizer( wxVERTICAL ); - - m_staticText = new wxStaticText( this, wxID_ANY, _("The footprint library is a folder.\nFootprints are files inside this folder."), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText->Wrap( -1 ); - m_staticText->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) ); - - bSizerMain->Add( m_staticText, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 ); - - m_dirCtrl = new wxGenericDirCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxDIRCTRL_3D_INTERNAL|wxDIRCTRL_DIR_ONLY|wxDIRCTRL_MULTIPLE|wxDIRCTRL_SHOW_FILTERS|wxSUNKEN_BORDER, _("*.pretty|*"), 0 ); - - m_dirCtrl->ShowHidden( false ); - m_dirCtrl->SetMinSize( wxSize( 400,350 ) ); - - bSizerMain->Add( m_dirCtrl, 1, wxEXPAND | wxALL, 5 ); - - m_staticline = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); - bSizerMain->Add( m_staticline, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); - - m_sdbSizer = new wxStdDialogButtonSizer(); - m_sdbSizerOK = new wxButton( this, wxID_OK ); - m_sdbSizer->AddButton( m_sdbSizerOK ); - m_sdbSizerCancel = new wxButton( this, wxID_CANCEL ); - m_sdbSizer->AddButton( m_sdbSizerCancel ); - m_sdbSizer->Realize(); - - bSizerMain->Add( m_sdbSizer, 0, wxALIGN_RIGHT|wxALL, 5 ); - - - this->SetSizer( bSizerMain ); - this->Layout(); - - this->Centre( wxBOTH ); - - // Connect Events - m_dirCtrl->Connect( wxEVT_COMMAND_TREE_ITEM_ACTIVATED, wxTreeEventHandler( DIALOG_SELECT_DIRLIST_BASE::OnSelectFolder ), NULL, this ); - m_dirCtrl->Connect( wxEVT_COMMAND_TREE_SEL_CHANGED, wxTreeEventHandler( DIALOG_SELECT_DIRLIST_BASE::OnSelectFolder ), NULL, this ); - m_sdbSizerCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SELECT_DIRLIST_BASE::OnCancelClick ), NULL, this ); - m_sdbSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SELECT_DIRLIST_BASE::OnOKClick ), NULL, this ); -} - -DIALOG_SELECT_DIRLIST_BASE::~DIALOG_SELECT_DIRLIST_BASE() -{ - // Disconnect Events - m_dirCtrl->Disconnect( wxEVT_COMMAND_TREE_ITEM_ACTIVATED, wxTreeEventHandler( DIALOG_SELECT_DIRLIST_BASE::OnSelectFolder ), NULL, this ); - m_dirCtrl->Disconnect( wxEVT_COMMAND_TREE_SEL_CHANGED, wxTreeEventHandler( DIALOG_SELECT_DIRLIST_BASE::OnSelectFolder ), NULL, this ); - m_sdbSizerCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SELECT_DIRLIST_BASE::OnCancelClick ), NULL, this ); - m_sdbSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SELECT_DIRLIST_BASE::OnOKClick ), NULL, this ); - -} diff --git a/pcbnew/dialogs/dialog_select_dirlist_base.fbp b/pcbnew/dialogs/dialog_select_dirlist_base.fbp deleted file mode 100644 index b02ebf74aa..0000000000 --- a/pcbnew/dialogs/dialog_select_dirlist_base.fbp +++ /dev/null @@ -1,391 +0,0 @@ - - - - - - C++ - 1 - source_name - 0 - 0 - res - UTF-8 - connect - dialog_select_dirlist_base - 1000 - none - 1 - dialog_select_dirlist_base - - . - - 1 - 1 - 1 - 1 - UI - 0 - 0 - - 0 - wxAUI_MGR_DEFAULT - - wxBOTH - - 1 - 1 - impl_virtual - - - - 0 - wxID_ANY - - 400,300 - DIALOG_SELECT_DIRLIST_BASE - - 400,321 - wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER - DIALOG_SHIM; dialog_shim.h - Select Footprint Library Folder - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bSizerMain - wxVERTICAL - none - - 5 - wxALL|wxALIGN_CENTER_HORIZONTAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - ,90,92,-1,70,0 - 0 - 0 - wxID_ANY - The footprint library is a folder. Footprints are files inside this folder. - - 0 - - - 0 - - 1 - m_staticText - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND | wxALL - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - - Dock - 0 - Left - 1 - - *.pretty|* - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - 400,350 - 1 - m_dirCtrl - 1 - - - protected - 1 - - Resizable - 1 - 0 - - wxDIRCTRL_3D_INTERNAL|wxDIRCTRL_DIR_ONLY|wxDIRCTRL_MULTIPLE|wxDIRCTRL_SHOW_FILTERS - - 0 - - - - wxSUNKEN_BORDER - - - - - - - - - - - - - - - - - - - - - - - - - - - - - OnSelectFolder - - - - - - - - - OnSelectFolder - - - - - - 5 - wxEXPAND|wxTOP|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_staticline - 1 - - - protected - 1 - - Resizable - 1 - - wxLI_HORIZONTAL - - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALIGN_RIGHT|wxALL - 0 - - 0 - 1 - 0 - 0 - 0 - 1 - 0 - 0 - - m_sdbSizer - protected - - OnCancelClick - - - - OnOKClick - - - - - - - - diff --git a/pcbnew/dialogs/dialog_select_dirlist_base.h b/pcbnew/dialogs/dialog_select_dirlist_base.h deleted file mode 100644 index 916ffd328f..0000000000 --- a/pcbnew/dialogs/dialog_select_dirlist_base.h +++ /dev/null @@ -1,60 +0,0 @@ -/////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jun 5 2014) -// http://www.wxformbuilder.org/ -// -// PLEASE DO "NOT" EDIT THIS FILE! -/////////////////////////////////////////////////////////////////////////// - -#ifndef __DIALOG_SELECT_DIRLIST_BASE_H__ -#define __DIALOG_SELECT_DIRLIST_BASE_H__ - -#include -#include -#include -class DIALOG_SHIM; - -#include "dialog_shim.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/////////////////////////////////////////////////////////////////////////// - - -/////////////////////////////////////////////////////////////////////////////// -/// Class DIALOG_SELECT_DIRLIST_BASE -/////////////////////////////////////////////////////////////////////////////// -class DIALOG_SELECT_DIRLIST_BASE : public DIALOG_SHIM -{ - private: - - protected: - wxStaticText* m_staticText; - wxGenericDirCtrl* m_dirCtrl; - wxStaticLine* m_staticline; - wxStdDialogButtonSizer* m_sdbSizer; - wxButton* m_sdbSizerOK; - wxButton* m_sdbSizerCancel; - - // Virtual event handlers, overide them in your derived class - virtual void OnSelectFolder( wxTreeEvent& event ) { event.Skip(); } - virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); } - virtual void OnOKClick( wxCommandEvent& event ) { event.Skip(); } - - - public: - - DIALOG_SELECT_DIRLIST_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Select Footprint Library Folder"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 400,321 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); - ~DIALOG_SELECT_DIRLIST_BASE(); - -}; - -#endif //__DIALOG_SELECT_DIRLIST_BASE_H__ diff --git a/pcbnew/dialogs/wizard_add_fplib.cpp b/pcbnew/dialogs/wizard_add_fplib.cpp index d20890f7f9..1df5284ccb 100644 --- a/pcbnew/dialogs/wizard_add_fplib.cpp +++ b/pcbnew/dialogs/wizard_add_fplib.cpp @@ -1,11 +1,9 @@ -/** - * @file wizard_add_fplib.cpp - */ - /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr + * Copyright (C) 2015 CERN + * @author Maciej Suminski + * Copyright (C) 2014-2015 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or @@ -26,76 +24,296 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -/** @brief this code creates a wizard to add entries in the footprint library table. - * The wizard contains 3 pages: - * The first is the selection of the type of libraries (plugin type): - * * Kicad .pretty library (actually a folder containing .kicad_mod footprint files) - * * Gihtub .pretty on line library, accessible via a internet connection - * * Legacy library (old .mod format file containing footprints desc) - * * Eagle xml V6 library (.lbr files) - * * Geda-PCB library (actually a folder containing .fp footprint files - * The second is the selection of path management: - * use environment variable or absolute path. - * When using an environment variable, selec it - * The third is the library list selection - * It allows entering entries by running a tool to select a set of libraries - * The tool depend on the type of lib (files/folder/urls): - * * multi files selector - * * multi folder selector - * * multi URL selector (via a web viewer) - * The path and the plugin type comes from the selection, and a library nickname - * is built from the path. +/** + * @brief Wizard for selecting footprint libraries consisting of 4 steps: + * - select source (Github/local files) + * - pick libraries + * - present a review of libraries (including validation) + * - select scope (global/project) */ #include -#include +#include #include #include -#include -#include -#include // For PROJECT_VAR_NAME definition -#include // For KISYSMOD definition -#include +#include #include -#include +#include +#include + +#include + +#ifdef BUILD_GITHUB_PLUGIN +#include <../github/github_getliblist.h> +#endif // a key to store the default Kicad Github libs URL #define KICAD_FPLIBS_URL_KEY wxT( "kicad_fplib_url" ) -// key to store last options of th wizard -#define WIZARD_LAST_PLUGIN_KEY wxT( "wizard_plugin" ) -#define WIZARD_LAST_PATHOPTION_KEY wxT( "wizard_path_option" ) - -// static members to store last choices during a session -int WIZARD_FPLIB_TABLE::m_last_plugin_choice = 0; -int WIZARD_FPLIB_TABLE::m_last_defaultpath_choice = 2; - -WIZARD_FPLIB_TABLE::WIZARD_FPLIB_TABLE( wxWindow* aParent, wxArrayString& aEnvVariableList ) - : WIZARD_FPLIB_TABLE_BASE( aParent ) +// Filters for the file picker +static const int FILTER_COUNT = 4; +static const struct { - initDlg( aEnvVariableList ); + wxString m_Description; + wxString m_Extension; + bool m_IsFile; + IO_MGR::PCB_FILE_T m_Plugin; +} fileFilters[FILTER_COUNT] = +{ + { "KiCad (*.pretty folders)", ".pretty", false, IO_MGR::KICAD }, + { "Eagle 6.x (*.lbr)", ".lbr", true, IO_MGR::EAGLE }, + { "KiCad legacy (*.mod)", ".mod", true, IO_MGR::LEGACY }, + { "Geda (folder with *.fp files)", "", false, IO_MGR::GEDA_PCB }, +}; - // Allows github plugin selection only when the plugin is compiled: -#ifndef BUILD_GITHUB_PLUGIN - m_rbFpLibFormat->Enable( GITHUB_PLUGIN, false ); - if( m_rbFpLibFormat->GetSelection() == GITHUB_PLUGIN ) - m_rbFpLibFormat->SetSelection( KICAD_PLUGIN ); -#endif +// Returns the filter string for the file picker +static wxString getFilterString() +{ + wxString filterInit = _( "All supported library formats|" ); + wxString filter; - // Currently, I (JPC) do not know the best way to add/store - // what is currently called env variables - // So do not show tools to change them, - // but do not remove the code, just in case - m_buttonAddEV->Show( false ); - m_buttonRemoveEV->Show( false ); + for( int i = 0; i < FILTER_COUNT; ++i ) + { + // Init part + if( i != 0 ) + filterInit += ";"; -#ifndef BUILD_GITHUB_PLUGIN - m_buttonGithubLibList->Show( false ); -#endif + filterInit += "*" + fileFilters[i].m_Extension; - // Gives a minimal size to the dialog, which allows displaying any page + // Rest of the filter string + filter += "|" + fileFilters[i].m_Description + "|*" + fileFilters[i].m_Extension; + } + + return filterInit + filter; +} + + +// Tries to guess the plugin type basing on the path +static boost::optional getPluginType( const wxString& aPath ) +{ + if( ( aPath.StartsWith( "http://" ) || aPath.StartsWith( "https://" ) ) && aPath.EndsWith( ".pretty" ) ) + return boost::optional( IO_MGR::GITHUB ); + + wxFileName file( aPath ); + + for( int i = 0; i < FILTER_COUNT; ++i ) + { + if( aPath.EndsWith( fileFilters[i].m_Extension ) && + file.FileExists() == fileFilters[i].m_IsFile ) + return boost::optional( fileFilters[i].m_Plugin ); + } + + return boost::optional(); +} + + +// Checks if a filename fits specific filter +static bool passesFilter( const wxString& aFileName, int aFilterIndex ) +{ + wxASSERT( aFilterIndex <= FILTER_COUNT ); + wxFileName file( aFileName ); + + if( aFilterIndex == 0 ) // any supported library format + { + boost::optional result = getPluginType( aFileName ); + return ( result ? true : false ); + } + else + { + if( aFileName.EndsWith( fileFilters[aFilterIndex - 1].m_Extension ) && + file.FileExists() == fileFilters[aFilterIndex - 1].m_IsFile ) + return true; + } + + return false; +} + + +WIZARD_FPLIB_TABLE::LIBRARY::LIBRARY( const wxString& aPath, const wxString& aDescription ) : + m_path( aPath ), m_description( aDescription ), m_status( NOT_CHECKED ) +{ + m_plugin = getPluginType( aPath ); +} + + +bool WIZARD_FPLIB_TABLE::LIBRARY::Test() +{ + if( !m_plugin ) + { + m_status = LIBRARY::INVALID; + return false; + } + + PLUGIN* p = IO_MGR::PluginFind( *m_plugin ); + wxArrayString footprints; + + if( !p ) + { + m_status = LIBRARY::INVALID; + return false; + } + + try + { + footprints = p->FootprintEnumerate( m_path ); + } + catch( IO_ERROR& e ) + { + m_status = LIBRARY::INVALID; + return false; + } + + if( footprints.GetCount() == 0 ) + { + m_status = LIBRARY::INVALID; + return false; + } + + m_status = LIBRARY::OK; + return true; +} + + +wxString WIZARD_FPLIB_TABLE::LIBRARY::GetPluginName() const +{ + if( !m_plugin ) + return _( "UNKNOWN" ); + + switch( *m_plugin ) + { + case IO_MGR::LEGACY: + return wxT( "Legacy" ); + + case IO_MGR::KICAD: + return wxT( "KiCad" ); + + case IO_MGR::EAGLE: + return wxT( "Eagle" ); + + case IO_MGR::GEDA_PCB: + return wxT( "Geda-PCB" ); + + case IO_MGR::GITHUB: + return wxT( "Github" ); + + default: + return _( "UNKNOWN" ); + } + + /*PLUGIN* p = IO_MGR::PluginFind( *m_plugin ); + + if( !p ) + return _( "UNKNOWN" ); + + return p->PluginName();*/ +} + + +wxString WIZARD_FPLIB_TABLE::LIBRARY::GetRelativePath( const wxString& aBase, const wxString& aSubstitution ) const +{ + wxFileName libPath( m_path ); + + // Check if the library path belongs to the project folder + if( libPath.MakeRelativeTo( aBase ) && !libPath.GetFullPath().StartsWith( ".." ) ) + { + return wxString( aSubstitution + "/" + libPath.GetFullPath() ); + } + + // Probably on another drive, so the relative path will not work + return wxEmptyString; +} + + +wxString WIZARD_FPLIB_TABLE::LIBRARY::GetAutoPath( LIB_SCOPE aScope ) const +{ + const wxString& global_env = FP_LIB_TABLE::GlobalPathEnvVariableName(); + const wxString& project_env = PROJECT_VAR_NAME; + const wxString& github_env( "KIGITHUB" ); + + wxString rel_path; + + // KISYSMOD check + rel_path = replaceEnv( global_env ); + + if( !rel_path.IsEmpty() ) + return rel_path; + + // KIGITHUB check + rel_path = replaceEnv( github_env, false ); + + if( !rel_path.IsEmpty() ) + return rel_path; + + // KIPRJMOD check + if( aScope == PROJECT ) + { + rel_path = replaceEnv( project_env ); + + if( !rel_path.IsEmpty() ) + return rel_path; + } + + // Return the full path + return m_path; +} + + +wxString WIZARD_FPLIB_TABLE::LIBRARY::GetDescription() const +{ + if( !m_description.IsEmpty() ) + return m_description; + + wxFileName filename( m_path ); + return filename.GetName(); +} + + +wxString WIZARD_FPLIB_TABLE::LIBRARY::replaceEnv( const wxString& aEnvVar, bool aFilePath ) const +{ + wxString env_path; + + if( !wxGetEnv( aEnvVar, &env_path ) ) + return wxEmptyString; + + std::cout << "replacing (" << env_path << ") " << aEnvVar << " in " << m_path << std::endl; + + //return GetRelativePath( m_path, wxString( "$(" + aEnvVar + ")" ) ); + + wxString result( m_path ); + + if( result.Replace( env_path, wxString( "$(" + aEnvVar + ")" ) ) ) + return result; + + return wxEmptyString; +} + + +WIZARD_FPLIB_TABLE::WIZARD_FPLIB_TABLE( wxWindow* aParent ) : + WIZARD_FPLIB_TABLE_BASE( aParent ), m_welcomeDlg( m_pages[0] ), + m_fileSelectDlg( m_pages[1] ), m_githubListDlg( m_pages[2] ), + m_reviewDlg( m_pages[3] ), m_targetDlg( m_pages[4] ), m_selectedFilter( 0 ) +{ + m_filePicker->SetFilter( getFilterString() ); + + // Initialize default download dir + wxString default_path; + wxGetEnv( FP_LIB_TABLE::GlobalPathEnvVariableName(), &default_path ); + setDownloadDir( default_path ); + m_filePicker->SetPath( default_path ); + + // Restore the Github url + wxString githubUrl; + wxConfigBase* cfg = Pgm().CommonSettings(); + cfg->Read( KICAD_FPLIBS_URL_KEY, &githubUrl ); + + if( githubUrl.IsEmpty() ) + githubUrl = wxT( "https://github.com/KiCad" ); + + SetGithubURL( githubUrl ); + + // Give the minimal size to the dialog, which allows displaying any page wxSize minsize; for( unsigned ii = 0; ii < m_pages.size(); ii++ ) @@ -109,6 +327,16 @@ WIZARD_FPLIB_TABLE::WIZARD_FPLIB_TABLE( wxWindow* aParent, wxArrayString& aEnvVa SetPageSize( minsize ); GetSizer()->SetSizeHints( this ); Center(); + + if( !m_radioAddGithub->GetValue() && !m_radioAddLocal->GetValue() ) + m_radioAddLocal->SetValue( true ); + + setupDialogOrder(); + updateGithubControls(); + + Connect( wxEVT_RADIOBUTTON, wxCommandEventHandler( WIZARD_FPLIB_TABLE::OnSourceCheck ), NULL, this ); + Connect( wxEVT_DIRCTRL_SELECTIONCHANGED, wxCommandEventHandler( WIZARD_FPLIB_TABLE::OnSelectFiles ), NULL, this ); + Connect( wxEVT_CHECKLISTBOX, wxCommandEventHandler( WIZARD_FPLIB_TABLE::OnCheckGithubList ), NULL, this ); } @@ -116,803 +344,255 @@ WIZARD_FPLIB_TABLE::~WIZARD_FPLIB_TABLE() { // Use this if you want to store kicad lib URL in pcbnew/cvpcb section config: // wxConfigBase* cfg = Kiface().KifaceSettings(); + // Use this if you want to store kicad lib URL in common section config: wxConfigBase* cfg = Pgm().CommonSettings(); - cfg->Write( KICAD_FPLIBS_URL_KEY, m_textCtrlGithubURL->GetValue() ); - - m_last_plugin_choice = m_rbFpLibFormat->GetSelection(); - m_last_defaultpath_choice = m_rbPathManagement->GetSelection(); - - cfg->Write( WIZARD_LAST_PLUGIN_KEY, m_last_plugin_choice ); - cfg->Write( WIZARD_LAST_PATHOPTION_KEY, m_last_defaultpath_choice ); + cfg->Write( KICAD_FPLIBS_URL_KEY, GetGithubURL() ); } -void WIZARD_FPLIB_TABLE::initDlg( wxArrayString& aEnvVariableList ) +WIZARD_FPLIB_TABLE::LIB_SOURCE WIZARD_FPLIB_TABLE::GetLibSource() const { - m_currLibDescr = NULL; + if( m_radioAddGithub->GetValue() ) + return GITHUB; + wxASSERT( m_radioAddLocal->GetValue() ); + + return LOCAL; +} + + +WIZARD_FPLIB_TABLE::LIB_SCOPE WIZARD_FPLIB_TABLE::GetLibScope() const +{ + if( m_radioGlobal->GetValue() ) + return GLOBAL; + + wxASSERT( m_radioProject->GetValue() ); + + return PROJECT; +} + + +void WIZARD_FPLIB_TABLE::OnPageChanged( wxWizardEvent& aEvent ) +{ SetBitmap( KiBitmap( wizard_add_fplib_icon_xpm ) ); + enableNext( true ); - wxString msg; - wxConfigBase* cfg = Pgm().CommonSettings(); - cfg->Read( WIZARD_LAST_PLUGIN_KEY, &m_last_plugin_choice ); - cfg->Read( WIZARD_LAST_PATHOPTION_KEY, &m_last_defaultpath_choice ); - cfg->Read( KICAD_FPLIBS_URL_KEY, &msg ); - - if( msg.IsEmpty() ) // Give our current KiCad github URL - msg = wxT( "http://github.com/KiCad" ); - - // Be sure there is no trailing '/' at the end of the repo name - if( msg.EndsWith( wxT("/" ) ) ) - msg.RemoveLast(); - - m_textCtrlGithubURL->SetValue( msg ); - - // KIGITHUB is frequently used (examples in docs, and other place) - // So add it if it not yet in list, but if it is defined as env var - // (note this env var is not hardcoded or existing in kicad sources) - if( aEnvVariableList.Index( wxT("KIGITHUB"), false ) == wxNOT_FOUND ) - { - // Not yet in use in lib table, see in env. vars - wxString evValue; - wxGetEnv( wxT("KIGITHUB"), &evValue ); - - // Not yet in use in lib table, but it is defined in environment, - // so add it, just in case - if( ! evValue.IsEmpty() ) - aEnvVariableList.Add( wxT("KIGITHUB") ); - } - - m_rowPrjEnvVarPosition = 0; - m_predefinedEnvVarCnt = aEnvVariableList.GetCount(); - - for( int row = 0; row < m_predefinedEnvVarCnt; row++ ) - { - if( GetEnvVarCount() <= row ) - m_gridEnvironmentVariablesList->AppendRows(1); - - m_gridEnvironmentVariablesList->SetCellValue( row, 0, aEnvVariableList[row] ); - - if( aEnvVariableList[row] == PROJECT_VAR_NAME ) - m_rowPrjEnvVarPosition = row; - - wxString evValue; - - if( wxGetEnv( aEnvVariableList[row], &evValue ) ) - m_gridEnvironmentVariablesList->SetCellValue( row, 1, evValue ); - - // All these env var are defined outside the wizard, - // and cannot be modified in this dialog - m_gridEnvironmentVariablesList->SetReadOnly( row, 0, true ); - m_gridEnvironmentVariablesList->SetReadOnly( row, 1, true ); - } - - m_gridEnvironmentVariablesList->Fit(); - - m_buttonRemoveEV->Enable( GetEnvVarCount() > m_predefinedEnvVarCnt ); - m_gridEnvironmentVariablesList->AutoSizeColumns(); - - m_rbFpLibFormat->SetSelection( m_last_plugin_choice ); - m_rbPathManagement->SetSelection( m_last_defaultpath_choice ); - - wxCommandEvent event; - updateFromPlugingChoice(); - OnPathManagementSelection( event ); -} - -int WIZARD_FPLIB_TABLE::HasGithubEnvVarCompatible() -{ - // Return true if at least one env var defines a url relative to github - for( int row = 0; row < GetEnvVarCount(); row++ ) - { - if( m_gridEnvironmentVariablesList->GetCellValue( - wxGridCellCoords( row, 1 ) ).Lower().StartsWith( "http" ) ) - return row; - } - - return -1; + if( GetCurrentPage() == m_githubListDlg ) + setupGithubList(); + else if( GetCurrentPage() == m_fileSelectDlg ) + setupFileSelect(); + else if( GetCurrentPage() == m_reviewDlg ) + setupReview(); } -bool WIZARD_FPLIB_TABLE::ValidateOptions() +void WIZARD_FPLIB_TABLE::OnSelectFiles( wxCommandEvent& aEvent ) { - // Some choices can be conficting or do not work. - // Warn the user when this is the case - wxString msg; + int filterIdx = m_filePicker->GetFilterIndex(); - if( getSelectedEnvVarValue().IsEmpty() ) + if( m_selectedFilter != filterIdx ) { - // PROJECT_PATH option cannot be used with empty local path - if( m_rbPathManagement->GetSelection() == PROJECT_PATH ) - { - msg = _("The project path is empty and this option is not valid.\n" - "Looks like you are running the wizard outside a project."); - wxMessageBox( msg ); - return false; - } - else if( m_rbPathManagement->GetSelection() != ABSOLUTE_PATH ) - { - wxMessageBox( wxString::Format( - _("The default path defined by env var \"%s\" is empty.\nCannot use it"), - GetChars( getSelectedEnvVar() ) ) ); - return false; - } + m_selectedFilter = filterIdx; + + // Process the event again, as in the first iteration we cannot get the list of selected items + wxCommandEvent ev( wxEVT_DIRCTRL_SELECTIONCHANGED ); + AddPendingEvent( ev ); + return; } - else + + enableNext( checkFiles() ); +} + + +void WIZARD_FPLIB_TABLE::OnCheckGithubList( wxCommandEvent& aEvent ) +{ + wxArrayInt dummy; + + enableNext( m_checkListGH->GetCheckedItems( dummy ) > 0 ); +} + + +void WIZARD_FPLIB_TABLE::OnSourceCheck( wxCommandEvent& aEvent ) +{ + updateGithubControls(); + setupDialogOrder(); +} + + +void WIZARD_FPLIB_TABLE::OnSelectAllGH( wxCommandEvent& aEvent ) +{ + for( unsigned int i = 0; i < m_checkListGH->GetCount(); ++i ) + m_checkListGH->Check( i, true ); + + // The list might be empty, e.g. in case of download error + wxArrayInt dummy; + enableNext( m_checkListGH->GetCheckedItems( dummy ) > 0 ); +} + + +void WIZARD_FPLIB_TABLE::OnUnselectAllGH( wxCommandEvent& aEvent ) +{ + for( unsigned int i = 0; i < m_checkListGH->GetCount(); ++i ) + m_checkListGH->Check( i, false ); + + enableNext( false ); +} + + +void WIZARD_FPLIB_TABLE::OnChangeSearch( wxCommandEvent& aEvent ) +{ + wxString searchPhrase = m_searchCtrlGH->GetValue().Lower(); + + // Store the current selection + wxArrayInt checkedIndices; + m_checkListGH->GetCheckedItems( checkedIndices ); + wxArrayString checkedStrings; + + for( unsigned int i = 0; i < checkedIndices.GetCount(); ++i ) + checkedStrings.Add( m_checkListGH->GetString( checkedIndices[i] ).AfterLast( '/' ) ); + + m_checkListGH->Clear(); + + // Rebuild the list, putting the matching entries on the top + int matching = 0; // number of entries matching the search phrase + for( unsigned int i = 0; i < m_githubLibs.GetCount(); ++i ) { - if( IsGithubPlugin() ) + const wxString& lib = m_githubLibs[i].AfterLast( '/' ); + bool wasChecked = ( checkedStrings.Index( lib ) != wxNOT_FOUND ); + int insertedIdx = -1; + + if( !searchPhrase.IsEmpty() && lib.Lower().Contains( searchPhrase ) ) { - // Github plugin cannot be used with local path; Need absolute path or valid URL - if( !getSelectedEnvVarValue().Lower().StartsWith( "http" ) ) - { - msg = _("Github Plugin uses a valid Internet URL starting by http.\n" - "Cannot be used as URL"); - wxMessageBox( msg ); - return false; - } + insertedIdx = m_checkListGH->Insert( lib, matching++ ); + m_checkListGH->SetSelection( insertedIdx ); + } + else + insertedIdx = m_checkListGH->Append( lib ); + + if( wasChecked ) + m_checkListGH->Check( insertedIdx ); + } + + if( !m_checkListGH->IsEmpty() ) + m_checkListGH->EnsureVisible( 0 ); +} + + +void WIZARD_FPLIB_TABLE::OnWizardFinished( wxWizardEvent& aEvent ) +{ + // Shall we download a localy copy of the libraries + if( GetLibSource() == GITHUB && m_downloadGithub->GetValue() ) + { + wxString error; + wxArrayString libs; + + // Prepare a list of libraries to download + for( std::vector::const_iterator it = m_libraries.begin(); + it != m_libraries.end(); ++it ) + { + wxASSERT( it->GetPluginType() == IO_MGR::GITHUB ); + + if( it->GetStatus() != LIBRARY::INVALID ) + libs.Add( it->GetAbsolutePath() ); + } + + if( !downloadGithubLibsFromList( libs, &error ) ) + { + DisplayError( this, error ); + m_libraries.clear(); } else { - if( getSelectedEnvVarValue().Lower().StartsWith( "http" ) ) + // Now libraries are stored locally, so update the paths to point to the download folder + for( std::vector::iterator it = m_libraries.begin(); + it != m_libraries.end(); ++it ) { - msg = _("This default path looks strange.\n" - "Cannot be used for a file path"); - wxMessageBox( msg ); - return false; + wxString path = it->GetAbsolutePath(); + path.Replace( GetGithubURL(), getDownloadDir() ); + it->setPath( path ); + std::cout << "replaced path " << it->GetAbsolutePath() << std::endl; + it->setPluginType( IO_MGR::KICAD ); } } } - - // Other conficts: TODO - - return true; } -void WIZARD_FPLIB_TABLE::OnPluginSelection( wxCommandEvent& event ) +void WIZARD_FPLIB_TABLE::OnBrowseButtonClick( wxCommandEvent& aEvent ) { - updateFromPlugingChoice(); -} + wxString path = getDownloadDir(); -void WIZARD_FPLIB_TABLE::updateFromPlugingChoice() -{ - #ifdef BUILD_GITHUB_PLUGIN - m_buttonGithubLibList->Show( IsGithubPlugin() || IsKicadPlugin() ); - #endif + path = wxDirSelector( _("Choose a folder to save the downloaded libraries" ), + path, 0, wxDefaultPosition, this ); - // update dialog options and widgets depending on a plugin choice - // Project path has no sense for GITHUB_PLUGIN - bool enablePrjPathOpt = not IsGithubPlugin(); - - // Project path cannot be used if unknown - if( m_gridEnvironmentVariablesList->GetCellValue( - wxGridCellCoords( m_rowPrjEnvVarPosition, 1 ) ).IsEmpty() ) - enablePrjPathOpt = false; - - m_rbPathManagement->Enable( PROJECT_PATH, enablePrjPathOpt ); - - // Sometimes only the choice "absolute path" is allowed; - // Force this choice, at least make it the default choice - bool force_absolute_path = false; - - // For github plugin, the project path is not allowed - if( ( m_rbPathManagement->GetSelection() == PROJECT_PATH ) && !enablePrjPathOpt ) - force_absolute_path = true; - - // For github plugin, at least one github compatible path must exist - // If no github path, force absolute path - int first_github_envvar = HasGithubEnvVarCompatible(); - if( IsGithubPlugin() ) + if( !path.IsEmpty() && wxDirExists( path ) ) { - if( first_github_envvar < 0 ) - force_absolute_path = true; - else if( !getSelectedEnvVarValue().StartsWith( "http" ) ) - m_gridEnvironmentVariablesList->SelectRow( first_github_envvar ); - - } - - if( force_absolute_path ) - m_rbPathManagement->SetSelection( ABSOLUTE_PATH ); -} - - -void WIZARD_FPLIB_TABLE::OnPathManagementSelection( wxCommandEvent& event ) -{ - // Disable irrevant options, and enable others. - int row_count = GetEnvVarCount(); - - switch( m_rbPathManagement->GetSelection() ) - { - case PROJECT_PATH: // Choice = path relative to the project - m_gridEnvironmentVariablesList->Enable( true ); - m_buttonAddEV->Enable( false ); - m_gridEnvironmentVariablesList->ShowRow( PROJECT_PATH ); - - for( int row = 0; row < row_count; row++ ) - { - if( row == PROJECT_PATH ) - continue; - - m_gridEnvironmentVariablesList->HideRow( row ); - } - break; - - case ENV_VAR_PATH: // Choice = path relative to env var - m_gridEnvironmentVariablesList->Enable( true ); - m_buttonAddEV->Enable( true ); - - for( int row = 0; row < row_count; row++ ) - m_gridEnvironmentVariablesList->ShowRow( row ); - - break; - - case ABSOLUTE_PATH: // Choice = path relative to the project - m_gridEnvironmentVariablesList->Enable( false ); - m_buttonAddEV->Enable( false ); - break; + setDownloadDir( path ); + updateGithubControls(); } } -void WIZARD_FPLIB_TABLE::OnAddEVariable( wxCommandEvent& event ) + +void WIZARD_FPLIB_TABLE::OnCheckSaveCopy( wxCommandEvent& aEvent ) { - m_gridEnvironmentVariablesList->AppendRows( 1 ); - m_gridEnvironmentVariablesList->AutoSizeColumns(); - m_buttonRemoveEV->Enable( GetEnvVarCount() > m_predefinedEnvVarCnt ); - m_gridEnvironmentVariablesList->SetGridCursor( GetEnvVarCount()-1, 0 ); -} - -void WIZARD_FPLIB_TABLE::OnRemoveEVariable( wxCommandEvent& event ) -{ - wxArrayInt selectedRows = m_gridEnvironmentVariablesList->GetSelectedRows(); - int row_cursor = m_gridEnvironmentVariablesList->GetGridCursorRow(); - - if( selectedRows.size() == 0 && row_cursor >= 0 ) - selectedRows.Add( row_cursor ); - - std::sort( selectedRows.begin(), selectedRows.end() ); - - for( int ii = selectedRows.GetCount()-1; ii >= 0; ii-- ) - { - int row = selectedRows[ii]; - - // don't remove them env var. which are already existing in lib table - if( row > m_predefinedEnvVarCnt-1 ) - m_gridEnvironmentVariablesList->DeleteRows( row, 1 ); - } - - m_gridEnvironmentVariablesList->SelectRow( m_gridEnvironmentVariablesList->GetGridCursorRow() ); - m_buttonRemoveEV->Enable( GetEnvVarCount() > m_predefinedEnvVarCnt ); -} - -void WIZARD_FPLIB_TABLE::OnSelectEnvVarCell( wxGridEvent& event ) -{ - // Ensure the selected row is also the row which have the focus. - // useful when the user want to delete a row, and select it by the mouse - m_gridEnvironmentVariablesList->SelectRow( event.GetRow() ); -} - -wxString WIZARD_FPLIB_TABLE::getSelectedEnvVar() -{ - wxString envVar; - wxArrayInt selectedRows = m_gridEnvironmentVariablesList->GetSelectedRows(); - int row = selectedRows.GetCount() ? selectedRows[0] : - m_gridEnvironmentVariablesList->GetGridCursorRow(); - - switch( m_rbPathManagement->GetSelection() ) - { - case ENV_VAR_PATH: // Choice = path relative to env var - envVar = m_gridEnvironmentVariablesList->GetCellValue( - wxGridCellCoords( row, 0 ) ); - break; - - case PROJECT_PATH: // Choice = path relative to the project - envVar = PROJECT_VAR_NAME; - break; - - case ABSOLUTE_PATH: // Choice = absolute path - default: - break; - } - - return envVar; + updateGithubControls(); } -wxString WIZARD_FPLIB_TABLE::getSelectedEnvVarValue() +bool WIZARD_FPLIB_TABLE::checkFiles() const { - wxString envVarValue; - wxArrayInt selectedRows = m_gridEnvironmentVariablesList->GetSelectedRows(); - int row = selectedRows.GetCount() ? selectedRows[0] : - m_gridEnvironmentVariablesList->GetGridCursorRow(); + // Get current selection (files & directories) + wxArrayString candidates; + m_filePicker->GetPaths( candidates ); - switch( m_rbPathManagement->GetSelection() ) + // Workaround, when you change filters "/" is automatically selected + int slash_index = candidates.Index( "/", true, true ); + if( slash_index != wxNOT_FOUND ) + candidates.RemoveAt( slash_index, 1 ); + + if( candidates.IsEmpty() ) + return false; + + // Verify all the files/folders comply to the selected library type filter + for( unsigned int i = 0; i < candidates.GetCount(); ++i ) { - case ENV_VAR_PATH: // Choice = path relative tp env var - envVarValue = m_gridEnvironmentVariablesList->GetCellValue( - wxGridCellCoords( row, 1 ) ); - break; - - case PROJECT_PATH: // Choice = path relative to the project - envVarValue = m_gridEnvironmentVariablesList->GetCellValue( - wxGridCellCoords( m_rowPrjEnvVarPosition, 1 ) ); - break; - - case ABSOLUTE_PATH: // Choice = absolute path - default: - break; - } - - return envVarValue; -} - -void WIZARD_FPLIB_TABLE::OnPageChanged( wxWizardEvent& event ) -{ - if( GetCurrentPage() == m_pages[2] ) - setLastPage(); - else if( GetCurrentPage() == m_pages[1] ) - setSecondPage(); -} - -void WIZARD_FPLIB_TABLE::OnPageChanging( wxWizardEvent& event ) -{ - if( !( GetCurrentPage() == m_pages[1] && event.GetDirection() ) ) - return; - - if( ! ValidateOptions() ) - { - event.Veto(); - return; - } - - if( ( m_rbPathManagement->GetSelection() != ABSOLUTE_PATH ) && - ( IsGithubPlugin() ) ) - { - wxURI uri( getSelectedEnvVarValue() ); - - // We cannot use wxURL to test the validity of the url, because - // wxURL does not know https protocol we are using, and aways returns - // error for url starting by https - bool badurl = !uri.HasPath(); - - if( badurl ) - { - wxMessageBox( wxString::Format( - _("The URL defined by env var \"%s\" is an incorrect URL.\nCannot use it"), - GetChars( getSelectedEnvVar() ) ) ); - event.Veto(); - } - } -} - -bool WIZARD_FPLIB_TABLE::setSecondPage() -{ - // Init parameters for the second wizard page: this is only - // the current library description. - updateFromPlugingChoice(); - - delete m_currLibDescr; - m_currLibDescr = NULL; - - switch( m_rbFpLibFormat->GetSelection() ) - { - case 0: // Kicad lib type - m_currLibDescr = new LIB_DESCR_KICAD; - m_buttonGithubLibList->SetLabel( _("Download Github Libs") ); - break; - - case 1: // Github lib type - m_currLibDescr = new LIB_DESCR_GITHUB; - m_buttonGithubLibList->SetLabel( _("Github Libs List") ); - break; - - case 2: // Legacy lib type - m_currLibDescr = new LIB_DESCR_LEGACY; - break; - - case 3: // Eagle V6 lib type - m_currLibDescr = new LIB_DESCR_EAGLE; - break; - - case 4: // Geda lib type - m_currLibDescr = new LIB_DESCR_GEDA; - break; - } - - if( IsGithubPlugin() ) - { -#ifdef KICAD_USE_WEBKIT - m_buttonAddLib->SetLabel( _("Add Libs with WebViewer") ); -#else - m_buttonAddLib->SetLabel( _("Add FP Library entry") ); -#endif - } - else - m_buttonAddLib->SetLabel( _("Add FP Libraries") ); - - return m_currLibDescr!= NULL; -} - -bool WIZARD_FPLIB_TABLE::setLastPage() // Init prms for the last wizard page -{ - // Update texts in last wizard page - m_textPluginType->SetLabel( m_rbFpLibFormat->GetStringSelection() ); - - switch( m_rbPathManagement->GetSelection() ) - { - case ENV_VAR_PATH: // Choice = path relative env var - case PROJECT_PATH: // Choice = path relative to the project - m_currLibDescr->m_EnvVarName = getSelectedEnvVar(); - m_currLibDescr->m_DefaultPath = getSelectedEnvVarValue(); - m_currLibDescr->m_IsAbsolutePath = false; - - m_textOption->SetLabel( wxString::Format( wxT("%s (%s)"), - m_rbPathManagement->GetStringSelection().GetData(), - getSelectedEnvVar().GetData() ) ); - - m_textPath->SetLabel( getSelectedEnvVarValue() ); - break; - - case ABSOLUTE_PATH: // Choice = absolute path - m_currLibDescr->m_IsAbsolutePath = true; - - m_textOption->SetLabel( m_rbPathManagement->GetStringSelection() ); - - if( IsGithubPlugin() ) - m_textPath->SetLabel( _("Full URL") ); - else - m_textPath->SetLabel( _("Full filename") ); - break; + if( !passesFilter( candidates[i], m_filePicker->GetFilterIndex() ) ) + return false; } return true; } - -void WIZARD_FPLIB_TABLE::OnAddFpLibs( wxCommandEvent& event ) -{ - if( m_currLibDescr->m_IsFile ) - selectLibsFiles(); - else if( m_currLibDescr->m_IsGitHub ) - selectLibsGithubWithWebViewer(); - else - selectLibsFolders(); - - m_gridFpListLibs->SetGridCursor( GetLibsCount()-1, 0 ); - m_gridFpListLibs->SelectRow( GetLibsCount()-1 ); -} - -void WIZARD_FPLIB_TABLE::selectLibsFiles() // select a set of library files -{ - wxString msk = wxT("*.") + m_currLibDescr->m_Ext; - - wxFileDialog dlg( this, _("Select Library Files"), m_currLibDescr->m_DefaultPath, - wxEmptyString, msk, - wxFD_DEFAULT_STYLE|wxFD_FILE_MUST_EXIST|wxFD_MULTIPLE ); - - dlg.ShowModal(); - - wxArrayString filepaths; - dlg.GetPaths( filepaths ); - - // Create the nickname: currently make it from the filename - wxArrayString nicknames; - wxFileName fn; - - for( unsigned ii = 0; ii < filepaths.GetCount(); ii++ ) - { - fn = filepaths[ii]; - nicknames.Add( fn.GetName() ); - - if( m_currLibDescr->m_IsAbsolutePath || m_currLibDescr->m_DefaultPath.IsEmpty() ) - { - filepaths[ii] = fn.GetPathWithSep(); - } - else - { - if( ! fn.MakeRelativeTo( m_currLibDescr->m_DefaultPath ) ) - filepaths[ii] = fn.GetFullPath(); - else - filepaths[ii].Printf( wxT("${%s}%c%s"), - GetChars( m_currLibDescr->m_EnvVarName ), - fn.GetPathSeparator(), - GetChars( fn.GetFullPath() ) ); - } -#ifdef __WINDOWS__ - // We store paths using Unix notation, which also works fine on Windows - filepaths[ii].Replace( wxT("\\"), wxT("/") ); -#endif - } - - populateLibList( nicknames, filepaths, m_currLibDescr->m_PluginName ); - m_gridFpListLibs->AutoSizeColumns(); -} - - -void WIZARD_FPLIB_TABLE::populateLibList( const wxArrayString& aNickNames, - const wxArrayString& aPaths, - const wxString& aPluginName ) -{ - if( aPaths.GetCount() <= 0 ) - return; - - // Ensure there is room for selected libs - int first_row = m_gridFpListLibs->GetTable()->GetRowsCount(); - m_gridFpListLibs->AppendRows( aPaths.GetCount() ); - - // Populates the library list - for( unsigned ii = 0; ii < aPaths.GetCount(); ii++ ) - { - int jj = first_row + ii; - // Add the nickname: currently make it from filename - m_gridFpListLibs->SetCellValue( jj, 0, aNickNames[ii] ); - // Add the full path: - m_gridFpListLibs->SetCellValue( jj, 1, aPaths[ii] ); - // Add the plugin name: - m_gridFpListLibs->SetCellValue( jj, 2, aPluginName ); - m_gridFpListLibs->SetReadOnly( jj, 2, true ); - } - - m_gridFpListLibs->Fit(); -} - - -// A helper dialog to show and select a set of directories -class DIALOG_SELECT_DIRLIST : public DIALOG_SELECT_DIRLIST_BASE -{ -public: - DIALOG_SELECT_DIRLIST( wxWindow* parent, - const wxString& aDefaultPath ): - DIALOG_SELECT_DIRLIST_BASE( parent, wxID_ANY ) - { - if( !aDefaultPath.IsEmpty() ) - m_dirCtrl->SetPath( aDefaultPath ); - - Layout(); - GetSizer()->Fit( this ); - GetSizer()->SetSizeHints(this); - Centre(); - } - - ~DIALOG_SELECT_DIRLIST() {}; - - void GetPaths( wxArrayString& aPaths ) { m_dirCtrl->GetPaths( aPaths ); } -}; - -void WIZARD_FPLIB_TABLE::selectLibsFolders() // select a set of library folders -{ - DIALOG_SELECT_DIRLIST dlg( this, m_currLibDescr->m_DefaultPath ); - - if( dlg.ShowModal() != wxID_OK ) - return; - - wxArrayString filepaths; - - dlg.GetPaths( filepaths ); - - // Create the nickname: currently make it from the filename - wxArrayString nicknames; - wxFileName fn; - - for( unsigned ii = 0; ii < filepaths.GetCount(); ii++ ) - { - fn = filepaths[ii]; - nicknames.Add( fn.GetName() ); - - fn.AssignDir( filepaths[ii] ); - - if( m_currLibDescr->m_IsAbsolutePath || m_currLibDescr->m_DefaultPath.IsEmpty() ) - { - filepaths[ii] = fn.GetFullPath(); - } - else - { - if( ! fn.MakeRelativeTo( m_currLibDescr->m_DefaultPath ) ) - filepaths[ii] = fn.GetFullPath(); - else - filepaths[ii].Printf( wxT("${%s}%c%s"), - GetChars( m_currLibDescr->m_EnvVarName ), - fn.GetPathSeparator(), - GetChars( fn.GetFullPath() ) ); - } -#ifdef __WINDOWS__ - // We store paths using Unix notation, which also works fine on Windows - filepaths[ii].Replace( wxT("\\"), wxT("/") ); -#endif - // Remove trailing path separator, if any. - if( filepaths[ii].EndsWith( wxT("/") ) ) - filepaths[ii].RemoveLast(); - } - - populateLibList( nicknames, filepaths, m_currLibDescr->m_PluginName ); -} - -#ifdef KICAD_USE_WEBKIT - -// A helper function to run the wen viewer (see webviewer.cpp) -extern int RunWebViewer( wxWindow * aParent, const wxString& aUrlOnStart, - wxArrayString* aUrlListSelection = NULL ); -#endif - -void WIZARD_FPLIB_TABLE::selectLibsGithubWithWebViewer() // select a set of library on Github -{ - // A string array to store the URLs selected from the web viewer: - wxArrayString urls; - - // Run the web viewer and open the default URL: the default path - // or our github library repos - wxString defaultURL = m_currLibDescr->m_DefaultPath; - - if( defaultURL.IsEmpty() ) - defaultURL = wxT( "https://github.com/KiCad" ); -#ifdef KICAD_USE_WEBKIT - RunWebViewer( this, defaultURL, &urls ); -#else - // If the Web Viewer is not available, just add a template - // to the fp lib table. - // The user have to edit it - urls.Add( defaultURL + wxT("/newlibname.pretty") ); -#endif - installGithubLibsFromList( urls ); -} - -void WIZARD_FPLIB_TABLE::installGithubLibsFromList( wxArrayString& aUrlList ) -{ - // add the libs found in aUrlList, after calculating a nickname and - // replacing the path by an env variable, if needed - // Create the nickname: currently make it from the url - wxArrayString filepaths; - wxArrayString nicknames; - - for( unsigned ii = 0; ii < aUrlList.GetCount(); ii++ ) - { - wxString urlstring( aUrlList[ii] ); - - wxURI uri( urlstring ); - - // We cannot use wxURL to test the validity of the url, because - // wxURL does not know https protocol we are using, and aways returns - // error for URLs starting by https. Hope this test is enough - if( uri.HasPath() ) - nicknames.Add( uri.GetPath().AfterLast( '/').BeforeLast( '.' ) ); - else - continue; // Should not happen: bad URL - - if( m_currLibDescr->m_IsAbsolutePath || - m_currLibDescr->m_DefaultPath.IsEmpty() ) - { - filepaths.Add( aUrlList[ii] ); // use the full URL - } - else - { - wxString shortURI; - if( aUrlList[ii].Lower().StartsWith( - m_currLibDescr->m_DefaultPath.Lower(), &shortURI ) ) - { - shortURI.Prepend( wxT("${") + m_currLibDescr->m_EnvVarName + wxT("}") ); - filepaths.Add( shortURI ); - } - else // keep the full URL - filepaths.Add( aUrlList[ii] ); // use the full URL - } - } - - populateLibList( nicknames, filepaths, m_currLibDescr->m_PluginName ); -} - - -void WIZARD_FPLIB_TABLE::OnRemoveFpLibs( wxCommandEvent& event ) -{ - wxArrayInt selectedRows = m_gridFpListLibs->GetSelectedRows(); - int row_cursor = m_gridFpListLibs->GetGridCursorRow(); - - if( selectedRows.size() == 0 && row_cursor >= 0 ) - selectedRows.Add( row_cursor ); - - std::sort( selectedRows.begin(), selectedRows.end() ); - - for( int ii = selectedRows.GetCount()-1; ii >= 0; ii-- ) - { - int row = selectedRows[ii]; - m_gridFpListLibs->DeleteRows( row, 1 ); - } - - m_gridFpListLibs->SelectRow( m_gridFpListLibs->GetGridCursorRow() ); -} - #ifdef BUILD_GITHUB_PLUGIN -#include <../github/github_getliblist.h> - -void WIZARD_FPLIB_TABLE::OnGithubLibsList( wxCommandEvent& event ) -{ - wxArrayString liblist; - getLibsListGithub( liblist ); - - if( liblist.GetCount() == 0 ) // No lib selected - return; - - if( IsKicadPlugin() ) - { - wxString msg; - - if( !downloadGithubLibsFromList( liblist, &msg ) ) - { - wxMessageBox( msg ); - return; - } - } - else - installGithubLibsFromList( liblist ); -} - void WIZARD_FPLIB_TABLE::getLibsListGithub( wxArrayString& aList ) { wxBeginBusyCursor(); // Be sure there is no trailing '/' at the end of the repo name wxString git_url = m_textCtrlGithubURL->GetValue(); - if( git_url.EndsWith( wxT("/" ) ) ) + + if( git_url.EndsWith( wxT( "/" ) ) ) { git_url.RemoveLast(); m_textCtrlGithubURL->SetValue( git_url ); } GITHUB_GETLIBLIST getter( git_url ); - - wxArrayString fullList; - getter.GetLibraryList( fullList ); + getter.GetLibraryList( aList ); wxEndBusyCursor(); - - wxArrayInt choices; - wxString msg( _( "Urls detected as footprint .pretty libraries.\n" - "Selected urls will be added to the current footprint library list" ) ); - - if( wxGetSelectedChoices( choices, msg, - _( "Footprint libraries" ), fullList, this ) <= 0 ) - return; - - // Add selected url in list - for( unsigned ii = 0; ii < choices.GetCount(); ii++ ) - { - wxString& url = fullList[choices[ii]]; - aList.Add( url ); - } } // Download the .pretty libraries found in aUrlLis and store them on disk // in a master folder bool WIZARD_FPLIB_TABLE::downloadGithubLibsFromList( wxArrayString& aUrlList, - wxString * aErrorMessage ) + wxString* aErrorMessage ) { - wxString masterFolder; - wxString default_path; - wxGetEnv( FP_LIB_TABLE::GlobalPathEnvVariableName(), &default_path ); - - masterFolder = wxDirSelector( _("Choose Folder to Copy Downloaded '.pretty' Libraries" ), - default_path, 0, wxDefaultPosition, this ); - - if( masterFolder.IsEmpty() ) // Aborted by user - { - if( aErrorMessage ) - *aErrorMessage = _( "Aborted" ); - - return false; - } - - if( !wxDirExists( masterFolder ) ) - { - if( aErrorMessage ) - aErrorMessage->Printf( _( "Folder '%s' does not exists" ), - GetChars( masterFolder ) ); - - return false; - } - // Display a progress bar to show the downlaod state - wxProgressDialog pdlg( _("Download libraries"), wxEmptyString, aUrlList.GetCount() ); + wxProgressDialog pdlg( _( "Downloading libraries" ), wxEmptyString, aUrlList.GetCount() ); // Download libs: for( unsigned ii = 0; ii < aUrlList.GetCount(); ii++ ) @@ -924,13 +604,13 @@ bool WIZARD_FPLIB_TABLE::downloadGithubLibsFromList( wxArrayString& aUrlList, wxURI url( libsrc_name ); wxFileName fn( url.GetPath() ); // Set our local path - fn.SetPath( masterFolder ); + fn.SetPath( getDownloadDir() ); libdst_name = fn.GetFullPath(); if( !wxDirExists( libdst_name ) ) wxMkdir( libdst_name ); - pdlg.Update( ii, libsrc_name); + pdlg.Update( ii, libsrc_name ); try { @@ -949,7 +629,7 @@ bool WIZARD_FPLIB_TABLE::downloadGithubLibsFromList( wxArrayString& aUrlList, catch( const IO_ERROR& ioe ) { if( aErrorMessage ) - aErrorMessage->Printf( _("Error:\n'%s'\nwhile downloading library:\n'%s'"), + aErrorMessage->Printf( _( "Error:\n'%s'\nwhile downloading library:\n'%s'" ), GetChars( ioe.errorText ), GetChars( libsrc_name ) ); return false; } @@ -957,5 +637,190 @@ bool WIZARD_FPLIB_TABLE::downloadGithubLibsFromList( wxArrayString& aUrlList, return true; } +#endif /* BUILD_GITHUB_PLUGIN */ + + +void WIZARD_FPLIB_TABLE::updateGithubControls() +{ +#ifndef BUILD_GITHUB_PLUGIN + m_radioAddGithub->Enable( false ); #endif + // Disable inputs that have no meaning for the selected source + bool githubEnabled = ( GetLibSource() == GITHUB ); + m_textCtrlGithubURL->Enable( githubEnabled ); + m_downloadGithub->Enable( githubEnabled ); + m_downloadDir->Enable( githubEnabled && wantLocalCopy() ); + m_btnBrowse->Enable( githubEnabled && wantLocalCopy() ); + + bool valid = !( githubEnabled && wantLocalCopy() ) || wxFileName::IsDirWritable( getDownloadDir() ); + + // Do not allow to go further unless there is a valid directory selected + m_invalidDir->Show( !valid ); + enableNext( valid ); +} + + +void WIZARD_FPLIB_TABLE::updateLibraries() +{ + // No need to update, the review list is ready + if( m_listCtrlReview->GetItemCount() != 0 ) + return; + + switch( GetLibSource() ) + { + case LOCAL: + { + wxArrayString libs; + m_filePicker->GetPaths( libs ); + + // Workaround, when you change filters "/" is automatically selected + int slash_index = libs.Index( "/", true, true ); + if( slash_index != wxNOT_FOUND ) + libs.RemoveAt( slash_index, 1 ); + + m_libraries.reserve( libs.GetCount() ); + + for( unsigned int i = 0; i < libs.GetCount(); ++i ) + m_libraries.push_back( libs[i] ); + } + break; + + case GITHUB: + { + wxArrayInt checkedLibs; + m_checkListGH->GetCheckedItems( checkedLibs ); + + m_libraries.reserve( checkedLibs.GetCount() ); + + for( unsigned int i = 0; i < checkedLibs.GetCount(); ++i ) + m_libraries.push_back( GetGithubURL() + "/" + m_checkListGH->GetString( checkedLibs[i] ) ); + } + break; + + default: + wxASSERT( false ); + break; + } +} + + +void WIZARD_FPLIB_TABLE::setupDialogOrder() +{ + // Alternate the wizard pages flow depending on the selected option + switch( GetLibSource() ) + { + case LOCAL: + m_welcomeDlg->SetNext( m_fileSelectDlg ); + m_fileSelectDlg->SetPrev( m_welcomeDlg ); + + m_fileSelectDlg->SetNext( m_reviewDlg ); + m_reviewDlg->SetPrev( m_fileSelectDlg ); + break; + + case GITHUB: + m_welcomeDlg->SetNext( m_githubListDlg ); + m_githubListDlg->SetPrev( m_welcomeDlg ); + + m_githubListDlg->SetNext( m_reviewDlg ); + m_reviewDlg->SetPrev( m_githubListDlg ); + break; + + default: + wxASSERT( false ); + break; + } +} + + +void WIZARD_FPLIB_TABLE::setupGithubList() +{ + // Enable 'Next' only if there is at least one library selected + wxArrayInt checkedIndices; + m_checkListGH->GetCheckedItems( checkedIndices ); + enableNext( checkedIndices.GetCount() > 0 ); + + // Update only if necessary + if( m_githubLibs.GetCount() == 0 ) + getLibsListGithub( m_githubLibs ); + + m_searchCtrlGH->Clear(); + + // Clear the review list so it will be reloaded + m_libraries.clear(); + m_listCtrlReview->DeleteAllItems(); +} + + +void WIZARD_FPLIB_TABLE::setupFileSelect() +{ + // Disable the button until something is selected + enableNext( checkFiles() ); + + // Clear the review list so it will be reloaded + m_libraries.clear(); + m_listCtrlReview->DeleteAllItems(); +} + + +void WIZARD_FPLIB_TABLE::setupReview() +{ + wxBeginBusyCursor(); + updateLibraries(); + + int libTotalCount = m_libraries.size(); + int libCount = 0; + bool validate = true; + wxProgressDialog progressDlg( _( "Please wait..." ), _( "Validating libraries" ), + libTotalCount, this, + wxPD_APP_MODAL | wxPD_CAN_ABORT | wxPD_AUTO_HIDE ); + + m_dvLibName->SetWidth( 280 ); + + // Prepare the review list + m_listCtrlReview->DeleteAllItems(); + + for( std::vector::iterator it = m_libraries.begin(); it != m_libraries.end(); ++it ) + { + wxVector row; + LIBRARY::STATUS status = it->GetStatus(); + + // Check if the library contents is valid + if( status == LIBRARY::NOT_CHECKED && validate ) + { + it->Test(); + status = it->GetStatus(); + } + + row.push_back( wxVariant( it->GetDescription() ) ); + + switch( it->GetStatus() ) + { + case LIBRARY::NOT_CHECKED: + row.push_back( wxVariant( _( "NOT CHECKED" ) ) ); + break; + + case LIBRARY::OK: + row.push_back( wxVariant( _( "OK" ) ) ); + break; + + case LIBRARY::INVALID: + row.push_back( wxVariant( _( "INVALID" ) ) ); + break; + } + + row.push_back( wxVariant( it->GetPluginName() ) ); + + m_listCtrlReview->AppendItem( row ); + + ++libCount; + if( !progressDlg.Update( libCount, wxString::Format( _( "Validating libraries %d/%d" ), + libCount, libTotalCount ) ) ) + validate = false; + } + + // The list should never be empty, but who knows? + enableNext( m_listCtrlReview->GetItemCount() > 0 ); + + wxEndBusyCursor(); +} diff --git a/pcbnew/dialogs/wizard_add_fplib.h b/pcbnew/dialogs/wizard_add_fplib.h index 867d544bf3..a162569d1f 100644 --- a/pcbnew/dialogs/wizard_add_fplib.h +++ b/pcbnew/dialogs/wizard_add_fplib.h @@ -1,12 +1,10 @@ -/** - * @file wizard_add_fplib.h - */ - /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 1992-2014 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2015 CERN + * @author Maciej Suminski + * Copyright (C) 2014-2015 Jean-Pierre Charras, jp.charras at wanadoo.fr + * Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -26,230 +24,254 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include -#include #include +#include +#include -// A helper class to handle the different types of lib depending -// on the plugin: ext, type of lib: files/folders ... and info -// needed to populate the main fp lib table -class LIB_DESCR -{ -public: - wxString m_PluginName; // The "official" name of the plugin (see fp lib table dialog) - wxString m_Ext; // standard extension (.mod, .pretty ...) - wxString m_EnvVarName; // the environment var if selected, or empty - wxString m_DefaultPath; - bool m_IsAbsolutePath; // true if absolue path is selected - bool m_IsFile; // true for libs which are single files, - // false for libs which are directories containing footprints - bool m_IsGitHub; // true only for GitHub plugin - - LIB_DESCR() - { - m_IsAbsolutePath = true; - m_IsFile = true; - m_IsGitHub = false; - } -}; - +class KIWAY_PLAYER; class WIZARD_FPLIB_TABLE : public WIZARD_FPLIB_TABLE_BASE { - int m_rowPrjEnvVarPosition; // the row of the PROJECT_VAR_NAME - int m_predefinedEnvVarCnt; // number of predefined env var when calling the wizard - // at least 3 are always defined - LIB_DESCR * m_currLibDescr; - - // static members to store options during a session - static int m_last_plugin_choice; - static int m_last_defaultpath_choice; - - // This enum must have the same order than m_rbPathManagement - enum OPT_PATH { - PROJECT_PATH, - ENV_VAR_PATH, - ABSOLUTE_PATH - }; - - // This enum must have the same order than m_rbFpLibFormat - enum OPT_PLUGIN { - KICAD_PLUGIN, - GITHUB_PLUGIN, - LEGACY_PLUGIN, - EAGLE_PLUGIN, - GEDA_PCB_PLUGIN - }; - public: - WIZARD_FPLIB_TABLE( wxWindow* aParent, wxArrayString& aEnvVariableList ); - wxWizardPage* GetFirstPage() { return m_pages[0]; } - + WIZARD_FPLIB_TABLE( wxWindow* aParent ); ~WIZARD_FPLIB_TABLE(); + ///> Source of the libraries (local files or Github) + enum LIB_SOURCE { LOCAL, GITHUB }; + + ///> Scope (global/project) + enum LIB_SCOPE { GLOBAL = 1, PROJECT = 2 }; + /** - * Return info on lib at line aIdx in aLibDescr - * @param aLibDescr = a wxArrayString to return the nickname, the lib URI and the lin type - * @return true if aIdx lin exists + * Function GetFirstPage + * Returns the welcoming page for the wizard. */ - bool GetLibDescr( int aIdx, wxArrayString& aLibDescr ) + inline wxWizardPage* GetFirstPage() const { - int count = m_gridFpListLibs->GetTable()->GetRowsCount(); - - if( aIdx >= count ) - return false; - - // Return info - // Add the nickname: - aLibDescr.Add( m_gridFpListLibs->GetCellValue( aIdx, 0 ) ); - // Add the full path: - aLibDescr.Add( m_gridFpListLibs->GetCellValue( aIdx, 1 ) ); - // Add the plugin name: - aLibDescr.Add( m_gridFpListLibs->GetCellValue( aIdx, 2 ) ); - - return true; + return m_welcomeDlg; } -private: - void initDlg( wxArrayString& aEnvVariableList ); - wxString getSelectedEnvVar(); // return the selected env variable - wxString getSelectedEnvVarValue(); // return the selected env variable value - bool setSecondPage(); // Init prms for the second wizard page - bool setLastPage(); // Init prms for the last wizard page - void selectLibsFiles(); // select a set of library files - void selectLibsFolders(); // select a set of library folders - - /** select a set of library on Github, using the Web viewer to explore - * the repos + /** + * Function GetGithubURL + * Returns the current Github repository URL set in the wizard. */ - void selectLibsGithubWithWebViewer(); + inline wxString GetGithubURL() const + { + return m_textCtrlGithubURL->GetValue(); + } - /** Get the list of .pretty libraries on Github, - * without using the viewer, from the lib list extracted from the KiCad repos + /** + * Function SetGithubURL + * Sets the current Github repository URL used by the wizard. + * @param aUrl is the new URL to be applied. */ + inline void SetGithubURL( const wxString& aUrl ) + { + m_textCtrlGithubURL->SetValue( aUrl ); + } + + /** + * Function GetLibSource + * Returns the source of libraries (local / Github). + */ + LIB_SOURCE GetLibSource() const; + + /** + * Function GetLibScope + * Returns the scope for the added libraries (global / project specific). + */ + LIB_SCOPE GetLibScope() const; + + // Wizard event handlers + void OnSourceCheck( wxCommandEvent& aEvent ); + void OnSelectFiles( wxCommandEvent& aEvent ); + void OnCheckGithubList( wxCommandEvent& aEvent ); + void OnPageChanged( wxWizardEvent& aEvent ); + void OnSelectAllGH( wxCommandEvent& aEvent ); + void OnUnselectAllGH( wxCommandEvent& aEvent ); + void OnChangeSearch( wxCommandEvent& aEvent ); + void OnWizardFinished( wxWizardEvent& aEvent ); + void OnBrowseButtonClick( wxCommandEvent& aEvent ); + void OnCheckSaveCopy( wxCommandEvent& aEvent ); + + class LIBRARY + { + public: + LIBRARY( const wxString& aPath, const wxString& aDescription = wxEmptyString ); + ~LIBRARY() + { + std::cout << "destroyed " << this << std::endl; + } + + ///> Possible states of validation. + enum STATUS { OK, INVALID, NOT_CHECKED }; + + /** + * Function Test + * Uses the associated plugin to validate the library contents. + * @return True if the library and the matched plugin type are valid. + */ + bool Test(); + + /** + * Function GetPluginType + * Returns the plugin type, autodetected basing on the path. + * @return Returns empty boost::optional if the type could not be autodetected. + */ + inline boost::optional GetPluginType() const + { + return m_plugin; + } + + /** + * Function GetPluginName + * Returns the plugin name, as used in the FPLIB table editor. + */ + wxString GetPluginName() const; + + /** + * Function GetAbsolutePath + * Returns the absolute path for the library. + */ + inline const wxString& GetAbsolutePath() const + { + return m_path; + } + + /** + * Function GetRelativePath + * Returns the relative path, based on the input path with the base part replaced. + * @param aBase is the base for the relative path. + * @param aSubstitution is the string to be replace the base path. + * @return Adjusted path if possible, or the absolute path when it is not possible. + */ + wxString GetRelativePath( const wxString& aBase, const wxString& aSubstitution = wxEmptyString ) const; + + /** + * Function GetAutoPath + * Returns path that is either absolute or related to KISYSMOD/KIPRJMOD if the files + * are stored within one of the mentioned paths. + * @param aScoep is the scope for the library. It determines the environmental variables + * that are used to check the path (GLOBAL scope checks only KISYSMOD, while PROJECT + * scope checks both KISYSMOD & KIPRJMOD). + */ + wxString GetAutoPath( LIB_SCOPE aScope ) const; + + /** + * Function GetDescription + * Returns the description for the library. If it is not specified in the constructor, + * it is just the filename. + */ + wxString GetDescription() const; + + /** + * Function GetStatus + * Returns the validity status for the library. It requires running Test() before, to get + * a result different than NOT_CHECKED. + */ + STATUS GetStatus() const + { + return m_status; + } + + protected: + inline void setPath( const wxString& aPath ) + { + m_path = aPath; + } + + inline void setPluginType( IO_MGR::PCB_FILE_T aType ) + { + m_plugin = aType; + } + + /** + * Function replaceEnv + * replaces path with environmental variable if applicable. + * @param aEnvVar is the environmental variable that should be substituted. + * @param aFilePath determines if the path is a file path (contrary to e.g. http address). + */ + wxString replaceEnv( const wxString& aEnvVar, bool aFilePath = true ) const; + + wxString m_path; + wxString m_description; + boost::optional m_plugin; + STATUS m_status; + + friend class WIZARD_FPLIB_TABLE; + }; + + /** + * Function GetLibraries + * Returns libraries selected by the user. + */ + const std::vector& GetLibraries() const + { + return m_libraries; + } + + +protected: + // Initialization of wizard pages + void setupDialogOrder(); + void setupGithubList(); + void setupFileSelect(); + void setupReview(); + + ///> Checks the selection in file picker + bool checkFiles() const; + + ///> Sets the target directory for libraries downloaded from Github + void setDownloadDir( const wxString& aDir ) + { + m_downloadDir->SetLabel( aDir ); + } + + ///> Gets the current target for downloaded libraries + inline wxString getDownloadDir() + { + return m_downloadDir->GetLabel(); + } + + ///> Downloads the list of Github libraries void getLibsListGithub( wxArrayString& aList ); - /** Helper function. - * add the .pretty libraries found in aUrlList, after calculating a nickname and - * replacing the path by an env variable, if allowed and possible - */ - void installGithubLibsFromList( wxArrayString& aUrlList ); + ///> Saves a list of Github libraries locally. + bool downloadGithubLibsFromList( wxArrayString& aUrlList, wxString* aErrorMessage ); - /** - * Download the .pretty libraries found in aUrlLis and store them on disk - * in a master folder - * @return true if OK, false on error - * @param aUrlList is the list of Github .pretty libs to download - * @param aErrorMessage is a wxString pointer to store error messages if any. - */ - bool downloadGithubLibsFromList( wxArrayString& aUrlList, wxString * aErrorMessage = NULL ); + ///> Does the user want a local copy of Github libraries? + inline bool wantLocalCopy() const { return m_downloadGithub->GetValue(); } - void updateFromPlugingChoice(); // update dialog options and widgets - // depending on the plugin choice - int GetEnvVarCount() // Get the number of rows in env var table + ///> Enables Github widgets depending on the selected options. + void updateGithubControls(); + + ///> Updates m_libraries basing on dialogs contents + void updateLibraries(); + + ///> Enables/disable 'Next' button + inline void enableNext( bool aEnable ) { - return m_gridEnvironmentVariablesList->GetTable()->GetRowsCount(); + wxWindow* nextBtn = FindWindowById( wxID_FORWARD ); + + if( nextBtn ) + nextBtn->Enable( aEnable ); } - int GetLibsCount() // Get the number of rows in libs table - { - return m_gridFpListLibs->GetTable()->GetRowsCount(); - } + ///> Cache for the downloaded Github library list + wxArrayString m_githubLibs; - bool IsGithubPlugin() // Helper funct, return true if - { // the Github plugin is the choice - return m_rbFpLibFormat->GetSelection() == GITHUB_PLUGIN; - } + ///> Libraries selected in the wizard + std::vector m_libraries; + // Aliases for wizard pages to make code more readable + wxWizardPageSimple* const m_welcomeDlg; + wxWizardPageSimple* const m_fileSelectDlg; + wxWizardPageSimple* const m_githubListDlg; + wxWizardPageSimple* const m_reviewDlg; + wxWizardPageSimple* const m_targetDlg; - bool IsKicadPlugin() // Helper funct, return true if - { // the Kicad plugin is the choice - return m_rbFpLibFormat->GetSelection() == KICAD_PLUGIN; - } - - int HasGithubEnvVarCompatible(); // Return the first index to one env var - // which defines a url compatible github - // or -1 if not found - - // Populate the library list with the currently selected libs - void populateLibList( const wxArrayString& aNickNames, - const wxArrayString& aPaths, - const wxString& aPluginName ); - - // Virtual event functions, from WIZARD_FPLIB_TABLE_BASE - void OnFinish( wxWizardEvent& event ) { event.Skip(); } - void OnPageChanged( wxWizardEvent& event ); - void OnPageChanging( wxWizardEvent& event ); - void OnAddEVariable( wxCommandEvent& event ); - void OnRemoveEVariable( wxCommandEvent& event ); - void OnAddFpLibs( wxCommandEvent& event ); - void OnRemoveFpLibs( wxCommandEvent& event ); - void OnPathManagementSelection( wxCommandEvent& event ); - void OnSelectEnvVarCell( wxGridEvent& event ); - void OnPluginSelection( wxCommandEvent& event ); -#ifdef BUILD_GITHUB_PLUGIN - void OnGithubLibsList( wxCommandEvent& event ); -#endif - bool ValidateOptions(); + // Since the same event is used for changing the selection/filter type, we need a way to + // determine what's the real cause of the event. Therefore here we store the number of the + // selected file type filter. + int m_selectedFilter; }; - - -// Specialized helper classes to handle the different plugin types: -class LIB_DESCR_KICAD: public LIB_DESCR -{ -public: - LIB_DESCR_KICAD(): LIB_DESCR() - { - m_PluginName = IO_MGR::ShowType( IO_MGR::KICAD ); - m_Ext = wxT("pretty"); - m_IsFile = false; - } -}; - - -class LIB_DESCR_GITHUB: public LIB_DESCR -{ -public: - LIB_DESCR_GITHUB(): LIB_DESCR() - { - m_PluginName = IO_MGR::ShowType( IO_MGR::GITHUB ); - m_Ext = wxT("pretty"); - m_IsFile = false; - m_IsGitHub = true; - } -}; - -class LIB_DESCR_LEGACY: public LIB_DESCR -{ -public: - LIB_DESCR_LEGACY(): LIB_DESCR() - { - m_PluginName = IO_MGR::ShowType( IO_MGR::LEGACY ); - m_Ext = wxT("mod"); - } -}; - - -class LIB_DESCR_EAGLE: public LIB_DESCR -{ -public: - LIB_DESCR_EAGLE(): LIB_DESCR() - { - m_PluginName = IO_MGR::ShowType( IO_MGR::EAGLE ); - m_Ext = wxT("lbr"); - m_IsFile = true; - } -}; - - -class LIB_DESCR_GEDA: public LIB_DESCR -{ -public: - // No specific extension known for folders - LIB_DESCR_GEDA(): LIB_DESCR() - { - m_PluginName = IO_MGR::ShowType( IO_MGR::GEDA_PCB ); - m_IsFile = false; - } -}; - diff --git a/pcbnew/dialogs/wizard_add_fplib_base.cpp b/pcbnew/dialogs/wizard_add_fplib_base.cpp index 4253ee3ad4..718d1f531d 100644 --- a/pcbnew/dialogs/wizard_add_fplib_base.cpp +++ b/pcbnew/dialogs/wizard_add_fplib_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jun 5 2014) +// C++ code generated with wxFormBuilder (version Mar 9 2015) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -12,210 +12,221 @@ WIZARD_FPLIB_TABLE_BASE::WIZARD_FPLIB_TABLE_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxBitmap& bitmap, const wxPoint& pos, long style ) { this->Create( parent, id, title, bitmap, pos, style ); - this->SetSizeHints( wxSize( 450,-1 ), wxDefaultSize ); + this->SetSizeHints( wxSize( 720,480 ), wxDefaultSize ); - wxWizardPageSimple* m_wizPage1 = new wxWizardPageSimple( this ); + wxWizardPageSimple* m_wizPage1 = new wxWizardPageSimple( this, NULL, NULL, wxArtProvider::GetBitmap( wxART_HELP_BOOK, wxART_FRAME_ICON ) ); m_pages.Add( m_wizPage1 ); - m_wizPage1->SetMinSize( wxSize( 500,-1 ) ); + m_wizPage1->SetMinSize( wxSize( 720,480 ) ); - wxBoxSizer* bSizerPage1; - bSizerPage1 = new wxBoxSizer( wxVERTICAL ); + wxBoxSizer* bSizer1; + bSizer1 = new wxBoxSizer( wxVERTICAL ); - wxString m_rbFpLibFormatChoices[] = { _("KiCad (*.Pretty folder containing .kicad_mod files)"), _("GitHub (.Pretty lib stored on GitHub repos)"), _("Legacy ( old *.mod lib file)"), _("Eagle V6 xml library file"), _("Geda footprint folder (folder containing *.fp files)") }; - int m_rbFpLibFormatNChoices = sizeof( m_rbFpLibFormatChoices ) / sizeof( wxString ); - m_rbFpLibFormat = new wxRadioBox( m_wizPage1, wxID_ANY, _("Library Format:"), wxDefaultPosition, wxDefaultSize, m_rbFpLibFormatNChoices, m_rbFpLibFormatChoices, 1, wxRA_SPECIFY_COLS ); - m_rbFpLibFormat->SetSelection( 0 ); - bSizerPage1->Add( m_rbFpLibFormat, 0, wxALL|wxEXPAND, 5 ); + wxFlexGridSizer* fgSizer112; + fgSizer112 = new wxFlexGridSizer( 3, 1, 0, 0 ); + fgSizer112->AddGrowableRow( 1 ); + fgSizer112->SetFlexibleDirection( wxBOTH ); + fgSizer112->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - m_staticline2 = new wxStaticLine( m_wizPage1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); - bSizerPage1->Add( m_staticline2, 0, wxEXPAND | wxALL, 5 ); - - m_bitmapGithubURL = new wxStaticBitmap( m_wizPage1, wxID_ANY, wxArtProvider::GetBitmap( wxART_INFORMATION, wxART_OTHER ), wxDefaultPosition, wxDefaultSize, 0 ); - bSizerPage1->Add( m_bitmapGithubURL, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 ); - - m_staticText10 = new wxStaticText( m_wizPage1, wxID_ANY, _("Default URL for KiCad libraries on Github:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText10->Wrap( -1 ); - bSizerPage1->Add( m_staticText10, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); - - m_textCtrlGithubURL = new wxTextCtrl( m_wizPage1, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - bSizerPage1->Add( m_textCtrlGithubURL, 0, wxALL|wxEXPAND, 5 ); - - - m_wizPage1->SetSizer( bSizerPage1 ); - m_wizPage1->Layout(); - bSizerPage1->Fit( m_wizPage1 ); - wxWizardPageSimple* m_wizPage2 = new wxWizardPageSimple( this ); - m_pages.Add( m_wizPage2 ); - - m_wizPage2->SetMinSize( wxSize( 450,-1 ) ); - - wxBoxSizer* bSizerPage2; - bSizerPage2 = new wxBoxSizer( wxVERTICAL ); - - wxString m_rbPathManagementChoices[] = { _("Use path relative to the project"), _("Use environment variable in path"), _("Use absolute path") }; - int m_rbPathManagementNChoices = sizeof( m_rbPathManagementChoices ) / sizeof( wxString ); - m_rbPathManagement = new wxRadioBox( m_wizPage2, wxID_ANY, _("Path management:"), wxDefaultPosition, wxDefaultSize, m_rbPathManagementNChoices, m_rbPathManagementChoices, 1, wxRA_SPECIFY_COLS ); - m_rbPathManagement->SetSelection( 2 ); - bSizerPage2->Add( m_rbPathManagement, 0, wxALL|wxEXPAND, 5 ); - - m_staticText1 = new wxStaticText( m_wizPage2, wxID_ANY, _("Environment variables:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText1 = new wxStaticText( m_wizPage1, wxID_ANY, wxT("Welcome to the Add Footprint Libraries Wizard!\n\nPlease select the source for the libraries to add:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText1->Wrap( -1 ); - bSizerPage2->Add( m_staticText1, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); + fgSizer112->Add( m_staticText1, 1, wxALL|wxEXPAND, 5 ); - m_gridEnvironmentVariablesList = new wxGrid( m_wizPage2, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); + wxBoxSizer* bSizer19; + bSizer19 = new wxBoxSizer( wxVERTICAL ); - // Grid - m_gridEnvironmentVariablesList->CreateGrid( 3, 2 ); - m_gridEnvironmentVariablesList->EnableEditing( true ); - m_gridEnvironmentVariablesList->EnableGridLines( true ); - m_gridEnvironmentVariablesList->EnableDragGridSize( false ); - m_gridEnvironmentVariablesList->SetMargins( 0, 0 ); + m_radioAddLocal = new wxRadioButton( m_wizPage1, wxID_ANY, wxT("Files on my computer"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer19->Add( m_radioAddLocal, 0, wxALL|wxEXPAND, 5 ); - // Columns - m_gridEnvironmentVariablesList->SetColSize( 0, 125 ); - m_gridEnvironmentVariablesList->SetColSize( 1, 154 ); - m_gridEnvironmentVariablesList->AutoSizeColumns(); - m_gridEnvironmentVariablesList->EnableDragColMove( false ); - m_gridEnvironmentVariablesList->EnableDragColSize( true ); - m_gridEnvironmentVariablesList->SetColLabelSize( 30 ); - m_gridEnvironmentVariablesList->SetColLabelValue( 0, _("Environment Variable") ); - m_gridEnvironmentVariablesList->SetColLabelValue( 1, _("Path Segment") ); - m_gridEnvironmentVariablesList->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); - - // Rows - m_gridEnvironmentVariablesList->AutoSizeRows(); - m_gridEnvironmentVariablesList->EnableDragRowSize( false ); - m_gridEnvironmentVariablesList->SetRowLabelSize( 40 ); - m_gridEnvironmentVariablesList->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); - - // Label Appearance - - // Cell Defaults - m_gridEnvironmentVariablesList->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); - bSizerPage2->Add( m_gridEnvironmentVariablesList, 1, wxALL|wxEXPAND, 5 ); - - wxBoxSizer* bSizerButs; - bSizerButs = new wxBoxSizer( wxHORIZONTAL ); - - m_buttonAddEV = new wxButton( m_wizPage2, wxID_ANY, _("Add Environment Variable"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizerButs->Add( m_buttonAddEV, 0, wxALL, 5 ); - - m_buttonRemoveEV = new wxButton( m_wizPage2, wxID_ANY, _("Remove Environment Variable"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizerButs->Add( m_buttonRemoveEV, 0, wxALL, 5 ); + wxBoxSizer* m_sizerGithub; + m_sizerGithub = new wxBoxSizer( wxHORIZONTAL ); - bSizerPage2->Add( bSizerButs, 0, wxALIGN_CENTER_HORIZONTAL, 5 ); + bSizer19->Add( m_sizerGithub, 0, wxEXPAND, 5 ); + + wxGridSizer* gSizer1; + gSizer1 = new wxGridSizer( 2, 2, 0, 0 ); - m_wizPage2->SetSizer( bSizerPage2 ); - m_wizPage2->Layout(); - bSizerPage2->Fit( m_wizPage2 ); - wxWizardPageSimple* m_wizPage3 = new wxWizardPageSimple( this ); - m_pages.Add( m_wizPage3 ); + bSizer19->Add( gSizer1, 0, wxEXPAND, 5 ); - m_wizPage3->SetMinSize( wxSize( 450,-1 ) ); + wxFlexGridSizer* m_githubSizer; + m_githubSizer = new wxFlexGridSizer( 0, 2, 0, 0 ); + m_githubSizer->SetFlexibleDirection( wxBOTH ); + m_githubSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - wxBoxSizer* bSizerPage3; - bSizerPage3 = new wxBoxSizer( wxVERTICAL ); + m_radioAddGithub = new wxRadioButton( m_wizPage1, wxID_ANY, wxT("Github repository"), wxDefaultPosition, wxDefaultSize, 0 ); + m_githubSizer->Add( m_radioAddGithub, 0, wxALL|wxEXPAND, 5 ); - wxStaticBoxSizer* sbSizer1; - sbSizer1 = new wxStaticBoxSizer( new wxStaticBox( m_wizPage3, wxID_ANY, _("Options") ), wxVERTICAL ); + m_textCtrlGithubURL = new wxTextCtrl( m_wizPage1, wxID_ANY, wxT("http://github.com/KiCad"), wxDefaultPosition, wxDefaultSize, 0 ); + m_textCtrlGithubURL->SetMinSize( wxSize( 300,-1 ) ); - wxFlexGridSizer* fgSizer1; - fgSizer1 = new wxFlexGridSizer( 0, 2, 0, 0 ); - fgSizer1->AddGrowableCol( 1 ); - fgSizer1->SetFlexibleDirection( wxBOTH ); - fgSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - - m_textPluginTitle = new wxStaticText( m_wizPage3, wxID_ANY, _("Plugin type:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_textPluginTitle->Wrap( -1 ); - fgSizer1->Add( m_textPluginTitle, 0, wxALL, 5 ); - - m_textPluginType = new wxStaticText( m_wizPage3, wxID_ANY, _("KiCad"), wxDefaultPosition, wxDefaultSize, 0 ); - m_textPluginType->Wrap( -1 ); - fgSizer1->Add( m_textPluginType, 1, wxALL, 5 ); - - m_textOptionTitle = new wxStaticText( m_wizPage3, wxID_ANY, _("Option:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_textOptionTitle->Wrap( -1 ); - fgSizer1->Add( m_textOptionTitle, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - - m_textOption = new wxStaticText( m_wizPage3, wxID_ANY, _("dummy"), wxDefaultPosition, wxDefaultSize, 0 ); - m_textOption->Wrap( -1 ); - fgSizer1->Add( m_textOption, 1, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - - m_stPathTitle = new wxStaticText( m_wizPage3, wxID_ANY, _("Path:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_stPathTitle->Wrap( -1 ); - fgSizer1->Add( m_stPathTitle, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - - m_textPath = new wxStaticText( m_wizPage3, wxID_ANY, _("dummy"), wxDefaultPosition, wxDefaultSize, 0 ); - m_textPath->Wrap( -1 ); - fgSizer1->Add( m_textPath, 1, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + m_githubSizer->Add( m_textCtrlGithubURL, 1, wxALL|wxEXPAND, 5 ); - sbSizer1->Add( fgSizer1, 0, wxEXPAND, 5 ); + m_githubSizer->Add( 0, 0, 1, wxEXPAND, 5 ); + + m_downloadGithub = new wxCheckBox( m_wizPage1, wxID_ANY, wxT("Save a local copy to:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_downloadGithub->SetValue(true); + m_githubSizer->Add( m_downloadGithub, 0, wxALL, 5 ); - bSizerPage3->Add( sbSizer1, 0, wxEXPAND|wxBOTTOM, 5 ); + m_githubSizer->Add( 0, 0, 1, wxEXPAND, 5 ); - m_staticText2 = new wxStaticText( m_wizPage3, wxID_ANY, _("Library list to add in Fp table:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText2->Wrap( -1 ); - bSizerPage3->Add( m_staticText2, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); + wxBoxSizer* bSizer9; + bSizer9 = new wxBoxSizer( wxHORIZONTAL ); - wxBoxSizer* bSizer6; - bSizer6 = new wxBoxSizer( wxVERTICAL ); + m_downloadDir = new wxStaticText( m_wizPage1, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_downloadDir->Wrap( -1 ); + m_downloadDir->SetMinSize( wxSize( 300,-1 ) ); - m_gridFpListLibs = new wxGrid( m_wizPage3, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); + bSizer9->Add( m_downloadDir, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); - // Grid - m_gridFpListLibs->CreateGrid( 0, 3 ); - m_gridFpListLibs->EnableEditing( true ); - m_gridFpListLibs->EnableGridLines( true ); - m_gridFpListLibs->EnableDragGridSize( false ); - m_gridFpListLibs->SetMargins( 0, 0 ); - - // Columns - m_gridFpListLibs->EnableDragColMove( false ); - m_gridFpListLibs->EnableDragColSize( true ); - m_gridFpListLibs->SetColLabelSize( 30 ); - m_gridFpListLibs->SetColLabelValue( 0, _("NickName") ); - m_gridFpListLibs->SetColLabelValue( 1, _("Path") ); - m_gridFpListLibs->SetColLabelValue( 2, _("Plugin") ); - m_gridFpListLibs->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); - - // Rows - m_gridFpListLibs->EnableDragRowSize( true ); - m_gridFpListLibs->SetRowLabelSize( 30 ); - m_gridFpListLibs->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); - - // Label Appearance - - // Cell Defaults - m_gridFpListLibs->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); - bSizer6->Add( m_gridFpListLibs, 1, wxALL|wxEXPAND, 5 ); + m_btnBrowse = new wxButton( m_wizPage1, wxID_ANY, wxT("Browse"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer9->Add( m_btnBrowse, 0, wxALL, 5 ); - bSizerPage3->Add( bSizer6, 1, wxEXPAND, 5 ); - - wxBoxSizer* bSizer5; - bSizer5 = new wxBoxSizer( wxHORIZONTAL ); - - m_buttonGithubLibList = new wxButton( m_wizPage3, wxID_ANY, _("Github Libs List"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizer5->Add( m_buttonGithubLibList, 0, wxALL, 5 ); - - m_buttonAddLib = new wxButton( m_wizPage3, wxID_ANY, _("Add FP Libraries"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizer5->Add( m_buttonAddLib, 0, wxALL, 5 ); - - m_buttonRemoveLib = new wxButton( m_wizPage3, wxID_ANY, _("Remove FP Libraries"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizer5->Add( m_buttonRemoveLib, 0, wxALL, 5 ); + m_githubSizer->Add( bSizer9, 1, wxEXPAND, 5 ); - bSizerPage3->Add( bSizer5, 0, wxALIGN_CENTER_HORIZONTAL, 5 ); + m_githubSizer->Add( 0, 0, 1, wxEXPAND, 5 ); + + m_invalidDir = new wxStaticText( m_wizPage1, wxID_ANY, wxT("It is not possible to write in the selected directory.\nPlease choose another one."), wxDefaultPosition, wxDefaultSize, 0 ); + m_invalidDir->Wrap( -1 ); + m_invalidDir->SetForegroundColour( wxColour( 255, 0, 0 ) ); + + m_githubSizer->Add( m_invalidDir, 0, wxALL, 5 ); - m_wizPage3->SetSizer( bSizerPage3 ); - m_wizPage3->Layout(); - bSizerPage3->Fit( m_wizPage3 ); + bSizer19->Add( m_githubSizer, 1, wxEXPAND, 5 ); + + + fgSizer112->Add( bSizer19, 1, wxEXPAND, 5 ); + + wxFlexGridSizer* fgSizer12; + fgSizer12 = new wxFlexGridSizer( 0, 3, 0, 0 ); + fgSizer12->SetFlexibleDirection( wxBOTH ); + fgSizer12->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + + m_staticText8 = new wxStaticText( m_wizPage1, wxID_ANY, wxT("Visit the official"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText8->Wrap( -1 ); + fgSizer12->Add( m_staticText8, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5 ); + + m_hyperlink1 = new wxHyperlinkCtrl( m_wizPage1, wxID_ANY, wxT("Kicad repository on Github"), wxT("https://github.com/KiCad"), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE ); + fgSizer12->Add( m_hyperlink1, 0, wxTOP|wxBOTTOM, 5 ); + + m_staticText9 = new wxStaticText( m_wizPage1, wxID_ANY, wxT("to find numerous footprint libraries!"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText9->Wrap( -1 ); + fgSizer12->Add( m_staticText9, 0, wxTOP|wxBOTTOM|wxALIGN_CENTER_VERTICAL, 5 ); + + + fgSizer112->Add( fgSizer12, 1, wxEXPAND, 5 ); + + + bSizer1->Add( fgSizer112, 1, wxEXPAND, 5 ); + + + m_wizPage1->SetSizer( bSizer1 ); + m_wizPage1->Layout(); + wxWizardPageSimple* m_wizPage2_Local = new wxWizardPageSimple( this, NULL, NULL, wxArtProvider::GetBitmap( wxART_HELP_BOOK, wxART_FRAME_ICON ) ); + m_pages.Add( m_wizPage2_Local ); + + wxBoxSizer* bSizer8; + bSizer8 = new wxBoxSizer( wxVERTICAL ); + + m_staticText7 = new wxStaticText( m_wizPage2_Local, wxID_ANY, wxT("Select files or folders to add:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText7->Wrap( -1 ); + bSizer8->Add( m_staticText7, 0, wxALL, 5 ); + + m_filePicker = new wxGenericDirCtrl( m_wizPage2_Local, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxDIRCTRL_3D_INTERNAL|wxDIRCTRL_MULTIPLE|wxDIRCTRL_SHOW_FILTERS|wxSUNKEN_BORDER, wxEmptyString, 0 ); + + m_filePicker->ShowHidden( false ); + bSizer8->Add( m_filePicker, 1, wxEXPAND | wxALL, 5 ); + + + m_wizPage2_Local->SetSizer( bSizer8 ); + m_wizPage2_Local->Layout(); + bSizer8->Fit( m_wizPage2_Local ); + wxWizardPageSimple* m_wizPage2_Github = new wxWizardPageSimple( this, NULL, NULL, wxArtProvider::GetBitmap( wxART_HELP_BOOK, wxART_FRAME_ICON ) ); + m_pages.Add( m_wizPage2_Github ); + + wxBoxSizer* bSizer111; + bSizer111 = new wxBoxSizer( wxVERTICAL ); + + m_staticText112 = new wxStaticText( m_wizPage2_Github, wxID_ANY, wxT("Select Github libraries to add:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText112->Wrap( -1 ); + bSizer111->Add( m_staticText112, 0, wxALL|wxEXPAND, 5 ); + + wxArrayString m_checkListGHChoices; + m_checkListGH = new wxCheckListBox( m_wizPage2_Github, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_checkListGHChoices, wxLB_MULTIPLE|wxLB_NEEDED_SB ); + bSizer111->Add( m_checkListGH, 1, wxALL|wxEXPAND, 5 ); + + wxBoxSizer* bSizer7; + bSizer7 = new wxBoxSizer( wxHORIZONTAL ); + + m_btnSelectAllGH = new wxButton( m_wizPage2_Github, wxID_ANY, wxT("Select all"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer7->Add( m_btnSelectAllGH, 1, wxALL, 5 ); + + m_btnUnselectAllGH = new wxButton( m_wizPage2_Github, wxID_ANY, wxT("Unselect all"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer7->Add( m_btnUnselectAllGH, 1, wxALL, 5 ); + + + bSizer7->Add( 0, 0, 1, wxEXPAND, 5 ); + + m_searchCtrlGH = new wxSearchCtrl( m_wizPage2_Github, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + #ifndef __WXMAC__ + m_searchCtrlGH->ShowSearchButton( true ); + #endif + m_searchCtrlGH->ShowCancelButton( false ); + bSizer7->Add( m_searchCtrlGH, 2, wxALL, 5 ); + + + bSizer111->Add( bSizer7, 0, wxEXPAND, 5 ); + + + m_wizPage2_Github->SetSizer( bSizer111 ); + m_wizPage2_Github->Layout(); + bSizer111->Fit( m_wizPage2_Github ); + wxWizardPageSimple* m_wizPage3_Review = new wxWizardPageSimple( this, NULL, NULL, wxArtProvider::GetBitmap( wxART_HELP_BOOK, wxART_FRAME_ICON ) ); + m_pages.Add( m_wizPage3_Review ); + + wxBoxSizer* bSizer1111; + bSizer1111 = new wxBoxSizer( wxVERTICAL ); + + m_staticText1121 = new wxStaticText( m_wizPage3_Review, wxID_ANY, wxT("Review and confirm the changes to the libraries:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText1121->Wrap( -1 ); + bSizer1111->Add( m_staticText1121, 0, wxALL|wxEXPAND, 5 ); + + m_listCtrlReview = new wxDataViewListCtrl( m_wizPage3_Review, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxDV_HORIZ_RULES|wxDV_ROW_LINES|wxDV_VERT_RULES ); + m_dvLibName = m_listCtrlReview->AppendTextColumn( wxT("Library") ); + m_dvLibStatus = m_listCtrlReview->AppendTextColumn( wxT("Status") ); + m_dvLibFormat = m_listCtrlReview->AppendTextColumn( wxT("Format") ); + bSizer1111->Add( m_listCtrlReview, 1, wxALL|wxEXPAND, 5 ); + + + m_wizPage3_Review->SetSizer( bSizer1111 ); + m_wizPage3_Review->Layout(); + bSizer1111->Fit( m_wizPage3_Review ); + wxWizardPageSimple* m_wizPage4_SelectTarget = new wxWizardPageSimple( this, NULL, NULL, wxArtProvider::GetBitmap( wxART_HELP_BOOK, wxART_FRAME_ICON ) ); + m_pages.Add( m_wizPage4_SelectTarget ); + + wxBoxSizer* bSizer12; + bSizer12 = new wxBoxSizer( wxVERTICAL ); + + m_staticText12 = new wxStaticText( m_wizPage4_SelectTarget, wxID_ANY, wxT("Where do you wish the new libraries to be added:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText12->Wrap( -1 ); + bSizer12->Add( m_staticText12, 0, wxALL|wxEXPAND, 5 ); + + m_radioGlobal = new wxRadioButton( m_wizPage4_SelectTarget, wxID_ANY, wxT("To global library configuration (visible by all projects)"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer12->Add( m_radioGlobal, 0, wxALL|wxEXPAND, 5 ); + + m_radioProject = new wxRadioButton( m_wizPage4_SelectTarget, wxID_ANY, wxT("To the current project only"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer12->Add( m_radioProject, 0, wxALL|wxEXPAND, 5 ); + + + m_wizPage4_SelectTarget->SetSizer( bSizer12 ); + m_wizPage4_SelectTarget->Layout(); + bSizer12->Fit( m_wizPage4_SelectTarget ); this->Centre( wxBOTH ); @@ -226,33 +237,27 @@ WIZARD_FPLIB_TABLE_BASE::WIZARD_FPLIB_TABLE_BASE( wxWindow* parent, wxWindowID i } // Connect Events - this->Connect( wxID_ANY, wxEVT_WIZARD_FINISHED, wxWizardEventHandler( WIZARD_FPLIB_TABLE_BASE::OnFinish ) ); + this->Connect( wxID_ANY, wxEVT_WIZARD_FINISHED, wxWizardEventHandler( WIZARD_FPLIB_TABLE_BASE::OnWizardFinished ) ); this->Connect( wxID_ANY, wxEVT_WIZARD_PAGE_CHANGED, wxWizardEventHandler( WIZARD_FPLIB_TABLE_BASE::OnPageChanged ) ); this->Connect( wxID_ANY, wxEVT_WIZARD_PAGE_CHANGING, wxWizardEventHandler( WIZARD_FPLIB_TABLE_BASE::OnPageChanging ) ); - m_rbFpLibFormat->Connect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( WIZARD_FPLIB_TABLE_BASE::OnPluginSelection ), NULL, this ); - m_rbPathManagement->Connect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( WIZARD_FPLIB_TABLE_BASE::OnPathManagementSelection ), NULL, this ); - m_gridEnvironmentVariablesList->Connect( wxEVT_GRID_SELECT_CELL, wxGridEventHandler( WIZARD_FPLIB_TABLE_BASE::OnSelectEnvVarCell ), NULL, this ); - m_buttonAddEV->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WIZARD_FPLIB_TABLE_BASE::OnAddEVariable ), NULL, this ); - m_buttonRemoveEV->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WIZARD_FPLIB_TABLE_BASE::OnRemoveEVariable ), NULL, this ); - m_buttonGithubLibList->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WIZARD_FPLIB_TABLE_BASE::OnGithubLibsList ), NULL, this ); - m_buttonAddLib->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WIZARD_FPLIB_TABLE_BASE::OnAddFpLibs ), NULL, this ); - m_buttonRemoveLib->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WIZARD_FPLIB_TABLE_BASE::OnRemoveFpLibs ), NULL, this ); + m_downloadGithub->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( WIZARD_FPLIB_TABLE_BASE::OnCheckSaveCopy ), NULL, this ); + m_btnBrowse->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WIZARD_FPLIB_TABLE_BASE::OnBrowseButtonClick ), NULL, this ); + m_btnSelectAllGH->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WIZARD_FPLIB_TABLE_BASE::OnSelectAllGH ), NULL, this ); + m_btnUnselectAllGH->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WIZARD_FPLIB_TABLE_BASE::OnUnselectAllGH ), NULL, this ); + m_searchCtrlGH->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( WIZARD_FPLIB_TABLE_BASE::OnChangeSearch ), NULL, this ); } WIZARD_FPLIB_TABLE_BASE::~WIZARD_FPLIB_TABLE_BASE() { // Disconnect Events - this->Disconnect( wxID_ANY, wxEVT_WIZARD_FINISHED, wxWizardEventHandler( WIZARD_FPLIB_TABLE_BASE::OnFinish ) ); + this->Disconnect( wxID_ANY, wxEVT_WIZARD_FINISHED, wxWizardEventHandler( WIZARD_FPLIB_TABLE_BASE::OnWizardFinished ) ); this->Disconnect( wxID_ANY, wxEVT_WIZARD_PAGE_CHANGED, wxWizardEventHandler( WIZARD_FPLIB_TABLE_BASE::OnPageChanged ) ); this->Disconnect( wxID_ANY, wxEVT_WIZARD_PAGE_CHANGING, wxWizardEventHandler( WIZARD_FPLIB_TABLE_BASE::OnPageChanging ) ); - m_rbFpLibFormat->Disconnect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( WIZARD_FPLIB_TABLE_BASE::OnPluginSelection ), NULL, this ); - m_rbPathManagement->Disconnect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( WIZARD_FPLIB_TABLE_BASE::OnPathManagementSelection ), NULL, this ); - m_gridEnvironmentVariablesList->Disconnect( wxEVT_GRID_SELECT_CELL, wxGridEventHandler( WIZARD_FPLIB_TABLE_BASE::OnSelectEnvVarCell ), NULL, this ); - m_buttonAddEV->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WIZARD_FPLIB_TABLE_BASE::OnAddEVariable ), NULL, this ); - m_buttonRemoveEV->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WIZARD_FPLIB_TABLE_BASE::OnRemoveEVariable ), NULL, this ); - m_buttonGithubLibList->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WIZARD_FPLIB_TABLE_BASE::OnGithubLibsList ), NULL, this ); - m_buttonAddLib->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WIZARD_FPLIB_TABLE_BASE::OnAddFpLibs ), NULL, this ); - m_buttonRemoveLib->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WIZARD_FPLIB_TABLE_BASE::OnRemoveFpLibs ), NULL, this ); + m_downloadGithub->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( WIZARD_FPLIB_TABLE_BASE::OnCheckSaveCopy ), NULL, this ); + m_btnBrowse->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WIZARD_FPLIB_TABLE_BASE::OnBrowseButtonClick ), NULL, this ); + m_btnSelectAllGH->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WIZARD_FPLIB_TABLE_BASE::OnSelectAllGH ), NULL, this ); + m_btnUnselectAllGH->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WIZARD_FPLIB_TABLE_BASE::OnUnselectAllGH ), NULL, this ); + m_searchCtrlGH->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( WIZARD_FPLIB_TABLE_BASE::OnChangeSearch ), NULL, this ); m_pages.Clear(); } diff --git a/pcbnew/dialogs/wizard_add_fplib_base.fbp b/pcbnew/dialogs/wizard_add_fplib_base.fbp index d8f2961131..dd6f590c78 100644 --- a/pcbnew/dialogs/wizard_add_fplib_base.fbp +++ b/pcbnew/dialogs/wizard_add_fplib_base.fbp @@ -14,8 +14,8 @@ wizard_add_fplib_base 1000 none - 1 - wizard_add_fplib_base + 0 + MyProject1 . @@ -40,13 +40,13 @@ 0 wxID_ANY - 450,-1 + 720,480 WIZARD_FPLIB_TABLE_BASE - 450,389 - wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER + 720,480 + wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxRESIZE_BORDER ; - Footprint Library Wizard + Add Footprint Libraries Wizard @@ -82,13 +82,13 @@ - OnFinish + OnWizardFinished OnPageChanged OnPageChanging - + Load From Art Provider; wxART_HELP_BOOK; wxART_FRAME_ICON 1 1 @@ -97,16 +97,16 @@ 0 wxID_ANY - 500,-1 + 720,480 m_wizPage1 - public + protected - + 720,480 - wxSUNKEN_BORDER + @@ -132,14 +132,1141 @@ - bSizerPage1 + bSizer1 wxVERTICAL none 5 - wxALL|wxEXPAND + wxEXPAND + 1 + + 1 + wxBOTH + + 1 + 0 + + fgSizer112 + wxFLEX_GROWMODE_SPECIFIED + none + 3 + 0 + + 5 + wxALL|wxEXPAND + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Welcome to the Add Footprint Libraries Wizard! Please select the source for the libraries to add: + + 0 + + + 0 + + 1 + m_staticText1 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 1 + + + bSizer19 + wxVERTICAL + none + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Files on my computer + + 0 + + + 0 + + 1 + m_radioAddLocal + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 0 + + + m_sizerGithub + wxHORIZONTAL + none + + + + 5 + wxEXPAND + 0 + + 2 + 0 + + gSizer1 + none + 2 + 0 + + + + 5 + wxEXPAND + 1 + + 2 + wxBOTH + + + 0 + + m_githubSizer + wxFLEX_GROWMODE_SPECIFIED + none + 0 + 0 + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Github repository + + 0 + + + 0 + + 1 + m_radioAddGithub + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + + 0 + 300,-1 + 1 + m_textCtrlGithubURL + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + http://github.com/KiCad + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Save a local copy to: + + 0 + + + 0 + + 1 + m_downloadGithub + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + OnCheckSaveCopy + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + 5 + wxEXPAND + 1 + + + bSizer9 + wxHORIZONTAL + none + + 5 + wxALIGN_CENTER_VERTICAL|wxALL + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + + 0 + + + 0 + 300,-1 + 1 + m_downloadDir + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Browse + + 0 + + + 0 + + 1 + m_btnBrowse + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnBrowseButtonClick + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + 255,0,0 + 1 + + 0 + 0 + wxID_ANY + It is not possible to write in the selected directory. Please choose another one. + + 0 + + + 0 + + 1 + m_invalidDir + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 1 + + 3 + wxBOTH + + + 0 + + fgSizer12 + wxFLEX_GROWMODE_SPECIFIED + none + 0 + 0 + + 5 + wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Visit the official + + 0 + + + 0 + + 1 + m_staticText8 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxTOP|wxBOTTOM + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + + wxID_ANY + Kicad repository on Github + + 0 + + + 0 + + 1 + m_hyperlink1 + + 1 + + + protected + 1 + + Resizable + 1 + + wxHL_DEFAULT_STYLE + + 0 + + https://github.com/KiCad + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxTOP|wxBOTTOM|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + to find numerous footprint libraries! + + 0 + + + 0 + + 1 + m_staticText9 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Load From Art Provider; wxART_HELP_BOOK; wxART_FRAME_ICON + + 1 + 1 + + + 0 + wxID_ANY + + + m_wizPage2_Local + protected + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + bSizer8 + wxVERTICAL + none + + 5 + wxALL 0 - + 1 1 1 @@ -153,7 +1280,6 @@ 1 0 - "KiCad (*.Pretty folder containing .kicad_mod files)" "GitHub (.Pretty lib stored on GitHub repos)" "Legacy ( old *.mod lib file)" "Eagle V6 xml library file" "Geda footprint folder (folder containing *.fp files)" 1 1 @@ -168,8 +1294,7 @@ 0 0 wxID_ANY - Library Format: - 1 + Select files or folders to add: 0 @@ -177,7 +1302,7 @@ 0 1 - m_rbFpLibFormat + m_staticText7 1 @@ -185,20 +1310,16 @@ 1 Resizable - 0 1 - wxRA_SPECIFY_COLS + 0 - - wxFILTER_NONE - wxDefaultValidator - + -1 @@ -216,7 +1337,6 @@ - OnPluginSelection @@ -228,8 +1348,8 @@ 5 wxEXPAND | wxALL - 0 - + 1 + 1 1 1 @@ -247,11 +1367,14 @@ 1 0 + 0 + Dock 0 Left 1 + 1 0 @@ -264,7 +1387,7 @@ 0 1 - m_staticline2 + m_filePicker 1 @@ -273,14 +1396,15 @@ Resizable 1 + 0 - wxLI_HORIZONTAL + wxDIRCTRL_3D_INTERNAL|wxDIRCTRL_MULTIPLE|wxDIRCTRL_SHOW_FILTERS 0 - + wxSUNKEN_BORDER @@ -303,261 +1427,23 @@ - - - - - 5 - wxALL|wxALIGN_CENTER_HORIZONTAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - Load From Art Provider; wxART_INFORMATION; wxART_OTHER - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_bitmapGithubURL - 1 - - - protected - 1 - - Resizable - 1 - - - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxTOP|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Default URL for KiCad libraries on Github: - - 0 - - - 0 - - 1 - m_staticText10 - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - - 0 - - 1 - m_textCtrlGithubURL - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + @@ -565,7 +1451,7 @@ - + Load From Art Provider; wxART_HELP_BOOK; wxART_FRAME_ICON 1 1 @@ -574,16 +1460,16 @@ 0 wxID_ANY - 450,-1 - m_wizPage2 - public + + m_wizPage2_Github + protected - wxSUNKEN_BORDER + @@ -608,105 +1494,15 @@ - -1,-1 - bSizerPage2 + + bSizer111 wxVERTICAL none - + 5 wxALL|wxEXPAND 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - "Use path relative to the project" "Use environment variable in path" "Use absolute path" - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Path management: - 1 - - 0 - - - 0 - - 1 - m_rbPathManagement - 1 - - - protected - 1 - - Resizable - 2 - 1 - - wxRA_SPECIFY_COLS - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - OnPathManagementSelection - - - - - - - - - - 5 - wxTOP|wxRIGHT|wxLEFT - 0 - + 1 1 1 @@ -734,7 +1530,7 @@ 0 0 wxID_ANY - Environment variables: + Select Github libraries to add: 0 @@ -742,7 +1538,7 @@ 0 1 - m_staticText1 + m_staticText112 1 @@ -785,922 +1581,11 @@ - + 5 wxALL|wxEXPAND 1 - - 1 - 1 - 1 - 1 - - - - - 1 - 1 - - - - 1 - - - wxALIGN_LEFT - - wxALIGN_TOP - 0 - 1 - wxALIGN_CENTRE - 30 - "Environment Variable" "Path Segment" - wxALIGN_CENTRE - 2 - 125,154 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - 0 - 0 - 1 - 1 - - 1 - - - 1 - 0 - 0 - wxID_ANY - - - - 0 - 0 - - 0 - - - 0 - - 1 - m_gridEnvironmentVariablesList - 1 - - - protected - 1 - - Resizable - wxALIGN_CENTRE - 40 - - wxALIGN_CENTRE - - 3 - 1 - - - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - OnSelectEnvVarCell - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALIGN_CENTER_HORIZONTAL - 0 - - - bSizerButs - wxHORIZONTAL - none - - 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Add Environment Variable - - 0 - - - 0 - - 1 - m_buttonAddEV - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnAddEVariable - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Remove Environment Variable - - 0 - - - 0 - - 1 - m_buttonRemoveEV - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnRemoveEVariable - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1 - 1 - - - 0 - wxID_ANY - - 450,-1 - m_wizPage3 - public - - - - - - - wxSUNKEN_BORDER - - - - - - - - - - - - - - - - - - - - - - - - - -1,-1 - bSizerPage3 - wxVERTICAL - none - - 5 - wxEXPAND|wxBOTTOM - 0 - - wxID_ANY - Options - - sbSizer1 - wxVERTICAL - none - - - 5 - wxEXPAND - 0 - - 2 - wxBOTH - 1 - - 0 - - fgSizer1 - wxFLEX_GROWMODE_SPECIFIED - none - 0 - 0 - - 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Plugin type: - - 0 - - - 0 - - 1 - m_textPluginTitle - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - KiCad - - 0 - - - 0 - - 1 - m_textPluginType - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxBOTTOM|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Option: - - 0 - - - 0 - - 1 - m_textOptionTitle - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxBOTTOM|wxRIGHT|wxLEFT - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - dummy - - 0 - - - 0 - - 1 - m_textOption - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxBOTTOM|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Path: - - 0 - - - 0 - - 1 - m_stPathTitle - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxBOTTOM|wxRIGHT|wxLEFT - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - dummy - - 0 - - - 0 - - 1 - m_textPath - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxTOP|wxRIGHT|wxLEFT - 0 - + 1 1 1 @@ -1714,6 +1599,7 @@ 1 0 + 1 1 @@ -1728,7 +1614,6 @@ 0 0 wxID_ANY - Library list to add in Fp table: 0 @@ -1736,7 +1621,7 @@ 0 1 - m_staticText2 + m_checkListGH 1 @@ -1746,15 +1631,21 @@ Resizable 1 - + wxLB_MULTIPLE|wxLB_NEEDED_SB 0 + + wxFILTER_NONE + wxDefaultValidator + - -1 + + + @@ -1782,171 +1673,17 @@ 5 wxEXPAND - 1 - - - bSizer6 - wxVERTICAL - none - - 5 - wxALL|wxEXPAND - 1 - - 1 - 1 - 1 - 1 - - - - - 0 - 0 - - - - 1 - - - wxALIGN_LEFT - - wxALIGN_TOP - 0 - 1 - wxALIGN_CENTRE - 30 - "NickName" "Path" "Plugin" - wxALIGN_CENTRE - 3 - - - 1 - 0 - Dock - 0 - Left - 0 - 1 - 0 - 1 - 1 - 1 - - 1 - - - 1 - 0 - 0 - wxID_ANY - - - - 0 - 0 - - 0 - - - 0 - - 1 - m_gridFpListLibs - 1 - - - protected - 1 - - Resizable - wxALIGN_CENTRE - 30 - - wxALIGN_CENTRE - - 0 - 1 - - - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALIGN_CENTER_HORIZONTAL 0 - bSizer5 + bSizer7 wxHORIZONTAL none - + 5 wxALL - 0 - + 1 + 1 1 1 @@ -1975,7 +1712,7 @@ 0 0 wxID_ANY - Github Libs List + Select all 0 @@ -1983,7 +1720,7 @@ 0 1 - m_buttonGithubLibList + m_btnSelectAllGH 1 @@ -2004,7 +1741,95 @@ - OnGithubLibsList + OnSelectAllGH + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Unselect all + + 0 + + + 0 + + 1 + m_btnUnselectAllGH + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnUnselectAllGH @@ -2032,97 +1857,19 @@ 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Add FP Libraries - - 0 - - - 0 - - 1 - m_buttonAddLib - 1 - - + wxEXPAND + 1 + + 0 protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnAddFpLibs - - - - - - - - - - - - - - - - - - - - - - - + 0 5 wxALL - 0 - + 2 + 1 1 1 @@ -2133,13 +1880,13 @@ + 0 1 0 1 1 - 0 0 Dock 0 @@ -2151,7 +1898,6 @@ 0 0 wxID_ANY - Remove FP Libraries 0 @@ -2159,7 +1905,7 @@ 0 1 - m_buttonRemoveLib + m_searchCtrlGH 1 @@ -2167,6 +1913,7 @@ 1 Resizable + 1 1 @@ -2177,10 +1924,11 @@ wxFILTER_NONE wxDefaultValidator + - OnRemoveFpLibs + @@ -2201,8 +1949,11 @@ + + OnChangeSearch + @@ -2210,6 +1961,536 @@ + + + Load From Art Provider; wxART_HELP_BOOK; wxART_FRAME_ICON + + 1 + 1 + + + 0 + wxID_ANY + + + m_wizPage3_Review + protected + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + bSizer1111 + wxVERTICAL + none + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Review and confirm the changes to the libraries: + + 0 + + + 0 + + 1 + m_staticText1121 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 1 + + + + 1 + 1 + + + 0 + wxID_ANY + + + m_listCtrlReview + protected + + + wxDV_HORIZ_RULES|wxDV_ROW_LINES|wxDV_VERT_RULES + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Library + m_dvLibName + protected + Text + + + Status + m_dvLibStatus + protected + Text + + + Format + m_dvLibFormat + protected + Text + + + + + + + + Load From Art Provider; wxART_HELP_BOOK; wxART_FRAME_ICON + + 1 + 1 + + + 0 + wxID_ANY + + + m_wizPage4_SelectTarget + protected + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + bSizer12 + wxVERTICAL + none + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Where do you wish the new libraries to be added: + + 0 + + + 0 + + 1 + m_staticText12 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + To global library configuration (visible by all projects) + + 0 + + + 0 + + 1 + m_radioGlobal + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + To the current project only + + 0 + + + 0 + + 1 + m_radioProject + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pcbnew/dialogs/wizard_add_fplib_base.h b/pcbnew/dialogs/wizard_add_fplib_base.h index 9edfa11a0f..54d85bd030 100644 --- a/pcbnew/dialogs/wizard_add_fplib_base.h +++ b/pcbnew/dialogs/wizard_add_fplib_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jun 5 2014) +// C++ code generated with wxFormBuilder (version Mar 9 2015) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -10,24 +10,25 @@ #include #include -#include #include -#include +#include #include #include #include #include -#include +#include +#include +#include +#include +#include +#include #include #include #include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include #include #include WX_DEFINE_ARRAY_PTR( wxWizardPageSimple*, WizardPages ); @@ -43,45 +44,47 @@ class WIZARD_FPLIB_TABLE_BASE : public wxWizard private: protected: - wxRadioBox* m_rbFpLibFormat; - wxStaticLine* m_staticline2; - wxStaticBitmap* m_bitmapGithubURL; - wxStaticText* m_staticText10; - wxTextCtrl* m_textCtrlGithubURL; - wxRadioBox* m_rbPathManagement; wxStaticText* m_staticText1; - wxGrid* m_gridEnvironmentVariablesList; - wxButton* m_buttonAddEV; - wxButton* m_buttonRemoveEV; - wxStaticText* m_textPluginTitle; - wxStaticText* m_textPluginType; - wxStaticText* m_textOptionTitle; - wxStaticText* m_textOption; - wxStaticText* m_stPathTitle; - wxStaticText* m_textPath; - wxStaticText* m_staticText2; - wxGrid* m_gridFpListLibs; - wxButton* m_buttonGithubLibList; - wxButton* m_buttonAddLib; - wxButton* m_buttonRemoveLib; + wxRadioButton* m_radioAddLocal; + wxRadioButton* m_radioAddGithub; + wxTextCtrl* m_textCtrlGithubURL; + wxCheckBox* m_downloadGithub; + wxStaticText* m_downloadDir; + wxButton* m_btnBrowse; + wxStaticText* m_invalidDir; + wxStaticText* m_staticText8; + wxHyperlinkCtrl* m_hyperlink1; + wxStaticText* m_staticText9; + wxStaticText* m_staticText7; + wxGenericDirCtrl* m_filePicker; + wxStaticText* m_staticText112; + wxCheckListBox* m_checkListGH; + wxButton* m_btnSelectAllGH; + wxButton* m_btnUnselectAllGH; + wxSearchCtrl* m_searchCtrlGH; + wxStaticText* m_staticText1121; + wxDataViewListCtrl* m_listCtrlReview; + wxDataViewColumn* m_dvLibName; + wxDataViewColumn* m_dvLibStatus; + wxDataViewColumn* m_dvLibFormat; + wxStaticText* m_staticText12; + wxRadioButton* m_radioGlobal; + wxRadioButton* m_radioProject; // Virtual event handlers, overide them in your derived class - virtual void OnFinish( wxWizardEvent& event ) { event.Skip(); } + virtual void OnWizardFinished( wxWizardEvent& event ) { event.Skip(); } virtual void OnPageChanged( wxWizardEvent& event ) { event.Skip(); } virtual void OnPageChanging( wxWizardEvent& event ) { event.Skip(); } - virtual void OnPluginSelection( wxCommandEvent& event ) { event.Skip(); } - virtual void OnPathManagementSelection( wxCommandEvent& event ) { event.Skip(); } - virtual void OnSelectEnvVarCell( wxGridEvent& event ) { event.Skip(); } - virtual void OnAddEVariable( wxCommandEvent& event ) { event.Skip(); } - virtual void OnRemoveEVariable( wxCommandEvent& event ) { event.Skip(); } - virtual void OnGithubLibsList( wxCommandEvent& event ) { event.Skip(); } - virtual void OnAddFpLibs( wxCommandEvent& event ) { event.Skip(); } - virtual void OnRemoveFpLibs( wxCommandEvent& event ) { event.Skip(); } + virtual void OnCheckSaveCopy( wxCommandEvent& event ) { event.Skip(); } + virtual void OnBrowseButtonClick( wxCommandEvent& event ) { event.Skip(); } + virtual void OnSelectAllGH( wxCommandEvent& event ) { event.Skip(); } + virtual void OnUnselectAllGH( wxCommandEvent& event ) { event.Skip(); } + virtual void OnChangeSearch( wxCommandEvent& event ) { event.Skip(); } public: - WIZARD_FPLIB_TABLE_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Footprint Library Wizard"), const wxBitmap& bitmap = wxArtProvider::GetBitmap( wxART_HELP_BOOK, wxART_FRAME_ICON ), const wxPoint& pos = wxDefaultPosition, long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + WIZARD_FPLIB_TABLE_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Add Footprint Libraries Wizard"), const wxBitmap& bitmap = wxArtProvider::GetBitmap( wxART_HELP_BOOK, wxART_FRAME_ICON ), const wxPoint& pos = wxDefaultPosition, long style = wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxRESIZE_BORDER ); WizardPages m_pages; ~WIZARD_FPLIB_TABLE_BASE(); diff --git a/pcbnew/invoke_pcb_dialog.h b/pcbnew/invoke_pcb_dialog.h index df9ceaf2d0..549b9c5716 100644 --- a/pcbnew/invoke_pcb_dialog.h +++ b/pcbnew/invoke_pcb_dialog.h @@ -73,6 +73,23 @@ class PCB_PLOT_PARAMS; */ int InvokePcbLibTableEditor( wxTopLevelWindow* aCaller, FP_LIB_TABLE* aGlobal, FP_LIB_TABLE* aProject ); +/** + * Function InvokeFootprintWizard + * Runs the footprint library wizard for easy library addition. + * + * @param aCaller is the wxTopLevelWindow which is invoking the dialog. + * @param aGlobal is the common footprint library table file being edited. If aGlobal is NULL, then + * it will not be updated. + * @param aProject is the project specific footprint library table file being edited. if aProject + * is NULL, then it will not be updated. + * + * @return int 0 - no changes + * 1 - changes in the global table + * 2 - changes in the project table + * 3 - changes in both tables + */ +int InvokeFootprintWizard( wxTopLevelWindow* aParent, FP_LIB_TABLE* aGlobal, FP_LIB_TABLE* aProject ); + /** * Function InvokePluginOptionsEditor * calls DIALOG_FP_PLUGIN_OPTIONS dialog so that plugin options set can be edited. diff --git a/pcbnew/menubar_modedit.cpp b/pcbnew/menubar_modedit.cpp index 61040b18b9..4696d348f4 100644 --- a/pcbnew/menubar_modedit.cpp +++ b/pcbnew/menubar_modedit.cpp @@ -280,8 +280,12 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar() //----- Preferences menu ----------------- wxMenu* prefs_menu = new wxMenu; + AddMenuItem( prefs_menu, ID_PCB_LIB_WIZARD, + _( "&Footprint Libraries Wizard" ), _( "Add footprint libraries with wizard" ), + KiBitmap( wizard_add_fplib_small_xpm ) ); + AddMenuItem( prefs_menu, ID_PCB_LIB_TABLE_EDIT, - _( "Footprint Li&braries" ), _( "Configure footprint libraries" ), + _( "Footprint Li&braries Manager" ), _( "Configure footprint libraries" ), KiBitmap( library_table_xpm ) ); // Path configuration edit dialog. diff --git a/pcbnew/menubar_pcbframe.cpp b/pcbnew/menubar_pcbframe.cpp index 67ff4c0618..cdd799feb7 100644 --- a/pcbnew/menubar_pcbframe.cpp +++ b/pcbnew/menubar_pcbframe.cpp @@ -480,8 +480,12 @@ void PCB_EDIT_FRAME::ReCreateMenuBar() //----- Preferences and configuration menu------------------------------------ wxMenu* configmenu = new wxMenu; + AddMenuItem( configmenu, ID_PCB_LIB_WIZARD, + _( "&Footprint Libraries Wizard" ), _( "Add footprint libraries with wizard" ), + KiBitmap( wizard_add_fplib_small_xpm ) ); + AddMenuItem( configmenu, ID_PCB_LIB_TABLE_EDIT, - _( "Footprint Li&braries" ), _( "Configure footprint libraries" ), + _( "Footprint Li&braries Manager" ), _( "Configure footprint libraries" ), KiBitmap( library_table_xpm ) ); // Path configuration edit dialog. diff --git a/pcbnew/moduleframe.cpp b/pcbnew/moduleframe.cpp index faa17bdb5b..3cf9a7dd44 100644 --- a/pcbnew/moduleframe.cpp +++ b/pcbnew/moduleframe.cpp @@ -116,7 +116,7 @@ BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME ) EVT_TOOL( ID_TB_OPTIONS_SHOW_MODULE_EDGE_SKETCH, FOOTPRINT_EDIT_FRAME::OnSelectOptionToolbar ) EVT_TOOL( ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE, FOOTPRINT_EDIT_FRAME::OnSelectOptionToolbar ) - // Preferences et option menus + // Preferences and option menus EVT_MENU( ID_PREFERENCES_HOTKEY_EXPORT_CONFIG, FOOTPRINT_EDIT_FRAME::ProcessPreferences ) EVT_MENU( ID_PREFERENCES_HOTKEY_IMPORT_CONFIG, @@ -125,6 +125,8 @@ BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME ) FOOTPRINT_EDIT_FRAME::ProcessPreferences ) EVT_MENU( ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, FOOTPRINT_EDIT_FRAME::ProcessPreferences ) + EVT_MENU( ID_PCB_LIB_WIZARD, + FOOTPRINT_EDIT_FRAME::ProcessPreferences ) EVT_MENU( ID_PCB_LIB_TABLE_EDIT, FOOTPRINT_EDIT_FRAME::ProcessPreferences ) EVT_MENU( wxID_PREFERENCES, @@ -851,10 +853,16 @@ void FOOTPRINT_EDIT_FRAME::ProcessPreferences( wxCommandEvent& event ) DisplayHotkeyList( this, g_Module_Editor_Hokeys_Descr ); break; + case ID_PCB_LIB_WIZARD: case ID_PCB_LIB_TABLE_EDIT: { bool tableChanged = false; - int r = InvokePcbLibTableEditor( this, &GFootprintTable, Prj().PcbFootprintLibs() ); + int r = 0; + + if( id == ID_PCB_LIB_TABLE_EDIT ) + r = InvokePcbLibTableEditor( this, &GFootprintTable, Prj().PcbFootprintLibs() ); + else + r = InvokeFootprintWizard( this, &GFootprintTable, Prj().PcbFootprintLibs() ); if( r & 1 ) { diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index 49565b25bb..fcea2a51ad 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -134,6 +134,7 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME ) // menu Config EVT_MENU( ID_PCB_DRAWINGS_WIDTHS_SETUP, PCB_EDIT_FRAME::OnConfigurePcbOptions ) EVT_MENU( ID_PCB_LIB_TABLE_EDIT, PCB_EDIT_FRAME::Process_Config ) + EVT_MENU( ID_PCB_LIB_WIZARD, PCB_EDIT_FRAME::Process_Config ) EVT_MENU( ID_PREFERENCES_CONFIGURE_PATHS, PCB_EDIT_FRAME::OnConfigurePaths ) EVT_MENU( ID_CONFIG_SAVE, PCB_EDIT_FRAME::Process_Config ) EVT_MENU( ID_CONFIG_READ, PCB_EDIT_FRAME::Process_Config ) diff --git a/pcbnew/pcbnew_config.cpp b/pcbnew/pcbnew_config.cpp index 51d58c4e7a..6354c5318d 100644 --- a/pcbnew/pcbnew_config.cpp +++ b/pcbnew/pcbnew_config.cpp @@ -112,10 +112,16 @@ void PCB_EDIT_FRAME::Process_Config( wxCommandEvent& event ) } break; + case ID_PCB_LIB_WIZARD: case ID_PCB_LIB_TABLE_EDIT: { bool tableChanged = false; - int r = InvokePcbLibTableEditor( this, &GFootprintTable, Prj().PcbFootprintLibs() ); + int r = 0; + + if( id == ID_PCB_LIB_TABLE_EDIT ) + r = InvokePcbLibTableEditor( this, &GFootprintTable, Prj().PcbFootprintLibs() ); + else + r = InvokeFootprintWizard( this, &GFootprintTable, Prj().PcbFootprintLibs() ); if( r & 1 ) { diff --git a/pcbnew/pcbnew_id.h b/pcbnew/pcbnew_id.h index 334bfaa8f6..c15d7969f2 100644 --- a/pcbnew/pcbnew_id.h +++ b/pcbnew/pcbnew_id.h @@ -294,6 +294,7 @@ enum pcbnew_ids ID_MENU_CANVAS_CAIRO, ID_PCB_USER_GRID_SETUP, ID_PCB_GEN_BOM_FILE_FROM_BOARD, + ID_PCB_LIB_WIZARD, ID_PCB_LIB_TABLE_EDIT, ID_MENU_PCB_SHOW_DESIGN_RULES_DIALOG, ID_MENU_PCB_SHOW_HIDE_LAYERS_MANAGER_DIALOG, diff --git a/webviewer/CMakeLists.txt b/webviewer/CMakeLists.txt deleted file mode 100644 index caf653d848..0000000000 --- a/webviewer/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ - -include_directories(BEFORE ${INC_BEFORE}) -include_directories( - ${INC_AFTER} - ) - -set( WEBVIEW_SRCS - html_link_parser.cpp - webviewer.cpp -) - -add_library( webviewer STATIC ${WEBVIEW_SRCS}) - -add_dependencies( webviewer lib-dependencies ) - diff --git a/webviewer/html_link_parser.cpp b/webviewer/html_link_parser.cpp deleted file mode 100644 index 22e52ebb21..0000000000 --- a/webviewer/html_link_parser.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/** - * @file html_link_parse.cpp - */ - -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 1992-2014 KiCad Developers, see AUTHORS.txt for contributors. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, you may find one here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -/* - * wxWidgets gives very few info about wxwebkit. For more info and more comments: - * see https://forums.wxwidgets.org/viewtopic.php?f=1&t=1119# - */ - -#include -#include -#include "html_link_parser.h" - -bool LINK_TAGHANDLER::HandleTag(const wxHtmlTag& tag) -{ - if( tag.HasParam( wxT("HREF") ) ) - { - wxString href( tag.GetParam( wxT("HREF") ) ); - // Add the first parameter (the link) - m_Parser->AddString( href ); - // Parse other params, but do nothing, becuse the AddText() callback - // do nothing - ParseInner(tag); - return true; - } - else - return false; -} - -HTML_LINK_PARSER::HTML_LINK_PARSER( const wxString& aSrc, wxArrayString& aUrls ) - : m_src( aSrc ), stringUrls( aUrls ) -{ - AddTagHandler( new LINK_TAGHANDLER(this) ); -} - - -void HTML_LINK_PARSER::AddString( const wxString& aText ) -{ - wxString text = aText; - text.Trim( true ); - text.Trim( false ); - - if( ! m_filter || m_filter( text ) ) - { - stringUrls.Add( text ); - } -} diff --git a/webviewer/html_link_parser.h b/webviewer/html_link_parser.h deleted file mode 100644 index d4de3cf30e..0000000000 --- a/webviewer/html_link_parser.h +++ /dev/null @@ -1,109 +0,0 @@ -/** - * @file html_link_parse.h - */ - -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 1992-2014 KiCad Developers, see AUTHORS.txt for contributors. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, you may find one here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -/* - * wxWidgets gives very few info about wxwebkit. For more info and more comments: - * see https://forums.wxwidgets.org/viewtopic.php?f=1&t=1119# - */ - -#ifndef HTML_LINK_PARSE_H -#define HTML_LINK_PARSE_H - - -#include -#include - -class HTML_LINK_PARSER ; - -/** - * a Tag parser, to extract tagged data in html text. - * this tag handler extract a url link, givent by tag "A" - * like: - * " Valves.pretty" - * the tag is "a" - * and the link is the parameter given by "href" - */ -class LINK_TAGHANDLER : public wxHtmlTagHandler -{ - HTML_LINK_PARSER* m_Parser; - -public: - LINK_TAGHANDLER() : m_Parser( NULL ) - { - } - - LINK_TAGHANDLER( HTML_LINK_PARSER* aParser ) : m_Parser( aParser ) - { - } - - wxString GetSupportedTags() - { - return "A"; - } - - bool HandleTag(const wxHtmlTag& tag); -}; - -/** - * The engine to parse a html text and extract useful data - * Here, the useful data are url links - */ -class HTML_LINK_PARSER : public wxHtmlParser -{ - const wxString& m_src; // the html text to parse - wxArrayString& stringUrls; // the strings extracted from html text - bool (*m_filter)( const wxString& aData ); // a callback function to filter strings - -public: - - HTML_LINK_PARSER( const wxString& aSrc, wxArrayString& aUrls ); - - /** - * Parse the html text and store links in stringUrls - * Stored links can be filtered if aFilter is non NULL - * @param aFilter a filtering function ( bool aFilter( const wxString& aData ) ) - * which return true if the tex(t aData must be stored. - */ - void ParseLinks( bool (*aFilter)( const wxString& aData ) ) - { - m_filter = aFilter; - Parse(m_src); - } - - // virtual pure from wxHtmlParser, do nothing here, but needed. - void AddText( const wxString& aText ){} - - // Our "AddText" used to store selected text (the url link) - void AddString( const wxString& aText ); - - wxObject* GetProduct() - { - return NULL; - } -}; - -#endif // ifndef HTML_LINK_PARSE_H diff --git a/webviewer/webviewer.cpp b/webviewer/webviewer.cpp deleted file mode 100644 index 2968a6057f..0000000000 --- a/webviewer/webviewer.cpp +++ /dev/null @@ -1,970 +0,0 @@ -/* - * This code comes from wxWebView sample webview.cpp and is modified to be used in Kicad - * the wxWidgets sample code webview.cpp is under wxWindows licence (author Marianne Gagnon) - * - * Webviewer runs in a dialog to allows an user to select a list of URLs which are .pretty library - * folder accessible from http or https using the Github plugin. - * - * The Web viewer just return a list of URLs selected from the context menu (command copy link) - * when mouse cursor in on a http link. - * URLs strings are filtered - * Only URLs starting by "http" and ending by ".pretty" can be currently selected and stored in fp lib list - */ - -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 1992-2014 KiCad Developers, see AUTHORS.txt for contributors. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, you may find one here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -/* - * wxWidgets gives very few info about wxwebkit. For more info and more comments: - * see https://forums.wxwidgets.org/viewtopic.php?f=1&t=1119# - */ - -#include "wx/wx.h" - -#if !wxUSE_WEBVIEW_WEBKIT && !wxUSE_WEBVIEW_IE -#error "wxWidgets must be built with wxWebView support enabled. Please rebuild wxWidgets" -#endif - -#include "wx/artprov.h" -#include "wx/cmdline.h" -#include "wx/notifmsg.h" -#include "wx/settings.h" -#include "wx/webview.h" -#include "wx/webviewarchivehandler.h" -#include "wx/webviewfshandler.h" -#include "wx/infobar.h" -#include "wx/filesys.h" -#include "wx/fs_arc.h" -#include -#include -#if wxUSE_STC -#include "wx/stc/stc.h" -#else -#error "wxWidgets must be built with wxStyledTextControl enabled. Please rebuild wxWidgets" -#endif - -#include -#include -#include "html_link_parser.h" - -// We map menu items to their history items -WX_DECLARE_HASH_MAP( int, wxSharedPtr, - wxIntegerHash, wxIntegerEqual, wxMenuHistoryMap ); - - -class WEB_NAVIGATOR : public DIALOG_SHIM -{ - wxArrayString* urlListSelection; - -public: - WEB_NAVIGATOR( wxWindow* aParent, - const wxString& aUrlOnStart, - wxArrayString* aUrlListSelection = NULL ); - virtual ~WEB_NAVIGATOR(); - - void InitNavigator( const wxString& aUrlOnStart ); - -private: - void buildToolBar(); - void buildToolMenu(); - void CreateFindToolBar( wxWindow* aParent ); - - void UpdateState(); - - // wxWebViewEvents: - /** Callback invoked when a navigation request was accepted - */ - void OnNavigationComplete( wxWebViewEvent& evt ) - { - UpdateState(); - } - - /** Callback invoked when a page is finished loading - */ - void OnDocumentLoaded( wxWebViewEvent& evt ) - { - UpdateState(); - } - - /** On new window, we veto to stop extra windows appearing - */ - void OnNewWindow( wxWebViewEvent& evt ) - { - UpdateState(); - } - - void OnTitleChanged( wxWebViewEvent& evt ) - { - SetTitle( evt.GetString() ); - } - - // event functions: - void OnIdle( wxIdleEvent& evt ); - void OnUrl( wxCommandEvent& evt ); - void OnBack( wxCommandEvent& evt ); - void OnForward( wxCommandEvent& evt ); - void OnStop( wxCommandEvent& evt ); - void OnReload( wxCommandEvent& evt ); - void OnClearHistory( wxCommandEvent& evt ); - void OnNavigationRequest( wxWebViewEvent& evt ); - void OnViewSourceRequest( wxCommandEvent& evt ); - void OnToolsClicked( wxCommandEvent& evt ); - void OnSetZoom( wxCommandEvent& evt ); - void OnError( wxWebViewEvent& evt ); - - void OnPrint( wxCommandEvent& evt ) - { - m_browser->Print(); - } - - void OnZoomLayout( wxCommandEvent& evt ); - - void OnHistory( wxCommandEvent& evt ) - { - m_browser->LoadHistoryItem( m_histMenuItems[evt.GetId()] ); - } - - void OnFind( wxCommandEvent& evt ); - void OnFindDone( wxCommandEvent& evt ); - void OnFindText( wxCommandEvent& evt ); - void OnFindOptions( wxCommandEvent& evt ); - - // only for fp lib wizard called if there is a non null - // aUrlListSelection from idle event, to see if a valid - // footprint lib was selected by user, from the context menu - // (command copy link) - void TestAndStoreFootprintLibLink(); - // Alternate way to list and select fp libraries: - void OnListPrettyLibURLs( wxCommandEvent& event ); - -private: - wxTextCtrl* m_url; - wxWebView* m_browser; - - wxToolBar* m_toolbar; - wxToolBarToolBase* m_toolbar_back; - wxToolBarToolBase* m_toolbar_forward; - wxToolBarToolBase* m_toolbar_stop; - wxToolBarToolBase* m_toolbar_reload; - wxToolBarToolBase* m_toolbar_tools; - wxToolBarToolBase* m_toolbar_ListLibs; - - wxToolBarToolBase* m_find_toolbar_done; - wxToolBarToolBase* m_find_toolbar_next; - wxToolBarToolBase* m_find_toolbar_previous; - wxToolBarToolBase* m_find_toolbar_options; - - wxMenuItem* m_find_toolbar_wrap; - wxMenuItem* m_find_toolbar_highlight; - wxMenuItem* m_find_toolbar_matchcase; - wxMenuItem* m_find_toolbar_wholeword; - - wxMenu* m_tools_menu; - wxMenuItem* m_tools_viewSource; - wxMenuItem* m_tools_print; - wxMenu* m_tools_history_menu; - wxMenuItem* m_tools_clearhist; - wxMenuItem* m_tools_layout; - wxMenuItem* m_tools_tiny; - wxMenuItem* m_tools_small; - wxMenuItem* m_tools_medium; - wxMenuItem* m_tools_large; - wxMenuItem* m_tools_largest; - wxMenuItem* m_find; - - wxInfoBar* m_info; - wxStaticText* m_info_text; - wxTextCtrl* m_find_ctrl; - wxToolBar* m_find_toolbar; - - wxMenuHistoryMap m_histMenuItems; - wxString m_findText; - int m_findFlags, m_findCount; -}; - -class SourceViewDialog : public wxDialog -{ -public: - SourceViewDialog( wxWindow* parent, wxString source ); -}; - -// Helper function to run the web viewer from an other dialog or frame: -int RunWebViewer( wxWindow* aParent, const wxString& aUrlOnStart, wxArrayString* aUrlListSelection ) -{ - WEB_NAVIGATOR dlg( aParent, aUrlOnStart, aUrlListSelection ); - return dlg.ShowModal(); -} - - -WEB_NAVIGATOR::WEB_NAVIGATOR( wxWindow* aParent, - const wxString& aUrlOnStart, wxArrayString* aUrlListSelection ) : - DIALOG_SHIM( aParent, wxID_ANY, "Web Viewer", wxDefaultPosition, wxDefaultSize, - wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ) -{ - urlListSelection = aUrlListSelection; - InitNavigator( aUrlOnStart ); - - SetMinSize( wxSize( 700, 500 ) ); - - GetSizer()->Fit( this ); - Centre(); -} - - -void WEB_NAVIGATOR::InitNavigator( const wxString& aUrlOnStart ) -{ - // To collect URLs, the Web Viewer can use the clipboard. - // Clear it before running the viewer - // For an unknown reason, wxTheClipboard->Clear() does not work, - // so use a trick - if( wxTheClipboard->Open() ) - { - wxTheClipboard->SetData( new wxTextDataObject( "" ) ); - wxTheClipboard->Close(); - } - - wxBoxSizer* topsizer = new wxBoxSizer( wxVERTICAL ); - - // Create the main toolbar - m_toolbar = new wxToolBar( this, wxID_ANY ); - buildToolBar(); - topsizer->Add( m_toolbar ); - - // Shows the tool to choose and select fp libs only if a selected URL list - // exists - if( urlListSelection == NULL ) - m_toolbar_ListLibs->Enable( false ); - - // Set find parameters and create the find toolbar. - m_findFlags = wxWEBVIEW_FIND_DEFAULT; - m_findCount = 0; - CreateFindToolBar( this ); - topsizer->Add( m_find_toolbar, wxSizerFlags().Expand() ); - m_find_toolbar->Hide(); - - // Create the info panel - m_info = new wxInfoBar( this ); - topsizer->Add( m_info, wxSizerFlags().Expand() ); - - // Create the webview engine - if( aUrlOnStart.IsEmpty() ) // Start on a blank page: - m_browser = wxWebView::New( this, wxID_ANY, wxT( "about:blank") ); - else - m_browser = wxWebView::New( this, wxID_ANY, aUrlOnStart, - wxDefaultPosition, wxSize( 900, 600 ) ); - - m_browser->EnableHistory( true ); - - topsizer->Add( m_browser, wxSizerFlags().Expand().Proportion( 1 ) ); - - SetSizer( topsizer ); - - // Create the Tools menu - buildToolMenu(); - - if( !m_browser->CanSetZoomType( wxWEBVIEW_ZOOM_TYPE_LAYOUT ) ) - m_tools_layout->Enable( false ); - - // Connect the toolbar events - Connect( m_toolbar_back->GetId(), wxEVT_TOOL, - wxCommandEventHandler( WEB_NAVIGATOR::OnBack ), NULL, this ); - Connect( m_toolbar_forward->GetId(), wxEVT_TOOL, - wxCommandEventHandler( WEB_NAVIGATOR::OnForward ), NULL, this ); - Connect( m_toolbar_stop->GetId(), wxEVT_TOOL, - wxCommandEventHandler( WEB_NAVIGATOR::OnStop ), NULL, this ); - Connect( m_toolbar_reload->GetId(), wxEVT_TOOL, - wxCommandEventHandler( WEB_NAVIGATOR::OnReload ), NULL, this ); - Connect( m_toolbar_tools->GetId(), wxEVT_TOOL, - wxCommandEventHandler( WEB_NAVIGATOR::OnToolsClicked ), NULL, this ); - - Connect( m_toolbar_ListLibs->GetId(), wxEVT_TOOL, - wxCommandEventHandler( WEB_NAVIGATOR::OnListPrettyLibURLs ), NULL, this ); - - Connect( m_url->GetId(), wxEVT_TEXT_ENTER, - wxCommandEventHandler( WEB_NAVIGATOR::OnUrl ), NULL, this ); - - // Connect find toolbar events. - Connect( m_find_toolbar_done->GetId(), wxEVT_TOOL, - wxCommandEventHandler( WEB_NAVIGATOR::OnFindDone ), NULL, this ); - Connect( m_find_toolbar_next->GetId(), wxEVT_TOOL, - wxCommandEventHandler( WEB_NAVIGATOR::OnFindText ), NULL, this ); - Connect( m_find_toolbar_previous->GetId(), wxEVT_TOOL, - wxCommandEventHandler( WEB_NAVIGATOR::OnFindText ), NULL, this ); - - // Connect find control events. - Connect( m_find_ctrl->GetId(), wxEVT_TEXT, - wxCommandEventHandler( WEB_NAVIGATOR::OnFindText ), NULL, this ); - Connect( m_find_ctrl->GetId(), wxEVT_TEXT_ENTER, - wxCommandEventHandler( WEB_NAVIGATOR::OnFindText ), NULL, this ); - - // Connect the webview events - Connect( m_browser->GetId(), wxEVT_WEBVIEW_NAVIGATING, - wxWebViewEventHandler( WEB_NAVIGATOR::OnNavigationRequest ), NULL, this ); - Connect( m_browser->GetId(), wxEVT_WEBVIEW_NAVIGATED, - wxWebViewEventHandler( WEB_NAVIGATOR::OnNavigationComplete ), NULL, this ); - Connect( m_browser->GetId(), wxEVT_WEBVIEW_LOADED, - wxWebViewEventHandler( WEB_NAVIGATOR::OnDocumentLoaded ), NULL, this ); - Connect( m_browser->GetId(), wxEVT_WEBVIEW_ERROR, - wxWebViewEventHandler( WEB_NAVIGATOR::OnError ), NULL, this ); - Connect( m_browser->GetId(), wxEVT_WEBVIEW_NEWWINDOW, - wxWebViewEventHandler( WEB_NAVIGATOR::OnNewWindow ), NULL, this ); - Connect( m_browser->GetId(), wxEVT_WEBVIEW_TITLE_CHANGED, - wxWebViewEventHandler( WEB_NAVIGATOR::OnTitleChanged ), NULL, this ); - - // Connect the menu events - Connect( m_tools_viewSource->GetId(), wxEVT_MENU, - wxCommandEventHandler( WEB_NAVIGATOR::OnViewSourceRequest ), NULL, this ); - Connect( m_tools_print->GetId(), wxEVT_MENU, - wxCommandEventHandler( WEB_NAVIGATOR::OnPrint ), NULL, this ); - Connect( m_tools_layout->GetId(), wxEVT_MENU, - wxCommandEventHandler( WEB_NAVIGATOR::OnZoomLayout ), NULL, this ); - Connect( m_tools_tiny->GetId(), wxEVT_MENU, - wxCommandEventHandler( WEB_NAVIGATOR::OnSetZoom ), NULL, this ); - Connect( m_tools_small->GetId(), wxEVT_MENU, - wxCommandEventHandler( WEB_NAVIGATOR::OnSetZoom ), NULL, this ); - Connect( m_tools_medium->GetId(), wxEVT_MENU, - wxCommandEventHandler( WEB_NAVIGATOR::OnSetZoom ), NULL, this ); - Connect( m_tools_large->GetId(), wxEVT_MENU, - wxCommandEventHandler( WEB_NAVIGATOR::OnSetZoom ), NULL, this ); - Connect( m_tools_largest->GetId(), wxEVT_MENU, - wxCommandEventHandler( WEB_NAVIGATOR::OnSetZoom ), NULL, this ); - Connect( m_tools_clearhist->GetId(), wxEVT_MENU, - wxCommandEventHandler( WEB_NAVIGATOR::OnClearHistory ), NULL, this ); - Connect( m_find->GetId(), wxEVT_MENU, - wxCommandEventHandler( WEB_NAVIGATOR::OnFind ), NULL, this ); - - // Connect the idle events - Connect( wxID_ANY, wxEVT_IDLE, wxIdleEventHandler( WEB_NAVIGATOR::OnIdle ), NULL, this ); -} - - -WEB_NAVIGATOR::~WEB_NAVIGATOR() -{ - delete m_tools_menu; -} - - -void WEB_NAVIGATOR::buildToolMenu() -{ - m_tools_menu = new wxMenu(); - - m_tools_print = m_tools_menu->Append( wxID_ANY, _( "Print" ) ); - m_tools_viewSource = m_tools_menu->Append( wxID_ANY, _( "View Source" ) ); - m_tools_menu->AppendSeparator(); - m_tools_layout = m_tools_menu->AppendCheckItem( wxID_ANY, _( "Use Layout Zoom" ) ); - m_tools_tiny = m_tools_menu->AppendCheckItem( wxID_ANY, _( "Tiny" ) ); - m_tools_small = m_tools_menu->AppendCheckItem( wxID_ANY, _( "Small" ) ); - m_tools_medium = m_tools_menu->AppendCheckItem( wxID_ANY, _( "Medium" ) ); - m_tools_large = m_tools_menu->AppendCheckItem( wxID_ANY, _( "Large" ) ); - m_tools_largest = m_tools_menu->AppendCheckItem( wxID_ANY, _( "Largest" ) ); - m_tools_menu->AppendSeparator(); - - // Find - m_find = m_tools_menu->Append( wxID_ANY, _( "Find" ) ); - m_tools_menu->AppendSeparator(); - - // History menu - m_tools_history_menu = new wxMenu(); - m_tools_clearhist = m_tools_history_menu->Append( wxID_ANY, _( "Clear History" ) ); - m_tools_history_menu->AppendSeparator(); - - m_tools_menu->AppendSubMenu( m_tools_history_menu, "History" ); -} - - -void WEB_NAVIGATOR::buildToolBar() -{ - // Populate the toolbar - m_toolbar->SetToolBitmapSize( wxSize( 26, 26 ) ); - m_toolbar->SetMargins( 3, 3 ); - - // The tool menu (one cannot have a menubar in a dialog, so uise a tool to display a menu - m_toolbar_tools = m_toolbar->AddTool( wxID_ANY, _( "Menu" ), KiBitmap( tools_xpm ), - _("Access to some options") ); - m_toolbar->AddSeparator(); - - // The navigation tools - m_toolbar_back = m_toolbar->AddTool( wxID_ANY, _( "Back" ), KiBitmap( left_xpm ) ); - m_toolbar_forward = m_toolbar->AddTool( wxID_ANY, _( "Forward" ), KiBitmap( right_xpm ) ); - m_toolbar_stop = m_toolbar->AddTool( wxID_ANY, _( "Stop" ), KiBitmap( red_xpm ) ); - m_toolbar_reload = m_toolbar->AddTool( wxID_ANY, _( "Reload" ), KiBitmap( reload2_xpm ) ); - - m_toolbar->AddSeparator(); - m_url = new wxTextCtrl( m_toolbar, wxID_ANY, wxT( "" ), wxDefaultPosition, wxSize( 400, - -1 ), wxTE_PROCESS_ENTER ); - m_toolbar->AddControl( m_url, _( "URL" ) ); - m_toolbar->AddSeparator(); - - // The Kicad footprint libraries extractor/selector tool: - m_toolbar_ListLibs = - m_toolbar->AddTool( wxID_ANY, _( "KicadLibs" ), KiBitmap( library_browse_xpm ), - _("List .pretty kicad footprint libraries and add selected libraries\n" - "to the footprint library table") ); - - m_toolbar->Realize(); -} - - -void WEB_NAVIGATOR::CreateFindToolBar( wxWindow* aParent ) -{ - m_find_toolbar = new wxToolBar( aParent, - wxID_ANY, wxDefaultPosition, wxDefaultSize, - wxTB_HORIZONTAL | wxTB_TEXT | wxTB_HORZ_LAYOUT ); - - // Create find control. - m_find_ctrl = new wxTextCtrl( m_find_toolbar, - wxID_ANY, wxEmptyString, wxDefaultPosition, - wxSize( 140, -1 ), wxTE_PROCESS_ENTER ); - - // Find options menu - wxMenu* findmenu = new wxMenu; - m_find_toolbar_wrap = findmenu->AppendCheckItem( wxID_ANY, "Wrap" ); - m_find_toolbar_matchcase = findmenu->AppendCheckItem( wxID_ANY, "Match Case" ); - m_find_toolbar_wholeword = findmenu->AppendCheckItem( wxID_ANY, "Entire Word" ); - m_find_toolbar_highlight = findmenu->AppendCheckItem( wxID_ANY, "Highlight" ); - m_find_toolbar_highlight->Check( true ); - - // Add find toolbar tools. - m_find_toolbar->SetToolSeparation( 7 ); - m_find_toolbar_done = m_find_toolbar->AddTool( wxID_ANY, "Close", - wxArtProvider::GetBitmap( wxART_CROSS_MARK ) ); - m_find_toolbar->AddSeparator(); - m_find_toolbar->AddControl( m_find_ctrl, "Find" ); - m_find_toolbar->AddSeparator(); - m_find_toolbar_next = m_find_toolbar->AddTool( wxID_ANY, "Next", - wxArtProvider::GetBitmap( wxART_GO_DOWN, wxART_TOOLBAR, wxSize( 16, 16 ) ) ); - m_find_toolbar_previous = m_find_toolbar->AddTool( wxID_ANY, "Previous", - wxArtProvider::GetBitmap( wxART_GO_UP, wxART_TOOLBAR, wxSize( 16, 16 ) ) ); - m_find_toolbar->AddSeparator(); - m_find_toolbar_options = m_find_toolbar->AddTool( wxID_ANY, "Options", - wxArtProvider::GetBitmap( wxART_PLUS, wxART_TOOLBAR, wxSize( 16, 16 ) ), - "", wxITEM_DROPDOWN ); - m_find_toolbar_options->SetDropdownMenu( findmenu ); - m_find_toolbar->Realize(); -} - - -// A helper function to try to validate urls names -// read in github repos. -// a valid .pretty github library name ( on github ) -// is expected ending with .pretty, and to be a path -// relative github url -static bool urlFilter( const wxString& aText ) -{ - if( aText.Length() < 8 ) // unlikely a valid .pretty name - return false; - - if( !aText.EndsWith( wxT( ".pretty" ) ) ) - return false; - - wxURI uri( aText ); - - if( !uri.GetQuery().IsEmpty() ) // the link is a request, not good - return false; - - return true; -} - - -void WEB_NAVIGATOR::OnListPrettyLibURLs( wxCommandEvent& event ) -{ - if( m_browser->IsBusy() ) // a page loading is currently in progress - return; - - wxString source = m_browser->GetPageSource(); - wxArrayString urls; - - HTML_LINK_PARSER parser( source, urls ); - parser.ParseLinks( urlFilter ); - - // Create library list. - // From github, the links can be relative to the github server URL - // In this case, make url absolute - wxString reposUrl( m_browser->GetCurrentURL() ); - wxURI reposUri( reposUrl ); - wxString reposName( reposUri.GetScheme() + wxT( "://" ) + reposUri.GetServer() ); - - for( unsigned ii = 0; ii < urls.GetCount(); ii++ ) - { - wxString url = urls[ii]; - wxURI currUri( url ); - - if( !currUri.HasServer() ) - { - if( url.StartsWith( wxT( "/" ) ) ) // path relative to the server name - url.Prepend( reposName ); - else // path relative to the server currently open path - url.Prepend( reposUrl ); - - urls[ii] = url; - } - } - - // Remove duplicates: - // A very basic test, not optimized, but usually we have only few urls - for( unsigned ii = 0; ii < urls.GetCount(); ii++ ) - { - for( unsigned jj = urls.GetCount() - 1; jj > ii; jj-- ) - { - if( urls[ii] == urls[jj] ) // Duplicate found - urls.RemoveAt( jj ); - } - } - - wxArrayInt choices; - wxString msg( _( "Urls detected as footprint .pretty libraries.\n" - "Selected urls will be added to the current footprint library list,\n" - "when closing the web viewer") ); - - if( wxGetSelectedChoices( choices, msg, - _( "Footprint libraries" ), urls, this ) <= 0 ) - return; - - // Add selected fp list in list - for( unsigned ii = 0; ii < choices.GetCount(); ii++ ) - { - wxString& url = urls[choices[ii]]; - urlListSelection->Add( url ); - } -} - - -/** - * Method that retrieves the current state from the web control and updates the GUI - * the reflect this current state. - */ -void WEB_NAVIGATOR::UpdateState() -{ - m_toolbar->EnableTool( m_toolbar_back->GetId(), m_browser->CanGoBack() ); - m_toolbar->EnableTool( m_toolbar_forward->GetId(), m_browser->CanGoForward() ); - - if( m_browser->IsBusy() ) - { - m_toolbar->EnableTool( m_toolbar_stop->GetId(), true ); - } - else - { - m_toolbar->EnableTool( m_toolbar_stop->GetId(), false ); - } - - SetTitle( m_browser->GetCurrentTitle() ); - m_url->SetValue( m_browser->GetCurrentURL() ); -} - - -void WEB_NAVIGATOR::OnIdle( wxIdleEvent& WXUNUSED( evt ) ) -{ - if( m_browser->IsBusy() ) - { - wxSetCursor( wxCURSOR_ARROWWAIT ); - m_toolbar->EnableTool( m_toolbar_stop->GetId(), true ); - } - else - { - wxSetCursor( wxNullCursor ); - m_toolbar->EnableTool( m_toolbar_stop->GetId(), false ); - - if( urlListSelection ) - TestAndStoreFootprintLibLink(); - } -} - - -// only for fp lib wizard called if there is a non null -// aUrlListSelection from idle event, to see if a valid -// footprint lib was selected by user, from the context menu -// (command copy link) -void WEB_NAVIGATOR::TestAndStoreFootprintLibLink() -{ - if( !urlListSelection ) - return; - - if( wxTheClipboard->Open() ) - { - if( wxTheClipboard->IsSupported( wxDF_TEXT ) ) - { - wxTextDataObject data; - - if( wxTheClipboard->GetData( data ) ) - { - // A valid text data is found - const wxString& text = data.GetText(); - - // Be sure it is a valid data for us, i.e. a valid - // kicad url - if( urlFilter( text ) && ( text.StartsWith( "http" ) ) ) - { - urlListSelection->Add( text ); - wxTheClipboard->SetData( new wxTextDataObject( wxEmptyString ) ); - } - } - - wxTheClipboard->Close(); - } - } -} - - -/** - * Callback invoked when user entered an URL and pressed enter - */ -void WEB_NAVIGATOR::OnUrl( wxCommandEvent& WXUNUSED( evt ) ) -{ - m_browser->LoadURL( m_url->GetValue() ); - m_browser->SetFocus(); - UpdateState(); -} - - -/** - * Callback invoked when user pressed the "back" button - */ -void WEB_NAVIGATOR::OnBack( wxCommandEvent& WXUNUSED( evt ) ) -{ - m_browser->GoBack(); - UpdateState(); -} - - -/** - * Callback invoked when user pressed the "forward" button - */ -void WEB_NAVIGATOR::OnForward( wxCommandEvent& WXUNUSED( evt ) ) -{ - m_browser->GoForward(); - UpdateState(); -} - - -/** - * Callback invoked when user pressed the "stop" button - */ -void WEB_NAVIGATOR::OnStop( wxCommandEvent& WXUNUSED( evt ) ) -{ - m_browser->Stop(); - UpdateState(); -} - - -/** - * Callback invoked when user pressed the "reload" button - */ -void WEB_NAVIGATOR::OnReload( wxCommandEvent& WXUNUSED( evt ) ) -{ - m_browser->Reload(); - UpdateState(); -} - - -void WEB_NAVIGATOR::OnClearHistory( wxCommandEvent& WXUNUSED( evt ) ) -{ - m_browser->ClearHistory(); - UpdateState(); -} - - -void WEB_NAVIGATOR::OnFind( wxCommandEvent& WXUNUSED( evt ) ) -{ - wxString value = m_browser->GetSelectedText(); - - if( value.Len() > 150 ) - { - value.Truncate( 150 ); - } - - m_find_ctrl->SetValue( value ); - - if( !m_find_toolbar->IsShown() ) - { - m_find_toolbar->Show( true ); - SendSizeEvent(); - } - - m_find_ctrl->SelectAll(); -} - - -void WEB_NAVIGATOR::OnFindDone( wxCommandEvent& WXUNUSED( evt ) ) -{ - m_browser->Find( "" ); - m_find_toolbar->Show( false ); - SendSizeEvent(); -} - - -void WEB_NAVIGATOR::OnFindText( wxCommandEvent& evt ) -{ - int flags = 0; - - if( m_find_toolbar_wrap->IsChecked() ) - flags |= wxWEBVIEW_FIND_WRAP; - - if( m_find_toolbar_wholeword->IsChecked() ) - flags |= wxWEBVIEW_FIND_ENTIRE_WORD; - - if( m_find_toolbar_matchcase->IsChecked() ) - flags |= wxWEBVIEW_FIND_MATCH_CASE; - - if( m_find_toolbar_highlight->IsChecked() ) - flags |= wxWEBVIEW_FIND_HIGHLIGHT_RESULT; - - if( m_find_toolbar_previous->GetId() == evt.GetId() ) - flags |= wxWEBVIEW_FIND_BACKWARDS; - - wxString find_text = m_find_ctrl->GetValue(); - - long count = wxNOT_FOUND; - - // On windows, for an unknwon reason (bug ?) some texts in some - // html pages hang the search. - // Waiting for 2 chars before starting a search reduces the risk - // (but the risk still exists) -#ifdef __WINDOWS__ - #define MIN_CHAR_CNT 2 - if( find_text.Length() >= MIN_CHAR_CNT ) - count = m_browser->Find( find_text, flags ); - else // Reset search - m_browser->Find( wxEmptyString, flags ); -#else - #define MIN_CHAR_CNT 1 - count = m_browser->Find( find_text, flags ); -#endif - - if( m_findText != find_text ) - { - m_findCount = count; - m_findText = find_text; - } - - if( count != wxNOT_FOUND || find_text.Length() < MIN_CHAR_CNT ) - m_find_ctrl->SetBackgroundColour( *wxWHITE ); - else - m_find_ctrl->SetBackgroundColour( wxColour( 255, 101, 101 ) ); - - m_find_ctrl->Refresh(); -} - - -/** - * Callback invoked when there is a request to load a new page (for instance - * when the user clicks a link) - */ -void WEB_NAVIGATOR::OnNavigationRequest( wxWebViewEvent& evt ) -{ - if( m_info->IsShown() ) - m_info->Dismiss(); - - wxASSERT( m_browser->IsBusy() ); - - UpdateState(); -} - - -/** - * Invoked when user selects the "View Source" menu item - */ -void WEB_NAVIGATOR::OnViewSourceRequest( wxCommandEvent& WXUNUSED( evt ) ) -{ - SourceViewDialog dlg( this, m_browser->GetPageSource() ); - - dlg.ShowModal(); -} - - -/** - * Invoked when user selects the "Menu" item - */ -void WEB_NAVIGATOR::OnToolsClicked( wxCommandEvent& WXUNUSED( evt ) ) -{ - if( m_browser->GetCurrentURL() == "" ) - return; - - m_tools_tiny->Check( false ); - m_tools_small->Check( false ); - m_tools_medium->Check( false ); - m_tools_large->Check( false ); - m_tools_largest->Check( false ); - - wxWebViewZoom zoom = m_browser->GetZoom(); - - switch( zoom ) - { - case wxWEBVIEW_ZOOM_TINY: - m_tools_tiny->Check(); - break; - - case wxWEBVIEW_ZOOM_SMALL: - m_tools_small->Check(); - break; - - case wxWEBVIEW_ZOOM_MEDIUM: - m_tools_medium->Check(); - break; - - case wxWEBVIEW_ZOOM_LARGE: - m_tools_large->Check(); - break; - - case wxWEBVIEW_ZOOM_LARGEST: - m_tools_largest->Check(); - break; - } - - // Firstly we clear the existing menu items, then we add the current ones - wxMenuHistoryMap::const_iterator it; - - for( it = m_histMenuItems.begin(); it != m_histMenuItems.end(); ++it ) - { - m_tools_history_menu->Destroy( it->first ); - } - - m_histMenuItems.clear(); - - wxVector > back = m_browser->GetBackwardHistory(); - wxVector > forward = m_browser->GetForwardHistory(); - - wxMenuItem* item; - - unsigned int i; - - for( i = 0; i < back.size(); i++ ) - { - item = m_tools_history_menu->AppendRadioItem( wxID_ANY, back[i]->GetTitle() ); - m_histMenuItems[item->GetId()] = back[i]; - Connect( item->GetId(), wxEVT_MENU, - wxCommandEventHandler( WEB_NAVIGATOR::OnHistory ), NULL, this ); - } - - wxString title = m_browser->GetCurrentTitle(); - - if( title.empty() ) - title = "(untitled)"; - - item = m_tools_history_menu->AppendRadioItem( wxID_ANY, title ); - item->Check(); - - // No need to connect the current item - m_histMenuItems[item->GetId()] = - wxSharedPtr( new wxWebViewHistoryItem( m_browser->GetCurrentURL(), - m_browser->GetCurrentTitle() ) ); - - for( i = 0; i < forward.size(); i++ ) - { - item = m_tools_history_menu->AppendRadioItem( wxID_ANY, forward[i]->GetTitle() ); - m_histMenuItems[item->GetId()] = forward[i]; - Connect( item->GetId(), wxEVT_TOOL, - wxCommandEventHandler( WEB_NAVIGATOR::OnHistory ), NULL, this ); - } - - wxPoint position = ScreenToClient( wxGetMousePosition() ); - PopupMenu( m_tools_menu, position.x, position.y ); -} - - -/** - * Invoked when user selects the zoom size in the menu - */ -void WEB_NAVIGATOR::OnSetZoom( wxCommandEvent& evt ) -{ - if( evt.GetId() == m_tools_tiny->GetId() ) - m_browser->SetZoom( wxWEBVIEW_ZOOM_TINY ); - else if( evt.GetId() == m_tools_small->GetId() ) - m_browser->SetZoom( wxWEBVIEW_ZOOM_SMALL ); - else if( evt.GetId() == m_tools_medium->GetId() ) - m_browser->SetZoom( wxWEBVIEW_ZOOM_MEDIUM ); - else if( evt.GetId() == m_tools_large->GetId() ) - m_browser->SetZoom( wxWEBVIEW_ZOOM_LARGE ); - else if( evt.GetId() == m_tools_largest->GetId() ) - m_browser->SetZoom( wxWEBVIEW_ZOOM_LARGEST ); - else - wxFAIL; -} - - -void WEB_NAVIGATOR::OnZoomLayout( wxCommandEvent& WXUNUSED( evt ) ) -{ - if( m_tools_layout->IsChecked() ) - m_browser->SetZoomType( wxWEBVIEW_ZOOM_TYPE_LAYOUT ); - else - m_browser->SetZoomType( wxWEBVIEW_ZOOM_TYPE_TEXT ); -} - - -/** - * Callback invoked when a loading error occurs - */ -void WEB_NAVIGATOR::OnError( wxWebViewEvent& evt ) -{ -#define WX_ERROR_CASE( type ) case type: \ - category = # type; break; - - wxString category; - - switch( evt.GetInt() ) - { - WX_ERROR_CASE( wxWEBVIEW_NAV_ERR_CONNECTION ); - WX_ERROR_CASE( wxWEBVIEW_NAV_ERR_CERTIFICATE ); - WX_ERROR_CASE( wxWEBVIEW_NAV_ERR_AUTH ); - WX_ERROR_CASE( wxWEBVIEW_NAV_ERR_SECURITY ); - WX_ERROR_CASE( wxWEBVIEW_NAV_ERR_NOT_FOUND ); - WX_ERROR_CASE( wxWEBVIEW_NAV_ERR_REQUEST ); - WX_ERROR_CASE( wxWEBVIEW_NAV_ERR_USER_CANCELLED ); - WX_ERROR_CASE( wxWEBVIEW_NAV_ERR_OTHER ); - } - - // Show the info bar with an error - wxString msg; - msg.Printf( _( "An error occurred loading %s\n'%s'" ), evt.GetURL().GetData(), - category.GetData() ); - m_info->ShowMessage( msg, wxICON_ERROR ); - - UpdateState(); -} - - -SourceViewDialog::SourceViewDialog( wxWindow* parent, wxString source ) : - wxDialog( parent, wxID_ANY, "Source Code", - wxDefaultPosition, wxSize( 700, 500 ), - wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ) -{ - wxStyledTextCtrl* text = new wxStyledTextCtrl( this, wxID_ANY ); - - text->SetMarginWidth( 1, 30 ); - text->SetMarginType( 1, wxSTC_MARGIN_NUMBER ); - text->SetText( source ); - - text->StyleClearAll(); - text->SetLexer( wxSTC_LEX_HTML ); - text->StyleSetForeground( wxSTC_H_DOUBLESTRING, wxColour( 255, 0, 0 ) ); - text->StyleSetForeground( wxSTC_H_SINGLESTRING, wxColour( 255, 0, 0 ) ); - text->StyleSetForeground( wxSTC_H_ENTITY, wxColour( 255, 0, 0 ) ); - text->StyleSetForeground( wxSTC_H_TAG, wxColour( 0, 150, 0 ) ); - text->StyleSetForeground( wxSTC_H_TAGUNKNOWN, wxColour( 0, 150, 0 ) ); - text->StyleSetForeground( wxSTC_H_ATTRIBUTE, wxColour( 0, 0, 150 ) ); - text->StyleSetForeground( wxSTC_H_ATTRIBUTEUNKNOWN, wxColour( 0, 0, 150 ) ); - text->StyleSetForeground( wxSTC_H_COMMENT, wxColour( 150, 150, 150 ) ); - - wxBoxSizer* sizer = new wxBoxSizer( wxVERTICAL ); - sizer->Add( text, 1, wxEXPAND ); - SetSizer( sizer ); -}