KiCad PCB EDA Suite
dialog_field_properties.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2012 Jean-Pierre Charras, [email protected]
5  * Copyright (C) 2016 Wayne Stambaugh, [email protected]
6  * Copyright (C) 2004-2021 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 
26 #include <bitmaps.h>
27 #include <kiway.h>
28 #include <confirm.h>
29 #include <string_utils.h>
30 #include <sch_base_frame.h>
31 #include <sch_edit_frame.h>
32 #include <ee_collectors.h>
33 #include <sch_symbol.h>
34 #include <lib_field.h>
35 #include <template_fieldnames.h>
36 #include <symbol_library.h>
37 #include <sch_validators.h>
38 #include <schematic.h>
40 #include <sch_text.h>
41 #include <scintilla_tricks.h>
43 
44 
46  const EDA_TEXT* aTextItem ) :
48  m_posX( aParent, m_xPosLabel, m_xPosCtrl, m_xPosUnits, true ),
49  m_posY( aParent, m_yPosLabel, m_yPosCtrl, m_yPosUnits, true ),
50  m_textSize( aParent, m_textSizeLabel, m_textSizeCtrl, m_textSizeUnits, true ),
51  m_firstFocus( true ),
52  m_scintillaTricks( nullptr )
53 {
54  wxASSERT( aTextItem );
55 
56  SetTitle( aTitle );
57 
58  m_note->SetFont( KIUI::GetInfoFont( this ).Italic() );
59  m_note->Show( false );
60 
61  // The field ID and power status are Initialized in the derived object's ctor.
63  m_isPower = false;
64 
65  m_scintillaTricks = new SCINTILLA_TRICKS( m_StyledTextCtrl, wxT( "{}" ), true,
66  [this]()
67  {
68  wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
69  } );
70  m_StyledTextCtrl->SetEOLMode( wxSTC_EOL_LF ); // Normalize EOL across platforms
71 
72  m_text = aTextItem->GetText();
73  m_isItalic = aTextItem->IsItalic();
74  m_isBold = aTextItem->IsBold();
75  m_position = aTextItem->GetTextPos();
76  m_size = aTextItem->GetTextWidth();
77  m_isVertical = ( aTextItem->GetTextAngle() == TEXT_ANGLE_VERT );
78  m_verticalJustification = aTextItem->GetVertJustify() + 1;
79  m_horizontalJustification = aTextItem->GetHorizJustify() + 1;
80  m_isVisible = aTextItem->IsVisible();
81 }
82 
83 
85 {
86  delete m_scintillaTricks;
87 }
88 
89 
91 {
92  SCH_BASE_FRAME* parent = GetParent();
93  bool isSymbolEditor = parent && parent->IsType( FRAME_SCH_SYMBOL_EDITOR );
94 
95  // Disable options for graphic text editing which are not needed for fields.
96  m_CommonConvert->Show( false );
97  m_CommonUnit->Show( false );
98 
99  // Predefined fields cannot contain some chars, or cannot be empty,
100  // and need a SCH_FIELD_VALIDATOR (m_StyledTextCtrl cannot use a SCH_FIELD_VALIDATOR).
101  bool use_validator = m_fieldId == REFERENCE_FIELD
102  || m_fieldId == VALUE_FIELD
105  || m_fieldId == SHEETNAME_V
107 
108  if( use_validator )
109  {
110  m_TextCtrl->SetValidator( SCH_FIELD_VALIDATOR( isSymbolEditor, m_fieldId, &m_text ) );
112 
113  m_StyledTextCtrl->Show( false );
114  }
115  else
116  {
118 
119  m_TextCtrl->Show( false );
120  }
121 
122  // Show the footprint selection dialog if this is the footprint field.
125 
126  // Value fields of power symbols cannot be modified. This will grey out
127  // the text box and display an explanation.
128  if( m_fieldId == VALUE_FIELD && m_isPower )
129  {
130  m_note->SetLabel( wxString::Format( m_note->GetLabel(),
131  _( "Power symbol value field text cannot be changed." ) ) );
132  m_note->Show( true );
133  m_TextCtrl->Enable( false );
134  }
135  else
136  {
137  m_TextCtrl->Enable( true );
138  }
139 
140  m_sdbSizerButtonsOK->SetDefault();
141 
142  GetSizer()->SetSizeHints( this );
143 
144  // Adjust the height of the scintilla text editor after the first layout
145  // To show only one line
146  // (multiline text are is supported in fields and will be removed)
147  if( m_StyledTextCtrl->IsShown() )
148  {
149  wxSize maxSize = m_StyledTextCtrl->GetSize();
150  maxSize.x = -1; // Do not fix the max width
151  maxSize.y = m_xPosCtrl->GetSize().y;
152  m_StyledTextCtrl->SetMaxSize( maxSize );
153  m_StyledTextCtrl->SetUseVerticalScrollBar( false );
154  m_StyledTextCtrl->SetUseHorizontalScrollBar( false );
155  }
156 
157  // Now all widgets have the size fixed, call FinishDialogSettings
159 }
160 
161 
163 {
164  // pick a footprint using the footprint picker.
165  wxString fpid;
166 
167  if( m_StyledTextCtrl->IsShown() )
168  fpid = m_StyledTextCtrl->GetValue();
169  else
170  fpid = m_TextCtrl->GetValue();
171 
173 
174  if( frame->ShowModal( &fpid, this ) )
175  {
176  if( m_StyledTextCtrl->IsShown() )
177  m_StyledTextCtrl->SetValue( fpid );
178  else
179  m_TextCtrl->SetValue( fpid );
180  }
181 
182  frame->Destroy();
183 }
184 
185 
186 void DIALOG_FIELD_PROPERTIES::OnSetFocusText( wxFocusEvent& event )
187 {
188  if( m_firstFocus )
189  {
190 #ifdef __WXGTK__
191  // Force an update of the text control before setting the text selection
192  // This is needed because GTK seems to ignore the selection on first update
193  //
194  // Note that we can't do this on OSX as it tends to provoke Apple's
195  // wxT( "[NSAlert runModal] may not be invoked inside of transaction begin/commit pair" )
196  // bug. See: https://bugs.launchpad.net/kicad/+bug/1837225
198  m_TextCtrl->Update();
199 #endif
200 
201  if( m_fieldId == REFERENCE_FIELD )
202  KIUI::SelectReferenceNumber( static_cast<wxTextEntry*>( m_TextCtrl ) );
203  else if( m_fieldId == VALUE_FIELD || m_fieldId == SHEETNAME_V )
204  m_TextCtrl->SetSelection( -1, -1 );
205 
206  m_firstFocus = false;
207  }
208 
209  event.Skip();
210 }
211 
212 
214 {
215  if( m_TextCtrl->IsShown() )
216  m_TextCtrl->SetValue( m_text );
217  else if( m_StyledTextCtrl->IsShown() )
218  m_StyledTextCtrl->SetValue( m_text );
219 
223  m_orientChoice->SetSelection( m_isVertical ? 1 : 0 );
224  m_hAlignChoice->SetSelection( m_horizontalJustification );
225  m_vAlignChoice->SetSelection( m_verticalJustification );
226  m_visible->SetValue( m_isVisible );
227  m_italic->SetValue( m_isItalic );
228  m_bold->SetValue( m_isBold );
229 
230  return true;
231 }
232 
233 
235 {
236  if( m_TextCtrl->IsShown() )
237  m_text = m_TextCtrl->GetValue();
238  else if( m_StyledTextCtrl->IsShown() )
239  m_text = m_StyledTextCtrl->GetValue();
240 
241  if( m_fieldId == REFERENCE_FIELD )
242  {
243  // Test if the reference string is valid:
245  {
246  DisplayError( this, _( "Illegal reference designator value!" ) );
247  return false;
248  }
249  }
250  else if( m_fieldId == VALUE_FIELD )
251  {
252  if( m_text.IsEmpty() )
253  {
254  DisplayError( this, _( "Value may not be empty." ) );
255  return false;
256  }
257  }
258  else if( m_fieldId == SHEETFILENAME_V )
259  {
260  wxFileName fn( m_text );
261 
262  // It's annoying to throw up nag dialogs when the extension isn't right. Just
263  // fix it.
264  if( fn.GetExt().CmpNoCase( KiCadSchematicFileExtension ) != 0 )
265  {
266  fn.SetExt( KiCadSchematicFileExtension );
267  m_text = fn.GetFullPath();
268  }
269  }
270 
271  m_isVertical = m_orientChoice->GetSelection() == 1;
272  m_position = wxPoint( m_posX.GetValue(), m_posY.GetValue() );
274  m_horizontalJustification = m_hAlignChoice->GetSelection();
275  m_verticalJustification = m_vAlignChoice->GetSelection();
276  m_isVisible = m_visible->GetValue();
277  m_isItalic = m_italic->GetValue();
278  m_isBold = m_bold->GetValue();
279 
280  return true;
281 }
282 
283 
285 {
286  if( aText->GetTextWidth() != m_size )
287  aText->SetTextSize( wxSize( m_size, m_size ) );
288 
289  aText->SetVisible( m_isVisible );
291  aText->SetItalic( m_isItalic );
292  aText->SetBold( m_isBold );
293 }
294 
295 
297  const wxString& aTitle,
298  const LIB_FIELD* aField ) :
299  DIALOG_FIELD_PROPERTIES( aParent, aTitle, aField )
300 {
301  m_fieldId = aField->GetId();
302 
303  if( m_fieldId == VALUE_FIELD )
304  m_text = UnescapeString( aField->GetText() );
305 
306  // When in the library editor, power symbols can be renamed.
307  m_isPower = false;
308  init();
309 }
310 
311 
313  const wxString& aTitle,
314  const SCH_FIELD* aField ) :
315  DIALOG_FIELD_PROPERTIES( aParent, aTitle, aField ),
316  m_field( aField )
317 {
318  m_isSheetFilename = false;
319 
320  if( aField->GetParent() && aField->GetParent()->Type() == SCH_SYMBOL_T )
321  {
322  m_fieldId = aField->GetId();
323  }
324  else if( aField->GetParent() && aField->GetParent()->Type() == SCH_SHEET_T )
325  {
326  switch( aField->GetId() )
327  {
328  case SHEETNAME:
330  break;
331 
332  case SHEETFILENAME:
333  m_isSheetFilename = true;
335  m_note->SetLabel( wxString::Format( m_note->GetLabel(),
336  _( "Sheet filename can only be modified in Sheet Properties dialog." ) ) );
337  m_note->Show( true );
338  break;
339 
340  default:
342  break;
343  }
344  }
345 
346  // show text variable cross-references in a human-readable format
347  m_text = aField->Schematic()->ConvertKIIDsToRefs( aField->GetText() );
348 
349  m_isPower = false;
350 
351  m_textLabel->SetLabel( m_field->GetName() + wxT( ":" ) );
352 
354 
357 
358  // The library symbol may have been removed so using SCH_SYMBOL::GetLibSymbolRef() here
359  // could result in a segfault. If the library symbol is no longer available, the
360  // schematic fields can still edit so set the power symbol flag to false. This may not
361  // be entirely accurate if the power library is missing but it's better then a segfault.
362  if( aField->GetParent() && aField->GetParent()->Type() == SCH_SYMBOL_T )
363  {
364  const SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( aField->GetParent() );
365  const LIB_SYMBOL* libSymbol = GetParent()->GetLibSymbol( symbol->GetLibId(), true );
366 
367  if( libSymbol && libSymbol->IsPower() )
368  m_isPower = true;
369  }
370 
371  m_StyledTextCtrl->Bind( wxEVT_STC_CHARADDED,
373 
374  init();
375 
376  if( m_isSheetFilename )
377  {
378  m_StyledTextCtrl->Enable( false );
379  m_TextCtrl->Enable( false );
380  }
381 }
382 
383 
384 void DIALOG_SCH_FIELD_PROPERTIES::onScintillaCharAdded( wxStyledTextEvent &aEvent )
385 {
386  int key = aEvent.GetKey();
387 
388  SCH_EDIT_FRAME* editFrame = static_cast<SCH_EDIT_FRAME*>( GetParent() );
389  wxArrayString autocompleteTokens;
390  int pos = m_StyledTextCtrl->GetCurrentPos();
391  int start = m_StyledTextCtrl->WordStartPosition( pos, true );
392  wxString partial;
393 
394  // Currently, '\n' is not allowed in fields. So remove it when entered
395  // TODO: see if we must close the dialog. However this is not obvious, as
396  // if a \n is typed (and removed) when a text is selected, this text is deleted
397  // (in fact replaced by \n, that is removed by the filter)
398  if( key == '\n' )
399  {
400  wxString text = m_StyledTextCtrl->GetText();
401  int currpos = m_StyledTextCtrl->GetCurrentPos();
402  text.Replace( wxT( "\n" ), wxEmptyString );
403  m_StyledTextCtrl->SetText( text );
404  m_StyledTextCtrl->GotoPos( currpos-1 );
405  return;
406  }
407 
408  auto textVarRef =
409  [&]( int pt )
410  {
411  return pt >= 2
412  && m_StyledTextCtrl->GetCharAt( pt - 2 ) == '$'
413  && m_StyledTextCtrl->GetCharAt( pt - 1 ) == '{';
414  };
415 
416  // Check for cross-reference
417  if( start > 1 && m_StyledTextCtrl->GetCharAt( start - 1 ) == ':' )
418  {
419  int refStart = m_StyledTextCtrl->WordStartPosition( start - 1, true );
420 
421  if( textVarRef( refStart ) )
422  {
423  partial = m_StyledTextCtrl->GetRange( start, pos );
424 
425  wxString ref = m_StyledTextCtrl->GetRange( refStart, start - 1 );
426  SCH_SHEET_LIST sheets = editFrame->Schematic().GetSheets();
427  SCH_REFERENCE_LIST refs;
428  SCH_SYMBOL* refSymbol = nullptr;
429 
430  sheets.GetSymbols( refs );
431 
432  for( size_t jj = 0; jj < refs.GetCount(); jj++ )
433  {
434  if( refs[ jj ].GetSymbol()->GetRef( &refs[ jj ].GetSheetPath(), true ) == ref )
435  {
436  refSymbol = refs[ jj ].GetSymbol();
437  break;
438  }
439  }
440 
441  if( refSymbol )
442  refSymbol->GetContextualTextVars( &autocompleteTokens );
443  }
444  }
445  else if( textVarRef( start ) )
446  {
447  partial = m_StyledTextCtrl->GetTextRange( start, pos );
448 
449  SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( m_field->GetParent() );
450  SCH_SHEET* sheet = dynamic_cast<SCH_SHEET*>( m_field->GetParent() );
451 
452  if( symbol )
453  {
454  symbol->GetContextualTextVars( &autocompleteTokens );
455 
456  SCHEMATIC* schematic = symbol->Schematic();
457 
458  if( schematic && schematic->CurrentSheet().Last() )
459  schematic->CurrentSheet().Last()->GetContextualTextVars( &autocompleteTokens );
460  }
461 
462  if( sheet )
463  sheet->GetContextualTextVars( &autocompleteTokens );
464 
465  for( std::pair<wxString, wxString> entry : Prj().GetTextVars() )
466  autocompleteTokens.push_back( entry.first );
467  }
468 
469  m_scintillaTricks->DoAutocomplete( partial, autocompleteTokens );
470  m_StyledTextCtrl->SetFocus();
471 }
472 
473 
475 {
476  SCH_EDIT_FRAME* editFrame = dynamic_cast<SCH_EDIT_FRAME*>( GetParent() );
477  SCH_ITEM* parent = dynamic_cast<SCH_ITEM*>( aField->GetParent() );
478  int fieldType = aField->GetId();
479 
480  if( parent && parent->Type() == SCH_SYMBOL_T )
481  {
482  SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( parent );
483 
484  if( fieldType == REFERENCE_FIELD )
485  symbol->SetRef( aSheetPath, m_text );
486  else if( fieldType == VALUE_FIELD )
487  symbol->SetValue( m_text );
488  else if( fieldType == FOOTPRINT_FIELD )
489  symbol->SetFootprint( m_text );
490  }
491 
494  bool positioningModified = false;
495 
496  if( aField->GetPosition() != m_position )
497  positioningModified = true;
498 
499  if( ( aField->GetTextAngle() == TEXT_ANGLE_VERT ) != m_isVertical )
500  positioningModified = true;
501 
502  if( aField->GetEffectiveHorizJustify() != hJustify )
503  positioningModified = true;
504 
505  if( aField->GetEffectiveVertJustify() != vJustify )
506  positioningModified = true;
507 
508  // convert any text variable cross-references to their UUIDs
509  m_text = aField->Schematic()->ConvertRefsToKIIDs( m_text );
510 
511  aField->SetText( m_text );
512  updateText( aField );
513  aField->SetPosition( m_position );
514 
515  // Note that we must set justifications before we can ask if they're flipped. If the old
516  // justification is center then it won't know (whereas if the new justification is center
517  // the we don't care).
518  aField->SetHorizJustify( hJustify );
519  aField->SetVertJustify( vJustify );
520 
521  if( aField->IsHorizJustifyFlipped() )
522  aField->SetHorizJustify( EDA_TEXT::MapHorizJustify( -hJustify ) );
523 
524  if( aField->IsVertJustifyFlipped() )
525  aField->SetVertJustify( EDA_TEXT::MapVertJustify( -vJustify ) );
526 
527  // The value, footprint and datasheet fields should be kept in sync in multi-unit parts.
528  // Of course the symbol must be annotated to collect other units.
529  if( editFrame && parent && parent->Type() == SCH_SYMBOL_T )
530  {
531  SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( parent );
532 
533  if( symbol->IsAnnotated( aSheetPath ) && ( fieldType == VALUE_FIELD
534  || fieldType == FOOTPRINT_FIELD
535  || fieldType == DATASHEET_FIELD ) )
536  {
537  wxString ref = symbol->GetRef( aSheetPath );
538  int unit = symbol->GetUnit();
539  LIB_ID libId = symbol->GetLibId();
540 
541  for( SCH_SHEET_PATH& sheet : editFrame->Schematic().GetSheets() )
542  {
543  SCH_SCREEN* screen = sheet.LastScreen();
544  std::vector<SCH_SYMBOL*> otherUnits;
545  constexpr bool appendUndo = true;
546 
547  CollectOtherUnits( ref, unit, libId, sheet, &otherUnits );
548 
549  for( SCH_SYMBOL* otherUnit : otherUnits )
550  {
551  editFrame->SaveCopyInUndoList( screen, otherUnit, UNDO_REDO::CHANGED,
552  appendUndo );
553 
554  if( fieldType == VALUE_FIELD )
555  otherUnit->SetValue( m_text );
556  else if( fieldType == FOOTPRINT_FIELD )
557  otherUnit->SetFootprint( m_text );
558  else
559  otherUnit->GetField( DATASHEET_FIELD )->SetText( m_text );
560 
561  editFrame->UpdateItem( otherUnit, false, true );
562  }
563  }
564  }
565  }
566 
567  if( positioningModified && parent )
568  parent->ClearFieldsAutoplaced();
569 }
Field Reference of part, i.e. "IC21".
virtual bool ShowModal(wxString *aResult=nullptr, wxWindow *aResultantFocusWindow=nullptr)
Show this wxFrame as if it were a modal dialog, with all other instantiated wxFrames disabled until t...
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:279
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
#define TEXT_ANGLE_HORIZ
Frequent text rotations, used with {Set,Get}TextAngle(), in 0.1 degrees for now, hoping to migrate to...
Definition: eda_text.h:71
bool IsBold() const
Definition: eda_text.h:204
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:49
void SelectReferenceNumber(wxTextEntry *aTextEntry)
Select the number (or "?") in a reference for ease of editing.
Definition: ui_common.cpp:185
Class DIALOG_LIB_TEXT_PROPERTIES_BASE.
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Definition: kiway_player.h:64
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:53
EDA_TEXT_HJUSTIFY_T
Definition: eda_text.h:82
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:220
Holds all the data relating to one schematic.
Definition: schematic.h:59
void GetSymbols(SCH_REFERENCE_LIST &aReferences, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanSymbols=false) const
Add a SCH_REFERENCE object to aReferences for each symbol in the list of sheets.
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
This file is part of the common library.
Add cut/copy/paste, dark theme, autocomplete and brace highlighting to a wxStyleTextCtrl instance.
A base class to edit schematic and symbol library fields.
wxPoint GetPosition() const override
Definition: sch_field.cpp:842
void DoAutocomplete(const wxString &aPartial, const wxArrayString &aTokens)
void updateText(EDA_TEXT *aText)
void SetItalic(bool isItalic)
Definition: eda_text.h:200
Field object used in symbol libraries.
Definition: lib_field.h:59
DIALOG_SCH_FIELD_PROPERTIES(SCH_BASE_FRAME *aParent, const wxString &aTitle, const SCH_FIELD *aField)
void SetValue(const SCH_SHEET_PATH *sheet, const wxString &aValue)
Definition: sch_symbol.cpp:624
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:104
wxFont GetInfoFont(wxWindow *aWindow)
Definition: ui_common.cpp:144
bool IsVertJustifyFlipped() const
Definition: sch_field.cpp:384
void GetContextualTextVars(wxArrayString *aVars) const
Return the list of system text vars & fields for this sheet.
Definition: sch_sheet.cpp:215
double GetTextAngle() const
Definition: eda_text.h:195
int GetId() const
Definition: sch_field.h:113
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:393
Schematic editor (Eeschema) main window.
void CollectOtherUnits(const wxString &aRef, int aUnit, const LIB_ID &aLibId, SCH_SHEET_PATH &aSheet, std::vector< SCH_SYMBOL * > *otherUnits)
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:258
int GetId() const
Definition: lib_field.h:115
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
Definition: sch_symbol.cpp:464
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
Define a library symbol object.
Definition: lib_symbol.h:96
void SetFootprint(const SCH_SHEET_PATH *sheet, const wxString &aFootprint)
Definition: sch_symbol.cpp:675
#define SHEETNAME_V
void SetInitialFocus(wxWindow *aWindow)
Sets the window (usually a wxTextCtrl) that should be focused when the dialog is shown.
Definition: dialog_shim.h:97
name of datasheet
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
bool IsItalic() const
Definition: eda_text.h:201
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:140
void onScintillaCharAdded(wxStyledTextEvent &aEvent)
void GetContextualTextVars(wxArrayString *aVars) const
Return the list of system text vars & fields for this symbol.
Definition: sch_symbol.cpp:958
virtual void SetVisible(bool aVisible)
Definition: eda_text.h:206
EDA_TEXT_VJUSTIFY_T GetEffectiveVertJustify() const
Definition: sch_field.cpp:407
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:219
static EDA_TEXT_HJUSTIFY_T MapHorizJustify(int aHorizJustify)
Definition: eda_text.cpp:73
Field Value of part, i.e. "3.3K".
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:124
wxString ConvertRefsToKIIDs(const wxString &aSource) const
Definition: schematic.cpp:288
virtual bool IsVisible() const
Definition: eda_text.h:207
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
Definition: eda_text.h:223
Definitions of control validators for schematic dialogs.
#define SHEETFILENAME_V
DIALOG_FIELD_PROPERTIES(SCH_BASE_FRAME *aParent, const wxString &aTitle, const EDA_TEXT *aTextItem)
SCHEMATIC & Schematic() const
Definition of file extensions used in Kicad.
size_t GetCount() const
void ClearFieldsAutoplaced()
Definition: sch_item.h:427
Definition for symbol library class.
EDA_ITEM * GetParent() const
Definition: eda_item.h:114
#define _(s)
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false, bool aUpdateRtree=false)
Mark an item for refresh.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
void OnTextValueSelectButtonClick(wxCommandEvent &aEvent) override
Handle the select button next to the text value field.
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:105
static EDA_TEXT_VJUSTIFY_T MapVertJustify(int aVertJustify)
Definition: eda_text.cpp:87
#define SHEETUSERFIELD_V
wxString UnescapeString(const wxString &aSource)
EDA_TEXT_HJUSTIFY_T GetEffectiveHorizJustify() const
Definition: sch_field.cpp:370
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:54
EDA_TEXT_VJUSTIFY_T
Definition: eda_text.h:89
bool IsAnnotated(const SCH_SHEET_PATH *aSheet)
Check if the symbol has a valid annotation (reference) for the given sheet path.
Definition: sch_symbol.cpp:540
SCINTILLA_TRICKS * m_scintillaTricks
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
wxString ConvertKIIDsToRefs(const wxString &aSource) const
Definition: schematic.cpp:344
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:87
int GetTextWidth() const
Definition: eda_text.h:262
DIALOG_LIB_FIELD_PROPERTIES(SCH_BASE_FRAME *aParent, const wxString &aTitle, const LIB_FIELD *aField)
Schematic symbol object.
Definition: sch_symbol.h:78
bool IsType(FRAME_T aType) const
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:222
void SaveCopyInUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItemToCopy, UNDO_REDO aTypeCommand, bool aAppend)
Create a copy of the current schematic item, and put it in the undo list.
virtual void SetValue(int aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion.
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:504
wxString GetName(bool aUseDefaultName=true) const
Return the field name.
Definition: sch_field.cpp:678
const std::string KiCadSchematicFileExtension
bool IsHorizJustifyFlipped() const
Return whether the field will be rendered with the horizontal justification inverted due to rotation ...
Definition: sch_field.cpp:347
virtual long long int GetValue()
Return the current value in Internal Units.
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
const wxPoint & GetTextPos() const
Definition: eda_text.h:268
LIB_SYMBOL * GetLibSymbol(const LIB_ID &aLibId, bool aUseCacheLib=false, bool aShowErrorMsg=false)
Load symbol from symbol library table.
#define TEXT_ANGLE_VERT
Definition: eda_text.h:72
virtual void SetTextAngle(double aAngle)
Definition: eda_text.h:188
void UpdateField(SCH_FIELD *aField, SCH_SHEET_PATH *aSheetPath)
A text control validator used for validating the text allowed in library and schematic symbol fields.
int GetUnit() const
Definition: sch_symbol.h:196
SCH_SHEET_PATH & CurrentSheet() const override
Definition: schematic.h:121
static bool IsReferenceStringValid(const wxString &aReferenceString)
Test for an acceptable reference string.
Definition: sch_symbol.cpp:498
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
void SetBold(bool aBold)
Definition: eda_text.h:203
void SetPosition(const wxPoint &aPosition) override
Definition: sch_field.cpp:822
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:182
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:154
virtual void OnSetFocusText(wxFocusEvent &event) override
Used to select the variant part of some text fields (for instance, the question mark or number in a r...
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112
const LIB_ID & GetLibId() const
Definition: sch_symbol.h:148
Field Name Module PCB, i.e. "16DIP300".