Browse Source
Fold 3D Search Paths dialog into Configure Paths.
Fold 3D Search Paths dialog into Configure Paths.
Use in-place editing for both. Fixes: lp:1743823 * https://bugs.launchpad.net/kicad/+bug/1743823 (cherry picked from commit 33622cd)pull/17/head
41 changed files with 2130 additions and 4216 deletions
-
103d-viewer/3d_cache/3d_cache.cpp
-
123d-viewer/3d_cache/3d_cache.h
-
153d-viewer/3d_cache/dialogs/3d_cache_dialogs.cpp
-
43d-viewer/3d_cache/dialogs/3d_cache_dialogs.h
-
3833d-viewer/3d_cache/dialogs/dlg_3d_pathconfig.cpp
-
573d-viewer/3d_cache/dialogs/dlg_3d_pathconfig.h
-
1623d-viewer/3d_cache/dialogs/dlg_3d_pathconfig_base.cpp
-
10463d-viewer/3d_cache/dialogs/dlg_3d_pathconfig_base.fbp
-
673d-viewer/3d_cache/dialogs/dlg_3d_pathconfig_base.h
-
63d-viewer/3d_cache/dialogs/dlg_select_3dmodel.cpp
-
43d-viewer/3d_cache/dialogs/dlg_select_3dmodel.h
-
323d-viewer/3d_cache/dialogs/panel_prev_model.h
-
873d-viewer/3d_cache/str_rsort.h
-
33d-viewer/CMakeLists.txt
-
5common/CMakeLists.txt
-
4common/dialog_shim.cpp
-
565common/dialogs/dialog_configure_paths.cpp
-
186common/dialogs/dialog_configure_paths_base.cpp
-
1021common/dialogs/dialog_configure_paths_base.fbp
-
75common/dialogs/dialog_configure_paths_base.h
-
511common/dialogs/dialog_env_var_config.cpp
-
167common/dialogs/dialog_env_var_config_base.cpp
-
1335common/dialogs/dialog_env_var_config_base.fbp
-
102common/dialogs/dialog_env_var_config_base.h
-
97common/filename_resolver.cpp
-
42common/pgm_base.cpp
-
3cvpcb/cvpcb_mainframe.cpp
-
2eeschema/sch_base_frame.cpp
-
87include/dialog_configure_paths.h
-
102include/dialog_env_var_config.h
-
23include/filename_resolver.h
-
48include/kicad_string.h
-
7include/pgm_base.h
-
2kicad/mainframe.cpp
-
8pcbnew/dialogs/dialog_edit_footprint_for_BoardEditor.cpp
-
8pcbnew/dialogs/dialog_edit_footprint_for_fp_editor.cpp
-
4pcbnew/exporters/export_idf.cpp
-
2pcbnew/footprint_edit_frame.cpp
-
2pcbnew/pcb_edit_frame.cpp
-
40utils/kicad2step/pcb/3d_resolver.cpp
-
10utils/kicad2step/pcb/3d_resolver.h
@ -1,383 +0,0 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2016 Cirilo Bernardo <cirilo.bernardo@gmail.com> |
|||
* |
|||
* 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/msgdlg.h>
|
|||
#include <pgm_base.h>
|
|||
#include <html_messagebox.h>
|
|||
#include "3d_cache/dialogs/dlg_3d_pathconfig.h"
|
|||
#include "3d_cache/3d_filename_resolver.h"
|
|||
|
|||
DLG_3D_PATH_CONFIG::DLG_3D_PATH_CONFIG( wxWindow* aParent, S3D_FILENAME_RESOLVER* aResolver ) : |
|||
DLG_3D_PATH_CONFIG_BASE( aParent ), m_resolver( aResolver ) |
|||
{ |
|||
initDialog(); |
|||
|
|||
GetSizer()->SetSizeHints( this ); |
|||
Centre(); |
|||
|
|||
return; |
|||
} |
|||
|
|||
|
|||
void DLG_3D_PATH_CONFIG::initDialog() |
|||
{ |
|||
m_Aliases->EnableEditing( true ); |
|||
|
|||
// Gives a min width to each column, when the user drags a column
|
|||
m_Aliases->SetColMinimalWidth( 0, 80 ); |
|||
m_Aliases->SetColMinimalWidth( 1, 300 ); |
|||
m_Aliases->SetColMinimalWidth( 2, 120 ); |
|||
m_Aliases->SetColMinimalAcceptableWidth( 80 ); |
|||
|
|||
// Set column sizes to this min value
|
|||
m_Aliases->SetColSize( 0, 80 ); |
|||
m_Aliases->SetColSize( 1, 300 ); |
|||
m_Aliases->SetColSize( 2, 120 ); |
|||
|
|||
m_EnvVars->SetColMinimalWidth( 0, 80 ); |
|||
m_EnvVars->SetColMinimalWidth( 1, 300 ); |
|||
m_EnvVars->SetColMinimalAcceptableWidth( 80 ); |
|||
m_EnvVars->SetColSize( 0, 80 ); |
|||
m_EnvVars->SetColSize( 1, 300 ); |
|||
|
|||
if( m_resolver ) |
|||
{ |
|||
updateEnvVars(); |
|||
|
|||
// prohibit these characters in the alias names: []{}()%~<>"='`;:.,&?/\|$
|
|||
m_aliasValidator.SetStyle( wxFILTER_EXCLUDE_CHAR_LIST ); |
|||
m_aliasValidator.SetCharExcludes( wxT( "{}[]()%~<>\"='`;:.,&?/\\|$" ) ); |
|||
|
|||
const std::list< S3D_ALIAS >* rpaths = m_resolver->GetPaths(); |
|||
std::list< S3D_ALIAS >::const_iterator rI = rpaths->begin(); |
|||
std::list< S3D_ALIAS >::const_iterator rE = rpaths->end(); |
|||
size_t listsize = rpaths->size(); |
|||
size_t listidx = 0; |
|||
|
|||
while( rI != rE && ( (*rI).m_alias.StartsWith( "${" ) || (*rI).m_alias.StartsWith( "$(" ) ) ) |
|||
{ |
|||
++listidx; |
|||
++rI; |
|||
} |
|||
|
|||
if( listidx < listsize ) |
|||
m_curdir = (*rI).m_pathexp; |
|||
else |
|||
return; |
|||
|
|||
listsize = listsize - listidx - m_Aliases->GetNumberRows(); |
|||
|
|||
// note: if the list allocation fails we have bigger problems
|
|||
// and there is no point in trying to notify the user here
|
|||
if( listsize > 0 && !m_Aliases->InsertRows( 0, listsize ) ) |
|||
return; |
|||
|
|||
int nitems = 0; |
|||
wxGridCellTextEditor* pEdAlias; |
|||
|
|||
while( rI != rE ) |
|||
{ |
|||
m_Aliases->SetCellValue( nitems, 0, rI->m_alias ); |
|||
|
|||
if( 0 == nitems ) |
|||
{ |
|||
m_Aliases->SetCellEditor( nitems, 0, new wxGridCellTextEditor ); |
|||
pEdAlias = (wxGridCellTextEditor*) m_Aliases->GetCellEditor( nitems, 0 ); |
|||
pEdAlias->SetValidator( m_aliasValidator ); |
|||
pEdAlias->DecRef(); |
|||
} |
|||
else |
|||
{ |
|||
pEdAlias->IncRef(); |
|||
m_Aliases->SetCellEditor( nitems, 0, pEdAlias ); |
|||
} |
|||
|
|||
m_Aliases->SetCellValue( nitems, 1, rI->m_pathvar ); |
|||
m_Aliases->SetCellValue( nitems++, 2, rI->m_description ); |
|||
|
|||
// TODO: implement a wxGridCellEditor which invokes a wxDirDialog
|
|||
|
|||
++rI; |
|||
} |
|||
|
|||
m_Aliases->AutoSize(); |
|||
} |
|||
} |
|||
|
|||
|
|||
bool DLG_3D_PATH_CONFIG::TransferDataFromWindow() |
|||
{ |
|||
if( NULL == m_resolver ) |
|||
{ |
|||
wxMessageBox( _( "[BUG] No valid resolver; data will not be updated" ), |
|||
_( "Update 3D search path list" ) ); |
|||
|
|||
return false; |
|||
} |
|||
|
|||
std::vector<S3D_ALIAS> alist; |
|||
S3D_ALIAS alias; |
|||
|
|||
int ni = m_Aliases->GetNumberRows(); |
|||
|
|||
if( ni <= 0 ) |
|||
{ |
|||
// note: UI usability: we should ask a user if they're sure they
|
|||
// want to clear the entire path list
|
|||
m_resolver->UpdatePathList( alist ); |
|||
return true; |
|||
} |
|||
|
|||
for( int i = 0; i < ni; ++i ) |
|||
{ |
|||
alias.m_alias = m_Aliases->GetCellValue( i, 0 ); |
|||
alias.m_pathvar = m_Aliases->GetCellValue( i, 1 ); |
|||
alias.m_description = m_Aliases->GetCellValue( i, 2 ); |
|||
|
|||
if( !alias.m_alias.empty() && !alias.m_pathvar.empty() ) |
|||
alist.push_back( alias ); |
|||
|
|||
} |
|||
|
|||
return m_resolver->UpdatePathList( alist ); |
|||
} |
|||
|
|||
|
|||
void DLG_3D_PATH_CONFIG::OnAddAlias( wxCommandEvent& event ) |
|||
{ |
|||
int ni = m_Aliases->GetNumberRows(); |
|||
|
|||
if( m_Aliases->InsertRows( ni, 1 ) ) |
|||
{ |
|||
wxGridCellTextEditor* pEdAlias; |
|||
pEdAlias = (wxGridCellTextEditor*) m_Aliases->GetCellEditor( 0, 0 ); |
|||
m_Aliases->SetCellEditor( ni, 0, pEdAlias ); |
|||
m_Aliases->SelectRow( ni, false ); |
|||
m_Aliases->AutoSize(); |
|||
Fit(); |
|||
|
|||
// TODO: set the editors on any newly created rows
|
|||
} |
|||
|
|||
event.Skip(); |
|||
} |
|||
|
|||
|
|||
void DLG_3D_PATH_CONFIG::OnDelAlias( wxCommandEvent& event ) |
|||
{ |
|||
wxArrayInt sel = m_Aliases->GetSelectedRows(); |
|||
|
|||
if( sel.empty() ) |
|||
{ |
|||
wxMessageBox( _( "No entry selected" ), _( "Delete alias entry" ) ); |
|||
return; |
|||
} |
|||
|
|||
if( sel.size() > 1 ) |
|||
{ |
|||
wxMessageBox( _( "Multiple entries selected; please\nselect only one entry" ), |
|||
_( "Delete alias entry" ) ); |
|||
return; |
|||
} |
|||
|
|||
if( m_Aliases->GetNumberRows() > 1 ) |
|||
{ |
|||
int ni = sel.front(); |
|||
m_Aliases->DeleteRows( ni, 1 ); |
|||
|
|||
if( ni >= m_Aliases->GetNumberRows() ) |
|||
ni = m_Aliases->GetNumberRows() - 1; |
|||
|
|||
m_Aliases->SelectRow( ni, false ); |
|||
m_Aliases->AutoSize(); |
|||
Fit(); |
|||
} |
|||
else |
|||
{ |
|||
m_Aliases->SetCellValue( 0, 0, wxEmptyString ); |
|||
m_Aliases->SetCellValue( 0, 1, wxEmptyString ); |
|||
m_Aliases->SetCellValue( 0, 2, wxEmptyString ); |
|||
} |
|||
|
|||
event.Skip(); |
|||
} |
|||
|
|||
|
|||
void DLG_3D_PATH_CONFIG::OnAliasMoveUp( wxCommandEvent& event ) |
|||
{ |
|||
wxArrayInt sel = m_Aliases->GetSelectedRows(); |
|||
|
|||
if( sel.empty() ) |
|||
{ |
|||
wxMessageBox( _( "No entry selected" ), _( "Move alias up" ) ); |
|||
return; |
|||
} |
|||
|
|||
if( sel.size() > 1 ) |
|||
{ |
|||
wxMessageBox( _( "Multiple entries selected; please\nselect only one entry" ), |
|||
_( "Move alias up" ) ); |
|||
return; |
|||
} |
|||
|
|||
int ci = sel.front(); |
|||
|
|||
if( ci > 0 ) |
|||
{ |
|||
S3D_ALIAS al0; |
|||
al0.m_alias = m_Aliases->GetCellValue( ci, 0 ); |
|||
al0.m_pathvar = m_Aliases->GetCellValue( ci, 1 ); |
|||
al0.m_description = m_Aliases->GetCellValue( ci, 2 ); |
|||
|
|||
int ni = ci - 1; |
|||
m_Aliases->SetCellValue( ci, 0, m_Aliases->GetCellValue( ni, 0 ) ); |
|||
m_Aliases->SetCellValue( ci, 1, m_Aliases->GetCellValue( ni, 1 ) ); |
|||
m_Aliases->SetCellValue( ci, 2, m_Aliases->GetCellValue( ni, 2 ) ); |
|||
|
|||
m_Aliases->SetCellValue( ni, 0, al0.m_alias ); |
|||
m_Aliases->SetCellValue( ni, 1, al0.m_pathvar ); |
|||
m_Aliases->SetCellValue( ni, 2, al0.m_description ); |
|||
m_Aliases->SelectRow( ni, false ); |
|||
} |
|||
|
|||
event.Skip(); |
|||
} |
|||
|
|||
|
|||
void DLG_3D_PATH_CONFIG::OnAliasMoveDown( wxCommandEvent& event ) |
|||
{ |
|||
wxArrayInt sel = m_Aliases->GetSelectedRows(); |
|||
|
|||
if( sel.empty() ) |
|||
{ |
|||
wxMessageBox( _( "No entry selected" ), _( "Move alias down" ) ); |
|||
return; |
|||
} |
|||
|
|||
if( sel.size() > 1 ) |
|||
{ |
|||
wxMessageBox( _( "Multiple entries selected; please\nselect only one entry" ), |
|||
_( "Move alias down" ) ); |
|||
return; |
|||
} |
|||
|
|||
int ni = m_Aliases->GetNumberRows() - 1; |
|||
int ci = sel.front(); |
|||
|
|||
if( ci < ni ) |
|||
{ |
|||
S3D_ALIAS al0; |
|||
al0.m_alias = m_Aliases->GetCellValue( ci, 0 ); |
|||
al0.m_pathvar = m_Aliases->GetCellValue( ci, 1 ); |
|||
al0.m_description = m_Aliases->GetCellValue( ci, 2 ); |
|||
|
|||
ni = ci + 1; |
|||
m_Aliases->SetCellValue( ci, 0, m_Aliases->GetCellValue( ni, 0 ) ); |
|||
m_Aliases->SetCellValue( ci, 1, m_Aliases->GetCellValue( ni, 1 ) ); |
|||
m_Aliases->SetCellValue( ci, 2, m_Aliases->GetCellValue( ni, 2 ) ); |
|||
|
|||
m_Aliases->SetCellValue( ni, 0, al0.m_alias ); |
|||
m_Aliases->SetCellValue( ni, 1, al0.m_pathvar ); |
|||
m_Aliases->SetCellValue( ni, 2, al0.m_description ); |
|||
m_Aliases->SelectRow( ni, false ); |
|||
} |
|||
|
|||
event.Skip(); |
|||
} |
|||
|
|||
|
|||
void DLG_3D_PATH_CONFIG::OnConfigEnvVar( wxCommandEvent& event ) |
|||
{ |
|||
Pgm().ConfigurePaths( this ); |
|||
updateEnvVars(); |
|||
event.Skip(); |
|||
} |
|||
|
|||
|
|||
void DLG_3D_PATH_CONFIG::updateEnvVars( void ) |
|||
{ |
|||
if( !m_resolver ) |
|||
return; |
|||
|
|||
std::list< wxString > epaths; |
|||
|
|||
m_resolver->GetKicadPaths( epaths ); |
|||
size_t nitems = epaths.size(); |
|||
size_t nrows = m_EnvVars->GetNumberRows(); |
|||
bool resize = nrows != nitems; // true after adding/removing env vars
|
|||
|
|||
if( nrows > nitems ) |
|||
{ |
|||
size_t ni = nrows - nitems; |
|||
m_EnvVars->DeleteRows( 0, ni ); |
|||
} |
|||
else if( nrows < nitems ) |
|||
{ |
|||
size_t ni = nitems - nrows; |
|||
m_EnvVars->InsertRows( 0, ni ); |
|||
} |
|||
|
|||
int j = 0; |
|||
|
|||
for( const auto& i : epaths ) |
|||
{ |
|||
wxString val = ExpandEnvVarSubstitutions( i ); |
|||
m_EnvVars->SetCellValue( j, 0, i ); |
|||
m_EnvVars->SetCellValue( j, 1, val ); |
|||
m_EnvVars->SetReadOnly( j, 0, true ); |
|||
m_EnvVars->SetReadOnly( j, 1, true ); |
|||
wxGridCellAttr* ap = m_EnvVars->GetOrCreateCellAttr( j, 0 ); |
|||
ap->SetReadOnly( true ); |
|||
ap->SetBackgroundColour( *wxLIGHT_GREY ); |
|||
m_EnvVars->SetRowAttr( j, ap ); |
|||
++j; |
|||
} |
|||
|
|||
m_EnvVars->AutoSize(); |
|||
|
|||
// Resizing the full dialog is sometimes needed for a clean display
|
|||
// i.e. when adding/removing Kicad environment variables
|
|||
if( resize ) |
|||
GetSizer()->SetSizeHints( this ); |
|||
|
|||
return; |
|||
} |
|||
|
|||
|
|||
void DLG_3D_PATH_CONFIG::OnHelp( wxCommandEvent& event ) |
|||
{ |
|||
wxString msg = _( "Enter the name and path for each 3D alias variable.<br>KiCad " |
|||
"environment variables and their values are shown for " |
|||
"reference only and cannot be edited." ); |
|||
msg << "<br><br><b>"; |
|||
msg << _( "Alias names may not contain any of the characters " ); |
|||
msg << "{}[]()%~<>\"='`;:.,&?/\\|$"; |
|||
msg << "</b>"; |
|||
|
|||
HTML_MESSAGE_BOX dlg( GetParent(), _( "Environment Variable Help" ) ); |
|||
dlg.AddHTML_Text( msg ); |
|||
dlg.ShowModal(); |
|||
|
|||
event.Skip(); |
|||
} |
|||
@ -1,57 +0,0 @@ |
|||
/* |
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2016 Cirilo Bernardo <cirilo.bernardo@gmail.com> |
|||
* |
|||
* 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 |
|||
*/ |
|||
|
|||
|
|||
#ifndef DLG_3D_PATHCONFIG_H |
|||
#define DLG_3D_PATHCONFIG_H |
|||
|
|||
#include <wx/valtext.h> |
|||
#include "dlg_3d_pathconfig_base.h" |
|||
|
|||
class S3D_FILENAME_RESOLVER; |
|||
|
|||
class DLG_3D_PATH_CONFIG : public DLG_3D_PATH_CONFIG_BASE |
|||
{ |
|||
private: |
|||
S3D_FILENAME_RESOLVER* m_resolver; |
|||
wxString m_curdir; |
|||
wxTextValidator m_aliasValidator; |
|||
|
|||
void initDialog(); |
|||
|
|||
void OnAddAlias( wxCommandEvent& event ) override; |
|||
void OnDelAlias( wxCommandEvent& event ) override; |
|||
void OnAliasMoveUp( wxCommandEvent& event ) override; |
|||
void OnAliasMoveDown( wxCommandEvent& event ) override; |
|||
void OnConfigEnvVar( wxCommandEvent& event ) override; |
|||
void OnHelp( wxCommandEvent& event ) override; |
|||
|
|||
public: |
|||
DLG_3D_PATH_CONFIG( wxWindow* aParent, S3D_FILENAME_RESOLVER* aResolver ); |
|||
bool TransferDataFromWindow() override; |
|||
|
|||
private: |
|||
void updateEnvVars( void ); |
|||
}; |
|||
|
|||
#endif // DLG_3D_PATHCONFIG_H |
|||
@ -1,162 +0,0 @@ |
|||
///////////////////////////////////////////////////////////////////////////
|
|||
// C++ code generated with wxFormBuilder (version Nov 22 2017)
|
|||
// http://www.wxformbuilder.org/
|
|||
//
|
|||
// PLEASE DO *NOT* EDIT THIS FILE!
|
|||
///////////////////////////////////////////////////////////////////////////
|
|||
|
|||
#include "dlg_3d_pathconfig_base.h"
|
|||
|
|||
///////////////////////////////////////////////////////////////////////////
|
|||
|
|||
DLG_3D_PATH_CONFIG_BASE::DLG_3D_PATH_CONFIG_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( -1,-1 ), wxDefaultSize ); |
|||
|
|||
wxBoxSizer* bSizerMain; |
|||
bSizerMain = new wxBoxSizer( wxVERTICAL ); |
|||
|
|||
wxBoxSizer* bSizer5; |
|||
bSizer5 = new wxBoxSizer( wxVERTICAL ); |
|||
|
|||
m_EnvVars = new wxGrid( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); |
|||
|
|||
// Grid
|
|||
m_EnvVars->CreateGrid( 1, 2 ); |
|||
m_EnvVars->EnableEditing( true ); |
|||
m_EnvVars->EnableGridLines( true ); |
|||
m_EnvVars->EnableDragGridSize( false ); |
|||
m_EnvVars->SetMargins( 0, 0 ); |
|||
|
|||
// Columns
|
|||
m_EnvVars->SetColSize( 0, 150 ); |
|||
m_EnvVars->SetColSize( 1, 300 ); |
|||
m_EnvVars->EnableDragColMove( false ); |
|||
m_EnvVars->EnableDragColSize( true ); |
|||
m_EnvVars->SetColLabelSize( 30 ); |
|||
m_EnvVars->SetColLabelValue( 0, _("Name") ); |
|||
m_EnvVars->SetColLabelValue( 1, _("Path") ); |
|||
m_EnvVars->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); |
|||
|
|||
// Rows
|
|||
m_EnvVars->EnableDragRowSize( true ); |
|||
m_EnvVars->SetRowLabelSize( 80 ); |
|||
m_EnvVars->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); |
|||
|
|||
// Label Appearance
|
|||
|
|||
// Cell Defaults
|
|||
m_EnvVars->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); |
|||
m_EnvVars->SetMinSize( wxSize( 250,100 ) ); |
|||
|
|||
bSizer5->Add( m_EnvVars, 1, wxALL|wxEXPAND, 5 ); |
|||
|
|||
m_btnEnvCfg = new wxButton( this, wxID_ANY, _("Configure Environment Variables"), wxDefaultPosition, wxDefaultSize, 0 ); |
|||
bSizer5->Add( m_btnEnvCfg, 0, wxALIGN_CENTER|wxALL, 5 ); |
|||
|
|||
|
|||
bSizerMain->Add( bSizer5, 0, wxEXPAND, 5 ); |
|||
|
|||
m_staticline2 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); |
|||
bSizerMain->Add( m_staticline2, 0, wxEXPAND | wxALL, 5 ); |
|||
|
|||
wxBoxSizer* bSizerGrid; |
|||
bSizerGrid = new wxBoxSizer( wxHORIZONTAL ); |
|||
|
|||
m_Aliases = new wxGrid( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); |
|||
|
|||
// Grid
|
|||
m_Aliases->CreateGrid( 1, 3 ); |
|||
m_Aliases->EnableEditing( true ); |
|||
m_Aliases->EnableGridLines( true ); |
|||
m_Aliases->EnableDragGridSize( false ); |
|||
m_Aliases->SetMargins( 0, 0 ); |
|||
|
|||
// Columns
|
|||
m_Aliases->SetColSize( 0, 80 ); |
|||
m_Aliases->SetColSize( 1, 300 ); |
|||
m_Aliases->SetColSize( 2, 120 ); |
|||
m_Aliases->EnableDragColMove( false ); |
|||
m_Aliases->EnableDragColSize( true ); |
|||
m_Aliases->SetColLabelSize( 30 ); |
|||
m_Aliases->SetColLabelValue( 0, _("Alias") ); |
|||
m_Aliases->SetColLabelValue( 1, _("Path") ); |
|||
m_Aliases->SetColLabelValue( 2, _("Description") ); |
|||
m_Aliases->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); |
|||
|
|||
// Rows
|
|||
m_Aliases->AutoSizeRows(); |
|||
m_Aliases->EnableDragRowSize( false ); |
|||
m_Aliases->SetRowLabelSize( 80 ); |
|||
m_Aliases->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); |
|||
|
|||
// Label Appearance
|
|||
|
|||
// Cell Defaults
|
|||
m_Aliases->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); |
|||
m_Aliases->SetMinSize( wxSize( -1,150 ) ); |
|||
|
|||
bSizerGrid->Add( m_Aliases, 1, wxALL|wxEXPAND, 5 ); |
|||
|
|||
|
|||
bSizerMain->Add( bSizerGrid, 1, wxEXPAND, 5 ); |
|||
|
|||
wxBoxSizer* bSizerButtons; |
|||
bSizerButtons = new wxBoxSizer( wxHORIZONTAL ); |
|||
|
|||
m_btnAddAlias = new wxButton( this, wxID_ANY, _("Add Alias"), wxDefaultPosition, wxDefaultSize, 0 ); |
|||
bSizerButtons->Add( m_btnAddAlias, 0, wxALL, 5 ); |
|||
|
|||
m_btnDelAlias = new wxButton( this, wxID_ANY, _("Remove Alias"), wxDefaultPosition, wxDefaultSize, 0 ); |
|||
bSizerButtons->Add( m_btnDelAlias, 0, wxALL, 5 ); |
|||
|
|||
m_btnMoveUp = new wxButton( this, wxID_ANY, _("Move Up"), wxDefaultPosition, wxDefaultSize, 0 ); |
|||
bSizerButtons->Add( m_btnMoveUp, 0, wxALL, 5 ); |
|||
|
|||
m_btnMoveDown = new wxButton( this, wxID_ANY, _("Move Down"), wxDefaultPosition, wxDefaultSize, 0 ); |
|||
bSizerButtons->Add( m_btnMoveDown, 0, wxALL, 5 ); |
|||
|
|||
|
|||
bSizerMain->Add( bSizerButtons, 0, wxALIGN_CENTER_HORIZONTAL, 5 ); |
|||
|
|||
m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); |
|||
bSizerMain->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 ); |
|||
|
|||
m_sdbSizer2 = new wxStdDialogButtonSizer(); |
|||
m_sdbSizer2OK = new wxButton( this, wxID_OK ); |
|||
m_sdbSizer2->AddButton( m_sdbSizer2OK ); |
|||
m_sdbSizer2Cancel = new wxButton( this, wxID_CANCEL ); |
|||
m_sdbSizer2->AddButton( m_sdbSizer2Cancel ); |
|||
m_sdbSizer2Help = new wxButton( this, wxID_HELP ); |
|||
m_sdbSizer2->AddButton( m_sdbSizer2Help ); |
|||
m_sdbSizer2->Realize(); |
|||
|
|||
bSizerMain->Add( m_sdbSizer2, 0, wxALL|wxEXPAND, 5 ); |
|||
|
|||
|
|||
this->SetSizer( bSizerMain ); |
|||
this->Layout(); |
|||
bSizerMain->Fit( this ); |
|||
|
|||
this->Centre( wxBOTH ); |
|||
|
|||
// Connect Events
|
|||
m_btnEnvCfg->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DLG_3D_PATH_CONFIG_BASE::OnConfigEnvVar ), NULL, this ); |
|||
m_btnAddAlias->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DLG_3D_PATH_CONFIG_BASE::OnAddAlias ), NULL, this ); |
|||
m_btnDelAlias->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DLG_3D_PATH_CONFIG_BASE::OnDelAlias ), NULL, this ); |
|||
m_btnMoveUp->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DLG_3D_PATH_CONFIG_BASE::OnAliasMoveUp ), NULL, this ); |
|||
m_btnMoveDown->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DLG_3D_PATH_CONFIG_BASE::OnAliasMoveDown ), NULL, this ); |
|||
m_sdbSizer2Help->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DLG_3D_PATH_CONFIG_BASE::OnHelp ), NULL, this ); |
|||
} |
|||
|
|||
DLG_3D_PATH_CONFIG_BASE::~DLG_3D_PATH_CONFIG_BASE() |
|||
{ |
|||
// Disconnect Events
|
|||
m_btnEnvCfg->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DLG_3D_PATH_CONFIG_BASE::OnConfigEnvVar ), NULL, this ); |
|||
m_btnAddAlias->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DLG_3D_PATH_CONFIG_BASE::OnAddAlias ), NULL, this ); |
|||
m_btnDelAlias->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DLG_3D_PATH_CONFIG_BASE::OnDelAlias ), NULL, this ); |
|||
m_btnMoveUp->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DLG_3D_PATH_CONFIG_BASE::OnAliasMoveUp ), NULL, this ); |
|||
m_btnMoveDown->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DLG_3D_PATH_CONFIG_BASE::OnAliasMoveDown ), NULL, this ); |
|||
m_sdbSizer2Help->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DLG_3D_PATH_CONFIG_BASE::OnHelp ), NULL, this ); |
|||
|
|||
} |
|||
1046
3d-viewer/3d_cache/dialogs/dlg_3d_pathconfig_base.fbp
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -1,67 +0,0 @@ |
|||
/////////////////////////////////////////////////////////////////////////// |
|||
// C++ code generated with wxFormBuilder (version Nov 22 2017) |
|||
// http://www.wxformbuilder.org/ |
|||
// |
|||
// PLEASE DO *NOT* EDIT THIS FILE! |
|||
/////////////////////////////////////////////////////////////////////////// |
|||
|
|||
#ifndef __DLG_3D_PATHCONFIG_BASE_H__ |
|||
#define __DLG_3D_PATHCONFIG_BASE_H__ |
|||
|
|||
#include <wx/artprov.h> |
|||
#include <wx/xrc/xmlres.h> |
|||
#include <wx/intl.h> |
|||
#include "dialog_shim.h" |
|||
#include <wx/colour.h> |
|||
#include <wx/settings.h> |
|||
#include <wx/string.h> |
|||
#include <wx/font.h> |
|||
#include <wx/grid.h> |
|||
#include <wx/gdicmn.h> |
|||
#include <wx/button.h> |
|||
#include <wx/sizer.h> |
|||
#include <wx/statline.h> |
|||
#include <wx/dialog.h> |
|||
|
|||
/////////////////////////////////////////////////////////////////////////// |
|||
|
|||
|
|||
/////////////////////////////////////////////////////////////////////////////// |
|||
/// Class DLG_3D_PATH_CONFIG_BASE |
|||
/////////////////////////////////////////////////////////////////////////////// |
|||
class DLG_3D_PATH_CONFIG_BASE : public DIALOG_SHIM |
|||
{ |
|||
private: |
|||
|
|||
protected: |
|||
wxGrid* m_EnvVars; |
|||
wxButton* m_btnEnvCfg; |
|||
wxStaticLine* m_staticline2; |
|||
wxGrid* m_Aliases; |
|||
wxButton* m_btnAddAlias; |
|||
wxButton* m_btnDelAlias; |
|||
wxButton* m_btnMoveUp; |
|||
wxButton* m_btnMoveDown; |
|||
wxStaticLine* m_staticline1; |
|||
wxStdDialogButtonSizer* m_sdbSizer2; |
|||
wxButton* m_sdbSizer2OK; |
|||
wxButton* m_sdbSizer2Cancel; |
|||
wxButton* m_sdbSizer2Help; |
|||
|
|||
// Virtual event handlers, overide them in your derived class |
|||
virtual void OnConfigEnvVar( wxCommandEvent& event ) { event.Skip(); } |
|||
virtual void OnAddAlias( wxCommandEvent& event ) { event.Skip(); } |
|||
virtual void OnDelAlias( wxCommandEvent& event ) { event.Skip(); } |
|||
virtual void OnAliasMoveUp( wxCommandEvent& event ) { event.Skip(); } |
|||
virtual void OnAliasMoveDown( wxCommandEvent& event ) { event.Skip(); } |
|||
virtual void OnHelp( wxCommandEvent& event ) { event.Skip(); } |
|||
|
|||
|
|||
public: |
|||
|
|||
DLG_3D_PATH_CONFIG_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("3D Search Path Configuration"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); |
|||
~DLG_3D_PATH_CONFIG_BASE(); |
|||
|
|||
}; |
|||
|
|||
#endif //__DLG_3D_PATHCONFIG_BASE_H__ |
|||
@ -1,87 +0,0 @@ |
|||
/* |
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com> |
|||
* |
|||
* 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 |
|||
*/ |
|||
|
|||
/** |
|||
* @file str_rsort.h |
|||
* provides a wxString sorting functino which works from the |
|||
* end of the string towards the beginning |
|||
*/ |
|||
|
|||
#ifndef STR_RSORT_H |
|||
#define STR_RSORT_H |
|||
|
|||
#include <wx/string.h> |
|||
|
|||
namespace S3D |
|||
{ |
|||
|
|||
struct rsort_wxString |
|||
{ |
|||
bool operator() (const wxString& strA, const wxString& strB ) const |
|||
{ |
|||
// sort a wxString using the reverse character order; for 3d model |
|||
// filenames this will typically be a much faster operation than |
|||
// a normal alphabetic sort |
|||
wxString::const_reverse_iterator sA = strA.rbegin(); |
|||
wxString::const_reverse_iterator eA = strA.rend(); |
|||
|
|||
wxString::const_reverse_iterator sB = strB.rbegin(); |
|||
wxString::const_reverse_iterator eB = strB.rend(); |
|||
|
|||
if( strA.empty() ) |
|||
{ |
|||
if( strB.empty() ) |
|||
return false; |
|||
|
|||
// note: this rule implies that a null string is first in the sort order |
|||
return true; |
|||
} |
|||
|
|||
if( strB.empty() ) |
|||
return false; |
|||
|
|||
while( sA != eA && sB != eB ) |
|||
{ |
|||
if( (*sA) == (*sB) ) |
|||
{ |
|||
++sA; |
|||
++sB; |
|||
continue; |
|||
} |
|||
|
|||
if( (*sA) < (*sB) ) |
|||
return true; |
|||
else |
|||
return false; |
|||
} |
|||
|
|||
if( sB == eB ) |
|||
return false; |
|||
|
|||
return true; |
|||
} |
|||
}; |
|||
|
|||
} // end NAMESPACE |
|||
|
|||
#endif // STR_RSORT_H |
|||
@ -0,0 +1,565 @@ |
|||
/*
|
|||
* This program source code file is part of KICAD, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2015 Wayne Stambaugh <stambaughw@gmail.com> |
|||
* Copyright (C) 2015-2018 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 <dialog_configure_paths.h>
|
|||
|
|||
#include <confirm.h>
|
|||
#include <menus_helpers.h>
|
|||
#include <validators.h>
|
|||
#include <html_messagebox.h>
|
|||
#include <filename_resolver.h>
|
|||
|
|||
|
|||
enum ENV_VAR_GRID_COLUMNS |
|||
{ |
|||
EV_NAME_COL = 0, |
|||
EV_PATH_COL, |
|||
EV_FLAG_COL |
|||
}; |
|||
|
|||
enum SEARCH_PATH_GRID_COLUMNS |
|||
{ |
|||
SP_ALIAS_COL = 0, |
|||
SP_PATH_COL, |
|||
SP_DESC_COL |
|||
}; |
|||
|
|||
|
|||
DIALOG_CONFIGURE_PATHS::DIALOG_CONFIGURE_PATHS( wxWindow* aParent, FILENAME_RESOLVER* aResolver ) : |
|||
DIALOG_CONFIGURE_PATHS_BASE( aParent ), |
|||
m_errorGrid( nullptr ), |
|||
m_resolver( aResolver ) |
|||
{ |
|||
m_btnAddEnvVar->SetBitmap( KiBitmap( small_plus_xpm ) ); |
|||
m_btnDeleteEnvVar->SetBitmap( KiBitmap( trash_xpm ) ); |
|||
m_btnAddSearchPath->SetBitmap( KiBitmap( small_plus_xpm ) ); |
|||
m_btnDeleteSearchPath->SetBitmap( KiBitmap( trash_xpm ) ); |
|||
m_btnMoveUp->SetBitmap( KiBitmap( small_up_xpm ) ); |
|||
m_btnMoveDown->SetBitmap( KiBitmap( small_down_xpm ) ); |
|||
|
|||
m_EnvVars->DeleteRows( 0, m_EnvVars->GetNumberRows() ); |
|||
m_EnvVars->AppendCols( 1 ); // for the isExternal flags
|
|||
m_EnvVars->HideCol( EV_FLAG_COL ); |
|||
m_EnvVars->UseNativeColHeader( true ); |
|||
|
|||
if( m_resolver ) |
|||
{ |
|||
m_SearchPaths->DeleteRows( 0, m_SearchPaths->GetNumberRows() ); |
|||
m_SearchPaths->UseNativeColHeader( true ); |
|||
|
|||
// prohibit these characters in the alias names: []{}()%~<>"='`;:.,&?/\|$
|
|||
m_aliasValidator.SetStyle( wxFILTER_EXCLUDE_CHAR_LIST ); |
|||
m_aliasValidator.SetCharExcludes( wxT( "{}[]()%~<>\"='`;:.,&?/\\|$" ) ); |
|||
} |
|||
else |
|||
m_sb3DSearchPaths->Show( false ); |
|||
|
|||
SetInitialFocus( m_EnvVars ); |
|||
m_sdbSizerOK->SetDefault(); |
|||
|
|||
// wxFormBuilder doesn't include this event...
|
|||
m_EnvVars->Connect( wxEVT_GRID_CELL_CHANGING, wxGridEventHandler( DIALOG_CONFIGURE_PATHS::OnGridCellChanging ), NULL, this ); |
|||
m_SearchPaths->Connect( wxEVT_GRID_CELL_CHANGING, wxGridEventHandler( DIALOG_CONFIGURE_PATHS::OnGridCellChanging ), NULL, this ); |
|||
|
|||
GetSizer()->SetSizeHints( this ); |
|||
Centre(); |
|||
} |
|||
|
|||
|
|||
DIALOG_CONFIGURE_PATHS::~DIALOG_CONFIGURE_PATHS() |
|||
{ |
|||
m_EnvVars->Disconnect( wxEVT_GRID_CELL_CHANGING, wxGridEventHandler( DIALOG_CONFIGURE_PATHS::OnGridCellChanging ), NULL, this ); |
|||
m_SearchPaths->Disconnect( wxEVT_GRID_CELL_CHANGING, wxGridEventHandler( DIALOG_CONFIGURE_PATHS::OnGridCellChanging ), NULL, this ); |
|||
} |
|||
|
|||
|
|||
bool DIALOG_CONFIGURE_PATHS::TransferDataToWindow() |
|||
{ |
|||
if( !wxDialog::TransferDataToWindow() ) |
|||
return false; |
|||
|
|||
// Environment variables
|
|||
|
|||
const ENV_VAR_MAP& envVars = Pgm().GetLocalEnvVariables(); |
|||
|
|||
for( auto it = envVars.begin(); it != envVars.end(); ++it ) |
|||
AppendEnvVar( it->first, it->second.GetValue(), it->second.GetDefinedExternally() ); |
|||
|
|||
// 3D search paths
|
|||
|
|||
if( m_resolver ) |
|||
{ |
|||
const std::list<SEARCH_PATH>* paths = m_resolver->GetPaths(); |
|||
auto it = paths->begin(); |
|||
|
|||
while( it != paths->end() |
|||
&& ( ( *it ).m_alias.StartsWith( "${" ) || ( *it ).m_alias.StartsWith( "$(" ) ) ) |
|||
++it; |
|||
|
|||
if( it != paths->end() ) |
|||
m_curdir = ( *it ).m_pathexp; |
|||
|
|||
for( ; it != paths->end(); ++it ) |
|||
AppendSearchPath( it->m_alias, it->m_pathvar, it->m_description ); |
|||
} |
|||
|
|||
return true; |
|||
} |
|||
|
|||
|
|||
void DIALOG_CONFIGURE_PATHS::AppendEnvVar( const wxString& aName, const wxString& aPath, |
|||
bool isExternal ) |
|||
{ |
|||
int i = m_EnvVars->GetNumberRows(); |
|||
|
|||
m_EnvVars->AppendRows( 1 ); |
|||
|
|||
m_EnvVars->SetCellValue( i, EV_NAME_COL, aName ); |
|||
|
|||
wxGridCellAttr* nameCellAttr = m_EnvVars->GetOrCreateCellAttr( i, EV_NAME_COL ); |
|||
wxGridCellTextEditor* nameTextEditor = new GRID_CELL_TEXT_EDITOR(); |
|||
nameTextEditor->SetValidator( ENV_VAR_NAME_VALIDATOR() ); |
|||
nameCellAttr->SetEditor( nameTextEditor ); |
|||
nameCellAttr->SetReadOnly( IsEnvVarImmutable( aName ) ); |
|||
nameCellAttr->DecRef(); |
|||
|
|||
m_EnvVars->SetCellValue( i, EV_PATH_COL, aPath ); |
|||
|
|||
wxGridCellAttr* pathCellAttr = m_EnvVars->GetOrCreateCellAttr( i, EV_PATH_COL ); |
|||
wxSystemColour c = isExternal ? wxSYS_COLOUR_MENU : wxSYS_COLOUR_LISTBOX; |
|||
pathCellAttr->SetBackgroundColour( wxSystemSettings::GetColour( c ) ); |
|||
pathCellAttr->DecRef(); |
|||
|
|||
m_EnvVars->SetCellValue( i, EV_FLAG_COL, isExternal ? wxT( "external" ) : wxEmptyString ); |
|||
} |
|||
|
|||
|
|||
void DIALOG_CONFIGURE_PATHS::AppendSearchPath( const wxString& aName, const wxString& aPath, |
|||
const wxString& aDescription ) |
|||
{ |
|||
int i = m_SearchPaths->GetNumberRows(); |
|||
|
|||
m_SearchPaths->AppendRows( 1 ); |
|||
|
|||
m_SearchPaths->SetCellValue( i, SP_ALIAS_COL, aName ); |
|||
|
|||
wxGridCellAttr* nameCellAttr = m_SearchPaths->GetOrCreateCellAttr( i, SP_ALIAS_COL ); |
|||
wxGridCellTextEditor* nameTextEditor = new GRID_CELL_TEXT_EDITOR(); |
|||
nameTextEditor->SetValidator( m_aliasValidator ); |
|||
nameCellAttr->SetEditor( nameTextEditor ); |
|||
nameCellAttr->DecRef(); |
|||
|
|||
m_SearchPaths->SetCellValue( i, SP_PATH_COL, aPath ); |
|||
m_SearchPaths->SetCellValue( i, SP_DESC_COL, aDescription ); |
|||
} |
|||
|
|||
|
|||
bool DIALOG_CONFIGURE_PATHS::TransferDataFromWindow() |
|||
{ |
|||
if( !wxDialog::TransferDataFromWindow() ) |
|||
return false; |
|||
|
|||
// Commit any pending in-place edits and close the editor
|
|||
m_EnvVars->DisableCellEditControl(); |
|||
m_SearchPaths->DisableCellEditControl(); |
|||
|
|||
// Environment variables
|
|||
|
|||
ENV_VAR_MAP envVarMap; |
|||
|
|||
for( int row = 0; row < m_EnvVars->GetNumberRows(); ++row ) |
|||
{ |
|||
wxString name = m_EnvVars->GetCellValue( row, EV_NAME_COL ); |
|||
wxString path = m_EnvVars->GetCellValue( row, EV_PATH_COL ); |
|||
|
|||
if( name.IsEmpty() ) |
|||
{ |
|||
m_errorGrid = m_EnvVars; |
|||
m_errorRow = row; |
|||
m_errorCol = EV_NAME_COL; |
|||
m_errorMsg = _( "Environment variable name cannot be empty." ); |
|||
return false; |
|||
} |
|||
else if( path.IsEmpty() ) |
|||
{ |
|||
m_errorGrid = m_EnvVars; |
|||
m_errorRow = row; |
|||
m_errorCol = EV_PATH_COL; |
|||
m_errorMsg = _( "Environment variable path cannot be empty." ); |
|||
return false; |
|||
} |
|||
|
|||
envVarMap[ name ] = ENV_VAR_ITEM( path ); |
|||
} |
|||
|
|||
Pgm().SetLocalEnvVariables( envVarMap ); |
|||
|
|||
// 3D search paths
|
|||
|
|||
if( m_resolver ) |
|||
{ |
|||
std::vector<SEARCH_PATH> alist; |
|||
SEARCH_PATH alias; |
|||
|
|||
for( int row = 0; row < m_SearchPaths->GetNumberRows(); ++row ) |
|||
{ |
|||
alias.m_alias = m_SearchPaths->GetCellValue( row, SP_ALIAS_COL ); |
|||
alias.m_pathvar = m_SearchPaths->GetCellValue( row, SP_PATH_COL ); |
|||
alias.m_description = m_SearchPaths->GetCellValue( row, SP_DESC_COL ); |
|||
|
|||
if( alias.m_alias.IsEmpty() ) |
|||
{ |
|||
m_errorGrid = m_SearchPaths; |
|||
m_errorRow = row; |
|||
m_errorCol = SP_ALIAS_COL; |
|||
m_errorMsg = _( "3D search path alias cannot be empty." ); |
|||
return false; |
|||
} |
|||
else if( alias.m_pathvar.IsEmpty() ) |
|||
{ |
|||
m_errorGrid = m_SearchPaths; |
|||
m_errorRow = row; |
|||
m_errorCol = SP_PATH_COL; |
|||
m_errorMsg = _( "3D search path cannot be empty." ); |
|||
return false; |
|||
} |
|||
|
|||
alist.push_back( alias ); |
|||
} |
|||
|
|||
if( !m_resolver->UpdatePathList( alist ) ) |
|||
return false; |
|||
} |
|||
|
|||
return true; |
|||
} |
|||
|
|||
|
|||
void DIALOG_CONFIGURE_PATHS::OnGridCellChanging( wxGridEvent& event ) |
|||
{ |
|||
wxGrid* grid = dynamic_cast<wxGrid*>( event.GetEventObject() ); |
|||
int row = event.GetRow(); |
|||
int col = event.GetCol(); |
|||
wxString text = event.GetString(); |
|||
|
|||
if( text.IsEmpty() ) |
|||
{ |
|||
if( grid == m_EnvVars ) |
|||
{ |
|||
if( col == EV_NAME_COL ) |
|||
m_errorMsg = _( "Environment variable name cannot be empty." ); |
|||
else |
|||
m_errorMsg = _( "Environment variable path cannot be empty." ); |
|||
} |
|||
else |
|||
{ |
|||
if( col == SP_ALIAS_COL ) |
|||
m_errorMsg = _( "3D search path alias cannot be empty." ); |
|||
else |
|||
m_errorMsg = _( "3D search path cannot be empty." ); |
|||
} |
|||
m_errorGrid = dynamic_cast<wxGrid*>( event.GetEventObject() ); |
|||
m_errorRow = row; |
|||
m_errorCol = col; |
|||
|
|||
event.Veto(); |
|||
} |
|||
|
|||
if( grid == m_EnvVars ) |
|||
{ |
|||
if( col == EV_PATH_COL && m_EnvVars->GetCellValue( row, EV_FLAG_COL ).Length() ) |
|||
{ |
|||
wxString msg1 = _( "This path was defined externally to the running process and\n" |
|||
"will only be temporarily overwritten." ); |
|||
wxString msg2 = _( "The next time KiCad is launched, any paths that have already\n" |
|||
"been defined are honored and any settings defined in the path\n" |
|||
"configuration dialog are ignored. If you did not intend for\n" |
|||
"this behavior, either rename any conflicting entries or remove\n" |
|||
"the external environment variable(s) from your system." ); |
|||
KIDIALOG dlg( this, msg1, KIDIALOG::KD_WARNING ); |
|||
dlg.ShowDetailedText( msg2 ); |
|||
dlg.DoNotShowCheckbox(); |
|||
dlg.ShowModal(); |
|||
} |
|||
else if( col == EV_NAME_COL && m_EnvVars->GetCellValue( row, EV_NAME_COL ) != text ) |
|||
{ |
|||
// Changing name; clear external flag
|
|||
m_EnvVars->SetCellValue( row, EV_FLAG_COL, wxEmptyString ); |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
void DIALOG_CONFIGURE_PATHS::OnAddEnvVar( wxCommandEvent& event ) |
|||
{ |
|||
AppendEnvVar( wxEmptyString, wxEmptyString, false ); |
|||
|
|||
m_EnvVars->MakeCellVisible( m_EnvVars->GetNumberRows() - 1, EV_NAME_COL ); |
|||
m_EnvVars->SetGridCursor( m_EnvVars->GetNumberRows() - 1, EV_NAME_COL ); |
|||
|
|||
m_EnvVars->EnableCellEditControl( true ); |
|||
m_EnvVars->ShowCellEditControl(); |
|||
} |
|||
|
|||
|
|||
void DIALOG_CONFIGURE_PATHS::OnAddSearchPath( wxCommandEvent& event ) |
|||
{ |
|||
AppendSearchPath( wxEmptyString, wxEmptyString, wxEmptyString); |
|||
|
|||
m_SearchPaths->MakeCellVisible( m_SearchPaths->GetNumberRows() - 1, SP_ALIAS_COL ); |
|||
m_SearchPaths->SetGridCursor( m_SearchPaths->GetNumberRows() - 1, SP_ALIAS_COL ); |
|||
|
|||
m_SearchPaths->EnableCellEditControl( true ); |
|||
m_SearchPaths->ShowCellEditControl(); |
|||
} |
|||
|
|||
|
|||
void DIALOG_CONFIGURE_PATHS::OnRemoveEnvVar( wxCommandEvent& event ) |
|||
{ |
|||
int curRow = m_EnvVars->GetGridCursorRow(); |
|||
|
|||
if( !m_EnvVars->HasFocus() || curRow < 0 ) |
|||
{ |
|||
m_EnvVars->SetFocus(); |
|||
return; |
|||
} |
|||
|
|||
if( IsEnvVarImmutable( m_EnvVars->GetCellValue( curRow, EV_NAME_COL ) ) ) |
|||
{ |
|||
wxBell(); |
|||
return; |
|||
} |
|||
|
|||
m_EnvVars->DeleteRows( curRow, 1 ); |
|||
|
|||
curRow = std::max( 0, curRow - 1 ); |
|||
m_EnvVars->MakeCellVisible( curRow, m_EnvVars->GetGridCursorCol() ); |
|||
m_EnvVars->SetGridCursor( curRow, m_EnvVars->GetGridCursorCol() ); |
|||
} |
|||
|
|||
|
|||
void DIALOG_CONFIGURE_PATHS::OnDeleteSearchPath( wxCommandEvent& event ) |
|||
{ |
|||
int curRow = m_SearchPaths->GetGridCursorRow(); |
|||
|
|||
if( !m_SearchPaths->HasFocus() || curRow < 0 ) |
|||
{ |
|||
m_SearchPaths->SetFocus(); |
|||
return; |
|||
} |
|||
|
|||
m_SearchPaths->DeleteRows( curRow, 1 ); |
|||
|
|||
curRow = std::max( 0, curRow - 1 ); |
|||
m_SearchPaths->MakeCellVisible( curRow, m_SearchPaths->GetGridCursorCol() ); |
|||
m_SearchPaths->SetGridCursor( curRow, m_SearchPaths->GetGridCursorCol() ); |
|||
} |
|||
|
|||
|
|||
void DIALOG_CONFIGURE_PATHS::OnSearchPathMoveUp( wxCommandEvent& event ) |
|||
{ |
|||
int curRow = m_SearchPaths->GetGridCursorRow(); |
|||
int prevRow = curRow - 1; |
|||
|
|||
m_SearchPaths->DisableCellEditControl(); |
|||
|
|||
if( curRow > 0 ) |
|||
{ |
|||
for( int i = 0; i < m_SearchPaths->GetNumberCols(); ++i ) |
|||
{ |
|||
wxString tmp = m_SearchPaths->GetCellValue( curRow, i ); |
|||
m_SearchPaths->SetCellValue( curRow, i, m_SearchPaths->GetCellValue( prevRow, i ) ); |
|||
m_SearchPaths->SetCellValue( prevRow, i, tmp ); |
|||
} |
|||
|
|||
m_SearchPaths->SetGridCursor( prevRow, m_SearchPaths->GetGridCursorCol() ); |
|||
} |
|||
} |
|||
|
|||
|
|||
void DIALOG_CONFIGURE_PATHS::OnSearchPathMoveDown( wxCommandEvent& event ) |
|||
{ |
|||
int curRow = m_SearchPaths->GetGridCursorRow(); |
|||
int nextRow = curRow + 1; |
|||
|
|||
m_SearchPaths->DisableCellEditControl(); |
|||
|
|||
if( curRow < m_SearchPaths->GetNumberRows() - 1 ) |
|||
{ |
|||
for( int i = 0; i < m_SearchPaths->GetNumberCols(); ++i ) |
|||
{ |
|||
wxString tmp = m_SearchPaths->GetCellValue( curRow, i ); |
|||
m_SearchPaths->SetCellValue( curRow, i, m_SearchPaths->GetCellValue( nextRow, i ) ); |
|||
m_SearchPaths->SetCellValue( nextRow, i, tmp ); |
|||
} |
|||
|
|||
m_SearchPaths->SetGridCursor( nextRow, m_SearchPaths->GetGridCursorCol() ); |
|||
} |
|||
} |
|||
|
|||
|
|||
void DIALOG_CONFIGURE_PATHS::OnGridCellRightClick( wxGridEvent& aEvent ) |
|||
{ |
|||
wxASSERT( (int) EV_PATH_COL == (int) SP_PATH_COL ); |
|||
|
|||
if( aEvent.GetCol() == EV_PATH_COL ) |
|||
{ |
|||
wxMenu menu; |
|||
|
|||
AddMenuItem( &menu, 1, _( "File Browser..." ), KiBitmap( folder_xpm ) ); |
|||
if( GetPopupMenuSelectionFromUser( menu ) == 1 ) |
|||
{ |
|||
wxString title = _( "Select Path" ); |
|||
wxString path; // Currently the first opened path is not initialized
|
|||
|
|||
wxDirDialog dlg( nullptr, title, path, wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST ); |
|||
|
|||
if( dlg.ShowModal() == wxID_OK ) |
|||
{ |
|||
wxGrid* grid = dynamic_cast<wxGrid*>( aEvent.GetEventObject() ); |
|||
grid->SetCellValue( aEvent.GetRow(), EV_PATH_COL, dlg.GetPath() ); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
void DIALOG_CONFIGURE_PATHS::AdjustGridColumns( int aWidth ) |
|||
{ |
|||
m_EnvVars->AutoSizeColumn( EV_NAME_COL ); |
|||
m_EnvVars->SetColSize( EV_NAME_COL, std::max( m_EnvVars->GetColSize( EV_NAME_COL ), 120 ) ); |
|||
|
|||
m_EnvVars->SetColSize( EV_PATH_COL, aWidth - m_EnvVars->GetColSize( EV_NAME_COL ) ); |
|||
|
|||
m_SearchPaths->AutoSizeColumn( SP_ALIAS_COL ); |
|||
m_SearchPaths->SetColSize( SP_ALIAS_COL, std::max( m_SearchPaths->GetColSize( SP_ALIAS_COL ), 120 ) ); |
|||
|
|||
m_SearchPaths->AutoSizeColumn( SP_PATH_COL ); |
|||
m_SearchPaths->SetColSize( SP_PATH_COL, std::max( m_SearchPaths->GetColSize( SP_PATH_COL ), 300 ) ); |
|||
|
|||
m_SearchPaths->SetColSize( SP_DESC_COL, aWidth - ( m_SearchPaths->GetColSize( SP_ALIAS_COL ) |
|||
+ m_SearchPaths->GetColSize( SP_PATH_COL ) ) ); |
|||
} |
|||
|
|||
|
|||
void DIALOG_CONFIGURE_PATHS::OnUpdateUI( wxUpdateUIEvent& event ) |
|||
{ |
|||
if( !m_EnvVars->IsCellEditControlShown() && !m_SearchPaths->IsCellEditControlShown() ) |
|||
AdjustGridColumns( m_EnvVars->GetRect().GetWidth() ); |
|||
|
|||
// Handle a grid error. This is delayed to OnUpdateUI so that we can change focus
|
|||
// even when the original validation was triggered from a killFocus event (and for
|
|||
// dialog with notebooks, so that the corresponding notebook page can be shown in
|
|||
// the background when triggered from an OK).
|
|||
if( m_errorGrid ) |
|||
{ |
|||
// We will re-enter this routine when the error dialog is displayed, so make
|
|||
// sure we don't keep putting up more dialogs.
|
|||
wxGrid* grid = m_errorGrid; |
|||
m_errorGrid = nullptr; |
|||
|
|||
DisplayErrorMessage( this, m_errorMsg ); |
|||
|
|||
grid->SetFocus(); |
|||
grid->MakeCellVisible( m_errorRow, m_errorCol ); |
|||
grid->SetGridCursor( m_errorRow, m_errorCol ); |
|||
|
|||
grid->EnableCellEditControl( true ); |
|||
grid->ShowCellEditControl(); |
|||
} |
|||
} |
|||
|
|||
|
|||
void DIALOG_CONFIGURE_PATHS::OnGridSize( wxSizeEvent& event ) |
|||
{ |
|||
AdjustGridColumns( event.GetSize().GetX() ); |
|||
|
|||
event.Skip(); |
|||
} |
|||
|
|||
|
|||
void DIALOG_CONFIGURE_PATHS::OnHelp( wxCommandEvent& event ) |
|||
{ |
|||
wxString msg = _( "Enter the name and value for each environment variable. Grey entries " |
|||
"are names that have been defined externally at the system or user " |
|||
"level. Environment variables defined at the system or user level " |
|||
"take precedence over the ones defined in this table. This means the " |
|||
"values in this table are ignored." ); |
|||
msg << wxT( "<br><br><b>" ); |
|||
msg << _( "To ensure environment variable names are valid on all platforms, the name field " |
|||
"will only accept upper case letters, digits, and the underscore characters." ); |
|||
msg << wxT( "</b><br><br>" ); |
|||
msg << _( "<b>KICAD_SYMBOL_DIR</b> is the base path of the locally installed symbol libraries." ); |
|||
msg << wxT( "<br><br>" ); |
|||
msg << _( "<b>KIGITHUB</b> is used by KiCad to define the URL of the repository " |
|||
"of the official KiCad footprint libraries." ); |
|||
msg << wxT( "<br><br>" ); |
|||
msg << _( "<b>KISYS3DMOD</b> is the base path of system footprint 3D " |
|||
"shapes (.3Dshapes folders)." ); |
|||
msg << wxT( "<br><br>" ); |
|||
msg << _( "<b>KISYSMOD</b> is the base path of locally installed system " |
|||
"footprint libraries (.pretty folders)." ); |
|||
msg << wxT( "<br><br>" ); |
|||
msg << _( "<b>KIPRJMOD</b> is internally defined by KiCad (cannot be edited) and is set " |
|||
"to the absolute path of the currently loaded project file. This environment " |
|||
"variable can be used to define files and paths relative to the currently loaded " |
|||
"project. For instance, ${KIPRJMOD}/libs/footprints.pretty can be defined as a " |
|||
"folder containing a project specific footprint library named footprints.pretty." ); |
|||
msg << wxT( "<br><br>" ); |
|||
msg << _( "<b>KICAD_PTEMPLATES</b> is optional and can be defined if you want to " |
|||
"create your own project templates folder." ); |
|||
|
|||
HTML_MESSAGE_BOX dlg( GetParent(), _( "Environment Variable Help" ) ); |
|||
dlg.SetDialogSizeInDU( 400, 250 ); |
|||
|
|||
dlg.AddHTML_Text( msg ); |
|||
dlg.ShowModal(); |
|||
} |
|||
|
|||
|
|||
bool DIALOG_CONFIGURE_PATHS::IsEnvVarImmutable( const wxString aEnvVar ) |
|||
{ |
|||
/*
|
|||
* TODO - Instead of defining these values here, |
|||
* extract them from elsewhere in the program |
|||
* (where they are originally defined) |
|||
*/ |
|||
|
|||
static const wxString immutable[] = { |
|||
"KIGITHUB", |
|||
"KISYS3DMOD", |
|||
"KISYSMOD", |
|||
"KIPRJMOD", |
|||
"KICAD_PTEMPLATES", |
|||
"KICAD_SYMBOL_DIR" |
|||
}; |
|||
|
|||
for( const auto& ii : immutable ) |
|||
{ |
|||
if( aEnvVar.Cmp( ii ) == 0 ) |
|||
return true; |
|||
} |
|||
|
|||
return false; |
|||
} |
|||
@ -0,0 +1,186 @@ |
|||
///////////////////////////////////////////////////////////////////////////
|
|||
// C++ code generated with wxFormBuilder (version Dec 30 2017)
|
|||
// http://www.wxformbuilder.org/
|
|||
//
|
|||
// PLEASE DO *NOT* EDIT THIS FILE!
|
|||
///////////////////////////////////////////////////////////////////////////
|
|||
|
|||
#include "dialog_configure_paths_base.h"
|
|||
|
|||
///////////////////////////////////////////////////////////////////////////
|
|||
|
|||
DIALOG_CONFIGURE_PATHS_BASE::DIALOG_CONFIGURE_PATHS_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( -1,-1 ), wxDefaultSize ); |
|||
|
|||
wxBoxSizer* bSizerMain; |
|||
bSizerMain = new wxBoxSizer( wxVERTICAL ); |
|||
|
|||
wxStaticBoxSizer* sbEnvVars; |
|||
sbEnvVars = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Environment Variables") ), wxVERTICAL ); |
|||
|
|||
m_EnvVars = new wxGrid( sbEnvVars->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); |
|||
|
|||
// Grid
|
|||
m_EnvVars->CreateGrid( 1, 2 ); |
|||
m_EnvVars->EnableEditing( true ); |
|||
m_EnvVars->EnableGridLines( true ); |
|||
m_EnvVars->EnableDragGridSize( false ); |
|||
m_EnvVars->SetMargins( 0, 0 ); |
|||
|
|||
// Columns
|
|||
m_EnvVars->SetColSize( 0, 150 ); |
|||
m_EnvVars->SetColSize( 1, 454 ); |
|||
m_EnvVars->EnableDragColMove( false ); |
|||
m_EnvVars->EnableDragColSize( true ); |
|||
m_EnvVars->SetColLabelSize( 22 ); |
|||
m_EnvVars->SetColLabelValue( 0, _("Name") ); |
|||
m_EnvVars->SetColLabelValue( 1, _("Path") ); |
|||
m_EnvVars->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); |
|||
|
|||
// Rows
|
|||
m_EnvVars->EnableDragRowSize( true ); |
|||
m_EnvVars->SetRowLabelSize( 0 ); |
|||
m_EnvVars->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); |
|||
|
|||
// Label Appearance
|
|||
|
|||
// Cell Defaults
|
|||
m_EnvVars->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); |
|||
m_EnvVars->SetMinSize( wxSize( 600,150 ) ); |
|||
|
|||
sbEnvVars->Add( m_EnvVars, 1, wxEXPAND|wxBOTTOM, 5 ); |
|||
|
|||
wxBoxSizer* bSizerEnvVarBtns; |
|||
bSizerEnvVarBtns = new wxBoxSizer( wxHORIZONTAL ); |
|||
|
|||
m_btnAddEnvVar = new wxBitmapButton( sbEnvVars->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW ); |
|||
m_btnAddEnvVar->SetMinSize( wxSize( 29,29 ) ); |
|||
|
|||
bSizerEnvVarBtns->Add( m_btnAddEnvVar, 0, 0, 5 ); |
|||
|
|||
m_btnDeleteEnvVar = new wxBitmapButton( sbEnvVars->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW ); |
|||
m_btnDeleteEnvVar->SetMinSize( wxSize( 29,29 ) ); |
|||
|
|||
bSizerEnvVarBtns->Add( m_btnDeleteEnvVar, 0, 0, 5 ); |
|||
|
|||
|
|||
sbEnvVars->Add( bSizerEnvVarBtns, 0, wxEXPAND, 5 ); |
|||
|
|||
|
|||
bSizerMain->Add( sbEnvVars, 1, wxEXPAND|wxALL, 5 ); |
|||
|
|||
m_sb3DSearchPaths = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("3D Search Paths") ), wxVERTICAL ); |
|||
|
|||
m_SearchPaths = new wxGrid( m_sb3DSearchPaths->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); |
|||
|
|||
// Grid
|
|||
m_SearchPaths->CreateGrid( 1, 3 ); |
|||
m_SearchPaths->EnableEditing( true ); |
|||
m_SearchPaths->EnableGridLines( true ); |
|||
m_SearchPaths->EnableDragGridSize( false ); |
|||
m_SearchPaths->SetMargins( 0, 0 ); |
|||
|
|||
// Columns
|
|||
m_SearchPaths->SetColSize( 0, 150 ); |
|||
m_SearchPaths->SetColSize( 1, 300 ); |
|||
m_SearchPaths->SetColSize( 2, 154 ); |
|||
m_SearchPaths->EnableDragColMove( false ); |
|||
m_SearchPaths->EnableDragColSize( true ); |
|||
m_SearchPaths->SetColLabelSize( 22 ); |
|||
m_SearchPaths->SetColLabelValue( 0, _("Alias") ); |
|||
m_SearchPaths->SetColLabelValue( 1, _("Path") ); |
|||
m_SearchPaths->SetColLabelValue( 2, _("Description") ); |
|||
m_SearchPaths->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); |
|||
|
|||
// Rows
|
|||
m_SearchPaths->AutoSizeRows(); |
|||
m_SearchPaths->EnableDragRowSize( false ); |
|||
m_SearchPaths->SetRowLabelSize( 0 ); |
|||
m_SearchPaths->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); |
|||
|
|||
// Label Appearance
|
|||
|
|||
// Cell Defaults
|
|||
m_SearchPaths->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); |
|||
m_SearchPaths->SetMinSize( wxSize( 600,150 ) ); |
|||
|
|||
m_sb3DSearchPaths->Add( m_SearchPaths, 1, wxEXPAND|wxBOTTOM, 5 ); |
|||
|
|||
wxBoxSizer* bSizerSearchPathBtns; |
|||
bSizerSearchPathBtns = new wxBoxSizer( wxHORIZONTAL ); |
|||
|
|||
m_btnAddSearchPath = new wxBitmapButton( m_sb3DSearchPaths->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW ); |
|||
m_btnAddSearchPath->SetMinSize( wxSize( 29,29 ) ); |
|||
|
|||
bSizerSearchPathBtns->Add( m_btnAddSearchPath, 0, 0, 5 ); |
|||
|
|||
m_btnDeleteSearchPath = new wxBitmapButton( m_sb3DSearchPaths->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW ); |
|||
m_btnDeleteSearchPath->SetMinSize( wxSize( 29,29 ) ); |
|||
|
|||
bSizerSearchPathBtns->Add( m_btnDeleteSearchPath, 0, wxRIGHT, 10 ); |
|||
|
|||
m_btnMoveUp = new wxBitmapButton( m_sb3DSearchPaths->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW ); |
|||
m_btnMoveUp->SetMinSize( wxSize( 29,29 ) ); |
|||
|
|||
bSizerSearchPathBtns->Add( m_btnMoveUp, 0, wxLEFT, 10 ); |
|||
|
|||
m_btnMoveDown = new wxBitmapButton( m_sb3DSearchPaths->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW ); |
|||
m_btnMoveDown->SetMinSize( wxSize( 29,29 ) ); |
|||
|
|||
bSizerSearchPathBtns->Add( m_btnMoveDown, 0, 0, 5 ); |
|||
|
|||
|
|||
m_sb3DSearchPaths->Add( bSizerSearchPathBtns, 0, wxEXPAND, 5 ); |
|||
|
|||
|
|||
bSizerMain->Add( m_sb3DSearchPaths, 1, 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_sdbSizerHelp = new wxButton( this, wxID_HELP ); |
|||
m_sdbSizer->AddButton( m_sdbSizerHelp ); |
|||
m_sdbSizer->Realize(); |
|||
|
|||
bSizerMain->Add( m_sdbSizer, 0, wxALL|wxEXPAND, 5 ); |
|||
|
|||
|
|||
this->SetSizer( bSizerMain ); |
|||
this->Layout(); |
|||
bSizerMain->Fit( this ); |
|||
|
|||
this->Centre( wxBOTH ); |
|||
|
|||
// Connect Events
|
|||
m_EnvVars->Connect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnGridSize ), NULL, this ); |
|||
m_EnvVars->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnUpdateUI ), NULL, this ); |
|||
m_btnAddEnvVar->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnAddEnvVar ), NULL, this ); |
|||
m_btnDeleteEnvVar->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnRemoveEnvVar ), NULL, this ); |
|||
m_SearchPaths->Connect( wxEVT_GRID_CELL_RIGHT_CLICK, wxGridEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnGridCellRightClick ), NULL, this ); |
|||
m_SearchPaths->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnUpdateUI ), NULL, this ); |
|||
m_btnAddSearchPath->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnAddSearchPath ), NULL, this ); |
|||
m_btnDeleteSearchPath->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnDeleteSearchPath ), NULL, this ); |
|||
m_btnMoveUp->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnSearchPathMoveUp ), NULL, this ); |
|||
m_btnMoveDown->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnSearchPathMoveDown ), NULL, this ); |
|||
m_sdbSizerHelp->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnHelp ), NULL, this ); |
|||
} |
|||
|
|||
DIALOG_CONFIGURE_PATHS_BASE::~DIALOG_CONFIGURE_PATHS_BASE() |
|||
{ |
|||
// Disconnect Events
|
|||
m_EnvVars->Disconnect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnGridSize ), NULL, this ); |
|||
m_EnvVars->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnUpdateUI ), NULL, this ); |
|||
m_btnAddEnvVar->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnAddEnvVar ), NULL, this ); |
|||
m_btnDeleteEnvVar->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnRemoveEnvVar ), NULL, this ); |
|||
m_SearchPaths->Disconnect( wxEVT_GRID_CELL_RIGHT_CLICK, wxGridEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnGridCellRightClick ), NULL, this ); |
|||
m_SearchPaths->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnUpdateUI ), NULL, this ); |
|||
m_btnAddSearchPath->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnAddSearchPath ), NULL, this ); |
|||
m_btnDeleteSearchPath->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnDeleteSearchPath ), NULL, this ); |
|||
m_btnMoveUp->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnSearchPathMoveUp ), NULL, this ); |
|||
m_btnMoveDown->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnSearchPathMoveDown ), NULL, this ); |
|||
m_sdbSizerHelp->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONFIGURE_PATHS_BASE::OnHelp ), NULL, this ); |
|||
|
|||
} |
|||
1021
common/dialogs/dialog_configure_paths_base.fbp
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,75 @@ |
|||
/////////////////////////////////////////////////////////////////////////// |
|||
// C++ code generated with wxFormBuilder (version Dec 30 2017) |
|||
// http://www.wxformbuilder.org/ |
|||
// |
|||
// PLEASE DO *NOT* EDIT THIS FILE! |
|||
/////////////////////////////////////////////////////////////////////////// |
|||
|
|||
#ifndef __DIALOG_CONFIGURE_PATHS_BASE_H__ |
|||
#define __DIALOG_CONFIGURE_PATHS_BASE_H__ |
|||
|
|||
#include <wx/artprov.h> |
|||
#include <wx/xrc/xmlres.h> |
|||
#include <wx/intl.h> |
|||
#include "dialog_shim.h" |
|||
#include <wx/colour.h> |
|||
#include <wx/settings.h> |
|||
#include <wx/string.h> |
|||
#include <wx/font.h> |
|||
#include <wx/grid.h> |
|||
#include <wx/gdicmn.h> |
|||
#include <wx/bitmap.h> |
|||
#include <wx/image.h> |
|||
#include <wx/icon.h> |
|||
#include <wx/bmpbuttn.h> |
|||
#include <wx/button.h> |
|||
#include <wx/sizer.h> |
|||
#include <wx/statbox.h> |
|||
#include <wx/dialog.h> |
|||
|
|||
/////////////////////////////////////////////////////////////////////////// |
|||
|
|||
|
|||
/////////////////////////////////////////////////////////////////////////////// |
|||
/// Class DIALOG_CONFIGURE_PATHS_BASE |
|||
/////////////////////////////////////////////////////////////////////////////// |
|||
class DIALOG_CONFIGURE_PATHS_BASE : public DIALOG_SHIM |
|||
{ |
|||
private: |
|||
|
|||
protected: |
|||
wxGrid* m_EnvVars; |
|||
wxBitmapButton* m_btnAddEnvVar; |
|||
wxBitmapButton* m_btnDeleteEnvVar; |
|||
wxStaticBoxSizer* m_sb3DSearchPaths; |
|||
wxGrid* m_SearchPaths; |
|||
wxBitmapButton* m_btnAddSearchPath; |
|||
wxBitmapButton* m_btnDeleteSearchPath; |
|||
wxBitmapButton* m_btnMoveUp; |
|||
wxBitmapButton* m_btnMoveDown; |
|||
wxStdDialogButtonSizer* m_sdbSizer; |
|||
wxButton* m_sdbSizerOK; |
|||
wxButton* m_sdbSizerCancel; |
|||
wxButton* m_sdbSizerHelp; |
|||
|
|||
// Virtual event handlers, overide them in your derived class |
|||
virtual void OnGridSize( wxSizeEvent& event ) { event.Skip(); } |
|||
virtual void OnUpdateUI( wxUpdateUIEvent& event ) { event.Skip(); } |
|||
virtual void OnAddEnvVar( wxCommandEvent& event ) { event.Skip(); } |
|||
virtual void OnRemoveEnvVar( wxCommandEvent& event ) { event.Skip(); } |
|||
virtual void OnGridCellRightClick( wxGridEvent& event ) { event.Skip(); } |
|||
virtual void OnAddSearchPath( wxCommandEvent& event ) { event.Skip(); } |
|||
virtual void OnDeleteSearchPath( wxCommandEvent& event ) { event.Skip(); } |
|||
virtual void OnSearchPathMoveUp( wxCommandEvent& event ) { event.Skip(); } |
|||
virtual void OnSearchPathMoveDown( wxCommandEvent& event ) { event.Skip(); } |
|||
virtual void OnHelp( wxCommandEvent& event ) { event.Skip(); } |
|||
|
|||
|
|||
public: |
|||
|
|||
DIALOG_CONFIGURE_PATHS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Configure Paths"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); |
|||
~DIALOG_CONFIGURE_PATHS_BASE(); |
|||
|
|||
}; |
|||
|
|||
#endif //__DIALOG_CONFIGURE_PATHS_BASE_H__ |
|||
@ -1,511 +0,0 @@ |
|||
/*
|
|||
* This program source code file is part of KICAD, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2015 Wayne Stambaugh <stambaughw@gmail.com> |
|||
* Copyright (C) 2015-2018 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 |
|||
*/ |
|||
|
|||
/**
|
|||
* @file dialog_env_var_config.cpp |
|||
*/ |
|||
|
|||
#include <dialog_env_var_config.h>
|
|||
|
|||
#include <confirm.h>
|
|||
|
|||
#include <validators.h>
|
|||
#include <html_messagebox.h>
|
|||
|
|||
#include <wx/regex.h>
|
|||
|
|||
/** A helper dialog to edit a env var name and/or its value (often a path)
|
|||
*/ |
|||
class DIALOG_ENV_VAR_SINGLE : public DIALOG_ENV_VAR_SINGLE_BASE |
|||
{ |
|||
public: |
|||
DIALOG_ENV_VAR_SINGLE( wxWindow* parent, const wxString& aEnvVarName, |
|||
const wxString& aEnvVarPath ); |
|||
|
|||
/// @return the new environment variable name
|
|||
wxString GetEnvVarName() const |
|||
{ |
|||
return m_envVarName->GetValue(); |
|||
} |
|||
|
|||
/// @return the new environment variable value
|
|||
wxString GetEnvVarValue() const |
|||
{ |
|||
return m_envVarPath->GetValue(); |
|||
} |
|||
|
|||
/// disable the environment variable name (must be called
|
|||
/// for predefined environment variable names, not editable
|
|||
void SetEnvVarProtected() |
|||
{ |
|||
m_envVarName->Enable( false ); |
|||
} |
|||
|
|||
protected: |
|||
void OnSelectPath( wxCommandEvent& event ) override; |
|||
void onHelpClick( wxCommandEvent& event ) override; |
|||
|
|||
// Currently, only upper case variable names are accepted. onVarNameChange
|
|||
// changes on the fly any lower case char by the corresponding upper case
|
|||
void onVarNameChange( wxCommandEvent& event ) override; |
|||
|
|||
bool TransferDataFromWindow() override; |
|||
}; |
|||
|
|||
|
|||
DIALOG_ENV_VAR_CONFIG::DIALOG_ENV_VAR_CONFIG( wxWindow* aParent, const ENV_VAR_MAP& aEnvVarMap ) : |
|||
DIALOG_ENV_VAR_CONFIG_BASE( aParent ) |
|||
{ |
|||
// Copy environment variables across
|
|||
m_envVarMap = aEnvVarMap; |
|||
} |
|||
|
|||
|
|||
bool DIALOG_ENV_VAR_CONFIG::TransferDataToWindow() |
|||
{ |
|||
wxLogDebug( wxT( "In DIALOG_ENV_VAR_CONFIG::TransferDataToWindow()." ) ); |
|||
|
|||
if( !wxDialog::TransferDataToWindow() ) |
|||
return false; |
|||
|
|||
//TODO
|
|||
/*
|
|||
// Grab the project path var (not editable)
|
|||
wxString prjPath; |
|||
|
|||
wxGetEnv( PROJECT_VAR_NAME, &prjPath ); |
|||
|
|||
m_kiprjmod->SetLabel( prjPath ); |
|||
*/ |
|||
|
|||
//TODO - Call SetAlternateRowColour first to prevent assertion error
|
|||
//m_pathList->EnableAlternateRowColours( true );
|
|||
|
|||
PopulatePathList(); |
|||
|
|||
// Select the first item in the list
|
|||
SelectListIndex( 0 ); |
|||
|
|||
GetSizer()->Layout(); |
|||
GetSizer()->Fit( this ); |
|||
GetSizer()->SetSizeHints( this ); |
|||
|
|||
return true; |
|||
} |
|||
|
|||
|
|||
bool DIALOG_ENV_VAR_CONFIG::TransferDataFromWindow() |
|||
{ |
|||
if( !wxDialog::TransferDataFromWindow() ) |
|||
{ |
|||
return false; |
|||
} |
|||
|
|||
Pgm().SetLocalEnvVariables( m_envVarMap ); |
|||
|
|||
return true; |
|||
} |
|||
|
|||
|
|||
void DIALOG_ENV_VAR_CONFIG::PopulatePathList() |
|||
{ |
|||
m_pathList->Freeze(); |
|||
|
|||
m_pathList->ClearAll(); |
|||
|
|||
m_pathList->AppendColumn( _( "Name:" ) ); |
|||
m_pathList->AppendColumn( _( "Path:" ) ); |
|||
|
|||
int row = 0; |
|||
|
|||
for( auto it = m_envVarMap.begin(); it != m_envVarMap.end(); ++it ) |
|||
{ |
|||
long index = m_pathList->InsertItem( row, it->first ); |
|||
|
|||
m_pathList->SetItem( index, 1, it->second.GetValue() ); |
|||
|
|||
if( it->second.GetDefinedExternally() ) |
|||
{ |
|||
wxColour color = wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ); |
|||
|
|||
m_pathList->SetItemBackgroundColour( index, color ); |
|||
} |
|||
|
|||
row++; |
|||
} |
|||
|
|||
m_pathList->SetColumnWidth( 0, wxLIST_AUTOSIZE ); |
|||
m_pathList->SetColumnWidth( 1, wxLIST_AUTOSIZE ); |
|||
|
|||
m_pathList->Update(); |
|||
|
|||
m_pathList->Thaw(); |
|||
} |
|||
|
|||
|
|||
bool DIALOG_ENV_VAR_CONFIG::GetPathAtIndex( unsigned int aIndex, wxString& aEnvVar, |
|||
wxString& aEnvPath ) |
|||
{ |
|||
if( aIndex > m_envVarMap.size() ) |
|||
{ |
|||
return false; |
|||
} |
|||
|
|||
unsigned int idx = 0; |
|||
|
|||
for( auto it = m_envVarMap.begin(); it != m_envVarMap.end(); ++it ) |
|||
{ |
|||
if( idx == aIndex ) |
|||
{ |
|||
aEnvVar = it->first; |
|||
aEnvPath = it->second.GetValue(); |
|||
|
|||
return true; |
|||
} |
|||
|
|||
idx++; |
|||
} |
|||
|
|||
return false; |
|||
} |
|||
|
|||
|
|||
void DIALOG_ENV_VAR_CONFIG::OnAddButton( wxCommandEvent& event ) |
|||
{ |
|||
DIALOG_ENV_VAR_SINGLE dlg( nullptr, wxEmptyString, wxEmptyString ); |
|||
|
|||
if( dlg.ShowModal() == wxID_OK ) |
|||
{ |
|||
wxString newName = dlg.GetEnvVarName(); |
|||
wxString newPath = dlg.GetEnvVarValue(); |
|||
|
|||
// Check that the name does not already exist
|
|||
if( m_envVarMap.count( newName ) > 0 ) |
|||
{ |
|||
//TODO - Improve this message, use DisplayErrorMessage instead
|
|||
DisplayError( this, _( "Path already exists." ) ); |
|||
} |
|||
else |
|||
{ |
|||
m_envVarMap[newName] = ENV_VAR_ITEM( newPath ); |
|||
|
|||
// Update path list
|
|||
PopulatePathList(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
void DIALOG_ENV_VAR_CONFIG::OnEditButton( wxCommandEvent& event ) |
|||
{ |
|||
EditSelectedEntry(); |
|||
} |
|||
|
|||
|
|||
void DIALOG_ENV_VAR_CONFIG::EditSelectedEntry() |
|||
{ |
|||
wxString envName; |
|||
wxString envPath; |
|||
|
|||
if( GetPathAtIndex( m_pathIndex, envName, envPath ) ) |
|||
{ |
|||
auto dlg = new DIALOG_ENV_VAR_SINGLE( nullptr, envName, envPath ); |
|||
|
|||
if( IsEnvVarImmutable( envName ) ) |
|||
{ |
|||
dlg->SetEnvVarProtected(); |
|||
} |
|||
|
|||
if( dlg->ShowModal() == wxID_OK ) |
|||
{ |
|||
wxString newName = dlg->GetEnvVarName(); |
|||
wxString newPath = dlg->GetEnvVarValue(); |
|||
|
|||
// If the path name has not been changed
|
|||
if( envName.Cmp( newName ) == 0 ) |
|||
{ |
|||
m_envVarMap[envName].SetValue( newPath ); |
|||
|
|||
if( m_envVarMap[envName].GetDefinedExternally() ) |
|||
{ |
|||
m_extDefsChanged = true; |
|||
} |
|||
} |
|||
// Path-name needs to be updated
|
|||
else |
|||
{ |
|||
if( IsEnvVarImmutable( envName ) ) |
|||
{ |
|||
DisplayErrorMessage( this, |
|||
wxString::Format( _( "Environment variable \"%s\" cannot " |
|||
"be renamed." ), |
|||
envName.ToStdString() ), |
|||
_( "The selected environment variable name " |
|||
"is required for KiCad functionality and " |
|||
"can not be renamed." ) ); |
|||
|
|||
return; |
|||
} |
|||
|
|||
auto envVar = m_envVarMap[envName]; |
|||
|
|||
m_envVarMap.erase( envName ); |
|||
|
|||
envVar.SetValue( newPath ); |
|||
envVar.SetDefinedExternally( false ); |
|||
m_envVarMap[newName] = envVar; |
|||
} |
|||
|
|||
// Update the path list
|
|||
PopulatePathList(); |
|||
} |
|||
|
|||
dlg->Destroy(); |
|||
} |
|||
} |
|||
|
|||
|
|||
void DIALOG_ENV_VAR_CONFIG::OnHelpButton( wxCommandEvent& event ) |
|||
{ |
|||
wxString msg = _( "Enter the name and value for each environment variable. Grey entries " |
|||
"are names that have been defined externally at the system or user " |
|||
"level. Environment variables defined at the system or user level " |
|||
"take precedence over the ones defined in this table. This means the " |
|||
"values in this table are ignored." ); |
|||
msg << wxT( "<br><br><b>" ); |
|||
msg << _( "To ensure environment variable names are valid on all platforms, the name field " |
|||
"will only accept upper case letters, digits, and the underscore characters." ); |
|||
msg << wxT( "</b><br><br>" ); |
|||
msg << _( "<b>KICAD_SYMBOL_DIR</b> is the base path of the locally installed symbol " |
|||
"libraries." ); |
|||
msg << wxT( "<br><br>" ); |
|||
msg << _( "<b>KIGITHUB</b> is used by KiCad to define the URL of the repository " |
|||
"of the official KiCad footprint libraries. This is only required if the " |
|||
"Github plugin is used to access footprint libraries" ); |
|||
msg << wxT( "<br><br>" ); |
|||
msg << _( "<b>KISYS3DMOD</b> is the base path of system footprint 3D " |
|||
"shapes (.3Dshapes folders)." ); |
|||
msg << wxT( "<br><br>" ); |
|||
msg << _( "<b>KISYSMOD</b> is the base path of locally installed system " |
|||
"footprint libraries (.pretty folders)." ); |
|||
msg << wxT( "<br><br>" ); |
|||
msg << _( "<b>KIPRJMOD</b> is internally defined by KiCad (cannot be edited) and is set " |
|||
"to the absolute path of the currently loaded project file. This environment " |
|||
"variable can be used to define files and paths relative to the currently loaded " |
|||
"project. For instance, ${KIPRJMOD}/libs/footprints.pretty can be defined as a " |
|||
"folder containing a project specific footprint library named footprints.pretty." ); |
|||
msg << wxT( "<br><br>" ); |
|||
msg << _( "<b>KICAD_TEMPLATE_DIR</b> is required and is the path containing the project " |
|||
"templates installed with KiCad." ); |
|||
msg << wxT( "<br><br>" ); |
|||
msg << _( "<b>KICAD_USER_TEMPLATE_DIR</b> is required and is the path containing any user " |
|||
"specific project templates." ); |
|||
|
|||
HTML_MESSAGE_BOX dlg( GetParent(), _( "Environment Variable Help" ) ); |
|||
dlg.SetDialogSizeInDU( 400, 350 ); |
|||
|
|||
dlg.AddHTML_Text( msg ); |
|||
dlg.ShowModal(); |
|||
} |
|||
|
|||
|
|||
bool DIALOG_ENV_VAR_CONFIG::IsEnvVarImmutable( const wxString aEnvVar ) |
|||
{ |
|||
/*
|
|||
* TODO - Instead of defining these values here, |
|||
* extract them from elsewhere in the program |
|||
* (where they are originally defined) |
|||
*/ |
|||
|
|||
static const wxString immutable[] = { |
|||
"KIGITHUB", |
|||
"KISYS3DMOD", |
|||
"KISYSMOD", |
|||
"KIPRJMOD", |
|||
"KICAD_SYMBOL_DIR", |
|||
"KICAD_TEMPLATE_DIR", |
|||
"KICAD_USER_TEMPLATE_DIR" |
|||
}; |
|||
|
|||
for( unsigned int ii=0; ii<6; ii++ ) |
|||
{ |
|||
if( aEnvVar.Cmp( immutable[ii] ) == 0 ) |
|||
{ |
|||
return true; |
|||
} |
|||
} |
|||
|
|||
return false; |
|||
} |
|||
|
|||
|
|||
void DIALOG_ENV_VAR_CONFIG::OnRemoveButton( wxCommandEvent& event ) |
|||
{ |
|||
wxString envName; |
|||
wxString envPath; |
|||
|
|||
if( GetPathAtIndex( m_pathIndex, envName, envPath ) ) |
|||
{ |
|||
if( IsEnvVarImmutable( envName ) ) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
m_envVarMap.erase( envName ); |
|||
|
|||
PopulatePathList(); |
|||
} |
|||
} |
|||
|
|||
|
|||
void DIALOG_ENV_VAR_CONFIG::SelectListIndex( unsigned int aIndex ) |
|||
{ |
|||
if( aIndex >= m_envVarMap.size() ) |
|||
{ |
|||
aIndex = 0; |
|||
} |
|||
|
|||
m_pathIndex = aIndex; |
|||
|
|||
wxString envName; |
|||
wxString envPath; |
|||
|
|||
if( GetPathAtIndex( m_pathIndex, envName, envPath ) ) |
|||
{ |
|||
// Disable the 'delete' button if the path cannot be deleted
|
|||
m_deletePathButton->Enable( !IsEnvVarImmutable( envName ) ); |
|||
} |
|||
} |
|||
|
|||
void DIALOG_ENV_VAR_CONFIG::OnPathSelected( wxListEvent& event ) |
|||
{ |
|||
SelectListIndex( event.GetIndex() ); |
|||
} |
|||
|
|||
|
|||
void DIALOG_ENV_VAR_CONFIG::OnPathActivated( wxListEvent& event ) |
|||
{ |
|||
SelectListIndex( event.GetIndex() ); |
|||
|
|||
EditSelectedEntry(); |
|||
} |
|||
|
|||
|
|||
///////////////////////////
|
|||
// DIALOG_ENV_VAR_SINGLE //
|
|||
///////////////////////////
|
|||
|
|||
DIALOG_ENV_VAR_SINGLE::DIALOG_ENV_VAR_SINGLE( wxWindow* parent, |
|||
const wxString& aEnvVarName, |
|||
const wxString& aEnvVarPath ) : |
|||
DIALOG_ENV_VAR_SINGLE_BASE( parent ) |
|||
{ |
|||
m_envVarName->SetValue( aEnvVarName ); |
|||
m_envVarPath->SetValue( aEnvVarPath ); |
|||
m_envVarName->SetValidator( ENV_VAR_NAME_VALIDATOR() ); |
|||
} |
|||
|
|||
|
|||
void DIALOG_ENV_VAR_SINGLE::OnSelectPath( wxCommandEvent& event ) |
|||
{ |
|||
wxString title = _( "Select Path for Environment Variable" ); |
|||
wxString path; // Currently the first opened path is not initialized
|
|||
|
|||
wxDirDialog dlg( nullptr, title, path, wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST ); |
|||
|
|||
if( dlg.ShowModal() == wxID_OK ) |
|||
m_envVarPath->SetValue( dlg.GetPath() ); |
|||
} |
|||
|
|||
|
|||
void DIALOG_ENV_VAR_SINGLE::onVarNameChange( wxCommandEvent& event ) |
|||
{ |
|||
wxString upper_var = m_envVarName->GetValue().Upper(); |
|||
|
|||
if( upper_var != m_envVarName->GetValue() ) |
|||
{ |
|||
int pos = m_envVarName->GetInsertionPoint(); |
|||
m_envVarName->ChangeValue( upper_var ); |
|||
m_envVarName->SetInsertionPoint( pos ); |
|||
} |
|||
|
|||
} |
|||
|
|||
|
|||
bool DIALOG_ENV_VAR_SINGLE::TransferDataFromWindow() |
|||
{ |
|||
// The user pressed the OK button, test data validity
|
|||
wxString name = m_envVarName->GetValue(); |
|||
wxString path = m_envVarPath->GetValue(); |
|||
|
|||
// Neither name nor path can be empty
|
|||
if( name.IsEmpty() ) |
|||
{ |
|||
DisplayError( this, _( "Environment variable name cannot be empty." ) ); |
|||
// Veto:
|
|||
return false; |
|||
} |
|||
|
|||
if( path.IsEmpty() ) |
|||
{ |
|||
DisplayError( this, _( "Environment variable value cannot be empty." ) ); |
|||
// Veto:
|
|||
return false; |
|||
} |
|||
|
|||
// Name cannot start with a number
|
|||
if( name.Left( 1 ).IsNumber() ) |
|||
{ |
|||
DisplayError( this, _( "Environment variable names cannot start with a digit (0-9)." ) ); |
|||
// Veto:
|
|||
return false; |
|||
} |
|||
|
|||
// No errors detected
|
|||
return true; |
|||
} |
|||
|
|||
|
|||
void DIALOG_ENV_VAR_SINGLE::onHelpClick( wxCommandEvent& event ) |
|||
{ |
|||
wxString msg = _( "An environment variable is used for string substitutions.<br>" |
|||
"Environment variables are primarily used for paths to make KiCad portable " |
|||
"between platforms.<br><br>" |
|||
"If an environment variable is defined as <b>MYLIBPATH</b> with a " |
|||
"value <b>e:/kicad_libs</b>, then a library name " |
|||
"<b>${MYLIBPATH}/mylib.lib</b> gets expanded to " |
|||
"<b>e:/kicad_libs/mylib.lib</b>" |
|||
"<br><br>" |
|||
"<b>Note:</b><br>" |
|||
"Only characters <b>ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_</b> are " |
|||
"allowed in environment variable names and the environment variable name " |
|||
"cannot start with a digit (0-9)." |
|||
); |
|||
|
|||
HTML_MESSAGE_BOX dlg( GetParent(), _( "Environment Variable Help" ) ); |
|||
dlg.SetDialogSizeInDU( 400, 350 ); |
|||
|
|||
dlg.AddHTML_Text( msg ); |
|||
dlg.ShowModal(); |
|||
} |
|||
@ -1,167 +0,0 @@ |
|||
///////////////////////////////////////////////////////////////////////////
|
|||
// C++ code generated with wxFormBuilder (version Aug 4 2017)
|
|||
// http://www.wxformbuilder.org/
|
|||
//
|
|||
// PLEASE DO "NOT" EDIT THIS FILE!
|
|||
///////////////////////////////////////////////////////////////////////////
|
|||
|
|||
#include "dialog_env_var_config_base.h"
|
|||
|
|||
///////////////////////////////////////////////////////////////////////////
|
|||
|
|||
DIALOG_ENV_VAR_CONFIG_BASE::DIALOG_ENV_VAR_CONFIG_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( wxDefaultSize, wxDefaultSize ); |
|||
|
|||
wxBoxSizer* mainSizer; |
|||
mainSizer = new wxBoxSizer( wxVERTICAL ); |
|||
|
|||
wxBoxSizer* bSizer7; |
|||
bSizer7 = new wxBoxSizer( wxHORIZONTAL ); |
|||
|
|||
m_pathList = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_HRULES|wxLC_REPORT|wxLC_VRULES ); |
|||
bSizer7->Add( m_pathList, 1, wxALL|wxEXPAND, 5 ); |
|||
|
|||
wxBoxSizer* bSizer6; |
|||
bSizer6 = new wxBoxSizer( wxVERTICAL ); |
|||
|
|||
m_addPathButton = new wxButton( this, ID_BUTTON_ADD_PATH, _("Add"), wxDefaultPosition, wxDefaultSize, 0 ); |
|||
m_addPathButton->SetToolTip( _("Add path prefix") ); |
|||
|
|||
bSizer6->Add( m_addPathButton, 0, wxALL, 5 ); |
|||
|
|||
m_editPathButton = new wxButton( this, ID_BUTTON_EDIT_PATH, _("Edit"), wxDefaultPosition, wxDefaultSize, 0 ); |
|||
m_editPathButton->SetToolTip( _("Edit selected path prefix") ); |
|||
|
|||
bSizer6->Add( m_editPathButton, 0, wxBOTTOM|wxLEFT|wxRIGHT, 5 ); |
|||
|
|||
m_deletePathButton = new wxButton( this, ID_BUTTON_DELETE_PATH, _("Remove"), wxDefaultPosition, wxDefaultSize, 0 ); |
|||
m_deletePathButton->SetToolTip( _("Remove selected path prefix") ); |
|||
|
|||
bSizer6->Add( m_deletePathButton, 0, wxBOTTOM|wxLEFT|wxRIGHT, 5 ); |
|||
|
|||
|
|||
bSizer6->Add( 0, 0, 1, wxEXPAND, 5 ); |
|||
|
|||
|
|||
bSizer7->Add( bSizer6, 0, wxEXPAND, 5 ); |
|||
|
|||
|
|||
mainSizer->Add( bSizer7, 1, wxEXPAND, 5 ); |
|||
|
|||
m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); |
|||
mainSizer->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_sdbSizerHelp = new wxButton( this, wxID_HELP ); |
|||
m_sdbSizer->AddButton( m_sdbSizerHelp ); |
|||
m_sdbSizer->Realize(); |
|||
|
|||
mainSizer->Add( m_sdbSizer, 0, wxBOTTOM|wxALIGN_RIGHT, 5 ); |
|||
|
|||
|
|||
this->SetSizer( mainSizer ); |
|||
this->Layout(); |
|||
mainSizer->Fit( this ); |
|||
|
|||
this->Centre( wxBOTH ); |
|||
|
|||
// Connect Events
|
|||
m_pathList->Connect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( DIALOG_ENV_VAR_CONFIG_BASE::OnPathActivated ), NULL, this ); |
|||
m_pathList->Connect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( DIALOG_ENV_VAR_CONFIG_BASE::OnPathSelected ), NULL, this ); |
|||
m_addPathButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ENV_VAR_CONFIG_BASE::OnAddButton ), NULL, this ); |
|||
m_editPathButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ENV_VAR_CONFIG_BASE::OnEditButton ), NULL, this ); |
|||
m_deletePathButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ENV_VAR_CONFIG_BASE::OnRemoveButton ), NULL, this ); |
|||
m_sdbSizerHelp->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ENV_VAR_CONFIG_BASE::OnHelpButton ), NULL, this ); |
|||
} |
|||
|
|||
DIALOG_ENV_VAR_CONFIG_BASE::~DIALOG_ENV_VAR_CONFIG_BASE() |
|||
{ |
|||
// Disconnect Events
|
|||
m_pathList->Disconnect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( DIALOG_ENV_VAR_CONFIG_BASE::OnPathActivated ), NULL, this ); |
|||
m_pathList->Disconnect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( DIALOG_ENV_VAR_CONFIG_BASE::OnPathSelected ), NULL, this ); |
|||
m_addPathButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ENV_VAR_CONFIG_BASE::OnAddButton ), NULL, this ); |
|||
m_editPathButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ENV_VAR_CONFIG_BASE::OnEditButton ), NULL, this ); |
|||
m_deletePathButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ENV_VAR_CONFIG_BASE::OnRemoveButton ), NULL, this ); |
|||
m_sdbSizerHelp->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ENV_VAR_CONFIG_BASE::OnHelpButton ), NULL, this ); |
|||
|
|||
} |
|||
|
|||
DIALOG_ENV_VAR_SINGLE_BASE::DIALOG_ENV_VAR_SINGLE_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( wxDefaultSize, wxDefaultSize ); |
|||
|
|||
wxBoxSizer* bSizerMain; |
|||
bSizerMain = new wxBoxSizer( wxVERTICAL ); |
|||
|
|||
wxFlexGridSizer* fgSizer1; |
|||
fgSizer1 = new wxFlexGridSizer( 0, 3, 0, 0 ); |
|||
fgSizer1->AddGrowableCol( 1 ); |
|||
fgSizer1->SetFlexibleDirection( wxBOTH ); |
|||
fgSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); |
|||
|
|||
m_envVarNameLabel = new wxStaticText( this, wxID_ANY, _("Name:"), wxDefaultPosition, wxDefaultSize, 0 ); |
|||
m_envVarNameLabel->Wrap( -1 ); |
|||
fgSizer1->Add( m_envVarNameLabel, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); |
|||
|
|||
m_envVarName = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); |
|||
fgSizer1->Add( m_envVarName, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 5 ); |
|||
|
|||
m_buttonHelp = new wxButton( this, wxID_ANY, _("Help"), wxDefaultPosition, wxDefaultSize, 0 ); |
|||
fgSizer1->Add( m_buttonHelp, 0, wxALL, 5 ); |
|||
|
|||
m_envVarPathLabel = new wxStaticText( this, wxID_ANY, _("Value:"), wxDefaultPosition, wxDefaultSize, 0 ); |
|||
m_envVarPathLabel->Wrap( -1 ); |
|||
fgSizer1->Add( m_envVarPathLabel, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT|wxRIGHT, 5 ); |
|||
|
|||
m_envVarPath = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); |
|||
m_envVarPath->SetMinSize( wxSize( 250,-1 ) ); |
|||
|
|||
fgSizer1->Add( m_envVarPath, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 ); |
|||
|
|||
m_selectPathButton = new wxButton( this, wxID_ANY, _("Browse"), wxDefaultPosition, wxDefaultSize, 0 ); |
|||
fgSizer1->Add( m_selectPathButton, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT|wxRIGHT, 5 ); |
|||
|
|||
|
|||
bSizerMain->Add( fgSizer1, 0, wxALL|wxEXPAND, 5 ); |
|||
|
|||
|
|||
bSizerMain->Add( 0, 0, 1, wxEXPAND, 5 ); |
|||
|
|||
m_staticline2 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); |
|||
bSizerMain->Add( m_staticline2, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 ); |
|||
|
|||
m_sdbSizer2 = new wxStdDialogButtonSizer(); |
|||
m_sdbSizer2OK = new wxButton( this, wxID_OK ); |
|||
m_sdbSizer2->AddButton( m_sdbSizer2OK ); |
|||
m_sdbSizer2Cancel = new wxButton( this, wxID_CANCEL ); |
|||
m_sdbSizer2->AddButton( m_sdbSizer2Cancel ); |
|||
m_sdbSizer2->Realize(); |
|||
|
|||
bSizerMain->Add( m_sdbSizer2, 0, wxBOTTOM|wxLEFT|wxRIGHT|wxALIGN_RIGHT, 5 ); |
|||
|
|||
|
|||
this->SetSizer( bSizerMain ); |
|||
this->Layout(); |
|||
bSizerMain->Fit( this ); |
|||
|
|||
this->Centre( wxBOTH ); |
|||
|
|||
// Connect Events
|
|||
m_envVarName->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_ENV_VAR_SINGLE_BASE::onVarNameChange ), NULL, this ); |
|||
m_buttonHelp->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ENV_VAR_SINGLE_BASE::onHelpClick ), NULL, this ); |
|||
m_selectPathButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ENV_VAR_SINGLE_BASE::OnSelectPath ), NULL, this ); |
|||
} |
|||
|
|||
DIALOG_ENV_VAR_SINGLE_BASE::~DIALOG_ENV_VAR_SINGLE_BASE() |
|||
{ |
|||
// Disconnect Events
|
|||
m_envVarName->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_ENV_VAR_SINGLE_BASE::onVarNameChange ), NULL, this ); |
|||
m_buttonHelp->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ENV_VAR_SINGLE_BASE::onHelpClick ), NULL, this ); |
|||
m_selectPathButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ENV_VAR_SINGLE_BASE::OnSelectPath ), NULL, this ); |
|||
|
|||
} |
|||
1335
common/dialogs/dialog_env_var_config_base.fbp
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -1,102 +0,0 @@ |
|||
/////////////////////////////////////////////////////////////////////////// |
|||
// C++ code generated with wxFormBuilder (version Aug 4 2017) |
|||
// http://www.wxformbuilder.org/ |
|||
// |
|||
// PLEASE DO "NOT" EDIT THIS FILE! |
|||
/////////////////////////////////////////////////////////////////////////// |
|||
|
|||
#ifndef __DIALOG_ENV_VAR_CONFIG_BASE_H__ |
|||
#define __DIALOG_ENV_VAR_CONFIG_BASE_H__ |
|||
|
|||
#include <wx/artprov.h> |
|||
#include <wx/xrc/xmlres.h> |
|||
#include <wx/intl.h> |
|||
class DIALOG_SHIM; |
|||
|
|||
#include "dialog_shim.h" |
|||
#include <wx/listctrl.h> |
|||
#include <wx/gdicmn.h> |
|||
#include <wx/font.h> |
|||
#include <wx/colour.h> |
|||
#include <wx/settings.h> |
|||
#include <wx/string.h> |
|||
#include <wx/button.h> |
|||
#include <wx/sizer.h> |
|||
#include <wx/statline.h> |
|||
#include <wx/dialog.h> |
|||
#include <wx/stattext.h> |
|||
#include <wx/textctrl.h> |
|||
|
|||
/////////////////////////////////////////////////////////////////////////// |
|||
|
|||
#define ID_BUTTON_ADD_PATH 1000 |
|||
#define ID_BUTTON_EDIT_PATH 1001 |
|||
#define ID_BUTTON_DELETE_PATH 1002 |
|||
|
|||
/////////////////////////////////////////////////////////////////////////////// |
|||
/// Class DIALOG_ENV_VAR_CONFIG_BASE |
|||
/////////////////////////////////////////////////////////////////////////////// |
|||
class DIALOG_ENV_VAR_CONFIG_BASE : public DIALOG_SHIM |
|||
{ |
|||
private: |
|||
|
|||
protected: |
|||
wxListCtrl* m_pathList; |
|||
wxButton* m_addPathButton; |
|||
wxButton* m_editPathButton; |
|||
wxButton* m_deletePathButton; |
|||
wxStaticLine* m_staticline1; |
|||
wxStdDialogButtonSizer* m_sdbSizer; |
|||
wxButton* m_sdbSizerOK; |
|||
wxButton* m_sdbSizerCancel; |
|||
wxButton* m_sdbSizerHelp; |
|||
|
|||
// Virtual event handlers, overide them in your derived class |
|||
virtual void OnPathActivated( wxListEvent& event ) { event.Skip(); } |
|||
virtual void OnPathSelected( wxListEvent& event ) { event.Skip(); } |
|||
virtual void OnAddButton( wxCommandEvent& event ) { event.Skip(); } |
|||
virtual void OnEditButton( wxCommandEvent& event ) { event.Skip(); } |
|||
virtual void OnRemoveButton( wxCommandEvent& event ) { event.Skip(); } |
|||
virtual void OnHelpButton( wxCommandEvent& event ) { event.Skip(); } |
|||
|
|||
|
|||
public: |
|||
|
|||
DIALOG_ENV_VAR_CONFIG_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Environment Variable Configuration"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); |
|||
~DIALOG_ENV_VAR_CONFIG_BASE(); |
|||
|
|||
}; |
|||
|
|||
/////////////////////////////////////////////////////////////////////////////// |
|||
/// Class DIALOG_ENV_VAR_SINGLE_BASE |
|||
/////////////////////////////////////////////////////////////////////////////// |
|||
class DIALOG_ENV_VAR_SINGLE_BASE : public DIALOG_SHIM |
|||
{ |
|||
private: |
|||
|
|||
protected: |
|||
wxStaticText* m_envVarNameLabel; |
|||
wxTextCtrl* m_envVarName; |
|||
wxButton* m_buttonHelp; |
|||
wxStaticText* m_envVarPathLabel; |
|||
wxTextCtrl* m_envVarPath; |
|||
wxButton* m_selectPathButton; |
|||
wxStaticLine* m_staticline2; |
|||
wxStdDialogButtonSizer* m_sdbSizer2; |
|||
wxButton* m_sdbSizer2OK; |
|||
wxButton* m_sdbSizer2Cancel; |
|||
|
|||
// Virtual event handlers, overide them in your derived class |
|||
virtual void onVarNameChange( wxCommandEvent& event ) { event.Skip(); } |
|||
virtual void onHelpClick( wxCommandEvent& event ) { event.Skip(); } |
|||
virtual void OnSelectPath( wxCommandEvent& event ) { event.Skip(); } |
|||
|
|||
|
|||
public: |
|||
|
|||
DIALOG_ENV_VAR_SINGLE_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Edit Environment Variable"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); |
|||
~DIALOG_ENV_VAR_SINGLE_BASE(); |
|||
|
|||
}; |
|||
|
|||
#endif //__DIALOG_ENV_VAR_CONFIG_BASE_H__ |
|||
@ -0,0 +1,87 @@ |
|||
/* |
|||
* This program source code file is part of KICAD, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2015 Wayne Stambaugh <stambaughw@gmail.com> |
|||
* Copyright (C) 2015-2018 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 |
|||
*/ |
|||
|
|||
#ifndef _DIALOG_CONFIGURE_PATHS_H_ |
|||
#define _DIALOG_CONFIGURE_PATHS_H_ |
|||
|
|||
#include <../common/dialogs/dialog_configure_paths_base.h> |
|||
|
|||
#include <wx/valtext.h> |
|||
#include <pgm_base.h> |
|||
|
|||
|
|||
class EDA_DRAW_FRAME; |
|||
class FILENAME_RESOLVER; |
|||
|
|||
/** |
|||
* DIALOG_CONFIGURE_PATHS class declaration |
|||
*/ |
|||
|
|||
class DIALOG_CONFIGURE_PATHS: public DIALOG_CONFIGURE_PATHS_BASE |
|||
{ |
|||
public: |
|||
DIALOG_CONFIGURE_PATHS( wxWindow* aParent, FILENAME_RESOLVER* aResolver ); |
|||
virtual ~DIALOG_CONFIGURE_PATHS(); |
|||
|
|||
bool TransferDataToWindow() override; |
|||
bool TransferDataFromWindow() override; |
|||
|
|||
protected: |
|||
// Various button callbacks |
|||
virtual void OnGridCellRightClick( wxGridEvent& event ) override; |
|||
virtual void OnGridSize( wxSizeEvent& event ) override; |
|||
virtual void OnUpdateUI( wxUpdateUIEvent& event ) override; |
|||
virtual void OnGridCellChanging( wxGridEvent& event ); |
|||
virtual void OnAddEnvVar( wxCommandEvent& event ) override; |
|||
virtual void OnRemoveEnvVar( wxCommandEvent& event ) override; |
|||
virtual void OnAddSearchPath( wxCommandEvent& event ) override; |
|||
virtual void OnDeleteSearchPath( wxCommandEvent& event ) override; |
|||
virtual void OnSearchPathMoveUp( wxCommandEvent& event ) override; |
|||
virtual void OnSearchPathMoveDown( wxCommandEvent& event ) override; |
|||
virtual void OnHelp( wxCommandEvent& event ) override; |
|||
|
|||
void AppendEnvVar( const wxString& aName, const wxString& aPath, |
|||
bool isExternal ); |
|||
void AppendSearchPath( const wxString& aName, const wxString& aPath, |
|||
const wxString& aDescription ); |
|||
void AdjustGridColumns( int aWidth ); |
|||
|
|||
/** |
|||
* Determine if a particular ENV_VAR is protected |
|||
*/ |
|||
bool IsEnvVarImmutable( const wxString aEnvVar ); |
|||
|
|||
private: |
|||
wxString m_errorMsg; |
|||
wxGrid* m_errorGrid; |
|||
int m_errorRow; |
|||
int m_errorCol; |
|||
|
|||
FILENAME_RESOLVER* m_resolver; |
|||
wxString m_curdir; |
|||
wxTextValidator m_aliasValidator; |
|||
|
|||
}; |
|||
|
|||
#endif // _DIALOG_CONFIGURE_PATHS_H_ |
|||
@ -1,102 +0,0 @@ |
|||
/* |
|||
* This program source code file is part of KICAD, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2015 Wayne Stambaugh <stambaughw@gmail.com> |
|||
* Copyright (C) 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 |
|||
* 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 |
|||
*/ |
|||
|
|||
#ifndef _DIALOG_ENV_VAR_CONFIG_H_ |
|||
#define _DIALOG_ENV_VAR_CONFIG_H_ |
|||
|
|||
class EDA_DRAW_FRAME; |
|||
|
|||
#include <../common/dialogs/dialog_env_var_config_base.h> |
|||
|
|||
#include <pgm_base.h> |
|||
|
|||
|
|||
/** |
|||
* DIALOG_ENV_VAR_CONFIG class declaration |
|||
*/ |
|||
|
|||
class DIALOG_ENV_VAR_CONFIG: public DIALOG_ENV_VAR_CONFIG_BASE |
|||
{ |
|||
private: |
|||
ENV_VAR_MAP m_envVarMap; |
|||
bool m_extDefsChanged = false; |
|||
|
|||
protected: |
|||
|
|||
/** |
|||
* Update the displayed list of ENV_VAR paths |
|||
*/ |
|||
void PopulatePathList(); |
|||
|
|||
/** |
|||
* Edit the currently selected ENV_VAR entry |
|||
*/ |
|||
void EditSelectedEntry(); |
|||
|
|||
// Various button callbacks |
|||
virtual void OnAddButton( wxCommandEvent& event ) override; |
|||
virtual void OnEditButton( wxCommandEvent& event ) override; |
|||
virtual void OnRemoveButton( wxCommandEvent& event ) override; |
|||
virtual void OnHelpButton( wxCommandEvent& event ) override; |
|||
|
|||
virtual void OnPathSelected( wxListEvent& event ) override; |
|||
virtual void OnPathActivated( wxListEvent& event ) override; |
|||
|
|||
// Variable for keeping track of currently selected list index |
|||
unsigned int m_pathIndex = 0; |
|||
|
|||
/** |
|||
* Extract the NAME and PATH data from the ENV_VAR at the provided index |
|||
* @param aIndex is the index to extract data from |
|||
* @return true if data was extracted else false |
|||
*/ |
|||
bool GetPathAtIndex( unsigned int aIndex, wxString& aEnvVar, wxString& aEnvPath ); |
|||
|
|||
/** |
|||
* Determine if a particular ENV_VAR is protected |
|||
* @param aEnvVar is the name of the ENV_VAR |
|||
*/ |
|||
bool IsEnvVarImmutable( const wxString aEnvVar ); |
|||
|
|||
/** |
|||
* Select the ENV_VAR at the provided index |
|||
*/ |
|||
void SelectListIndex( unsigned int aIndex ); |
|||
|
|||
public: |
|||
DIALOG_ENV_VAR_CONFIG( wxWindow* parent, const ENV_VAR_MAP& aEnvVarMap ); |
|||
virtual ~DIALOG_ENV_VAR_CONFIG() {} |
|||
|
|||
bool TransferDataToWindow() override; |
|||
bool TransferDataFromWindow() override; |
|||
|
|||
bool ExternalDefsChanged() const { return m_extDefsChanged; } |
|||
|
|||
const ENV_VAR_MAP& GetEnvVarMap() const |
|||
{ |
|||
return m_envVarMap; |
|||
} |
|||
}; |
|||
|
|||
#endif // _DIALOG_ENV_VAR_CONFIG_H_ |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue