47#include <wx/settings.h>
61#define DEFAULT_FONT_NAME _( "Default Font" )
78 const std::unique_ptr< LIB_SYMBOL >& lib_symbol = aSymbol->
GetLibSymbolRef();
85 std::vector<wxString> expanded =
pin->GetStackedPinNumbers( &valid );
87 if( valid && !expanded.empty() )
89 for(
const wxString& num : expanded )
90 pins.push_back( num +
' ' +
pin->GetShownName() );
94 pins.push_back(
pin->GetNumber() +
' ' +
pin->GetShownName() );
101 wxString dbg = wxJoin( pins,
'\t' );
102 wxLogTrace(
"FOOTPRINT_CHOOSER", wxS(
"Chooser payload pins: %s" ), dbg );
112 if( !fpFilters.IsEmpty() )
135 std::vector<wxString> expanded =
pin->GetStackedPinNumbers( &valid );
137 if( valid && !expanded.empty() )
139 for(
const wxString& num : expanded )
140 pins.push_back( num +
' ' +
pin->GetShownName() );
144 pins.push_back(
pin->GetNumber() +
' ' +
pin->GetShownName() );
148 if( !pins.IsEmpty() )
150 wxString dbg = wxJoin( pins,
'\t' );
151 wxLogTrace(
"FOOTPRINT_CHOOSER", wxS(
"Chooser payload pins: %s" ), dbg );
159 if( !fpFilters.IsEmpty() )
169 LIB_SYMBOL* aSymbol, std::vector<EMBEDDED_FILES*> aFilesStack ) :
192 m_part( aSymbol->GetLibSymbolRef().get() ),
250 int mandatoryRows = 0;
258 return mandatoryRows;
264 std::vector<SCH_FIELD>::push_back( aField );
330 wxString wildCard(
_(
"Schematic Files" ) );
331 std::vector<std::string> exts;
340 m_boolAttr->SetRenderer(
new wxGridCellBoolRenderer() );
341 m_boolAttr->SetEditor(
new wxGridCellBoolEditor() );
342 m_boolAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
344 wxArrayString vAlignNames;
345 vAlignNames.Add(
_(
"Top" ) );
346 vAlignNames.Add(
_(
"Center" ) );
347 vAlignNames.Add(
_(
"Bottom" ) );
349 m_vAlignAttr->SetEditor(
new wxGridCellChoiceEditor( vAlignNames ) );
350 m_vAlignAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
352 wxArrayString hAlignNames;
353 hAlignNames.Add(
_(
"Left" ) );
354 hAlignNames.Add(
_(
"Center" ) );
355 hAlignNames.Add(
_(
"Right" ) );
357 m_hAlignAttr->SetEditor(
new wxGridCellChoiceEditor( hAlignNames ) );
358 m_hAlignAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
360 wxArrayString orientationNames;
361 orientationNames.Add(
_(
"Horizontal" ) );
362 orientationNames.Add(
_(
"Vertical" ) );
368 wxArrayString existingNetclasses;
371 std::vector<std::string> fontNames;
377 const std::shared_ptr<NET_SETTINGS>& settings = projectFile.
NetSettings();
379 existingNetclasses.push_back( settings->GetDefaultNetclass()->GetName() );
381 for(
const auto& [
name, netclass] : settings->GetNetclasses() )
382 existingNetclasses.push_back(
name );
386 const std::vector<wxString>* fontFiles =
nullptr;
389 fontFiles =
m_frame->GetScreen()->Schematic()->GetEmbeddedFiles()->GetFontFiles();
391 Fontconfig()->ListFonts( fontNames, std::string(
Pgm().GetLanguageTag().utf8_str() ),
396 const std::vector<wxString>* fontFiles =
m_part->GetEmbeddedFiles()->UpdateFontFiles();
400 Fontconfig()->ListFonts( fontNames, std::string(
Pgm().GetLanguageTag().utf8_str() ),
401 fontFiles, !fontFiles->empty() );
407 for(
const std::string&
name : fontNames )
421 m_eval = std::make_unique<NUMERIC_EVALUATOR>(
m_frame->GetUserUnits() );
446 field.SetParent(
nullptr );
455 GetView()->ForceRefresh();
491 return (
int) this->size();
507 if( visibleRow == aRow )
513 wxFAIL_MSG( wxT(
"Row index off end of visible row count" ) );
516 return this->at( aRow );
540 default: wxFAIL;
return wxEmptyString;
559 return aTypeName == wxGRID_VALUE_STRING;
567 return aTypeName == wxGRID_VALUE_BOOL;
587 wxGridCellAttr* attr =
nullptr;
595 attr->SetReadOnly(
true );
728 wxGridCellAttr* text_attr = attr ? attr->Clone() :
new wxGridCellAttr;
731 if( !text_attr->HasFont() )
732 font = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
734 font = text_attr->GetFont();
737 text_attr->SetFont( font );
738 text_attr->SetTextColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
754 wxGrid*
grid = GetView();
757 if(
grid->GetGridCursorRow() == aRow &&
grid->GetGridCursorCol() == aCol
758 &&
grid->IsCellEditControlShown() )
825 return _(
"Horizontal" );
827 return _(
"Vertical" );
856 return wxT(
"bad wxWidgets!" );
874 wxFAIL_MSG( wxString::Format( wxT(
"column %d doesn't hold a bool value" ), aCol ) );
885 wxString value = aValue;
894 if(
m_eval->Process( value ) )
939 if( value ==
_(
"Left" ) )
941 else if( value ==
_(
"Center" ) )
943 else if( value ==
_(
"Right" ) )
961 if( value ==
_(
"Top" ) )
963 else if( value ==
_(
"Center" ) )
965 else if( value ==
_(
"Bottom" ) )
989 m_frame->ValueFromString( value ) ) );
993 if( value ==
_(
"Horizontal" ) )
995 else if( value ==
_(
"Vertical" ) )
998 wxFAIL_MSG( wxT(
"unknown orientation: " ) + value );
1007 pos.
x =
m_frame->ValueFromString( value );
1009 pos.
y =
m_frame->ValueFromString( value );
1037 wxFAIL_MSG( wxString::Format( wxT(
"column %d doesn't hold a string value" ), aCol ) );
1043 GetView()->Refresh();
1079 wxFAIL_MSG( wxString::Format( wxT(
"column %d doesn't hold a bool value" ), aCol ) );
1098 if( aValue == wxS(
"1" ) )
1102 else if( aValue == wxS(
"0" ) )
1108 wxFAIL_MSG( wxString::Format(
"string '%s' can't be converted to boolean correctly and "
1109 "will be perceived as FALSE", aValue ) );
1119 if( field.
GetId() == aFieldId )
1129 for(
int ii = 0; ii < (int) this->size(); ++ii )
1131 if( this->at( ii ).GetId() == aFieldId )
1141 back().SetParent(
m_part );
1163 std::vector<SCH_FIELD>::erase( begin() + aRow );
1169 wxCHECK( a < this->size() && b < this->size(), );
1171 std::swap( at( a ), at( b ) );
1204 _(
"Browse for footprint" ) );
1205 menu.AppendSeparator();
1212 _(
"Show datasheet in browser" ) );
1213 menu.AppendSeparator();
1229 if( frame->ShowModal( &fpid,
m_dlg ) )
Dialog helper object to sit in the inheritance tree between wxDialog and any class written by wxFormB...
bool IsHorizontal() const
virtual void SetParent(EDA_ITEM *aParent)
int GetTextHeight() const
void SetTextColor(const COLOR4D &aColor)
const VECTOR2I & GetTextPos() const
COLOR4D GetTextColor() const
const EDA_ANGLE & GetTextAngle() const
void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true)
virtual const wxString & GetText() const
Return the string associated with the text object.
virtual bool IsVisible() const
void SetTextPos(const VECTOR2I &aPoint)
KIFONT::FONT * GetFont() const
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
virtual void SetVisible(bool aVisible)
static GR_TEXT_H_ALIGN_T MapHorizJustify(int aHorizJustify)
void SetBold(bool aBold)
Set the text to be bold - this will also update the font if needed.
static GR_TEXT_V_ALIGN_T MapVertJustify(int aVertJustify)
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
void SetItalic(bool aItalic)
Set the text to be italic - this will also update the font if needed.
void SetFont(KIFONT::FONT *aFont)
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
wxGridCellAttr * GetAttr(int aRow, int aCol, wxGridCellAttr::wxAttrKind aKind) override
std::vector< bool > m_isInherited
bool IsInherited(size_t aRow) const
SCH_FIELD * GetField(FIELD_T aFieldId)
wxString StringFromBool(bool aValue) const
bool GetValueAsBool(int aRow, int aCol) override
FIELD_VALIDATOR m_fieldNameValidator
bool CanSetValueAs(int aRow, int aCol, const wxString &aTypeName) override
void initGrid(WX_GRID *aGrid)
wxGridCellAttr * m_fieldNameAttr
int getColumnCount() const
int GetNumberRows() override
void push_back(const SCH_FIELD &field)
wxGridCellAttr * m_readOnlyAttr
int GetMandatoryRowCount() const
FIELDS_GRID_TABLE(DIALOG_SHIM *aDialog, SCH_BASE_FRAME *aFrame, WX_GRID *aGrid, LIB_SYMBOL *aSymbol, std::vector< EMBEDDED_FILES * > aFilesStack={})
FIELD_VALIDATOR m_urlValidator
~FIELDS_GRID_TABLE() override
bool CanGetValueAs(int aRow, int aCol, const wxString &aTypeName) override
wxGridCellAttr * m_colorAttr
wxGridCellAttr * m_nonUrlAttr
bool EraseRow(size_t row)
wxGridCellAttr * m_referenceAttr
FIELD_VALIDATOR m_referenceValidator
FIELD_VALIDATOR m_valueValidator
std::map< std::pair< int, int >, wxString > m_evalOriginal
int getVisibleRowCount() const
wxGridCellAttr * m_footprintAttr
wxGridCellAttr * m_boolAttr
std::vector< EMBEDDED_FILES * > m_filesStack
int GetFieldRow(FIELD_T aFieldId)
bool BoolFromString(const wxString &aValue) const
wxGridCellAttr * m_fontAttr
wxGridCellAttr * m_urlAttr
wxGridCellAttr * m_valueAttr
wxGridCellAttr * m_hAlignAttr
void AddInheritedField(const SCH_FIELD &aParent)
wxGridCellAttr * m_orientationAttr
void SetValue(int aRow, int aCol, const wxString &aValue) override
wxGridCellAttr * m_vAlignAttr
wxGridCellAttr * m_filepathAttr
SCH_FIELD & getField(int aRow)
wxGridCellAttr * m_netclassAttr
void SetValueAsBool(int aRow, int aCol, bool aValue) override
wxString GetValue(int aRow, int aCol) override
void SwapRows(size_t a, size_t b)
void onUnitsChanged(wxCommandEvent &aEvent)
std::unique_ptr< NUMERIC_EVALUATOR > m_eval
std::vector< SCH_FIELD > m_parentFields
FIELD_VALIDATOR m_nonUrlValidator
FIELD_VALIDATOR m_filepathValidator
wxString GetColLabelValue(int aCol) override
void showPopupMenu(wxMenu &menu, wxGridEvent &aEvent) override
int getFieldRow(FIELD_T aFieldId)
std::vector< EMBEDDED_FILES * > m_filesStack
void doPopupSelection(wxCommandEvent &event) override
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...
virtual void SetValidator(const wxValidator &validator) override
virtual void doPopupSelection(wxCommandEvent &event)
virtual void showPopupMenu(wxMenu &menu, wxGridEvent &aEvent)
WX_GRID * m_grid
I don't own the grid, but he owns me.
static FONT * GetFont(const wxString &aFontName=wxEmptyString, bool aBold=false, bool aItalic=false, const std::vector< wxString > *aEmbeddedFiles=nullptr, bool aForDrawingSheet=false)
const wxString & GetName() const
wxString ToCSSString() const
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Define a library symbol object.
wxArrayString GetFPFilters() const
std::vector< SCH_PIN * > GetGraphicalPins(int aUnit=0, int aBodyStyle=0) const
Graphical pins: Return schematic pin objects as drawn (unexpanded), filtered by unit/body.
The backing store for a PROJECT, in JSON format.
std::shared_ptr< NET_SETTINGS > & NetSettings()
static SEARCH_STACK * SchSearchS(PROJECT *aProject)
Accessor for Eeschema search stack.
virtual PROJECT_FILE & GetProjectFile() const
These are loaded from Eeschema settings but then overwritten by the project settings.
TEMPLATES m_TemplateFieldNames
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
Schematic editor (Eeschema) main window.
GR_TEXT_V_ALIGN_T GetEffectiveVertJustify() const
bool IsHypertext() const override
Allow items to support hypertext actions when hovered/clicked.
bool IsHorizJustifyFlipped() const
Return whether the field will be rendered with the horizontal justification inverted due to rotation ...
bool IsVertJustifyFlipped() const
void SetCanAutoplace(bool aCanPlace)
wxString GetCanonicalName() const
Get a non-language-specific name for a field which can be used for storage, variable look-up,...
GR_TEXT_H_ALIGN_T GetEffectiveHorizJustify() const
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
void SetName(const wxString &aName)
bool CanAutoplace() const
void SetText(const wxString &aText) override
void OnScintillaCharAdded(SCINTILLA_TRICKS *aScintillaTricks, wxStyledTextEvent &aEvent) const
void SetNameShown(bool aShown=true)
void SetPrivate(bool aPrivate)
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
static const wxString GetDefaultFieldName(const wxString &aName, bool aUseDefaultName)
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
Add cut/copy/paste, dark theme, autocomplete and brace highlighting to a wxStyleTextCtrl instance.
Look for files in a number of paths.
const TEMPLATE_FIELDNAME * GetFieldName(const wxString &aName)
Search for aName in the template field name list.
wxGridCellAttr * enhanceAttr(wxGridCellAttr *aInputAttr, int aRow, int aCol, wxGridCellAttr::wxAttrKind aKind)
wxString EnsureFileExtension(const wxString &aFilename, const wxString &aExtension)
It's annoying to throw up nag dialogs when the extension isn't right.
static constexpr EDA_ANGLE ANGLE_VERTICAL
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
bool GetAssociatedDocument(wxWindow *aParent, const wxString &aDocName, PROJECT *aProject, SEARCH_STACK *aPaths, std::vector< EMBEDDED_FILES * > aFilesStack)
Open a document (file) with the suitable browser.
This file is part of the common library.
#define DEFAULT_FONT_NAME
static wxString netList(SCH_SYMBOL *aSymbol, SCH_SHEET_PATH &aSheetPath)
@ FDC_SYMBOL_EDITOR_COUNT
FONTCONFIG * Fontconfig()
@ FRAME_FOOTPRINT_CHOOSER
@ GRIDTRICKS_FIRST_CLIENT_ID
static const std::string KiCadSchematicFileExtension
@ USER
The main config directory (e.g. ~/.config/kicad/)
PGM_BASE & Pgm()
The global program "get" accessor.
Definitions of control validators for schematic dialogs.
wxString UnescapeString(const wxString &aSource)
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
Hold a name of a symbol's field, field value, and default visibility.
Definition for symbol library class.
wxString GetDefaultFieldName(FIELD_T aFieldId, bool aTranslateForHI)
Return a default symbol field name for a mandatory field type.
FIELD_T
The set of all field indices assuming an array like sequence that a SCH_COMPONENT or LIB_PART can hol...
@ FOOTPRINT
Field Name Module PCB, i.e. "16DIP300".
@ DATASHEET
name of datasheet
@ REFERENCE
Field Reference of part, i.e. "IC21".
@ VALUE
Field Value of part, i.e. "3.3K".
GR_TEXT_H_ALIGN_T
This is API surface mapped to common.types.HorizontalAlignment.
@ GR_TEXT_H_ALIGN_INDETERMINATE
GR_TEXT_V_ALIGN_T
This is API surface mapped to common.types.VertialAlignment.
@ GR_TEXT_V_ALIGN_INDETERMINATE
#define INDETERMINATE_STATE
Used for holding indeterminate values, such as with multiple selections holding different values or c...
Custom text control validator definitions.
VECTOR2< int32_t > VECTOR2I
wxString AddFileExtListToFilter(const std::vector< std::string > &aExts)
Build the wildcard extension file dialog wildcard filter to add to the base message dialog.
Definition of file extensions used in Kicad.