KiCad PCB EDA Suite
dialog_edit_one_field.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, jean-pierre.charras@gipsa-lab.inpg.com
5  * Copyright (C) 2016 Wayne Stambaugh, stambaughw@gmail.com
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 <kicad_string.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>
39 #include <dialog_edit_one_field.h>
40 #include <sch_text.h>
41 #include <scintilla_tricks.h>
42 
44  const EDA_TEXT* aTextItem ) :
45  DIALOG_LIB_EDIT_TEXT_BASE( aParent ),
46  m_posX( aParent, m_xPosLabel, m_xPosCtrl, m_xPosUnits, true ),
47  m_posY( aParent, m_yPosLabel, m_yPosCtrl, m_yPosUnits, true ),
48  m_textSize( aParent, m_textSizeLabel, m_textSizeCtrl, m_textSizeUnits, true ),
49  m_firstFocus( true ),
50  m_scintillaTricks( nullptr )
51 {
52  wxASSERT( aTextItem );
53 
54  SetTitle( aTitle );
55 
56  // The field ID and power status are Initialized in the derived object's ctor.
58  m_isPower = false;
59 
61  m_StyledTextCtrl->SetEOLMode( wxSTC_EOL_LF ); // Normalize EOL across platforms
62 
63  m_text = aTextItem->GetText();
64  m_isItalic = aTextItem->IsItalic();
65  m_isBold = aTextItem->IsBold();
66  m_position = aTextItem->GetTextPos();
67  m_size = aTextItem->GetTextWidth();
68  m_isVertical = ( aTextItem->GetTextAngle() == TEXT_ANGLE_VERT );
69  m_verticalJustification = aTextItem->GetVertJustify() + 1;
70  m_horizontalJustification = aTextItem->GetHorizJustify() + 1;
71  m_isVisible = aTextItem->IsVisible();
72 }
73 
74 
76 {
77  delete m_scintillaTricks;
78 }
79 
80 
82 {
83  SCH_BASE_FRAME* parent = GetParent();
84  bool isSymbolEditor = parent && parent->IsType( FRAME_SCH_SYMBOL_EDITOR );
85 
86  // Disable options for graphic text editing which are not needed for fields.
87  m_CommonConvert->Show( false );
88  m_CommonUnit->Show( false );
89 
90  // Predefined fields cannot contain some chars, or cannot be empty,
91  // and need a SCH_FIELD_VALIDATOR (m_StyledTextCtrl cannot use a SCH_FIELD_VALIDATOR).
92  bool use_validator = m_fieldId == REFERENCE_FIELD
98 
99  if( use_validator )
100  {
101  m_TextCtrl->SetValidator( SCH_FIELD_VALIDATOR( isSymbolEditor, m_fieldId, &m_text ) );
103 
104  m_StyledTextCtrl->Show( false );
105  }
106  else
107  {
109 
110  m_TextCtrl->Show( false );
111  }
112 
113  // Show the footprint selection dialog if this is the footprint field.
116 
117  // Value fields of power symbols cannot be modified. This will grey out
118  // the text box and display an explanation.
119  if( m_fieldId == VALUE_FIELD && m_isPower )
120  {
121  m_PowerComponentValues->Show( true );
122  m_TextCtrl->Enable( false );
123  }
124  else
125  {
126  m_PowerComponentValues->Show( false );
127  m_TextCtrl->Enable( true );
128  }
129 
130  m_sdbSizerButtonsOK->SetDefault();
131 
132  GetSizer()->SetSizeHints( this );
133 
134  // Adjust the height of the scintilla text editor after the first layout
135  // To show only one line
136  // (multiline text are is supported in fields and will be removed)
137  if( m_StyledTextCtrl->IsShown() )
138  {
139  wxSize maxSize = m_StyledTextCtrl->GetSize();
140  maxSize.y = m_xPosCtrl->GetSize().y;
141  m_StyledTextCtrl->SetMaxSize( maxSize );
142  m_StyledTextCtrl->SetUseVerticalScrollBar( false );
143  m_StyledTextCtrl->SetUseHorizontalScrollBar( false );
144  }
145 
146  // Now all widgets have the size fixed, call FinishDialogSettings
148 }
149 
150 
152 {
153  // pick a footprint using the footprint picker.
154  wxString fpid;
155 
156  if( m_StyledTextCtrl->IsShown() )
157  fpid = m_StyledTextCtrl->GetValue();
158  else
159  fpid = m_TextCtrl->GetValue();
160 
162 
163  if( frame->ShowModal( &fpid, this ) )
164  {
165  if( m_StyledTextCtrl->IsShown() )
166  m_StyledTextCtrl->SetValue( fpid );
167  else
168  m_TextCtrl->SetValue( fpid );
169  }
170 
171  frame->Destroy();
172 }
173 
174 
175 void DIALOG_EDIT_ONE_FIELD::OnSetFocusText( wxFocusEvent& event )
176 {
177  if( m_firstFocus )
178  {
179 #ifdef __WXGTK__
180  // Force an update of the text control before setting the text selection
181  // This is needed because GTK seems to ignore the selection on first update
182  //
183  // Note that we can't do this on OSX as it tends to provoke Apple's
184  // "[NSAlert runModal] may not be invoked inside of transaction begin/commit pair"
185  // bug. See: https://bugs.launchpad.net/kicad/+bug/1837225
187  m_TextCtrl->Update();
188 #endif
189 
190  if( m_fieldId == REFERENCE_FIELD )
191  KIUI::SelectReferenceNumber( static_cast<wxTextEntry*>( m_TextCtrl ) );
192  else if( m_fieldId == VALUE_FIELD || m_fieldId == SHEETNAME_V )
193  m_TextCtrl->SetSelection( -1, -1 );
194 
195  m_firstFocus = false;
196  }
197 
198  event.Skip();
199 }
200 
201 
203 {
204  if( m_TextCtrl->IsShown() )
205  m_TextCtrl->SetValue( m_text );
206  else if( m_StyledTextCtrl->IsShown() )
207  m_StyledTextCtrl->SetValue( m_text );
208 
212  m_orientChoice->SetSelection( m_isVertical ? 1 : 0 );
213  m_hAlignChoice->SetSelection( m_horizontalJustification );
214  m_vAlignChoice->SetSelection( m_verticalJustification );
215  m_visible->SetValue( m_isVisible );
216  m_italic->SetValue( m_isItalic );
217  m_bold->SetValue( m_isBold );
218 
219  return true;
220 }
221 
222 
224 {
225  if( m_TextCtrl->IsShown() )
226  m_text = m_TextCtrl->GetValue();
227  else if( m_StyledTextCtrl->IsShown() )
228  m_text = m_StyledTextCtrl->GetValue();
229 
230  if( m_fieldId == REFERENCE_FIELD )
231  {
232  // Test if the reference string is valid:
234  {
235  DisplayError( this, _( "Illegal reference designator value!" ) );
236  return false;
237  }
238  }
239  else if( m_fieldId == VALUE_FIELD )
240  {
241  if( m_text.IsEmpty() )
242  {
243  DisplayError( this, _( "Value may not be empty." ) );
244  return false;
245  }
246  }
247 
248  m_isVertical = m_orientChoice->GetSelection() == 1;
249  m_position = wxPoint( m_posX.GetValue(), m_posY.GetValue() );
251  m_horizontalJustification = m_hAlignChoice->GetSelection();
252  m_verticalJustification = m_vAlignChoice->GetSelection();
253  m_isVisible = m_visible->GetValue();
254  m_isItalic = m_italic->GetValue();
255  m_isBold = m_bold->GetValue();
256 
257  return true;
258 }
259 
260 
262 {
263  aText->SetTextPos( m_position );
264  aText->SetTextSize( wxSize( m_size, m_size ) );
265  aText->SetVisible( m_isVisible );
267  aText->SetItalic( m_isItalic );
268  aText->SetBold( m_isBold );
271 }
272 
273 
275  const wxString& aTitle,
276  const LIB_FIELD* aField ) :
277  DIALOG_EDIT_ONE_FIELD( aParent, aTitle, aField )
278 {
279  m_fieldId = aField->GetId();
280 
281  // When in the library editor, power symbols can be renamed.
282  m_isPower = false;
283  init();
284 }
285 
286 
288  const wxString& aTitle,
289  const SCH_FIELD* aField ) :
290  DIALOG_EDIT_ONE_FIELD( aParent, aTitle, aField ),
291  m_field( aField )
292 {
293  if( aField->GetParent() && aField->GetParent()->Type() == SCH_SYMBOL_T )
294  {
295  m_fieldId = aField->GetId();
296  }
297  else if( aField->GetParent() && aField->GetParent()->Type() == SCH_SHEET_T )
298  {
299  switch( aField->GetId() )
300  {
301  case SHEETNAME: m_fieldId = SHEETNAME_V; break;
302  case SHEETFILENAME: m_fieldId = SHEETFILENAME_V; break;
303  default: m_fieldId = SHEETUSERFIELD_V; break;
304  }
305  }
306 
307  // show text variable cross-references in a human-readable format
308  m_text = aField->Schematic()->ConvertKIIDsToRefs( aField->GetText() );
309 
310  m_isPower = false;
311 
312  m_textLabel->SetLabel( m_field->GetName() + ":" );
313 
314  // The library symbol may have been removed so using SCH_SYMBOL::GetLibSymbolRef() here
315  // could result in a segfault. If the library symbol is no longer available, the
316  // schematic fields can still edit so set the power symbol flag to false. This may not
317  // be entirely accurate if the power library is missing but it's better then a segfault.
318  if( aField->GetParent() && aField->GetParent()->Type() == SCH_SYMBOL_T )
319  {
320  const SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( aField->GetParent() );
321  const LIB_SYMBOL* libSymbol = GetParent()->GetLibSymbol( symbol->GetLibId(), true );
322 
323  if( libSymbol && libSymbol->IsPower() )
324  m_isPower = true;
325  }
326 
327  m_StyledTextCtrl->Bind( wxEVT_STC_CHARADDED,
329 
330  init();
331 }
332 
333 
334 void DIALOG_SCH_EDIT_ONE_FIELD::onScintillaCharAdded( wxStyledTextEvent &aEvent )
335 {
336  int key = aEvent.GetKey();
337 
338  SCH_EDIT_FRAME* editFrame = static_cast<SCH_EDIT_FRAME*>( GetParent() );
339  wxArrayString autocompleteTokens;
340  int pos = m_StyledTextCtrl->GetCurrentPos();
341  int start = m_StyledTextCtrl->WordStartPosition( pos, true );
342  wxString partial;
343 
344  // Currently, '\n' is not allowed in fields. So remove it when entered
345  // TODO: see if we must close the dialog. However this is not obvious, as
346  // if a \n is typed (and removed) when a text is selected, this text is deleted
347  // (in fact replaced by \n, that is removed by the filter)
348  if( key == '\n' )
349  {
350  wxString text = m_StyledTextCtrl->GetText();
351  int currpos = m_StyledTextCtrl->GetCurrentPos();
352  text.Replace( "\n", "" );
353  m_StyledTextCtrl->SetText( text );
354  m_StyledTextCtrl->GotoPos( currpos-1 );
355  return;
356  }
357 
358  auto textVarRef =
359  [&]( int pt )
360  {
361  return pt >= 2
362  && m_StyledTextCtrl->GetCharAt( pt - 2 ) == '$'
363  && m_StyledTextCtrl->GetCharAt( pt - 1 ) == '{';
364  };
365 
366  // Check for cross-reference
367  if( start > 1 && m_StyledTextCtrl->GetCharAt( start - 1 ) == ':' )
368  {
369  int refStart = m_StyledTextCtrl->WordStartPosition( start - 1, true );
370 
371  if( textVarRef( refStart ) )
372  {
373  partial = m_StyledTextCtrl->GetRange( start, pos );
374 
375  wxString ref = m_StyledTextCtrl->GetRange( refStart, start - 1 );
376  SCH_SHEET_LIST sheets = editFrame->Schematic().GetSheets();
377  SCH_REFERENCE_LIST refs;
378  SCH_SYMBOL* refSymbol = nullptr;
379 
380  sheets.GetSymbols( refs );
381 
382  for( size_t jj = 0; jj < refs.GetCount(); jj++ )
383  {
384  if( refs[ jj ].GetSymbol()->GetRef( &refs[ jj ].GetSheetPath(), true ) == ref )
385  {
386  refSymbol = refs[ jj ].GetSymbol();
387  break;
388  }
389  }
390 
391  if( refSymbol )
392  refSymbol->GetContextualTextVars( &autocompleteTokens );
393  }
394  }
395  else if( textVarRef( start ) )
396  {
397  partial = m_StyledTextCtrl->GetTextRange( start, pos );
398 
399  SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( m_field->GetParent() );
400  SCH_SHEET* sheet = dynamic_cast<SCH_SHEET*>( m_field->GetParent() );
401 
402  if( symbol )
403  {
404  symbol->GetContextualTextVars( &autocompleteTokens );
405 
406  SCHEMATIC* schematic = symbol->Schematic();
407 
408  if( schematic && schematic->CurrentSheet().Last() )
409  schematic->CurrentSheet().Last()->GetContextualTextVars( &autocompleteTokens );
410  }
411 
412  if( sheet )
413  sheet->GetContextualTextVars( &autocompleteTokens );
414 
415  for( std::pair<wxString, wxString> entry : Prj().GetTextVars() )
416  autocompleteTokens.push_back( entry.first );
417  }
418 
419  m_scintillaTricks->DoAutocomplete( partial, autocompleteTokens );
420  m_StyledTextCtrl->SetFocus();
421 }
422 
423 
425 {
426  SCH_EDIT_FRAME* editFrame = dynamic_cast<SCH_EDIT_FRAME*>( GetParent() );
427  SCH_ITEM* parent = dynamic_cast<SCH_ITEM*>( aField->GetParent() );
428  int fieldType = aField->GetId();
429 
430  if( parent && parent->Type() == SCH_SYMBOL_T )
431  {
432  SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( parent );
433 
434  if( fieldType == REFERENCE_FIELD )
435  symbol->SetRef( aSheetPath, m_text );
436  else if( fieldType == VALUE_FIELD )
437  symbol->SetValue( m_text );
438  else if( fieldType == FOOTPRINT_FIELD )
439  symbol->SetFootprint( m_text );
440  }
441 
442  bool positioningModified = false;
443 
444  if( aField->GetTextPos() != m_position )
445  positioningModified = true;
446 
447  if( ( aField->GetTextAngle() == TEXT_ANGLE_VERT ) != m_isVertical )
448  positioningModified = true;
449 
451  positioningModified = true;
452 
454  positioningModified = true;
455 
456  // convert any text variable cross-references to their UUIDs
457  m_text = aField->Schematic()->ConvertRefsToKIIDs( m_text );
458 
459  aField->SetText( m_text );
460  updateText( aField );
461 
462  // The value, footprint and datasheet fields should be kept in sync in multi-unit parts.
463  // Of course the symbol must be annotated to collect other units.
464  if( editFrame && parent && parent->Type() == SCH_SYMBOL_T )
465  {
466  SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( parent );
467 
468  if( symbol->IsAnnotated( aSheetPath ) && ( fieldType == VALUE_FIELD
469  || fieldType == FOOTPRINT_FIELD
470  || fieldType == DATASHEET_FIELD ) )
471  {
472  wxString ref = symbol->GetRef( aSheetPath );
473  int unit = symbol->GetUnit();
474  LIB_ID libId = symbol->GetLibId();
475 
476  for( SCH_SHEET_PATH& sheet : editFrame->Schematic().GetSheets() )
477  {
478  SCH_SCREEN* screen = sheet.LastScreen();
479  std::vector<SCH_SYMBOL*> otherUnits;
480  constexpr bool appendUndo = true;
481 
482  CollectOtherUnits( ref, unit, libId, sheet, &otherUnits );
483 
484  for( SCH_SYMBOL* otherUnit : otherUnits )
485  {
486  editFrame->SaveCopyInUndoList( screen, otherUnit, UNDO_REDO::CHANGED,
487  appendUndo );
488 
489  if( fieldType == VALUE_FIELD )
490  otherUnit->SetValue( m_text );
491  else if( fieldType == FOOTPRINT_FIELD )
492  otherUnit->SetFootprint( m_text );
493  else
494  otherUnit->GetField( DATASHEET_FIELD )->SetText( m_text );
495 
496  editFrame->UpdateItem( otherUnit );
497  }
498  }
499  }
500  }
501 
502  if( positioningModified && parent )
503  parent->ClearFieldsAutoplaced();
504 }
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:252
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:50
bool IsBold() const
Definition: eda_text.h:190
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:103
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Definition: kiway_player.h:64
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false)
Mark an item for refresh.
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_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:206
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.
SCINTILLA_TRICKS * m_scintillaTricks
This file is part of the common library.
void onScintillaCharAdded(wxStyledTextEvent &aEvent)
Add cut/copy/paste, autocomplete and brace highlighting to a wxStyleTextCtrl instance.
bool IsVisible() const
Definition: eda_text.h:193
void DoAutocomplete(const wxString &aPartial, const wxArrayString &aTokens)
void SetItalic(bool isItalic)
Definition: eda_text.h:186
Field object used in symbol libraries.
Definition: lib_field.h:59
void SetValue(const SCH_SHEET_PATH *sheet, const wxString &aValue)
Definition: sch_symbol.cpp:584
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:253
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:97
void GetContextualTextVars(wxArrayString *aVars) const
Return the list of system text vars & fields for this sheet.
Definition: sch_sheet.cpp:197
void SetVisible(bool aVisible)
Definition: eda_text.h:192
double GetTextAngle() const
Definition: eda_text.h:181
int GetId() const
Definition: sch_field.h:113
void UpdateField(SCH_FIELD *aField, SCH_SHEET_PATH *aSheetPath)
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:373
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:244
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:431
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:635
#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
DIALOG_EDIT_ONE_FIELD(SCH_BASE_FRAME *aParent, const wxString &aTitle, const EDA_TEXT *aTextItem)
name of datasheet
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
DIALOG_SCH_EDIT_ONE_FIELD(SCH_BASE_FRAME *aParent, const wxString &aTitle, const SCH_FIELD *aField)
bool IsItalic() const
Definition: eda_text.h:187
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:119
DIALOG_LIB_EDIT_ONE_FIELD(SCH_BASE_FRAME *aParent, const wxString &aTitle, const LIB_FIELD *aField)
void GetContextualTextVars(wxArrayString *aVars) const
Return the list of system text vars & fields for this symbol.
Definition: sch_symbol.cpp:918
A base class to edit schematic and symbol library fields.
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:205
static EDA_TEXT_HJUSTIFY_T MapHorizJustify(int aHorizJustify)
Definition: eda_text.cpp:63
Field Value of part, i.e. "3.3K".
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:114
wxString ConvertRefsToKIIDs(const wxString &aSource) const
Definition: schematic.cpp:247
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
Definition: eda_text.h:209
Definitions of control validators for schematic dialogs.
#define SHEETFILENAME_V
SCHEMATIC & Schematic() const
size_t GetCount() const
void ClearFieldsAutoplaced()
Definition: sch_item.h:436
Definition for symbol library class.
EDA_ITEM * GetParent() const
Definition: eda_item.h:115
#define _(s)
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
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:77
bool TransferDataToWindow() override
#define SHEETUSERFIELD_V
void updateText(EDA_TEXT *aText)
Class DIALOG_LIB_EDIT_TEXT_BASE.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:54
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:507
wxString ConvertKIIDsToRefs(const wxString &aSource) const
Definition: schematic.cpp:307
SCH_BASE_FRAME * GetParent()
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:248
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:208
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.
void OnTextValueSelectButtonClick(wxCommandEvent &aEvent) override
Handle the select button next to the text value field.
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:471
wxString GetName(bool aUseDefaultName=true) const
Return the field name.
Definition: sch_field.cpp:548
virtual long long int GetValue()
Return the current value in Internal Units.
bool TransferDataFromWindow() override
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
const wxPoint & GetTextPos() const
Definition: eda_text.h:254
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:51
virtual void SetTextAngle(double aAngle)
Definition: eda_text.h:174
A text control validator used for validating the text allowed in library and schematic symbol fields.
int GetUnit() const
Definition: sch_symbol.h:195
SCH_SHEET_PATH & CurrentSheet() const override
Definition: schematic.h:119
static bool IsReferenceStringValid(const wxString &aReferenceString)
Test for an acceptable reference string.
Definition: sch_symbol.cpp:465
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
void SetBold(bool aBold)
Definition: eda_text.h:189
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:197
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:133
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113
const LIB_ID & GetLibId() const
Definition: sch_symbol.h:147
Field Name Module PCB, i.e. "16DIP300".
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...