45#include <wx/settings.h>
58#define DEFAULT_FONT_NAME _( "Default Font" )
120 m_part( aSymbol->GetLibSymbolRef().get() ),
121 m_symbolNetlist(
netList( aSymbol, aFrame->GetCurrentSheet() ) ),
162 m_mandatoryFieldCount( aLabel->GetMandatoryFieldCount() ),
183 m_readOnlyAttr =
new wxGridCellAttr;
184 m_readOnlyAttr->SetReadOnly(
true );
186 m_fieldNameAttr =
new wxGridCellAttr;
189 m_fieldNameAttr->SetEditor( nameEditor );
191 m_referenceAttr =
new wxGridCellAttr;
194 m_referenceAttr->SetEditor( referenceEditor );
196 m_valueAttr =
new wxGridCellAttr;
199 m_valueAttr->SetEditor( valueEditor );
201 m_footprintAttr =
new wxGridCellAttr;
203 fpIdEditor->SetValidator( m_libIdValidator );
204 m_footprintAttr->SetEditor( fpIdEditor );
206 m_urlAttr =
new wxGridCellAttr;
208 m_frame->Prj().SchSearchS() );
209 urlEditor->SetValidator( m_urlValidator );
210 m_urlAttr->SetEditor( urlEditor );
212 m_nonUrlAttr =
new wxGridCellAttr;
215 m_nonUrlAttr->SetEditor( nonUrlEditor );
217 m_curdir = m_frame->Prj().GetProjectPath();
218 m_filepathAttr =
new wxGridCellAttr;
221 wxString wildCard(
_(
"Schematic Files" ) );
222 std::vector<std::string> exts;
227 filepathEditor->SetValidator( m_filepathValidator );
228 m_filepathAttr->SetEditor( filepathEditor );
230 m_boolAttr =
new wxGridCellAttr;
231 m_boolAttr->SetRenderer(
new wxGridCellBoolRenderer() );
232 m_boolAttr->SetEditor(
new wxGridCellBoolEditor() );
233 m_boolAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
235 wxArrayString vAlignNames;
236 vAlignNames.Add(
_(
"Top" ) );
237 vAlignNames.Add(
_(
"Center" ) );
238 vAlignNames.Add(
_(
"Bottom" ) );
239 m_vAlignAttr =
new wxGridCellAttr;
240 m_vAlignAttr->SetEditor(
new wxGridCellChoiceEditor( vAlignNames ) );
241 m_vAlignAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_BOTTOM );
243 wxArrayString hAlignNames;
244 hAlignNames.Add(
_(
"Left" ) );
245 hAlignNames.Add(
_(
"Center" ) );
246 hAlignNames.Add(
_(
"Right" ) );
247 m_hAlignAttr =
new wxGridCellAttr;
248 m_hAlignAttr->SetEditor(
new wxGridCellChoiceEditor( hAlignNames ) );
249 m_hAlignAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_BOTTOM );
251 wxArrayString orientationNames;
252 orientationNames.Add(
_(
"Horizontal" ) );
253 orientationNames.Add(
_(
"Vertical" ) );
254 m_orientationAttr =
new wxGridCellAttr;
255 m_orientationAttr->SetEditor(
new wxGridCellChoiceEditor( orientationNames ) );
256 m_orientationAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_BOTTOM );
259 wxArrayString existingNetclasses;
265 const std::shared_ptr<NET_SETTINGS>& settings = projectFile.
NetSettings();
267 existingNetclasses.push_back( settings->m_DefaultNetClass->GetName() );
269 for(
const auto& [
name, netclass ] : settings->m_NetClasses )
270 existingNetclasses.push_back(
name );
273 m_netclassAttr =
new wxGridCellAttr;
277 std::vector<std::string> fontNames;
278 Fontconfig()->ListFonts( fontNames, std::string(
Pgm().GetLanguageTag().utf8_str() ) );
280 for(
const std::string&
name : fontNames )
287 m_fontAttr =
new wxGridCellAttr;
290 m_colorAttr =
new wxGridCellAttr;
294 m_eval = std::make_unique<NUMERIC_EVALUATOR>( m_frame->GetUserUnits() );
303 m_readOnlyAttr->DecRef();
304 m_fieldNameAttr->DecRef();
305 m_boolAttr->DecRef();
306 m_referenceAttr->DecRef();
307 m_valueAttr->DecRef();
308 m_footprintAttr->DecRef();
310 m_nonUrlAttr->DecRef();
311 m_filepathAttr->DecRef();
312 m_vAlignAttr->DecRef();
313 m_hAlignAttr->DecRef();
314 m_orientationAttr->DecRef();
315 m_netclassAttr->DecRef();
316 m_fontAttr->DecRef();
317 m_colorAttr->DecRef();
327 GetView()->ForceRefresh();
353 default: wxFAIL;
return wxEmptyString;
373 return aTypeName == wxGRID_VALUE_STRING;
380 return aTypeName == wxGRID_VALUE_BOOL;
392 return CanGetValueAs( aRow, aCol, aTypeName );
404 if( aRow < m_mandatoryFieldCount )
406 tmp = m_fieldNameAttr->Clone();
407 tmp->SetReadOnly(
true );
412 m_fieldNameAttr->IncRef();
413 return m_fieldNameAttr;
419 m_referenceAttr->IncRef();
420 return m_referenceAttr;
424 m_valueAttr->IncRef();
429 m_footprintAttr->IncRef();
430 return m_footprintAttr;
439 m_referenceAttr->IncRef();
440 return m_referenceAttr;
444 m_filepathAttr->IncRef();
445 return m_filepathAttr;
448 && this->at( (
size_t) aRow ).GetCanonicalName() == wxT(
"Netclass" ) )
450 m_netclassAttr->IncRef();
451 return m_netclassAttr;
455 wxString fn = GetValue( aRow,
FDC_NAME );
462 if( templateFn && templateFn->
m_URL )
469 m_nonUrlAttr->IncRef();
480 m_hAlignAttr->IncRef();
484 m_vAlignAttr->IncRef();
488 m_orientationAttr->IncRef();
489 return m_orientationAttr;
496 m_boolAttr->IncRef();
500 m_fontAttr->IncRef();
504 m_colorAttr->IncRef();
517 wxCHECK( aRow < GetNumberRows(), wxEmptyString );
519 wxGrid*
grid = GetView();
520 const T& field = this->at( (
size_t) aRow );
522 if(
grid->GetGridCursorRow() == aRow &&
grid->GetGridCursorCol() == aCol
523 &&
grid->IsCellEditControlShown() )
525 auto it = m_evalOriginal.find( { aRow, aCol } );
527 if( it != m_evalOriginal.end() )
538 if( aRow < m_mandatoryFieldCount )
541 return field.GetName(
false );
545 if( aRow < m_mandatoryFieldCount )
548 return field.GetName(
false );
556 wxFAIL_MSG( wxS(
"Unhandled field owner type." ) );
557 return field.GetName(
false );
564 return StringFromBool( field.IsVisible() );
567 return StringFromBool( field.IsNameShown() );
570 switch ( field.GetHorizJustify() )
580 switch ( field.GetVertJustify() )
590 return StringFromBool( field.IsItalic() );
593 return StringFromBool( field.IsBold() );
596 return m_frame->StringFromValue( field.GetTextHeight(),
true );
599 if( field.GetTextAngle().IsHorizontal() )
600 return _(
"Horizontal" );
602 return _(
"Vertical" );
605 return m_frame->StringFromValue( field.GetTextPos().x,
true );
608 return m_frame->StringFromValue( field.GetTextPos().y,
true );
611 if( field.GetFont() )
612 return field.GetFont()->GetName();
617 return field.GetTextColor().ToCSSString();
620 return StringFromBool( field.CanAutoplace() );
628 return wxT(
"bad wxWidgets!" );
635 wxCHECK( aRow < GetNumberRows(),
false );
636 const T& field = this->at( (
size_t) aRow );
640 case FDC_SHOWN:
return field.IsVisible();
643 case FDC_BOLD:
return field.IsBold();
646 wxFAIL_MSG( wxString::Format( wxT(
"column %d doesn't hold a bool value" ), aCol ) );
655 wxCHECK( aRow < GetNumberRows(), );
656 T& field = this->at( (
size_t) aRow );
658 wxString value = aValue;
665 m_eval->SetDefaultUnits( m_frame->GetUserUnits() );
667 if( m_eval->Process( value ) )
669 m_evalOriginal[ { aRow, aCol } ] = value;
670 value = m_eval->Result();
682 field.SetName( value );
696 field.SetText( value );
701 field.SetVisible( BoolFromString( value ) );
705 field.SetNameShown( BoolFromString( value ) );
709 if( value ==
_(
"Left" ) )
711 else if( value ==
_(
"Center" ) )
713 else if( value ==
_(
"Right" ) )
716 wxFAIL_MSG( wxT(
"unknown horizontal alignment: " ) + value );
721 if( value ==
_(
"Top" ) )
723 else if( value ==
_(
"Center" ) )
725 else if( value ==
_(
"Bottom" ) )
728 wxFAIL_MSG( wxT(
"unknown vertical alignment: " ) + value);
733 field.SetItalic( BoolFromString( value ) );
737 field.SetBold( BoolFromString( value ) );
741 field.SetTextSize(
VECTOR2I( m_frame->ValueFromString( value ),
742 m_frame->ValueFromString( value ) ) );
746 if( value ==
_(
"Horizontal" ) )
748 else if( value ==
_(
"Vertical" ) )
751 wxFAIL_MSG( wxT(
"unknown orientation: " ) + value );
757 pos = field.GetTextPos();
760 pos.
x = m_frame->ValueFromString( value );
762 pos.
y = m_frame->ValueFromString( value );
764 field.SetTextPos( pos );
769 field.SetFont(
nullptr );
778 field.SetTextColor( wxColor( value ) );
782 field.SetCanAutoplace( BoolFromString( value ) );
786 wxFAIL_MSG( wxString::Format( wxT(
"column %d doesn't hold a string value" ), aCol ) );
790 m_dialog->OnModify();
792 GetView()->Refresh();
799 wxCHECK( aRow < GetNumberRows(), );
800 T& field = this->at( (
size_t) aRow );
805 field.SetVisible( aValue );
809 field.SetNameShown( aValue );
813 field.SetItalic( aValue );
817 field.SetBold( aValue );
821 field.SetCanAutoplace( aValue );
825 wxFAIL_MSG( wxString::Format( wxT(
"column %d doesn't hold a bool value" ), aCol ) );
829 m_dialog->OnModify();
844 _(
"Browse for footprint" ) );
845 menu.AppendSeparator();
850 _(
"Show datasheet in browser" ) );
851 menu.AppendSeparator();
896 if( aValue == wxS(
"1" ) )
900 else if( aValue == wxS(
"0" ) )
906 wxFAIL_MSG( wxString::Format(
"string '%s' can't be converted to boolean correctly and "
907 "will be perceived as FALSE", aValue ) );
Dialog helper object to sit in the inheritance tree between wxDialog and any class written by wxFormB...
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.
The backing store for a PROJECT, in JSON format.
std::shared_ptr< NET_SETTINGS > & NetSettings()
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.
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)
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
std::vector< SCH_PIN * > GetPins(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve a list of the SCH_PINs for the given sheet path.
const wxString GetFootprintFieldText(bool aResolve, const SCH_SHEET_PATH *aPath, bool aAllowExtraText) const
const wxString GetValueFieldText(bool aResolve, const SCH_SHEET_PATH *aPath, bool aAllowExtraText) const
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_HORIZONTAL
static constexpr EDA_ANGLE & ANGLE_VERTICAL
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_VIEWER_MODAL
@ FRAME_SCH_SYMBOL_EDITOR
@ GRIDTRICKS_FIRST_CLIENT_ID
wxString AddFileExtListToFilter(const std::vector< std::string > &aExts)
Build the wildcard extension file dialog wildcard filter to add to the base message dialog.
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 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
@ REFERENCE_FIELD
Field Reference of part, i.e. "IC21".
Custom text control validator definitions.
Definition of file extensions used in Kicad.