KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_sheet_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) 2009 Wayne Stambaugh <[email protected]>
5 * Copyright The KiCad Developers, see CHANGELOG.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
22
23#include <algorithm>
24
25#include <kiface_base.h>
26#include <wx/string.h>
27#include <wx/log.h>
28#include <wx/tooltip.h>
29#include <common.h>
30#include <confirm.h>
31#include <kidialog.h>
32#include <validators.h>
33#include <wx_filename.h>
36#include <kiplatform/ui.h>
37#include <sch_commit.h>
38#include <sch_edit_frame.h>
39#include <sch_io/sch_io.h>
40#include <sch_sheet.h>
41#include <schematic.h>
44#include <template_fieldnames.h>
45#include <bitmaps.h>
46#include <eeschema_settings.h>
48#include <widgets/wx_infobar.h>
49#include <trace_helpers.h>
51#include "wx/dcclient.h"
52#include "string_utils.h"
53
55 bool* aIsUndoable, bool* aClearAnnotationNewItems,
56 bool* aUpdateHierarchyNavigator,
57 wxString* aSourceSheetFilename ) :
59 m_frame( aParent ),
60 m_isUndoable( aIsUndoable ),
61 m_clearAnnotationNewItems( aClearAnnotationNewItems ),
62 m_updateHierarchyNavigator( aUpdateHierarchyNavigator ),
63 m_sourceSheetFilename( aSourceSheetFilename ),
65 m_dummySheet( *aSheet ),
67{
68 m_sheet = aSheet;
69 m_fields = new FIELDS_GRID_TABLE( this, aParent, m_grid, m_sheet );
72
73 m_grid->SetTable( m_fields );
74 m_grid->PushEventHandler( new FIELDS_GRID_TRICKS( m_grid, this, { &aParent->Schematic() },
75 [&]( wxCommandEvent& aEvent )
76 {
77 OnAddField( aEvent );
78 } ) );
79 m_grid->SetSelectionMode( wxGrid::wxGridSelectRows );
80 m_grid->ShowHideColumns( "0 1 2 3 4 5 6 7" );
81 m_shownColumns = m_grid->GetShownColumns();
82
83 if( m_frame->GetColorSettings()->GetOverrideSchItemColors() )
84 m_infoBar->ShowMessage( _( "Note: individual item colors overridden in Preferences." ) );
85
86 wxSize minSize = m_pageNumberTextCtrl->GetMinSize();
87 int minWidth = m_pageNumberTextCtrl->GetTextExtent( wxT( "XXX.XXX" ) ).GetWidth();
88
89 m_pageNumberTextCtrl->SetMinSize( wxSize( minWidth, minSize.GetHeight() ) );
90
91 wxToolTip::Enable( true );
93
94 // Configure button logos
99
100 // Set font sizes
102 m_hierarchicalPath->SetFont( KIUI::GetSmallInfoFont( this ) );
103
104 // wxFormBuilder doesn't include this event...
105 m_grid->Connect( wxEVT_GRID_CELL_CHANGING, wxGridEventHandler( DIALOG_SHEET_PROPERTIES::OnGridCellChanging ),
106 nullptr, this );
107
109}
110
111
113{
114 // Prevents crash bug in wxGrid's d'tor
115 m_grid->DestroyTable( m_fields );
116
117 m_grid->Disconnect( wxEVT_GRID_CELL_CHANGING, wxGridEventHandler( DIALOG_SHEET_PROPERTIES::OnGridCellChanging ),
118 nullptr, this );
119
120 // Delete the GRID_TRICKS.
121 m_grid->PopEventHandler( true );
122}
123
124
126{
127 if( !wxDialog::TransferDataToWindow() )
128 return false;
129
130 SCH_SHEET_PATH instance = m_frame->GetCurrentSheet();
131 wxString variantName = m_frame->Schematic().GetCurrentVariant();
132
133 std::vector<SCH_FIELD*> orderedFields;
134
135 for( SCH_FIELD& field : m_sheet->GetFields() )
136 orderedFields.push_back( &field );
137
138 std::stable_sort( orderedFields.begin(), orderedFields.end(),
139 []( const SCH_FIELD* lhs, const SCH_FIELD* rhs )
140 {
141 return lhs->GetOrdinal() < rhs->GetOrdinal();
142 } );
143
144 // Push a copy of each field into m_updateFields
145 for( SCH_FIELD* field : orderedFields )
146 {
147 SCH_FIELD field_copy( *field );
148
149#ifdef __WINDOWS__
150 // Filenames are stored using unix notation, so convert to Windows notation
151 if( field_copy.GetId() == FIELD_T::SHEET_FILENAME )
152 {
153 wxString filename = field_copy.GetText();
154 filename.Replace( wxT( "/" ), wxT( "\\" ) );
155 field_copy.SetText( filename );
156 }
157#endif
158
159 if( !field_copy.IsMandatory() )
160 field_copy.SetText( m_sheet->GetFieldText( field->GetName(), &instance, variantName ) );
161
162 // change offset to be symbol-relative
163 field_copy.Offset( -m_sheet->GetPosition() );
164
165 m_fields->push_back( field_copy );
166 }
167
168 // notify the grid
169 wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, m_fields->size() );
170 m_grid->ProcessTableMessage( msg );
171
172 // border width
173 m_borderWidth.SetValue( m_sheet->GetBorderWidth() );
174
175 // set up color swatches
176 KIGFX::COLOR4D borderColor = m_sheet->GetBorderColor();
177 KIGFX::COLOR4D backgroundColor = m_sheet->GetBackgroundColor();
178
179 m_borderSwatch->SetDefaultColor( COLOR4D::UNSPECIFIED );
180 m_backgroundSwatch->SetDefaultColor( COLOR4D::UNSPECIFIED );
181
182 m_borderSwatch->SetSwatchColor( borderColor, false );
183 m_backgroundSwatch->SetSwatchColor( backgroundColor, false );
184
185 KIGFX::COLOR4D canvas = m_frame->GetColorSettings()->GetColor( LAYER_SCHEMATIC_BACKGROUND );
186 m_borderSwatch->SetSwatchBackground( canvas );
187 m_backgroundSwatch->SetSwatchBackground( canvas );
188
189 m_cbExcludeFromSim->SetValue( m_sheet->GetExcludedFromSim( &instance, variantName ) );
190 m_cbExcludeFromBom->SetValue( m_sheet->GetExcludedFromBOM( &instance, variantName ) );
191 m_cbExcludeFromBoard->SetValue( m_sheet->GetExcludedFromBoard( &instance, variantName ) );
192 m_cbDNP->SetValue( m_sheet->GetDNP( &instance, variantName ) );
193
194 instance.push_back( m_sheet );
195 m_pageNumberTextCtrl->ChangeValue( instance.GetPageNumber() );
196
197 // Recalculate the dialog size now that the grid is populated and controls
198 // have their real values. On first run, the dialog was sized before data
199 // was available, so the minimum size may not account for the actual content.
200 m_grid->Layout();
201 Layout();
202 GetSizer()->SetSizeHints( this );
203
204 wxSize minSize = GetMinSize();
205 wxSize curSize = GetSize();
206
207 if( curSize.x < minSize.x || curSize.y < minSize.y )
208 SetSize( wxSize( std::max( curSize.x, minSize.x ), std::max( curSize.y, minSize.y ) ) );
209
210 return true;
211}
212
213
215{
216 if( !m_grid->CommitPendingChanges() || !m_grid->Validate() )
217 return false;
218
219 // Check for missing field names.
220 for( size_t i = 0; i < m_fields->size(); ++i )
221 {
222 SCH_FIELD& field = m_fields->at( i );
223
224 if( field.IsMandatory() )
225 continue;
226
227 if( field.GetName( false ).empty() && !field.GetText().empty() )
228 {
229 DisplayErrorMessage( this, _( "Fields must have a name." ) );
230
232 m_delayedFocusRow = (int) i;
233
234 return false;
235 }
236 }
237
238 return true;
239}
240
241
242static bool positioningChanged( const SCH_FIELD& a, const SCH_FIELD& b )
243{
244 if( a.GetPosition() != b.GetPosition() )
245 return true;
246
247 if( a.GetHorizJustify() != b.GetHorizJustify() )
248 return true;
249
250 if( a.GetVertJustify() != b.GetVertJustify() )
251 return true;
252
253 if( a.GetTextAngle() != b.GetTextAngle() )
254 return true;
255
256 return false;
257}
258
259
261{
263 return true;
264
266 return true;
267
268 return false;
269}
270
271
273{
274 wxCHECK( m_sheet && m_frame, false );
275
276 if( !wxDialog::TransferDataFromWindow() ) // Calls our Validate() method.
277 return false;
278
279 if( m_isUndoable )
280 *m_isUndoable = true;
281
282 // Sheet file names can be relative or absolute.
283 wxString sheetFileName = m_fields->GetField( FIELD_T::SHEET_FILENAME )->GetText();
284
285 // Ensure filepath is not empty. (In normal use will be caught by grid validators,
286 // but unedited data from existing files can be bad.)
287 if( sheetFileName.IsEmpty() )
288 {
289 DisplayError( this, _( "A sheet must have a valid file name." ) );
290 return false;
291 }
292
293 // Ensure the filename extension is OK. (In normal use will be caught by grid validators,
294 // but unedited data from existing files can be bad.)
295 sheetFileName = EnsureFileExtension( sheetFileName, FILEEXT::KiCadSchematicFileExtension );
296
297 // Ensure sheetFileName is legal
298 if( !IsFullFileNameValid( sheetFileName ) )
299 {
300 DisplayError( this, _( "A sheet must have a valid file name." ) );
301 return false;
302 }
303
304 wxFileName fn( sheetFileName );
305
306 wxString newRelativeFilename = fn.GetFullPath();
307
308 // Inside Eeschema, filenames are stored using unix notation
309 newRelativeFilename.Replace( wxT( "\\" ), wxT( "/" ) );
310
311 wxString oldFilename = m_sheet->GetField( FIELD_T::SHEET_FILENAME )->GetText();
312 oldFilename.Replace( wxT( "\\" ), wxT( "/" ) );
313
314 bool filename_changed = oldFilename != newRelativeFilename;
315
316 if( filename_changed || m_sheet->IsNew() )
317 {
318 SCH_SCREEN* currentScreen = m_frame->GetCurrentSheet().LastScreen();
319
320 wxCHECK( currentScreen, false );
321
322 bool clearFileName = false;
323
324 // This can happen for the root sheet when opening Eeschema in the stand alone mode.
325 if( currentScreen->GetFileName().IsEmpty() )
326 {
327 clearFileName = true;
328 currentScreen->SetFileName( m_frame->Prj().AbsolutePath( wxT( "noname.kicad_sch" ) ) );
329 }
330
331 wxFileName tmp( fn );
332 wxFileName screenFileName = currentScreen->GetFileName();
333
334 if( fn.IsAbsolute() && fn.MakeRelativeTo( screenFileName.GetPath() ) )
335 {
336 KICAD_MESSAGE_DIALOG makeRelDlg( this, _( "Use relative path for sheet file?" ),
337 _( "Sheet File Path" ),
338 wxYES_NO | wxYES_DEFAULT | wxICON_QUESTION | wxCENTER );
339
340 makeRelDlg.SetExtendedMessage( _( "Using relative hierarchical sheet file name paths improves "
341 "schematic portability across systems and platforms. Using "
342 "absolute paths can result in portability issues." ) );
343 makeRelDlg.SetYesNoLabels( KICAD_MESSAGE_DIALOG::ButtonLabel( _( "Use Relative Path" ) ),
344 KICAD_MESSAGE_DIALOG::ButtonLabel( _( "Use Absolute Path" ) ) );
345
346 if( makeRelDlg.ShowModal() == wxID_YES )
347 {
348 wxLogTrace( tracePathsAndFiles, "\n Converted absolute path: '%s'"
349 "\n to relative path: '%s'",
350 tmp.GetPath(),
351 fn.GetPath() );
352 m_fields->GetField( FIELD_T::SHEET_FILENAME )->SetText( fn.GetFullPath() );
353 newRelativeFilename = fn.GetFullPath();
354 }
355 }
356
357 if( !onSheetFilenameChanged( newRelativeFilename ) )
358 {
359 if( clearFileName )
360 currentScreen->SetFileName( wxEmptyString );
361 else
363
364 return false;
365 }
367 {
369 }
370
371 if( clearFileName )
372 currentScreen->SetFileName( wxEmptyString );
373
374 // One last validity check (and potential repair) just to be sure to be sure
375 SCH_SHEET_LIST repairedList;
376 repairedList.BuildSheetList( &m_frame->Schematic().Root(), true );
377 }
378
379 wxString newSheetname = m_fields->GetField( FIELD_T::SHEET_NAME )->GetText();
380
381 if( ( newSheetname != m_sheet->GetName() ) && m_updateHierarchyNavigator )
383
384 if( newSheetname.IsEmpty() )
385 newSheetname = _( "Untitled Sheet" );
386
387 m_fields->GetField( FIELD_T::SHEET_NAME )->SetText( newSheetname );
388
389 // Net names embed the sheet path, so retarget netclass/color assignments on a rename.
390 SCH_SHEET_PATH renamedPath = m_frame->GetCurrentSheet();
391 renamedPath.push_back( m_sheet );
392 wxString oldNetPrefix = renamedPath.PathHumanReadable( true, false, true );
393
394 m_sheet->SetName( newSheetname );
395 m_sheet->SetFileName( newRelativeFilename );
396
397 wxString newNetPrefix = renamedPath.PathHumanReadable( true, false, true );
398
399 if( oldNetPrefix != newNetPrefix )
400 m_frame->Prj().GetProjectFile().NetSettings()->RenameNetPathPrefix( oldNetPrefix, newNetPrefix );
401
402 // change all field positions from relative to absolute
403 for( SCH_FIELD& m_field : *m_fields)
404 m_field.Offset( m_sheet->GetPosition() );
405
407 m_sheet->SetFieldsAutoplaced( AUTOPLACE_NONE );
408
409 SCH_SHEET_PATH instance = m_frame->GetCurrentSheet();
410 wxString variantName = m_frame->Schematic().GetCurrentVariant();
411
412 int ordinal = 42; // Arbitrarily larger than any mandatory FIELD_T ids.
413
414 for( SCH_FIELD& field : *m_fields )
415 {
416 const wxString& fieldName = field.GetUntranslatedName();
417
418 if( field.IsEmpty() )
419 continue;
420 else if( fieldName.IsEmpty() )
421 field.SetName( _( "untitled" ) );
422
423 if( !field.IsMandatory() )
424 field.SetOrdinal( ordinal++, FIELD_T::SHEET_USER );
425
426 SCH_FIELD* existingField = m_sheet->GetField( fieldName );
427 SCH_FIELD* tmp;
428
429 if( !existingField )
430 {
431 tmp = m_sheet->AddField( field );
432 tmp->SetParent( m_sheet );
433 }
434 else
435 {
436 wxString defaultText = m_sheet->Schematic()->ConvertRefsToKIIDs( existingField->GetText() );
437 tmp = const_cast<SCH_FIELD*>( existingField );
438
439 *tmp = field;
440
441 if( !variantName.IsEmpty() )
442 {
443 // Restore the default field text for existing fields.
444 tmp->SetText( defaultText, &instance );
445
446 wxString variantText = m_sheet->Schematic()->ConvertRefsToKIIDs( field.GetText() );
447 tmp->SetText( variantText, &instance, variantName );
448 }
449 }
450 }
451
452 for( int ii = (int) m_sheet->GetFields().size() - 1; ii >= 0; ii-- )
453 {
454 SCH_FIELD& sheetField = m_sheet->GetFields()[ii];
455
456 if( sheetField.IsMandatory() )
457 continue;
458
459 bool found = false;
460
461 for( const SCH_FIELD& editedField : *m_fields )
462 {
463 if( editedField.GetName() == sheetField.GetName() )
464 {
465 found = true;
466 break;
467 }
468 }
469
470 if( !found )
471 m_sheet->GetFields().erase( m_sheet->GetFields().begin() + ii );
472 }
473
474 std::stable_sort( m_sheet->GetFields().begin(), m_sheet->GetFields().end(),
475 []( const SCH_FIELD& lhs, const SCH_FIELD& rhs )
476 {
477 return lhs.GetOrdinal() < rhs.GetOrdinal();
478 } );
479
480 m_sheet->SetBorderWidth( m_borderWidth.GetIntValue() );
481
482 COLOR_SETTINGS* colorSettings = m_frame->GetColorSettings();
483
484 if( colorSettings->GetOverrideSchItemColors()
485 && ( m_sheet->GetBorderColor() != m_borderSwatch->GetSwatchColor() ||
486 m_sheet->GetBackgroundColor() != m_backgroundSwatch->GetSwatchColor() ) )
487 {
488 wxPanel temp( this );
489 temp.Hide();
490 PANEL_EESCHEMA_COLOR_SETTINGS prefs( &temp );
491 wxString checkboxLabel = prefs.m_optOverrideColors->GetLabel();
492
493 KIDIALOG dlg( this, _( "Note: item colors are overridden in the current color theme." ),
495 dlg.ShowDetailedText( wxString::Format( _( "To see individual item colors uncheck '%s'\n"
496 "in Preferences > Schematic Editor > Colors." ),
497 checkboxLabel ) );
498 dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
499 dlg.ShowModal();
500 }
501
502 m_sheet->SetBorderColor( m_borderSwatch->GetSwatchColor() );
503 m_sheet->SetBackgroundColor( m_backgroundSwatch->GetSwatchColor() );
504
505 m_sheet->SetExcludedFromSim( m_cbExcludeFromSim->GetValue(), &instance, variantName );
506 m_sheet->SetExcludedFromBOM( m_cbExcludeFromBom->GetValue(), &instance, variantName );
507 m_sheet->SetExcludedFromBoard( m_cbExcludeFromBoard->GetValue() );
508 m_sheet->SetDNP( m_cbDNP->GetValue(), &instance, variantName );
509
510 instance.push_back( m_sheet );
511
512 instance.SetPageNumber( m_pageNumberTextCtrl->GetValue() );
513
514 m_frame->TestDanglingEnds();
515
516 // Refresh all sheets in case ordering changed.
517 for( SCH_ITEM* item : m_frame->GetScreen()->Items().OfType( SCH_SHEET_T ) )
518 m_frame->UpdateItem( item );
519
520 return true;
521}
522
523
524bool DIALOG_SHEET_PROPERTIES::onSheetFilenameChanged( const wxString& aNewFilename )
525{
526 return m_frame->ChangeSheetFile( m_sheet, aNewFilename, m_clearAnnotationNewItems, m_isUndoable,
528}
529
530
532{
533 bool success = true;
534 wxGridCellEditor* editor = m_grid->GetCellEditor( event.GetRow(), event.GetCol() );
535 wxControl* control = editor->GetControl();
536
537 if( control && control->GetValidator() )
538 success = control->GetValidator()->Validate( control );
539
540 if( !success )
541 {
542 event.Veto();
543 m_delayedFocusRow = event.GetRow();
544 m_delayedFocusColumn = event.GetCol();
545 }
546 else if( event.GetCol() == FDC_NAME )
547 {
548 wxString newName = event.GetString();
549
550 for( int i = 0; i < m_grid->GetNumberRows(); ++i )
551 {
552 if( i == event.GetRow() )
553 continue;
554
555 if( FieldNamesAreDuplicates( newName, m_grid->GetCellValue( i, FDC_NAME ),
557 {
558 DisplayError( this, wxString::Format( _( "Field name '%s' already in use." ), newName ) );
559 event.Veto();
560 m_delayedFocusRow = event.GetRow();
561 m_delayedFocusColumn = event.GetCol();
562 break;
563 }
564 }
565 }
566
567 editor->DecRef();
568}
569
570
571void DIALOG_SHEET_PROPERTIES::OnAddField( wxCommandEvent& event )
572{
573 m_grid->OnAddRow(
574 [&]() -> std::pair<int, int>
575 {
577
578 newField.SetTextAngle( m_fields->GetField( FIELD_T::SHEET_NAME )->GetTextAngle() );
579 newField.SetVisible( false );
580 m_fields->push_back( newField );
581
582 // notify the grid
583 wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
584 m_grid->ProcessTableMessage( msg );
585 return { m_fields->size() - 1, FDC_NAME };
586 } );
587}
588
589
590void DIALOG_SHEET_PROPERTIES::OnDeleteField( wxCommandEvent& event )
591{
592 m_grid->OnDeleteRows(
593 [&]( int row )
594 {
595 if( row < m_fields->GetMandatoryRowCount() )
596 {
597 DisplayError( this, wxString::Format( _( "The first %d fields are mandatory." ),
598 m_fields->GetMandatoryRowCount() ) );
599 return false;
600 }
601
602 return true;
603 },
604 [&]( int row )
605 {
606 m_fields->erase( m_fields->begin() + row );
607
608 // notify the grid
609 wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, row, 1 );
610 m_grid->ProcessTableMessage( msg );
611 } );
612}
613
614
615void DIALOG_SHEET_PROPERTIES::OnMoveUp( wxCommandEvent& event )
616{
617 m_grid->OnMoveRowUp(
618 [&]( int row )
619 {
620 return row > m_fields->GetMandatoryRowCount();
621 },
622 [&]( int row )
623 {
624 std::swap( *( m_fields->begin() + row ), *( m_fields->begin() + row - 1 ) );
625 m_grid->ForceRefresh();
626 } );
627}
628
629
630void DIALOG_SHEET_PROPERTIES::OnMoveDown( wxCommandEvent& event )
631{
632 m_grid->OnMoveRowUp(
633 [&]( int row )
634 {
635 return row >= m_fields->GetMandatoryRowCount();
636 },
637 [&]( int row )
638 {
639 std::swap( *( m_fields->begin() + row ), *( m_fields->begin() + row + 1 ) );
640 m_grid->ForceRefresh();
641 } );
642}
643
644
645void DIALOG_SHEET_PROPERTIES::OnUpdateUI( wxUpdateUIEvent& event )
646{
647 std::bitset<64> shownColumns = m_grid->GetShownColumns();
648
649 if( shownColumns != m_shownColumns )
650 {
651 m_shownColumns = shownColumns;
652
653 if( !m_grid->IsCellEditControlShown() )
654 m_grid->SetGridWidthsDirty();
655 }
656
657 // Propagate changes in sheetname to displayed hierarchical path
658 int sheetnameRow = m_fields->GetFieldRow( FIELD_T::SHEET_NAME );
659 wxString path = m_frame->GetCurrentSheet().PathHumanReadable( false );
660
661 if( path.Last() != '/' )
662 path.Append( '/' );
663
664 wxGridCellEditor* editor = m_grid->GetCellEditor( sheetnameRow, FDC_VALUE );
665 wxControl* control = editor->GetControl();
666 wxTextEntry* textControl = dynamic_cast<wxTextEntry*>( control );
667 wxString sheetName;
668
669 if( textControl )
670 sheetName = textControl->GetValue();
671 else
672 sheetName = m_grid->GetCellValue( sheetnameRow, FDC_VALUE );
673
674 m_dummySheet.SetFields( *m_fields );
675 m_dummySheetNameField.SetText( sheetName );
676 path += m_dummySheetNameField.GetShownText( FOR_GUI );
677
678 editor->DecRef();
679
680 wxClientDC dc( m_hierarchicalPathLabel );
681 int width = m_sizerBottom->GetSize().x - m_stdDialogButtonSizer->GetSize().x
682 - m_hierarchicalPathLabel->GetSize().x
683 - 30;
684
685 path = wxControl::Ellipsize( path, dc, wxELLIPSIZE_START, width, wxELLIPSIZE_FLAGS_NONE );
686
687 if( m_hierarchicalPath->GetLabel() != path )
688 m_hierarchicalPath->SetLabel( path );
689
690 // Handle a delayed focus
691 if( m_delayedFocusRow >= 0 )
692 {
693 m_grid->SetFocus();
694 m_grid->MakeCellVisible( m_delayedFocusRow, m_delayedFocusColumn );
696
697 m_grid->EnableCellEditControl( true );
698 m_grid->ShowCellEditControl();
699
702 }
703}
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
Definition bitmap.cpp:106
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
Definition color4d.h:399
Color settings are a bit different than most of the settings objects in that there can be more than o...
bool GetOverrideSchItemColors() const
wxStdDialogButtonSizer * m_stdDialogButtonSizer
DIALOG_SHEET_PROPERTIES_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Sheet Properties"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU)
void OnAddField(wxCommandEvent &event) override
void OnMoveDown(wxCommandEvent &event) override
void OnGridCellChanging(wxGridEvent &event)
void OnDeleteField(wxCommandEvent &event) override
bool onSheetFilenameChanged(const wxString &aNewFilename)
void OnUpdateUI(wxUpdateUIEvent &event) override
void OnMoveUp(wxCommandEvent &event) override
DIALOG_SHEET_PROPERTIES(SCH_EDIT_FRAME *aParent, SCH_SHEET *aSheet, bool *aIsUndoable, bool *aClearAnnotationNewItems, bool *aUpdateHierarchyNavigator, wxString *aSourceSheetFilename)
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...
virtual void SetParent(EDA_ITEM *aParent)
Definition eda_item.cpp:153
virtual void Offset(const VECTOR2I &aOffset)
Definition eda_text.cpp:558
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition eda_text.h:239
virtual void SetVisible(bool aVisible)
Definition eda_text.cpp:342
virtual EDA_ANGLE GetTextAngle() const
Definition eda_text.h:178
GR_TEXT_V_ALIGN_T GetVertJustify() const
Definition eda_text.h:242
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition eda_text.cpp:263
SCH_FIELD * GetField(FIELD_T aFieldId)
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
Definition kidialog.h:38
@ KD_WARNING
Definition kidialog.h:43
void DoNotShowCheckbox(wxString file, int line)
Shows the 'do not show again' checkbox.
Definition kidialog.cpp:51
int ShowModal() override
Definition kidialog.cpp:89
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
Schematic editor (Eeschema) main window.
SCHEMATIC & Schematic() const
bool IsMandatory() const
VECTOR2I GetPosition() const override
virtual const wxString & GetText() const override
Return the string associated with the text object.
Definition sch_field.h:138
FIELD_T GetId() const
Definition sch_field.h:142
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
void SetText(const wxString &aText) override
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:165
const wxString & GetFileName() const
Definition sch_screen.h:153
void SetFileName(const wxString &aFileName)
Set the file name for this screen to aFileName.
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
void BuildSheetList(SCH_SHEET *aSheet, bool aCheckIntegrity)
Build the list of sheets and their sheet path from aSheet.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
wxString GetPageNumber() const
wxString PathHumanReadable(bool aUseShortRootName=true, bool aStripTrailingSeparator=false, bool aEscapeSheetNames=false) const
Return the sheet path in a human readable form made from the sheet names.
void SetPageNumber(const wxString &aPageNumber)
Set the sheet instance user definable page number.
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition sch_sheet.h:48
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this sheet.
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:848
@ FOR_GUI
Definition common.h:89
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition confirm.cpp:217
void DisplayError(wxWindow *aParent, const wxString &aText)
Display an error or warning message box with aMessage.
Definition confirm.cpp:192
This file is part of the common library.
#define KICAD_MESSAGE_DIALOG
Definition confirm.h:48
static bool positioningChanged(const SCH_FIELD &a, const SCH_FIELD &b)
static bool positioningChanged(const SCH_FIELD &a, const SCH_FIELD &b)
const int minSize
Push and Shove router track width and via size dialog.
#define _(s)
@ FDC_NAME
@ FDC_VALUE
static const std::string KiCadSchematicFileExtension
const wxChar *const tracePathsAndFiles
Flag to enable path and file name debug output.
@ LAYER_SCHEMATIC_BACKGROUND
Definition layer_ids.h:510
KICOMMON_API wxFont GetSmallInfoFont(wxWindow *aWindow)
const SCH_FIELD * FindField(const std::vector< SCH_FIELD > &aFields, FIELD_T aFieldId)
Definition sch_field.h:393
@ AUTOPLACE_NONE
Definition sch_item.h:69
bool IsFullFileNameValid(const wxString &aFullFilename)
Checks if a full filename is valid, i.e.
bool FieldNamesAreDuplicates(const wxString &aLhs, const wxString &aRhs, std::initializer_list< FIELD_T > aMandatoryFields)
Test whether two field names should be treated as duplicates for the purposes of field name uniquenes...
wxString GetUserFieldName(int aFieldNdx, TRANSLATION aTranslation)
FIELD_T
The set of all field indices assuming an array like sequence that a SCH_COMPONENT or LIB_PART can hol...
@ TRANSLATED
#define SHEET_MANDATORY_FIELDS
std::string path
wxLogTrace helper definitions.
@ SCH_SHEET_T
Definition typeinfo.h:171
Custom text control validator definitions.
Definition of file extensions used in Kicad.