Commit cfb43317 authored by jean-pierre charras's avatar jean-pierre charras

Add a wizard to the footprint library table dialog editor, to help users to...

Add a wizard to the footprint library table dialog editor, to help users to select the right plugin, an existing enviroment vairable or an absolute path, and addl a list of new entries to the table.
Note: the wxWidgets webkit/webview library is needed.
On windows,there is no problem.
On Linux,  the libwebkitgtk-dev tool (sudo apt-get install libwebkitgtk-dev)  must be installed if it is missing (and wxWidgets rebuilt).
However, to avoid use of wxwebview, you can compile kicad with cmake option -DKICAD_USE_WEBKIT=OFF.
But the github plugin wizard will be not available.
parents 1393bcaf 83e43993
...@@ -36,6 +36,21 @@ option( KICAD_KEEPCASE ...@@ -36,6 +36,21 @@ option( KICAD_KEEPCASE
ON 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 colud 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.
# (I don't know the OSX status)
# However the default option is on
# This option could be removed soon, if no serious issue happens on Linux or OSX
option( KICAD_USE_WEBKIT
"Use system web kit to build a web viewer in footprint library wizard to easily select github libraries (default ON)."
ON
)
option( USE_WX_GRAPHICS_CONTEXT option( USE_WX_GRAPHICS_CONTEXT
"Use wxGraphicsContext for rendering (default OFF). Warning, this is experimental" ) "Use wxGraphicsContext for rendering (default OFF). Warning, this is experimental" )
...@@ -403,7 +418,13 @@ add_definitions( -DWX_COMPATIBILITY ) ...@@ -403,7 +418,13 @@ add_definitions( -DWX_COMPATIBILITY )
# See line 41 of CMakeModules/FindwxWidgets.cmake # See line 41 of CMakeModules/FindwxWidgets.cmake
set( wxWidgets_CONFIG_OPTIONS --static=no ) set( wxWidgets_CONFIG_OPTIONS --static=no )
find_package( wxWidgets 3.0.0 COMPONENTS gl aui adv html core net base xml REQUIRED ) if( KICAD_USE_WEBKIT )
set( webkitlib "webview" )
else()
set( webkitlib "" )
endif()
find_package( wxWidgets 3.0.0 COMPONENTS gl aui adv html core net base xml ${webkitlib} stc REQUIRED )
# Include wxWidgets macros. # Include wxWidgets macros.
include( ${wxWidgets_USE_FILE} ) include( ${wxWidgets_USE_FILE} )
...@@ -684,6 +705,9 @@ add_subdirectory( cvpcb ) ...@@ -684,6 +705,9 @@ add_subdirectory( cvpcb )
add_subdirectory( eeschema ) add_subdirectory( eeschema )
add_subdirectory( gerbview ) add_subdirectory( gerbview )
add_subdirectory( lib_dxf ) add_subdirectory( lib_dxf )
if( KICAD_USE_WEBKIT )
add_subdirectory( webviewer )
endif()
add_subdirectory( pcbnew ) add_subdirectory( pcbnew )
add_subdirectory( polygon ) add_subdirectory( polygon )
add_subdirectory( pagelayout_editor ) add_subdirectory( pagelayout_editor )
......
...@@ -8,6 +8,12 @@ endif() ...@@ -8,6 +8,12 @@ endif()
add_definitions( -DCVPCB ) add_definitions( -DCVPCB )
if( KICAD_USE_WEBKIT )
set( WEBVIEWERTOOL "webviewer" )
add_definitions( -DKICAD_USE_WEBKIT )
endif()
include_directories( BEFORE ${INC_BEFORE} ) include_directories( BEFORE ${INC_BEFORE} )
include_directories( include_directories(
./dialogs ./dialogs
...@@ -29,6 +35,8 @@ set( CVPCB_DIALOGS ...@@ -29,6 +35,8 @@ set( CVPCB_DIALOGS
../pcbnew/dialogs/dialog_fp_lib_table_base.cpp ../pcbnew/dialogs/dialog_fp_lib_table_base.cpp
../pcbnew/dialogs/dialog_fp_plugin_options.cpp ../pcbnew/dialogs/dialog_fp_plugin_options.cpp
../pcbnew/dialogs/dialog_fp_plugin_options_base.cpp ../pcbnew/dialogs/dialog_fp_plugin_options_base.cpp
../pcbnew/dialogs/wizard_add_fplib_base.cpp
../pcbnew/dialogs/wizard_add_fplib.cpp
) )
set( CVPCB_SRCS set( CVPCB_SRCS
...@@ -75,9 +83,11 @@ add_executable( cvpcb WIN32 MACOSX_BUNDLE ...@@ -75,9 +83,11 @@ add_executable( cvpcb WIN32 MACOSX_BUNDLE
../common/pgm_base.cpp ../common/pgm_base.cpp
${CVPCB_RESOURCES} ${CVPCB_RESOURCES}
) )
set_source_files_properties( ../common/single_top.cpp PROPERTIES set_source_files_properties( ../common/single_top.cpp PROPERTIES
COMPILE_DEFINITIONS "TOP_FRAME=FRAME_CVPCB;PGM_DATA_FILE_EXT=\"net\";BUILD_KIWAY_DLL" COMPILE_DEFINITIONS "TOP_FRAME=FRAME_CVPCB;PGM_DATA_FILE_EXT=\"net\";BUILD_KIWAY_DLL"
) )
target_link_libraries( cvpcb target_link_libraries( cvpcb
#singletop # replaces common, giving us restrictive control and link warnings. #singletop # replaces common, giving us restrictive control and link warnings.
# There's way too much crap coming in from common yet. # There's way too much crap coming in from common yet.
...@@ -107,6 +117,7 @@ target_link_libraries( cvpcb_kiface ...@@ -107,6 +117,7 @@ target_link_libraries( cvpcb_kiface
pcbcommon pcbcommon
pcad2kicadpcb pcad2kicadpcb
common common
${WEBVIEWERTOOL} # before bitmaps, because it uses some bitmaps defined in bitmaps
bitmaps bitmaps
polygon polygon
gal gal
......
...@@ -129,6 +129,8 @@ set( PCBNEW_DIALOGS ...@@ -129,6 +129,8 @@ set( PCBNEW_DIALOGS
footprint_wizard_frame.cpp footprint_wizard_frame.cpp
dialogs/dialog_footprint_wizard_list_base.cpp dialogs/dialog_footprint_wizard_list_base.cpp
dialogs/dialog_footprint_wizard_list.cpp dialogs/dialog_footprint_wizard_list.cpp
dialogs/wizard_add_fplib_base.cpp
dialogs/wizard_add_fplib.cpp
) )
set( PCBNEW_IMPORT_DXF set( PCBNEW_IMPORT_DXF
...@@ -368,6 +370,11 @@ if( UNIX AND NOT APPLE ) ...@@ -368,6 +370,11 @@ if( UNIX AND NOT APPLE )
list( APPEND PCBNEW_EXTRA_LIBS rt ) list( APPEND PCBNEW_EXTRA_LIBS rt )
endif() endif()
if( KICAD_USE_WEBKIT )
set( WEBVIEWERTOOL "webviewer" )
add_definitions( -DKICAD_USE_WEBKIT )
endif()
if( KICAD_SCRIPTING_MODULES ) if( KICAD_SCRIPTING_MODULES )
...@@ -375,6 +382,7 @@ if( KICAD_SCRIPTING_MODULES ) ...@@ -375,6 +382,7 @@ if( KICAD_SCRIPTING_MODULES )
set( CMAKE_SWIG_FLAGS ${SWIG_FLAGS} ) set( CMAKE_SWIG_FLAGS ${SWIG_FLAGS} )
set_source_files_properties( scripting/pcbnew.i PROPERTIES CPLUSPLUS ON ) set_source_files_properties( scripting/pcbnew.i PROPERTIES CPLUSPLUS ON )
swig_add_module( pcbnew swig_add_module( pcbnew
python python
scripting/pcbnew.i scripting/pcbnew.i
...@@ -383,6 +391,7 @@ if( KICAD_SCRIPTING_MODULES ) ...@@ -383,6 +391,7 @@ if( KICAD_SCRIPTING_MODULES )
${PCBNEW_SRCS} ${PCBNEW_SRCS}
${PCBNEW_COMMON_SRCS} ${PCBNEW_COMMON_SRCS}
) )
swig_link_libraries( pcbnew swig_link_libraries( pcbnew
3d-viewer 3d-viewer
pcbcommon pcbcommon
...@@ -393,6 +402,7 @@ if( KICAD_SCRIPTING_MODULES ) ...@@ -393,6 +402,7 @@ if( KICAD_SCRIPTING_MODULES )
idf3 idf3
${GITHUB_PLUGIN_LIBRARIES} ${GITHUB_PLUGIN_LIBRARIES}
polygon polygon
${WEBVIEWERTOOL}
bitmaps bitmaps
gal gal
${GLEW_LIBRARIES} ${GLEW_LIBRARIES}
...@@ -559,6 +569,7 @@ target_link_libraries( pcbnew_kiface ...@@ -559,6 +569,7 @@ target_link_libraries( pcbnew_kiface
common common
pcad2kicadpcb pcad2kicadpcb
polygon polygon
${WEBVIEWERTOOL} # before bitmaps, because it uses some bitmaps defined in bitmap
bitmaps bitmaps
gal gal
lib_dxf lib_dxf
......
...@@ -43,6 +43,8 @@ ...@@ -43,6 +43,8 @@
#include <invoke_pcb_dialog.h> #include <invoke_pcb_dialog.h>
#include <grid_tricks.h> #include <grid_tricks.h>
#include <confirm.h> #include <confirm.h>
#include <wizard_add_fplib.h>
/// grid column order is established by this sequence /// grid column order is established by this sequence
enum COL_ORDER enum COL_ORDER
...@@ -356,6 +358,11 @@ public: ...@@ -356,6 +358,11 @@ public:
wxAuiNotebookEvent uneventful; wxAuiNotebookEvent uneventful;
pageChangedHandler( uneventful ); pageChangedHandler( uneventful );
// Gives a selection for each grid, mainly for delete lib button.
// Without that, we do not see what lib will be deleted
m_global_grid->SelectRow(0);
m_project_grid->SelectRow(0);
// for ALT+A handling, we want the initial focus to be on the first selected grid. // for ALT+A handling, we want the initial focus to be on the first selected grid.
m_cur_grid->SetFocus(); m_cur_grid->SetFocus();
} }
...@@ -512,11 +519,32 @@ private: ...@@ -512,11 +519,32 @@ private:
// wx documentation is wrong, SetGridCursor does not make visible. // wx documentation is wrong, SetGridCursor does not make visible.
m_cur_grid->MakeCellVisible( last_row, 0 ); m_cur_grid->MakeCellVisible( last_row, 0 );
m_cur_grid->SetGridCursor( last_row, 0 ); m_cur_grid->SetGridCursor( last_row, 0 );
m_cur_grid->SelectRow( m_cur_grid->GetGridCursorRow() );
} }
} }
void deleteRowHandler( wxMouseEvent& event ) void deleteRowHandler( wxMouseEvent& event )
{ {
#if 1
int currRow = getCursorRow();
wxArrayInt selectedRows = m_cur_grid->GetSelectedRows();
if( selectedRows.size() == 0 && getCursorRow() >= 0 )
selectedRows.Add( getCursorRow() );
std::sort( selectedRows.begin(), selectedRows.end() );
for( int ii = selectedRows.GetCount()-1; ii >= 0; ii-- )
{
int row = selectedRows[ii];
m_cur_grid->DeleteRows( row, 1 );
}
if( currRow >= m_cur_grid->GetNumberRows() )
m_cur_grid->SetGridCursor(m_cur_grid->GetNumberRows()-1, getCursorCol() );
m_cur_grid->SelectRow( m_cur_grid->GetGridCursorRow() );
#else
int rowCount = m_cur_grid->GetNumberRows(); int rowCount = m_cur_grid->GetNumberRows();
int curRow = getCursorRow(); int curRow = getCursorRow();
...@@ -525,8 +553,11 @@ private: ...@@ -525,8 +553,11 @@ private:
m_cur_grid->DeleteRows( curRow ); m_cur_grid->DeleteRows( curRow );
if( curRow && curRow == rowCount - 1 ) if( curRow && curRow == rowCount - 1 )
{
m_cur_grid->SetGridCursor( curRow-1, getCursorCol() ); m_cur_grid->SetGridCursor( curRow-1, getCursorCol() );
}
} }
#endif
} }
void moveUpHandler( wxMouseEvent& event ) void moveUpHandler( wxMouseEvent& event )
...@@ -557,6 +588,7 @@ private: ...@@ -557,6 +588,7 @@ private:
m_cur_grid->MakeCellVisible( curRow, curCol ); m_cur_grid->MakeCellVisible( curRow, curCol );
m_cur_grid->SetGridCursor( curRow, curCol ); m_cur_grid->SetGridCursor( curRow, curCol );
m_cur_grid->SelectRow( getCursorRow() );
} }
} }
...@@ -588,6 +620,7 @@ private: ...@@ -588,6 +620,7 @@ private:
m_cur_grid->MakeCellVisible( curRow, curCol ); m_cur_grid->MakeCellVisible( curRow, curCol );
m_cur_grid->SetGridCursor( curRow, curCol ); m_cur_grid->SetGridCursor( curRow, curCol );
m_cur_grid->SelectRow( getCursorRow() );
} }
} }
...@@ -623,6 +656,8 @@ private: ...@@ -623,6 +656,8 @@ private:
} }
} }
void OnClickLibraryWizard( wxCommandEvent& event );
void onCancelButtonClick( wxCommandEvent& event ) void onCancelButtonClick( wxCommandEvent& event )
{ {
EndModal( 0 ); EndModal( 0 );
...@@ -719,7 +754,7 @@ private: ...@@ -719,7 +754,7 @@ private:
// the current project. // the current project.
unique.insert( PROJECT_VAR_NAME ); unique.insert( PROJECT_VAR_NAME );
unique.insert( FP_LIB_TABLE::GlobalPathEnvVariableName() ); unique.insert( FP_LIB_TABLE::GlobalPathEnvVariableName() );
// This special environment variable is used to locad 3d shapes // This special environment variable is used to locate 3d shapes
unique.insert( KISYS3DMOD ); unique.insert( KISYS3DMOD );
unique.insert( FP_LIB_TABLE::GlobalPathEnvVariableName() ); unique.insert( FP_LIB_TABLE::GlobalPathEnvVariableName() );
...@@ -757,6 +792,50 @@ private: ...@@ -757,6 +792,50 @@ private:
int DIALOG_FP_LIB_TABLE::m_pageNdx = 0; int DIALOG_FP_LIB_TABLE::m_pageNdx = 0;
void DIALOG_FP_LIB_TABLE::OnClickLibraryWizard( wxCommandEvent& event )
{
wxArrayString envVariableList;
// 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() ) )
return; // Aborted by user
wxGrid* libgrid = m_cur_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 ) )
{
if( ! libDescr[0].IsEmpty() && m_cur_grid->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] );
// Add the plugin name:
tbl->SetValue( last_row, COL_TYPE, libDescr[2] );
libgrid->MakeCellVisible( last_row, 0 );
libgrid->SetGridCursor( last_row, 0 );
}
libDescr.Clear();
}
libgrid->SelectRow( libgrid->GetGridCursorRow() );
}
int InvokePcbLibTableEditor( wxTopLevelWindow* aParent, FP_LIB_TABLE* aGlobal, FP_LIB_TABLE* aProject ) int InvokePcbLibTableEditor( wxTopLevelWindow* aParent, FP_LIB_TABLE* aGlobal, FP_LIB_TABLE* aProject )
{ {
DIALOG_FP_LIB_TABLE dlg( aParent, aGlobal, aProject ); DIALOG_FP_LIB_TABLE dlg( aParent, aGlobal, aProject );
......
...@@ -103,6 +103,9 @@ DIALOG_FP_LIB_TABLE_BASE::DIALOG_FP_LIB_TABLE_BASE( wxWindow* parent, wxWindowID ...@@ -103,6 +103,9 @@ DIALOG_FP_LIB_TABLE_BASE::DIALOG_FP_LIB_TABLE_BASE( wxWindow* parent, wxWindowID
bSizer51->Add( m_append_button, 0, wxALL, 5 ); 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 = new wxButton( this, wxID_ANY, _("Remove Library"), wxDefaultPosition, wxDefaultSize, 0 );
m_delete_button->SetToolTip( _("Remove a PCB library from this library table") ); m_delete_button->SetToolTip( _("Remove a PCB library from this library table") );
...@@ -194,6 +197,7 @@ DIALOG_FP_LIB_TABLE_BASE::DIALOG_FP_LIB_TABLE_BASE( wxWindow* parent, wxWindowID ...@@ -194,6 +197,7 @@ DIALOG_FP_LIB_TABLE_BASE::DIALOG_FP_LIB_TABLE_BASE( wxWindow* parent, wxWindowID
this->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( DIALOG_FP_LIB_TABLE_BASE::onKeyDown ) ); 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_auinotebook->Connect( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, wxAuiNotebookEventHandler( DIALOG_FP_LIB_TABLE_BASE::pageChangedHandler ), NULL, this );
m_append_button->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_FP_LIB_TABLE_BASE::appendRowHandler ), NULL, this ); m_append_button->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( 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_delete_button->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_FP_LIB_TABLE_BASE::deleteRowHandler ), NULL, this ); m_delete_button->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_FP_LIB_TABLE_BASE::deleteRowHandler ), NULL, this );
m_move_up_button->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_FP_LIB_TABLE_BASE::moveUpHandler ), NULL, this ); m_move_up_button->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_FP_LIB_TABLE_BASE::moveUpHandler ), NULL, this );
m_move_down_button->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_FP_LIB_TABLE_BASE::moveDownHandler ), NULL, this ); m_move_down_button->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_FP_LIB_TABLE_BASE::moveDownHandler ), NULL, this );
...@@ -209,6 +213,7 @@ DIALOG_FP_LIB_TABLE_BASE::~DIALOG_FP_LIB_TABLE_BASE() ...@@ -209,6 +213,7 @@ DIALOG_FP_LIB_TABLE_BASE::~DIALOG_FP_LIB_TABLE_BASE()
this->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( DIALOG_FP_LIB_TABLE_BASE::onKeyDown ) ); 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_auinotebook->Disconnect( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, wxAuiNotebookEventHandler( DIALOG_FP_LIB_TABLE_BASE::pageChangedHandler ), NULL, this );
m_append_button->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_FP_LIB_TABLE_BASE::appendRowHandler ), NULL, this ); m_append_button->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( 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_delete_button->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_FP_LIB_TABLE_BASE::deleteRowHandler ), NULL, this ); m_delete_button->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_FP_LIB_TABLE_BASE::deleteRowHandler ), NULL, this );
m_move_up_button->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_FP_LIB_TABLE_BASE::moveUpHandler ), NULL, this ); m_move_up_button->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_FP_LIB_TABLE_BASE::moveUpHandler ), NULL, this );
m_move_down_button->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_FP_LIB_TABLE_BASE::moveDownHandler ), NULL, this ); m_move_down_button->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_FP_LIB_TABLE_BASE::moveDownHandler ), NULL, this );
......
...@@ -751,6 +751,94 @@ ...@@ -751,6 +751,94 @@
<event name="OnUpdateUI"></event> <event name="OnUpdateUI"></event>
</object> </object>
</object> </object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxButton" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default">0</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Append with Wizard</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_buttonWizard</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">OnClickLibraryWizard</event>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="0"> <object class="sizeritem" expanded="0">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxALL</property> <property name="flag">wxALL</property>
......
...@@ -47,6 +47,7 @@ class DIALOG_FP_LIB_TABLE_BASE : public DIALOG_SHIM ...@@ -47,6 +47,7 @@ class DIALOG_FP_LIB_TABLE_BASE : public DIALOG_SHIM
wxPanel* m_project_panel; wxPanel* m_project_panel;
wxGrid* m_project_grid; wxGrid* m_project_grid;
wxButton* m_append_button; wxButton* m_append_button;
wxButton* m_buttonWizard;
wxButton* m_delete_button; wxButton* m_delete_button;
wxButton* m_move_up_button; wxButton* m_move_up_button;
wxButton* m_move_down_button; wxButton* m_move_down_button;
...@@ -61,6 +62,7 @@ class DIALOG_FP_LIB_TABLE_BASE : public DIALOG_SHIM ...@@ -61,6 +62,7 @@ class DIALOG_FP_LIB_TABLE_BASE : public DIALOG_SHIM
virtual void onKeyDown( wxKeyEvent& event ) = 0; virtual void onKeyDown( wxKeyEvent& event ) = 0;
virtual void pageChangedHandler( wxAuiNotebookEvent& event ) = 0; virtual void pageChangedHandler( wxAuiNotebookEvent& event ) = 0;
virtual void appendRowHandler( wxMouseEvent& event ) = 0; virtual void appendRowHandler( wxMouseEvent& event ) = 0;
virtual void OnClickLibraryWizard( wxCommandEvent& event ) = 0;
virtual void deleteRowHandler( wxMouseEvent& event ) = 0; virtual void deleteRowHandler( wxMouseEvent& event ) = 0;
virtual void moveUpHandler( wxMouseEvent& event ) = 0; virtual void moveUpHandler( wxMouseEvent& event ) = 0;
virtual void moveDownHandler( wxMouseEvent& event ) = 0; virtual void moveDownHandler( wxMouseEvent& event ) = 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 folde.\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 );
bSizerMain->Add( m_dirCtrl, 1, wxEXPAND | wxALL, 5 );
m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bSizerMain->Add( m_staticline1, 0, wxEXPAND | wxALL, 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, 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 );
}
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 );
}
This diff is collapsed.
///////////////////////////////////////////////////////////////////////////
// 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 <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
class DIALOG_SHIM;
#include "dialog_shim.h"
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/dirctrl.h>
#include <wx/statline.h>
#include <wx/sizer.h>
#include <wx/button.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_SELECT_DIRLIST_BASE
///////////////////////////////////////////////////////////////////////////////
class DIALOG_SELECT_DIRLIST_BASE : public DIALOG_SHIM
{
private:
protected:
wxStaticText* m_staticText;
wxGenericDirCtrl* m_dirCtrl;
wxStaticLine* m_staticline1;
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(); }
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,300 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_SELECT_DIRLIST_BASE();
};
#endif //__DIALOG_SELECT_DIRLIST_BASE_H__
This diff is collapsed.
/**
* @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.
*
* 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
*/
#include <wx/wx.h>
#include <dialog_helpers.h>
#include <wizard_add_fplib_base.h>
// 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 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();
/**
* 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
*/
bool GetLibDescr( int aIdx, wxArrayString& aLibDescr )
{
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;
}
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
void selectLibsGithub(); // select a set of library on Github
void updateFromPlugingChoice(); // update dialog options and widgets
// depending on the plugin choice
int GetEnvVarCount() // Get the number of rows in env var table
{
return m_gridEnvironmentVariablesList->GetTable()->GetRowsCount();
}
int GetLibsCount() // Get the number of rows in libs table
{
return m_gridFpListLibs->GetTable()->GetRowsCount();
}
bool IsGithubPlugin() // Helper funct, return true if
{ // the Github plugin is the choice
return m_rbFpLibFormat->GetSelection() == GITHUB_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 );
bool ValidateOptions();
};
// 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;
}
};
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jun 5 2014)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __WIZARD_ADD_FPLIB_BASE_H__
#define __WIZARD_ADD_FPLIB_BASE_H__
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
#include <wx/string.h>
#include <wx/radiobox.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/statline.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/statbmp.h>
#include <wx/stattext.h>
#include <wx/textctrl.h>
#include <wx/sizer.h>
#include <wx/grid.h>
#include <wx/button.h>
#include <wx/statbox.h>
#include <wx/wizard.h>
#include <wx/dynarray.h>
WX_DEFINE_ARRAY_PTR( wxWizardPageSimple*, WizardPages );
#include <wx/dirctrl.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class WIZARD_FPLIB_TABLE_BASE
///////////////////////////////////////////////////////////////////////////////
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_buttonAddLib;
wxButton* m_buttonRemoveLib;
// Virtual event handlers, overide them in your derived class
virtual void OnFinish( 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 OnAddFpLibs( wxCommandEvent& event ) { event.Skip(); }
virtual void OnRemoveFpLibs( 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 );
WizardPages m_pages;
~WIZARD_FPLIB_TABLE_BASE();
};
///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_SELECT_DIRLIST_BASE
///////////////////////////////////////////////////////////////////////////////
class DIALOG_SELECT_DIRLIST_BASE : public wxDialog
{
private:
protected:
wxStaticText* m_staticTextInfo;
wxGenericDirCtrl* m_dirCtrl;
wxStaticLine* m_staticline1;
wxStdDialogButtonSizer* m_sdbSizer;
wxButton* m_sdbSizerOK;
wxButton* m_sdbSizerCancel;
// Virtual event handlers, overide them in your derived class
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( 346,325 ), long style = wxDEFAULT_DIALOG_STYLE );
~DIALOG_SELECT_DIRLIST_BASE();
};
#endif //__WIZARD_ADD_FPLIB_BASE_H__
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 )
/**
* @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 <wx/wx.h>
#include <wx/html/htmlpars.h>
#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 );
}
}
/**
* @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 <wx/wx.h>
#include <wx/html/htmlpars.h>
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:
* "<a href="/KiCad/Valves.pretty" itemprop="name codeRepository"> Valves.pretty</a>"
* 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
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment