38 #include <wx/dirdlg.h> 57 m_errorGrid( nullptr ),
60 m_resolver( aResolver ),
62 m_gridWidthsDirty( true ),
63 m_helpDialog( nullptr )
77 wxGridCellAttr* attr =
new wxGridCellAttr;
81 attr =
new wxGridCellAttr;
92 m_EnvVars->SetSelectionMode( wxGrid::wxGridSelectionModes::wxGridSelectRows );
93 m_SearchPaths->SetSelectionMode( wxGrid::wxGridSelectionModes::wxGridSelectRows );
114 GetSizer()->SetSizeHints(
this );
135 if( !wxDialog::TransferDataToWindow() )
144 for(
auto it = paths->begin(); it != paths->end(); ++it )
146 if ( !( *it ).m_Alias.StartsWith(
"${" ) && !( *it ).m_Alias.StartsWith(
"$(" ) )
160 for(
auto it = envVars.begin(); it != envVars.end(); ++it )
162 const wxString& path = it->second.GetValue();
163 AppendEnvVar( it->first, path, it->second.GetDefinedExternally() );
165 if(
m_curdir.IsEmpty() && !path.StartsWith(
"${" ) && !path.StartsWith(
"$(" ) )
185 nameCellAttr->SetEditor( nameTextEditor );
187 nameCellAttr->DecRef();
192 wxSystemColour c = isExternal ? wxSYS_COLOUR_MENU : wxSYS_COLOUR_LISTBOX;
193 pathCellAttr->SetBackgroundColour( wxSystemSettings::GetColour( c ) );
194 pathCellAttr->DecRef();
201 const wxString& aDescription )
212 nameCellAttr->SetEditor( nameTextEditor );
213 nameCellAttr->DecRef();
225 if( !wxDialog::TransferDataFromWindow() )
232 for(
int row = 0; row <
m_EnvVars->GetNumberRows(); ++row )
239 if( external.Length() )
244 else if(
name.IsEmpty() )
249 m_errorMsg =
_(
"Environment variable name cannot be empty." );
252 else if( path.IsEmpty() )
257 m_errorMsg =
_(
"Environment variable path cannot be empty." );
261 envVarMap[
name ] = var;
264 Pgm().SetLocalEnvVariables( envVarMap );
270 std::vector<SEARCH_PATH> alist;
273 for(
int row = 0; row <
m_SearchPaths->GetNumberRows(); ++row )
284 m_errorMsg =
_(
"3D search path alias cannot be empty." );
292 m_errorMsg =
_(
"3D search path cannot be empty." );
296 alist.push_back( alias );
309 wxGrid* grid = dynamic_cast<wxGrid*>( event.GetEventObject() );
310 int row =
event.GetRow();
311 int col =
event.GetCol();
312 wxString text =
event.GetString();
319 m_errorMsg =
_(
"Environment variable name cannot be empty." );
321 m_errorMsg =
_(
"Environment variable path cannot be empty." );
326 m_errorMsg =
_(
"3D search path alias cannot be empty." );
328 m_errorMsg =
_(
"3D search path cannot be empty." );
330 m_errorGrid = dynamic_cast<wxGrid*>( event.GetEventObject() );
341 wxString msg1 =
_(
"This path was defined externally to the running process and\n" 342 "will only be temporarily overwritten." );
343 wxString msg2 =
_(
"The next time KiCad is launched, any paths that have already\n" 344 "been defined are honored and any settings defined in the path\n" 345 "configuration dialog are ignored. If you did not intend for\n" 346 "this behavior, either rename any conflicting entries or remove\n" 347 "the external environment variable(s) from your system." );
349 dlg.ShowDetailedText( msg2 );
358 _(
"The name %s is reserved, and cannot be used here" ),
379 m_EnvVars->EnableCellEditControl(
true );
401 int curRow =
m_EnvVars->GetGridCursorRow();
403 if( curRow < 0 || m_EnvVars->GetNumberRows() <= curRow )
423 if( curRow < 0 || m_SearchPaths->GetNumberRows() <= curRow )
444 int prevRow = curRow - 1;
468 int nextRow = curRow + 1;
470 if( curRow < m_SearchPaths->GetNumberRows() - 1 )
495 if( GetPopupMenuSelectionFromUser( menu ) == 1 )
497 wxDirDialog dlg(
nullptr,
_(
"Select Path" ),
m_curdir,
498 wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST );
500 if( dlg.ShowModal() == wxID_OK )
502 wxGrid* grid = dynamic_cast<wxGrid*>( aEvent.GetEventObject() );
503 grid->SetCellValue( aEvent.GetRow(),
TV_VALUE_COL, dlg.GetPath() );
515 int width =
m_EnvVars->GetClientRect().GetWidth();
553 grid->EnableCellEditControl(
true );
554 grid->ShowCellEditControl();
576 wxString msg =
_(
"Enter the name and value for each environment variable. Grey entries " 577 "are names that have been defined externally at the system or user " 578 "level. Environment variables defined at the system or user level " 579 "take precedence over the ones defined in this table. This means the " 580 "values in this table are ignored." );
581 msg <<
"<br><br><b>";
582 msg <<
_(
"To ensure environment variable names are valid on all platforms, the name field " 583 "will only accept upper case letters, digits, and the underscore characters." );
588 msg <<
"<br><br><b>" << var <<
"</b>";
592 if( desc.size() > 0 )
void DoNotShowCheckbox(wxString file, int line)
Checks the 'do not show again' setting for the dialog.
bool IsEnvVarImmutable(const wxString &aEnvVar)
Determine if an environment variable is "predefined", i.e.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
const ENV_VAR_LIST & GetPredefinedEnvVars()
Get the list of pre-defined environment variables.
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
This file is part of the common library.
const BITMAP_OPAQUE small_folder_xpm[1]
wxMenuItem * AddMenuItem(wxMenu *aMenu, int aId, const wxString &aText, const wxBitmap &aImage, wxItemKind aType=wxITEM_NORMAL)
Create and insert a menu item with an icon into aMenu.
A simple helper class to store environment variable values and the status of whether or not they were...
#define PROJECT_VAR_NAME
A variable name whose value holds the current project directory.
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
const std::list< SEARCH_PATH > * GetPaths(void)
Return a pointer to the internal path list; the items in:load.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
void SetInitialFocus(wxWindow *aWindow)
Sets the window (usually a wxTextCtrl) that should be focused when the dialog is shown.
This class works around a bug in wxGrid where the first keystroke doesn't get sent through the valida...
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
bool UpdatePathList(std::vector< SEARCH_PATH > &aPathList)
Clear the current path list and substitutes the given path list and update the path configuration fil...
std::map< wxString, ENV_VAR_ITEM > ENV_VAR_MAP
void SetDefinedExternally(bool aIsDefinedExternally)
const BITMAP_OPAQUE small_down_xpm[1]
Editor for wxGrid cells that adds a file/folder browser to the grid input field.
wxString LookUpEnvVarHelp(const wxString &aEnvVar)
Look up long-form help text for a given environment variable.
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
const BITMAP_OPAQUE small_up_xpm[1]
const BITMAP_OPAQUE small_trash_xpm[1]
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
void ShowModeless()
Show a modeless version of the dialog (without an OK button).
void SetDialogSizeInDU(int aWidth, int aHeight)
set the dialog size, using a "logical" value.
This class provides a custom wxValidator object for limiting the allowable characters when defining a...
Provide an extensible class to resolve 3D model paths.
void AddHTML_Text(const wxString &message)
Add HTML text (without any change) to message list.
Functions related to environment variables, including help functions.
const BITMAP_OPAQUE small_plus_xpm[1]
Custom text control validator definitions.