KiCad PCB EDA Suite
dialog_field_properties.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 (C) 2012 Jean-Pierre Charras, [email protected]
5 * Copyright (C) 2016 Wayne Stambaugh, [email protected]
6 * Copyright (C) 2004-2022 KiCad Developers, see AITHORS.txt for contributors.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
27#include <widgets/font_choice.h>
30#include <bitmaps.h>
31#include <kiway.h>
32#include <confirm.h>
33#include <string_utils.h>
34#include <sch_base_frame.h>
35#include <sch_edit_frame.h>
36#include <ee_collectors.h>
37#include <sch_symbol.h>
38#include <lib_field.h>
39#include <template_fieldnames.h>
40#include <symbol_library.h>
41#include <sch_validators.h>
42#include <schematic.h>
44#include <sch_text.h>
45#include <scintilla_tricks.h>
47
48
50 const EDA_TEXT* aTextItem ) :
51 DIALOG_FIELD_PROPERTIES_BASE( aParent, wxID_ANY, aTitle ),
52 m_posX( aParent, m_xPosLabel, m_xPosCtrl, m_xPosUnits, true ),
53 m_posY( aParent, m_yPosLabel, m_yPosCtrl, m_yPosUnits, true ),
54 m_textSize( aParent, m_textSizeLabel, m_textSizeCtrl, m_textSizeUnits, true ),
55 m_font( nullptr ),
56 m_firstFocus( true ),
57 m_scintillaTricks( nullptr )
58{
59 COLOR_SETTINGS* colorSettings = aParent->GetColorSettings();
60 COLOR4D schematicBackground = colorSettings->GetColor( LAYER_SCHEMATIC_BACKGROUND );
61
62 wxASSERT( aTextItem );
63
64 m_note->SetFont( KIUI::GetInfoFont( this ).Italic() );
65 m_note->Show( false );
66
67 // The field ID and power status are Initialized in the derived object's ctor.
69 m_isPower = false;
70
71 m_scintillaTricks = new SCINTILLA_TRICKS( m_StyledTextCtrl, wxT( "{}" ), true,
72 [this]()
73 {
74 wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
75 } );
76 m_StyledTextCtrl->SetEOLMode( wxSTC_EOL_LF ); // Normalize EOL across platforms
77
78 m_textColorSwatch->SetDefaultColor( COLOR4D::UNSPECIFIED );
79 m_textColorSwatch->SetSwatchBackground( schematicBackground );
80
82
87
89
94
96
103
105
112
114
115 m_horizontal->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onOrientButton, this );
116 m_vertical->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onOrientButton, this );
117
118 m_hAlignLeft->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onHAlignButton, this );
119 m_hAlignCenter->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onHAlignButton, this );
120 m_hAlignRight->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onHAlignButton, this );
121
122 m_vAlignTop->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onVAlignButton, this );
123 m_vAlignCenter->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onVAlignButton, this );
124 m_vAlignBottom->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onVAlignButton, this );
125
126 m_text = aTextItem->GetText();
127 m_isItalic = aTextItem->IsItalic();
128 m_isBold = aTextItem->IsBold();
129 m_color = aTextItem->GetTextColor();
130 m_position = aTextItem->GetTextPos();
131 m_size = aTextItem->GetTextWidth();
132 m_isVertical = aTextItem->GetTextAngle().IsVertical();
135 m_isVisible = aTextItem->IsVisible();
136
137 // These should be initialized in the child classes implementing dialogs for lib and sch items.
138 m_isNameVisible = false;
139 m_allowAutoplace = true;
140}
141
142
144{
145 delete m_scintillaTricks;
146}
147
148
150{
151 SCH_BASE_FRAME* parent = GetParent();
152 bool isSymbolEditor = parent && parent->IsType( FRAME_SCH_SYMBOL_EDITOR );
153
154 // Disable options for graphic text editing which are not needed for fields.
155 m_CommonConvert->Show( false );
156 m_CommonUnit->Show( false );
157
158 // Predefined fields cannot contain some chars, or cannot be empty,
159 // and need a SCH_FIELD_VALIDATOR (m_StyledTextCtrl cannot use a SCH_FIELD_VALIDATOR).
160 bool use_validator = m_fieldId == REFERENCE_FIELD
165
166 if( use_validator )
167 {
168 m_TextCtrl->SetValidator( SCH_FIELD_VALIDATOR( isSymbolEditor, m_fieldId, &m_text ) );
170
171 m_StyledTextCtrl->Show( false );
172 }
173 else
174 {
176
177 m_TextCtrl->Show( false );
178 }
179
180 // Show the footprint selection dialog if this is the footprint field.
183
184 // Value fields of power symbols cannot be modified. This will grey out
185 // the text box and display an explanation.
187 {
188 m_note->SetLabel( wxString::Format( m_note->GetLabel(), _( "Power symbol value field text "
189 "cannot be changed." ) ) );
190 m_note->Show( true );
191 m_TextCtrl->Enable( false );
192 }
193 else
194 {
195 m_TextCtrl->Enable( true );
196 }
197
198 GetSizer()->SetSizeHints( this );
199
200 // Adjust the height of the scintilla text editor after the first layout
201 // To show only one line
202 // (multiline text are is supported in fields and will be removed)
203 if( m_StyledTextCtrl->IsShown() )
204 {
205 wxSize maxSize = m_StyledTextCtrl->GetSize();
206 maxSize.x = -1; // Do not fix the max width
207 maxSize.y = m_xPosCtrl->GetSize().y;
208 m_StyledTextCtrl->SetMaxSize( maxSize );
209 m_StyledTextCtrl->SetUseVerticalScrollBar( false );
210 m_StyledTextCtrl->SetUseHorizontalScrollBar( false );
211 }
212
214
215 // Now all widgets have the size fixed, call FinishDialogSettings
217}
218
219
221{
222 // pick a footprint using the footprint picker.
223 wxString fpid;
224
225 if( m_StyledTextCtrl->IsShown() )
226 fpid = m_StyledTextCtrl->GetValue();
227 else
228 fpid = m_TextCtrl->GetValue();
229
230 if( KIWAY_PLAYER* frame = Kiway().Player( FRAME_FOOTPRINT_VIEWER_MODAL, true ) )
231 {
232 if( frame->ShowModal( &fpid, this ) )
233 {
234 if( m_StyledTextCtrl->IsShown() )
235 m_StyledTextCtrl->SetValue( fpid );
236 else
237 m_TextCtrl->SetValue( fpid );
238 }
239
240 frame->Destroy();
241 }
242}
243
244
246{
247 if( m_firstFocus )
248 {
249#ifdef __WXGTK__
250 // Force an update of the text control before setting the text selection
251 // This is needed because GTK seems to ignore the selection on first update
252 //
253 // Note that we can't do this on OSX as it tends to provoke Apple's
254 // "[NSAlert runModal] may not be invoked inside of transaction begin/commit pair"
255 // bug. See: https://bugs.launchpad.net/kicad/+bug/1837225
257 m_TextCtrl->Update();
258#endif
259
261 KIUI::SelectReferenceNumber( static_cast<wxTextEntry*>( m_TextCtrl ) );
262 else if( m_fieldId == VALUE_FIELD || m_fieldId == SHEETNAME_V )
263 m_TextCtrl->SetSelection( -1, -1 );
264
265 m_firstFocus = false;
266 }
267
268 event.Skip();
269}
270
271
272void DIALOG_FIELD_PROPERTIES::onOrientButton( wxCommandEvent& aEvent )
273{
274 for( BITMAP_BUTTON* btn : { m_horizontal, m_vertical } )
275 {
276 if( btn->IsChecked() && btn != aEvent.GetEventObject() )
277 btn->Check( false );
278 }
279}
280
281
282void DIALOG_FIELD_PROPERTIES::onHAlignButton( wxCommandEvent& aEvent )
283{
285 {
286 if( btn->IsChecked() && btn != aEvent.GetEventObject() )
287 btn->Check( false );
288 }
289}
290
291
292void DIALOG_FIELD_PROPERTIES::onVAlignButton( wxCommandEvent& aEvent )
293{
295 {
296 if( btn->IsChecked() && btn != aEvent.GetEventObject() )
297 btn->Check( false );
298 }
299}
300
301
303{
304 if( m_TextCtrl->IsShown() )
305 {
306 m_TextCtrl->SetValue( m_text );
307 }
308 else if( m_StyledTextCtrl->IsShown() )
309 {
310 m_StyledTextCtrl->SetValue( m_text );
311 m_StyledTextCtrl->EmptyUndoBuffer();
312 }
313
315
319
322
325
327
329 {
330 case GR_TEXT_H_ALIGN_LEFT: m_hAlignLeft->Check( true ); break;
331 case GR_TEXT_H_ALIGN_CENTER: m_hAlignCenter->Check( true ); break;
332 case GR_TEXT_H_ALIGN_RIGHT: m_hAlignRight->Check( true ); break;
333 }
334
335 switch ( m_verticalJustification )
336 {
337 case GR_TEXT_V_ALIGN_TOP: m_vAlignTop->Check( true ); break;
338 case GR_TEXT_V_ALIGN_CENTER: m_vAlignCenter->Check( true ); break;
339 case GR_TEXT_V_ALIGN_BOTTOM: m_vAlignBottom->Check( true ); break;
340 }
341
342 m_visible->SetValue( m_isVisible );
343 m_nameVisible->SetValue( m_isNameVisible );
345
346 return true;
347}
348
349
351{
352 if( m_TextCtrl->IsShown() )
353 m_text = m_TextCtrl->GetValue();
354 else if( m_StyledTextCtrl->IsShown() )
355 m_text = m_StyledTextCtrl->GetValue();
356
358 {
359 // Test if the reference string is valid:
361 {
362 DisplayError( this, _( "Illegal reference designator value!" ) );
363 return false;
364 }
365 }
366 else if( m_fieldId == SHEETFILENAME_V )
367 {
368 wxFileName fn( m_text );
369
370 // It's annoying to throw up nag dialogs when the extension isn't right. Just
371 // fix it.
372 if( fn.GetExt().CmpNoCase( KiCadSchematicFileExtension ) != 0 )
373 {
374 fn.SetExt( KiCadSchematicFileExtension );
375 m_text = fn.GetFullPath();
376 }
377 }
378
379 m_position = wxPoint( m_posX.GetValue(), m_posY.GetValue() );
381
384
386
390
391 if( m_hAlignLeft->IsChecked() )
393 else if( m_hAlignCenter->IsChecked() )
395 else
397
398 if( m_vAlignTop->IsChecked() )
400 else if( m_vAlignCenter->IsChecked() )
402 else
404
405 m_isVisible = m_visible->GetValue();
406 m_isNameVisible = m_nameVisible->GetValue();
408
409 return true;
410}
411
412
414{
415 if( aText->GetTextWidth() != m_size )
416 aText->SetTextSize( wxSize( m_size, m_size ) );
417
418 aText->SetVisible( m_isVisible );
420 aText->SetItalic( m_isItalic );
421 aText->SetBold( m_isBold );
422 aText->SetTextColor( m_color );
423}
424
425
427 const wxString& aTitle,
428 const LIB_FIELD* aField ) :
429 DIALOG_FIELD_PROPERTIES( aParent, aTitle, aField )
430{
431 m_fieldId = aField->GetId();
432 m_isNameVisible = aField->IsNameShown();
433 m_allowAutoplace = aField->CanAutoplace();
434
435 if( m_fieldId == VALUE_FIELD )
436 m_text = UnescapeString( aField->GetText() );
437
438 m_nameVisible->Show();
439 m_cbAllowAutoPlace->Show();
440
441 // When in the library editor, power symbols can be renamed.
442 m_isPower = false;
443 init();
444}
445
446
448{
449 aField->SetText( m_text );
450
451 updateText( aField );
452
453 aField->SetNameShown( m_isNameVisible );
455
458 aField->SetTextPos( m_position );
459}
460
461
463 const wxString& aTitle,
464 const SCH_FIELD* aField ) :
465 DIALOG_FIELD_PROPERTIES( aParent, aTitle, aField ),
466 m_field( aField )
467{
468 m_isSheetFilename = false;
469
470 if( aField->GetParent() && aField->GetParent()->Type() == SCH_SYMBOL_T )
471 {
472 m_fieldId = aField->GetId();
473 }
474 else if( aField->GetParent() && aField->GetParent()->Type() == SCH_SHEET_T )
475 {
476 switch( aField->GetId() )
477 {
478 case SHEETNAME:
480 break;
481
482 case SHEETFILENAME:
483 m_isSheetFilename = true;
485 m_note->SetLabel( wxString::Format( m_note->GetLabel(),
486 _( "Sheet filename can only be modified in Sheet Properties dialog." ) ) );
487 m_note->Show( true );
488 break;
489
490 default:
492 break;
493 }
494 }
495 else if( aField->GetParent() && aField->GetParent()->IsType( { SCH_LABEL_LOCATE_ANY_T } ) )
496 {
498 }
499
500 // show text variable cross-references in a human-readable format
501 m_text = aField->Schematic()->ConvertKIIDsToRefs( aField->GetText() );
502
504
505 m_isPower = false;
506
507 m_textLabel->SetLabel( aField->GetName() + wxS( ":" ) );
508
510
513
516
517 // The library symbol may have been removed so using SCH_SYMBOL::GetLibSymbolRef() here
518 // could result in a segfault. If the library symbol is no longer available, the
519 // schematic fields can still edit so set the power symbol flag to false. This may not
520 // be entirely accurate if the power library is missing but it's better then a segfault.
521 if( aField->GetParent() && aField->GetParent()->Type() == SCH_SYMBOL_T )
522 {
523 const SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( aField->GetParent() );
524 const LIB_SYMBOL* libSymbol = GetParent()->GetLibSymbol( symbol->GetLibId(), true );
525
526 if( libSymbol && libSymbol->IsPower() )
527 m_isPower = true;
528 }
529
531 this );
532
533 m_nameVisible->Show();
534 m_cbAllowAutoPlace->Show();
535
536 init();
537
539 {
540 m_StyledTextCtrl->Enable( false );
541 m_TextCtrl->Enable( false );
542 }
543}
544
545
547{
548 int key = aEvent.GetKey();
549
550 SCH_EDIT_FRAME* editFrame = static_cast<SCH_EDIT_FRAME*>( GetParent() );
551 wxArrayString autocompleteTokens;
552 int pos = m_StyledTextCtrl->GetCurrentPos();
553 int start = m_StyledTextCtrl->WordStartPosition( pos, true );
554 wxString partial;
555
556 // Currently, '\n' is not allowed in fields. So remove it when entered
557 // TODO: see if we must close the dialog. However this is not obvious, as
558 // if a \n is typed (and removed) when a text is selected, this text is deleted
559 // (in fact replaced by \n, that is removed by the filter)
560 if( key == '\n' )
561 {
562 wxString text = m_StyledTextCtrl->GetText();
563 int currpos = m_StyledTextCtrl->GetCurrentPos();
564 text.Replace( wxS( "\n" ), wxS( "" ) );
565 m_StyledTextCtrl->SetText( text );
566 m_StyledTextCtrl->GotoPos( currpos-1 );
567 return;
568 }
569
570 auto textVarRef =
571 [&]( int pt )
572 {
573 return pt >= 2
574 && m_StyledTextCtrl->GetCharAt( pt - 2 ) == '$'
575 && m_StyledTextCtrl->GetCharAt( pt - 1 ) == '{';
576 };
577
578 // Check for cross-reference
579 if( start > 1 && m_StyledTextCtrl->GetCharAt( start - 1 ) == ':' )
580 {
581 int refStart = m_StyledTextCtrl->WordStartPosition( start - 1, true );
582
583 if( textVarRef( refStart ) )
584 {
585 partial = m_StyledTextCtrl->GetRange( start, pos );
586
587 wxString ref = m_StyledTextCtrl->GetRange( refStart, start - 1 );
588 SCH_SHEET_LIST sheets = editFrame->Schematic().GetSheets();
590 SCH_SYMBOL* refSymbol = nullptr;
591
592 sheets.GetSymbols( refs );
593
594 for( size_t jj = 0; jj < refs.GetCount(); jj++ )
595 {
596 if( refs[ jj ].GetSymbol()->GetRef( &refs[ jj ].GetSheetPath(), true ) == ref )
597 {
598 refSymbol = refs[ jj ].GetSymbol();
599 break;
600 }
601 }
602
603 if( refSymbol )
604 refSymbol->GetContextualTextVars( &autocompleteTokens );
605 }
606 }
607 else if( textVarRef( start ) )
608 {
609 partial = m_StyledTextCtrl->GetTextRange( start, pos );
610
611 SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( m_field->GetParent() );
612 SCH_SHEET* sheet = dynamic_cast<SCH_SHEET*>( m_field->GetParent() );
613
614 if( symbol )
615 {
616 symbol->GetContextualTextVars( &autocompleteTokens );
617
618 SCHEMATIC* schematic = symbol->Schematic();
619
620 if( schematic && schematic->CurrentSheet().Last() )
621 schematic->CurrentSheet().Last()->GetContextualTextVars( &autocompleteTokens );
622 }
623
624 if( sheet )
625 sheet->GetContextualTextVars( &autocompleteTokens );
626
627 for( std::pair<wxString, wxString> entry : Prj().GetTextVars() )
628 autocompleteTokens.push_back( entry.first );
629 }
630
631 m_scintillaTricks->DoAutocomplete( partial, autocompleteTokens );
632 m_StyledTextCtrl->SetFocus();
633}
634
635
637{
638 SCH_EDIT_FRAME* editFrame = dynamic_cast<SCH_EDIT_FRAME*>( GetParent() );
639 SCH_ITEM* parent = dynamic_cast<SCH_ITEM*>( aField->GetParent() );
640 int fieldType = aField->GetId();
641
642 if( parent && parent->Type() == SCH_SYMBOL_T )
643 {
644 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( parent );
645
646 if( fieldType == REFERENCE_FIELD )
647 symbol->SetRef( aSheetPath, m_text );
648 else if( fieldType == VALUE_FIELD )
649 symbol->SetValueFieldText( m_text );
650 else if( fieldType == FOOTPRINT_FIELD )
651 symbol->SetFootprintFieldText( m_text );
652 }
653 else if( parent && parent->Type() == SCH_GLOBAL_LABEL_T )
654 {
655 if( fieldType == 0 )
656 {
657 if( m_visible->GetValue() != parent->Schematic()->Settings().m_IntersheetRefsShow )
658 {
659 DisplayInfoMessage( this, _( "Intersheet reference visibility is "
660 "controlled globally from "
661 "Schematic Setup > General > Formatting" ) );
662 }
663 }
664 }
665
666 bool positioningModified = false;
667
668 if( aField->GetPosition() != m_position )
669 positioningModified = true;
670
671 if( aField->GetTextAngle().IsVertical() != m_isVertical )
672 positioningModified = true;
673
675 positioningModified = true;
676
678 positioningModified = true;
679
680 // convert any text variable cross-references to their UUIDs
682
683 aField->SetText( m_text );
684 updateText( aField );
685 aField->SetPosition( m_position );
686
687 aField->SetFont( m_font );
688
689 aField->SetNameShown( m_isNameVisible );
691
692 // Note that we must set justifications before we can ask if they're flipped. If the old
693 // justification is center then it won't know (whereas if the new justification is center
694 // the we don't care).
697
698 if( aField->IsHorizJustifyFlipped() )
700
701 if( aField->IsVertJustifyFlipped() )
703
704 // The value, footprint and datasheet fields should be kept in sync in multi-unit parts.
705 // Of course the symbol must be annotated to collect other units.
706 if( editFrame && parent && parent->Type() == SCH_SYMBOL_T )
707 {
708 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( parent );
709
710 if( symbol->IsAnnotated( aSheetPath ) && ( fieldType == VALUE_FIELD
711 || fieldType == FOOTPRINT_FIELD
712 || fieldType == DATASHEET_FIELD ) )
713 {
714 wxString ref = symbol->GetRef( aSheetPath );
715 int unit = symbol->GetUnit();
716 LIB_ID libId = symbol->GetLibId();
717
718 for( SCH_SHEET_PATH& sheet : editFrame->Schematic().GetSheets() )
719 {
720 SCH_SCREEN* screen = sheet.LastScreen();
721 std::vector<SCH_SYMBOL*> otherUnits;
722 constexpr bool appendUndo = true;
723
724 CollectOtherUnits( ref, unit, libId, sheet, &otherUnits );
725
726 for( SCH_SYMBOL* otherUnit : otherUnits )
727 {
728 editFrame->SaveCopyInUndoList( screen, otherUnit, UNDO_REDO::CHANGED,
729 appendUndo );
730
731 if( fieldType == VALUE_FIELD )
732 otherUnit->SetValueFieldText( m_text );
733 else if( fieldType == FOOTPRINT_FIELD )
734 otherUnit->SetFootprintFieldText( m_text );
735 else
736 otherUnit->GetField( DATASHEET_FIELD )->SetText( m_text );
737
738 editFrame->UpdateItem( otherUnit, false, true );
739 }
740 }
741 }
742 }
743
744 if( positioningModified && parent )
745 parent->ClearFieldsAutoplaced();
746}
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:105
@ text_align_right
@ text_valign_top
@ text_align_left
@ small_library
@ text_valign_center
@ text_vertical
@ text_align_center
@ text_horizontal
@ text_valign_bottom
A bitmap button widget that behaves like an AUI toolbar item's button when it is drawn.
Definition: bitmap_button.h:41
void SetIsRadioButton()
bool IsChecked() const
void SetBitmap(const wxBitmap &aBmp)
Set the bitmap shown when the button is enabled.
void Check(bool aCheck=true)
Check the control.
void SetIsSeparator()
Render button as a toolbar separator.
void SetIsCheckButton()
Setup the control as a two-state button (checked or unchecked).
Color settings are a bit different than most of the settings objects in that there can be more than o...
COLOR4D GetColor(int aLayer) const
void SetSwatchColor(const KIGFX::COLOR4D &aColor, bool aSendEvent)
Set the current swatch color directly.
KIGFX::COLOR4D GetSwatchColor() const
void SetDefaultColor(const KIGFX::COLOR4D &aColor)
Sets the color that will be chosen with the "Reset to Default" button in the chooser.
void SetSwatchBackground(const KIGFX::COLOR4D &aBackground)
Set the swatch background color.
Class DIALOG_FIELD_PROPERTIES_BASE.
A base class to edit schematic and symbol library fields.
void onOrientButton(wxCommandEvent &aEvent)
void OnTextValueSelectButtonClick(wxCommandEvent &aEvent) override
Handle the select button next to the text value field.
GR_TEXT_H_ALIGN_T m_horizontalJustification
void onVAlignButton(wxCommandEvent &aEvent)
SCINTILLA_TRICKS * m_scintillaTricks
virtual void OnSetFocusText(wxFocusEvent &event) override
Used to select the variant part of some text fields (for instance, the question mark or number in a r...
void updateText(EDA_TEXT *aText)
void onHAlignButton(wxCommandEvent &aEvent)
GR_TEXT_V_ALIGN_T m_verticalJustification
DIALOG_FIELD_PROPERTIES(SCH_BASE_FRAME *aParent, const wxString &aTitle, const EDA_TEXT *aTextItem)
DIALOG_LIB_FIELD_PROPERTIES(SCH_BASE_FRAME *aParent, const wxString &aTitle, const LIB_FIELD *aField)
DIALOG_SCH_FIELD_PROPERTIES(SCH_BASE_FRAME *aParent, const wxString &aTitle, const SCH_FIELD *aField)
void onScintillaCharAdded(wxStyledTextEvent &aEvent)
void UpdateField(SCH_FIELD *aField, SCH_SHEET_PATH *aSheetPath)
void SetInitialFocus(wxWindow *aWindow)
Sets the window (usually a wxTextCtrl) that should be focused when the dialog is shown.
Definition: dialog_shim.h:97
void SetupStandardButtons(std::map< int, wxString > aLabels={})
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
bool IsVertical() const
Definition: eda_angle.h:179
bool IsType(FRAME_T aType) const
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
virtual bool IsType(const std::vector< KICAD_T > &aScanTypes) const
Check whether the item is one of the listed types.
Definition: eda_item.h:181
EDA_ITEM * GetParent() const
Definition: eda_item.h:99
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:72
void SetTextColor(const COLOR4D &aColor)
Definition: eda_text.h:204
const VECTOR2I & GetTextPos() const
Definition: eda_text.h:208
COLOR4D GetTextColor() const
Definition: eda_text.h:205
bool IsItalic() const
Definition: eda_text.h:130
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:120
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:87
virtual bool IsVisible() const
Definition: eda_text.h:136
void SetTextPos(const VECTOR2I &aPoint)
Definition: eda_text.cpp:371
KIFONT::FONT * GetFont() const
Definition: eda_text.h:188
int GetTextWidth() const
Definition: eda_text.h:199
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
Definition: eda_text.cpp:248
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition: eda_text.h:149
virtual void SetVisible(bool aVisible)
Definition: eda_text.cpp:217
static GR_TEXT_H_ALIGN_T MapHorizJustify(int aHorizJustify)
Definition: eda_text.cpp:62
void SetBold(bool aBold)
Definition: eda_text.cpp:209
bool IsBold() const
Definition: eda_text.h:133
static GR_TEXT_V_ALIGN_T MapVertJustify(int aVertJustify)
Definition: eda_text.cpp:76
GR_TEXT_V_ALIGN_T GetVertJustify() const
Definition: eda_text.h:152
void SetTextSize(const VECTOR2I &aNewSize)
Definition: eda_text.cpp:347
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:163
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition: eda_text.cpp:193
void SetItalic(bool aItalic)
Definition: eda_text.cpp:201
void SetFont(KIFONT::FONT *aFont)
Definition: eda_text.cpp:331
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Definition: eda_text.cpp:240
bool HaveFontSelection() const
Definition: font_choice.cpp:88
void SetFontSelection(KIFONT::FONT *aFont)
Definition: font_choice.cpp:67
KIFONT::FONT * GetFontSelection(bool aBold, bool aItalic) const
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:53
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Definition: kiway_player.h:66
Field object used in symbol libraries.
Definition: lib_field.h:61
bool CanAutoplace() const
Definition: lib_field.h:183
bool IsNameShown() const
Definition: lib_field.h:180
void SetNameShown(bool aShown=true)
Definition: lib_field.h:181
void SetCanAutoplace(bool aCanPlace)
Definition: lib_field.h:184
int GetId() const
Definition: lib_field.h:114
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:49
Define a library symbol object.
Definition: lib_symbol.h:99
bool IsPower() const
Definition: lib_symbol.cpp:548
virtual std::map< wxString, wxString > & GetTextVars() const
Definition: project.cpp:82
Holds all the data relating to one schematic.
Definition: schematic.h:61
SCH_SHEET_PATH & CurrentSheet() const override
Definition: schematic.h:120
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:178
wxString ConvertKIIDsToRefs(const wxString &aSource) const
Definition: schematic.cpp:426
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:86
wxString ConvertRefsToKIIDs(const wxString &aSource) const
Definition: schematic.cpp:358
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
LIB_SYMBOL * GetLibSymbol(const LIB_ID &aLibId, bool aUseCacheLib=false, bool aShowErrorMsg=false)
Load symbol from symbol library table.
COLOR_SETTINGS * GetColorSettings(bool aForceRefresh=false) const override
Returns a pointer to the active color theme settings.
Schematic editor (Eeschema) main window.
void SaveCopyInUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItemToCopy, UNDO_REDO aTypeCommand, bool aAppend, bool aDirtyConnectivity=true)
Create a copy of the current schematic item, and put it in the undo list.
SCHEMATIC & Schematic() const
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false, bool aUpdateRtree=false) override
Mark an item for refresh.
A text control validator used for validating the text allowed in library and schematic symbol fields.
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:51
GR_TEXT_V_ALIGN_T GetEffectiveVertJustify() const
Definition: sch_field.cpp:550
VECTOR2I GetPosition() const override
Definition: sch_field.cpp:1061
bool IsNameShown() const
Definition: sch_field.h:158
bool IsHorizJustifyFlipped() const
Return whether the field will be rendered with the horizontal justification inverted due to rotation ...
Definition: sch_field.cpp:490
bool IsVertJustifyFlipped() const
Definition: sch_field.cpp:527
void SetCanAutoplace(bool aCanPlace)
Definition: sch_field.h:162
int GetId() const
Definition: sch_field.h:125
GR_TEXT_H_ALIGN_T GetEffectiveHorizJustify() const
Definition: sch_field.cpp:513
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
Definition: sch_field.cpp:813
void SetPosition(const VECTOR2I &aPosition) override
Definition: sch_field.cpp:1041
bool CanAutoplace() const
Definition: sch_field.h:161
void SetNameShown(bool aShown=true)
Definition: sch_field.h:159
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:147
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:112
void ClearFieldsAutoplaced()
Definition: sch_item.h:427
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
size_t GetCount() const
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
void GetSymbols(SCH_REFERENCE_LIST &aReferences, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanSymbols=false) const
Add a SCH_REFERENCE object to aReferences for each symbol in the list of sheets.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:57
void GetContextualTextVars(wxArrayString *aVars) const
Return the list of system text vars & fields for this sheet.
Definition: sch_sheet.cpp:202
Schematic symbol object.
Definition: sch_symbol.h:81
int GetUnit() const
Definition: sch_symbol.h:228
static bool IsReferenceStringValid(const wxString &aReferenceString)
Test for an acceptable reference string.
Definition: sch_symbol.cpp:688
void SetValueFieldText(const wxString &aValue)
Definition: sch_symbol.cpp:822
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
Definition: sch_symbol.cpp:652
void SetRef(const SCH_SHEET_PATH *aSheet, const wxString &aReference)
Set the reference for the given sheet path for this symbol.
Definition: sch_symbol.cpp:694
void SetFootprintFieldText(const wxString &aFootprint)
Definition: sch_symbol.cpp:837
void GetContextualTextVars(wxArrayString *aVars) const
Return the list of system text vars & fields for this symbol.
bool IsAnnotated(const SCH_SHEET_PATH *aSheet)
Check if the symbol has a valid annotation (reference) for the given sheet path.
Definition: sch_symbol.cpp:730
const LIB_ID & GetLibId() const
Definition: sch_symbol.h:175
Add cut/copy/paste, dark theme, autocomplete and brace highlighting to a wxStyleTextCtrl instance.
void DoAutocomplete(const wxString &aPartial, const wxArrayString &aTokens)
virtual long long int GetValue()
Return the current value in Internal Units.
virtual void SetValue(long long int aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion.
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:300
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:352
This file is part of the common library.
#define _(s)
static constexpr EDA_ANGLE & ANGLE_HORIZONTAL
Definition: eda_angle.h:408
static constexpr EDA_ANGLE & ANGLE_VERTICAL
Definition: eda_angle.h:409
void CollectOtherUnits(const wxString &aRef, int aUnit, const LIB_ID &aLibId, SCH_SHEET_PATH &aSheet, std::vector< SCH_SYMBOL * > *otherUnits)
@ FRAME_FOOTPRINT_VIEWER_MODAL
Definition: frame_type.h:43
@ FRAME_SCH_SYMBOL_EDITOR
Definition: frame_type.h:35
const std::string KiCadSchematicFileExtension
@ LAYER_SCHEMATIC_BACKGROUND
Definition: layer_ids.h:376
wxFont GetInfoFont(wxWindow *aWindow)
Definition: ui_common.cpp:156
void SelectReferenceNumber(wxTextEntry *aTextEntry)
Select the number (or "?") in a reference for ease of editing.
Definition: ui_common.cpp:230
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
@ SHEETNAME
Definition: sch_sheet.h:45
@ SHEETFILENAME
Definition: sch_sheet.h:46
Definitions of control validators for schematic dialogs.
#define SHEETFILENAME_V
#define LABELUSERFIELD_V
#define SHEETNAME_V
#define SHEETUSERFIELD_V
wxString UnescapeString(const wxString &aSource)
Definition for symbol library class.
@ DATASHEET_FIELD
name of datasheet
@ FOOTPRINT_FIELD
Field Name Module PCB, i.e. "16DIP300".
@ VALUE_FIELD
Field Value of part, i.e. "3.3K".
@ REFERENCE_FIELD
Field Reference of part, i.e. "IC21".
@ GR_TEXT_H_ALIGN_CENTER
@ GR_TEXT_H_ALIGN_RIGHT
@ GR_TEXT_H_ALIGN_LEFT
@ GR_TEXT_V_ALIGN_BOTTOM
@ GR_TEXT_V_ALIGN_CENTER
@ GR_TEXT_V_ALIGN_TOP
@ SCH_SYMBOL_T
Definition: typeinfo.h:156
@ SCH_SHEET_T
Definition: typeinfo.h:158
@ SCH_GLOBAL_LABEL_T
Definition: typeinfo.h:152
Definition of file extensions used in Kicad.