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-2024 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
28#include <widgets/font_choice.h>
31#include <bitmaps.h>
32#include <kiway.h>
33#include <kiway_express.h>
34#include <confirm.h>
35#include <common.h>
36#include <string_utils.h>
37#include <sch_edit_frame.h>
38#include <ee_collectors.h>
39#include <sch_symbol.h>
40#include <template_fieldnames.h>
41#include <symbol_library.h>
42#include <sch_validators.h>
43#include <schematic.h>
44#include <sch_commit.h>
46#include <sch_text.h>
47#include <scintilla_tricks.h>
49
50
52 const SCH_FIELD* aField ) :
53 DIALOG_FIELD_PROPERTIES_BASE( aParent, wxID_ANY, aTitle ),
54 m_posX( aParent, m_xPosLabel, m_xPosCtrl, m_xPosUnits, true ),
55 m_posY( aParent, m_yPosLabel, m_yPosCtrl, m_yPosUnits, true ),
56 m_textSize( aParent, m_textSizeLabel, m_textSizeCtrl, m_textSizeUnits, true ),
57 m_font( nullptr ),
58 m_firstFocus( true ),
59 m_scintillaTricks( nullptr ),
60 m_field( aField )
61{
62 COLOR_SETTINGS* colorSettings = aParent->GetColorSettings();
63 COLOR4D schematicBackground = colorSettings->GetColor( LAYER_SCHEMATIC_BACKGROUND );
64
65 wxASSERT( m_field );
66
67 m_note->SetFont( KIUI::GetInfoFont( this ).Italic() );
68 m_note->Show( false );
69
70 m_scintillaTricks = new SCINTILLA_TRICKS( m_StyledTextCtrl, wxT( "{}" ), true,
71 // onAcceptFn
72 [this]( wxKeyEvent& aEvent )
73 {
74 wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
75 } );
76
77 m_StyledTextCtrl->SetEOLMode( wxSTC_EOL_LF ); // Normalize EOL across platforms
78
79#ifdef _WIN32
80 // Without this setting, on Windows, some esoteric unicode chars create display issue
81 // in a wxStyledTextCtrl.
82 // for SetTechnology() info, see https://www.scintilla.org/ScintillaDoc.html#SCI_SETTECHNOLOGY
83 m_StyledTextCtrl->SetTechnology(wxSTC_TECHNOLOGY_DIRECTWRITE);
84#endif
85
86 m_textColorSwatch->SetDefaultColor( COLOR4D::UNSPECIFIED );
87 m_textColorSwatch->SetSwatchBackground( schematicBackground );
88
90
92 m_horizontal->SetBitmap( KiBitmapBundle( BITMAPS::text_horizontal ) );
94 m_vertical->SetBitmap( KiBitmapBundle( BITMAPS::text_vertical ) );
95
97
99 m_bold->SetBitmap( KiBitmapBundle( BITMAPS::text_bold ) );
101 m_italic->SetBitmap( KiBitmapBundle( BITMAPS::text_italic ) );
102
104
106 m_hAlignLeft->SetBitmap( KiBitmapBundle( BITMAPS::text_align_left ) );
108 m_hAlignCenter->SetBitmap( KiBitmapBundle( BITMAPS::text_align_center ) );
110 m_hAlignRight->SetBitmap( KiBitmapBundle( BITMAPS::text_align_right ) );
111
113
115 m_vAlignTop->SetBitmap( KiBitmapBundle( BITMAPS::text_valign_top ) );
117 m_vAlignCenter->SetBitmap( KiBitmapBundle( BITMAPS::text_valign_center ) );
119 m_vAlignBottom->SetBitmap( KiBitmapBundle( BITMAPS::text_valign_bottom ) );
120
122
123 m_horizontal->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onOrientButton, this );
124 m_vertical->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onOrientButton, this );
125
126 m_hAlignLeft->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onHAlignButton, this );
127 m_hAlignCenter->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onHAlignButton, this );
128 m_hAlignRight->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onHAlignButton, this );
129
130 m_vAlignTop->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onVAlignButton, this );
131 m_vAlignCenter->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onVAlignButton, this );
132 m_vAlignBottom->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onVAlignButton, this );
133
134 // show text variable cross-references in a human-readable format
135 if( aField->Schematic() )
136 m_text = aField->Schematic()->ConvertKIIDsToRefs( aField->GetText() );
137 else
138 m_text = aField->GetText();
139
141 m_isItalic = aField->IsItalic();
142 m_isBold = aField->IsBold();
143 m_color = aField->GetTextColor();
144 m_position = aField->GetTextPos();
145 m_size = aField->GetTextWidth();
149 m_isVisible = aField->IsVisible();
150
151 m_isSheetFilename = false;
152
153 if( aField->GetParent() && aField->GetParent()->Type() == LIB_SYMBOL_T )
154 {
155 const LIB_SYMBOL* symbol = static_cast<const LIB_SYMBOL*>( aField->GetParentSymbol() );
156
157 m_fieldId = aField->GetId();
158
159 /*
160 * Symbol netlist format:
161 * pinNumber pinName <tab> pinNumber pinName...
162 * fpFilter fpFilter...
163 */
164 wxString netlist;
165 wxArrayString pins;
166
167 for( SCH_PIN* pin : symbol->GetPins( 0 /* all units */, 1 /* single bodyStyle */ ) )
168 pins.push_back( pin->GetNumber() + ' ' + pin->GetShownName() );
169
170 if( !pins.IsEmpty() )
171 netlist << EscapeString( wxJoin( pins, '\t' ), CTX_LINE );
172
173 netlist << wxS( "\r" );
174
175 wxArrayString fpFilters = symbol->GetFPFilters();
176
177 if( !fpFilters.IsEmpty() )
178 netlist << EscapeString( wxJoin( fpFilters, ' ' ), CTX_LINE );
179
180 netlist << wxS( "\r" );
181
183 }
184 else if( aField->GetParent() && aField->GetParent()->Type() == SCH_SYMBOL_T )
185 {
186 const SCH_SYMBOL* symbol = static_cast<const SCH_SYMBOL*>( aField->GetParentSymbol() );
187 SCH_SHEET_PATH sheetPath = static_cast<SCH_EDIT_FRAME*>( aParent )->GetCurrentSheet();
188
189 m_fieldId = aField->GetId();
190
191 /*
192 * Symbol netlist format:
193 * pinNumber pinName <tab> pinNumber pinName...
194 * fpFilter fpFilter...
195 */
196 wxString netlist;
197
198 // We need the list of pins of the lib symbol, not just the pins of the current
199 // sch symbol, that can be just an unit of a multi-unit symbol, to be able to
200 // select/filter right footprints
201 wxArrayString pins;
202
203 const std::unique_ptr< LIB_SYMBOL >& lib_symbol = symbol->GetLibSymbolRef();
204
205 if( lib_symbol )
206 {
207 for( SCH_PIN* pin : lib_symbol->GetPins( 0 /* all units */, 1 /* single bodyStyle */ ) )
208 pins.push_back( pin->GetNumber() + ' ' + pin->GetShownName() );
209 }
210
211 if( !pins.IsEmpty() )
212 netlist << EscapeString( wxJoin( pins, '\t' ), CTX_LINE );
213
214 netlist << wxS( "\r" );
215
216 wxArrayString fpFilters = symbol->GetLibSymbolRef()->GetFPFilters();
217
218 if( !fpFilters.IsEmpty() )
219 netlist << EscapeString( wxJoin( fpFilters, ' ' ), CTX_LINE );
220
221 netlist << wxS( "\r" );
222
224 }
225 else if( aField->GetParent() && aField->GetParent()->Type() == SCH_SHEET_T )
226 {
227 switch( aField->GetId() )
228 {
229 case SHEETNAME:
231 break;
232
233 case SHEETFILENAME:
234 m_isSheetFilename = true;
236 m_note->SetLabel( wxString::Format( m_note->GetLabel(),
237 _( "Sheet filename can only be modified in Sheet Properties dialog." ) ) );
238 m_note->Show( true );
239 break;
240
241 default:
243 break;
244 }
245 }
246 else if( aField->GetParent() && aField->GetParent()->IsType( { SCH_LABEL_LOCATE_ANY_T } ) )
247 {
249 }
250
251 m_textLabel->SetLabel( aField->GetName() + wxS( ":" ) );
252
254
257
260
261 m_StyledTextCtrl->Bind( wxEVT_STC_CHARADDED,
263 m_StyledTextCtrl->Bind( wxEVT_STC_AUTOCOMP_CHAR_DELETED,
265
266 m_nameVisible->Show();
267 m_cbAllowAutoPlace->Show();
268
269 init();
270
272 {
273 m_StyledTextCtrl->Enable( false );
274 m_TextCtrl->Enable( false );
275 }
276}
277
278
280{
281 delete m_scintillaTricks;
282}
283
284
286{
287 // Disable options for graphic text editing which are not needed for fields.
288 m_commonToAllBodyStyles->Show( false );
289 m_commonToAllUnits->Show( false );
290
291 // Predefined fields cannot contain some chars and cannot be empty, so they need a
292 // SCH_FIELD_VALIDATOR (m_StyledTextCtrl cannot use a SCH_FIELD_VALIDATOR).
298 {
299 m_TextCtrl->SetValidator( FIELD_VALIDATOR( m_fieldId, &m_text ) );
301
302 m_StyledTextCtrl->Show( false );
303 }
304 else
305 {
307
308 m_TextCtrl->Show( false );
309 }
310
311 // Show the unit selector for reference fields on multi-unit symbols
312 bool showUnitSelector = m_fieldId == REFERENCE_FIELD
316
317 m_unitLabel->Show( showUnitSelector );
318 m_unitChoice->Show( showUnitSelector );
319
320 // Show the footprint selection dialog if this is the footprint field.
321 m_TextValueSelectButton->SetBitmap( KiBitmapBundle( BITMAPS::small_library ) );
323
324 m_TextCtrl->Enable( true );
325
326 GetSizer()->SetSizeHints( this );
327
328 // Adjust the height of the scintilla editor after the first layout to show a single line
329 // (multiline text is not supported in fields and will be removed)
330 if( m_StyledTextCtrl->IsShown() )
331 {
332 wxSize maxSize = m_StyledTextCtrl->GetSize();
333 maxSize.x = -1; // Do not fix the max width
334 maxSize.y = m_xPosCtrl->GetSize().y;
335 m_StyledTextCtrl->SetMaxSize( maxSize );
336 m_StyledTextCtrl->SetUseVerticalScrollBar( false );
337 m_StyledTextCtrl->SetUseHorizontalScrollBar( false );
338 }
339
341
342 // Now all widgets have the size fixed, call FinishDialogSettings
344}
345
346
348{
349 // pick a footprint using the footprint picker.
350 wxString fpid;
351
352 if( m_StyledTextCtrl->IsShown() )
353 fpid = m_StyledTextCtrl->GetValue();
354 else
355 fpid = m_TextCtrl->GetValue();
356
357 if( KIWAY_PLAYER* frame = Kiway().Player( FRAME_FOOTPRINT_CHOOSER, true ) )
358 {
360 frame->KiwayMailIn( event );
361
362 if( frame->ShowModal( &fpid, this ) )
363 {
364 if( m_StyledTextCtrl->IsShown() )
365 m_StyledTextCtrl->SetValue( fpid );
366 else
367 m_TextCtrl->SetValue( fpid );
368 }
369
370 frame->Destroy();
371 }
372}
373
374
376{
377 if( m_firstFocus )
378 {
379#ifdef __WXGTK__
380 // Force an update of the text control before setting the text selection
381 // This is needed because GTK seems to ignore the selection on first update
382 //
383 // Note that we can't do this on OSX as it tends to provoke Apple's
384 // "[NSAlert runModal] may not be invoked inside of transaction begin/commit pair"
385 // bug. See: https://bugs.launchpad.net/kicad/+bug/1837225
387 m_TextCtrl->Update();
388#endif
389
391 KIUI::SelectReferenceNumber( static_cast<wxTextEntry*>( m_TextCtrl ) );
392 else if( m_fieldId == VALUE_FIELD || m_fieldId == SHEETNAME_V )
393 m_TextCtrl->SetSelection( -1, -1 );
394
395 m_firstFocus = false;
396 }
397
398 event.Skip();
399}
400
401
402void DIALOG_FIELD_PROPERTIES::onOrientButton( wxCommandEvent& aEvent )
403{
404 for( BITMAP_BUTTON* btn : { m_horizontal, m_vertical } )
405 {
406 if( btn->IsChecked() && btn != aEvent.GetEventObject() )
407 btn->Check( false );
408 }
409}
410
411
412void DIALOG_FIELD_PROPERTIES::onHAlignButton( wxCommandEvent& aEvent )
413{
415 {
416 if( btn->IsChecked() && btn != aEvent.GetEventObject() )
417 btn->Check( false );
418 }
419}
420
421
422void DIALOG_FIELD_PROPERTIES::onVAlignButton( wxCommandEvent& aEvent )
423{
425 {
426 if( btn->IsChecked() && btn != aEvent.GetEventObject() )
427 btn->Check( false );
428 }
429}
430
431
433{
434 if( m_TextCtrl->IsShown() )
435 {
436 m_TextCtrl->SetValue( EscapeString( m_text, CTX_LINE ) );
437 }
438 else if( m_StyledTextCtrl->IsShown() )
439 {
441 m_StyledTextCtrl->EmptyUndoBuffer();
442 }
443
444 if( m_unitChoice->IsShown() )
445 {
446 const SCH_SYMBOL* symbol = static_cast<const SCH_SYMBOL*>( m_field->GetParentSymbol() );
447
448 for( int ii = 1; ii <= symbol->GetUnitCount(); ii++ )
449 {
450 if( symbol->HasUnitDisplayName( ii ) )
451 m_unitChoice->Append( symbol->GetUnitDisplayName( ii ) );
452 else
453 m_unitChoice->Append( symbol->SubReference( ii, false ) );
454 }
455
456 if( symbol->GetUnit() <= ( int )m_unitChoice->GetCount() )
457 m_unitChoice->SetSelection( symbol->GetUnit() - 1 );
458 }
459
461
465
468
471
473
475 {
476 case GR_TEXT_H_ALIGN_LEFT: m_hAlignLeft->Check( true ); break;
477 case GR_TEXT_H_ALIGN_CENTER: m_hAlignCenter->Check( true ); break;
478 case GR_TEXT_H_ALIGN_RIGHT: m_hAlignRight->Check( true ); break;
480 }
481
482 switch ( m_verticalJustification )
483 {
484 case GR_TEXT_V_ALIGN_TOP: m_vAlignTop->Check( true ); break;
485 case GR_TEXT_V_ALIGN_CENTER: m_vAlignCenter->Check( true ); break;
486 case GR_TEXT_V_ALIGN_BOTTOM: m_vAlignBottom->Check( true ); break;
488 }
489
490 m_visible->SetValue( m_isVisible );
491 m_nameVisible->SetValue( m_isNameVisible );
493
494 return true;
495}
496
497
499{
500 if( m_TextCtrl->IsShown() )
501 m_text = UnescapeString( m_TextCtrl->GetValue() );
502 else if( m_StyledTextCtrl->IsShown() )
503 m_text = UnescapeString( m_StyledTextCtrl->GetValue() );
504
507
510
513
515
519
520 if( m_hAlignLeft->IsChecked() )
522 else if( m_hAlignCenter->IsChecked() )
524 else
526
527 if( m_vAlignTop->IsChecked() )
529 else if( m_vAlignCenter->IsChecked() )
531 else
533
534 m_isVisible = m_visible->GetValue();
535 m_isNameVisible = m_nameVisible->GetValue();
537
538 return true;
539}
540
541
543{
544 if( aText->GetTextWidth() != m_size )
545 aText->SetTextSize( VECTOR2I( m_size, m_size ) );
546
547 aText->SetFont( m_font );
548 aText->SetVisible( m_isVisible );
550 aText->SetItalic( m_isItalic );
551 aText->SetBold( m_isBold );
552 aText->SetTextColor( m_color );
553}
554
555
557{
558 aField->SetText( m_text );
559
560 updateText( aField );
561
562 aField->SetNameShown( m_isNameVisible );
564
567 aField->SetTextPos( m_position );
568}
569
570
571void DIALOG_FIELD_PROPERTIES::onScintillaCharAdded( wxStyledTextEvent &aEvent )
572{
574}
575
576
578 SCH_SHEET_PATH* aSheetPath )
579{
580 SCH_EDIT_FRAME* editFrame = dynamic_cast<SCH_EDIT_FRAME*>( GetParent() );
581 SCH_ITEM* parent = dynamic_cast<SCH_ITEM*>( aField->GetParent() );
582 int fieldType = aField->GetId();
583
584 if( parent && parent->Type() == SCH_SYMBOL_T )
585 {
586 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( parent );
587
588 if( fieldType == REFERENCE_FIELD )
589 symbol->SetRef( aSheetPath, m_text );
590 else if( fieldType == VALUE_FIELD )
591 symbol->SetValueFieldText( m_text );
592 else if( fieldType == FOOTPRINT_FIELD )
593 symbol->SetFootprintFieldText( m_text );
594
595 // Set the unit selection in multiple units per package
596 if( m_unitChoice->IsShown() )
597 {
598 int unit_selection = m_unitChoice->IsEnabled() ? m_unitChoice->GetSelection() + 1 : 1;
599 symbol->SetUnitSelection( aSheetPath, unit_selection );
600 symbol->SetUnit( unit_selection );
601 }
602 }
603 else if( parent && parent->Type() == SCH_GLOBAL_LABEL_T )
604 {
605 if( aField->GetCanonicalName() == wxT( "Intersheetrefs" ) )
606 {
607 if( m_visible->GetValue() != parent->Schematic()->Settings().m_IntersheetRefsShow )
608 {
609 DisplayInfoMessage( this, _( "Intersheet reference visibility is "
610 "controlled globally from "
611 "Schematic Setup > General > Formatting" ) );
612 }
613 }
614 }
615
616 bool positioningModified = false;
617
618 if( aField->GetPosition() != m_position )
619 positioningModified = true;
620
621 if( aField->GetTextAngle().IsVertical() != m_isVertical )
622 positioningModified = true;
623
625 positioningModified = true;
626
628 positioningModified = true;
629
630 // convert any text variable cross-references to their UUIDs
632
633 // Changing a sheetname need to update the hierarchy navigator
634 bool needUpdateHierNav = false;
635
636 if( parent && parent->Type() == SCH_SHEET_T && fieldType == SHEETNAME )
637 needUpdateHierNav = m_text != aField->GetText();
638
639 aField->SetText( m_text );
640 updateText( aField );
641 aField->SetPosition( m_position );
642
643 aField->SetNameShown( m_isNameVisible );
645
646 // Note that we must set justifications before we can ask if they're flipped. If the old
647 // justification is center then it won't know (whereas if the new justification is center
648 // the we don't care).
651
652 if( aField->IsHorizJustifyFlipped() )
654
655 if( aField->IsVertJustifyFlipped() )
657
658 // The value, footprint and datasheet fields should be kept in sync in multi-unit parts.
659 // Of course the symbol must be annotated to collect other units.
660 if( editFrame && parent && parent->Type() == SCH_SYMBOL_T )
661 {
662 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( parent );
663
664 if( symbol->IsAnnotated( aSheetPath ) && ( fieldType == VALUE_FIELD
665 || fieldType == FOOTPRINT_FIELD
666 || fieldType == DATASHEET_FIELD ) )
667 {
668 wxString ref = symbol->GetRef( aSheetPath );
669 int unit = symbol->GetUnit();
670 LIB_ID libId = symbol->GetLibId();
671
672 for( SCH_SHEET_PATH& sheet : editFrame->Schematic().Hierarchy() )
673 {
674 SCH_SCREEN* screen = sheet.LastScreen();
675 std::vector<SCH_SYMBOL*> otherUnits;
676
677 CollectOtherUnits( ref, unit, libId, sheet, &otherUnits );
678
679 for( SCH_SYMBOL* otherUnit : otherUnits )
680 {
681 aCommit->Modify( otherUnit, screen );
682
683 if( fieldType == VALUE_FIELD )
684 otherUnit->SetValueFieldText( m_text );
685 else if( fieldType == FOOTPRINT_FIELD )
686 otherUnit->SetFootprintFieldText( m_text );
687 else
688 otherUnit->GetField( DATASHEET_FIELD )->SetText( m_text );
689
690 editFrame->UpdateItem( otherUnit, false, true );
691 }
692 }
693 }
694 }
695
696 if( positioningModified && parent )
697 parent->ClearFieldsAutoplaced();
698
699 //Update the hierarchy navigator labels if needed
700 if( needUpdateHierNav )
702}
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap)
Definition: bitmap.cpp:110
A bitmap button widget that behaves like an AUI toolbar item's button when it is drawn.
Definition: bitmap_button.h:42
void SetIsRadioButton()
bool IsChecked() const
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).
void SetBitmap(const wxBitmapBundle &aBmp)
Set the bitmap shown when the button is enabled.
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.
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Create an undo entry for an item that has been already modified.
Definition: commit.h:105
Class DIALOG_FIELD_PROPERTIES_BASE.
void onOrientButton(wxCommandEvent &aEvent)
void OnTextValueSelectButtonClick(wxCommandEvent &aEvent) override
Handle the select button next to the text value field.
DIALOG_FIELD_PROPERTIES(SCH_BASE_FRAME *aParent, const wxString &aTitle, const SCH_FIELD *aField)
GR_TEXT_H_ALIGN_T m_horizontalJustification
void onVAlignButton(wxCommandEvent &aEvent)
SCINTILLA_TRICKS * m_scintillaTricks
void UpdateField(SCH_FIELD *aField)
void onScintillaCharAdded(wxStyledTextEvent &aEvent)
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
void SetInitialFocus(wxWindow *aWindow)
Sets the window (usually a wxTextCtrl) that should be focused when the dialog is shown.
Definition: dialog_shim.h:102
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:143
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:101
virtual bool IsType(const std::vector< KICAD_T > &aScanTypes) const
Check whether the item is one of the listed types.
Definition: eda_item.h:176
EDA_ITEM * GetParent() const
Definition: eda_item.h:103
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:79
void SetTextColor(const COLOR4D &aColor)
Definition: eda_text.h:249
const VECTOR2I & GetTextPos() const
Definition: eda_text.h:253
COLOR4D GetTextColor() const
Definition: eda_text.h:250
bool IsItalic() const
Definition: eda_text.h:152
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:130
void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true)
Definition: eda_text.cpp:419
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:94
virtual bool IsVisible() const
Definition: eda_text.h:170
void SetTextPos(const VECTOR2I &aPoint)
Definition: eda_text.cpp:464
KIFONT::FONT * GetFont() const
Definition: eda_text.h:230
int GetTextWidth() const
Definition: eda_text.h:244
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
Definition: eda_text.cpp:321
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition: eda_text.h:183
virtual void SetVisible(bool aVisible)
Definition: eda_text.cpp:290
static GR_TEXT_H_ALIGN_T MapHorizJustify(int aHorizJustify)
Definition: eda_text.cpp:64
void SetBold(bool aBold)
Set the text to be bold - this will also update the font if needed.
Definition: eda_text.cpp:240
bool IsBold() const
Definition: eda_text.h:167
static GR_TEXT_V_ALIGN_T MapVertJustify(int aVertJustify)
Definition: eda_text.cpp:78
GR_TEXT_V_ALIGN_T GetVertJustify() const
Definition: eda_text.h:186
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition: eda_text.cpp:204
void SetItalic(bool aItalic)
Set the text to be italic - this will also update the font if needed.
Definition: eda_text.cpp:212
void SetFont(KIFONT::FONT *aFont)
Definition: eda_text.cpp:403
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Definition: eda_text.cpp:313
A text control validator used for validating the text allowed in fields.
Definition: validators.h:221
KIFONT::FONT * GetFontSelection(bool aBold, bool aItalic, bool aForDrawingSheet=false) const
bool HaveFontSelection() const
Definition: font_choice.cpp:94
void SetFontSelection(KIFONT::FONT *aFont)
Definition: font_choice.cpp:73
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
Carry a payload from one KIWAY_PLAYER to another within a PROJECT.
Definition: kiway_express.h:40
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:55
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Definition: kiway_player.h:65
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:78
std::vector< SCH_PIN * > GetPins(int aUnit=0, int aBodyStyle=0) const
Return a list of pin object pointers from the draw item list.
Definition: lib_symbol.cpp:810
wxArrayString GetFPFilters() const
Definition: lib_symbol.h:206
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:314
wxString ConvertKIIDsToRefs(const wxString &aSource) const
Definition: schematic.cpp:572
SCH_SHEET_LIST Hierarchy() const override
Return the full schematic flattened hierarchical sheet list.
Definition: schematic.cpp:214
wxString ConvertRefsToKIIDs(const wxString &aSource) const
Definition: schematic.cpp:505
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.
SCHEMATIC & Schematic() const
void UpdateLabelsHierarchyNavigator()
Update the hierarchy navigation tree labels.
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false, bool aUpdateRtree=false) override
Mark an item for refresh.
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:744
VECTOR2I GetPosition() const override
Definition: sch_field.cpp:1485
bool IsNameShown() const
Definition: sch_field.h:208
bool IsHorizJustifyFlipped() const
Return whether the field will be rendered with the horizontal justification inverted due to rotation ...
Definition: sch_field.cpp:644
bool IsVertJustifyFlipped() const
Definition: sch_field.cpp:701
void SetCanAutoplace(bool aCanPlace)
Definition: sch_field.h:220
wxString GetCanonicalName() const
Get a non-language-specific name for a field which can be used for storage, variable look-up,...
Definition: sch_field.cpp:1252
bool IsNamedVariable() const
Named variables are fields whose names are variables like ${VAR}.
Definition: sch_field.h:217
int GetId() const
Definition: sch_field.h:133
GR_TEXT_H_ALIGN_T GetEffectiveHorizJustify() const
Definition: sch_field.cpp:687
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
Definition: sch_field.cpp:1227
void SetPosition(const VECTOR2I &aPosition) override
Definition: sch_field.cpp:1465
bool CanAutoplace() const
Definition: sch_field.h:219
void SetText(const wxString &aText) override
Definition: sch_field.cpp:1212
void OnScintillaCharAdded(SCINTILLA_TRICKS *aScintillaTricks, wxStyledTextEvent &aEvent) const
Definition: sch_field.cpp:807
void SetNameShown(bool aShown=true)
Definition: sch_field.h:209
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:166
const SYMBOL * GetParentSymbol() const
Definition: sch_item.cpp:166
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:150
int GetUnit() const
Definition: sch_item.h:229
void ClearFieldsAutoplaced()
Definition: sch_item.h:551
virtual void SetUnit(int aUnit)
Definition: sch_item.h:228
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
Schematic symbol object.
Definition: sch_symbol.h:104
wxString GetUnitDisplayName(int aUnit) const
Return the display name for a given unit aUnit.
Definition: sch_symbol.cpp:477
wxString SubReference(int aUnit, bool aAddSeparator=true) const
Definition: sch_symbol.cpp:856
bool IsAnnotated(const SCH_SHEET_PATH *aSheet) const
Check if the symbol has a valid annotation (reference) for the given sheet path.
Definition: sch_symbol.cpp:815
void SetValueFieldText(const wxString &aValue)
Definition: sch_symbol.cpp:917
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:779
void SetFootprintFieldText(const wxString &aFootprint)
Definition: sch_symbol.cpp:933
const LIB_ID & GetLibId() const override
Definition: sch_symbol.h:193
int GetUnitCount() const override
Return the number of units per package of the symbol.
Definition: sch_symbol.cpp:468
void SetUnitSelection(const SCH_SHEET_PATH *aSheet, int aUnitSelection)
Set the selected unit of this symbol on one sheet.
Definition: sch_symbol.cpp:881
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
Definition: sch_symbol.h:212
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const override
Definition: sch_symbol.cpp:737
bool HasUnitDisplayName(int aUnit) const
Return true if the given unit aUnit has a display name set.
Definition: sch_symbol.cpp:485
Add cut/copy/paste, dark theme, autocomplete and brace highlighting to a wxStyleTextCtrl instance.
void SetBitmap(const wxBitmapBundle &aBmp)
virtual bool IsMulti() const =0
int GetIntValue()
Definition: unit_binder.h:129
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:422
The common library.
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:222
This file is part of the common library.
#define _(s)
static constexpr EDA_ANGLE ANGLE_VERTICAL
Definition: eda_angle.h:398
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
Definition: eda_angle.h:397
void CollectOtherUnits(const wxString &aRef, int aUnit, const LIB_ID &aLibId, SCH_SHEET_PATH &aSheet, std::vector< SCH_SYMBOL * > *otherUnits)
@ FRAME_FOOTPRINT_CHOOSER
Definition: frame_type.h:44
static const std::string KiCadSchematicFileExtension
@ LAYER_SCHEMATIC_BACKGROUND
Definition: layer_ids.h:391
@ MAIL_SYMBOL_NETLIST
Definition: mail_type.h:45
KICOMMON_API wxFont GetInfoFont(wxWindow *aWindow)
Definition: ui_common.cpp:154
KICOMMON_API void SelectReferenceNumber(wxTextEntry *aTextEntry)
Select the number (or "?") in a reference for ease of editing.
Definition: ui_common.cpp:228
@ SHEETNAME
Definition: sch_sheet.h:45
@ SHEETFILENAME
Definition: sch_sheet.h:46
Definitions of control validators for schematic dialogs.
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_LINE
Definition: string_utils.h:59
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_H_ALIGN_INDETERMINATE
@ GR_TEXT_V_ALIGN_BOTTOM
@ GR_TEXT_V_ALIGN_INDETERMINATE
@ GR_TEXT_V_ALIGN_CENTER
@ GR_TEXT_V_ALIGN_TOP
@ LIB_SYMBOL_T
Definition: typeinfo.h:148
@ SCH_SYMBOL_T
Definition: typeinfo.h:172
@ SCH_SHEET_T
Definition: typeinfo.h:174
@ SCH_GLOBAL_LABEL_T
Definition: typeinfo.h:168
#define SHEETFILENAME_V
Definition: validators.h:47
#define LABELUSERFIELD_V
Definition: validators.h:50
#define SHEETNAME_V
Definition: validators.h:46
#define SHEETUSERFIELD_V
Definition: validators.h:48
VECTOR2< int32_t > VECTOR2I
Definition: vector2d.h:691
Definition of file extensions used in Kicad.