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 ),
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( 6 );
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
101 m_separator1->SetIsSeparator();
102
103 m_horizontal->SetIsRadioButton();
105 m_vertical->SetIsRadioButton();
107
108 m_separator2->SetIsSeparator();
109
110 m_bold->SetIsCheckButton();
112 m_italic->SetIsCheckButton();
114
115 m_separator3->SetIsSeparator();
116
117 m_hAlignLeft->SetIsRadioButton();
119 m_hAlignCenter->SetIsRadioButton();
121 m_hAlignRight->SetIsRadioButton();
123
124 m_separator4->SetIsSeparator();
125
126 m_vAlignTop->SetIsRadioButton();
128 m_vAlignCenter->SetIsRadioButton();
130 m_vAlignBottom->SetIsRadioButton();
132
133 m_separator5->SetIsSeparator();
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
152 m_font = m_field->GetFont();
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->GetGraphicalPins( 0 /* all units */, 1 /* single bodyStyle */ ) )
179 {
180 bool valid = false;
181 auto expanded = pin->GetStackedPinNumbers( &valid );
182
183 if( valid && !expanded.empty() )
184 {
185 for( const wxString& num : expanded )
186 pins.push_back( num + ' ' + pin->GetShownName() );
187 }
188 else
189 {
190 pins.push_back( pin->GetNumber() + ' ' + pin->GetShownName() );
191 }
192 }
193
194 if( !pins.IsEmpty() )
195 {
196 wxString dbg = wxJoin( pins, '\t' );
197 wxLogTrace( "FOOTPRINT_CHOOSER", wxS( "Chooser payload pins (LIB_SYMBOL): %s" ), dbg );
198 netlist << EscapeString( dbg, CTX_LINE );
199 }
200
201 netlist << wxS( "\r" );
202
203 wxArrayString fpFilters = symbol->GetFPFilters();
204
205 if( !fpFilters.IsEmpty() )
206 netlist << EscapeString( wxJoin( fpFilters, ' ' ), CTX_LINE );
207
208 netlist << wxS( "\r" );
209
211 }
212 else if( aField->GetParent() && aField->GetParent()->Type() == SCH_SYMBOL_T )
213 {
214 const SCH_SYMBOL* symbol = static_cast<const SCH_SYMBOL*>( aField->GetParentSymbol() );
215 SCH_SHEET_PATH sheetPath = static_cast<SCH_EDIT_FRAME*>( aParent )->GetCurrentSheet();
216
217 /*
218 * Symbol netlist format:
219 * pinNumber pinName <tab> pinNumber pinName...
220 * fpFilter fpFilter...
221 */
222 wxString netlist;
223
224 // We need the list of pins of the lib symbol, not just the pins of the current
225 // sch symbol, that can be just an unit of a multi-unit symbol, to be able to
226 // select/filter right footprints
227 wxArrayString pins;
228
229 const std::unique_ptr< LIB_SYMBOL >& lib_symbol = symbol->GetLibSymbolRef();
230
231 if( lib_symbol )
232 {
233 for( SCH_PIN* pin : lib_symbol->GetGraphicalPins( 0 /* all units */, 1 /* single bodyStyle */ ) )
234 {
235 bool valid = false;
236 auto expanded = pin->GetStackedPinNumbers( &valid );
237 if( valid && !expanded.empty() )
238 {
239 for( const wxString& num : expanded )
240 pins.push_back( num + ' ' + pin->GetShownName() );
241 }
242 else
243 {
244 pins.push_back( pin->GetNumber() + ' ' + pin->GetShownName() );
245 }
246 }
247 }
248
249 if( !pins.IsEmpty() )
250 {
251 wxString dbg = wxJoin( pins, '\t' );
252 wxLogTrace( "FOOTPRINT_CHOOSER", wxS( "Chooser payload pins (SCH_SYMBOL): %s" ), dbg );
253 netlist << EscapeString( dbg, CTX_LINE );
254 }
255
256 netlist << wxS( "\r" );
257
258 wxArrayString fpFilters;
259
260 if( symbol->GetLibSymbolRef() ) // can be null with very old schematic
261 fpFilters = symbol->GetLibSymbolRef()->GetFPFilters();
262
263 if( !fpFilters.IsEmpty() )
264 netlist << EscapeString( wxJoin( fpFilters, ' ' ), CTX_LINE );
265
266 netlist << wxS( "\r" );
267
269 }
270
271 if( aField->GetId() == FIELD_T::SHEET_FILENAME )
272 {
273 m_isSheetFilename = true;
274 m_note->Show( true );
275 }
276
277 m_textLabel->SetLabel( aField->GetName() + wxS( ":" ) );
278
279 m_position = m_field->GetPosition();
280
281 m_isNameVisible = m_field->IsNameShown();
282 m_allowAutoplace = m_field->CanAutoplace();
283
284 m_horizontalJustification = m_field->GetEffectiveHorizJustify();
285 m_verticalJustification = m_field->GetEffectiveVertJustify();
286
287 m_StyledTextCtrl->Bind( wxEVT_STC_CHARADDED,
289 m_StyledTextCtrl->Bind( wxEVT_STC_AUTOCOMP_CHAR_DELETED,
291
292 m_nameVisible->Show();
293 m_cbAllowAutoPlace->Show();
294
295 init();
296
297 if( m_isSheetFilename || m_field->IsGeneratedField() )
298 {
299 m_StyledTextCtrl->Enable( false );
300 m_TextCtrl->Enable( false );
301 }
302}
303
304
309
310
312{
313 // Disable options for graphic text editing which are not needed for fields.
314 m_commonToAllBodyStyles->Show( false );
315 m_commonToAllUnits->Show( false );
316
317 // Predefined fields cannot contain some chars and cannot be empty, so they need a
318 // SCH_FIELD_VALIDATOR (m_StyledTextCtrl cannot use a SCH_FIELD_VALIDATOR).
324 {
325 m_TextCtrl->SetValidator( FIELD_VALIDATOR( m_fieldId, &m_text ) );
327
328 m_StyledTextCtrl->Show( false );
329 m_StyledTextCtrlBorder->Show( false );
330 }
331 else
332 {
334
335 m_TextCtrl->Show( false );
336 }
337
338 // Show the unit selector for reference fields on multi-unit schematic symbols
339 bool showUnitSelector = m_fieldId == FIELD_T::REFERENCE
340 && m_field->GetParentSymbol()
341 && m_field->GetParentSymbol()->Type() == SCH_SYMBOL_T
342 && m_field->GetParentSymbol()->IsMultiUnit();
343
344 m_unitLabel->Show( showUnitSelector );
345 m_unitChoice->Show( showUnitSelector );
346
347 // Show the footprint selection dialog if this is the footprint field.
350
351 m_TextCtrl->Enable( true );
352
353 GetSizer()->SetSizeHints( this );
354
355 // Adjust the height of the scintilla editor after the first layout to show a single line
356 // (multiline text is not supported in fields and will be removed)
357 if( m_StyledTextCtrl->IsShown() )
358 {
359 wxSize maxSize;
360 maxSize.x = -1; // Do not fix the max width
361 maxSize.y = m_StyledTextCtrl->TextHeight( 0 );
362 m_StyledTextCtrl->SetMaxSize( maxSize );
363 m_StyledTextCtrl->SetUseVerticalScrollBar( false );
364 m_StyledTextCtrl->SetUseHorizontalScrollBar( false );
365 }
366
368
369 // Now all widgets have the size fixed, call FinishDialogSettings
371}
372
373
375{
376 // pick a footprint using the footprint picker.
377 wxString fpid;
378
379 if( m_StyledTextCtrl->IsShown() )
380 fpid = m_StyledTextCtrl->GetValue();
381 else
382 fpid = m_TextCtrl->GetValue();
383
384 if( KIWAY_PLAYER* frame = Kiway().Player( FRAME_FOOTPRINT_CHOOSER, true, this ) )
385 {
387 frame->KiwayMailIn( event );
388
389 if( frame->ShowModal( &fpid, this ) )
390 {
391 if( m_StyledTextCtrl->IsShown() )
392 m_StyledTextCtrl->SetValue( fpid );
393 else
394 m_TextCtrl->SetValue( fpid );
395 }
396
397 frame->Destroy();
398 }
399}
400
401
403{
404 if( m_firstFocus )
405 {
406#ifdef __WXGTK__
407 // Force an update of the text control before setting the text selection
408 // This is needed because GTK seems to ignore the selection on first update
409 //
410 // Note that we can't do this on OSX as it tends to provoke Apple's
411 // "[NSAlert runModal] may not be invoked inside of transaction begin/commit pair"
412 // bug. See: https://bugs.launchpad.net/kicad/+bug/1837225
414 m_TextCtrl->Update();
415#endif
416
418 KIUI::SelectReferenceNumber( static_cast<wxTextEntry*>( m_TextCtrl ) );
420 m_TextCtrl->SetSelection( -1, -1 );
421
422 m_firstFocus = false;
423 }
424
425 event.Skip();
426}
427
428
429void DIALOG_FIELD_PROPERTIES::onOrientButton( wxCommandEvent& aEvent )
430{
431 for( BITMAP_BUTTON* btn : { m_horizontal, m_vertical } )
432 {
433 if( btn->IsChecked() && btn != aEvent.GetEventObject() )
434 btn->Check( false );
435 }
436}
437
438
439void DIALOG_FIELD_PROPERTIES::onHAlignButton( wxCommandEvent& aEvent )
440{
442 {
443 if( btn->IsChecked() && btn != aEvent.GetEventObject() )
444 btn->Check( false );
445 }
446}
447
448
449void DIALOG_FIELD_PROPERTIES::onVAlignButton( wxCommandEvent& aEvent )
450{
452 {
453 if( btn->IsChecked() && btn != aEvent.GetEventObject() )
454 btn->Check( false );
455 }
456}
457
458
460{
461 if( m_TextCtrl->IsShown() )
462 {
463 m_TextCtrl->SetValue( EscapeString( m_text, CTX_LINE ) );
464 }
465 else if( m_StyledTextCtrl->IsShown() )
466 {
468 m_StyledTextCtrl->EmptyUndoBuffer();
469 }
470
471 if( m_unitChoice->IsShown() )
472 {
473 const SYMBOL* parent = m_field->GetParentSymbol();
474
475 // Control shouldn't be shown for non-schematic symbols
476 wxCHECK( parent->Type() == SCH_SYMBOL_T, true );
477
478 const SCH_SYMBOL* symbol = static_cast<const SCH_SYMBOL*>( parent );
479
480 for( int ii = 1; ii <= symbol->GetUnitCount(); ii++ )
481 m_unitChoice->Append( symbol->GetUnitDisplayName( ii, false ) );
482
483 if( symbol->GetUnit() <= (int) m_unitChoice->GetCount() )
484 m_unitChoice->SetSelection( symbol->GetUnit() - 1 );
485 }
486
487 m_fontCtrl->SetFontSelection( m_font );
488
489 m_posX.SetValue( m_position.x );
490 m_posY.SetValue( m_position.y );
491 m_textSize.SetValue( m_size );
492
493 m_horizontal->Check( !m_isVertical );
494 m_vertical->Check( m_isVertical );
495
496 m_italic->Check( m_isItalic );
497 m_bold->Check( m_isBold );
498
499 m_textColorSwatch->SetSwatchColor( m_color, false );
500
502 {
503 case GR_TEXT_H_ALIGN_LEFT: m_hAlignLeft->Check( true ); break;
504 case GR_TEXT_H_ALIGN_CENTER: m_hAlignCenter->Check( true ); break;
505 case GR_TEXT_H_ALIGN_RIGHT: m_hAlignRight->Check( true ); break;
507 }
508
509 switch ( m_verticalJustification )
510 {
511 case GR_TEXT_V_ALIGN_TOP: m_vAlignTop->Check( true ); break;
512 case GR_TEXT_V_ALIGN_CENTER: m_vAlignCenter->Check( true ); break;
513 case GR_TEXT_V_ALIGN_BOTTOM: m_vAlignBottom->Check( true ); break;
515 }
516
517 m_visible->SetValue( m_isVisible );
518 m_nameVisible->SetValue( m_isNameVisible );
520
521 return true;
522}
523
524
526{
527 if( m_TextCtrl->IsShown() )
528 m_text = UnescapeString( m_TextCtrl->GetValue() );
529 else if( m_StyledTextCtrl->IsShown() )
530 m_text = UnescapeString( m_StyledTextCtrl->GetValue() );
531
534
535 m_position = VECTOR2I( m_posX.GetIntValue(), m_posY.GetIntValue() );
536 m_size = m_textSize.GetIntValue();
537
538 if( m_fontCtrl->HaveFontSelection() )
539 m_font = m_fontCtrl->GetFontSelection( m_bold->IsChecked(), m_italic->IsChecked() );
540
541 m_isVertical = m_vertical->IsChecked();
542
543 m_isBold = m_bold->IsChecked();
544 m_isItalic = m_italic->IsChecked();
545 m_color = m_textColorSwatch->GetSwatchColor();
546
547 if( m_hAlignLeft->IsChecked() )
549 else if( m_hAlignCenter->IsChecked() )
551 else
553
554 if( m_vAlignTop->IsChecked() )
556 else if( m_vAlignCenter->IsChecked() )
558 else
560
561 m_isVisible = m_visible->GetValue();
562 m_isNameVisible = m_nameVisible->GetValue();
564
565 return true;
566}
567
568
570{
571 if( aField->GetTextWidth() != m_size )
572 aField->SetTextSize( VECTOR2I( m_size, m_size ) );
573
574 aField->SetFont( m_font );
575 aField->SetVisible( m_isVisible );
577 aField->SetItalic( m_isItalic );
578 aField->SetBold( m_isBold );
579 aField->SetTextColor( m_color );
580}
581
582
596
597
598void DIALOG_FIELD_PROPERTIES::onScintillaCharAdded( wxStyledTextEvent &aEvent )
599{
600 m_field->OnScintillaCharAdded( m_scintillaTricks, aEvent );
601}
602
603
605 SCH_SHEET_PATH* aSheetPath )
606{
607 SCH_EDIT_FRAME* editFrame = dynamic_cast<SCH_EDIT_FRAME*>( GetParent() );
608 SCH_ITEM* parent = dynamic_cast<SCH_ITEM*>( aField->GetParent() );
609
610 if( parent && parent->Type() == SCH_SYMBOL_T )
611 {
612 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( parent );
613
615 symbol->SetRef( aSheetPath, m_text );
616
617 // Set the unit selection in multiple units per package
618 if( m_unitChoice->IsShown() )
619 {
620 int unit_selection = m_unitChoice->IsEnabled() ? m_unitChoice->GetSelection() + 1 : 1;
621 symbol->SetUnitSelection( aSheetPath, unit_selection );
622 symbol->SetUnit( unit_selection );
623 }
624 }
625 else if( parent && parent->Type() == SCH_GLOBAL_LABEL_T )
626 {
628 {
629 if( m_visible->GetValue() != parent->Schematic()->Settings().m_IntersheetRefsShow )
630 {
631 DisplayInfoMessage( this, _( "Intersheet reference visibility is "
632 "controlled globally from "
633 "Schematic Setup > General > Formatting" ) );
634 }
635 }
636 }
637
638 bool positioningModified = false;
639
640 if( aField->GetPosition() != m_position )
641 positioningModified = true;
642
643 if( aField->GetTextAngle().IsVertical() != m_isVertical )
644 positioningModified = true;
645
647 positioningModified = true;
648
650 positioningModified = true;
651
652 // convert any text variable cross-references to their UUIDs
654
655 // Changing a sheetname need to update the hierarchy navigator
656 bool needUpdateHierNav = false;
657
659 needUpdateHierNav = m_text != aField->GetText();
660
661 aField->SetText( m_text );
662 updateText( aField );
663 aField->SetPosition( m_position );
664
665 aField->SetNameShown( m_isNameVisible );
667
668 // Note that we must set justifications before we can ask if they're flipped. If the old
669 // justification is center then it won't know (whereas if the new justification is center
670 // the we don't care).
673
674 if( aField->IsHorizJustifyFlipped() )
676
677 if( aField->IsVertJustifyFlipped() )
679
680 // The value, footprint and datasheet fields should be kept in sync in multi-unit parts.
681 // Of course the symbol must be annotated to collect other units.
682 if( editFrame && parent && parent->Type() == SCH_SYMBOL_T )
683 {
684 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( parent );
685
686 if( symbol->IsAnnotated( aSheetPath ) && ( m_fieldId == FIELD_T::VALUE
689 {
690 wxString ref = symbol->GetRef( aSheetPath );
691 int unit = symbol->GetUnit();
692 LIB_ID libId = symbol->GetLibId();
693
694 for( SCH_SHEET_PATH& sheet : editFrame->Schematic().Hierarchy() )
695 {
696 SCH_SCREEN* screen = sheet.LastScreen();
697 std::vector<SCH_SYMBOL*> otherUnits;
698
699 CollectOtherUnits( ref, unit, libId, sheet, &otherUnits );
700
701 for( SCH_SYMBOL* otherUnit : otherUnits )
702 {
703 aCommit->Modify( otherUnit, screen );
704 otherUnit->GetField( m_fieldId )->SetText( m_text );
705 editFrame->UpdateItem( otherUnit, false, true );
706 }
707 }
708 }
709 }
710
711 if( positioningModified && parent )
713
714 // Update the hierarchy navigator labels if needed.
715 if( editFrame && needUpdateHierNav )
717}
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
Definition bitmap.cpp:110
@ text_align_right
@ text_valign_top
@ text_align_left
@ text_valign_center
@ 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.
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
Definition color4d.h:398
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
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
Definition commit.h:106
DIALOG_FIELD_PROPERTIES_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Text Item Properties"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
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)
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:82
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:148
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:110
EDA_ITEM * GetParent() const
Definition eda_item.h:112
void SetTextColor(const COLOR4D &aColor)
Definition eda_text.h:268
const VECTOR2I & GetTextPos() const
Definition eda_text.h:272
COLOR4D GetTextColor() const
Definition eda_text.h:269
bool IsItalic() const
Definition eda_text.h:168
const EDA_ANGLE & GetTextAngle() const
Definition eda_text.h:146
void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true)
Definition eda_text.cpp:534
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:186
void SetTextPos(const VECTOR2I &aPoint)
Definition eda_text.cpp:579
int GetTextWidth() const
Definition eda_text.h:263
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
Definition eda_text.cpp:418
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition eda_text.h:199
virtual void SetVisible(bool aVisible)
Definition eda_text.cpp:387
static GR_TEXT_H_ALIGN_T MapHorizJustify(int aHorizJustify)
Definition eda_text.cpp:68
void SetBold(bool aBold)
Set the text to be bold - this will also update the font if needed.
Definition eda_text.cpp:336
bool IsBold() const
Definition eda_text.h:183
static GR_TEXT_V_ALIGN_T MapVertJustify(int aVertJustify)
Definition eda_text.cpp:82
GR_TEXT_V_ALIGN_T GetVertJustify() const
Definition eda_text.h:202
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition eda_text.cpp:300
void SetItalic(bool aItalic)
Set the text to be italic - this will also update the font if needed.
Definition eda_text.cpp:308
void SetFont(KIFONT::FONT *aFont)
Definition eda_text.cpp:500
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Definition eda_text.cpp:410
A text control validator used for validating the text allowed in fields.
Definition validators.h:142
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.
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
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
wxArrayString GetFPFilters() const
Definition lib_symbol.h:217
std::vector< SCH_PIN * > GetGraphicalPins(int aUnit=0, int aBodyStyle=0) const
Graphical pins: Return schematic pin objects as drawn (unexpanded), filtered by unit/body.
SCHEMATIC_SETTINGS & Settings() const
wxString ConvertKIIDsToRefs(const wxString &aSource) const
SCH_SHEET_LIST Hierarchy() const
Return the full schematic flattened hierarchical sheet list.
wxString ConvertRefsToKIIDs(const wxString &aSource) const
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
VECTOR2I GetPosition() const override
bool IsHorizJustifyFlipped() const
Return whether the field will be rendered with the horizontal justification inverted due to rotation ...
bool IsVertJustifyFlipped() const
FIELD_T GetId() const
Definition sch_field.h:116
void SetCanAutoplace(bool aCanPlace)
Definition sch_field.h:214
GR_TEXT_H_ALIGN_T GetEffectiveHorizJustify() const
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
void SetPosition(const VECTOR2I &aPosition) override
void SetText(const wxString &aText) override
void SetNameShown(bool aShown=true)
Definition sch_field.h:203
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:223
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
Definition sch_item.cpp:217
int GetUnit() const
Definition sch_item.h:238
void SetFieldsAutoplaced(AUTOPLACE_ALGO aAlgo)
Definition sch_item.h:593
virtual void SetUnit(int aUnit)
Definition sch_item.h:237
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, bool aLabel) const override
Return the display name for a given unit aUnit.
bool IsAnnotated(const SCH_SHEET_PATH *aSheet) const
Check if the symbol has a valid annotation (reference) for the given sheet path.
void SetRef(const SCH_SHEET_PATH *aSheet, const wxString &aReference)
Set the reference for the given sheet path for this symbol.
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.
void SetUnitSelection(const SCH_SHEET_PATH *aSheet, int aUnitSelection)
Set the selected unit of this symbol on one sheet.
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
Definition sch_symbol.h:183
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const override
Add cut/copy/paste, dark theme, autocomplete and brace highlighting to a wxStyleTextCtrl instance.
A base class for LIB_SYMBOL and SCH_SYMBOL.
Definition symbol.h:63
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:429
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:408
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
Definition eda_angle.h:407
@ FRAME_FOOTPRINT_CHOOSER
Definition frame_type.h:44
static const std::string KiCadSchematicFileExtension
@ LAYER_SCHEMATIC_BACKGROUND
Definition layer_ids.h:487
@ MAIL_SYMBOL_NETLIST
Definition mail_type.h:45
KICOMMON_API wxFont GetInfoFont(wxWindow *aWindow)
KICOMMON_API void SelectReferenceNumber(wxTextEntry *aTextEntry)
Select the number (or "?") in a reference for ease of editing.
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 for symbol library class.
@ INTERSHEET_REFS
Global label cross-reference page numbers.
@ FOOTPRINT
Field Name Module PCB, i.e. "16DIP300".
@ DATASHEET
name of datasheet
@ REFERENCE
Field Reference of part, i.e. "IC21".
@ VALUE
Field Value of part, i.e. "3.3K".
@ 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:150
@ SCH_SYMBOL_T
Definition typeinfo.h:174
@ SCH_GLOBAL_LABEL_T
Definition typeinfo.h:170
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:695
Definition of file extensions used in Kicad.