60 m_errorGrid( nullptr ),
64 m_gridWidthsDirty( true ),
66 m_heightBeforeHelp( 400 )
76 wxGridCellAttr* attr =
new wxGridCellAttr;
84 [
this]( wxCommandEvent& aEvent )
89 m_EnvVars->SetSelectionMode( wxGrid::wxGridSelectionModes::wxGridSelectRows );
95 m_EnvVars->Connect( wxEVT_GRID_CELL_CHANGING,
99 GetSizer()->SetSizeHints(
this );
109 m_EnvVars->Disconnect( wxEVT_GRID_CELL_CHANGING,
117 if( !wxDialog::TransferDataToWindow() )
122 for(
auto it = envVars.begin(); it != envVars.end(); ++it )
124 const wxString&
path = it->second.GetValue();
127 if(
m_curdir.IsEmpty() && !
path.StartsWith(
"${" ) && !
path.StartsWith(
"$(" ) )
147 nameCellAttr->SetEditor( nameTextEditor );
149 nameCellAttr->DecRef();
154 wxSystemColour c = isExternal ? wxSYS_COLOUR_MENU : wxSYS_COLOUR_LISTBOX;
155 pathCellAttr->SetBackgroundColour( wxSystemSettings::GetColour( c ) );
156 pathCellAttr->DecRef();
167 if( !wxDialog::TransferDataFromWindow() )
173 for(
int row = 0; row <
m_EnvVars->GetNumberRows(); ++row )
183 else if(
name.empty() &&
path.empty() )
188 else if(
name.IsEmpty() )
193 m_errorMsg =
_(
"Environment variable name cannot be empty." );
196 else if(
path.IsEmpty() )
201 m_errorMsg =
_(
"Environment variable path cannot be empty." );
205 if( envVarMap.count(
name ) )
206 envVarMap.at(
name ).SetValue(
path );
212 for(
auto it = envVarMap.begin(); it != envVarMap.end(); )
216 for(
int row = 0; row <
m_EnvVars->GetNumberRows(); ++row )
220 if( it->first ==
name )
230 it = envVarMap.erase( it );
233 Pgm().SetLocalEnvVariables();
241 wxGrid*
grid =
dynamic_cast<wxGrid*
>(
event.GetEventObject() );
242 int row =
event.GetRow();
243 int col =
event.GetCol();
244 wxString
text =
event.GetString();
251 m_errorMsg =
_(
"Environment variable name cannot be empty." );
253 m_errorMsg =
_(
"Environment variable path cannot be empty." );
258 m_errorMsg =
_(
"3D search path alias cannot be empty." );
260 m_errorMsg =
_(
"3D search path cannot be empty." );
263 m_errorGrid =
dynamic_cast<wxGrid*
>(
event.GetEventObject() );
273 && !
Pgm().GetCommonSettings()->m_DoNotShowAgain.env_var_overwrite_warning )
275 wxString msg1 =
_(
"This path was defined externally to the running process and\n"
276 "will only be temporarily overwritten." );
277 wxString msg2 =
_(
"The next time KiCad is launched, any paths that have already\n"
278 "been defined are honored and any settings defined in the path\n"
279 "configuration dialog are ignored. If you did not intend for\n"
280 "this behavior, either rename any conflicting entries or remove\n"
281 "the external environment variable(s) from your system." );
283 dlg.ShowDetailedText( msg2 );
288 Pgm().GetCommonSettings()->m_DoNotShowAgain.env_var_overwrite_warning =
true;
295 wxMessageBox( wxString::Format(
_(
"The name %s is reserved, and cannot be used." ),
318 m_EnvVars->EnableCellEditControl(
true );
325 int curRow =
m_EnvVars->GetGridCursorRow();
327 if( curRow < 0 || m_EnvVars->GetNumberRows() <= curRow )
349 int width =
m_EnvVars->GetClientRect().GetWidth();
375 grid->EnableCellEditControl(
true );
376 grid->ShowCellEditControl();
392 wxSizer* sizerMain = GetSizer();
397 wxHW_SCROLLBAR_AUTO );
399 wxString msg =
_(
"Enter the name and value for each environment variable. Grey entries "
400 "are names that have been defined externally at the system or user "
401 "level. Environment variables defined at the system or user level "
402 "take precedence over the ones defined in this table. This means the "
403 "values in this table are ignored." );
404 msg <<
"<br><br><b>";
405 msg <<
_(
"To ensure environment variable names are valid on all platforms, the name field "
406 "will only accept upper case letters, digits, and the underscore characters." );
411 msg <<
"<br><br><b>" << var <<
"</b>";
415 if( desc.size() > 0 )
423 sizerMain->Insert( sizerMain->GetItemCount() - 1,
m_helpBox, 1, wxALL|wxEXPAND, 10 );
436 int minHelpBoxHeight = GetTextExtent( wxT(
"T" ) ).y * 20;
438 if( GetClientSize().y < minHelpBoxHeight * 2 )
439 SetClientSize( wxSize( GetClientSize().x, GetClientSize().y + minHelpBoxHeight ) );
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
void SetInitialFocus(wxWindow *aWindow)
Sets the window (usually a wxTextCtrl) that should be focused when the dialog is shown.
void SetupStandardButtons(std::map< int, wxString > aLabels={})
KiCad uses environment variables internally for determining the base paths for libraries,...
This class provides a custom wxValidator object for limiting the allowable characters when defining a...
Editor for wxGrid cells that adds a file/folder browser to the grid input field.
This class works around a bug in wxGrid where the first keystroke doesn't get sent through the valida...
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
Add dark theme support to wxHtmlWindow.
bool SetPage(const wxString &aSource) override
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
bool DoNotShowAgain() const
void DoNotShowCheckbox(wxString file, int line)
Checks the 'do not show again' setting for the dialog.
void ClearRows()
wxWidgets recently added an ASSERT which fires if the position is greater than or equal to the number...
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
This file is part of the common library.
Functions related to environment variables, including help functions.
std::map< wxString, ENV_VAR_ITEM > ENV_VAR_MAP
wxString LookUpEnvVarHelp(const wxString &aEnvVar)
Look up long-form help text for a given environment variable.
const ENV_VAR_LIST & GetPredefinedEnvVars()
Get the list of pre-defined environment variables.
bool IsEnvVarImmutable(const wxString &aEnvVar)
Determine if an environment variable is "predefined", i.e.
#define PROJECT_VAR_NAME
A variable name whose value holds the current project directory.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Custom text control validator definitions.