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 <embedded_files.h>
21#include <kiway.h>
22#include <kiway_player.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
59static wxString netList( SCH_SYMBOL* aSymbol, SCH_SHEET_PATH& aSheetPath )
60{
61 /*
62 * Symbol netlist format:
63 * pinNumber pinName <tab> pinNumber pinName...
64 * fpFilter fpFilter...
65 */
66 wxString netlist;
67
68 // We need the list of pins of the lib symbol, not just the pins of the current
69 // sch symbol, that can be just an unit of a multi-unit symbol, to be able to
70 // select/filter right footprints
71 wxArrayString pins;
72
73 const std::unique_ptr< LIB_SYMBOL >& lib_symbol = aSymbol->GetLibSymbolRef();
74
75 if( lib_symbol )
76 {
77 for( SCH_PIN* pin : lib_symbol->GetGraphicalPins( 0 /* all units */, 1 /* single bodyStyle */ ) )
78 {
79 bool valid = false;
80 std::vector<wxString> expanded = pin->GetStackedPinNumbers( &valid );
81
82 if( valid && !expanded.empty() )
83 {
84 for( const wxString& num : expanded )
85 pins.push_back( num + ' ' + pin->GetShownName() );
86 }
87 else
88 {
89 pins.push_back( pin->GetNumber() + ' ' + pin->GetShownName() );
90 }
91 }
92 }
93
94 if( !pins.IsEmpty() )
95 {
96 wxString dbg = wxJoin( pins, '\t' );
97 wxLogTrace( "FOOTPRINT_CHOOSER", wxS( "Chooser payload pins: %s" ), dbg );
98 netlist << EscapeString( dbg, CTX_LINE );
99 }
100
101 netlist << wxS( "\r" );
102
103 if( lib_symbol )
104 {
105 wxArrayString fpFilters = lib_symbol->GetFPFilters();
106
107 if( !fpFilters.IsEmpty() )
108 netlist << EscapeString( wxJoin( fpFilters, ' ' ), CTX_LINE );
109 }
110
111 netlist << wxS( "\r" );
112
113 return netlist;
114}
115
116
117static wxString netList( LIB_SYMBOL* aSymbol )
118{
119 /*
120 * Symbol netlist format:
121 * pinNumber pinName <tab> pinNumber pinName...
122 * fpFilter fpFilter...
123 */
124 wxString netlist;
125 wxArrayString pins;
126
127 for( SCH_PIN* pin : aSymbol->GetGraphicalPins( 0 /* all units */, 1 /* single bodyStyle */ ) )
128 {
129 bool valid = false;
130 std::vector<wxString> expanded = pin->GetStackedPinNumbers( &valid );
131
132 if( valid && !expanded.empty() )
133 {
134 for( const wxString& num : expanded )
135 pins.push_back( num + ' ' + pin->GetShownName() );
136 }
137 else
138 {
139 pins.push_back( pin->GetNumber() + ' ' + pin->GetShownName() );
140 }
141 }
142
143 if( !pins.IsEmpty() )
144 {
145 wxString dbg = wxJoin( pins, '\t' );
146 wxLogTrace( "FOOTPRINT_CHOOSER", wxS( "Chooser payload pins: %s" ), dbg );
147 netlist << EscapeString( dbg, CTX_LINE );
148 }
149
150 netlist << wxS( "\r" );
151
152 wxArrayString fpFilters = aSymbol->GetFPFilters();
153
154 if( !fpFilters.IsEmpty() )
155 netlist << EscapeString( wxJoin( fpFilters, ' ' ), CTX_LINE );
156
157 netlist << wxS( "\r" );
158
159 return netlist;
160}
161
162
164 LIB_SYMBOL* aSymbol, std::vector<EMBEDDED_FILES*> aFilesStack ) :
165 m_frame( aFrame ),
166 m_dialog( aDialog ),
168 m_part( aSymbol ),
169 m_filesStack( aFilesStack ),
170 m_symbolNetlist( netList( aSymbol ) ),
177{
178 initGrid( aGrid );
179}
180
181
183 SCH_SYMBOL* aSymbol ) :
184 m_frame( aFrame ),
185 m_dialog( aDialog ),
187 m_part( nullptr ),
188 m_symbolNetlist( netList( aSymbol, aFrame->GetCurrentSheet() ) ),
195{
196 // GetLibSymbolRef() hands back a raw pointer into a unique_ptr owned by the schematic symbol.
197 // This dialog is quasi-modal, so the still-live schematic can free that part through
198 // SetLibSymbol() (library update, ERC, undo) while the grid is open, after which GetAttr() would
199 // dereference freed memory. Keep a private copy alive for the grid's lifetime instead.
200 if( LIB_SYMBOL* libSymbol = aSymbol->GetLibSymbolRef().get() )
201 {
202 m_ownedPart = std::make_unique<LIB_SYMBOL>( *libSymbol );
203 m_part = m_ownedPart.get();
204 }
205
206 m_filesStack.push_back( aSymbol->Schematic() );
207
208 if( m_part )
209 m_filesStack.push_back( m_part );
210
211 initGrid( aGrid );
212}
213
214
216 SCH_SHEET* aSheet ) :
217 m_frame( aFrame ),
218 m_dialog( aDialog ),
220 m_part( nullptr ),
227{
228 m_filesStack.push_back( aSheet->Schematic() );
229
230 initGrid( aGrid );
231}
232
233
235 SCH_LABEL_BASE* aLabel ) :
236 m_frame( aFrame ),
237 m_dialog( aDialog ),
239 m_part( nullptr ),
246{
247 m_filesStack.push_back( aLabel->Schematic() );
248
249 initGrid( aGrid );
250}
251
252
254{
255 int mandatoryRows = 0;
256
257 for( const SCH_FIELD& field : *this )
258 {
259 if( field.IsMandatory() )
260 mandatoryRows++;
261 }
262
263 return mandatoryRows;
264}
265
266
268{
269 std::vector<SCH_FIELD>::push_back( aField );
270
271 m_isInherited.resize( size() );
272 m_parentFields.resize( size() );
273}
274
275
277{
278 // Build the various grid cell attributes.
279 // NOTE: validators and cellAttrs are member variables to get the destruction order
280 // right. wxGrid is VERY cranky about this.
281
282 m_readOnlyAttr = new wxGridCellAttr;
283 m_readOnlyAttr->SetReadOnly( true );
284
285 m_fieldNameAttr = new wxGridCellAttr;
287 nameEditor->SetValidator( m_fieldNameValidator );
288 m_fieldNameAttr->SetEditor( nameEditor );
289
290 m_referenceAttr = new wxGridCellAttr;
291 GRID_CELL_TEXT_EDITOR* referenceEditor = new GRID_CELL_TEXT_EDITOR();
292 referenceEditor->SetValidator( m_referenceValidator );
293 m_referenceAttr->SetEditor( referenceEditor );
294
295 m_valueAttr = new wxGridCellAttr;
296
298 {
299 GRID_CELL_TEXT_EDITOR* valueEditor = new GRID_CELL_TEXT_EDITOR();
300 valueEditor->SetValidator( m_valueValidator );
301 m_valueAttr->SetEditor( valueEditor );
302 }
303 else
304 {
305 GRID_CELL_STC_EDITOR* valueEditor = new GRID_CELL_STC_EDITOR( true, true,
306 [this]( wxStyledTextEvent& aEvent, SCINTILLA_TRICKS* aScintillaTricks )
307 {
308 SCH_FIELD* valueField = this->GetField( FIELD_T::VALUE );
309 valueField->OnScintillaCharAdded( aScintillaTricks, aEvent );
310 } );
311
312 m_valueAttr->SetEditor( valueEditor );
313 }
314
315 m_footprintAttr = new wxGridCellAttr;
317 fpIdEditor->SetValidator( m_nonUrlValidator );
318 m_footprintAttr->SetEditor( fpIdEditor );
319
320 m_urlAttr = new wxGridCellAttr;
321 SEARCH_STACK* prjSearchStack = PROJECT_SCH::SchSearchS( &m_frame->Prj() );
322 GRID_CELL_URL_EDITOR* urlEditor = new GRID_CELL_URL_EDITOR( m_dialog, prjSearchStack, m_filesStack );
323 urlEditor->SetValidator( m_urlValidator );
324 m_urlAttr->SetEditor( urlEditor );
325
326 m_nonUrlAttr = new wxGridCellAttr;
327 GRID_CELL_TEXT_EDITOR* nonUrlEditor = new GRID_CELL_TEXT_EDITOR();
328 nonUrlEditor->SetValidator( m_nonUrlValidator );
329 m_nonUrlAttr->SetEditor( nonUrlEditor );
330
331 m_curdir = m_frame->Prj().GetProjectPath();
332 m_filepathAttr = new wxGridCellAttr;
333
334 // Create a wild card using wxFileDialog syntax.
335 wxString wildCard( _( "Schematic Files" ) );
336 std::vector<std::string> exts;
337 exts.push_back( FILEEXT::KiCadSchematicFileExtension );
338 wildCard += AddFileExtListToFilter( exts );
339
340 auto filepathEditor = new GRID_CELL_PATH_EDITOR( m_dialog, aGrid, &m_curdir, wildCard );
341 filepathEditor->SetValidator( m_filepathValidator );
342 m_filepathAttr->SetEditor( filepathEditor );
343
344 m_boolAttr = new wxGridCellAttr;
345 m_boolAttr->SetRenderer( new wxGridCellBoolRenderer() );
346 m_boolAttr->SetEditor( new wxGridCellBoolEditor() );
347 m_boolAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
348
349 wxArrayString vAlignNames;
350 vAlignNames.Add( _( "Top" ) );
351 vAlignNames.Add( _( "Center" ) );
352 vAlignNames.Add( _( "Bottom" ) );
353 m_vAlignAttr = new wxGridCellAttr;
354 m_vAlignAttr->SetEditor( new wxGridCellChoiceEditor( vAlignNames ) );
355 m_vAlignAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
356
357 wxArrayString hAlignNames;
358 hAlignNames.Add( _( "Left" ) );
359 hAlignNames.Add(_( "Center" ) );
360 hAlignNames.Add(_( "Right" ) );
361 m_hAlignAttr = new wxGridCellAttr;
362 m_hAlignAttr->SetEditor( new wxGridCellChoiceEditor( hAlignNames ) );
363 m_hAlignAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
364
365 wxArrayString orientationNames;
366 orientationNames.Add( _( "Horizontal" ) );
367 orientationNames.Add(_( "Vertical" ) );
368 m_orientationAttr = new wxGridCellAttr;
369 m_orientationAttr->SetEditor( new wxGridCellChoiceEditor( orientationNames ) );
370 m_orientationAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
371
372 SCH_EDIT_FRAME* editFrame = dynamic_cast<SCH_EDIT_FRAME*>( m_frame );
373 wxArrayString existingNetclasses;
374
375 wxArrayString fonts;
376 std::vector<std::string> fontNames;
377
378 if( editFrame )
379 {
380 // Load the combobox with existing existingNetclassNames
381 PROJECT_FILE& projectFile = editFrame->Prj().GetProjectFile();
382 const std::shared_ptr<NET_SETTINGS>& settings = projectFile.NetSettings();
383
384 existingNetclasses.push_back( settings->GetDefaultNetclass()->GetName() );
385
386 for( const auto& [name, netclass] : settings->GetNetclasses() )
387 existingNetclasses.push_back( name );
388
389 // We don't need to re-cache the embedded fonts when looking at symbols in the schematic
390 // editor because the fonts are all available in the schematic.
391 const std::vector<wxString>* fontFiles = nullptr;
392
393 if( m_frame->GetScreen() && m_frame->GetScreen()->Schematic() )
394 fontFiles = m_frame->GetScreen()->Schematic()->GetEmbeddedFiles()->GetFontFiles();
395
396 Fontconfig()->ListFonts( fontNames, std::string( Pgm().GetLanguageTag().utf8_str() ),
397 fontFiles, false );
398 }
399 else
400 {
401 const std::vector<wxString>* fontFiles = m_part->GetEmbeddedFiles()->UpdateFontFiles();
402
403 // If there are font files embedded, we want to re-cache our fonts for each symbol that
404 // we are looking at in the symbol editor.
405 Fontconfig()->ListFonts( fontNames, std::string( Pgm().GetLanguageTag().utf8_str() ),
406 fontFiles, !fontFiles->empty() );
407 }
408
409 m_netclassAttr = new wxGridCellAttr;
410 m_netclassAttr->SetEditor( new GRID_CELL_COMBOBOX( existingNetclasses ) );
411
412 for( const std::string& name : fontNames )
413 fonts.Add( wxString( name ) );
414
415 fonts.Sort();
416 fonts.Insert( KICAD_FONT_NAME, 0 );
417 fonts.Insert( DEFAULT_FONT_NAME, 0 );
418
419 m_fontAttr = new wxGridCellAttr;
420 m_fontAttr->SetEditor( new GRID_CELL_COMBOBOX( fonts ) );
421
422 m_colorAttr = new wxGridCellAttr;
423 m_colorAttr->SetRenderer( new GRID_CELL_COLOR_RENDERER( m_dialog ) );
424 m_colorAttr->SetEditor( new GRID_CELL_COLOR_SELECTOR( m_dialog, aGrid ) );
425
426 m_eval = std::make_unique<NUMERIC_EVALUATOR>( m_frame->GetUserUnits() );
427
429
430 m_frame->Bind( EDA_EVT_UNITS_CHANGED, &FIELDS_GRID_TABLE::onUnitsChanged, this );
431}
432
433
435{
436 m_readOnlyAttr->DecRef();
437 m_fieldNameAttr->DecRef();
438 m_boolAttr->DecRef();
439 m_referenceAttr->DecRef();
440 m_valueAttr->DecRef();
441 m_footprintAttr->DecRef();
442 m_urlAttr->DecRef();
443 m_nonUrlAttr->DecRef();
444 m_filepathAttr->DecRef();
445 m_vAlignAttr->DecRef();
446 m_hAlignAttr->DecRef();
447 m_orientationAttr->DecRef();
448 m_netclassAttr->DecRef();
449 m_fontAttr->DecRef();
450 m_colorAttr->DecRef();
451
452 for( SCH_FIELD& field : m_parentFields )
453 field.SetParent( nullptr );
454
455 m_frame->Unbind( EDA_EVT_UNITS_CHANGED, &FIELDS_GRID_TABLE::onUnitsChanged, this );
456}
457
458
459void FIELDS_GRID_TABLE::onUnitsChanged( wxCommandEvent& aEvent )
460{
461 if( GetView() )
462 GetView()->ForceRefresh();
463
464 aEvent.Skip();
465}
466
467
469{
470 if( m_frame->GetFrameType() == FRAME_SCH
471 || m_frame->GetFrameType() == FRAME_SCH_VIEWER )
472 {
473 return FDC_SCH_EDIT_COUNT;
474 }
475 else
476 {
478 }
479}
480
481
483{
484 if( m_frame->GetFrameType() == FRAME_SCH
485 || m_frame->GetFrameType() == FRAME_SCH_VIEWER )
486 {
487 int visibleRows = 0;
488
489 for( const SCH_FIELD& field : *this )
490 {
491 if( !field.IsPrivate() )
492 visibleRows++;
493 }
494
495 return visibleRows;
496 }
497
498 return (int) this->size();
499}
500
501
503{
504 if( m_frame->GetFrameType() == FRAME_SCH
505 || m_frame->GetFrameType() == FRAME_SCH_VIEWER )
506 {
507 int visibleRow = 0;
508
509 for( SCH_FIELD& field : *this )
510 {
511 if( field.IsPrivate() )
512 continue;
513
514 if( visibleRow == aRow )
515 return field;
516
517 ++visibleRow;
518 }
519
520 wxFAIL_MSG( wxT( "Row index off end of visible row count" ) );
521 }
522
523 return this->at( aRow );
524}
525
526
528{
529 switch( aCol )
530 {
531 case FDC_NAME: return _( "Name" );
532 case FDC_VALUE: return _( "Value" );
533 case FDC_SHOWN: return _( "Show" );
534 case FDC_SHOW_NAME: return _( "Show Name" );
535 case FDC_H_ALIGN: return _( "H Align" );
536 case FDC_V_ALIGN: return _( "V Align" );
537 case FDC_ITALIC: return _( "Italic" );
538 case FDC_BOLD: return _( "Bold" );
539 case FDC_TEXT_SIZE: return _( "Text Size" );
540 case FDC_ORIENTATION: return _( "Orientation" );
541 case FDC_POSX: return _( "X Position" );
542 case FDC_POSY: return _( "Y Position" );
543 case FDC_FONT: return _( "Font" );
544 case FDC_COLOR: return _( "Color" );
545 case FDC_ALLOW_AUTOPLACE: return _( "Allow Autoplacement" );
546 case FDC_PRIVATE: return _( "Private" );
547 default: wxFAIL; return wxEmptyString;
548 }
549}
550
551
552bool FIELDS_GRID_TABLE::CanGetValueAs( int aRow, int aCol, const wxString& aTypeName )
553{
554 switch( aCol )
555 {
556 case FDC_NAME:
557 case FDC_VALUE:
558 case FDC_H_ALIGN:
559 case FDC_V_ALIGN:
560 case FDC_TEXT_SIZE:
561 case FDC_ORIENTATION:
562 case FDC_POSX:
563 case FDC_POSY:
564 case FDC_FONT:
565 case FDC_COLOR:
566 return aTypeName == wxGRID_VALUE_STRING;
567
568 case FDC_SHOWN:
569 case FDC_SHOW_NAME:
570 case FDC_ITALIC:
571 case FDC_BOLD:
573 case FDC_PRIVATE:
574 return aTypeName == wxGRID_VALUE_BOOL;
575
576 default:
577 wxFAIL;
578 return false;
579 }
580}
581
582
583bool FIELDS_GRID_TABLE::CanSetValueAs( int aRow, int aCol, const wxString& aTypeName )
584{
585 return CanGetValueAs( aRow, aCol, aTypeName );
586}
587
588
589wxGridCellAttr* FIELDS_GRID_TABLE::GetAttr( int aRow, int aCol, wxGridCellAttr::wxAttrKind aKind )
590{
591 wxCHECK( aRow < GetNumberRows(), nullptr );
592
593 const SCH_FIELD& field = getField( aRow );
594 wxGridCellAttr* attr = nullptr;
595
596 switch( aCol )
597 {
598 case FDC_NAME:
599 if( field.IsMandatory() )
600 {
601 attr = m_fieldNameAttr->Clone();
602 attr->SetReadOnly( true );
603 }
604 else
605 {
606 m_fieldNameAttr->IncRef();
607 attr = m_fieldNameAttr;
608 }
609
610 break;
611
612 case FDC_VALUE:
613 if( field.GetId() == FIELD_T::REFERENCE )
614 {
615 m_referenceAttr->IncRef();
616 attr = m_referenceAttr;
617 }
618 else if( field.GetId() == FIELD_T::VALUE )
619 {
620 m_valueAttr->IncRef();
621 attr = m_valueAttr;
622 }
623 else if( field.GetId() == FIELD_T::FOOTPRINT )
624 {
625 // Power symbols have do not appear in the board, so don't allow
626 // a footprint (m_part can be nullptr when loading a old schematic
627 // (for instance Kicad 4) with libraries missing)
628 if( m_part && m_part->IsPower() )
629 {
630 m_readOnlyAttr->IncRef();
631 attr = m_readOnlyAttr;
632 }
633 else
634 {
635 m_footprintAttr->IncRef();
636 attr = m_footprintAttr;
637 }
638 }
639 else if( field.GetId() == FIELD_T::DATASHEET )
640 {
641 m_urlAttr->IncRef();
642 attr = m_urlAttr;
643 }
644 else if( field.GetId() == FIELD_T::SHEET_NAME )
645 {
646 m_referenceAttr->IncRef();
647 attr = m_referenceAttr;
648 }
649 else if( field.GetId() == FIELD_T::SHEET_FILENAME )
650 {
651 m_filepathAttr->IncRef();
652 attr = m_filepathAttr;
653 }
655 && field.GetCanonicalName() == wxT( "Netclass" ) )
656 {
657 m_netclassAttr->IncRef();
658 attr = m_netclassAttr;
659 }
660 else
661 {
662 wxString fn = GetValue( aRow, FDC_NAME );
663
664 SCHEMATIC_SETTINGS* settings = m_frame->Prj().GetProjectFile().m_SchematicSettings;
665
666 const TEMPLATE_FIELDNAME* templateFn =
667 settings ? settings->m_TemplateFieldNames.GetFieldName( fn ) : nullptr;
668
669 if( ( templateFn && templateFn->m_URL ) || field.HasHypertext() )
670 {
671 m_urlAttr->IncRef();
672 attr = m_urlAttr;
673 }
674 else
675 {
676 m_nonUrlAttr->IncRef();
677 attr = m_nonUrlAttr;
678 }
679 }
680
681 break;
682
683 case FDC_TEXT_SIZE:
684 case FDC_POSX:
685 case FDC_POSY:
686 break;
687
688 case FDC_H_ALIGN:
689 m_hAlignAttr->IncRef();
690 attr = m_hAlignAttr;
691 break;
692
693 case FDC_V_ALIGN:
694 m_vAlignAttr->IncRef();
695 attr = m_vAlignAttr;
696 break;
697
698 case FDC_ORIENTATION:
699 m_orientationAttr->IncRef();
700 attr = m_orientationAttr;
701 break;
702
703 case FDC_SHOWN:
704 case FDC_SHOW_NAME:
705 case FDC_ITALIC:
706 case FDC_BOLD:
708 case FDC_PRIVATE:
709 m_boolAttr->IncRef();
710 attr = m_boolAttr;
711 break;
712
713 case FDC_FONT:
714 m_fontAttr->IncRef();
715 attr = m_fontAttr;
716 break;
717
718 case FDC_COLOR:
719 m_colorAttr->IncRef();
720 attr = m_colorAttr;
721 break;
722
723 default:
724 attr = nullptr;
725 break;
726 }
727
728 if( !attr )
729 return nullptr;
730
731 attr = enhanceAttr( attr, aRow, aCol, aKind );
732
733 if( IsInherited( aRow ) )
734 {
735 wxGridCellAttr* text_attr = attr ? attr->Clone() : new wxGridCellAttr;
736 wxFont font;
737
738 if( !text_attr->HasFont() )
739 font = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
740 else
741 font = text_attr->GetFont();
742
743 font.MakeItalic();
744 text_attr->SetFont( font );
745 text_attr->SetTextColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
746
747 if( attr )
748 attr->DecRef();
749
750 attr = text_attr;
751 }
752
753 return attr;
754}
755
756
757wxString FIELDS_GRID_TABLE::GetValue( int aRow, int aCol )
758{
759 wxCHECK( aRow < GetNumberRows(), wxEmptyString );
760
761 wxGrid* grid = GetView();
762 const SCH_FIELD& field = getField( aRow );
763
764 if( grid->GetGridCursorRow() == aRow && grid->GetGridCursorCol() == aCol
765 && grid->IsCellEditControlShown() )
766 {
767 auto it = m_evalOriginal.find( { aRow, aCol } );
768
769 if( it != m_evalOriginal.end() )
770 return it->second;
771 }
772
773 switch( aCol )
774 {
775 case FDC_NAME:
776 // Use default field names for mandatory and system fields because they are translated
777 // according to the current locale
779 {
781 }
782 else
783 {
784 if( field.IsMandatory() )
785 return GetDefaultFieldName( field.GetId(), DO_TRANSLATE );
786 else
787 return field.GetName( false );
788 }
789
790 case FDC_VALUE:
791 return EscapeString( UnescapeString( field.GetText() ), CTX_LINE );
792
793 case FDC_SHOWN:
794 return StringFromBool( field.IsVisible() );
795
796 case FDC_SHOW_NAME:
797 return StringFromBool( field.IsNameShown() );
798
799 case FDC_H_ALIGN:
800 switch ( field.GetEffectiveHorizJustify() )
801 {
802 case GR_TEXT_H_ALIGN_LEFT: return _( "Left" );
803 case GR_TEXT_H_ALIGN_CENTER: return _( "Center" );
804 case GR_TEXT_H_ALIGN_RIGHT: return _( "Right" );
806 }
807
808 break;
809
810 case FDC_V_ALIGN:
811 switch ( field.GetEffectiveVertJustify() )
812 {
813 case GR_TEXT_V_ALIGN_TOP: return _( "Top" );
814 case GR_TEXT_V_ALIGN_CENTER: return _( "Center" );
815 case GR_TEXT_V_ALIGN_BOTTOM: return _( "Bottom" );
817 }
818
819 break;
820
821 case FDC_ITALIC:
822 return StringFromBool( field.IsItalic() );
823
824 case FDC_BOLD:
825 return StringFromBool( field.IsBold() );
826
827 case FDC_TEXT_SIZE:
828 return m_frame->StringFromValue( field.GetTextHeight(), true );
829
830 case FDC_ORIENTATION:
831 if( field.GetTextAngle().IsHorizontal() )
832 return _( "Horizontal" );
833 else
834 return _( "Vertical" );
835
836 case FDC_POSX:
837 return m_frame->StringFromValue( field.GetTextPos().x, true );
838
839 case FDC_POSY:
840 return m_frame->StringFromValue( field.GetTextPos().y, true );
841
842 case FDC_FONT:
843 if( field.GetFont() )
844 return field.GetFont()->GetName();
845 else
846 return DEFAULT_FONT_NAME;
847
848 case FDC_COLOR:
849 return field.GetTextColor().ToCSSString();
850
852 return StringFromBool( field.CanAutoplace() );
853
854 case FDC_PRIVATE:
855 return StringFromBool( field.IsPrivate() );
856
857 default:
858 // we can't assert here because wxWidgets sometimes calls this without checking
859 // the column type when trying to see if there's an overflow
860 break;
861 }
862
863 return wxT( "bad wxWidgets!" );
864}
865
866
867bool FIELDS_GRID_TABLE::GetValueAsBool( int aRow, int aCol )
868{
869 wxCHECK( aRow < GetNumberRows(), false );
870 const SCH_FIELD& field = getField( aRow );
871
872 switch( aCol )
873 {
874 case FDC_SHOWN: return field.IsVisible();
875 case FDC_SHOW_NAME: return field.IsNameShown();
876 case FDC_ITALIC: return field.IsItalic();
877 case FDC_BOLD: return field.IsBold();
878 case FDC_ALLOW_AUTOPLACE: return field.CanAutoplace();
879 case FDC_PRIVATE: return field.IsPrivate();
880 default:
881 wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a bool value" ), aCol ) );
882 return false;
883 }
884}
885
886
887void FIELDS_GRID_TABLE::SetValue( int aRow, int aCol, const wxString &aValue )
888{
889 wxCHECK( aRow < GetNumberRows(), /*void*/ );
890 SCH_FIELD& field = getField( aRow );
891 VECTOR2I pos;
892 wxString value = aValue;
893
894 if( aCol != FDC_VALUE )
895 value.Trim( true ).Trim( false );
896
897 if( aCol == FDC_TEXT_SIZE || aCol == FDC_POSX || aCol == FDC_POSY )
898 {
899 m_eval->SetDefaultUnits( m_frame->GetUserUnits() );
900
901 if( m_eval->Process( value ) )
902 {
903 m_evalOriginal[ { aRow, aCol } ] = value;
904 value = m_eval->Result();
905 }
906 }
907
908 switch( aCol )
909 {
910 case FDC_NAME:
911 field.SetName( value );
912 break;
913
914 case FDC_VALUE:
916 {
918 }
919 else if( m_parentType == LIB_SYMBOL_T && field.GetId() == FIELD_T::VALUE )
920 {
921 value = EscapeString( value, CTX_LIBID );
922 }
923 else if( m_frame )
924 {
925 value = ConvertPathToFileUri( value, &m_frame->Prj() );
926 }
927
928 field.SetText( UnescapeString( value ) );
929 break;
930
931 case FDC_SHOWN:
932 field.SetVisible( BoolFromString( value ) );
933 break;
934
935 case FDC_SHOW_NAME:
936 field.SetNameShown( BoolFromString( value ) );
937 break;
938
939 case FDC_H_ALIGN:
940 {
941 GR_TEXT_H_ALIGN_T horizontalJustification = GR_TEXT_H_ALIGN_CENTER;
942
943 if( value == _( "Left" ) )
944 horizontalJustification = GR_TEXT_H_ALIGN_LEFT;
945 else if( value == _( "Center" ) )
946 horizontalJustification = GR_TEXT_H_ALIGN_CENTER;
947 else if( value == _( "Right" ) )
948 horizontalJustification = GR_TEXT_H_ALIGN_RIGHT;
949
950 // Note that we must set justifications before we can ask if they're flipped. If the old
951 // justification is center then it won't know (whereas if the new justification is center
952 // the we don't care).
953 field.SetHorizJustify( horizontalJustification );
954
955 if( field.IsHorizJustifyFlipped() )
956 field.SetHorizJustify( EDA_TEXT::MapHorizJustify( - horizontalJustification ) );
957
958 break;
959 }
960
961 case FDC_V_ALIGN:
962 {
963 GR_TEXT_V_ALIGN_T verticalJustification = GR_TEXT_V_ALIGN_BOTTOM;
964
965 if( value == _( "Top" ) )
966 verticalJustification = GR_TEXT_V_ALIGN_TOP;
967 else if( value == _( "Center" ) )
968 verticalJustification = GR_TEXT_V_ALIGN_CENTER;
969 else if( value == _( "Bottom" ) )
970 verticalJustification = GR_TEXT_V_ALIGN_BOTTOM;
971
972 // Note that we must set justifications before we can ask if they're flipped. If the old
973 // justification is center then it won't know (whereas if the new justification is center
974 // the we don't care).
975 field.SetVertJustify( verticalJustification );
976
977 if( field.IsVertJustifyFlipped() )
978 field.SetVertJustify( EDA_TEXT::MapVertJustify( -verticalJustification ) );
979
980 break;
981 }
982
983 case FDC_ITALIC:
984 field.SetItalic( BoolFromString( value ) );
985 break;
986
987 case FDC_BOLD:
988 field.SetBold( BoolFromString( value ) );
989 break;
990
991 case FDC_TEXT_SIZE:
992 field.SetTextSize( VECTOR2I( m_frame->ValueFromString( value ), m_frame->ValueFromString( value ) ) );
993 break;
994
995 case FDC_ORIENTATION:
996 if( value == _( "Horizontal" ) )
998 else if( value == _( "Vertical" ) )
1000 else
1001 wxFAIL_MSG( wxT( "unknown orientation: " ) + value );
1002
1003 break;
1004
1005 case FDC_POSX:
1006 case FDC_POSY:
1007 pos = field.GetTextPos();
1008
1009 if( aCol == FDC_POSX )
1010 pos.x = m_frame->ValueFromString( value );
1011 else
1012 pos.y = m_frame->ValueFromString( value );
1013
1014 field.SetTextPos( pos );
1015 break;
1016
1017 case FDC_FONT:
1018 if( value == DEFAULT_FONT_NAME )
1019 field.SetFont( nullptr );
1020 else if( value == KICAD_FONT_NAME )
1021 field.SetFont( KIFONT::FONT::GetFont( wxEmptyString, field.IsBold(), field.IsItalic() ) );
1022 else
1023 field.SetFont( KIFONT::FONT::GetFont( aValue, field.IsBold(), field.IsItalic() ) );
1024
1025 break;
1026
1027 case FDC_COLOR:
1028 field.SetTextColor( wxColor( value ) );
1029 break;
1030
1032 field.SetCanAutoplace( BoolFromString( value ) );
1033 break;
1034
1035 case FDC_PRIVATE:
1036 field.SetPrivate( BoolFromString( value ) );
1037 break;
1038
1039 default:
1040 wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a string value" ), aCol ) );
1041 break;
1042 }
1043
1044 m_dialog->OnModify();
1045
1046 GetView()->Refresh();
1047}
1048
1049
1050void FIELDS_GRID_TABLE::SetValueAsBool( int aRow, int aCol, bool aValue )
1051{
1052 wxCHECK( aRow < GetNumberRows(), /*void*/ );
1053 SCH_FIELD& field = getField( aRow );
1054
1055 switch( aCol )
1056 {
1057 case FDC_SHOWN:
1058 field.SetVisible( aValue );
1059 break;
1060
1061 case FDC_SHOW_NAME:
1062 field.SetNameShown( aValue );
1063 break;
1064
1065 case FDC_ITALIC:
1066 field.SetItalic( aValue );
1067 break;
1068
1069 case FDC_BOLD:
1070 field.SetBold( aValue );
1071 break;
1072
1074 field.SetCanAutoplace( aValue );
1075 break;
1076
1077 case FDC_PRIVATE:
1078 field.SetPrivate( aValue );
1079 break;
1080
1081 default:
1082 wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a bool value" ), aCol ) );
1083 break;
1084 }
1085
1086 m_dialog->OnModify();
1087}
1088
1089
1090wxString FIELDS_GRID_TABLE::StringFromBool( bool aValue ) const
1091{
1092 if( aValue )
1093 return wxT( "1" );
1094 else
1095 return wxT( "0" );
1096}
1097
1098
1099bool FIELDS_GRID_TABLE::BoolFromString( const wxString& aValue ) const
1100{
1101 if( aValue == wxS( "1" ) )
1102 {
1103 return true;
1104 }
1105 else if( aValue == wxS( "0" ) )
1106 {
1107 return false;
1108 }
1109 else
1110 {
1111 wxFAIL_MSG( wxString::Format( "string '%s' can't be converted to boolean correctly and "
1112 "will be perceived as FALSE", aValue ) );
1113 return false;
1114 }
1115}
1116
1117
1119{
1120 for( SCH_FIELD& field : *this )
1121 {
1122 if( field.GetId() == aFieldId )
1123 return &field;
1124 }
1125
1126 return nullptr;
1127}
1128
1129
1131{
1132 for( int ii = 0; ii < (int) this->size(); ++ii )
1133 {
1134 if( this->at( ii ).GetId() == aFieldId )
1135 return ii;
1136 }
1137
1138 return -1;
1139}
1140
1142{
1143 push_back( aParent );
1144 back().SetParent( m_part );
1145 m_isInherited.back() = true;
1146 m_parentFields.back() = aParent;
1147}
1148
1150{
1151 if( m_isInherited.size() > aRow )
1152 {
1153 // You can't erase inherited fields, but you can reset them to the parent value.
1154 if( m_isInherited[aRow] )
1155 {
1156 at( aRow ) = m_parentFields[aRow];
1157 return false;
1158 }
1159
1160 m_isInherited.erase( m_isInherited.begin() + aRow );
1161 }
1162
1163 if( m_parentFields.size() > aRow )
1164 m_parentFields.erase( m_parentFields.begin() + aRow );
1165
1166 std::vector<SCH_FIELD>::erase( begin() + aRow );
1167 return true;
1168}
1169
1170void FIELDS_GRID_TABLE::SwapRows( size_t a, size_t b )
1171{
1172 wxCHECK( a < this->size() && b < this->size(), /*void*/ );
1173
1174 std::swap( at( a ), at( b ) );
1175
1176 bool tmpInherited = m_isInherited[a];
1178 m_isInherited[b] = tmpInherited;
1179
1180 std::swap( m_parentFields[a], m_parentFields[b] );
1181}
1182
1183
1185{
1186 for( SCH_FIELD& field : *this )
1187 field.SetParent( nullptr );
1188
1189 for( SCH_FIELD& field : m_parentFields )
1190 field.SetParent( nullptr );
1191}
1192
1193
1195{
1196 return static_cast<FIELDS_GRID_TABLE*>( m_grid->GetTable() )->GetFieldRow( aFieldId );
1197}
1198
1199
1200void FIELDS_GRID_TRICKS::showPopupMenu( wxMenu& menu, wxGridEvent& aEvent )
1201{
1202 if( m_grid->GetGridCursorRow() == getFieldRow( FIELD_T::FOOTPRINT )
1203 && m_grid->GetGridCursorCol() == FDC_VALUE
1204 && !m_grid->IsReadOnly( getFieldRow( FIELD_T::FOOTPRINT ), FDC_VALUE ) )
1205 {
1206 menu.Append( MYID_SELECT_FOOTPRINT, _( "Select Footprint..." ), _( "Browse for footprint" ) );
1207 menu.AppendSeparator();
1208 }
1209 else if( m_grid->GetGridCursorRow() == getFieldRow( FIELD_T::DATASHEET )
1210 && m_grid->GetGridCursorCol() == FDC_VALUE
1211 && !m_grid->IsReadOnly( getFieldRow( FIELD_T::DATASHEET ), FDC_VALUE ) )
1212 {
1213 menu.Append( MYID_SHOW_DATASHEET, _( "Show Datasheet" ), _( "Show datasheet in browser" ) );
1214 menu.AppendSeparator();
1215 }
1216
1217 GRID_TRICKS::showPopupMenu( menu, aEvent );
1218}
1219
1220
1221void FIELDS_GRID_TRICKS::doPopupSelection( wxCommandEvent& event )
1222{
1223 if( event.GetId() == MYID_SELECT_FOOTPRINT )
1224 {
1225 // pick a footprint using the footprint picker.
1226 wxString fpid = m_grid->GetCellValue( getFieldRow( FIELD_T::FOOTPRINT ), FDC_VALUE );
1227
1228 if( KIWAY_PLAYER* frame = m_dlg->Kiway().Player( FRAME_FOOTPRINT_CHOOSER, true, m_dlg ) )
1229 {
1230 if( frame->ShowModal( &fpid, m_dlg ) )
1231 m_grid->SetCellValue( getFieldRow( FIELD_T::FOOTPRINT ), FDC_VALUE, fpid );
1232
1233 frame->Destroy();
1234 }
1235 }
1236 else if (event.GetId() == MYID_SHOW_DATASHEET )
1237 {
1238 wxString datasheet_uri = m_grid->GetCellValue( getFieldRow( FIELD_T::DATASHEET ), FDC_VALUE );
1239
1240 GetAssociatedDocument( m_dlg, datasheet_uri, &m_dlg->Prj(), PROJECT_SCH::SchSearchS( &m_dlg->Prj() ),
1241 m_filesStack );
1242 }
1243 else
1244 {
1246 }
1247}
1248
1249
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:142
virtual void SetParent(EDA_ITEM *aParent)
Definition eda_item.cpp:89
void SetTextColor(const COLOR4D &aColor)
Definition eda_text.h:290
COLOR4D GetTextColor() const
Definition eda_text.h:291
virtual VECTOR2I GetTextPos() const
Definition eda_text.h:294
bool IsItalic() const
Definition eda_text.h:190
virtual void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true)
Definition eda_text.cpp:532
virtual bool IsVisible() const
Definition eda_text.h:208
virtual void SetTextPos(const VECTOR2I &aPoint)
Definition eda_text.cpp:576
virtual int GetTextHeight() const
Definition eda_text.h:288
KIFONT::FONT * GetFont() const
Definition eda_text.h:268
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
Definition eda_text.cpp:412
virtual void SetVisible(bool aVisible)
Definition eda_text.cpp:381
static GR_TEXT_H_ALIGN_T MapHorizJustify(int aHorizJustify)
Definition eda_text.cpp:70
virtual EDA_ANGLE GetTextAngle() const
Definition eda_text.h:168
void SetBold(bool aBold)
Set the text to be bold - this will also update the font if needed.
Definition eda_text.cpp:330
bool IsBold() const
Definition eda_text.h:205
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:294
void SetItalic(bool aItalic)
Set the text to be italic - this will also update the font if needed.
Definition eda_text.cpp:302
void SetFont(KIFONT::FONT *aFont)
Definition eda_text.cpp:495
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Definition eda_text.cpp:404
wxGridCellAttr * GetAttr(int aRow, int aCol, wxGridCellAttr::wxAttrKind aKind) override
std::vector< bool > m_isInherited
bool IsInherited(size_t aRow) const
SCH_FIELD * GetField(FIELD_T aFieldId)
wxString StringFromBool(bool aValue) const
bool GetValueAsBool(int aRow, int aCol) override
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
FIELDS_GRID_TABLE(DIALOG_SHIM *aDialog, SCH_BASE_FRAME *aFrame, WX_GRID *aGrid, LIB_SYMBOL *aSymbol, std::vector< EMBEDDED_FILES * > aFilesStack={})
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
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
void AddInheritedField(const SCH_FIELD &aParent)
wxGridCellAttr * m_orientationAttr
void SetValue(int aRow, int aCol, const wxString &aValue) override
wxGridCellAttr * m_vAlignAttr
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
void SwapRows(size_t a, size_t b)
void onUnitsChanged(wxCommandEvent &aEvent)
std::unique_ptr< NUMERIC_EVALUATOR > m_eval
std::vector< SCH_FIELD > m_parentFields
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.
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Define a library symbol object.
Definition lib_symbol.h:114
std::vector< const SCH_PIN * > GetGraphicalPins(int aUnit=0, int aBodyStyle=0) const
Graphical pins: Return schematic pin objects as drawn (unexpanded), filtered by unit/body.
wxArrayString GetFPFilters() const
Definition lib_symbol.h:242
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
These are loaded from Eeschema settings but then overwritten by the project settings.
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:218
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:128
FIELD_T GetId() const
Definition sch_field.h:132
void SetCanAutoplace(bool aCanPlace)
Definition sch_field.h:230
wxString GetCanonicalName() const
Get a non-language-specific name for a field which can be used for storage, variable look-up,...
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:229
void SetText(const wxString &aText) override
void OnScintillaCharAdded(SCINTILLA_TRICKS *aScintillaTricks, wxStyledTextEvent &aEvent) const
void SetNameShown(bool aShown=true)
Definition sch_field.h:219
void SetPrivate(bool aPrivate)
Definition sch_item.h:247
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
Definition sch_item.cpp:268
bool IsPrivate() const
Definition sch_item.h:248
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.
Definition sch_sheet.h:44
Schematic symbol object.
Definition sch_symbol.h:69
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
Definition sch_symbol.h:177
Add cut/copy/paste, dark theme, autocomplete and brace highlighting to a wxStyleTextCtrl instance.
Look for files in a number of paths.
const TEMPLATE_FIELDNAME * GetFieldName(const wxString &aName)
Search for aName in the template field name list.
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:1125
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:792
@ MYID_SELECT_FOOTPRINT
#define _(s)
static constexpr EDA_ANGLE ANGLE_VERTICAL
Definition eda_angle.h:408
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
Definition eda_angle.h:407
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
static wxString netList(SCH_SYMBOL *aSymbol, SCH_SHEET_PATH &aSheetPath)
@ 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
FONTCONFIG * Fontconfig()
@ FRAME_SCH_VIEWER
Definition frame_type.h:32
@ FRAME_SCH
Definition frame_type.h:30
@ FRAME_FOOTPRINT_CHOOSER
Definition frame_type.h:40
@ 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
Hold a name of a symbol's field, field value, and default visibility.
wxString GetDefaultFieldName(FIELD_T aFieldId, bool aTranslateForHI)
Return a default symbol field name for a mandatory field type.
#define DO_TRANSLATE
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".
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:145
@ SCH_SYMBOL_T
Definition typeinfo.h:169
@ SCH_SHEET_T
Definition typeinfo.h:172
@ SCH_LABEL_LOCATE_ANY_T
Definition typeinfo.h:188
#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:683
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.