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 The 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 <sch_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 __WXGTK__
80 m_StyledTextCtrl->SetExtraAscent( 6 );
81 m_StyledTextCtrl->SetExtraDescent( 2 );
82#elif defined ( __WXMSW__ )
83 // Do nothing: SetExtraAscent() + SetExtraDescent(), when set to a value not 0
84 // Generate a strange bug: the text is not always shown (Perhaps a wxMSW bug)
85 // and this call is not needed on WXMSW
86#else
87 m_StyledTextCtrl->SetExtraAscent( 1 );
88 m_StyledTextCtrl->SetExtraDescent( 2 );
89#endif
90
91#ifdef _WIN32
92 // Without this setting, on Windows, some esoteric unicode chars create display issue
93 // in a wxStyledTextCtrl.
94 // for SetTechnology() info, see https://www.scintilla.org/ScintillaDoc.html#SCI_SETTECHNOLOGY
95 m_StyledTextCtrl->SetTechnology(wxSTC_TECHNOLOGY_DIRECTWRITE);
96#endif
97
98 m_textColorSwatch->SetDefaultColor( COLOR4D::UNSPECIFIED );
99 m_textColorSwatch->SetSwatchBackground( schematicBackground );
100
102
104 m_horizontal->SetBitmap( KiBitmapBundle( BITMAPS::text_horizontal ) );
106 m_vertical->SetBitmap( KiBitmapBundle( BITMAPS::text_vertical ) );
107
109
111 m_bold->SetBitmap( KiBitmapBundle( BITMAPS::text_bold ) );
113 m_italic->SetBitmap( KiBitmapBundle( BITMAPS::text_italic ) );
114
116
118 m_hAlignLeft->SetBitmap( KiBitmapBundle( BITMAPS::text_align_left ) );
120 m_hAlignCenter->SetBitmap( KiBitmapBundle( BITMAPS::text_align_center ) );
122 m_hAlignRight->SetBitmap( KiBitmapBundle( BITMAPS::text_align_right ) );
123
125
127 m_vAlignTop->SetBitmap( KiBitmapBundle( BITMAPS::text_valign_top ) );
129 m_vAlignCenter->SetBitmap( KiBitmapBundle( BITMAPS::text_valign_center ) );
131 m_vAlignBottom->SetBitmap( KiBitmapBundle( BITMAPS::text_valign_bottom ) );
132
134
135 m_horizontal->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onOrientButton, this );
136 m_vertical->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onOrientButton, this );
137
138 m_hAlignLeft->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onHAlignButton, this );
139 m_hAlignCenter->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onHAlignButton, this );
140 m_hAlignRight->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onHAlignButton, this );
141
142 m_vAlignTop->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onVAlignButton, this );
143 m_vAlignCenter->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onVAlignButton, this );
144 m_vAlignBottom->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onVAlignButton, this );
145
146 // show text variable cross-references in a human-readable format
147 if( aField->Schematic() )
148 m_text = aField->Schematic()->ConvertKIIDsToRefs( aField->GetText() );
149 else
150 m_text = aField->GetText();
151
153 m_isItalic = aField->IsItalic();
154 m_isBold = aField->IsBold();
155 m_color = aField->GetTextColor();
156 m_position = aField->GetTextPos();
157 m_size = aField->GetTextWidth();
161 m_isVisible = aField->IsVisible();
162
163 m_isSheetFilename = false;
164 m_fieldId = aField->GetId();
165
166 if( aField->GetParent() && aField->GetParent()->Type() == LIB_SYMBOL_T )
167 {
168 const LIB_SYMBOL* symbol = static_cast<const LIB_SYMBOL*>( aField->GetParentSymbol() );
169
170 /*
171 * Symbol netlist format:
172 * pinNumber pinName <tab> pinNumber pinName...
173 * fpFilter fpFilter...
174 */
175 wxString netlist;
176 wxArrayString pins;
177
178 for( SCH_PIN* pin : symbol->GetPins( 0 /* all units */, 1 /* single bodyStyle */ ) )
179 pins.push_back( pin->GetNumber() + ' ' + pin->GetShownName() );
180
181 if( !pins.IsEmpty() )
182 netlist << EscapeString( wxJoin( pins, '\t' ), CTX_LINE );
183
184 netlist << wxS( "\r" );
185
186 wxArrayString fpFilters = symbol->GetFPFilters();
187
188 if( !fpFilters.IsEmpty() )
189 netlist << EscapeString( wxJoin( fpFilters, ' ' ), CTX_LINE );
190
191 netlist << wxS( "\r" );
192
194 }
195 else if( aField->GetParent() && aField->GetParent()->Type() == SCH_SYMBOL_T )
196 {
197 const SCH_SYMBOL* symbol = static_cast<const SCH_SYMBOL*>( aField->GetParentSymbol() );
198 SCH_SHEET_PATH sheetPath = static_cast<SCH_EDIT_FRAME*>( aParent )->GetCurrentSheet();
199
200 /*
201 * Symbol netlist format:
202 * pinNumber pinName <tab> pinNumber pinName...
203 * fpFilter fpFilter...
204 */
205 wxString netlist;
206
207 // We need the list of pins of the lib symbol, not just the pins of the current
208 // sch symbol, that can be just an unit of a multi-unit symbol, to be able to
209 // select/filter right footprints
210 wxArrayString pins;
211
212 const std::unique_ptr< LIB_SYMBOL >& lib_symbol = symbol->GetLibSymbolRef();
213
214 if( lib_symbol )
215 {
216 for( SCH_PIN* pin : lib_symbol->GetPins( 0 /* all units */, 1 /* single bodyStyle */ ) )
217 pins.push_back( pin->GetNumber() + ' ' + pin->GetShownName() );
218 }
219
220 if( !pins.IsEmpty() )
221 netlist << EscapeString( wxJoin( pins, '\t' ), CTX_LINE );
222
223 netlist << wxS( "\r" );
224
225 wxArrayString fpFilters;
226
227 if( symbol->GetLibSymbolRef() ) // can be null with very old schematic
228 fpFilters = symbol->GetLibSymbolRef()->GetFPFilters();
229
230 if( !fpFilters.IsEmpty() )
231 netlist << EscapeString( wxJoin( fpFilters, ' ' ), CTX_LINE );
232
233 netlist << wxS( "\r" );
234
236 }
237
238 if( aField->GetId() == FIELD_T::SHEET_FILENAME )
239 {
240 m_isSheetFilename = true;
241 m_note->Show( true );
242 }
243
244 m_textLabel->SetLabel( aField->GetName() + wxS( ":" ) );
245
247
250
253
254 m_StyledTextCtrl->Bind( wxEVT_STC_CHARADDED,
256 m_StyledTextCtrl->Bind( wxEVT_STC_AUTOCOMP_CHAR_DELETED,
258
259 m_nameVisible->Show();
260 m_cbAllowAutoPlace->Show();
261
262 init();
263
265 {
266 m_StyledTextCtrl->Enable( false );
267 m_TextCtrl->Enable( false );
268 }
269}
270
271
273{
274 delete m_scintillaTricks;
275}
276
277
279{
280 // Disable options for graphic text editing which are not needed for fields.
281 m_commonToAllBodyStyles->Show( false );
282 m_commonToAllUnits->Show( false );
283
284 // Predefined fields cannot contain some chars and cannot be empty, so they need a
285 // SCH_FIELD_VALIDATOR (m_StyledTextCtrl cannot use a SCH_FIELD_VALIDATOR).
286 if( m_fieldId == FIELD_T::REFERENCE
287 || m_fieldId == FIELD_T::FOOTPRINT
288 || m_fieldId == FIELD_T::DATASHEET
289 || m_fieldId == FIELD_T::SHEET_NAME
290 || m_fieldId == FIELD_T::SHEET_FILENAME )
291 {
292 m_TextCtrl->SetValidator( FIELD_VALIDATOR( m_fieldId, &m_text ) );
294
295 m_StyledTextCtrl->Show( false );
296 }
297 else
298 {
300
301 m_TextCtrl->Show( false );
302 }
303
304 // Show the unit selector for reference fields on multi-unit schematic symbols
305 bool showUnitSelector = m_fieldId == FIELD_T::REFERENCE
309
310 m_unitLabel->Show( showUnitSelector );
311 m_unitChoice->Show( showUnitSelector );
312
313 // Show the footprint selection dialog if this is the footprint field.
314 m_TextValueSelectButton->SetBitmap( KiBitmapBundle( BITMAPS::small_library ) );
315 m_TextValueSelectButton->Show( m_fieldId == FIELD_T::FOOTPRINT );
316
317 m_TextCtrl->Enable( true );
318
319 GetSizer()->SetSizeHints( this );
320
321 // Adjust the height of the scintilla editor after the first layout to show a single line
322 // (multiline text is not supported in fields and will be removed)
323 if( m_StyledTextCtrl->IsShown() )
324 {
325 wxSize maxSize = m_StyledTextCtrl->GetSize();
326 maxSize.x = -1; // Do not fix the max width
327 maxSize.y = m_xPosCtrl->GetSize().y;
328 m_StyledTextCtrl->SetMaxSize( maxSize );
329 m_StyledTextCtrl->SetUseVerticalScrollBar( false );
330 m_StyledTextCtrl->SetUseHorizontalScrollBar( false );
331 }
332
334
335 // Now all widgets have the size fixed, call FinishDialogSettings
337}
338
339
341{
342 // pick a footprint using the footprint picker.
343 wxString fpid;
344
345 if( m_StyledTextCtrl->IsShown() )
346 fpid = m_StyledTextCtrl->GetValue();
347 else
348 fpid = m_TextCtrl->GetValue();
349
350 if( KIWAY_PLAYER* frame = Kiway().Player( FRAME_FOOTPRINT_CHOOSER, true, this ) )
351 {
353 frame->KiwayMailIn( event );
354
355 if( frame->ShowModal( &fpid, this ) )
356 {
357 if( m_StyledTextCtrl->IsShown() )
358 m_StyledTextCtrl->SetValue( fpid );
359 else
360 m_TextCtrl->SetValue( fpid );
361 }
362
363 frame->Destroy();
364 }
365}
366
367
369{
370 if( m_firstFocus )
371 {
372#ifdef __WXGTK__
373 // Force an update of the text control before setting the text selection
374 // This is needed because GTK seems to ignore the selection on first update
375 //
376 // Note that we can't do this on OSX as it tends to provoke Apple's
377 // "[NSAlert runModal] may not be invoked inside of transaction begin/commit pair"
378 // bug. See: https://bugs.launchpad.net/kicad/+bug/1837225
379 if( m_fieldId == FIELD_T::REFERENCE || m_fieldId == FIELD_T::VALUE || m_fieldId == FIELD_T::SHEET_NAME )
380 m_TextCtrl->Update();
381#endif
382
383 if( m_fieldId == FIELD_T::REFERENCE )
384 KIUI::SelectReferenceNumber( static_cast<wxTextEntry*>( m_TextCtrl ) );
385 else if( m_fieldId == FIELD_T::VALUE || m_fieldId == FIELD_T::SHEET_NAME )
386 m_TextCtrl->SetSelection( -1, -1 );
387
388 m_firstFocus = false;
389 }
390
391 event.Skip();
392}
393
394
395void DIALOG_FIELD_PROPERTIES::onOrientButton( wxCommandEvent& aEvent )
396{
397 for( BITMAP_BUTTON* btn : { m_horizontal, m_vertical } )
398 {
399 if( btn->IsChecked() && btn != aEvent.GetEventObject() )
400 btn->Check( false );
401 }
402}
403
404
405void DIALOG_FIELD_PROPERTIES::onHAlignButton( wxCommandEvent& aEvent )
406{
408 {
409 if( btn->IsChecked() && btn != aEvent.GetEventObject() )
410 btn->Check( false );
411 }
412}
413
414
415void DIALOG_FIELD_PROPERTIES::onVAlignButton( wxCommandEvent& aEvent )
416{
418 {
419 if( btn->IsChecked() && btn != aEvent.GetEventObject() )
420 btn->Check( false );
421 }
422}
423
424
426{
427 if( m_TextCtrl->IsShown() )
428 {
429 m_TextCtrl->SetValue( EscapeString( m_text, CTX_LINE ) );
430 }
431 else if( m_StyledTextCtrl->IsShown() )
432 {
434 m_StyledTextCtrl->EmptyUndoBuffer();
435 }
436
437 if( m_unitChoice->IsShown() )
438 {
439 const SYMBOL* parent = m_field->GetParentSymbol();
440
441 // Control shouldn't be shown for non-schematic symbols
442 wxCHECK( parent->Type() == SCH_SYMBOL_T, true );
443
444 const SCH_SYMBOL* symbol = static_cast<const SCH_SYMBOL*>( parent );
445
446 for( int ii = 1; ii <= symbol->GetUnitCount(); ii++ )
447 {
448 if( symbol->HasUnitDisplayName( ii ) )
449 m_unitChoice->Append( symbol->GetUnitDisplayName( ii ) );
450 else
451 m_unitChoice->Append( symbol->SubReference( ii, false ) );
452 }
453
454 if( symbol->GetUnit() <= (int) m_unitChoice->GetCount() )
455 m_unitChoice->SetSelection( symbol->GetUnit() - 1 );
456 }
457
459
463
466
469
471
473 {
474 case GR_TEXT_H_ALIGN_LEFT: m_hAlignLeft->Check( true ); break;
475 case GR_TEXT_H_ALIGN_CENTER: m_hAlignCenter->Check( true ); break;
476 case GR_TEXT_H_ALIGN_RIGHT: m_hAlignRight->Check( true ); break;
478 }
479
480 switch ( m_verticalJustification )
481 {
482 case GR_TEXT_V_ALIGN_TOP: m_vAlignTop->Check( true ); break;
483 case GR_TEXT_V_ALIGN_CENTER: m_vAlignCenter->Check( true ); break;
484 case GR_TEXT_V_ALIGN_BOTTOM: m_vAlignBottom->Check( true ); break;
486 }
487
488 m_visible->SetValue( m_isVisible );
489 m_nameVisible->SetValue( m_isNameVisible );
491
492 return true;
493}
494
495
497{
498 if( m_TextCtrl->IsShown() )
499 m_text = UnescapeString( m_TextCtrl->GetValue() );
500 else if( m_StyledTextCtrl->IsShown() )
501 m_text = UnescapeString( m_StyledTextCtrl->GetValue() );
502
503 if( m_fieldId == FIELD_T::SHEET_FILENAME )
505
508
511
513
517
518 if( m_hAlignLeft->IsChecked() )
520 else if( m_hAlignCenter->IsChecked() )
522 else
524
525 if( m_vAlignTop->IsChecked() )
527 else if( m_vAlignCenter->IsChecked() )
529 else
531
532 m_isVisible = m_visible->GetValue();
533 m_isNameVisible = m_nameVisible->GetValue();
535
536 return true;
537}
538
539
541{
542 if( aField->GetTextWidth() != m_size )
543 aField->SetTextSize( VECTOR2I( m_size, m_size ) );
544
545 aField->SetFont( m_font );
546 aField->SetVisible( m_isVisible );
548 aField->SetItalic( m_isItalic );
549 aField->SetBold( m_isBold );
550 aField->SetTextColor( m_color );
551}
552
553
555{
556 aField->SetText( m_text );
557
558 updateText( aField );
559
560 aField->SetNameShown( m_isNameVisible );
562
565 aField->SetTextPos( m_position );
566}
567
568
569void DIALOG_FIELD_PROPERTIES::onScintillaCharAdded( wxStyledTextEvent &aEvent )
570{
572}
573
574
576 SCH_SHEET_PATH* aSheetPath )
577{
578 SCH_EDIT_FRAME* editFrame = dynamic_cast<SCH_EDIT_FRAME*>( GetParent() );
579 SCH_ITEM* parent = dynamic_cast<SCH_ITEM*>( aField->GetParent() );
580
581 if( parent && parent->Type() == SCH_SYMBOL_T )
582 {
583 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( parent );
584
585 if( m_fieldId == FIELD_T::REFERENCE )
586 symbol->SetRef( aSheetPath, m_text );
587
588 // Set the unit selection in multiple units per package
589 if( m_unitChoice->IsShown() )
590 {
591 int unit_selection = m_unitChoice->IsEnabled() ? m_unitChoice->GetSelection() + 1 : 1;
592 symbol->SetUnitSelection( aSheetPath, unit_selection );
593 symbol->SetUnit( unit_selection );
594 }
595 }
596 else if( parent && parent->Type() == SCH_GLOBAL_LABEL_T )
597 {
598 if( m_fieldId == FIELD_T::INTERSHEET_REFS )
599 {
600 if( m_visible->GetValue() != parent->Schematic()->Settings().m_IntersheetRefsShow )
601 {
602 DisplayInfoMessage( this, _( "Intersheet reference visibility is "
603 "controlled globally from "
604 "Schematic Setup > General > Formatting" ) );
605 }
606 }
607 }
608
609 bool positioningModified = false;
610
611 if( aField->GetPosition() != m_position )
612 positioningModified = true;
613
614 if( aField->GetTextAngle().IsVertical() != m_isVertical )
615 positioningModified = true;
616
618 positioningModified = true;
619
621 positioningModified = true;
622
623 // convert any text variable cross-references to their UUIDs
625
626 // Changing a sheetname need to update the hierarchy navigator
627 bool needUpdateHierNav = false;
628
629 if( m_fieldId == FIELD_T::SHEET_NAME )
630 needUpdateHierNav = m_text != aField->GetText();
631
632 aField->SetText( m_text );
633 updateText( aField );
634 aField->SetPosition( m_position );
635
636 aField->SetNameShown( m_isNameVisible );
638
639 // Note that we must set justifications before we can ask if they're flipped. If the old
640 // justification is center then it won't know (whereas if the new justification is center
641 // the we don't care).
644
645 if( aField->IsHorizJustifyFlipped() )
647
648 if( aField->IsVertJustifyFlipped() )
650
651 // The value, footprint and datasheet fields should be kept in sync in multi-unit parts.
652 // Of course the symbol must be annotated to collect other units.
653 if( editFrame && parent && parent->Type() == SCH_SYMBOL_T )
654 {
655 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( parent );
656
657 if( symbol->IsAnnotated( aSheetPath ) && ( m_fieldId == FIELD_T::VALUE
658 || m_fieldId == FIELD_T::FOOTPRINT
659 || m_fieldId == FIELD_T::DATASHEET ) )
660 {
661 wxString ref = symbol->GetRef( aSheetPath );
662 int unit = symbol->GetUnit();
663 LIB_ID libId = symbol->GetLibId();
664
665 for( SCH_SHEET_PATH& sheet : editFrame->Schematic().Hierarchy() )
666 {
667 SCH_SCREEN* screen = sheet.LastScreen();
668 std::vector<SCH_SYMBOL*> otherUnits;
669
670 CollectOtherUnits( ref, unit, libId, sheet, &otherUnits );
671
672 for( SCH_SYMBOL* otherUnit : otherUnits )
673 {
674 aCommit->Modify( otherUnit, screen );
675 otherUnit->GetField( m_fieldId )->SetText( m_text );
676 editFrame->UpdateItem( otherUnit, false, true );
677 }
678 }
679 }
680 }
681
682 if( positioningModified && parent )
684
685 // Update the hierarchy navigator labels if needed.
686 if( needUpdateHierNav )
688}
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
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)
Modify a given item in the model.
Definition: commit.h:108
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 updateText(SCH_FIELD *aField)
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 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:66
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:146
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:108
EDA_ITEM * GetParent() const
Definition: eda_item.h:110
void SetTextColor(const COLOR4D &aColor)
Definition: eda_text.h:266
const VECTOR2I & GetTextPos() const
Definition: eda_text.h:270
COLOR4D GetTextColor() const
Definition: eda_text.h:267
bool IsItalic() const
Definition: eda_text.h:166
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:144
void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true)
Definition: eda_text.cpp:533
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:97
virtual bool IsVisible() const
Definition: eda_text.h:184
void SetTextPos(const VECTOR2I &aPoint)
Definition: eda_text.cpp:578
KIFONT::FONT * GetFont() const
Definition: eda_text.h:244
int GetTextWidth() const
Definition: eda_text.h:261
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
Definition: eda_text.cpp:417
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition: eda_text.h:197
virtual void SetVisible(bool aVisible)
Definition: eda_text.cpp:386
static GR_TEXT_H_ALIGN_T MapHorizJustify(int aHorizJustify)
Definition: eda_text.cpp:67
void SetBold(bool aBold)
Set the text to be bold - this will also update the font if needed.
Definition: eda_text.cpp:335
bool IsBold() const
Definition: eda_text.h:181
static GR_TEXT_V_ALIGN_T MapVertJustify(int aVertJustify)
Definition: eda_text.cpp:81
GR_TEXT_V_ALIGN_T GetVertJustify() const
Definition: eda_text.h:200
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition: eda_text.cpp:299
void SetItalic(bool aItalic)
Set the text to be italic - this will also update the font if needed.
Definition: eda_text.cpp:307
void SetFont(KIFONT::FONT *aFont)
Definition: eda_text.cpp:499
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Definition: eda_text.cpp:409
A text control validator used for validating the text allowed in fields.
Definition: validators.h:142
void SetFontSelection(KIFONT::FONT *aFont, bool aSilentMode=false)
Set the selection in wxChoice widget.
Definition: font_choice.cpp:73
KIFONT::FONT * GetFontSelection(bool aBold, bool aItalic, bool aForDrawingSheet=false) const
bool HaveFontSelection() const
Definition: font_choice.cpp:95
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:85
std::vector< SCH_PIN * > GetPins(int aUnit, int aBodyStyle) const
Return a list of pin object pointers from the draw item list.
Definition: lib_symbol.cpp:800
wxArrayString GetFPFilters() const
Definition: lib_symbol.h:218
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:306
wxString ConvertKIIDsToRefs(const wxString &aSource) const
Definition: schematic.cpp:575
SCH_SHEET_LIST Hierarchy() const
Return the full schematic flattened hierarchical sheet list.
Definition: schematic.cpp:208
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.
GR_TEXT_V_ALIGN_T GetEffectiveVertJustify() const
Definition: sch_field.cpp:626
VECTOR2I GetPosition() const override
Definition: sch_field.cpp:1339
bool IsNameShown() const
Definition: sch_field.h:199
bool IsGeneratedField() const
Generated fields are fields whose names are variables like ${VAR}.
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:526
bool IsVertJustifyFlipped() const
Definition: sch_field.cpp:583
FIELD_T GetId() const
Definition: sch_field.h:115
void SetCanAutoplace(bool aCanPlace)
Definition: sch_field.h:211
GR_TEXT_H_ALIGN_T GetEffectiveHorizJustify() const
Definition: sch_field.cpp:569
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
Definition: sch_field.cpp:1109
void SetPosition(const VECTOR2I &aPosition) override
Definition: sch_field.cpp:1319
bool CanAutoplace() const
Definition: sch_field.h:210
void SetText(const wxString &aText) override
Definition: sch_field.cpp:1095
void OnScintillaCharAdded(SCINTILLA_TRICKS *aScintillaTricks, wxStyledTextEvent &aEvent) const
Definition: sch_field.cpp:697
void SetNameShown(bool aShown=true)
Definition: sch_field.h:200
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:167
const SYMBOL * GetParentSymbol() const
Definition: sch_item.cpp:193
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:177
int GetUnit() const
Definition: sch_item.h:236
void SetFieldsAutoplaced(AUTOPLACE_ALGO aAlgo)
Definition: sch_item.h:575
virtual void SetUnit(int aUnit)
Definition: sch_item.h:235
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:75
wxString GetUnitDisplayName(int aUnit) const
Return the display name for a given unit aUnit.
Definition: sch_symbol.cpp:444
wxString SubReference(int aUnit, bool aAddSeparator=true) const
Definition: sch_symbol.cpp:731
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:690
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:654
const LIB_ID & GetLibId() const override
Definition: sch_symbol.h:164
int GetUnitCount() const override
Return the number of units per package of the symbol.
Definition: sch_symbol.cpp:435
void SetUnitSelection(const SCH_SHEET_PATH *aSheet, int aUnitSelection)
Set the selected unit of this symbol on one sheet.
Definition: sch_symbol.cpp:756
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
Definition: sch_symbol.h:183
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const override
Definition: sch_symbol.cpp:612
bool HasUnitDisplayName(int aUnit) const
Return true if the given unit aUnit has a display name set.
Definition: sch_symbol.cpp:452
Add cut/copy/paste, dark theme, autocomplete and brace highlighting to a wxStyleTextCtrl instance.
void SetBitmap(const wxBitmapBundle &aBmp)
A base class for LIB_SYMBOL and SCH_SYMBOL.
Definition: symbol.h:63
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:427
The common library.
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:221
This file is part of the common library.
#define _(s)
static constexpr EDA_ANGLE ANGLE_VERTICAL
Definition: eda_angle.h:401
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
Definition: eda_angle.h:400
@ FRAME_FOOTPRINT_CHOOSER
Definition: frame_type.h:44
static const std::string KiCadSchematicFileExtension
@ LAYER_SCHEMATIC_BACKGROUND
Definition: layer_ids.h:477
@ MAIL_SYMBOL_NETLIST
Definition: mail_type.h:45
KICOMMON_API wxFont GetInfoFont(wxWindow *aWindow)
Definition: ui_common.cpp:156
KICOMMON_API void SelectReferenceNumber(wxTextEntry *aTextEntry)
Select the number (or "?") in a reference for ease of editing.
Definition: ui_common.cpp:236
void CollectOtherUnits(const wxString &aRef, int aUnit, const LIB_ID &aLibId, SCH_SHEET_PATH &aSheet, std::vector< SCH_SYMBOL * > *otherUnits)
@ AUTOPLACE_NONE
Definition: sch_item.h:69
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.
@ 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_GLOBAL_LABEL_T
Definition: typeinfo.h:168
VECTOR2< int32_t > VECTOR2I
Definition: vector2d.h:695
Definition of file extensions used in Kicad.