35#include <python_scripting.h>
49#include <wx/stattext.h>
53 _(
"Current variant" ),
54 _(
"Selects the current schematic variant" ),
74 auto menu = std::make_unique<ACTION_MENU>(
false, selTool );
234 auto variantSelectionCtrlFactory =
241 wxDefaultSize,
Schematic().GetVariantNamesForUI(), 0,
242 wxDefaultValidator, tmp );
255 auto pluginControlFactory =
259 bool scriptingAvailable = SCRIPTING::IsWxAvailable();
265 bool haveApiPlugins =
false;
268 if( scriptingAvailable || haveApiPlugins )
270 aToolbar->AddScaledSeparator( aToolbar->GetParent() );
301 if( selectionIndex != wxNOT_FOUND )
305 wxArrayString contents = aVariantNames;
306 contents.Add( wxS(
"---" ) );
307 contents.Add(
_(
"Add New Variant..." ) );
328 if( selection == wxNOT_FOUND || count == 0 )
332 if( selection == count - 1 )
339 if( previousSelection != wxNOT_FOUND )
347 if( selection == count - 2 )
353 if( previousSelection != wxNOT_FOUND )
360 wxString selectedVariant;
363 selectedVariant = selectedString;
374 wxDialog dlg(
this, wxID_ANY,
_(
"New Variant" ), wxDefaultPosition, wxDefaultSize,
375 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER );
377 wxBoxSizer* mainSizer =
new wxBoxSizer( wxVERTICAL );
380 wxStaticText* nameLabel =
new wxStaticText( &dlg, wxID_ANY,
_(
"Variant name:" ) );
381 mainSizer->Add( nameLabel, 0, wxALL | wxEXPAND, 5 );
383 wxTextCtrl* nameCtrl =
new wxTextCtrl( &dlg, wxID_ANY );
384 mainSizer->Add( nameCtrl, 0, wxALL | wxEXPAND, 5 );
387 wxStaticText* descLabel =
new wxStaticText( &dlg, wxID_ANY,
_(
"Description (optional):" ) );
388 mainSizer->Add( descLabel, 0, wxALL | wxEXPAND, 5 );
390 wxTextCtrl* descCtrl =
new wxTextCtrl( &dlg, wxID_ANY, wxEmptyString, wxDefaultPosition,
391 wxSize( 300, 60 ), wxTE_MULTILINE );
392 mainSizer->Add( descCtrl, 1, wxALL | wxEXPAND, 5 );
395 wxStdDialogButtonSizer* btnSizer =
new wxStdDialogButtonSizer();
396 btnSizer->AddButton(
new wxButton( &dlg, wxID_OK ) );
397 btnSizer->AddButton(
new wxButton( &dlg, wxID_CANCEL ) );
399 mainSizer->Add( btnSizer, 0, wxALL | wxALIGN_RIGHT, 5 );
401 dlg.SetSizer( mainSizer );
405 if( dlg.ShowModal() == wxID_CANCEL )
408 wxString variantName = nameCtrl->GetValue().Trim().Trim(
false );
409 wxString variantDesc = descCtrl->GetValue().Trim().Trim(
false );
412 if( variantName.IsEmpty() )
415 10000, wxICON_ERROR );
424 10000, wxICON_ERROR );
429 for(
const wxString& existingName :
Schematic().GetVariantNames() )
431 if( existingName.CmpNoCase( variantName ) == 0 )
435 10000, wxICON_ERROR );
443 if( !variantDesc.IsEmpty() )
464 if( newSelection == wxNOT_FOUND )
469 wxString selectedString;
471 if( currentSelection != wxNOT_FOUND )
474 if( selectedString !=
name )
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
static TOOL_ACTION gridProperties
static TOOL_ACTION toggleGrid
static TOOL_ACTION zoomRedraw
static TOOL_ACTION millimetersUnits
static TOOL_ACTION cursorSmallCrosshairs
static TOOL_ACTION zoomOutCenter
static TOOL_ACTION selectSetLasso
static TOOL_ACTION selectSetRect
Set lasso selection mode.
static TOOL_ACTION showSymbolEditor
static TOOL_ACTION showSymbolBrowser
static TOOL_ACTION findAndReplace
static TOOL_ACTION milsUnits
static TOOL_ACTION ungroup
static TOOL_ACTION toggleBoundingBoxes
static TOOL_ACTION pageSettings
static TOOL_ACTION inchesUnits
static TOOL_ACTION zoomFitScreen
static TOOL_ACTION deleteTool
static TOOL_ACTION zoomTool
static TOOL_ACTION cursor45Crosshairs
static TOOL_ACTION showFootprintEditor
static TOOL_ACTION showProperties
static TOOL_ACTION zoomFitObjects
static TOOL_ACTION zoomInCenter
static TOOL_ACTION toggleGridOverrides
static TOOL_ACTION cursorFullCrosshairs
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
virtual void ClearToolbarControl(int aId)
void RegisterCustomToolbarControlFactory(const ACTION_TOOLBAR_CONTROL &aControlDesc, const ACTION_TOOLBAR_CONTROL_FACTORY &aControlFactory)
Register a creation factory for toolbar controls that are present in this frame.
virtual void configureToolbars()
WX_INFOBAR * GetInfoBar()
virtual void AddApiPluginTools(ACTION_TOOLBAR *aToolbar)
Append actions from API plugins to the given toolbar.
virtual COMMON_SETTINGS * GetCommonSettings() const
void SetCurrentVariant(const wxString &aVariantName)
void AddVariant(const wxString &aVariantName)
wxString GetCurrentVariant() const
Return the current variant being edited.
void SetVariantDescription(const wxString &aVariantName, const wxString &aDescription)
Set the description for a variant.
static TOOL_ACTION showPcbNew
static TOOL_ACTION rotateCCW
static TOOL_ACTION placeClassLabel
static TOOL_ACTION placeSheetPin
static TOOL_ACTION assignFootprints
static TOOL_ACTION mirrorV
static TOOL_ACTION placeGlobalLabel
static TOOL_ACTION editSymbolFields
static TOOL_ACTION drawTextBox
static TOOL_ACTION toggleAnnotateAuto
static TOOL_ACTION syncAllSheetsPins
static TOOL_ACTION drawArc
static TOOL_ACTION drawSheet
static TOOL_ACTION navigateBack
static TOOL_ACTION schematicSetup
static TOOL_ACTION highlightNetTool
static TOOL_ACTION drawRectangle
static TOOL_ACTION drawLines
static TOOL_ACTION placeHierLabel
static TOOL_ACTION placeLabel
static TOOL_ACTION drawCircle
static TOOL_ACTION placeBusWireEntry
static TOOL_ACTION drawBezier
static TOOL_ACTION drawWire
static TOOL_ACTION lineMode45
static TOOL_ACTION rotateCW
static TOOL_ACTION generateBOM
static TOOL_ACTION showHierarchy
static TOOL_ACTION placeJunction
static TOOL_ACTION drawRuleArea
static TOOL_ACTION placeSymbol
static TOOL_ACTION placeImage
static TOOL_ACTION navigateForward
static TOOL_ACTION mirrorH
static TOOL_ACTION showSimulator
static TOOL_ACTION drawBus
static TOOL_ACTION runERC
Inspection and Editing.
static TOOL_ACTION drawTable
static TOOL_ACTION lineMode90
static TOOL_ACTION placeSchematicText
static TOOL_ACTION lineModeFree
static TOOL_ACTION annotate
static TOOL_ACTION placeNoConnect
static TOOL_ACTION toggleHiddenPins
static TOOL_ACTION placePower
static TOOL_ACTION navigateUp
wxChoice * m_currentVariantCtrl
void SetCurrentVariant(const wxString &aVariantName)
void UpdateVariantSelectionCtrl(const wxArrayString &aVariantNames)
Update the variant name control on the main toolbar.
bool ShowAddVariantDialog()
Show a dialog to create a new variant with name and description.
void configureToolbars() override
void HardRedraw() override
Rebuild the GAL and redraw the screen.
PLUGIN_ACTION_SCOPE PluginActionScope() const override
SCHEMATIC & Schematic() const
void onVariantSelected(wxCommandEvent &aEvent)
void ClearToolbarControl(int aId) override
void ShowMessageFor(const wxString &aMessage, int aTime, int aFlags=wxICON_INFORMATION, MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
Show the infobar with the provided message and icon for a specific period of time.
@ ID_TOOLBAR_SCH_SELECT_VARAIANT
PGM_BASE & Pgm()
The global program "get" accessor.
wxString GetDefaultVariantName()