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, LIB_SYMBOL* aPart,
151 std::vector<EMBEDDED_FILES*>& aFilesStack ) :
152 m_frame( aFrame ),
153 m_dialog( aDialog ),
155 m_part( aPart ),
156 m_filesStack( aFilesStack ),
157 m_symbolNetlist( BuildFootprintChooserSymbolNetlist( aSymbol->GetLibSymbolRef().get() ) ),
164{
165 initGrid( aGrid );
166}
167
168
170 SCH_SHEET* aSheet, std::vector<EMBEDDED_FILES*>& aFilesStack ) :
171 m_frame( aFrame ),
172 m_dialog( aDialog ),
174 m_part( nullptr ),
175 m_filesStack( aFilesStack ),
182{
183 initGrid( aGrid );
184}
185
186
188 SCH_LABEL_BASE* aLabel, std::vector<EMBEDDED_FILES*>& aFilesStack ) :
189 m_frame( aFrame ),
190 m_dialog( aDialog ),
192 m_part( nullptr ),
193 m_filesStack( aFilesStack ),
200{
201 initGrid( aGrid );
202}
203
204
206{
207 int mandatoryRows = 0;
208
209 for( const SCH_FIELD& field : *this )
210 {
211 if( field.IsMandatory() && ( !privateFieldsAreHidden() || !field.IsPrivate() ) )
212 mandatoryRows++;
213 }
214
215 return mandatoryRows;
216}
217
218
220{
221 std::vector<SCH_FIELD>::push_back( aField );
222
223 m_inheritance.resize( size() );
224}
225
226
228{
229 // Build the various grid cell attributes.
230 // NOTE: validators and cellAttrs are member variables to get the destruction order
231 // right. wxGrid is VERY cranky about this.
232
233 m_readOnlyAttr = new wxGridCellAttr;
234 m_readOnlyAttr->SetReadOnly( true );
235
236 m_fieldNameAttr = new wxGridCellAttr;
238 nameEditor->SetValidator( m_fieldNameValidator );
239 m_fieldNameAttr->SetEditor( nameEditor );
240
241 m_referenceAttr = new wxGridCellAttr;
242 GRID_CELL_TEXT_EDITOR* referenceEditor = new GRID_CELL_TEXT_EDITOR();
243 referenceEditor->SetValidator( m_referenceValidator );
244 m_referenceAttr->SetEditor( referenceEditor );
245
246 m_valueAttr = new wxGridCellAttr;
247
249 {
250 GRID_CELL_TEXT_EDITOR* valueEditor = new GRID_CELL_TEXT_EDITOR();
251 valueEditor->SetValidator( m_valueValidator );
252 m_valueAttr->SetEditor( valueEditor );
253 }
254 else
255 {
256 GRID_CELL_STC_EDITOR* valueEditor = new GRID_CELL_STC_EDITOR( true, true,
257 [this]( wxStyledTextEvent& aEvent, SCINTILLA_TRICKS* aScintillaTricks )
258 {
259 SCH_FIELD* valueField = this->GetField( FIELD_T::VALUE );
260 valueField->OnScintillaCharAdded( aScintillaTricks, aEvent );
261 } );
262
263 m_valueAttr->SetEditor( valueEditor );
264 }
265
266 m_footprintAttr = new wxGridCellAttr;
268 m_dialog,
269 [this]( int )
270 {
271 return m_symbolNetlist;
272 } );
273 fpIdEditor->SetValidator( m_nonUrlValidator );
274 m_footprintAttr->SetEditor( fpIdEditor );
275
276 m_urlAttr = new wxGridCellAttr;
277 SEARCH_STACK* prjSearchStack = PROJECT_SCH::SchSearchS( &m_frame->Prj() );
278 GRID_CELL_URL_EDITOR* urlEditor = new GRID_CELL_URL_EDITOR( m_dialog, prjSearchStack, m_filesStack );
279 urlEditor->SetValidator( m_urlValidator );
280 m_urlAttr->SetEditor( urlEditor );
281
282 m_nonUrlAttr = new wxGridCellAttr;
283 GRID_CELL_TEXT_EDITOR* nonUrlEditor = new GRID_CELL_TEXT_EDITOR();
284 nonUrlEditor->SetValidator( m_nonUrlValidator );
285 m_nonUrlAttr->SetEditor( nonUrlEditor );
286
287 m_curdir = m_frame->Prj().GetProjectPath();
288 m_filepathAttr = new wxGridCellAttr;
289
290 // Create a wild card using wxFileDialog syntax.
291 wxString wildCard( _( "Schematic Files" ) );
292 std::vector<std::string> exts;
293 exts.push_back( FILEEXT::KiCadSchematicFileExtension );
294 wildCard += AddFileExtListToFilter( exts );
295
296 auto filepathEditor = new GRID_CELL_PATH_EDITOR( m_dialog, aGrid, &m_curdir, wildCard );
297 filepathEditor->SetValidator( m_filepathValidator );
298 m_filepathAttr->SetEditor( filepathEditor );
299
300 m_boolAttr = new wxGridCellAttr;
301 m_boolAttr->SetRenderer( new wxGridCellBoolRenderer() );
302 m_boolAttr->SetEditor( new wxGridCellBoolEditor() );
303 m_boolAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
304
305 wxArrayString vAlignNames;
306 vAlignNames.Add( _( "Top" ) );
307 vAlignNames.Add( _( "Center" ) );
308 vAlignNames.Add( _( "Bottom" ) );
309 m_vAlignAttr = new wxGridCellAttr;
310 m_vAlignAttr->SetEditor( new wxGridCellChoiceEditor( vAlignNames ) );
311 m_vAlignAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
312
313 wxArrayString hAlignNames;
314 hAlignNames.Add( _( "Left" ) );
315 hAlignNames.Add(_( "Center" ) );
316 hAlignNames.Add(_( "Right" ) );
317 m_hAlignAttr = new wxGridCellAttr;
318 m_hAlignAttr->SetEditor( new wxGridCellChoiceEditor( hAlignNames ) );
319 m_hAlignAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
320
321 wxArrayString orientationNames;
322 orientationNames.Add( _( "Horizontal" ) );
323 orientationNames.Add(_( "Vertical" ) );
324 m_orientationAttr = new wxGridCellAttr;
325 m_orientationAttr->SetEditor( new wxGridCellChoiceEditor( orientationNames ) );
326 m_orientationAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
327
328 SCH_EDIT_FRAME* editFrame = dynamic_cast<SCH_EDIT_FRAME*>( m_frame );
329 wxArrayString existingNetclasses;
330
331 wxArrayString fonts;
332 std::vector<std::string> fontNames;
333
334 if( editFrame )
335 {
336 // Load the combobox with existing existingNetclassNames
337 PROJECT_FILE& projectFile = editFrame->Prj().GetProjectFile();
338 const std::shared_ptr<NET_SETTINGS>& settings = projectFile.NetSettings();
339
340 existingNetclasses.push_back( settings->GetDefaultNetclass()->GetName() );
341
342 for( const auto& [name, netclass] : settings->GetNetclasses() )
343 existingNetclasses.push_back( name );
344
345 // We don't need to re-cache the embedded fonts when looking at symbols in the schematic
346 // editor because the fonts are all available in the schematic.
347 const std::vector<wxString>* fontFiles = nullptr;
348
349 if( m_frame->GetScreen() && m_frame->GetScreen()->Schematic() )
350 fontFiles = m_frame->GetScreen()->Schematic()->GetEmbeddedFiles()->GetFontFiles();
351
352 Fontconfig()->ListFonts( fontNames, std::string( Pgm().GetLanguageTag().utf8_str() ),
353 fontFiles, false );
354 }
355 else
356 {
357 const std::vector<wxString>* fontFiles = m_part->GetEmbeddedFiles()->UpdateFontFiles();
358
359 // If there are font files embedded, we want to re-cache our fonts for each symbol that
360 // we are looking at in the symbol editor.
361 Fontconfig()->ListFonts( fontNames, std::string( Pgm().GetLanguageTag().utf8_str() ),
362 fontFiles, !fontFiles->empty() );
363 }
364
365 m_netclassAttr = new wxGridCellAttr;
366 m_netclassAttr->SetEditor( new GRID_CELL_COMBOBOX( existingNetclasses ) );
367
368 for( const std::string& name : fontNames )
369 fonts.Add( wxString( name ) );
370
371 fonts.Sort();
372 fonts.Insert( KICAD_FONT_NAME, 0 );
373 fonts.Insert( DEFAULT_FONT_NAME, 0 );
374
375 m_fontAttr = new wxGridCellAttr;
376 m_fontAttr->SetEditor( new GRID_CELL_COMBOBOX( fonts ) );
377
378 m_colorAttr = new wxGridCellAttr;
379 m_colorAttr->SetRenderer( new GRID_CELL_COLOR_RENDERER( m_dialog ) );
380 m_colorAttr->SetEditor( new GRID_CELL_COLOR_SELECTOR( m_dialog, aGrid ) );
381
382 m_eval = std::make_unique<NUMERIC_EVALUATOR>( m_frame->GetUserUnits() );
383
385
386 m_frame->Bind( EDA_EVT_UNITS_CHANGED, &FIELDS_GRID_TABLE::onUnitsChanged, this );
387}
388
389
391{
392 m_readOnlyAttr->DecRef();
393 m_fieldNameAttr->DecRef();
394 m_boolAttr->DecRef();
395 m_referenceAttr->DecRef();
396 m_valueAttr->DecRef();
397 m_footprintAttr->DecRef();
398 m_urlAttr->DecRef();
399 m_nonUrlAttr->DecRef();
400 m_filepathAttr->DecRef();
401 m_vAlignAttr->DecRef();
402 m_hAlignAttr->DecRef();
403 m_orientationAttr->DecRef();
404 m_netclassAttr->DecRef();
405 m_fontAttr->DecRef();
406 m_colorAttr->DecRef();
407
408 for( INHERITANCE& inheritance : m_inheritance )
409 inheritance.m_parentField.SetParent( nullptr );
410
411 m_frame->Unbind( EDA_EVT_UNITS_CHANGED, &FIELDS_GRID_TABLE::onUnitsChanged, this );
412}
413
414
415void FIELDS_GRID_TABLE::onUnitsChanged( wxCommandEvent& aEvent )
416{
417 if( GetView() )
418 GetView()->ForceRefresh();
419
420 aEvent.Skip();
421}
422
423
425{
426 if( m_frame->GetFrameType() == FRAME_SCH
427 || m_frame->GetFrameType() == FRAME_SCH_VIEWER )
428 {
429 return FDC_SCH_EDIT_COUNT;
430 }
431 else
432 {
434 }
435}
436
437
439{
440 return m_frame->GetFrameType() == FRAME_SCH || m_frame->GetFrameType() == FRAME_SCH_VIEWER;
441}
442
443
445{
446 wxCHECK_MSG( aRow >= 0 && aRow < getVisibleRowCount(), -1, wxT( "Invalid field row" ) );
447
449 return aRow;
450
451 int visibleRow = 0;
452
453 for( int fieldIndex = 0; fieldIndex < static_cast<int>( size() ); ++fieldIndex )
454 {
455 if( at( fieldIndex ).IsPrivate() )
456 continue;
457
458 if( visibleRow == aRow )
459 return fieldIndex;
460
461 ++visibleRow;
462 }
463
464 wxFAIL_MSG( wxT( "Row index off end of visible row count" ) );
465 return -1;
466}
467
468
470{
472 {
473 int visibleRows = 0;
474
475 for( const SCH_FIELD& field : *this )
476 {
477 if( !field.IsPrivate() )
478 visibleRows++;
479 }
480
481 return visibleRows;
482 }
483
484 return (int) this->size();
485}
486
487
489{
490 return at( getFieldIndex( aRow ) );
491}
492
493
495{
496 switch( aCol )
497 {
498 case FDC_NAME: return _( "Name" );
499 case FDC_VALUE: return _( "Value" );
500 case FDC_SHOWN: return _( "Show" );
501 case FDC_SHOW_NAME: return _( "Show Name" );
502 case FDC_H_ALIGN: return _( "H Align" );
503 case FDC_V_ALIGN: return _( "V Align" );
504 case FDC_ITALIC: return _( "Italic" );
505 case FDC_BOLD: return _( "Bold" );
506 case FDC_TEXT_SIZE: return _( "Text Size" );
507 case FDC_ORIENTATION: return _( "Orientation" );
508 case FDC_POSX: return _( "X Position" );
509 case FDC_POSY: return _( "Y Position" );
510 case FDC_FONT: return _( "Font" );
511 case FDC_COLOR: return _( "Color" );
512 case FDC_ALLOW_AUTOPLACE: return _( "Allow Autoplacement" );
513 case FDC_PRIVATE: return _( "Private" );
514 default: wxFAIL; return wxEmptyString;
515 }
516}
517
518
519bool FIELDS_GRID_TABLE::CanGetValueAs( int aRow, int aCol, const wxString& aTypeName )
520{
521 switch( aCol )
522 {
523 case FDC_NAME:
524 case FDC_VALUE:
525 case FDC_H_ALIGN:
526 case FDC_V_ALIGN:
527 case FDC_TEXT_SIZE:
528 case FDC_ORIENTATION:
529 case FDC_POSX:
530 case FDC_POSY:
531 case FDC_FONT:
532 case FDC_COLOR:
533 return aTypeName == wxGRID_VALUE_STRING;
534
535 case FDC_SHOWN:
536 case FDC_SHOW_NAME:
537 case FDC_ITALIC:
538 case FDC_BOLD:
540 case FDC_PRIVATE:
541 return aTypeName == wxGRID_VALUE_BOOL;
542
543 default:
544 wxFAIL;
545 return false;
546 }
547}
548
549
550bool FIELDS_GRID_TABLE::CanSetValueAs( int aRow, int aCol, const wxString& aTypeName )
551{
552 return CanGetValueAs( aRow, aCol, aTypeName );
553}
554
555
556wxGridCellAttr* FIELDS_GRID_TABLE::GetAttr( int aRow, int aCol, wxGridCellAttr::wxAttrKind aKind )
557{
558 wxCHECK( aRow < GetNumberRows(), nullptr );
559
560 const SCH_FIELD& field = getField( aRow );
561 wxGridCellAttr* attr = nullptr;
562
563 switch( aCol )
564 {
565 case FDC_NAME:
566 if( field.IsMandatory() )
567 {
568 attr = m_fieldNameAttr->Clone();
569 attr->SetReadOnly( true );
570 }
571 else
572 {
573 m_fieldNameAttr->IncRef();
574 attr = m_fieldNameAttr;
575 }
576
577 break;
578
579 case FDC_VALUE:
580 if( field.GetId() == FIELD_T::REFERENCE )
581 {
582 m_referenceAttr->IncRef();
583 attr = m_referenceAttr;
584 }
585 else if( field.GetId() == FIELD_T::VALUE )
586 {
587 m_valueAttr->IncRef();
588 attr = m_valueAttr;
589 }
590 else if( field.GetId() == FIELD_T::FOOTPRINT )
591 {
592 // Power symbols have do not appear in the board, so don't allow
593 // a footprint (m_part can be nullptr when loading a old schematic
594 // (for instance Kicad 4) with libraries missing)
595 if( m_part && m_part->IsPower() )
596 {
597 m_readOnlyAttr->IncRef();
598 attr = m_readOnlyAttr;
599 }
600 else
601 {
602 m_footprintAttr->IncRef();
603 attr = m_footprintAttr;
604 }
605 }
606 else if( field.GetId() == FIELD_T::DATASHEET )
607 {
608 m_urlAttr->IncRef();
609 attr = m_urlAttr;
610 }
611 else if( field.GetId() == FIELD_T::SHEET_NAME )
612 {
613 m_referenceAttr->IncRef();
614 attr = m_referenceAttr;
615 }
616 else if( field.GetId() == FIELD_T::SHEET_FILENAME )
617 {
618 m_filepathAttr->IncRef();
619 attr = m_filepathAttr;
620 }
622 && field.GetUntranslatedName() == wxT( "Netclass" ) )
623 {
624 m_netclassAttr->IncRef();
625 attr = m_netclassAttr;
626 }
627 else
628 {
629 wxString fn = GetValue( aRow, FDC_NAME );
630
631 const TEMPLATE_FIELDNAME* templateFn =
632 m_frame->Prj().GetProjectFile().m_TemplateFieldNames.GetFieldName( fn );
633
634 if( ( templateFn && templateFn->m_URL ) || field.HasHypertext() )
635 {
636 m_urlAttr->IncRef();
637 attr = m_urlAttr;
638 }
639 else
640 {
641 m_nonUrlAttr->IncRef();
642 attr = m_nonUrlAttr;
643 }
644 }
645
646 break;
647
648 case FDC_TEXT_SIZE:
649 case FDC_POSX:
650 case FDC_POSY:
651 break;
652
653 case FDC_H_ALIGN:
654 m_hAlignAttr->IncRef();
655 attr = m_hAlignAttr;
656 break;
657
658 case FDC_V_ALIGN:
659 m_vAlignAttr->IncRef();
660 attr = m_vAlignAttr;
661 break;
662
663 case FDC_ORIENTATION:
664 m_orientationAttr->IncRef();
665 attr = m_orientationAttr;
666 break;
667
668 case FDC_SHOWN:
669 case FDC_SHOW_NAME:
670 case FDC_ITALIC:
671 case FDC_BOLD:
673 case FDC_PRIVATE:
674 m_boolAttr->IncRef();
675 attr = m_boolAttr;
676 break;
677
678 case FDC_FONT:
679 m_fontAttr->IncRef();
680 attr = m_fontAttr;
681 break;
682
683 case FDC_COLOR:
684 m_colorAttr->IncRef();
685 attr = m_colorAttr;
686 break;
687
688 default:
689 attr = nullptr;
690 break;
691 }
692
693 if( !attr )
694 return nullptr;
695
696 attr = enhanceAttr( attr, aRow, aCol, aKind );
697
698 if( IsInherited( aRow ) )
699 {
700 wxGridCellAttr* text_attr = attr ? attr->Clone() : new wxGridCellAttr;
701 wxFont font;
702
703 if( !text_attr->HasFont() )
704 font = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
705 else
706 font = text_attr->GetFont();
707
708 font.MakeItalic();
709 text_attr->SetFont( font );
710 text_attr->SetTextColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
711
712 if( attr )
713 attr->DecRef();
714
715 attr = text_attr;
716 }
717
718 return attr;
719}
720
721
722wxString FIELDS_GRID_TABLE::GetValue( int aRow, int aCol )
723{
724 wxCHECK( aRow < GetNumberRows(), wxEmptyString );
725
726 wxGrid* grid = GetView();
727 const SCH_FIELD& field = getField( aRow );
728
729 if( grid->GetGridCursorRow() == aRow && grid->GetGridCursorCol() == aCol
730 && grid->IsCellEditControlShown() )
731 {
732 auto it = m_evalOriginal.find( { aRow, aCol } );
733
734 if( it != m_evalOriginal.end() )
735 return it->second;
736 }
737
738 switch( aCol )
739 {
740 case FDC_NAME:
741 // Use default field names for mandatory and system fields because they are translated
742 // according to the current locale
744 {
746 }
747 else
748 {
749 if( field.IsMandatory() )
750 return GetDefaultFieldName( field.GetId(), TRANSLATED );
751 else
752 return field.GetName( false );
753 }
754
755 case FDC_VALUE:
756 return EscapeString( UnescapeString( field.GetText() ), CTX_LINE );
757
758 case FDC_SHOWN:
759 return StringFromBool( field.IsVisible() );
760
761 case FDC_SHOW_NAME:
762 return StringFromBool( field.IsNameShown() );
763
764 case FDC_H_ALIGN:
765 switch ( field.GetEffectiveHorizJustify() )
766 {
767 case GR_TEXT_H_ALIGN_LEFT: return _( "Left" );
768 case GR_TEXT_H_ALIGN_CENTER: return _( "Center" );
769 case GR_TEXT_H_ALIGN_RIGHT: return _( "Right" );
771 }
772
773 break;
774
775 case FDC_V_ALIGN:
776 switch ( field.GetEffectiveVertJustify() )
777 {
778 case GR_TEXT_V_ALIGN_TOP: return _( "Top" );
779 case GR_TEXT_V_ALIGN_CENTER: return _( "Center" );
780 case GR_TEXT_V_ALIGN_BOTTOM: return _( "Bottom" );
782 }
783
784 break;
785
786 case FDC_ITALIC:
787 return StringFromBool( field.IsItalic() );
788
789 case FDC_BOLD:
790 return StringFromBool( field.IsBold() );
791
792 case FDC_TEXT_SIZE:
793 return m_frame->StringFromValue( field.GetTextHeight(), true );
794
795 case FDC_ORIENTATION:
796 if( field.GetTextAngle().IsHorizontal() )
797 return _( "Horizontal" );
798 else
799 return _( "Vertical" );
800
801 case FDC_POSX:
802 return m_frame->StringFromValue( field.GetTextPos().x, true );
803
804 case FDC_POSY:
805 return m_frame->StringFromValue( field.GetTextPos().y, true );
806
807 case FDC_FONT:
808 if( field.GetFont() )
809 return field.GetFont()->GetName();
810 else
811 return DEFAULT_FONT_NAME;
812
813 case FDC_COLOR:
814 return field.GetTextColor().ToCSSString();
815
817 return StringFromBool( field.CanAutoplace() );
818
819 case FDC_PRIVATE:
820 return StringFromBool( field.IsPrivate() );
821
822 default:
823 // we can't assert here because wxWidgets sometimes calls this without checking
824 // the column type when trying to see if there's an overflow
825 break;
826 }
827
828 return wxT( "bad wxWidgets!" );
829}
830
831
832bool FIELDS_GRID_TABLE::GetValueAsBool( int aRow, int aCol )
833{
834 wxCHECK( aRow < GetNumberRows(), false );
835 const SCH_FIELD& field = getField( aRow );
836
837 switch( aCol )
838 {
839 case FDC_SHOWN: return field.IsVisible();
840 case FDC_SHOW_NAME: return field.IsNameShown();
841 case FDC_ITALIC: return field.IsItalic();
842 case FDC_BOLD: return field.IsBold();
843 case FDC_ALLOW_AUTOPLACE: return field.CanAutoplace();
844 case FDC_PRIVATE: return field.IsPrivate();
845 default:
846 wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a bool value" ), aCol ) );
847 return false;
848 }
849}
850
851
852void FIELDS_GRID_TABLE::SetValue( int aRow, int aCol, const wxString &aValue )
853{
854 wxCHECK( aRow < GetNumberRows(), /*void*/ );
855 SCH_FIELD& field = getField( aRow );
856 VECTOR2I pos;
857 wxString value = aValue;
858
859 if( aCol != FDC_VALUE )
860 value.Trim( true ).Trim( false );
861
862 if( aCol == FDC_TEXT_SIZE || aCol == FDC_POSX || aCol == FDC_POSY )
863 {
864 m_eval->SetDefaultUnits( m_frame->GetUserUnits() );
865
866 if( m_eval->Process( value ) )
867 {
868 m_evalOriginal[ { aRow, aCol } ] = value;
869 value = m_eval->Result();
870 }
871 }
872
873 switch( aCol )
874 {
875 case FDC_NAME:
876 field.SetName( value );
877 break;
878
879 case FDC_VALUE:
881 {
883 }
884 else if( m_parentType == LIB_SYMBOL_T && field.GetId() == FIELD_T::VALUE )
885 {
886 value = EscapeString( value, CTX_LIBID );
887 }
888 else if( m_frame )
889 {
890 value = ConvertPathToFileUri( value, &m_frame->Prj() );
891 }
892
893 field.SetText( UnescapeString( value ) );
894 break;
895
896 case FDC_SHOWN:
897 field.SetVisible( BoolFromString( value ) );
898 break;
899
900 case FDC_SHOW_NAME:
901 field.SetNameShown( BoolFromString( value ) );
902 break;
903
904 case FDC_H_ALIGN:
905 {
906 GR_TEXT_H_ALIGN_T horizontalJustification = GR_TEXT_H_ALIGN_CENTER;
907
908 if( value == _( "Left" ) )
909 horizontalJustification = GR_TEXT_H_ALIGN_LEFT;
910 else if( value == _( "Center" ) )
911 horizontalJustification = GR_TEXT_H_ALIGN_CENTER;
912 else if( value == _( "Right" ) )
913 horizontalJustification = GR_TEXT_H_ALIGN_RIGHT;
914
915 // Note that we must set justifications before we can ask if they're flipped. If the old
916 // justification is center then it won't know (whereas if the new justification is center
917 // the we don't care).
918 field.SetHorizJustify( horizontalJustification );
919
920 if( field.IsHorizJustifyFlipped() )
921 field.SetHorizJustify( EDA_TEXT::MapHorizJustify( - horizontalJustification ) );
922
923 break;
924 }
925
926 case FDC_V_ALIGN:
927 {
928 GR_TEXT_V_ALIGN_T verticalJustification = GR_TEXT_V_ALIGN_BOTTOM;
929
930 if( value == _( "Top" ) )
931 verticalJustification = GR_TEXT_V_ALIGN_TOP;
932 else if( value == _( "Center" ) )
933 verticalJustification = GR_TEXT_V_ALIGN_CENTER;
934 else if( value == _( "Bottom" ) )
935 verticalJustification = GR_TEXT_V_ALIGN_BOTTOM;
936
937 // Note that we must set justifications before we can ask if they're flipped. If the old
938 // justification is center then it won't know (whereas if the new justification is center
939 // the we don't care).
940 field.SetVertJustify( verticalJustification );
941
942 if( field.IsVertJustifyFlipped() )
943 field.SetVertJustify( EDA_TEXT::MapVertJustify( -verticalJustification ) );
944
945 break;
946 }
947
948 case FDC_ITALIC:
949 field.SetItalic( BoolFromString( value ) );
950 break;
951
952 case FDC_BOLD:
953 field.SetBold( BoolFromString( value ) );
954 break;
955
956 case FDC_TEXT_SIZE:
957 field.SetTextSize( VECTOR2I( m_frame->ValueFromString( value ), m_frame->ValueFromString( value ) ) );
958 break;
959
960 case FDC_ORIENTATION:
961 if( value == _( "Horizontal" ) )
963 else if( value == _( "Vertical" ) )
965 else
966 wxFAIL_MSG( wxT( "unknown orientation: " ) + value );
967
968 break;
969
970 case FDC_POSX:
971 case FDC_POSY:
972 pos = field.GetTextPos();
973
974 if( aCol == FDC_POSX )
975 pos.x = m_frame->ValueFromString( value );
976 else
977 pos.y = m_frame->ValueFromString( value );
978
979 field.SetTextPos( pos );
980 break;
981
982 case FDC_FONT:
983 if( value == DEFAULT_FONT_NAME )
984 field.SetFont( nullptr );
985 else if( value == KICAD_FONT_NAME )
986 field.SetFont( KIFONT::FONT::GetFont( wxEmptyString, field.IsBold(), field.IsItalic() ) );
987 else
988 field.SetFont( KIFONT::FONT::GetFont( aValue, field.IsBold(), field.IsItalic() ) );
989
990 break;
991
992 case FDC_COLOR:
993 field.SetTextColor( wxColor( value ) );
994 break;
995
997 field.SetCanAutoplace( BoolFromString( value ) );
998 break;
999
1000 case FDC_PRIVATE:
1001 field.SetPrivate( BoolFromString( value ) );
1002 break;
1003
1004 default:
1005 wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a string value" ), aCol ) );
1006 break;
1007 }
1008
1009 m_dialog->OnModify();
1010
1011 GetView()->Refresh();
1012}
1013
1014
1015void FIELDS_GRID_TABLE::SetValueAsBool( int aRow, int aCol, bool aValue )
1016{
1017 wxCHECK( aRow < GetNumberRows(), /*void*/ );
1018 SCH_FIELD& field = getField( aRow );
1019
1020 switch( aCol )
1021 {
1022 case FDC_SHOWN:
1023 field.SetVisible( aValue );
1024 break;
1025
1026 case FDC_SHOW_NAME:
1027 field.SetNameShown( aValue );
1028 break;
1029
1030 case FDC_ITALIC:
1031 field.SetItalic( aValue );
1032 break;
1033
1034 case FDC_BOLD:
1035 field.SetBold( aValue );
1036 break;
1037
1039 field.SetCanAutoplace( aValue );
1040 break;
1041
1042 case FDC_PRIVATE:
1043 field.SetPrivate( aValue );
1044 break;
1045
1046 default:
1047 wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a bool value" ), aCol ) );
1048 break;
1049 }
1050
1051 m_dialog->OnModify();
1052}
1053
1054
1055wxString FIELDS_GRID_TABLE::StringFromBool( bool aValue ) const
1056{
1057 if( aValue )
1058 return wxT( "1" );
1059 else
1060 return wxT( "0" );
1061}
1062
1063
1064bool FIELDS_GRID_TABLE::BoolFromString( const wxString& aValue ) const
1065{
1066 if( aValue == wxS( "1" ) )
1067 {
1068 return true;
1069 }
1070 else if( aValue == wxS( "0" ) )
1071 {
1072 return false;
1073 }
1074 else
1075 {
1076 wxFAIL_MSG( wxString::Format( "string '%s' can't be converted to boolean correctly and "
1077 "will be perceived as FALSE", aValue ) );
1078 return false;
1079 }
1080}
1081
1082
1084{
1085 for( SCH_FIELD& field : *this )
1086 {
1087 if( field.GetId() == aFieldId )
1088 return &field;
1089 }
1090
1091 return nullptr;
1092}
1093
1094
1096{
1097 int visibleRow = 0;
1098
1099 for( const SCH_FIELD& field : *this )
1100 {
1101 if( field.GetId() == aFieldId )
1102 return privateFieldsAreHidden() && field.IsPrivate() ? -1 : visibleRow;
1103
1104 if( !privateFieldsAreHidden() || !field.IsPrivate() )
1105 ++visibleRow;
1106 }
1107
1108 return -1;
1109}
1110
1111
1112bool FIELDS_GRID_TABLE::IsInherited( size_t aRow ) const
1113{
1114 int fieldIndex = getFieldIndex( static_cast<int>( aRow ) );
1115
1116 if( fieldIndex < 0 || fieldIndex >= static_cast<int>( m_inheritance.size() ) )
1117 return false;
1118
1119 const INHERITANCE& inheritance = m_inheritance[fieldIndex];
1120
1121 // Any edit, including position or visibility, turns the row into an override
1122 return inheritance.m_derived && at( fieldIndex ).HasSameContent( inheritance.m_parentField );
1123}
1124
1125
1127{
1128 return m_inheritance.at( getFieldIndex( static_cast<int>( aRow ) ) ).m_parentField;
1129}
1130
1131
1132const wxString& FIELDS_GRID_TABLE::InheritedFrom( size_t aRow ) const
1133{
1134 return m_inheritance.at( getFieldIndex( static_cast<int>( aRow ) ) ).m_source;
1135}
1136
1137
1138void FIELDS_GRID_TABLE::AddInheritedField( const SCH_FIELD& aParent, const wxString& aSource )
1139{
1140 push_back( aParent );
1141 back().SetParent( m_part );
1142 m_inheritance.back().m_derived = true;
1143 SetFieldInherited( size() - 1, aParent, aSource );
1144}
1145
1146
1147void FIELDS_GRID_TABLE::SetFieldInherited( size_t aFieldIndex, const SCH_FIELD& aParent, const wxString& aSource )
1148{
1149 wxCHECK( aFieldIndex < size() && aFieldIndex < m_inheritance.size(), /*void*/ );
1150
1151 INHERITANCE& inheritance = m_inheritance[aFieldIndex];
1152 SCH_FIELD& field = at( aFieldIndex );
1153
1154 // Flatten() gives an empty mandatory field the ancestor's value, but any user field the symbol owns wins
1155 if( inheritance.m_derived || ( field.IsMandatory() && field.GetText().IsEmpty() ) )
1156 {
1157 field = aParent;
1158 inheritance.m_derived = true;
1159 }
1160
1161 inheritance.m_parentField = aParent;
1162 inheritance.m_parentField.SetParent( nullptr );
1163 inheritance.m_source = aSource;
1164 inheritance.m_hasParent = true;
1165}
1166
1167
1169{
1170 int fieldIndex = getFieldIndex( static_cast<int>( aRow ) );
1171
1172 if( fieldIndex < 0 )
1173 return false;
1174
1175 if( m_inheritance.size() > static_cast<size_t>( fieldIndex ) )
1176 {
1177 INHERITANCE& inheritance = m_inheritance[fieldIndex];
1178
1179 // You can't erase inherited fields, but you can reset them to the parent value.
1180 if( inheritance.m_hasParent )
1181 {
1182 at( fieldIndex ) = inheritance.m_parentField;
1183 inheritance.m_derived = true;
1184 return false;
1185 }
1186
1187 m_inheritance.erase( m_inheritance.begin() + fieldIndex );
1188 }
1189
1190 std::vector<SCH_FIELD>::erase( begin() + fieldIndex );
1191 return true;
1192}
1193
1194void FIELDS_GRID_TABLE::SwapRows( size_t a, size_t b )
1195{
1196 int fieldIndexA = getFieldIndex( static_cast<int>( a ) );
1197 int fieldIndexB = getFieldIndex( static_cast<int>( b ) );
1198
1199 wxCHECK( fieldIndexA >= 0 && fieldIndexB >= 0, /*void*/ );
1200 wxCHECK( fieldIndexA < static_cast<int>( m_inheritance.size() )
1201 && fieldIndexB < static_cast<int>( m_inheritance.size() ),
1202 /*void*/ );
1203
1204 std::swap( at( fieldIndexA ), at( fieldIndexB ) );
1205 std::swap( m_inheritance[fieldIndexA], m_inheritance[fieldIndexB] );
1206}
1207
1208
1210{
1211 for( SCH_FIELD& field : *this )
1212 field.SetParent( nullptr );
1213
1214 for( INHERITANCE& inheritance : m_inheritance )
1215 inheritance.m_parentField.SetParent( nullptr );
1216}
1217
1218
1220{
1221 return static_cast<FIELDS_GRID_TABLE*>( m_grid->GetTable() )->GetFieldRow( aFieldId );
1222}
1223
1224
1225void FIELDS_GRID_TRICKS::showPopupMenu( wxMenu& menu, wxGridEvent& aEvent )
1226{
1227 if( m_grid->GetGridCursorRow() == getFieldRow( FIELD_T::FOOTPRINT )
1228 && m_grid->GetGridCursorCol() == FDC_VALUE
1229 && !m_grid->IsReadOnly( getFieldRow( FIELD_T::FOOTPRINT ), FDC_VALUE ) )
1230 {
1231 menu.Append( MYID_SELECT_FOOTPRINT, _( "Select Footprint..." ), _( "Browse for footprint" ) );
1232 menu.AppendSeparator();
1233 }
1234 else if( m_grid->GetGridCursorRow() == getFieldRow( FIELD_T::DATASHEET )
1235 && m_grid->GetGridCursorCol() == FDC_VALUE
1236 && !m_grid->IsReadOnly( getFieldRow( FIELD_T::DATASHEET ), FDC_VALUE ) )
1237 {
1238 menu.Append( MYID_SHOW_DATASHEET, _( "Show Datasheet" ), _( "Show datasheet in browser" ) );
1239 menu.AppendSeparator();
1240 }
1241
1242 GRID_TRICKS::showPopupMenu( menu, aEvent );
1243}
1244
1245
1246void FIELDS_GRID_TRICKS::doPopupSelection( wxCommandEvent& event )
1247{
1248 if( event.GetId() == MYID_SELECT_FOOTPRINT )
1249 {
1250 // pick a footprint using the footprint picker.
1251 wxString fpid = m_grid->GetCellValue( getFieldRow( FIELD_T::FOOTPRINT ), FDC_VALUE );
1252
1253 if( SelectFootprintFromChooser( m_dlg, fpid ) )
1254 m_grid->SetCellValue( getFieldRow( FIELD_T::FOOTPRINT ), FDC_VALUE, fpid );
1255 }
1256 else if (event.GetId() == MYID_SHOW_DATASHEET )
1257 {
1258 wxString datasheet_uri = m_grid->GetCellValue( getFieldRow( FIELD_T::DATASHEET ), FDC_VALUE );
1259
1260 GetAssociatedDocument( m_dlg, datasheet_uri, &m_dlg->Prj(), PROJECT_SCH::SchSearchS( &m_dlg->Prj() ),
1261 m_filesStack );
1262 }
1263 else
1264 {
1266 }
1267}
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
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)
Definition font.cpp:144
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
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:75
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:44
void SetupColumnAutosizer(int aFlexibleCol)
Set autosize behaviour using wxFormBuilder column widths as minimums, with a single specified growabl...
Definition wx_grid.cpp:1161
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:880
#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:47
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.