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 <sch_validators.h>
42#include <schematic.h>
43#include <sch_commit.h>
45#include <sch_text.h>
46#include <scintilla_tricks.h>
48
49
51 const SCH_FIELD* aField ) :
52 DIALOG_FIELD_PROPERTIES_BASE( aParent, wxID_ANY, aTitle ),
53 m_posX( aParent, m_xPosLabel, m_xPosCtrl, m_xPosUnits, true ),
54 m_posY( aParent, m_yPosLabel, m_yPosCtrl, m_yPosUnits, true ),
56 m_font( nullptr ),
57 m_firstFocus( true ),
58 m_scintillaTricks( nullptr ),
59 m_field( aField )
60{
61 COLOR_SETTINGS* colorSettings = aParent->GetColorSettings();
62 COLOR4D schematicBackground = colorSettings->GetColor( LAYER_SCHEMATIC_BACKGROUND );
63
64 wxASSERT( m_field );
65
66 m_note->SetFont( KIUI::GetInfoFont( this ).Italic() );
67 m_note->Show( false );
68
69 m_scintillaTricks = new SCINTILLA_TRICKS( m_StyledTextCtrl, wxT( "{}" ), true,
70 // onAcceptFn
71 [this]( wxKeyEvent& aEvent )
72 {
73 wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
74 } );
75
76 m_StyledTextCtrl->SetEOLMode( wxSTC_EOL_LF ); // Normalize EOL across platforms
77
78#ifdef __WXGTK__
79 m_StyledTextCtrl->SetExtraAscent( 6 );
80 m_StyledTextCtrl->SetExtraDescent( 6 );
81#elif defined ( __WXMSW__ )
82 // Do nothing: SetExtraAscent() + SetExtraDescent(), when set to a value not 0
83 // Generate a strange bug: the text is not always shown (Perhaps a wxMSW bug)
84 // and this call is not needed on WXMSW
85#else
86 m_StyledTextCtrl->SetExtraAscent( 1 );
87 m_StyledTextCtrl->SetExtraDescent( 2 );
88#endif
89
90#ifdef _WIN32
91 // Without this setting, on Windows, some esoteric unicode chars create display issue
92 // in a wxStyledTextCtrl.
93 // for SetTechnology() info, see https://www.scintilla.org/ScintillaDoc.html#SCI_SETTECHNOLOGY
94 m_StyledTextCtrl->SetTechnology(wxSTC_TECHNOLOGY_DIRECTWRITE);
95#endif
96
97 m_textColorSwatch->SetDefaultColor( COLOR4D::UNSPECIFIED );
98 m_textColorSwatch->SetSwatchBackground( schematicBackground );
99
100 m_separator1->SetIsSeparator();
101
102 m_horizontal->SetIsRadioButton();
104 m_vertical->SetIsRadioButton();
106
107 m_separator2->SetIsSeparator();
108
109 m_bold->SetIsCheckButton();
111 m_italic->SetIsCheckButton();
113
114 m_separator3->SetIsSeparator();
115
116 m_hAlignLeft->SetIsRadioButton();
118 m_hAlignCenter->SetIsRadioButton();
120 m_hAlignRight->SetIsRadioButton();
122
123 m_separator4->SetIsSeparator();
124
125 m_vAlignTop->SetIsRadioButton();
127 m_vAlignCenter->SetIsRadioButton();
129 m_vAlignBottom->SetIsRadioButton();
131
132 m_separator5->SetIsSeparator();
133
134 m_horizontal->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onOrientButton, this );
135 m_vertical->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onOrientButton, this );
136
137 m_hAlignLeft->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onHAlignButton, this );
138 m_hAlignCenter->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onHAlignButton, this );
139 m_hAlignRight->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onHAlignButton, this );
140
141 m_vAlignTop->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onVAlignButton, this );
142 m_vAlignCenter->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onVAlignButton, this );
143 m_vAlignBottom->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onVAlignButton, this );
144
145 // show text variable cross-references in a human-readable format
146 if( aField->Schematic() )
147 m_text = aField->Schematic()->ConvertKIIDsToRefs( aField->GetText() );
148 else
149 m_text = aField->GetText();
150
151 m_font = m_field->GetFont();
152 m_isItalic = aField->IsItalic();
153 m_isBold = aField->IsBold();
154 m_color = aField->GetTextColor();
155 m_position = aField->GetTextPos();
156 m_size = aField->GetTextWidth();
160 m_isVisible = aField->IsVisible();
161
162 m_isSheetFilename = false;
163 m_fieldId = aField->GetId();
164
165 if( aField->GetParent() && aField->GetParent()->Type() == LIB_SYMBOL_T )
166 {
167 const LIB_SYMBOL* symbol = static_cast<const LIB_SYMBOL*>( aField->GetParentSymbol() );
168
169 /*
170 * Symbol netlist format:
171 * pinNumber pinName <tab> pinNumber pinName...
172 * fpFilter fpFilter...
173 */
174 wxString netlist;
175 wxArrayString pins;
176
177 for( SCH_PIN* pin : symbol->GetGraphicalPins( 0 /* all units */, 1 /* single bodyStyle */ ) )
178 {
179 bool valid = false;
180 auto expanded = pin->GetStackedPinNumbers( &valid );
181
182 if( valid && !expanded.empty() )
183 {
184 for( const wxString& num : expanded )
185 pins.push_back( num + ' ' + pin->GetShownName() );
186 }
187 else
188 {
189 pins.push_back( pin->GetNumber() + ' ' + pin->GetShownName() );
190 }
191 }
192
193 if( !pins.IsEmpty() )
194 {
195 wxString dbg = wxJoin( pins, '\t' );
196 wxLogTrace( "FOOTPRINT_CHOOSER", wxS( "Chooser payload pins (LIB_SYMBOL): %s" ), dbg );
197 netlist << EscapeString( dbg, CTX_LINE );
198 }
199
200 netlist << wxS( "\r" );
201
202 wxArrayString fpFilters = symbol->GetFPFilters();
203
204 if( !fpFilters.IsEmpty() )
205 netlist << EscapeString( wxJoin( fpFilters, ' ' ), CTX_LINE );
206
207 netlist << wxS( "\r" );
208
210 }
211 else if( aField->GetParent() && aField->GetParent()->Type() == SCH_SYMBOL_T )
212 {
213 const SCH_SYMBOL* symbol = static_cast<const SCH_SYMBOL*>( aField->GetParentSymbol() );
214 SCH_SHEET_PATH sheetPath = static_cast<SCH_EDIT_FRAME*>( aParent )->GetCurrentSheet();
215
216 /*
217 * Symbol netlist format:
218 * pinNumber pinName <tab> pinNumber pinName...
219 * fpFilter fpFilter...
220 */
221 wxString netlist;
222
223 // We need the list of pins of the lib symbol, not just the pins of the current
224 // sch symbol, that can be just an unit of a multi-unit symbol, to be able to
225 // select/filter right footprints
226 wxArrayString pins;
227
228 const std::unique_ptr< LIB_SYMBOL >& lib_symbol = symbol->GetLibSymbolRef();
229
230 if( lib_symbol )
231 {
232 for( SCH_PIN* pin : lib_symbol->GetGraphicalPins( 0 /* all units */, 1 /* single bodyStyle */ ) )
233 {
234 bool valid = false;
235 auto expanded = pin->GetStackedPinNumbers( &valid );
236 if( valid && !expanded.empty() )
237 {
238 for( const wxString& num : expanded )
239 pins.push_back( num + ' ' + pin->GetShownName() );
240 }
241 else
242 {
243 pins.push_back( pin->GetNumber() + ' ' + pin->GetShownName() );
244 }
245 }
246 }
247
248 if( !pins.IsEmpty() )
249 {
250 wxString dbg = wxJoin( pins, '\t' );
251 wxLogTrace( "FOOTPRINT_CHOOSER", wxS( "Chooser payload pins (SCH_SYMBOL): %s" ), dbg );
252 netlist << EscapeString( dbg, CTX_LINE );
253 }
254
255 netlist << wxS( "\r" );
256
257 wxArrayString fpFilters;
258
259 if( symbol->GetLibSymbolRef() ) // can be null with very old schematic
260 fpFilters = symbol->GetLibSymbolRef()->GetFPFilters();
261
262 if( !fpFilters.IsEmpty() )
263 netlist << EscapeString( wxJoin( fpFilters, ' ' ), CTX_LINE );
264
265 netlist << wxS( "\r" );
266
268 }
269
270 if( aField->GetId() == FIELD_T::SHEET_FILENAME )
271 {
272 m_isSheetFilename = true;
273 m_note->Show( true );
274 }
275
276 m_textLabel->SetLabel( aField->GetName() + wxS( ":" ) );
277
278 m_position = m_field->GetPosition();
279
280 m_isNameVisible = m_field->IsNameShown();
281 m_allowAutoplace = m_field->CanAutoplace();
282
283 m_horizontalJustification = m_field->GetEffectiveHorizJustify();
284 m_verticalJustification = m_field->GetEffectiveVertJustify();
285
286 m_StyledTextCtrl->Bind( wxEVT_STC_CHARADDED,
288 m_StyledTextCtrl->Bind( wxEVT_STC_AUTOCOMP_CHAR_DELETED,
290
291 m_nameVisible->Show();
292 m_cbAllowAutoPlace->Show();
293
294 init();
295
296 if( m_isSheetFilename || m_field->IsGeneratedField() )
297 {
298 m_StyledTextCtrl->Enable( false );
299 m_TextCtrl->Enable( false );
300 }
301}
302
303
308
309
311{
312 // Disable options for graphic text editing which are not needed for fields.
313 m_commonToAllBodyStyles->Show( false );
314 m_commonToAllUnits->Show( false );
315
316 // Predefined fields cannot contain some chars and cannot be empty, so they need a
317 // SCH_FIELD_VALIDATOR (m_StyledTextCtrl cannot use a SCH_FIELD_VALIDATOR).
323 {
324 m_TextCtrl->SetValidator( FIELD_VALIDATOR( m_fieldId, &m_text ) );
326
327 m_StyledTextCtrl->Show( false );
328 m_StyledTextCtrlBorder->Show( false );
329 }
330 else
331 {
333
334 m_TextCtrl->Show( false );
335 }
336
337 // Show the unit selector for reference fields on multi-unit schematic symbols
338 bool showUnitSelector = m_fieldId == FIELD_T::REFERENCE
339 && m_field->GetParentSymbol()
340 && m_field->GetParentSymbol()->Type() == SCH_SYMBOL_T
341 && m_field->GetParentSymbol()->IsMultiUnit();
342
343 m_unitLabel->Show( showUnitSelector );
344 m_unitChoice->Show( showUnitSelector );
345
346 // Show the footprint selection dialog if this is the footprint field.
349
350 m_TextCtrl->Enable( true );
351
352 GetSizer()->SetSizeHints( this );
353
354 // Adjust the height of the scintilla editor after the first layout to show a single line
355 // (multiline text is not supported in fields and will be removed)
356 if( m_StyledTextCtrl->IsShown() )
357 {
358 wxSize maxSize;
359 maxSize.x = -1; // Do not fix the max width
360 maxSize.y = m_StyledTextCtrl->TextHeight( 0 );
361 m_StyledTextCtrl->SetMaxSize( maxSize );
362 m_StyledTextCtrl->SetUseVerticalScrollBar( false );
363 m_StyledTextCtrl->SetUseHorizontalScrollBar( false );
364 }
365
367
368 // Now all widgets have the size fixed, call FinishDialogSettings
370}
371
372
374{
375 // pick a footprint using the footprint picker.
376 wxString fpid;
377
378 if( m_StyledTextCtrl->IsShown() )
379 fpid = m_StyledTextCtrl->GetValue();
380 else
381 fpid = m_TextCtrl->GetValue();
382
383 if( KIWAY_PLAYER* frame = Kiway().Player( FRAME_FOOTPRINT_CHOOSER, true, this ) )
384 {
386 frame->KiwayMailIn( event );
387
388 if( frame->ShowModal( &fpid, this ) )
389 {
390 if( m_StyledTextCtrl->IsShown() )
391 m_StyledTextCtrl->SetValue( fpid );
392 else
393 m_TextCtrl->SetValue( fpid );
394 }
395
396 frame->Destroy();
397 }
398}
399
400
402{
403 if( m_firstFocus )
404 {
405#ifdef __WXGTK__
406 // Force an update of the text control before setting the text selection
407 // This is needed because GTK seems to ignore the selection on first update
408 //
409 // Note that we can't do this on OSX as it tends to provoke Apple's
410 // "[NSAlert runModal] may not be invoked inside of transaction begin/commit pair"
411 // bug. See: https://bugs.launchpad.net/kicad/+bug/1837225
413 m_TextCtrl->Update();
414#endif
415
417 KIUI::SelectReferenceNumber( static_cast<wxTextEntry*>( m_TextCtrl ) );
419 m_TextCtrl->SetSelection( -1, -1 );
420
421 m_firstFocus = false;
422 }
423
424 event.Skip();
425}
426
427
428void DIALOG_FIELD_PROPERTIES::onOrientButton( wxCommandEvent& aEvent )
429{
430 for( BITMAP_BUTTON* btn : { m_horizontal, m_vertical } )
431 {
432 if( btn->IsChecked() && btn != aEvent.GetEventObject() )
433 btn->Check( false );
434 }
435}
436
437
438void DIALOG_FIELD_PROPERTIES::onHAlignButton( wxCommandEvent& aEvent )
439{
441 {
442 if( btn->IsChecked() && btn != aEvent.GetEventObject() )
443 btn->Check( false );
444 }
445}
446
447
448void DIALOG_FIELD_PROPERTIES::onVAlignButton( wxCommandEvent& aEvent )
449{
451 {
452 if( btn->IsChecked() && btn != aEvent.GetEventObject() )
453 btn->Check( false );
454 }
455}
456
457
459{
460 if( m_TextCtrl->IsShown() )
461 {
462 m_TextCtrl->SetValue( EscapeString( m_text, CTX_LINE ) );
463 }
464 else if( m_StyledTextCtrl->IsShown() )
465 {
467 m_StyledTextCtrl->EmptyUndoBuffer();
468 }
469
470 if( m_unitChoice->IsShown() )
471 {
472 const SYMBOL* parent = m_field->GetParentSymbol();
473
474 // Control shouldn't be shown for non-schematic symbols
475 wxCHECK( parent->Type() == SCH_SYMBOL_T, true );
476
477 const SCH_SYMBOL* symbol = static_cast<const SCH_SYMBOL*>( parent );
478
479 for( int ii = 1; ii <= symbol->GetUnitCount(); ii++ )
480 m_unitChoice->Append( symbol->GetUnitDisplayName( ii, false ) );
481
482 if( symbol->GetUnit() <= (int) m_unitChoice->GetCount() )
483 m_unitChoice->SetSelection( symbol->GetUnit() - 1 );
484 }
485
486 m_fontCtrl->SetFontSelection( m_font );
487
488 m_posX.SetValue( m_position.x );
489 m_posY.SetValue( m_position.y );
490 m_textSize.SetValue( m_size );
491
492 m_horizontal->Check( !m_isVertical );
493 m_vertical->Check( m_isVertical );
494
495 m_italic->Check( m_isItalic );
496 m_bold->Check( m_isBold );
497
498 m_textColorSwatch->SetSwatchColor( m_color, false );
499
501 {
502 case GR_TEXT_H_ALIGN_LEFT: m_hAlignLeft->Check( true ); break;
503 case GR_TEXT_H_ALIGN_CENTER: m_hAlignCenter->Check( true ); break;
504 case GR_TEXT_H_ALIGN_RIGHT: m_hAlignRight->Check( true ); break;
506 }
507
508 switch ( m_verticalJustification )
509 {
510 case GR_TEXT_V_ALIGN_TOP: m_vAlignTop->Check( true ); break;
511 case GR_TEXT_V_ALIGN_CENTER: m_vAlignCenter->Check( true ); break;
512 case GR_TEXT_V_ALIGN_BOTTOM: m_vAlignBottom->Check( true ); break;
514 }
515
516 m_visible->SetValue( m_isVisible );
517 m_nameVisible->SetValue( m_isNameVisible );
519
520 return true;
521}
522
523
525{
526 if( m_TextCtrl->IsShown() )
527 m_text = UnescapeString( m_TextCtrl->GetValue() );
528 else if( m_StyledTextCtrl->IsShown() )
529 m_text = UnescapeString( m_StyledTextCtrl->GetValue() );
530
533
534 m_position = VECTOR2I( m_posX.GetIntValue(), m_posY.GetIntValue() );
535 m_size = m_textSize.GetIntValue();
536
537 if( m_fontCtrl->HaveFontSelection() )
538 m_font = m_fontCtrl->GetFontSelection( m_bold->IsChecked(), m_italic->IsChecked() );
539
540 m_isVertical = m_vertical->IsChecked();
541
542 m_isBold = m_bold->IsChecked();
543 m_isItalic = m_italic->IsChecked();
544 m_color = m_textColorSwatch->GetSwatchColor();
545
546 if( m_hAlignLeft->IsChecked() )
548 else if( m_hAlignCenter->IsChecked() )
550 else
552
553 if( m_vAlignTop->IsChecked() )
555 else if( m_vAlignCenter->IsChecked() )
557 else
559
560 m_isVisible = m_visible->GetValue();
561 m_isNameVisible = m_nameVisible->GetValue();
563
564 return true;
565}
566
567
569{
570 if( aField->GetTextWidth() != m_size )
571 aField->SetTextSize( VECTOR2I( m_size, m_size ) );
572
573 aField->SetFont( m_font );
574 aField->SetVisible( m_isVisible );
576 aField->SetItalic( m_isItalic );
577 aField->SetBold( m_isBold );
578 aField->SetTextColor( m_color );
579}
580
581
595
596
597void DIALOG_FIELD_PROPERTIES::onScintillaCharAdded( wxStyledTextEvent &aEvent )
598{
599 m_field->OnScintillaCharAdded( m_scintillaTricks, aEvent );
600}
601
602
604 SCH_SHEET_PATH* aSheetPath )
605{
606 SCH_EDIT_FRAME* editFrame = dynamic_cast<SCH_EDIT_FRAME*>( GetParent() );
607 SCH_ITEM* parent = dynamic_cast<SCH_ITEM*>( aField->GetParent() );
608
609 if( parent && parent->Type() == SCH_SYMBOL_T )
610 {
611 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( parent );
612
614 symbol->SetRef( aSheetPath, m_text );
615
616 // Set the unit selection in multiple units per package
617 if( m_unitChoice->IsShown() )
618 {
619 int unit_selection = m_unitChoice->IsEnabled() ? m_unitChoice->GetSelection() + 1 : 1;
620 symbol->SetUnitSelection( aSheetPath, unit_selection );
621 symbol->SetUnit( unit_selection );
622 }
623 }
624 else if( parent && parent->Type() == SCH_GLOBAL_LABEL_T )
625 {
627 {
628 if( m_visible->GetValue() != parent->Schematic()->Settings().m_IntersheetRefsShow )
629 {
630 DisplayInfoMessage( this, _( "Intersheet reference visibility is "
631 "controlled globally from "
632 "Schematic Setup > General > Formatting" ) );
633 }
634 }
635 }
636
637 bool positioningModified = false;
638
639 if( aField->GetPosition() != m_position )
640 positioningModified = true;
641
642 if( aField->GetTextAngle().IsVertical() != m_isVertical )
643 positioningModified = true;
644
646 positioningModified = true;
647
649 positioningModified = true;
650
651 // convert any text variable cross-references to their UUIDs
653
654 // Changing a sheetname need to update the hierarchy navigator
655 bool needUpdateHierNav = false;
656
658 needUpdateHierNav = m_text != aField->GetText();
659
660 aField->SetText( m_text );
661 updateText( aField );
662 aField->SetPosition( m_position );
663
664 aField->SetNameShown( m_isNameVisible );
666
667 // Note that we must set justifications before we can ask if they're flipped. If the old
668 // justification is center then it won't know (whereas if the new justification is center
669 // the we don't care).
672
673 if( aField->IsHorizJustifyFlipped() )
675
676 if( aField->IsVertJustifyFlipped() )
678
679 // The value, footprint and datasheet fields should be kept in sync in multi-unit parts.
680 // Of course the symbol must be annotated to collect other units.
681 if( editFrame && parent && parent->Type() == SCH_SYMBOL_T )
682 {
683 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( parent );
684
685 if( symbol->IsAnnotated( aSheetPath ) && ( m_fieldId == FIELD_T::VALUE
688 {
689 wxString ref = symbol->GetRef( aSheetPath );
690 int unit = symbol->GetUnit();
691 LIB_ID libId = symbol->GetLibId();
692
693 for( SCH_SHEET_PATH& sheet : editFrame->Schematic().Hierarchy() )
694 {
695 SCH_SCREEN* screen = sheet.LastScreen();
696 std::vector<SCH_SYMBOL*> otherUnits;
697
698 CollectOtherUnits( ref, unit, libId, sheet, &otherUnits );
699
700 for( SCH_SYMBOL* otherUnit : otherUnits )
701 {
702 aCommit->Modify( otherUnit, screen );
703 otherUnit->GetField( m_fieldId )->SetText( m_text );
704 editFrame->UpdateItem( otherUnit, false, true );
705 }
706 }
707 }
708 }
709
710 if( positioningModified && parent )
712
713 // Update the hierarchy navigator labels if needed.
714 if( editFrame && needUpdateHierNav )
716}
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:269
const VECTOR2I & GetTextPos() const
Definition eda_text.h:273
COLOR4D GetTextColor() const
Definition eda_text.h:270
bool IsItalic() const
Definition eda_text.h:169
const EDA_ANGLE & GetTextAngle() const
Definition eda_text.h:147
void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true)
Definition eda_text.cpp:544
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition eda_text.h:98
virtual bool IsVisible() const
Definition eda_text.h:187
void SetTextPos(const VECTOR2I &aPoint)
Definition eda_text.cpp:589
int GetTextWidth() const
Definition eda_text.h:264
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
Definition eda_text.cpp:428
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition eda_text.h:200
virtual void SetVisible(bool aVisible)
Definition eda_text.cpp:397
static GR_TEXT_H_ALIGN_T MapHorizJustify(int aHorizJustify)
Definition eda_text.cpp:69
void SetBold(bool aBold)
Set the text to be bold - this will also update the font if needed.
Definition eda_text.cpp:346
bool IsBold() const
Definition eda_text.h:184
static GR_TEXT_V_ALIGN_T MapVertJustify(int aVertJustify)
Definition eda_text.cpp:83
GR_TEXT_V_ALIGN_T GetVertJustify() const
Definition eda_text.h:203
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition eda_text.cpp:310
void SetItalic(bool aItalic)
Set the text to be italic - this will also update the font if needed.
Definition eda_text.cpp:318
void SetFont(KIFONT::FONT *aFont)
Definition eda_text.cpp:510
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Definition eda_text.cpp:420
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:213
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:202
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:250
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
Definition sch_item.cpp:244
int GetUnit() const
Definition sch_item.h:238
void SetFieldsAutoplaced(AUTOPLACE_ALGO aAlgo)
Definition sch_item.h:607
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:76
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:165
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:184
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:439
The common library.
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition confirm.cpp:230
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:488
@ 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
@ 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:152
@ SCH_SYMBOL_T
Definition typeinfo.h:176
@ SCH_GLOBAL_LABEL_T
Definition typeinfo.h:172
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:695
Definition of file extensions used in Kicad.