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 );
231 auto variantSelectionCtrlFactory =
238 wxDefaultSize,
Schematic().GetVariantNamesForUI(), 0,
239 wxDefaultValidator, tmp );
251 auto pluginControlFactory =
255 bool scriptingAvailable = SCRIPTING::IsWxAvailable();
261 bool haveApiPlugins =
false;
264 if( scriptingAvailable || haveApiPlugins )
266 aToolbar->AddScaledSeparator( aToolbar->GetParent() );
297 if( selectionIndex != wxNOT_FOUND )
301 wxArrayString contents = aVariantNames;
302 contents.Add( wxS(
"---" ) );
303 contents.Add(
_(
"Add New Design Variant..." ) );
326 if( selection == wxNOT_FOUND || count == 0 )
330 if( selection == count - 1 )
337 if( previousSelection != wxNOT_FOUND )
345 if( selection == count - 2 )
351 if( previousSelection != wxNOT_FOUND )
358 wxString selectedVariant;
361 selectedVariant = selectedString;
372 wxDialog dlg(
this, wxID_ANY,
_(
"New Design Variant" ), wxDefaultPosition, wxDefaultSize,
373 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER );
375 wxBoxSizer* mainSizer =
new wxBoxSizer( wxVERTICAL );
378 wxStaticText* nameLabel =
new wxStaticText( &dlg, wxID_ANY,
_(
"Variant name:" ) );
379 mainSizer->Add( nameLabel, 0, wxLEFT | wxRIGHT | wxTOP | wxEXPAND, 10 );
381 mainSizer->AddSpacer( 3 );
383 wxTextCtrl* nameCtrl =
new wxTextCtrl( &dlg, wxID_ANY );
384 mainSizer->Add( nameCtrl, 0, wxLEFT | wxRIGHT | wxBOTTOM | wxEXPAND, 10 );
387 wxStaticText* descLabel =
new wxStaticText( &dlg, wxID_ANY,
_(
"Description (optional):" ) );
388 mainSizer->Add( descLabel, 0, wxLEFT | wxRIGHT | wxTOP | wxEXPAND, 10 );
390 mainSizer->AddSpacer( 3 );
392 wxTextCtrl* descCtrl =
new wxTextCtrl( &dlg, wxID_ANY, wxEmptyString, wxDefaultPosition,
393 wxSize( 300, 60 ), wxTE_MULTILINE );
394 mainSizer->Add( descCtrl, 1, wxLEFT | wxRIGHT | wxBOTTOM | wxEXPAND, 10 );
397 wxStdDialogButtonSizer* btnSizer =
new wxStdDialogButtonSizer();
398 btnSizer->AddButton(
new wxButton( &dlg, wxID_OK ) );
399 btnSizer->AddButton(
new wxButton( &dlg, wxID_CANCEL ) );
401 mainSizer->Add( btnSizer, 0, wxALL | wxALIGN_RIGHT, 5 );
403 dlg.SetSizer( mainSizer );
406 nameLabel->SetFocus();
408 if( dlg.ShowModal() == wxID_CANCEL )
411 wxString variantName = nameCtrl->GetValue().Trim().Trim(
false );
412 wxString variantDesc = descCtrl->GetValue().Trim().Trim(
false );
415 if( variantName.IsEmpty() )
426 10000, wxICON_ERROR );
431 for(
const wxString& existingName :
Schematic().GetVariantNames() )
433 if( existingName.CmpNoCase( variantName ) == 0 )
437 10000, wxICON_ERROR );
445 if( !variantDesc.IsEmpty() )
466 if( newSelection == wxNOT_FOUND )
471 wxString selectedString;
473 if( currentSelection != wxNOT_FOUND )
476 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()