KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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-2023 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 <common.h>
34#include <string_utils.h>
35#include <sch_base_frame.h>
36#include <sch_edit_frame.h>
37#include <ee_collectors.h>
38#include <sch_symbol.h>
39#include <sch_label.h>
40#include <lib_field.h>
41#include <template_fieldnames.h>
42#include <symbol_library.h>
43#include <sch_validators.h>
44#include <schematic.h>
46#include <sch_text.h>
47#include <scintilla_tricks.h>
49#include <sim/sim_model.h>
50#include <sim/sim_lib_mgr.h>
51
52
54 const EDA_TEXT* aTextItem ) :
55 DIALOG_FIELD_PROPERTIES_BASE( aParent, wxID_ANY, aTitle ),
56 m_posX( aParent, m_xPosLabel, m_xPosCtrl, m_xPosUnits, true ),
57 m_posY( aParent, m_yPosLabel, m_yPosCtrl, m_yPosUnits, true ),
58 m_textSize( aParent, m_textSizeLabel, m_textSizeCtrl, m_textSizeUnits, true ),
59 m_font( nullptr ),
60 m_firstFocus( true ),
61 m_scintillaTricks( nullptr )
62{
63 COLOR_SETTINGS* colorSettings = aParent->GetColorSettings();
64 COLOR4D schematicBackground = colorSettings->GetColor( LAYER_SCHEMATIC_BACKGROUND );
65
66 wxASSERT( aTextItem );
67
68 m_note->SetFont( KIUI::GetInfoFont( this ).Italic() );
69 m_note->Show( false );
70
71 // The field ID is initialized in the derived object's ctor.
73
74 m_scintillaTricks = new SCINTILLA_TRICKS( m_StyledTextCtrl, wxT( "{}" ), true,
75 [this]()
76 {
77 wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
78 } );
79 m_StyledTextCtrl->SetEOLMode( wxSTC_EOL_LF ); // Normalize EOL across platforms
80
81 m_textColorSwatch->SetDefaultColor( COLOR4D::UNSPECIFIED );
82 m_textColorSwatch->SetSwatchBackground( schematicBackground );
83
85
87 m_horizontal->SetBitmap( KiBitmap( BITMAPS::text_horizontal ) );
89 m_vertical->SetBitmap( KiBitmap( BITMAPS::text_vertical ) );
90
92
94 m_bold->SetBitmap( KiBitmap( BITMAPS::text_bold ) );
96 m_italic->SetBitmap( KiBitmap( BITMAPS::text_italic ) );
97
99
101 m_hAlignLeft->SetBitmap( KiBitmap( BITMAPS::text_align_left ) );
103 m_hAlignCenter->SetBitmap( KiBitmap( BITMAPS::text_align_center ) );
105 m_hAlignRight->SetBitmap( KiBitmap( BITMAPS::text_align_right ) );
106
108
110 m_vAlignTop->SetBitmap( KiBitmap( BITMAPS::text_valign_top ) );
112 m_vAlignCenter->SetBitmap( KiBitmap( BITMAPS::text_valign_center ) );
114 m_vAlignBottom->SetBitmap( KiBitmap( BITMAPS::text_valign_bottom ) );
115
117
118 m_horizontal->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onOrientButton, this );
119 m_vertical->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onOrientButton, this );
120
121 m_hAlignLeft->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onHAlignButton, this );
122 m_hAlignCenter->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onHAlignButton, this );
123 m_hAlignRight->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onHAlignButton, this );
124
125 m_vAlignTop->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onVAlignButton, this );
126 m_vAlignCenter->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onVAlignButton, this );
127 m_vAlignBottom->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onVAlignButton, this );
128
129 m_text = aTextItem->GetText();
130 m_isItalic = aTextItem->IsItalic();
131 m_isBold = aTextItem->IsBold();
132 m_color = aTextItem->GetTextColor();
133 m_position = aTextItem->GetTextPos();
134 m_size = aTextItem->GetTextWidth();
135 m_isVertical = aTextItem->GetTextAngle().IsVertical();
138 m_isVisible = aTextItem->IsVisible();
139
140 // These should be initialized in the child classes implementing dialogs for lib and sch items.
141 m_isNameVisible = false;
142 m_allowAutoplace = true;
143}
144
145
147{
148 delete m_scintillaTricks;
149}
150
151
153{
154 SCH_BASE_FRAME* parent = GetParent();
155 bool isSymbolEditor = parent && parent->IsType( FRAME_SCH_SYMBOL_EDITOR );
156
157 // Disable options for graphic text editing which are not needed for fields.
158 m_CommonConvert->Show( false );
159 m_CommonUnit->Show( false );
160
161 // Predefined fields cannot contain some chars, or cannot be empty,
162 // and need a SCH_FIELD_VALIDATOR (m_StyledTextCtrl cannot use a SCH_FIELD_VALIDATOR).
163 bool use_validator = m_fieldId == REFERENCE_FIELD
168
169 if( use_validator )
170 {
171 m_TextCtrl->SetValidator( SCH_FIELD_VALIDATOR( isSymbolEditor, m_fieldId, &m_text ) );
173
174 m_StyledTextCtrl->Show( false );
175 }
176 else
177 {
179
180 m_TextCtrl->Show( false );
181 }
182
183 // Show the footprint selection dialog if this is the footprint field.
184 m_TextValueSelectButton->SetBitmap( KiBitmap( BITMAPS::small_library ) );
186
187 m_TextCtrl->Enable( true );
188
189 GetSizer()->SetSizeHints( this );
190
191 // Adjust the height of the scintilla text editor after the first layout
192 // To show only one line
193 // (multiline text are is supported in fields and will be removed)
194 if( m_StyledTextCtrl->IsShown() )
195 {
196 wxSize maxSize = m_StyledTextCtrl->GetSize();
197 maxSize.x = -1; // Do not fix the max width
198 maxSize.y = m_xPosCtrl->GetSize().y;
199 m_StyledTextCtrl->SetMaxSize( maxSize );
200 m_StyledTextCtrl->SetUseVerticalScrollBar( false );
201 m_StyledTextCtrl->SetUseHorizontalScrollBar( false );
202 }
203
205
206 // Now all widgets have the size fixed, call FinishDialogSettings
208}
209
210
212{
213 // pick a footprint using the footprint picker.
214 wxString fpid;
215
216 if( m_StyledTextCtrl->IsShown() )
217 fpid = m_StyledTextCtrl->GetValue();
218 else
219 fpid = m_TextCtrl->GetValue();
220
221 if( KIWAY_PLAYER* frame = Kiway().Player( FRAME_FOOTPRINT_VIEWER_MODAL, true ) )
222 {
223 if( frame->ShowModal( &fpid, this ) )
224 {
225 if( m_StyledTextCtrl->IsShown() )
226 m_StyledTextCtrl->SetValue( fpid );
227 else
228 m_TextCtrl->SetValue( fpid );
229 }
230
231 frame->Destroy();
232 }
233}
234
235
237{
238 if( m_firstFocus )
239 {
240#ifdef __WXGTK__
241 // Force an update of the text control before setting the text selection
242 // This is needed because GTK seems to ignore the selection on first update
243 //
244 // Note that we can't do this on OSX as it tends to provoke Apple's
245 // "[NSAlert runModal] may not be invoked inside of transaction begin/commit pair"
246 // bug. See: https://bugs.launchpad.net/kicad/+bug/1837225
248 m_TextCtrl->Update();
249#endif
250
252 KIUI::SelectReferenceNumber( static_cast<wxTextEntry*>( m_TextCtrl ) );
253 else if( m_fieldId == VALUE_FIELD || m_fieldId == SHEETNAME_V )
254 m_TextCtrl->SetSelection( -1, -1 );
255
256 m_firstFocus = false;
257 }
258
259 event.Skip();
260}
261
262
263void DIALOG_FIELD_PROPERTIES::onOrientButton( wxCommandEvent& aEvent )
264{
265 for( BITMAP_BUTTON* btn : { m_horizontal, m_vertical } )
266 {
267 if( btn->IsChecked() && btn != aEvent.GetEventObject() )
268 btn->Check( false );
269 }
270}
271
272
273void DIALOG_FIELD_PROPERTIES::onHAlignButton( wxCommandEvent& aEvent )
274{
276 {
277 if( btn->IsChecked() && btn != aEvent.GetEventObject() )
278 btn->Check( false );
279 }
280}
281
282
283void DIALOG_FIELD_PROPERTIES::onVAlignButton( wxCommandEvent& aEvent )
284{
286 {
287 if( btn->IsChecked() && btn != aEvent.GetEventObject() )
288 btn->Check( false );
289 }
290}
291
292
294{
295 if( m_TextCtrl->IsShown() )
296 {
297 m_TextCtrl->SetValue( m_text );
298 }
299 else if( m_StyledTextCtrl->IsShown() )
300 {
301 m_StyledTextCtrl->SetValue( m_text );
302 m_StyledTextCtrl->EmptyUndoBuffer();
303 }
304
306
310
313
316
318
320 {
321 case GR_TEXT_H_ALIGN_LEFT: m_hAlignLeft->Check( true ); break;
322 case GR_TEXT_H_ALIGN_CENTER: m_hAlignCenter->Check( true ); break;
323 case GR_TEXT_H_ALIGN_RIGHT: m_hAlignRight->Check( true ); break;
324 }
325
326 switch ( m_verticalJustification )
327 {
328 case GR_TEXT_V_ALIGN_TOP: m_vAlignTop->Check( true ); break;
329 case GR_TEXT_V_ALIGN_CENTER: m_vAlignCenter->Check( true ); break;
330 case GR_TEXT_V_ALIGN_BOTTOM: m_vAlignBottom->Check( true ); break;
331 }
332
333 m_visible->SetValue( m_isVisible );
334 m_nameVisible->SetValue( m_isNameVisible );
336
337 return true;
338}
339
340
342{
343 if( m_TextCtrl->IsShown() )
344 m_text = m_TextCtrl->GetValue();
345 else if( m_StyledTextCtrl->IsShown() )
346 m_text = m_StyledTextCtrl->GetValue();
347
349 {
350 // Test if the reference string is valid:
352 {
353 DisplayError( this, _( "Illegal reference designator value!" ) );
354 return false;
355 }
356 }
357 else if( m_fieldId == SHEETFILENAME_V )
358 {
360 }
361
364
367
369
373
374 if( m_hAlignLeft->IsChecked() )
376 else if( m_hAlignCenter->IsChecked() )
378 else
380
381 if( m_vAlignTop->IsChecked() )
383 else if( m_vAlignCenter->IsChecked() )
385 else
387
388 m_isVisible = m_visible->GetValue();
389 m_isNameVisible = m_nameVisible->GetValue();
391
392 return true;
393}
394
395
397{
398 if( aText->GetTextWidth() != m_size )
399 aText->SetTextSize( VECTOR2I( m_size, m_size ) );
400
401 aText->SetVisible( m_isVisible );
403 aText->SetItalic( m_isItalic );
404 aText->SetBold( m_isBold );
405 aText->SetTextColor( m_color );
406}
407
408
410 const wxString& aTitle,
411 const LIB_FIELD* aField ) :
412 DIALOG_FIELD_PROPERTIES( aParent, aTitle, aField )
413{
414 m_fieldId = aField->GetId();
415 m_isNameVisible = aField->IsNameShown();
416 m_allowAutoplace = aField->CanAutoplace();
417
418 if( m_fieldId == VALUE_FIELD )
419 m_text = UnescapeString( aField->GetText() );
420
421 m_nameVisible->Show();
422 m_cbAllowAutoPlace->Show();
423
424 init();
425}
426
427
429{
430 aField->SetText( m_text );
431
432 updateText( aField );
433
434 aField->SetNameShown( m_isNameVisible );
436
439 aField->SetTextPos( m_position );
440}
441
442
444 const wxString& aTitle,
445 const SCH_FIELD* aField ) :
446 DIALOG_FIELD_PROPERTIES( aParent, aTitle, aField ),
447 m_field( aField )
448{
449 m_isSheetFilename = false;
450
451 if( aField->GetParent() && aField->GetParent()->Type() == SCH_SYMBOL_T )
452 {
453 m_fieldId = aField->GetId();
454 }
455 else if( aField->GetParent() && aField->GetParent()->Type() == SCH_SHEET_T )
456 {
457 switch( aField->GetId() )
458 {
459 case SHEETNAME:
461 break;
462
463 case SHEETFILENAME:
464 m_isSheetFilename = true;
466 m_note->SetLabel( wxString::Format( m_note->GetLabel(),
467 _( "Sheet filename can only be modified in Sheet Properties dialog." ) ) );
468 m_note->Show( true );
469 break;
470
471 default:
473 break;
474 }
475 }
476 else if( aField->GetParent() && aField->GetParent()->IsType( { SCH_LABEL_LOCATE_ANY_T } ) )
477 {
479 }
480
481 // show text variable cross-references in a human-readable format
482 m_text = aField->Schematic()->ConvertKIIDsToRefs( aField->GetText() );
483
485
486 m_textLabel->SetLabel( aField->GetName() + wxS( ":" ) );
487
489
492
495
497 this );
498 m_StyledTextCtrl->Bind( wxEVT_STC_AUTOCOMP_CHAR_DELETED,
500
501 m_nameVisible->Show();
502 m_cbAllowAutoPlace->Show();
503
504 init();
505
507 {
508 m_StyledTextCtrl->Enable( false );
509 m_TextCtrl->Enable( false );
510 }
511}
512
513
515{
516 int key = aEvent.GetKey();
517
518 SCH_EDIT_FRAME* editFrame = static_cast<SCH_EDIT_FRAME*>( GetParent() );
519 wxArrayString autocompleteTokens;
520 int pos = m_StyledTextCtrl->GetCurrentPos();
521 int start = m_StyledTextCtrl->WordStartPosition( pos, true );
522 wxString partial;
523
524 // Currently, '\n' is not allowed in fields. So remove it when entered
525 // TODO: see if we must close the dialog. However this is not obvious, as
526 // if a \n is typed (and removed) when a text is selected, this text is deleted
527 // (in fact replaced by \n, that is removed by the filter)
528 if( key == '\n' )
529 {
530 wxString text = m_StyledTextCtrl->GetText();
531 int currpos = m_StyledTextCtrl->GetCurrentPos();
532 text.Replace( wxS( "\n" ), wxS( "" ) );
533 m_StyledTextCtrl->SetText( text );
534 m_StyledTextCtrl->GotoPos( currpos-1 );
535 return;
536 }
537
538 auto textVarRef =
539 [&]( int pt )
540 {
541 return pt >= 2
542 && m_StyledTextCtrl->GetCharAt( pt - 2 ) == '$'
543 && m_StyledTextCtrl->GetCharAt( pt - 1 ) == '{';
544 };
545
546 // Check for cross-reference
547 if( start > 1 && m_StyledTextCtrl->GetCharAt( start - 1 ) == ':' )
548 {
549 int refStart = m_StyledTextCtrl->WordStartPosition( start - 1, true );
550
551 if( textVarRef( refStart ) )
552 {
553 partial = m_StyledTextCtrl->GetRange( start, pos );
554
555 wxString ref = m_StyledTextCtrl->GetRange( refStart, start - 1 );
556
557 if( ref == wxS( "OP" ) )
558 {
559 // SPICE operating points use ':' syntax for ports
560 SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( m_field->GetParent() );
561 SCH_SHEET_PATH& sheet = editFrame->Schematic().CurrentSheet();
562
563 if( symbol )
564 {
565 SIM_LIB_MGR mgr( &Prj() );
566 SIM_MODEL& model = mgr.CreateModel( &sheet, *symbol ).model;
567
568 for( wxString pin : model.GetPinNames() )
569 {
570 if( pin.StartsWith( '<' ) && pin.EndsWith( '>' ) )
571 autocompleteTokens.push_back( pin.Mid( 1, pin.Length() - 2 ) );
572 else
573 autocompleteTokens.push_back( pin );
574 }
575 }
576 }
577 else
578 {
579 SCH_SHEET_LIST sheets = editFrame->Schematic().GetSheets();
581 SCH_SYMBOL* refSymbol = nullptr;
582
583 sheets.GetSymbols( refs );
584
585 for( size_t jj = 0; jj < refs.GetCount(); jj++ )
586 {
587 if( refs[ jj ].GetSymbol()->GetRef( &refs[ jj ].GetSheetPath(), true ) == ref )
588 {
589 refSymbol = refs[ jj ].GetSymbol();
590 break;
591 }
592 }
593
594 if( refSymbol )
595 refSymbol->GetContextualTextVars( &autocompleteTokens );
596 }
597 }
598 }
599 else if( textVarRef( start ) )
600 {
601 partial = m_StyledTextCtrl->GetTextRange( start, pos );
602
603 SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( m_field->GetParent() );
604 SCH_SHEET* sheet = dynamic_cast<SCH_SHEET*>( m_field->GetParent() );
605 SCH_LABEL_BASE* label = dynamic_cast<SCH_LABEL_BASE*>( m_field->GetParent() );
606
607 if( symbol )
608 {
609 symbol->GetContextualTextVars( &autocompleteTokens );
610
611 SCHEMATIC* schematic = symbol->Schematic();
612
613 if( schematic && schematic->CurrentSheet().Last() )
614 schematic->CurrentSheet().Last()->GetContextualTextVars( &autocompleteTokens );
615 }
616
617 if( sheet )
618 sheet->GetContextualTextVars( &autocompleteTokens );
619
620 if( label )
621 label->GetContextualTextVars( &autocompleteTokens );
622
623 for( std::pair<wxString, wxString> entry : Prj().GetTextVars() )
624 autocompleteTokens.push_back( entry.first );
625 }
626
627 m_scintillaTricks->DoAutocomplete( partial, autocompleteTokens );
628 m_StyledTextCtrl->SetFocus();
629}
630
631
633{
634 SCH_EDIT_FRAME* editFrame = dynamic_cast<SCH_EDIT_FRAME*>( GetParent() );
635 SCH_ITEM* parent = dynamic_cast<SCH_ITEM*>( aField->GetParent() );
636 int fieldType = aField->GetId();
637
638 if( parent && parent->Type() == SCH_SYMBOL_T )
639 {
640 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( parent );
641
642 if( fieldType == REFERENCE_FIELD )
643 symbol->SetRef( aSheetPath, m_text );
644 else if( fieldType == VALUE_FIELD )
645 symbol->SetValueFieldText( m_text );
646 else if( fieldType == FOOTPRINT_FIELD )
647 symbol->SetFootprintFieldText( m_text );
648 }
649 else if( parent && parent->Type() == SCH_GLOBAL_LABEL_T )
650 {
651 if( fieldType == 0 )
652 {
653 if( m_visible->GetValue() != parent->Schematic()->Settings().m_IntersheetRefsShow )
654 {
655 DisplayInfoMessage( this, _( "Intersheet reference visibility is "
656 "controlled globally from "
657 "Schematic Setup > General > Formatting" ) );
658 }
659 }
660 }
661
662 bool positioningModified = false;
663
664 if( aField->GetPosition() != m_position )
665 positioningModified = true;
666
667 if( aField->GetTextAngle().IsVertical() != m_isVertical )
668 positioningModified = true;
669
671 positioningModified = true;
672
674 positioningModified = true;
675
676 // convert any text variable cross-references to their UUIDs
678
679 aField->SetText( m_text );
680 updateText( aField );
681 aField->SetPosition( m_position );
682
683 aField->SetFont( m_font );
684
685 aField->SetNameShown( m_isNameVisible );
687
688 // Note that we must set justifications before we can ask if they're flipped. If the old
689 // justification is center then it won't know (whereas if the new justification is center
690 // the we don't care).
693
694 if( aField->IsHorizJustifyFlipped() )
696
697 if( aField->IsVertJustifyFlipped() )
699
700 // The value, footprint and datasheet fields should be kept in sync in multi-unit parts.
701 // Of course the symbol must be annotated to collect other units.
702 if( editFrame && parent && parent->Type() == SCH_SYMBOL_T )
703 {
704 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( parent );
705
706 if( symbol->IsAnnotated( aSheetPath ) && ( fieldType == VALUE_FIELD
707 || fieldType == FOOTPRINT_FIELD
708 || fieldType == DATASHEET_FIELD ) )
709 {
710 wxString ref = symbol->GetRef( aSheetPath );
711 int unit = symbol->GetUnit();
712 LIB_ID libId = symbol->GetLibId();
713
714 for( SCH_SHEET_PATH& sheet : editFrame->Schematic().GetSheets() )
715 {
716 SCH_SCREEN* screen = sheet.LastScreen();
717 std::vector<SCH_SYMBOL*> otherUnits;
718 constexpr bool appendUndo = true;
719
720 CollectOtherUnits( ref, unit, libId, sheet, &otherUnits );
721
722 for( SCH_SYMBOL* otherUnit : otherUnits )
723 {
724 editFrame->SaveCopyInUndoList( screen, otherUnit, UNDO_REDO::CHANGED,
725 appendUndo );
726
727 if( fieldType == VALUE_FIELD )
728 otherUnit->SetValueFieldText( m_text );
729 else if( fieldType == FOOTPRINT_FIELD )
730 otherUnit->SetFootprintFieldText( m_text );
731 else
732 otherUnit->GetField( DATASHEET_FIELD )->SetText( m_text );
733
734 editFrame->UpdateItem( otherUnit, false, true );
735 }
736 }
737 }
738 }
739
740 if( positioningModified && parent )
741 parent->ClearFieldsAutoplaced();
742}
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:106
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:165
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:207
const VECTOR2I & GetTextPos() const
Definition: eda_text.h:211
COLOR4D GetTextColor() const
Definition: eda_text.h:208
bool IsItalic() const
Definition: eda_text.h:133
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:123
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:139
void SetTextPos(const VECTOR2I &aPoint)
Definition: eda_text.cpp:383
KIFONT::FONT * GetFont() const
Definition: eda_text.h:191
int GetTextWidth() const
Definition: eda_text.h:202
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
Definition: eda_text.cpp:260
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition: eda_text.h:152
virtual void SetVisible(bool aVisible)
Definition: eda_text.cpp:229
static GR_TEXT_H_ALIGN_T MapHorizJustify(int aHorizJustify)
Definition: eda_text.cpp:65
void SetBold(bool aBold)
Definition: eda_text.cpp:221
bool IsBold() const
Definition: eda_text.h:136
static GR_TEXT_V_ALIGN_T MapVertJustify(int aVertJustify)
Definition: eda_text.cpp:79
GR_TEXT_V_ALIGN_T GetVertJustify() const
Definition: eda_text.h:155
void SetTextSize(const VECTOR2I &aNewSize)
Definition: eda_text.cpp:359
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:175
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition: eda_text.cpp:205
void SetItalic(bool aItalic)
Definition: eda_text.cpp:213
void SetFont(KIFONT::FONT *aFont)
Definition: eda_text.cpp:343
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Definition: eda_text.cpp:252
bool HaveFontSelection() const
Definition: font_choice.cpp:94
void SetFontSelection(KIFONT::FONT *aFont)
Definition: font_choice.cpp:73
KIFONT::FONT * GetFontSelection(bool aBold, bool aItalic) const
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103
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:188
bool IsNameShown() const
Definition: lib_field.h:185
void SetNameShown(bool aShown=true)
Definition: lib_field.h:186
void SetCanAutoplace(bool aCanPlace)
Definition: lib_field.h:189
int GetId() const
Definition: lib_field.h:119
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:49
virtual std::map< wxString, wxString > & GetTextVars() const
Definition: project.cpp:82
Holds all the data relating to one schematic.
Definition: schematic.h:72
SCH_SHEET_PATH & CurrentSheet() const override
Definition: schematic.h:133
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:205
wxString ConvertKIIDsToRefs(const wxString &aSource) const
Definition: schematic.cpp:453
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:97
wxString ConvertRefsToKIIDs(const wxString &aSource) const
Definition: schematic.cpp:385
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
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:563
VECTOR2I GetPosition() const override
Definition: sch_field.cpp:1079
bool IsNameShown() const
Definition: sch_field.h:161
bool IsHorizJustifyFlipped() const
Return whether the field will be rendered with the horizontal justification inverted due to rotation ...
Definition: sch_field.cpp:503
bool IsVertJustifyFlipped() const
Definition: sch_field.cpp:540
void SetCanAutoplace(bool aCanPlace)
Definition: sch_field.h:165
int GetId() const
Definition: sch_field.h:125
GR_TEXT_H_ALIGN_T GetEffectiveHorizJustify() const
Definition: sch_field.cpp:526
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
Definition: sch_field.cpp:815
void SetPosition(const VECTOR2I &aPosition) override
Definition: sch_field.cpp:1059
bool CanAutoplace() const
Definition: sch_field.h:164
void SetNameShown(bool aShown=true)
Definition: sch_field.h:162
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:113
void ClearFieldsAutoplaced()
Definition: sch_item.h:433
void GetContextualTextVars(wxArrayString *aVars) const
Return the list of system text vars & fields for this label.
Definition: sch_label.cpp:572
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:201
Schematic symbol object.
Definition: sch_symbol.h:81
int GetUnit() const
Definition: sch_symbol.h:231
static bool IsReferenceStringValid(const wxString &aReferenceString)
Test for an acceptable reference string.
Definition: sch_symbol.cpp:734
void SetValueFieldText(const wxString &aValue)
Definition: sch_symbol.cpp:869
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
Definition: sch_symbol.cpp:698
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:740
void SetFootprintFieldText(const wxString &aFootprint)
Definition: sch_symbol.cpp:885
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:776
const LIB_ID & GetLibId() const
Definition: sch_symbol.h:178
Add cut/copy/paste, dark theme, autocomplete and brace highlighting to a wxStyleTextCtrl instance.
void DoAutocomplete(const wxString &aPartial, const wxArrayString &aTokens)
SIM_MODEL & CreateModel(SIM_MODEL::TYPE aType, const std::vector< LIB_PIN * > &aPins)
virtual std::vector< std::string > GetPinNames() const
Definition: sim_model.h:465
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.
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:380
The common library.
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:283
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:335
This file is part of the common library.
#define _(s)
static constexpr EDA_ANGLE & ANGLE_HORIZONTAL
Definition: eda_angle.h:425
static constexpr EDA_ANGLE & ANGLE_VERTICAL
Definition: eda_angle.h:426
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:380
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
@ 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:146
@ SCH_SHEET_T
Definition: typeinfo.h:148
@ SCH_GLOBAL_LABEL_T
Definition: typeinfo.h:142
VECTOR2< int > VECTOR2I
Definition: vector2d.h:588
Definition of file extensions used in Kicad.