KiCad PCB EDA Suite
Loading...
Searching...
No Matches
fields_grid_table.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#include <font/font.h>
21#include <embedded_files.h>
22#include <kiway.h>
23#include <dialog_shim.h>
24#include <fields_grid_table.h>
25#include <sch_base_frame.h>
26#include <sch_field.h>
27#include <sch_label.h>
28#include <sch_validators.h>
29#include <validators.h>
30#include <sch_edit_frame.h>
31#include <schematic.h>
32#include <template_fieldnames.h>
37#include "eda_doc.h"
39#include "font/fontconfig.h"
42#include <wx/settings.h>
43#include <string_utils.h>
45#include <pgm_base.h>
46#include <project_sch.h>
47
48
49enum
50{
53};
54
55
56#define DEFAULT_FONT_NAME _( "Default Font" )
57
58
60{
61 /*
62 * Symbol netlist format:
63 * pinNumber pinName <tab> pinNumber pinName...
64 * fpFilter fpFilter...
65 */
66 wxString netlist;
67 wxArrayString pins;
68
69 if( aSymbol )
70 {
71 for( const SCH_PIN* pin : aSymbol->GetGraphicalPins( 0 /* all units */, 1 /* single bodyStyle */ ) )
72 {
73 bool valid = false;
74 std::vector<wxString> expanded = pin->GetStackedPinNumbers( &valid );
75
76 if( valid && !expanded.empty() )
77 {
78 for( const wxString& number : expanded )
79 pins.push_back( number + ' ' + pin->GetShownName() );
80 }
81 else
82 {
83 pins.push_back( pin->GetNumber() + ' ' + pin->GetShownName() );
84 }
85 }
86 }
87
88 if( !pins.IsEmpty() )
89 {
90 wxString pinList = wxJoin( pins, '\t' );
91 wxLogTrace( "FOOTPRINT_CHOOSER", wxS( "Chooser payload pins: %s" ), pinList );
92 netlist << EscapeString( pinList, CTX_LINE );
93 }
94
95 netlist << wxS( "\r" );
96
97 if( aSymbol )
98 {
99 wxArrayString fpFilters = aSymbol->GetFPFilters();
100
101 if( !fpFilters.IsEmpty() )
102 netlist << EscapeString( wxJoin( fpFilters, ' ' ), CTX_LINE );
103 }
104
105 netlist << wxS( "\r" );
106
107 return netlist;
108}
109
110
111wxString BuildFootprintChooserSymbolNetlist( const std::vector<LIB_SYMBOL*>& aSymbols )
112{
113 if( aSymbols.empty() || !aSymbols.front() )
114 return wxEmptyString;
115
116 wxString symbolNetlist = BuildFootprintChooserSymbolNetlist( aSymbols.front() );
117
118 for( size_t i = 1; i < aSymbols.size(); ++i )
119 {
120 // A grouped-row edit applies to every symbol in the row. Only provide chooser filters
121 // when they describe all of those symbols accurately.
122 if( !aSymbols[i] || BuildFootprintChooserSymbolNetlist( aSymbols[i] ) != symbolNetlist )
123 return wxEmptyString;
124 }
125
126 return symbolNetlist;
127}
128
129
131 LIB_SYMBOL* aSymbol, std::vector<EMBEDDED_FILES*> aFilesStack ) :
132 m_frame( aFrame ),
133 m_dialog( aDialog ),
135 m_part( aSymbol ),
136 m_filesStack( aFilesStack ),
144{
145 initGrid( aGrid );
146}
147
148
150 SCH_SYMBOL* aSymbol, std::vector<EMBEDDED_FILES*> aFilesStack ) :
151 m_frame( aFrame ),
152 m_dialog( aDialog ),
154 m_part( nullptr ),
155 m_filesStack( aFilesStack ),
156 m_symbolNetlist( BuildFootprintChooserSymbolNetlist( aSymbol->GetLibSymbolRef().get() ) ),
163{
164 // GetLibSymbolRef() hands back a raw pointer into a unique_ptr owned by the schematic symbol.
165 // This dialog is quasi-modal, so the still-live schematic can free that part through
166 // SetLibSymbol() (library update, ERC, undo) while the grid is open, after which GetAttr() would
167 // dereference freed memory. Keep a private copy alive for the grid's lifetime instead.
168 if( LIB_SYMBOL* libSymbol = aSymbol->GetLibSymbolRef().get() )
169 {
170 m_ownedPart = std::make_unique<LIB_SYMBOL>( *libSymbol );
171 m_part = m_ownedPart.get();
172 }
173
174 m_filesStack.push_back( aSymbol->Schematic() );
175
176 if( m_part )
177 m_filesStack.push_back( m_part );
178
179 initGrid( aGrid );
180}
181
182
184 SCH_SHEET* aSheet ) :
185 m_frame( aFrame ),
186 m_dialog( aDialog ),
188 m_part( nullptr ),
195{
196 m_filesStack.push_back( aSheet->Schematic() );
197
198 initGrid( aGrid );
199}
200
201
203 SCH_LABEL_BASE* aLabel ) :
204 m_frame( aFrame ),
205 m_dialog( aDialog ),
207 m_part( nullptr ),
214{
215 m_filesStack.push_back( aLabel->Schematic() );
216
217 initGrid( aGrid );
218}
219
220
222{
223 int mandatoryRows = 0;
224
225 for( const SCH_FIELD& field : *this )
226 {
227 if( field.IsMandatory() && ( !privateFieldsAreHidden() || !field.IsPrivate() ) )
228 mandatoryRows++;
229 }
230
231 return mandatoryRows;
232}
233
234
236{
237 std::vector<SCH_FIELD>::push_back( aField );
238
239 m_inheritance.resize( size() );
240}
241
242
244{
245 // Build the various grid cell attributes.
246 // NOTE: validators and cellAttrs are member variables to get the destruction order
247 // right. wxGrid is VERY cranky about this.
248
249 m_readOnlyAttr = new wxGridCellAttr;
250 m_readOnlyAttr->SetReadOnly( true );
251
252 m_fieldNameAttr = new wxGridCellAttr;
254 nameEditor->SetValidator( m_fieldNameValidator );
255 m_fieldNameAttr->SetEditor( nameEditor );
256
257 m_referenceAttr = new wxGridCellAttr;
258 GRID_CELL_TEXT_EDITOR* referenceEditor = new GRID_CELL_TEXT_EDITOR();
259 referenceEditor->SetValidator( m_referenceValidator );
260 m_referenceAttr->SetEditor( referenceEditor );
261
262 m_valueAttr = new wxGridCellAttr;
263
265 {
266 GRID_CELL_TEXT_EDITOR* valueEditor = new GRID_CELL_TEXT_EDITOR();
267 valueEditor->SetValidator( m_valueValidator );
268 m_valueAttr->SetEditor( valueEditor );
269 }
270 else
271 {
272 GRID_CELL_STC_EDITOR* valueEditor = new GRID_CELL_STC_EDITOR( true, true,
273 [this]( wxStyledTextEvent& aEvent, SCINTILLA_TRICKS* aScintillaTricks )
274 {
275 SCH_FIELD* valueField = this->GetField( FIELD_T::VALUE );
276 valueField->OnScintillaCharAdded( aScintillaTricks, aEvent );
277 } );
278
279 m_valueAttr->SetEditor( valueEditor );
280 }
281
282 m_footprintAttr = new wxGridCellAttr;
284 m_dialog,
285 [this]( int )
286 {
287 return m_symbolNetlist;
288 } );
289 fpIdEditor->SetValidator( m_nonUrlValidator );
290 m_footprintAttr->SetEditor( fpIdEditor );
291
292 m_urlAttr = new wxGridCellAttr;
293 SEARCH_STACK* prjSearchStack = PROJECT_SCH::SchSearchS( &m_frame->Prj() );
294 GRID_CELL_URL_EDITOR* urlEditor = new GRID_CELL_URL_EDITOR( m_dialog, prjSearchStack, m_filesStack );
295 urlEditor->SetValidator( m_urlValidator );
296 m_urlAttr->SetEditor( urlEditor );
297
298 m_nonUrlAttr = new wxGridCellAttr;
299 GRID_CELL_TEXT_EDITOR* nonUrlEditor = new GRID_CELL_TEXT_EDITOR();
300 nonUrlEditor->SetValidator( m_nonUrlValidator );
301 m_nonUrlAttr->SetEditor( nonUrlEditor );
302
303 m_curdir = m_frame->Prj().GetProjectPath();
304 m_filepathAttr = new wxGridCellAttr;
305
306 // Create a wild card using wxFileDialog syntax.
307 wxString wildCard( _( "Schematic Files" ) );
308 std::vector<std::string> exts;
309 exts.push_back( FILEEXT::KiCadSchematicFileExtension );
310 wildCard += AddFileExtListToFilter( exts );
311
312 auto filepathEditor = new GRID_CELL_PATH_EDITOR( m_dialog, aGrid, &m_curdir, wildCard );
313 filepathEditor->SetValidator( m_filepathValidator );
314 m_filepathAttr->SetEditor( filepathEditor );
315
316 m_boolAttr = new wxGridCellAttr;
317 m_boolAttr->SetRenderer( new wxGridCellBoolRenderer() );
318 m_boolAttr->SetEditor( new wxGridCellBoolEditor() );
319 m_boolAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
320
321 wxArrayString vAlignNames;
322 vAlignNames.Add( _( "Top" ) );
323 vAlignNames.Add( _( "Center" ) );
324 vAlignNames.Add( _( "Bottom" ) );
325 m_vAlignAttr = new wxGridCellAttr;
326 m_vAlignAttr->SetEditor( new wxGridCellChoiceEditor( vAlignNames ) );
327 m_vAlignAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
328
329 wxArrayString hAlignNames;
330 hAlignNames.Add( _( "Left" ) );
331 hAlignNames.Add(_( "Center" ) );
332 hAlignNames.Add(_( "Right" ) );
333 m_hAlignAttr = new wxGridCellAttr;
334 m_hAlignAttr->SetEditor( new wxGridCellChoiceEditor( hAlignNames ) );
335 m_hAlignAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
336
337 wxArrayString orientationNames;
338 orientationNames.Add( _( "Horizontal" ) );
339 orientationNames.Add(_( "Vertical" ) );
340 m_orientationAttr = new wxGridCellAttr;
341 m_orientationAttr->SetEditor( new wxGridCellChoiceEditor( orientationNames ) );
342 m_orientationAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
343
344 SCH_EDIT_FRAME* editFrame = dynamic_cast<SCH_EDIT_FRAME*>( m_frame );
345 wxArrayString existingNetclasses;
346
347 wxArrayString fonts;
348 std::vector<std::string> fontNames;
349
350 if( editFrame )
351 {
352 // Load the combobox with existing existingNetclassNames
353 PROJECT_FILE& projectFile = editFrame->Prj().GetProjectFile();
354 const std::shared_ptr<NET_SETTINGS>& settings = projectFile.NetSettings();
355
356 existingNetclasses.push_back( settings->GetDefaultNetclass()->GetName() );
357
358 for( const auto& [name, netclass] : settings->GetNetclasses() )
359 existingNetclasses.push_back( name );
360
361 // We don't need to re-cache the embedded fonts when looking at symbols in the schematic
362 // editor because the fonts are all available in the schematic.
363 const std::vector<wxString>* fontFiles = nullptr;
364
365 if( m_frame->GetScreen() && m_frame->GetScreen()->Schematic() )
366 fontFiles = m_frame->GetScreen()->Schematic()->GetEmbeddedFiles()->GetFontFiles();
367
368 Fontconfig()->ListFonts( fontNames, std::string( Pgm().GetLanguageTag().utf8_str() ),
369 fontFiles, false );
370 }
371 else
372 {
373 const std::vector<wxString>* fontFiles = m_part->GetEmbeddedFiles()->UpdateFontFiles();
374
375 // If there are font files embedded, we want to re-cache our fonts for each symbol that
376 // we are looking at in the symbol editor.
377 Fontconfig()->ListFonts( fontNames, std::string( Pgm().GetLanguageTag().utf8_str() ),
378 fontFiles, !fontFiles->empty() );
379 }
380
381 m_netclassAttr = new wxGridCellAttr;
382 m_netclassAttr->SetEditor( new GRID_CELL_COMBOBOX( existingNetclasses ) );
383
384 for( const std::string& name : fontNames )
385 fonts.Add( wxString( name ) );
386
387 fonts.Sort();
388 fonts.Insert( KICAD_FONT_NAME, 0 );
389 fonts.Insert( DEFAULT_FONT_NAME, 0 );
390
391 m_fontAttr = new wxGridCellAttr;
392 m_fontAttr->SetEditor( new GRID_CELL_COMBOBOX( fonts ) );
393
394 m_colorAttr = new wxGridCellAttr;
395 m_colorAttr->SetRenderer( new GRID_CELL_COLOR_RENDERER( m_dialog ) );
396 m_colorAttr->SetEditor( new GRID_CELL_COLOR_SELECTOR( m_dialog, aGrid ) );
397
398 m_eval = std::make_unique<NUMERIC_EVALUATOR>( m_frame->GetUserUnits() );
399
401
402 m_frame->Bind( EDA_EVT_UNITS_CHANGED, &FIELDS_GRID_TABLE::onUnitsChanged, this );
403}
404
405
407{
408 m_readOnlyAttr->DecRef();
409 m_fieldNameAttr->DecRef();
410 m_boolAttr->DecRef();
411 m_referenceAttr->DecRef();
412 m_valueAttr->DecRef();
413 m_footprintAttr->DecRef();
414 m_urlAttr->DecRef();
415 m_nonUrlAttr->DecRef();
416 m_filepathAttr->DecRef();
417 m_vAlignAttr->DecRef();
418 m_hAlignAttr->DecRef();
419 m_orientationAttr->DecRef();
420 m_netclassAttr->DecRef();
421 m_fontAttr->DecRef();
422 m_colorAttr->DecRef();
423
424 for( INHERITANCE& inheritance : m_inheritance )
425 inheritance.m_parentField.SetParent( nullptr );
426
427 m_frame->Unbind( EDA_EVT_UNITS_CHANGED, &FIELDS_GRID_TABLE::onUnitsChanged, this );
428}
429
430
431void FIELDS_GRID_TABLE::onUnitsChanged( wxCommandEvent& aEvent )
432{
433 if( GetView() )
434 GetView()->ForceRefresh();
435
436 aEvent.Skip();
437}
438
439
441{
442 if( m_frame->GetFrameType() == FRAME_SCH
443 || m_frame->GetFrameType() == FRAME_SCH_VIEWER )
444 {
445 return FDC_SCH_EDIT_COUNT;
446 }
447 else
448 {
450 }
451}
452
453
455{
456 return m_frame->GetFrameType() == FRAME_SCH || m_frame->GetFrameType() == FRAME_SCH_VIEWER;
457}
458
459
461{
462 wxCHECK_MSG( aRow >= 0 && aRow < getVisibleRowCount(), -1, wxT( "Invalid field row" ) );
463
465 return aRow;
466
467 int visibleRow = 0;
468
469 for( int fieldIndex = 0; fieldIndex < static_cast<int>( size() ); ++fieldIndex )
470 {
471 if( at( fieldIndex ).IsPrivate() )
472 continue;
473
474 if( visibleRow == aRow )
475 return fieldIndex;
476
477 ++visibleRow;
478 }
479
480 wxFAIL_MSG( wxT( "Row index off end of visible row count" ) );
481 return -1;
482}
483
484
486{
488 {
489 int visibleRows = 0;
490
491 for( const SCH_FIELD& field : *this )
492 {
493 if( !field.IsPrivate() )
494 visibleRows++;
495 }
496
497 return visibleRows;
498 }
499
500 return (int) this->size();
501}
502
503
505{
506 return at( getFieldIndex( aRow ) );
507}
508
509
511{
512 switch( aCol )
513 {
514 case FDC_NAME: return _( "Name" );
515 case FDC_VALUE: return _( "Value" );
516 case FDC_SHOWN: return _( "Show" );
517 case FDC_SHOW_NAME: return _( "Show Name" );
518 case FDC_H_ALIGN: return _( "H Align" );
519 case FDC_V_ALIGN: return _( "V Align" );
520 case FDC_ITALIC: return _( "Italic" );
521 case FDC_BOLD: return _( "Bold" );
522 case FDC_TEXT_SIZE: return _( "Text Size" );
523 case FDC_ORIENTATION: return _( "Orientation" );
524 case FDC_POSX: return _( "X Position" );
525 case FDC_POSY: return _( "Y Position" );
526 case FDC_FONT: return _( "Font" );
527 case FDC_COLOR: return _( "Color" );
528 case FDC_ALLOW_AUTOPLACE: return _( "Allow Autoplacement" );
529 case FDC_PRIVATE: return _( "Private" );
530 default: wxFAIL; return wxEmptyString;
531 }
532}
533
534
535bool FIELDS_GRID_TABLE::CanGetValueAs( int aRow, int aCol, const wxString& aTypeName )
536{
537 switch( aCol )
538 {
539 case FDC_NAME:
540 case FDC_VALUE:
541 case FDC_H_ALIGN:
542 case FDC_V_ALIGN:
543 case FDC_TEXT_SIZE:
544 case FDC_ORIENTATION:
545 case FDC_POSX:
546 case FDC_POSY:
547 case FDC_FONT:
548 case FDC_COLOR:
549 return aTypeName == wxGRID_VALUE_STRING;
550
551 case FDC_SHOWN:
552 case FDC_SHOW_NAME:
553 case FDC_ITALIC:
554 case FDC_BOLD:
556 case FDC_PRIVATE:
557 return aTypeName == wxGRID_VALUE_BOOL;
558
559 default:
560 wxFAIL;
561 return false;
562 }
563}
564
565
566bool FIELDS_GRID_TABLE::CanSetValueAs( int aRow, int aCol, const wxString& aTypeName )
567{
568 return CanGetValueAs( aRow, aCol, aTypeName );
569}
570
571
572wxGridCellAttr* FIELDS_GRID_TABLE::GetAttr( int aRow, int aCol, wxGridCellAttr::wxAttrKind aKind )
573{
574 wxCHECK( aRow < GetNumberRows(), nullptr );
575
576 const SCH_FIELD& field = getField( aRow );
577 wxGridCellAttr* attr = nullptr;
578
579 switch( aCol )
580 {
581 case FDC_NAME:
582 if( field.IsMandatory() )
583 {
584 attr = m_fieldNameAttr->Clone();
585 attr->SetReadOnly( true );
586 }
587 else
588 {
589 m_fieldNameAttr->IncRef();
590 attr = m_fieldNameAttr;
591 }
592
593 break;
594
595 case FDC_VALUE:
596 if( field.GetId() == FIELD_T::REFERENCE )
597 {
598 m_referenceAttr->IncRef();
599 attr = m_referenceAttr;
600 }
601 else if( field.GetId() == FIELD_T::VALUE )
602 {
603 m_valueAttr->IncRef();
604 attr = m_valueAttr;
605 }
606 else if( field.GetId() == FIELD_T::FOOTPRINT )
607 {
608 // Power symbols have do not appear in the board, so don't allow
609 // a footprint (m_part can be nullptr when loading a old schematic
610 // (for instance Kicad 4) with libraries missing)
611 if( m_part && m_part->IsPower() )
612 {
613 m_readOnlyAttr->IncRef();
614 attr = m_readOnlyAttr;
615 }
616 else
617 {
618 m_footprintAttr->IncRef();
619 attr = m_footprintAttr;
620 }
621 }
622 else if( field.GetId() == FIELD_T::DATASHEET )
623 {
624 m_urlAttr->IncRef();
625 attr = m_urlAttr;
626 }
627 else if( field.GetId() == FIELD_T::SHEET_NAME )
628 {
629 m_referenceAttr->IncRef();
630 attr = m_referenceAttr;
631 }
632 else if( field.GetId() == FIELD_T::SHEET_FILENAME )
633 {
634 m_filepathAttr->IncRef();
635 attr = m_filepathAttr;
636 }
638 && field.GetUntranslatedName() == wxT( "Netclass" ) )
639 {
640 m_netclassAttr->IncRef();
641 attr = m_netclassAttr;
642 }
643 else
644 {
645 wxString fn = GetValue( aRow, FDC_NAME );
646
647 const TEMPLATE_FIELDNAME* templateFn =
648 m_frame->Prj().GetProjectFile().m_TemplateFieldNames.GetFieldName( fn );
649
650 if( ( templateFn && templateFn->m_URL ) || field.HasHypertext() )
651 {
652 m_urlAttr->IncRef();
653 attr = m_urlAttr;
654 }
655 else
656 {
657 m_nonUrlAttr->IncRef();
658 attr = m_nonUrlAttr;
659 }
660 }
661
662 break;
663
664 case FDC_TEXT_SIZE:
665 case FDC_POSX:
666 case FDC_POSY:
667 break;
668
669 case FDC_H_ALIGN:
670 m_hAlignAttr->IncRef();
671 attr = m_hAlignAttr;
672 break;
673
674 case FDC_V_ALIGN:
675 m_vAlignAttr->IncRef();
676 attr = m_vAlignAttr;
677 break;
678
679 case FDC_ORIENTATION:
680 m_orientationAttr->IncRef();
681 attr = m_orientationAttr;
682 break;
683
684 case FDC_SHOWN:
685 case FDC_SHOW_NAME:
686 case FDC_ITALIC:
687 case FDC_BOLD:
689 case FDC_PRIVATE:
690 m_boolAttr->IncRef();
691 attr = m_boolAttr;
692 break;
693
694 case FDC_FONT:
695 m_fontAttr->IncRef();
696 attr = m_fontAttr;
697 break;
698
699 case FDC_COLOR:
700 m_colorAttr->IncRef();
701 attr = m_colorAttr;
702 break;
703
704 default:
705 attr = nullptr;
706 break;
707 }
708
709 if( !attr )
710 return nullptr;
711
712 attr = enhanceAttr( attr, aRow, aCol, aKind );
713
714 if( IsInherited( aRow ) )
715 {
716 wxGridCellAttr* text_attr = attr ? attr->Clone() : new wxGridCellAttr;
717 wxFont font;
718
719 if( !text_attr->HasFont() )
720 font = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
721 else
722 font = text_attr->GetFont();
723
724 font.MakeItalic();
725 text_attr->SetFont( font );
726 text_attr->SetTextColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
727
728 if( attr )
729 attr->DecRef();
730
731 attr = text_attr;
732 }
733
734 return attr;
735}
736
737
738wxString FIELDS_GRID_TABLE::GetValue( int aRow, int aCol )
739{
740 wxCHECK( aRow < GetNumberRows(), wxEmptyString );
741
742 wxGrid* grid = GetView();
743 const SCH_FIELD& field = getField( aRow );
744
745 if( grid->GetGridCursorRow() == aRow && grid->GetGridCursorCol() == aCol
746 && grid->IsCellEditControlShown() )
747 {
748 auto it = m_evalOriginal.find( { aRow, aCol } );
749
750 if( it != m_evalOriginal.end() )
751 return it->second;
752 }
753
754 switch( aCol )
755 {
756 case FDC_NAME:
757 // Use default field names for mandatory and system fields because they are translated
758 // according to the current locale
760 {
762 }
763 else
764 {
765 if( field.IsMandatory() )
766 return GetDefaultFieldName( field.GetId(), TRANSLATED );
767 else
768 return field.GetName( false );
769 }
770
771 case FDC_VALUE:
772 return EscapeString( UnescapeString( field.GetText() ), CTX_LINE );
773
774 case FDC_SHOWN:
775 return StringFromBool( field.IsVisible() );
776
777 case FDC_SHOW_NAME:
778 return StringFromBool( field.IsNameShown() );
779
780 case FDC_H_ALIGN:
781 switch ( field.GetEffectiveHorizJustify() )
782 {
783 case GR_TEXT_H_ALIGN_LEFT: return _( "Left" );
784 case GR_TEXT_H_ALIGN_CENTER: return _( "Center" );
785 case GR_TEXT_H_ALIGN_RIGHT: return _( "Right" );
787 }
788
789 break;
790
791 case FDC_V_ALIGN:
792 switch ( field.GetEffectiveVertJustify() )
793 {
794 case GR_TEXT_V_ALIGN_TOP: return _( "Top" );
795 case GR_TEXT_V_ALIGN_CENTER: return _( "Center" );
796 case GR_TEXT_V_ALIGN_BOTTOM: return _( "Bottom" );
798 }
799
800 break;
801
802 case FDC_ITALIC:
803 return StringFromBool( field.IsItalic() );
804
805 case FDC_BOLD:
806 return StringFromBool( field.IsBold() );
807
808 case FDC_TEXT_SIZE:
809 return m_frame->StringFromValue( field.GetTextHeight(), true );
810
811 case FDC_ORIENTATION:
812 if( field.GetTextAngle().IsHorizontal() )
813 return _( "Horizontal" );
814 else
815 return _( "Vertical" );
816
817 case FDC_POSX:
818 return m_frame->StringFromValue( field.GetTextPos().x, true );
819
820 case FDC_POSY:
821 return m_frame->StringFromValue( field.GetTextPos().y, true );
822
823 case FDC_FONT:
824 if( field.GetFont() )
825 return field.GetFont()->GetName();
826 else
827 return DEFAULT_FONT_NAME;
828
829 case FDC_COLOR:
830 return field.GetTextColor().ToCSSString();
831
833 return StringFromBool( field.CanAutoplace() );
834
835 case FDC_PRIVATE:
836 return StringFromBool( field.IsPrivate() );
837
838 default:
839 // we can't assert here because wxWidgets sometimes calls this without checking
840 // the column type when trying to see if there's an overflow
841 break;
842 }
843
844 return wxT( "bad wxWidgets!" );
845}
846
847
848bool FIELDS_GRID_TABLE::GetValueAsBool( int aRow, int aCol )
849{
850 wxCHECK( aRow < GetNumberRows(), false );
851 const SCH_FIELD& field = getField( aRow );
852
853 switch( aCol )
854 {
855 case FDC_SHOWN: return field.IsVisible();
856 case FDC_SHOW_NAME: return field.IsNameShown();
857 case FDC_ITALIC: return field.IsItalic();
858 case FDC_BOLD: return field.IsBold();
859 case FDC_ALLOW_AUTOPLACE: return field.CanAutoplace();
860 case FDC_PRIVATE: return field.IsPrivate();
861 default:
862 wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a bool value" ), aCol ) );
863 return false;
864 }
865}
866
867
868void FIELDS_GRID_TABLE::SetValue( int aRow, int aCol, const wxString &aValue )
869{
870 wxCHECK( aRow < GetNumberRows(), /*void*/ );
871 SCH_FIELD& field = getField( aRow );
872 VECTOR2I pos;
873 wxString value = aValue;
874
875 if( aCol != FDC_VALUE )
876 value.Trim( true ).Trim( false );
877
878 if( aCol == FDC_TEXT_SIZE || aCol == FDC_POSX || aCol == FDC_POSY )
879 {
880 m_eval->SetDefaultUnits( m_frame->GetUserUnits() );
881
882 if( m_eval->Process( value ) )
883 {
884 m_evalOriginal[ { aRow, aCol } ] = value;
885 value = m_eval->Result();
886 }
887 }
888
889 switch( aCol )
890 {
891 case FDC_NAME:
892 field.SetName( value );
893 break;
894
895 case FDC_VALUE:
897 {
899 }
900 else if( m_parentType == LIB_SYMBOL_T && field.GetId() == FIELD_T::VALUE )
901 {
902 value = EscapeString( value, CTX_LIBID );
903 }
904 else if( m_frame )
905 {
906 value = ConvertPathToFileUri( value, &m_frame->Prj() );
907 }
908
909 field.SetText( UnescapeString( value ) );
910 break;
911
912 case FDC_SHOWN:
913 field.SetVisible( BoolFromString( value ) );
914 break;
915
916 case FDC_SHOW_NAME:
917 field.SetNameShown( BoolFromString( value ) );
918 break;
919
920 case FDC_H_ALIGN:
921 {
922 GR_TEXT_H_ALIGN_T horizontalJustification = GR_TEXT_H_ALIGN_CENTER;
923
924 if( value == _( "Left" ) )
925 horizontalJustification = GR_TEXT_H_ALIGN_LEFT;
926 else if( value == _( "Center" ) )
927 horizontalJustification = GR_TEXT_H_ALIGN_CENTER;
928 else if( value == _( "Right" ) )
929 horizontalJustification = GR_TEXT_H_ALIGN_RIGHT;
930
931 // Note that we must set justifications before we can ask if they're flipped. If the old
932 // justification is center then it won't know (whereas if the new justification is center
933 // the we don't care).
934 field.SetHorizJustify( horizontalJustification );
935
936 if( field.IsHorizJustifyFlipped() )
937 field.SetHorizJustify( EDA_TEXT::MapHorizJustify( - horizontalJustification ) );
938
939 break;
940 }
941
942 case FDC_V_ALIGN:
943 {
944 GR_TEXT_V_ALIGN_T verticalJustification = GR_TEXT_V_ALIGN_BOTTOM;
945
946 if( value == _( "Top" ) )
947 verticalJustification = GR_TEXT_V_ALIGN_TOP;
948 else if( value == _( "Center" ) )
949 verticalJustification = GR_TEXT_V_ALIGN_CENTER;
950 else if( value == _( "Bottom" ) )
951 verticalJustification = GR_TEXT_V_ALIGN_BOTTOM;
952
953 // Note that we must set justifications before we can ask if they're flipped. If the old
954 // justification is center then it won't know (whereas if the new justification is center
955 // the we don't care).
956 field.SetVertJustify( verticalJustification );
957
958 if( field.IsVertJustifyFlipped() )
959 field.SetVertJustify( EDA_TEXT::MapVertJustify( -verticalJustification ) );
960
961 break;
962 }
963
964 case FDC_ITALIC:
965 field.SetItalic( BoolFromString( value ) );
966 break;
967
968 case FDC_BOLD:
969 field.SetBold( BoolFromString( value ) );
970 break;
971
972 case FDC_TEXT_SIZE:
973 field.SetTextSize( VECTOR2I( m_frame->ValueFromString( value ), m_frame->ValueFromString( value ) ) );
974 break;
975
976 case FDC_ORIENTATION:
977 if( value == _( "Horizontal" ) )
979 else if( value == _( "Vertical" ) )
981 else
982 wxFAIL_MSG( wxT( "unknown orientation: " ) + value );
983
984 break;
985
986 case FDC_POSX:
987 case FDC_POSY:
988 pos = field.GetTextPos();
989
990 if( aCol == FDC_POSX )
991 pos.x = m_frame->ValueFromString( value );
992 else
993 pos.y = m_frame->ValueFromString( value );
994
995 field.SetTextPos( pos );
996 break;
997
998 case FDC_FONT:
999 if( value == DEFAULT_FONT_NAME )
1000 field.SetFont( nullptr );
1001 else if( value == KICAD_FONT_NAME )
1002 field.SetFont( KIFONT::FONT::GetFont( wxEmptyString, field.IsBold(), field.IsItalic() ) );
1003 else
1004 field.SetFont( KIFONT::FONT::GetFont( aValue, field.IsBold(), field.IsItalic() ) );
1005
1006 break;
1007
1008 case FDC_COLOR:
1009 field.SetTextColor( wxColor( value ) );
1010 break;
1011
1013 field.SetCanAutoplace( BoolFromString( value ) );
1014 break;
1015
1016 case FDC_PRIVATE:
1017 field.SetPrivate( BoolFromString( value ) );
1018 break;
1019
1020 default:
1021 wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a string value" ), aCol ) );
1022 break;
1023 }
1024
1025 m_dialog->OnModify();
1026
1027 GetView()->Refresh();
1028}
1029
1030
1031void FIELDS_GRID_TABLE::SetValueAsBool( int aRow, int aCol, bool aValue )
1032{
1033 wxCHECK( aRow < GetNumberRows(), /*void*/ );
1034 SCH_FIELD& field = getField( aRow );
1035
1036 switch( aCol )
1037 {
1038 case FDC_SHOWN:
1039 field.SetVisible( aValue );
1040 break;
1041
1042 case FDC_SHOW_NAME:
1043 field.SetNameShown( aValue );
1044 break;
1045
1046 case FDC_ITALIC:
1047 field.SetItalic( aValue );
1048 break;
1049
1050 case FDC_BOLD:
1051 field.SetBold( aValue );
1052 break;
1053
1055 field.SetCanAutoplace( aValue );
1056 break;
1057
1058 case FDC_PRIVATE:
1059 field.SetPrivate( aValue );
1060 break;
1061
1062 default:
1063 wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a bool value" ), aCol ) );
1064 break;
1065 }
1066
1067 m_dialog->OnModify();
1068}
1069
1070
1071wxString FIELDS_GRID_TABLE::StringFromBool( bool aValue ) const
1072{
1073 if( aValue )
1074 return wxT( "1" );
1075 else
1076 return wxT( "0" );
1077}
1078
1079
1080bool FIELDS_GRID_TABLE::BoolFromString( const wxString& aValue ) const
1081{
1082 if( aValue == wxS( "1" ) )
1083 {
1084 return true;
1085 }
1086 else if( aValue == wxS( "0" ) )
1087 {
1088 return false;
1089 }
1090 else
1091 {
1092 wxFAIL_MSG( wxString::Format( "string '%s' can't be converted to boolean correctly and "
1093 "will be perceived as FALSE", aValue ) );
1094 return false;
1095 }
1096}
1097
1098
1100{
1101 for( SCH_FIELD& field : *this )
1102 {
1103 if( field.GetId() == aFieldId )
1104 return &field;
1105 }
1106
1107 return nullptr;
1108}
1109
1110
1112{
1113 int visibleRow = 0;
1114
1115 for( const SCH_FIELD& field : *this )
1116 {
1117 if( field.GetId() == aFieldId )
1118 return privateFieldsAreHidden() && field.IsPrivate() ? -1 : visibleRow;
1119
1120 if( !privateFieldsAreHidden() || !field.IsPrivate() )
1121 ++visibleRow;
1122 }
1123
1124 return -1;
1125}
1126
1127
1128bool FIELDS_GRID_TABLE::IsInherited( size_t aRow ) const
1129{
1130 int fieldIndex = getFieldIndex( static_cast<int>( aRow ) );
1131
1132 if( fieldIndex < 0 || fieldIndex >= static_cast<int>( m_inheritance.size() ) )
1133 return false;
1134
1135 const INHERITANCE& inheritance = m_inheritance[fieldIndex];
1136
1137 // Any edit, including position or visibility, turns the row into an override
1138 return inheritance.m_derived && at( fieldIndex ).HasSameContent( inheritance.m_parentField );
1139}
1140
1141
1143{
1144 return m_inheritance.at( getFieldIndex( static_cast<int>( aRow ) ) ).m_parentField;
1145}
1146
1147
1148const wxString& FIELDS_GRID_TABLE::InheritedFrom( size_t aRow ) const
1149{
1150 return m_inheritance.at( getFieldIndex( static_cast<int>( aRow ) ) ).m_source;
1151}
1152
1153
1154void FIELDS_GRID_TABLE::AddInheritedField( const SCH_FIELD& aParent, const wxString& aSource )
1155{
1156 push_back( aParent );
1157 back().SetParent( m_part );
1158 m_inheritance.back().m_derived = true;
1159 SetFieldInherited( size() - 1, aParent, aSource );
1160}
1161
1162
1163void FIELDS_GRID_TABLE::SetFieldInherited( size_t aFieldIndex, const SCH_FIELD& aParent, const wxString& aSource )
1164{
1165 wxCHECK( aFieldIndex < size() && aFieldIndex < m_inheritance.size(), /*void*/ );
1166
1167 INHERITANCE& inheritance = m_inheritance[aFieldIndex];
1168 SCH_FIELD& field = at( aFieldIndex );
1169
1170 // Flatten() gives an empty mandatory field the ancestor's value, but any user field the symbol owns wins
1171 if( inheritance.m_derived || ( field.IsMandatory() && field.GetText().IsEmpty() ) )
1172 {
1173 field = aParent;
1174 inheritance.m_derived = true;
1175 }
1176
1177 inheritance.m_parentField = aParent;
1178 inheritance.m_parentField.SetParent( nullptr );
1179 inheritance.m_source = aSource;
1180 inheritance.m_hasParent = true;
1181}
1182
1183
1185{
1186 int fieldIndex = getFieldIndex( static_cast<int>( aRow ) );
1187
1188 if( fieldIndex < 0 )
1189 return false;
1190
1191 if( m_inheritance.size() > static_cast<size_t>( fieldIndex ) )
1192 {
1193 INHERITANCE& inheritance = m_inheritance[fieldIndex];
1194
1195 // You can't erase inherited fields, but you can reset them to the parent value.
1196 if( inheritance.m_hasParent )
1197 {
1198 at( fieldIndex ) = inheritance.m_parentField;
1199 inheritance.m_derived = true;
1200 return false;
1201 }
1202
1203 m_inheritance.erase( m_inheritance.begin() + fieldIndex );
1204 }
1205
1206 std::vector<SCH_FIELD>::erase( begin() + fieldIndex );
1207 return true;
1208}
1209
1210void FIELDS_GRID_TABLE::SwapRows( size_t a, size_t b )
1211{
1212 int fieldIndexA = getFieldIndex( static_cast<int>( a ) );
1213 int fieldIndexB = getFieldIndex( static_cast<int>( b ) );
1214
1215 wxCHECK( fieldIndexA >= 0 && fieldIndexB >= 0, /*void*/ );
1216 wxCHECK( fieldIndexA < static_cast<int>( m_inheritance.size() )
1217 && fieldIndexB < static_cast<int>( m_inheritance.size() ),
1218 /*void*/ );
1219
1220 std::swap( at( fieldIndexA ), at( fieldIndexB ) );
1221 std::swap( m_inheritance[fieldIndexA], m_inheritance[fieldIndexB] );
1222}
1223
1224
1226{
1227 for( SCH_FIELD& field : *this )
1228 field.SetParent( nullptr );
1229
1230 for( INHERITANCE& inheritance : m_inheritance )
1231 inheritance.m_parentField.SetParent( nullptr );
1232}
1233
1234
1236{
1237 return static_cast<FIELDS_GRID_TABLE*>( m_grid->GetTable() )->GetFieldRow( aFieldId );
1238}
1239
1240
1241void FIELDS_GRID_TRICKS::showPopupMenu( wxMenu& menu, wxGridEvent& aEvent )
1242{
1243 if( m_grid->GetGridCursorRow() == getFieldRow( FIELD_T::FOOTPRINT )
1244 && m_grid->GetGridCursorCol() == FDC_VALUE
1245 && !m_grid->IsReadOnly( getFieldRow( FIELD_T::FOOTPRINT ), FDC_VALUE ) )
1246 {
1247 menu.Append( MYID_SELECT_FOOTPRINT, _( "Select Footprint..." ), _( "Browse for footprint" ) );
1248 menu.AppendSeparator();
1249 }
1250 else if( m_grid->GetGridCursorRow() == getFieldRow( FIELD_T::DATASHEET )
1251 && m_grid->GetGridCursorCol() == FDC_VALUE
1252 && !m_grid->IsReadOnly( getFieldRow( FIELD_T::DATASHEET ), FDC_VALUE ) )
1253 {
1254 menu.Append( MYID_SHOW_DATASHEET, _( "Show Datasheet" ), _( "Show datasheet in browser" ) );
1255 menu.AppendSeparator();
1256 }
1257
1258 GRID_TRICKS::showPopupMenu( menu, aEvent );
1259}
1260
1261
1262void FIELDS_GRID_TRICKS::doPopupSelection( wxCommandEvent& event )
1263{
1264 if( event.GetId() == MYID_SELECT_FOOTPRINT )
1265 {
1266 // pick a footprint using the footprint picker.
1267 wxString fpid = m_grid->GetCellValue( getFieldRow( FIELD_T::FOOTPRINT ), FDC_VALUE );
1268
1269 if( SelectFootprintFromChooser( m_dlg, fpid ) )
1270 m_grid->SetCellValue( getFieldRow( FIELD_T::FOOTPRINT ), FDC_VALUE, fpid );
1271 }
1272 else if (event.GetId() == MYID_SHOW_DATASHEET )
1273 {
1274 wxString datasheet_uri = m_grid->GetCellValue( getFieldRow( FIELD_T::DATASHEET ), FDC_VALUE );
1275
1276 GetAssociatedDocument( m_dlg, datasheet_uri, &m_dlg->Prj(), PROJECT_SCH::SchSearchS( &m_dlg->Prj() ),
1277 m_filesStack );
1278 }
1279 else
1280 {
1282 }
1283}
const char * name
Dialog helper object to sit in the inheritance tree between wxDialog and any class written by wxFormB...
Definition dialog_shim.h:80
bool IsHorizontal() const
Definition eda_angle.h:141
virtual void SetParent(EDA_ITEM *aParent)
Definition eda_item.cpp:153
void SetTextColor(const COLOR4D &aColor)
Definition eda_text.h:309
COLOR4D GetTextColor() const
Definition eda_text.h:310
virtual VECTOR2I GetTextPos() const
Definition eda_text.h:313
bool IsItalic() const
Definition eda_text.h:200
virtual void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true)
Definition eda_text.cpp:512
virtual bool IsVisible() const
Definition eda_text.h:226
virtual void SetTextPos(const VECTOR2I &aPoint)
Definition eda_text.cpp:556
virtual int GetTextHeight() const
Definition eda_text.h:307
KIFONT::FONT * GetFont() const
Definition eda_text.h:286
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
Definition eda_text.cpp:378
virtual void SetVisible(bool aVisible)
Definition eda_text.cpp:347
static GR_TEXT_H_ALIGN_T MapHorizJustify(int aHorizJustify)
Definition eda_text.cpp:70
virtual EDA_ANGLE GetTextAngle() const
Definition eda_text.h:178
void SetBold(bool aBold)
Set the text to be bold - this will also update the font if needed.
Definition eda_text.cpp:310
bool IsBold() const
Definition eda_text.h:215
static GR_TEXT_V_ALIGN_T MapVertJustify(int aVertJustify)
Definition eda_text.cpp:84
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition eda_text.cpp:268
void SetItalic(bool aItalic)
Set the text to be italic - this will also update the font if needed.
Definition eda_text.cpp:290
void SetFont(KIFONT::FONT *aFont)
Definition eda_text.cpp:471
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Definition eda_text.cpp:370
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 GetNumberRows() override
void push_back(const SCH_FIELD &field)
wxGridCellAttr * m_readOnlyAttr
int GetMandatoryRowCount() const
FIELD_VALIDATOR m_urlValidator
SCH_BASE_FRAME * m_frame
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
const SCH_FIELD & ParentField(size_t aRow) 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
FIELDS_GRID_TABLE(DIALOG_SHIM *aDialog, SCH_BASE_FRAME *aFrame, WX_GRID *aGrid, LIB_SYMBOL *aSymbol, std::vector< EMBEDDED_FILES * > aFilesStack)
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
int getFieldIndex(int aRow) const
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)
Definition font.cpp:143
const wxString & GetName() const
Definition font.h:112
wxString ToCSSString() const
Definition color4d.cpp:146
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
Define a library symbol object.
Definition lib_symbol.h:114
wxArrayString GetFPFilters() const
Definition lib_symbol.h:252
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
Definition project.h:201
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 IsMandatory() const
bool IsNameShown() const
Definition sch_field.h:229
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.
Definition sch_field.h:139
FIELD_T GetId() const
Definition sch_field.h:143
void SetCanAutoplace(bool aCanPlace)
Definition sch_field.h:241
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 SetName(const wxString &aName)
bool CanAutoplace() const
Definition sch_field.h:240
void SetText(const wxString &aText) override
void OnScintillaCharAdded(SCINTILLA_TRICKS *aScintillaTricks, wxStyledTextEvent &aEvent) const
void SetNameShown(bool aShown=true)
Definition sch_field.h:230
void SetPrivate(bool aPrivate)
Definition sch_item.h:258
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
Definition sch_item.cpp:302
bool IsPrivate() const
Definition sch_item.h:259
static const wxString GetDefaultFieldName(const wxString &aName, bool aUseDefaultName)
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition sch_sheet.h:48
Schematic symbol object.
Definition sch_symbol.h:73
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
Definition sch_symbol.h:182
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)
Definition wx_grid.cpp:43
void SetupColumnAutosizer(int aFlexibleCol)
Set autosize behaviour using wxFormBuilder column widths as minimums, with a single specified growabl...
Definition wx_grid.cpp:1160
wxString EnsureFileExtension(const wxString &aFilename, const wxString &aExtension)
It's annoying to throw up nag dialogs when the extension isn't right.
Definition common.cpp:848
#define _(s)
static constexpr EDA_ANGLE ANGLE_VERTICAL
Definition eda_angle.h:445
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
Definition eda_angle.h:444
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.
Definition eda_doc.cpp:59
This file is part of the common library.
#define DEFAULT_FONT_NAME
wxString BuildFootprintChooserSymbolNetlist(const LIB_SYMBOL *aSymbol)
@ FDC_TEXT_SIZE
@ FDC_BOLD
@ FDC_SCH_EDIT_COUNT
@ FDC_POSY
@ FDC_ITALIC
@ FDC_SHOW_NAME
@ FDC_NAME
@ FDC_H_ALIGN
@ FDC_COLOR
@ FDC_SHOWN
@ FDC_ALLOW_AUTOPLACE
@ FDC_VALUE
@ FDC_SYMBOL_EDITOR_COUNT
@ FDC_POSX
@ FDC_ORIENTATION
@ FDC_V_ALIGN
@ FDC_FONT
@ FDC_PRIVATE
wxString BuildFootprintChooserSymbolNetlist(const LIB_SYMBOL *aSymbol)
FONTCONFIG * Fontconfig()
@ FRAME_SCH_VIEWER
Definition frame_type.h:32
@ FRAME_SCH
Definition frame_type.h:30
bool SelectFootprintFromChooser(DIALOG_SHIM *aDialog, wxString &aFootprint, const wxString &aSymbolNetlist)
@ GRIDTRICKS_FIRST_CLIENT_ID
Definition grid_tricks.h:44
static const std::string KiCadSchematicFileExtension
@ USER
The main config directory (e.g. ~/.config/kicad/)
#define KICAD_FONT_NAME
PGM_BASE & Pgm()
The global program "get" accessor.
see class PGM_BASE
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:...
@ CTX_LINE
@ CTX_LIBID
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".
@ DATASHEET
name of datasheet
@ REFERENCE
Field Reference of part, i.e. "IC21".
@ VALUE
Field Value of part, i.e. "3.3K".
@ TRANSLATED
std::string netlist
KIBIS_PIN * pin
GR_TEXT_H_ALIGN_T
This is API surface mapped to common.types.HorizontalAlignment.
@ GR_TEXT_H_ALIGN_CENTER
@ GR_TEXT_H_ALIGN_RIGHT
@ GR_TEXT_H_ALIGN_LEFT
@ GR_TEXT_H_ALIGN_INDETERMINATE
GR_TEXT_V_ALIGN_T
This is API surface mapped to common.types.VertialAlignment.
@ GR_TEXT_V_ALIGN_BOTTOM
@ GR_TEXT_V_ALIGN_INDETERMINATE
@ GR_TEXT_V_ALIGN_CENTER
@ GR_TEXT_V_ALIGN_TOP
@ LIB_SYMBOL_T
Definition typeinfo.h:144
@ SCH_SYMBOL_T
Definition typeinfo.h:168
@ SCH_SHEET_T
Definition typeinfo.h:171
@ SCH_LABEL_LOCATE_ANY_T
Definition typeinfo.h:187
#define INDETERMINATE_STATE
Used for holding indeterminate values, such as with multiple selections holding different values or c...
Definition ui_common.h:46
Custom text control validator definitions.
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708
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.