35#include <python_scripting.h>
51#include <wx/stattext.h>
55 _(
"Current variant" ),
56 _(
"Selects the current schematic variant" ),
76 auto menu = std::make_unique<ACTION_MENU>(
false, selTool );
233 auto variantSelectionCtrlFactory =
240 wxDefaultSize,
Schematic().GetVariantNamesForUI(), 0,
241 wxDefaultValidator, tmp );
253 auto pluginControlFactory =
257 bool scriptingAvailable = SCRIPTING::IsWxAvailable();
263 bool haveApiPlugins =
false;
266 if( scriptingAvailable || haveApiPlugins )
268 aToolbar->AddScaledSeparator( aToolbar->GetParent() );
299 if( selectionIndex != wxNOT_FOUND )
303 wxArrayString contents = aVariantNames;
304 contents.Add( wxS(
"---" ) );
305 contents.Add(
_(
"Add New Design 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;
385 wxDialog dlg(
this, wxID_ANY,
_(
"New Design Variant" ), wxDefaultPosition, wxDefaultSize,
386 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER );
388 wxBoxSizer* mainSizer =
new wxBoxSizer( wxVERTICAL );
391 wxStaticText* nameLabel =
new wxStaticText( &dlg, wxID_ANY,
_(
"Variant name:" ) );
392 mainSizer->Add( nameLabel, 0, wxLEFT | wxRIGHT | wxTOP | wxEXPAND, 10 );
394 mainSizer->AddSpacer( 3 );
396 wxTextCtrl* nameCtrl =
new wxTextCtrl( &dlg, wxID_ANY );
397 mainSizer->Add( nameCtrl, 0, wxLEFT | wxRIGHT | wxBOTTOM | wxEXPAND, 10 );
400 wxStaticText* descLabel =
new wxStaticText( &dlg, wxID_ANY,
_(
"Description (optional):" ) );
401 mainSizer->Add( descLabel, 0, wxLEFT | wxRIGHT | wxTOP | wxEXPAND, 10 );
403 mainSizer->AddSpacer( 3 );
405 wxTextCtrl* descCtrl =
new wxTextCtrl( &dlg, wxID_ANY, wxEmptyString, wxDefaultPosition,
406 wxSize( 300, 60 ), wxTE_MULTILINE );
407 mainSizer->Add( descCtrl, 1, wxLEFT | wxRIGHT | wxBOTTOM | wxEXPAND, 10 );
410 wxStdDialogButtonSizer* btnSizer =
new wxStdDialogButtonSizer();
411 btnSizer->AddButton(
new wxButton( &dlg, wxID_OK ) );
412 btnSizer->AddButton(
new wxButton( &dlg, wxID_CANCEL ) );
414 mainSizer->Add( btnSizer, 0, wxALL | wxALIGN_RIGHT, 5 );
416 dlg.SetSizer( mainSizer );
419 nameLabel->SetFocus();
421 if( dlg.ShowModal() == wxID_CANCEL )
424 wxString variantName = nameCtrl->GetValue().Trim().Trim(
false );
425 wxString variantDesc = descCtrl->GetValue().Trim().Trim(
false );
428 if( variantName.IsEmpty() )
439 10000, wxICON_ERROR );
444 for(
const wxString& existingName :
Schematic().GetVariantNames() )
446 if( existingName.CmpNoCase( variantName ) == 0 )
450 10000, wxICON_ERROR );
458 if( !variantDesc.IsEmpty() )
479 if( newSelection == wxNOT_FOUND )
484 wxString selectedString;
486 if( currentSelection != wxNOT_FOUND )
489 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()
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
virtual void AddApiPluginTools(ACTION_TOOLBAR *aToolbar)
Append actions from API plugins to the given toolbar.
A base class for most all the KiCad significant classes used in schematics and boards.
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
virtual unsigned int GetSize() const override
Return the number of stored items.
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()