42#include <wx/settings.h>
56#define DEFAULT_FONT_NAME _( "Default Font" )
74 std::vector<wxString> expanded =
pin->GetStackedPinNumbers( &valid );
76 if( valid && !expanded.empty() )
78 for(
const wxString& number : expanded )
79 pins.push_back( number +
' ' +
pin->GetShownName() );
83 pins.push_back(
pin->GetNumber() +
' ' +
pin->GetShownName() );
90 wxString pinList = wxJoin( pins,
'\t' );
91 wxLogTrace(
"FOOTPRINT_CHOOSER", wxS(
"Chooser payload pins: %s" ), pinList );
101 if( !fpFilters.IsEmpty() )
113 if( aSymbols.empty() || !aSymbols.front() )
114 return wxEmptyString;
118 for(
size_t i = 1; i < aSymbols.size(); ++i )
123 return wxEmptyString;
126 return symbolNetlist;
132 std::vector<SCH_FIELD> fields = aSheet.
GetFields();
142 fields.push_back( suffix );
145 std::stable_sort( fields.begin(), fields.end(),
148 if( a.IsMandatory() != b.IsMandatory() )
149 return a.IsMandatory();
151 if( !a.IsMandatory() )
153 bool aSuffix = a.GetId() == FIELD_T::SHEET_REF_SUFFIX;
154 bool bSuffix = b.GetId() == FIELD_T::SHEET_REF_SUFFIX;
156 if( aSuffix != bSuffix )
168 LIB_SYMBOL* aSymbol, std::vector<EMBEDDED_FILES*>& aFilesStack ) :
188 std::vector<EMBEDDED_FILES*>& aFilesStack ) :
207 SCH_SHEET* aSheet, std::vector<EMBEDDED_FILES*>& aFilesStack ) :
225 SCH_LABEL_BASE* aLabel, std::vector<EMBEDDED_FILES*>& aFilesStack ) :
244 int mandatoryRows = 0;
252 return mandatoryRows;
258 std::vector<SCH_FIELD>::push_back( aField );
328 wxString wildCard(
_(
"Schematic Files" ) );
329 std::vector<std::string> exts;
338 m_boolAttr->SetRenderer(
new wxGridCellBoolRenderer() );
339 m_boolAttr->SetEditor(
new wxGridCellBoolEditor() );
340 m_boolAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
342 wxArrayString vAlignNames;
343 vAlignNames.Add(
_(
"Top" ) );
344 vAlignNames.Add(
_(
"Center" ) );
345 vAlignNames.Add(
_(
"Bottom" ) );
347 m_vAlignAttr->SetEditor(
new wxGridCellChoiceEditor( vAlignNames ) );
348 m_vAlignAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
350 wxArrayString hAlignNames;
351 hAlignNames.Add(
_(
"Left" ) );
352 hAlignNames.Add(
_(
"Center" ) );
353 hAlignNames.Add(
_(
"Right" ) );
355 m_hAlignAttr->SetEditor(
new wxGridCellChoiceEditor( hAlignNames ) );
356 m_hAlignAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
358 wxArrayString orientationNames;
359 orientationNames.Add(
_(
"Horizontal" ) );
360 orientationNames.Add(
_(
"Vertical" ) );
366 wxArrayString existingNetclasses;
369 std::vector<std::string> fontNames;
375 const std::shared_ptr<NET_SETTINGS>& settings = projectFile.
NetSettings();
377 existingNetclasses.push_back( settings->GetDefaultNetclass()->GetName() );
379 for(
const auto& [
name, netclass] : settings->GetNetclasses() )
380 existingNetclasses.push_back(
name );
384 const std::vector<wxString>* fontFiles =
nullptr;
387 fontFiles =
m_frame->GetScreen()->Schematic()->GetEmbeddedFiles()->GetFontFiles();
389 Fontconfig()->ListFonts( fontNames, std::string(
Pgm().GetLanguageTag().utf8_str() ),
394 const std::vector<wxString>* fontFiles =
m_part->GetEmbeddedFiles()->UpdateFontFiles();
398 Fontconfig()->ListFonts( fontNames, std::string(
Pgm().GetLanguageTag().utf8_str() ),
399 fontFiles, !fontFiles->empty() );
405 for(
const std::string&
name : fontNames )
419 m_eval = std::make_unique<NUMERIC_EVALUATOR>(
m_frame->GetUserUnits() );
446 inheritance.m_parentField.SetParent(
nullptr );
455 GetView()->ForceRefresh();
483 wxCHECK_MSG( aRow >= 0 && aRow <
getVisibleRowCount(), -1, wxT(
"Invalid field row" ) );
490 for(
int fieldIndex = 0; fieldIndex < static_cast<int>( size() ); ++fieldIndex )
492 if( at( fieldIndex ).IsPrivate() )
495 if( visibleRow == aRow )
501 wxFAIL_MSG( wxT(
"Row index off end of visible row count" ) );
521 return (
int) this->size();
551 default: wxFAIL;
return wxEmptyString;
570 return aTypeName == wxGRID_VALUE_STRING;
578 return aTypeName == wxGRID_VALUE_BOOL;
598 wxGridCellAttr* attr =
nullptr;
606 attr->SetReadOnly(
true );
669 m_frame->Prj().GetProjectFile().m_TemplateFieldNames.GetFieldName( fn );
737 wxGridCellAttr* text_attr = attr ? attr->Clone() :
new wxGridCellAttr;
740 if( !text_attr->HasFont() )
741 font = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
743 font = text_attr->GetFont();
746 text_attr->SetFont( font );
747 text_attr->SetTextColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
763 wxGrid*
grid = GetView();
766 if(
grid->GetGridCursorRow() == aRow &&
grid->GetGridCursorCol() == aCol
767 &&
grid->IsCellEditControlShown() )
834 return _(
"Horizontal" );
836 return _(
"Vertical" );
865 return wxT(
"bad wxWidgets!" );
883 wxFAIL_MSG( wxString::Format( wxT(
"column %d doesn't hold a bool value" ), aCol ) );
894 wxString value = aValue;
897 value.Trim(
true ).Trim(
false );
903 if(
m_eval->Process( value ) )
955 if( value ==
_(
"Left" ) )
957 else if( value ==
_(
"Center" ) )
959 else if( value ==
_(
"Right" ) )
977 if( value ==
_(
"Top" ) )
979 else if( value ==
_(
"Center" ) )
981 else if( value ==
_(
"Bottom" ) )
1008 if( value ==
_(
"Horizontal" ) )
1010 else if( value ==
_(
"Vertical" ) )
1013 wxFAIL_MSG( wxT(
"unknown orientation: " ) + value );
1022 pos.
x =
m_frame->ValueFromString( value );
1024 pos.
y =
m_frame->ValueFromString( value );
1052 wxFAIL_MSG( wxString::Format( wxT(
"column %d doesn't hold a string value" ), aCol ) );
1058 GetView()->Refresh();
1094 wxFAIL_MSG( wxString::Format( wxT(
"column %d doesn't hold a bool value" ), aCol ) );
1113 if( aValue == wxS(
"1" ) )
1117 else if( aValue == wxS(
"0" ) )
1123 wxFAIL_MSG( wxString::Format(
"string '%s' can't be converted to boolean correctly and "
1124 "will be perceived as FALSE", aValue ) );
1134 if( field.
GetId() == aFieldId )
1148 if( field.
GetId() == aFieldId )
1163 if( fieldIndex < 0 || fieldIndex >=
static_cast<int>(
m_inheritance.size() ) )
1188 back().SetParent(
m_part );
1196 wxCHECK( aFieldIndex < size() && aFieldIndex <
m_inheritance.size(), );
1222 if(
m_inheritance.size() >
static_cast<size_t>( fieldIndex ) )
1237 std::vector<SCH_FIELD>::erase( begin() + fieldIndex );
1246 wxCHECK( fieldIndexA >= 0 && fieldIndexB >= 0, );
1247 wxCHECK( fieldIndexA <
static_cast<int>(
m_inheritance.size() )
1251 std::swap( at( fieldIndexA ), at( fieldIndexB ) );
1262 inheritance.m_parentField.SetParent(
nullptr );
1279 menu.AppendSeparator();
1286 menu.AppendSeparator();
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)
virtual VECTOR2I GetTextSize() const
void SetTextColor(const COLOR4D &aColor)
COLOR4D GetTextColor() const
virtual VECTOR2I GetTextPos() const
virtual void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true)
virtual bool IsVisible() const
virtual void SetTextPos(const VECTOR2I &aPoint)
virtual int GetTextHeight() const
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)
virtual EDA_ANGLE GetTextAngle() const
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
bool IsInherited(size_t aRow) const
const wxString & InheritedFrom(size_t aRow) const
SCH_FIELD * GetField(FIELD_T aFieldId)
wxString StringFromBool(bool aValue) const
bool GetValueAsBool(int aRow, int aCol) override
void SetFieldInherited(size_t aFieldIndex, const SCH_FIELD &aParent, const wxString &aSource)
Record the ancestor field that aFieldIndex resolves against.
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
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
std::vector< INHERITANCE > m_inheritance
int getVisibleRowCount() const
const SCH_FIELD & ParentField(size_t aRow) const
wxGridCellAttr * m_footprintAttr
wxGridCellAttr * m_boolAttr
int GetFieldRow(FIELD_T aFieldId)
bool BoolFromString(const wxString &aValue) const
wxGridCellAttr * m_fontAttr
wxGridCellAttr * m_urlAttr
wxGridCellAttr * m_valueAttr
wxGridCellAttr * m_hAlignAttr
wxGridCellAttr * m_orientationAttr
void SetValue(int aRow, int aCol, const wxString &aValue) override
wxGridCellAttr * m_vAlignAttr
bool privateFieldsAreHidden() const
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
FIELDS_GRID_TABLE(DIALOG_SHIM *aDialog, SCH_BASE_FRAME *aFrame, WX_GRID *aGrid, LIB_SYMBOL *aSymbol, std::vector< EMBEDDED_FILES * > &aFilesStack)
int getFieldIndex(int aRow) const
std::vector< EMBEDDED_FILES * > & m_filesStack
void SwapRows(size_t a, size_t b)
void AddInheritedField(const SCH_FIELD &aParent, const wxString &aSource)
Append a row for an ancestor field the symbol does not define.
void onUnitsChanged(wxCommandEvent &aEvent)
std::unique_ptr< NUMERIC_EVALUATOR > m_eval
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.
Define a library symbol object.
wxArrayString GetFPFilters() const
std::vector< SCH_PIN * > GetGraphicalPins(int aUnit=0, int aBodyStyle=0) const override
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
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 HasHypertext() const override
Indicates that the item has at least one hypertext action.
bool IsHorizJustifyFlipped() const
Return whether the field will be rendered with the horizontal justification inverted due to rotation ...
bool IsVertJustifyFlipped() const
virtual const wxString & GetText() const override
Return the string associated with the text object.
void SetCanAutoplace(bool aCanPlace)
wxString GetUntranslatedName() const
Get the untranslated field name for storage, variable look-up, etc.
GR_TEXT_H_ALIGN_T GetEffectiveHorizJustify() const
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
void SetPosition(const VECTOR2I &aPosition) override
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)
static const wxString GetDefaultFieldName(const wxString &aName, bool aUseDefaultName)
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
std::vector< SCH_FIELD > & GetFields()
Return a reference to the vector holding the sheet's fields.
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this sheet.
VECTOR2I GetPosition() const override
Add cut/copy/paste, dark theme, autocomplete and brace highlighting to a wxStyleTextCtrl instance.
Look for files in a number of paths.
wxGridCellAttr * enhanceAttr(wxGridCellAttr *aInputAttr, int aRow, int aCol, wxGridCellAttr::wxAttrKind aKind)
void SetupColumnAutosizer(int aFlexibleCol)
Set autosize behaviour using wxFormBuilder column widths as minimums, with a single specified growabl...
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
std::vector< SCH_FIELD > GetSheetFieldsForEditing(const SCH_SHEET &aSheet)
wxString BuildFootprintChooserSymbolNetlist(const LIB_SYMBOL *aSymbol)
@ FDC_SYMBOL_EDITOR_COUNT
wxString BuildFootprintChooserSymbolNetlist(const LIB_SYMBOL *aSymbol)
FONTCONFIG * Fontconfig()
bool SelectFootprintFromChooser(DIALOG_SHIM *aDialog, wxString &aFootprint, const wxString &aSymbolNetlist)
@ 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.
const SCH_FIELD * FindField(const std::vector< SCH_FIELD > &aFields, FIELD_T aFieldId)
Definitions of control validators for schematic dialogs.
wxString UnescapeString(const wxString &aSource)
wxString ConvertPathToFileUri(const wxString &aPath, const PROJECT *aProject)
Convert a file path to a file:// URI.
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
bool m_derived
Row shows the ancestor's value instead of owning one.
Hold a name of a symbol's field, field value, and default visibility.
wxString GetDefaultFieldName(FIELD_T aFieldId, TRANSLATION aTranslation)
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".
@ SHEET_REF_SUFFIX
Optional sheet field appended to the references of the sheet's symbols.
@ 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.