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
166
167 if( use_validator )
168 {
169 m_TextCtrl->SetValidator( SCH_FIELD_VALIDATOR( isSymbolEditor, m_fieldId, &m_text ) );
171
172 m_StyledTextCtrl->Show( false );
173 }
174 else
175 {
177
178 m_TextCtrl->Show( false );
179 }
180
181 // Show the footprint selection dialog if this is the footprint field.
184
185 // Value fields of power symbols cannot be modified. This will grey out
186 // the text box and display an explanation.
188 {
189 m_note->SetLabel( wxString::Format( m_note->GetLabel(),
190 _( "Power symbol value field text cannot be changed." ) ) );
191 m_note->Show( true );
192 m_TextCtrl->Enable( false );
193 }
194 else
195 {
196 m_TextCtrl->Enable( true );
197 }
198
199 GetSizer()->SetSizeHints( this );
200
201 // Adjust the height of the scintilla text editor after the first layout
202 // To show only one line
203 // (multiline text are is supported in fields and will be removed)
204 if( m_StyledTextCtrl->IsShown() )
205 {
206 wxSize maxSize = m_StyledTextCtrl->GetSize();
207 maxSize.x = -1; // Do not fix the max width
208 maxSize.y = m_xPosCtrl->GetSize().y;
209 m_StyledTextCtrl->SetMaxSize( maxSize );
210 m_StyledTextCtrl->SetUseVerticalScrollBar( false );
211 m_StyledTextCtrl->SetUseHorizontalScrollBar( false );
212 }
213
215
216 // Now all widgets have the size fixed, call FinishDialogSettings
218}
219
220
222{
223 // pick a footprint using the footprint picker.
224 wxString fpid;
225
226 if( m_StyledTextCtrl->IsShown() )
227 fpid = m_StyledTextCtrl->GetValue();
228 else
229 fpid = m_TextCtrl->GetValue();
230
232
233 if( frame->ShowModal( &fpid, this ) )
234 {
235 if( m_StyledTextCtrl->IsShown() )
236 m_StyledTextCtrl->SetValue( fpid );
237 else
238 m_TextCtrl->SetValue( fpid );
239 }
240
241 frame->Destroy();
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 m_TextCtrl->SetValue( m_text );
306 else if( m_StyledTextCtrl->IsShown() )
307 m_StyledTextCtrl->SetValue( m_text );
308
310
314
317
320
322
324 {
325 case GR_TEXT_H_ALIGN_LEFT: m_hAlignLeft->Check( true ); break;
326 case GR_TEXT_H_ALIGN_CENTER: m_hAlignCenter->Check( true ); break;
327 case GR_TEXT_H_ALIGN_RIGHT: m_hAlignRight->Check( true ); break;
328 }
329
330 switch ( m_verticalJustification )
331 {
332 case GR_TEXT_V_ALIGN_TOP: m_vAlignTop->Check( true ); break;
333 case GR_TEXT_V_ALIGN_CENTER: m_vAlignCenter->Check( true ); break;
334 case GR_TEXT_V_ALIGN_BOTTOM: m_vAlignBottom->Check( true ); break;
335 }
336
337 m_visible->SetValue( m_isVisible );
338 m_nameVisible->SetValue( m_isNameVisible );
340
341 return true;
342}
343
344
346{
347 if( m_TextCtrl->IsShown() )
348 m_text = m_TextCtrl->GetValue();
349 else if( m_StyledTextCtrl->IsShown() )
350 m_text = m_StyledTextCtrl->GetValue();
351
353 {
354 // Test if the reference string is valid:
356 {
357 DisplayError( this, _( "Illegal reference designator value!" ) );
358 return false;
359 }
360 }
361 else if( m_fieldId == VALUE_FIELD )
362 {
363 if( m_text.IsEmpty() )
364 {
365 DisplayError( this, _( "Value may not be empty." ) );
366 return false;
367 }
368 }
369 else if( m_fieldId == SHEETFILENAME_V )
370 {
371 wxFileName fn( m_text );
372
373 // It's annoying to throw up nag dialogs when the extension isn't right. Just
374 // fix it.
375 if( fn.GetExt().CmpNoCase( KiCadSchematicFileExtension ) != 0 )
376 {
377 fn.SetExt( KiCadSchematicFileExtension );
378 m_text = fn.GetFullPath();
379 }
380 }
381
382 m_position = wxPoint( m_posX.GetValue(), m_posY.GetValue() );
384
387
389
393
394 if( m_hAlignLeft->IsChecked() )
396 else if( m_hAlignCenter->IsChecked() )
398 else
400
401 if( m_vAlignTop->IsChecked() )
403 else if( m_vAlignCenter->IsChecked() )
405 else
407
408 m_isVisible = m_visible->GetValue();
409 m_isNameVisible = m_nameVisible->GetValue();
411
412 return true;
413}
414
415
417{
418 if( aText->GetTextWidth() != m_size )
419 aText->SetTextSize( wxSize( m_size, m_size ) );
420
421 aText->SetVisible( m_isVisible );
423 aText->SetItalic( m_isItalic );
424 aText->SetBold( m_isBold );
425 aText->SetTextColor( m_color );
426}
427
428
430 const wxString& aTitle,
431 const LIB_FIELD* aField ) :
432 DIALOG_FIELD_PROPERTIES( aParent, aTitle, aField )
433{
434 m_fieldId = aField->GetId();
435 m_isNameVisible = aField->IsNameShown();
436 m_allowAutoplace = aField->CanAutoplace();
437
438 if( m_fieldId == VALUE_FIELD )
439 m_text = UnescapeString( aField->GetText() );
440
441 m_nameVisible->Show();
442 m_cbAllowAutoPlace->Show();
443
444 // When in the library editor, power symbols can be renamed.
445 m_isPower = false;
446 init();
447}
448
449
451{
452 wxString value = m_text;
453
454 if( m_fieldId == VALUE_FIELD )
455 value = EscapeString( value, CTX_LIBID );
456
457 aField->SetText( value );
458
459 // VALUE === symbol name, so update the parent symbol if it changes.
460 if( m_fieldId == VALUE_FIELD && aField->GetParent() )
461 aField->GetParent()->SetName( value );
462
463 updateText( aField );
464
465 aField->SetNameShown( m_isNameVisible );
467
470 aField->SetTextPos( m_position );
471}
472
473
475 const wxString& aTitle,
476 const SCH_FIELD* aField ) :
477 DIALOG_FIELD_PROPERTIES( aParent, aTitle, aField ),
478 m_field( aField )
479{
480 m_isSheetFilename = false;
481
482 if( aField->GetParent() && aField->GetParent()->Type() == SCH_SYMBOL_T )
483 {
484 m_fieldId = aField->GetId();
485 }
486 else if( aField->GetParent() && aField->GetParent()->Type() == SCH_SHEET_T )
487 {
488 switch( aField->GetId() )
489 {
490 case SHEETNAME:
492 break;
493
494 case SHEETFILENAME:
495 m_isSheetFilename = true;
497 m_note->SetLabel( wxString::Format( m_note->GetLabel(),
498 _( "Sheet filename can only be modified in Sheet Properties dialog." ) ) );
499 m_note->Show( true );
500 break;
501
502 default:
504 break;
505 }
506 }
507 else if( aField->GetParent() && aField->GetParent()->IsType( { SCH_LABEL_LOCATE_ANY_T } ) )
508 {
510 }
511
512 // show text variable cross-references in a human-readable format
513 m_text = aField->Schematic()->ConvertKIIDsToRefs( aField->GetText() );
514
516
517 m_isPower = false;
518
519 m_textLabel->SetLabel( aField->GetName() + ":" );
520
522
525
528
529 // The library symbol may have been removed so using SCH_SYMBOL::GetLibSymbolRef() here
530 // could result in a segfault. If the library symbol is no longer available, the
531 // schematic fields can still edit so set the power symbol flag to false. This may not
532 // be entirely accurate if the power library is missing but it's better then a segfault.
533 if( aField->GetParent() && aField->GetParent()->Type() == SCH_SYMBOL_T )
534 {
535 const SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( aField->GetParent() );
536 const LIB_SYMBOL* libSymbol = GetParent()->GetLibSymbol( symbol->GetLibId(), true );
537
538 if( libSymbol && libSymbol->IsPower() )
539 m_isPower = true;
540 }
541
543 this );
544
545 m_nameVisible->Show();
546 m_cbAllowAutoPlace->Show();
547
548 init();
549
551 {
552 m_StyledTextCtrl->Enable( false );
553 m_TextCtrl->Enable( false );
554 }
555}
556
557
559{
560 int key = aEvent.GetKey();
561
562 SCH_EDIT_FRAME* editFrame = static_cast<SCH_EDIT_FRAME*>( GetParent() );
563 wxArrayString autocompleteTokens;
564 int pos = m_StyledTextCtrl->GetCurrentPos();
565 int start = m_StyledTextCtrl->WordStartPosition( pos, true );
566 wxString partial;
567
568 // Currently, '\n' is not allowed in fields. So remove it when entered
569 // TODO: see if we must close the dialog. However this is not obvious, as
570 // if a \n is typed (and removed) when a text is selected, this text is deleted
571 // (in fact replaced by \n, that is removed by the filter)
572 if( key == '\n' )
573 {
574 wxString text = m_StyledTextCtrl->GetText();
575 int currpos = m_StyledTextCtrl->GetCurrentPos();
576 text.Replace( "\n", "" );
577 m_StyledTextCtrl->SetText( text );
578 m_StyledTextCtrl->GotoPos( currpos-1 );
579 return;
580 }
581
582 auto textVarRef =
583 [&]( int pt )
584 {
585 return pt >= 2
586 && m_StyledTextCtrl->GetCharAt( pt - 2 ) == '$'
587 && m_StyledTextCtrl->GetCharAt( pt - 1 ) == '{';
588 };
589
590 // Check for cross-reference
591 if( start > 1 && m_StyledTextCtrl->GetCharAt( start - 1 ) == ':' )
592 {
593 int refStart = m_StyledTextCtrl->WordStartPosition( start - 1, true );
594
595 if( textVarRef( refStart ) )
596 {
597 partial = m_StyledTextCtrl->GetRange( start, pos );
598
599 wxString ref = m_StyledTextCtrl->GetRange( refStart, start - 1 );
600 SCH_SHEET_LIST sheets = editFrame->Schematic().GetSheets();
602 SCH_SYMBOL* refSymbol = nullptr;
603
604 sheets.GetSymbols( refs );
605
606 for( size_t jj = 0; jj < refs.GetCount(); jj++ )
607 {
608 if( refs[ jj ].GetSymbol()->GetRef( &refs[ jj ].GetSheetPath(), true ) == ref )
609 {
610 refSymbol = refs[ jj ].GetSymbol();
611 break;
612 }
613 }
614
615 if( refSymbol )
616 refSymbol->GetContextualTextVars( &autocompleteTokens );
617 }
618 }
619 else if( textVarRef( start ) )
620 {
621 partial = m_StyledTextCtrl->GetTextRange( start, pos );
622
623 SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( m_field->GetParent() );
624 SCH_SHEET* sheet = dynamic_cast<SCH_SHEET*>( m_field->GetParent() );
625
626 if( symbol )
627 {
628 symbol->GetContextualTextVars( &autocompleteTokens );
629
630 SCHEMATIC* schematic = symbol->Schematic();
631
632 if( schematic && schematic->CurrentSheet().Last() )
633 schematic->CurrentSheet().Last()->GetContextualTextVars( &autocompleteTokens );
634 }
635
636 if( sheet )
637 sheet->GetContextualTextVars( &autocompleteTokens );
638
639 for( std::pair<wxString, wxString> entry : Prj().GetTextVars() )
640 autocompleteTokens.push_back( entry.first );
641 }
642
643 m_scintillaTricks->DoAutocomplete( partial, autocompleteTokens );
644 m_StyledTextCtrl->SetFocus();
645}
646
647
649{
650 SCH_EDIT_FRAME* editFrame = dynamic_cast<SCH_EDIT_FRAME*>( GetParent() );
651 SCH_ITEM* parent = dynamic_cast<SCH_ITEM*>( aField->GetParent() );
652 int fieldType = aField->GetId();
653
654 if( parent && parent->Type() == SCH_SYMBOL_T )
655 {
656 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( parent );
657
658 if( fieldType == REFERENCE_FIELD )
659 symbol->SetRef( aSheetPath, m_text );
660 else if( fieldType == VALUE_FIELD )
661 symbol->SetValue( m_text );
662 else if( fieldType == FOOTPRINT_FIELD )
663 symbol->SetFootprint( m_text );
664 }
665 else if( parent && parent->Type() == SCH_GLOBAL_LABEL_T )
666 {
667 if( fieldType == 0 )
668 {
669 if( m_visible->GetValue() != parent->Schematic()->Settings().m_IntersheetRefsShow )
670 {
671 DisplayInfoMessage( this, _( "Intersheet reference visibility is "
672 "controlled globally from "
673 "Schematic Setup > General > Formatting" ) );
674 }
675 }
676 }
677
678 bool positioningModified = false;
679
680 if( aField->GetPosition() != m_position )
681 positioningModified = true;
682
683 if( aField->GetTextAngle().IsVertical() != m_isVertical )
684 positioningModified = true;
685
687 positioningModified = true;
688
690 positioningModified = true;
691
692 // convert any text variable cross-references to their UUIDs
694
695 aField->SetText( m_text );
696 updateText( aField );
697 aField->SetPosition( m_position );
698
699 aField->SetFont( m_font );
700
701 aField->SetNameShown( m_isNameVisible );
703
704 // Note that we must set justifications before we can ask if they're flipped. If the old
705 // justification is center then it won't know (whereas if the new justification is center
706 // the we don't care).
709
710 if( aField->IsHorizJustifyFlipped() )
712
713 if( aField->IsVertJustifyFlipped() )
715
716 // The value, footprint and datasheet fields should be kept in sync in multi-unit parts.
717 // Of course the symbol must be annotated to collect other units.
718 if( editFrame && parent && parent->Type() == SCH_SYMBOL_T )
719 {
720 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( parent );
721
722 if( symbol->IsAnnotated( aSheetPath ) && ( fieldType == VALUE_FIELD
723 || fieldType == FOOTPRINT_FIELD
724 || fieldType == DATASHEET_FIELD ) )
725 {
726 wxString ref = symbol->GetRef( aSheetPath );
727 int unit = symbol->GetUnit();
728 LIB_ID libId = symbol->GetLibId();
729
730 for( SCH_SHEET_PATH& sheet : editFrame->Schematic().GetSheets() )
731 {
732 SCH_SCREEN* screen = sheet.LastScreen();
733 std::vector<SCH_SYMBOL*> otherUnits;
734 constexpr bool appendUndo = true;
735
736 CollectOtherUnits( ref, unit, libId, sheet, &otherUnits );
737
738 for( SCH_SYMBOL* otherUnit : otherUnits )
739 {
740 editFrame->SaveCopyInUndoList( screen, otherUnit, UNDO_REDO::CHANGED,
741 appendUndo );
742
743 if( fieldType == VALUE_FIELD )
744 otherUnit->SetValue( m_text );
745 else if( fieldType == FOOTPRINT_FIELD )
746 otherUnit->SetFootprint( m_text );
747 else
748 otherUnit->GetField( DATASHEET_FIELD )->SetText( m_text );
749
750 editFrame->UpdateItem( otherUnit, false, true );
751 }
752 }
753 }
754 }
755
756 if( positioningModified && parent )
757 parent->ClearFieldsAutoplaced();
758}
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:183
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:194
const VECTOR2I & GetTextPos() const
Definition: eda_text.h:198
COLOR4D GetTextColor() const
Definition: eda_text.h:195
bool IsItalic() const
Definition: eda_text.h:120
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:117
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:126
void SetTextPos(const VECTOR2I &aPoint)
Definition: eda_text.cpp:371
KIFONT::FONT * GetFont() const
Definition: eda_text.h:178
int GetTextWidth() const
Definition: eda_text.h:189
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
Definition: eda_text.cpp:248
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition: eda_text.h:139
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:123
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:142
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
virtual bool ShowModal(wxString *aResult=nullptr, wxWindow *aResultantFocusWindow=nullptr)
Show this wxFrame as if it were a modal dialog, with all other instantiated wxFrames disabled until t...
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:394
Field object used in symbol libraries.
Definition: lib_field.h:60
bool CanAutoplace() const
Definition: lib_field.h:184
bool IsNameShown() const
Definition: lib_field.h:181
void SetNameShown(bool aShown=true)
Definition: lib_field.h:182
void SetCanAutoplace(bool aCanPlace)
Definition: lib_field.h:185
int GetId() const
Definition: lib_field.h:115
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:49
LIB_SYMBOL * GetParent() const
Definition: lib_item.h:168
Define a library symbol object.
Definition: lib_symbol.h:98
bool IsPower() const
Definition: lib_symbol.cpp:552
virtual void SetName(const wxString &aName)
Definition: lib_symbol.cpp:441
virtual std::map< wxString, wxString > & GetTextVars() const
Definition: project.cpp:81
Holds all the data relating to one schematic.
Definition: schematic.h:60
SCH_SHEET_PATH & CurrentSheet() const override
Definition: schematic.h:119
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:172
wxString ConvertKIIDsToRefs(const wxString &aSource) const
Definition: schematic.cpp:387
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:85
wxString ConvertRefsToKIIDs(const wxString &aSource) const
Definition: schematic.cpp:319
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:50
GR_TEXT_V_ALIGN_T GetEffectiveVertJustify() const
Definition: sch_field.cpp:542
VECTOR2I GetPosition() const override
Definition: sch_field.cpp:1052
bool IsNameShown() const
Definition: sch_field.h:149
bool IsHorizJustifyFlipped() const
Return whether the field will be rendered with the horizontal justification inverted due to rotation ...
Definition: sch_field.cpp:482
bool IsVertJustifyFlipped() const
Definition: sch_field.cpp:519
void SetCanAutoplace(bool aCanPlace)
Definition: sch_field.h:153
int GetId() const
Definition: sch_field.h:116
GR_TEXT_H_ALIGN_T GetEffectiveHorizJustify() const
Definition: sch_field.cpp:505
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
Definition: sch_field.cpp:811
void SetPosition(const VECTOR2I &aPosition) override
Definition: sch_field.cpp:1032
bool CanAutoplace() const
Definition: sch_field.h:152
void SetNameShown(bool aShown=true)
Definition: sch_field.h:150
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:55
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:80
void SetValue(const SCH_SHEET_PATH *sheet, const wxString &aValue)
Definition: sch_symbol.cpp:795
int GetUnit() const
Definition: sch_symbol.h:231
static bool IsReferenceStringValid(const wxString &aReferenceString)
Test for an acceptable reference string.
Definition: sch_symbol.cpp:668
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
Definition: sch_symbol.cpp:632
void SetFootprint(const SCH_SHEET_PATH *sheet, const wxString &aFootprint)
Definition: sch_symbol.cpp:854
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:674
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:711
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)
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:280
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:320
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:144
void SelectReferenceNumber(wxTextEntry *aTextEntry)
Select the number (or "?") in a reference for ease of editing.
Definition: ui_common.cpp:218
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:43
@ SHEETFILENAME
Definition: sch_sheet.h:44
Definitions of control validators for schematic dialogs.
#define SHEETFILENAME_V
#define LABELUSERFIELD_V
#define SHEETNAME_V
#define SHEETUSERFIELD_V
wxString UnescapeString(const wxString &aSource)
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
@ CTX_LIBID
Definition: string_utils.h:55
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:155
@ SCH_SHEET_T
Definition: typeinfo.h:157
@ SCH_GLOBAL_LABEL_T
Definition: typeinfo.h:151
Definition of file extensions used in Kicad.