46#include <wx/settings.h>
60#define DEFAULT_FONT_NAME _( "Default Font" )
77 pins.push_back(
pin->GetNumber() +
' ' +
pin->GetShownName() );
86 if( !fpFilters.IsEmpty() )
104 std::vector<LIB_PIN*> pinList;
106 aSymbol->
GetPins( pinList, 0, 1 );
111 pins.push_back(
pin->GetNumber() +
' ' +
pin->GetShownName() );
113 if( !pins.IsEmpty() )
120 if( !fpFilters.IsEmpty() )
138 m_symbolNetlist(
netList( aSymbol ) ),
158 m_part( aSymbol->GetLibSymbolRef().get() ),
159 m_symbolNetlist(
netList( aSymbol, aFrame->GetCurrentSheet() ) ),
198 m_mandatoryFieldCount( aLabel->GetMandatoryFieldCount() ),
201 m_referenceValidator( 0 ),
202 m_valueValidator( 0 ),
205 m_filepathValidator( 0 )
218 m_readOnlyAttr =
new wxGridCellAttr;
219 m_readOnlyAttr->SetReadOnly(
true );
221 m_fieldNameAttr =
new wxGridCellAttr;
224 m_fieldNameAttr->SetEditor( nameEditor );
226 m_referenceAttr =
new wxGridCellAttr;
229 m_referenceAttr->SetEditor( referenceEditor );
231 m_valueAttr =
new wxGridCellAttr;
233 if constexpr ( std::is_same_v<T, SCH_FIELD> )
241 m_valueAttr->SetEditor( valueEditor );
247 m_valueAttr->SetEditor( valueEditor );
250 m_footprintAttr =
new wxGridCellAttr;
252 fpIdEditor->SetValidator( m_nonUrlValidator );
253 m_footprintAttr->SetEditor( fpIdEditor );
255 m_urlAttr =
new wxGridCellAttr;
257 urlEditor->SetValidator( m_urlValidator );
258 m_urlAttr->SetEditor( urlEditor );
260 m_nonUrlAttr =
new wxGridCellAttr;
263 m_nonUrlAttr->SetEditor( nonUrlEditor );
265 m_curdir = m_frame->Prj().GetProjectPath();
266 m_filepathAttr =
new wxGridCellAttr;
269 wxString wildCard(
_(
"Schematic Files" ) );
270 std::vector<std::string> exts;
275 filepathEditor->SetValidator( m_filepathValidator );
276 m_filepathAttr->SetEditor( filepathEditor );
278 m_boolAttr =
new wxGridCellAttr;
279 m_boolAttr->SetRenderer(
new wxGridCellBoolRenderer() );
280 m_boolAttr->SetEditor(
new wxGridCellBoolEditor() );
281 m_boolAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
283 wxArrayString vAlignNames;
284 vAlignNames.Add(
_(
"Top" ) );
285 vAlignNames.Add(
_(
"Center" ) );
286 vAlignNames.Add(
_(
"Bottom" ) );
287 m_vAlignAttr =
new wxGridCellAttr;
288 m_vAlignAttr->SetEditor(
new wxGridCellChoiceEditor( vAlignNames ) );
289 m_vAlignAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
291 wxArrayString hAlignNames;
292 hAlignNames.Add(
_(
"Left" ) );
293 hAlignNames.Add(
_(
"Center" ) );
294 hAlignNames.Add(
_(
"Right" ) );
295 m_hAlignAttr =
new wxGridCellAttr;
296 m_hAlignAttr->SetEditor(
new wxGridCellChoiceEditor( hAlignNames ) );
297 m_hAlignAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
299 wxArrayString orientationNames;
300 orientationNames.Add(
_(
"Horizontal" ) );
301 orientationNames.Add(
_(
"Vertical" ) );
302 m_orientationAttr =
new wxGridCellAttr;
303 m_orientationAttr->SetEditor(
new wxGridCellChoiceEditor( orientationNames ) );
304 m_orientationAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
307 wxArrayString existingNetclasses;
313 const std::shared_ptr<NET_SETTINGS>& settings = projectFile.
NetSettings();
315 existingNetclasses.push_back( settings->m_DefaultNetClass->GetName() );
317 for(
const auto& [
name, netclass ] : settings->m_NetClasses )
318 existingNetclasses.push_back(
name );
321 m_netclassAttr =
new wxGridCellAttr;
325 std::vector<std::string> fontNames;
326 Fontconfig()->ListFonts( fontNames, std::string(
Pgm().GetLanguageTag().utf8_str() ) );
328 for(
const std::string&
name : fontNames )
335 m_fontAttr =
new wxGridCellAttr;
338 m_colorAttr =
new wxGridCellAttr;
342 m_eval = std::make_unique<NUMERIC_EVALUATOR>( m_frame->GetUserUnits() );
351 m_readOnlyAttr->DecRef();
352 m_fieldNameAttr->DecRef();
353 m_boolAttr->DecRef();
354 m_referenceAttr->DecRef();
355 m_valueAttr->DecRef();
356 m_footprintAttr->DecRef();
358 m_nonUrlAttr->DecRef();
359 m_filepathAttr->DecRef();
360 m_vAlignAttr->DecRef();
361 m_hAlignAttr->DecRef();
362 m_orientationAttr->DecRef();
363 m_netclassAttr->DecRef();
364 m_fontAttr->DecRef();
365 m_colorAttr->DecRef();
375 GetView()->ForceRefresh();
401 default: wxFAIL;
return wxEmptyString;
421 return aTypeName == wxGRID_VALUE_STRING;
428 return aTypeName == wxGRID_VALUE_BOOL;
440 return CanGetValueAs( aRow, aCol, aTypeName );
452 if( aRow < m_mandatoryFieldCount )
454 tmp = m_fieldNameAttr->Clone();
455 tmp->SetReadOnly(
true );
460 m_fieldNameAttr->IncRef();
461 return m_fieldNameAttr;
467 m_referenceAttr->IncRef();
468 return m_referenceAttr;
472 m_valueAttr->IncRef();
480 if( m_part && m_part->IsPower() )
482 m_readOnlyAttr->IncRef();
483 return m_readOnlyAttr;
487 m_footprintAttr->IncRef();
488 return m_footprintAttr;
498 m_referenceAttr->IncRef();
499 return m_referenceAttr;
503 m_filepathAttr->IncRef();
504 return m_filepathAttr;
507 && this->at( (
size_t) aRow ).GetCanonicalName() == wxT(
"Netclass" ) )
509 m_netclassAttr->IncRef();
510 return m_netclassAttr;
514 wxString fn = GetValue( aRow,
FDC_NAME );
521 if( templateFn && templateFn->
m_URL )
528 m_nonUrlAttr->IncRef();
539 m_hAlignAttr->IncRef();
543 m_vAlignAttr->IncRef();
547 m_orientationAttr->IncRef();
548 return m_orientationAttr;
555 m_boolAttr->IncRef();
559 m_fontAttr->IncRef();
563 m_colorAttr->IncRef();
576 wxCHECK( aRow < GetNumberRows(), wxEmptyString );
578 wxGrid*
grid = GetView();
579 const T& field = this->at( (
size_t) aRow );
581 if(
grid->GetGridCursorRow() == aRow &&
grid->GetGridCursorCol() == aCol
582 &&
grid->IsCellEditControlShown() )
584 auto it = m_evalOriginal.find( { aRow, aCol } );
586 if( it != m_evalOriginal.end() )
597 if( aRow < m_mandatoryFieldCount )
600 return field.GetName(
false );
604 if( aRow < m_mandatoryFieldCount )
607 return field.GetName(
false );
615 wxFAIL_MSG( wxS(
"Unhandled field owner type." ) );
616 return field.GetName(
false );
623 return StringFromBool( field.IsVisible() );
626 return StringFromBool( field.IsNameShown() );
629 switch ( field.GetEffectiveHorizJustify() )
640 switch ( field.GetEffectiveVertJustify() )
651 return StringFromBool( field.IsItalic() );
654 return StringFromBool( field.IsBold() );
657 return m_frame->StringFromValue( field.GetTextHeight(),
true );
660 if( field.GetTextAngle().IsHorizontal() )
661 return _(
"Horizontal" );
663 return _(
"Vertical" );
666 return m_frame->StringFromValue( field.GetTextPos().x,
true );
669 return m_frame->StringFromValue( field.GetTextPos().y,
true );
672 if( field.GetFont() )
673 return field.GetFont()->GetName();
678 return field.GetTextColor().ToCSSString();
681 return StringFromBool( field.CanAutoplace() );
689 return wxT(
"bad wxWidgets!" );
696 wxCHECK( aRow < GetNumberRows(),
false );
697 const T& field = this->at( (
size_t) aRow );
701 case FDC_SHOWN:
return field.IsVisible();
704 case FDC_BOLD:
return field.IsBold();
707 wxFAIL_MSG( wxString::Format( wxT(
"column %d doesn't hold a bool value" ), aCol ) );
716 wxCHECK( aRow < GetNumberRows(), );
717 T& field = this->at( (
size_t) aRow );
719 wxString value = aValue;
726 m_eval->SetDefaultUnits( m_frame->GetUserUnits() );
728 if( m_eval->Process( value ) )
730 m_evalOriginal[ { aRow, aCol } ] = value;
731 value = m_eval->Result();
743 field.SetName( value );
762 field.SetVisible( BoolFromString( value ) );
766 field.SetNameShown( BoolFromString( value ) );
773 if( value ==
_(
"Left" ) )
775 else if( value ==
_(
"Center" ) )
777 else if( value ==
_(
"Right" ) )
780 wxFAIL_MSG( wxT(
"unknown horizontal alignment: " ) + value );
785 field.SetHorizJustify( horizontalJustification );
787 if( field.IsHorizJustifyFlipped() )
797 if( value ==
_(
"Top" ) )
799 else if( value ==
_(
"Center" ) )
801 else if( value ==
_(
"Bottom" ) )
804 wxFAIL_MSG( wxT(
"unknown vertical alignment: " ) + value);
809 field.SetVertJustify( verticalJustification );
811 if( field.IsVertJustifyFlipped() )
818 field.SetItalic( BoolFromString( value ) );
822 field.SetBold( BoolFromString( value ) );
826 field.SetTextSize(
VECTOR2I( m_frame->ValueFromString( value ),
827 m_frame->ValueFromString( value ) ) );
831 if( value ==
_(
"Horizontal" ) )
833 else if( value ==
_(
"Vertical" ) )
836 wxFAIL_MSG( wxT(
"unknown orientation: " ) + value );
842 pos = field.GetTextPos();
845 pos.
x = m_frame->ValueFromString( value );
847 pos.
y = m_frame->ValueFromString( value );
849 field.SetTextPos( pos );
854 field.SetFont(
nullptr );
857 field.IsItalic() ) );
864 field.SetTextColor( wxColor( value ) );
868 field.SetCanAutoplace( BoolFromString( value ) );
872 wxFAIL_MSG( wxString::Format( wxT(
"column %d doesn't hold a string value" ), aCol ) );
876 m_dialog->OnModify();
878 GetView()->Refresh();
885 wxCHECK( aRow < GetNumberRows(), );
886 T& field = this->at( (
size_t) aRow );
891 field.SetVisible( aValue );
895 field.SetNameShown( aValue );
899 field.SetItalic( aValue );
903 field.SetBold( aValue );
907 field.SetCanAutoplace( aValue );
911 wxFAIL_MSG( wxString::Format( wxT(
"column %d doesn't hold a bool value" ), aCol ) );
915 m_dialog->OnModify();
931 _(
"Browse for footprint" ) );
932 menu.AppendSeparator();
938 _(
"Show datasheet in browser" ) );
939 menu.AppendSeparator();
985 if( aValue == wxS(
"1" ) )
989 else if( aValue == wxS(
"0" ) )
995 wxFAIL_MSG( wxString::Format(
"string '%s' can't be converted to boolean correctly and "
996 "will be perceived as FALSE", aValue ) );
Dialog helper object to sit in the inheritance tree between wxDialog and any class written by wxFormB...
static GR_TEXT_H_ALIGN_T MapHorizJustify(int aHorizJustify)
static GR_TEXT_V_ALIGN_T MapVertJustify(int aVertJustify)
wxString GetValue(int aRow, int aCol) override
bool CanSetValueAs(int aRow, int aCol, const wxString &aTypeName) override
bool GetValueAsBool(int aRow, int aCol) override
void onUnitsChanged(wxCommandEvent &aEvent)
wxString GetColLabelValue(int aCol) override
void SetValue(int aRow, int aCol, const wxString &aValue) override
bool CanGetValueAs(int aRow, int aCol, const wxString &aTypeName) override
FIELDS_GRID_TABLE(DIALOG_SHIM *aDialog, SCH_BASE_FRAME *aFrame, WX_GRID *aGrid, LIB_SYMBOL *aSymbol)
wxGridCellAttr * GetAttr(int row, int col, wxGridCellAttr::wxAttrKind kind) override
wxString StringFromBool(bool aValue) const
void SetValueAsBool(int aRow, int aCol, bool aValue) override
bool BoolFromString(wxString aValue) const
void initGrid(WX_GRID *aGrid)
virtual void showPopupMenu(wxMenu &menu, wxGridEvent &aEvent) override
virtual 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)
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
virtual bool ShowModal(wxString *aResult=nullptr, wxWindow *aResultantFocusWindow=nullptr)
Show this wxFrame as if it were a modal dialog, with all other instantiated wxFrames disabled until t...
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Define a library symbol object.
void GetPins(LIB_PINS &aList, int aUnit=0, int aBodyStyle=0) const
Return a list of pin object pointers from the draw item list.
wxArrayString GetFPFilters() const
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 settings were stored in SCH_BASE_FRAME previously.
TEMPLATES m_TemplateFieldNames
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
Schematic editor (Eeschema) main window.
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
void OnScintillaCharAdded(SCINTILLA_TRICKS *aScintillaTricks, wxStyledTextEvent &aEvent) const
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.
static const wxString GetDefaultFieldName(int aFieldNdx, bool aTranslated=true)
std::vector< SCH_PIN * > GetPins(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve a list of the SCH_PINs for the given sheet path.
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
Add cut/copy/paste, dark theme, autocomplete and brace highlighting to a wxStyleTextCtrl instance.
const TEMPLATE_FIELDNAME * GetFieldName(const wxString &aName)
Search for aName in the template field name list.
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)
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)
FONTCONFIG * Fontconfig()
@ FRAME_FOOTPRINT_CHOOSER
@ GRIDTRICKS_FIRST_CLIENT_ID
static const std::string KiCadSchematicFileExtension
@ SHEET_MANDATORY_FIELDS
The first 2 are mandatory, and must be instantiated in SCH_SHEET.
Definitions of control validators for schematic dialogs.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
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.
static const wxString GetDefaultFieldName(int aFieldNdx, bool aTranslateForHI=false)
Return a default symbol field name for field aFieldNdx for all components.
Definition for symbol library class.
@ DATASHEET_FIELD
name of datasheet
@ FOOTPRINT_FIELD
Field Name Module PCB, i.e. "16DIP300".
@ VALUE_FIELD
Field Value of part, i.e. "3.3K".
@ MANDATORY_FIELDS
The first 5 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
@ REFERENCE_FIELD
Field Reference of part, i.e. "IC21".
@ GR_TEXT_H_ALIGN_INDETERMINATE
@ 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.
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.