KiCad PCB EDA Suite
dialog_label_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) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright (C) 2013 Wayne Stambaugh <[email protected]>
6 * Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.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
27#include <widgets/font_choice.h>
30#include <sch_edit_frame.h>
31#include <sch_validators.h>
32#include <tool/tool_manager.h>
33#include <gr_text.h>
34#include <confirm.h>
35#include <schematic.h>
38#include <string_utils.h>
41#include <kiface_base.h>
42#include <sch_label.h>
43
44
47 m_Parent( aParent ),
48 m_currentLabel( aLabel ),
49 m_activeTextEntry( nullptr ),
50 m_netNameValidator( true ),
51 m_fields( nullptr ),
52 m_textSize( aParent, m_textSizeLabel, m_textSizeCtrl, m_textSizeUnits, false ),
53 m_helpWindow( nullptr )
54{
55 COLOR_SETTINGS* colorSettings = m_Parent->GetColorSettings();
56 COLOR4D schematicBackground = colorSettings->GetColor( LAYER_SCHEMATIC_BACKGROUND );
57
59 m_width = 100; // Will be later set to a better value
62
64 {
67
68 m_labelSingleLine->Show( false );
69 m_valueSingleLine->Show( false );
70
71 m_valueCombo->SetValidator( m_netNameValidator );
72 }
73 else if( m_currentLabel->Type() == SCH_HIER_LABEL_T )
74 {
77
78 m_labelCombo->Show( false );
79 m_valueCombo->Show( false );
80
82 }
84 {
87
88 m_labelSingleLine->Show( false );
89 m_valueSingleLine->Show( false );
90 m_labelCombo->Show( false );
91 m_valueCombo->Show( false );
92 m_syntaxHelp->Show( false );
93
94 m_textSizeLabel->SetLabel( _( "Pin length:" ) );
95 }
96
97 switch( m_currentLabel->Type() )
98 {
99 case SCH_GLOBAL_LABEL_T: SetTitle( _( "Global Label Properties" ) ); break;
100 case SCH_HIER_LABEL_T: SetTitle( _( "Hierarchical Label Properties" ) ); break;
101 case SCH_LABEL_T: SetTitle( _( "Label Properties" ) ); break;
102 case SCH_DIRECTIVE_LABEL_T: SetTitle( _( "Directive Label Properties" ) ); break;
103 case SCH_SHEET_PIN_T: SetTitle( _( "Hierarchical Sheet Pin Properties" ) ); break;
104 default: UNIMPLEMENTED_FOR( m_currentLabel->GetClass() ); break;
105 }
106
107 // Give a bit more room for combobox editors
108 m_grid->SetDefaultRowSize( m_grid->GetDefaultRowSize() + 4 );
109
111 m_grid->PushEventHandler( new FIELDS_GRID_TRICKS( m_grid, this ) );
112 m_grid->SetSelectionMode( wxGrid::wxGridSelectRows );
113
114 // Show/hide columns according to user's preference
115 auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
116 wxASSERT( cfg );
117
118 if( cfg )
119 {
120 m_shownColumns = cfg->m_Appearance.edit_label_visible_columns;
122 }
123
124 // Configure button logos
125 m_bpAdd->SetBitmap( KiBitmap( BITMAPS::small_plus ) );
127 m_bpMoveUp->SetBitmap( KiBitmap( BITMAPS::small_up ) );
129
131
136
138
143
145
146 m_textColorSwatch->SetDefaultColor( COLOR4D::UNSPECIFIED );
147 m_textColorSwatch->SetSwatchBackground( schematicBackground );
148
149 // Show/hide relevant controls
151 {
152 m_dot->Hide();
153 m_circle->Hide();
154 m_diamond->Hide();
155 m_rectangle->Hide();
156
161 }
163 {
164 m_input->Hide();
165 m_output->Hide();
166 m_bidirectional->Hide();
167 m_triState->Hide();
168 m_passive->Hide();
169
170 m_fontLabel->SetLabel( _( "Orientation:" ) );
171 m_fontCtrl->Hide();
172 m_separator1->Hide();
173 m_bold->Hide();
174 m_italic->Hide();
175 m_separator2->Hide();
180 m_separator3->Hide();
181
182 m_formattingGB->Detach( m_fontCtrl );
183 m_formattingGB->Detach( m_iconBar );
184 m_formattingGB->Add( m_iconBar, wxGBPosition( 0, 1 ), wxGBSpan( 1, 1 ), wxEXPAND|wxRIGHT, 5 );
185 }
186 else
187 {
188 m_shapeSizer->Show( false );
189
194 }
195
197 {
198 m_autoRotate->Hide();
199 wxSizer* parentSizer = m_autoRotate->GetContainingSizer();
200 parentSizer->Detach( m_autoRotate );
201 parentSizer->Layout();
202 }
203
205
206 // DIALOG_SHIM needs a unique hash_key because classname is not sufficient because the
207 // various versions have different controls so we want to store sizes for each version.
208 m_hash_key = TO_UTF8( GetTitle() );
209
210 m_spin0->Bind( wxEVT_BUTTON, &DIALOG_LABEL_PROPERTIES::onSpinButton, this );
211 m_spin1->Bind( wxEVT_BUTTON, &DIALOG_LABEL_PROPERTIES::onSpinButton, this );
212 m_spin2->Bind( wxEVT_BUTTON, &DIALOG_LABEL_PROPERTIES::onSpinButton, this );
213 m_spin3->Bind( wxEVT_BUTTON, &DIALOG_LABEL_PROPERTIES::onSpinButton, this );
214
215 // Now all widgets have the size fixed, call FinishDialogSettings
217}
218
219
221{
222 EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
223 wxASSERT( cfg );
224
225 if( cfg )
227
228 // Prevents crash bug in wxGrid's d'tor
230
231 // Delete the GRID_TRICKS.
232 m_grid->PopEventHandler( true );
233
234 if( m_helpWindow )
235 m_helpWindow->Destroy();
236}
237
238
240{
241 if( !wxDialog::TransferDataToWindow() )
242 return false;
243
245 {
246 // show control characters in a human-readable format
247 wxString text = UnescapeString( m_currentLabel->GetText() );
248
249 // show text variable cross-references in a human-readable format
251
252 m_activeTextEntry->SetValue( text );
253 }
254
256 {
257 // Load the combobox with the existing labels of the same type
258 std::set<wxString> existingLabels;
259 std::vector<std::shared_ptr<BUS_ALIAS>> busAliases;
260 SCH_SCREENS allScreens( m_Parent->Schematic().Root() );
261
262 for( SCH_SCREEN* screen = allScreens.GetFirst(); screen; screen = allScreens.GetNext() )
263 {
264 for( SCH_ITEM* item : screen->Items().OfType( m_currentLabel->Type() ) )
265 {
266 const SCH_LABEL_BASE* label = static_cast<const SCH_LABEL_BASE*>( item );
267 existingLabels.insert( UnescapeString( label->GetText() ) );
268 }
269
270 std::set<std::shared_ptr<BUS_ALIAS>> sheetAliases = screen->GetBusAliases();
271 busAliases.insert( busAliases.end(), sheetAliases.begin(), sheetAliases.end() );
272 }
273
274 // Add bus aliases to label list
275 for( const std::shared_ptr<BUS_ALIAS>& busAlias : busAliases )
276 existingLabels.insert( wxT( "{" ) + busAlias->GetName() + wxT( "}" ) );
277
278 wxArrayString existingLabelArray;
279
280 for( const wxString& label : existingLabels )
281 existingLabelArray.push_back( label );
282
283 m_valueCombo->Append( existingLabelArray );
284 }
285
286 // Push a copy of each field into m_updateFields
287 for( SCH_FIELD& field : m_currentLabel->GetFields() )
288 {
289 SCH_FIELD field_copy( field );
290
291 // change offset to be symbol-relative
292 field_copy.Offset( -m_currentLabel->GetPosition() );
293
294 m_fields->push_back( field_copy );
295 }
296
297 // notify the grid
298 wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, m_fields->size() );
299 m_grid->ProcessTableMessage( msg );
300 AdjustGridColumns( m_grid->GetRect().GetWidth() );
301
302 if( m_shapeSizer->AreAnyItemsShown() )
303 {
304 switch( m_currentLabel->GetShape() )
305 {
306 case LABEL_FLAG_SHAPE::L_INPUT: m_input->SetValue( true ); break;
307 case LABEL_FLAG_SHAPE::L_OUTPUT: m_output->SetValue( true ); break;
308 case LABEL_FLAG_SHAPE::L_BIDI: m_bidirectional->SetValue( true ); break;
309 case LABEL_FLAG_SHAPE::L_TRISTATE: m_triState->SetValue( true ); break;
310 case LABEL_FLAG_SHAPE::L_UNSPECIFIED: m_passive->SetValue( true ); break;
311 case LABEL_FLAG_SHAPE::F_DOT: m_dot->SetValue( true ); break;
312 case LABEL_FLAG_SHAPE::F_ROUND: m_circle->SetValue( true ); break;
313 case LABEL_FLAG_SHAPE::F_DIAMOND: m_diamond->SetValue( true ); break;
314 case LABEL_FLAG_SHAPE::F_RECTANGLE: m_rectangle->SetValue( true ); break;
315 }
316 }
317
319
321 m_textSize.SetValue( static_cast<SCH_DIRECTIVE_LABEL*>( m_currentLabel )->GetPinLength() );
322 else
324
328
330 {
331 case TEXT_SPIN_STYLE::RIGHT: m_spin0->Check( true ); break;
332 case TEXT_SPIN_STYLE::LEFT: m_spin1->Check( true ); break;
333 case TEXT_SPIN_STYLE::UP: m_spin2->Check( true ); break;
334 case TEXT_SPIN_STYLE::BOTTOM: m_spin3->Check( true ); break;
335 }
336
339
340 return true;
341}
342
343
347void DIALOG_LABEL_PROPERTIES::OnEnterKey( wxCommandEvent& aEvent )
348{
349 wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
350}
351
352
354{
355 if( aEvent.GetKeyCode() == WXK_TAB )
356 {
357 if( aEvent.ShiftDown() )
358 {
359 m_textSizeCtrl->SetFocusFromKbd();
360 }
361 else if( !m_fields->empty() )
362 {
363 m_grid->SetFocusFromKbd();
364 m_grid->MakeCellVisible( 0, 0 );
365 m_grid->SetGridCursor( 0, 0 );
366 }
367 else
368 {
369 m_textSizeCtrl->SetFocusFromKbd();
370 }
371 }
372 else
373 {
374 aEvent.Skip();
375 }
376}
377
378
379static bool positioningChanged( const SCH_FIELD& a, const SCH_FIELD& b )
380{
381 return a.GetPosition() != b.GetPosition()
382 || a.GetHorizJustify() != b.GetHorizJustify()
383 || a.GetVertJustify() != b.GetVertJustify()
384 || a.GetTextAngle() != b.GetTextAngle();
385}
386
387
388static bool positioningChanged( FIELDS_GRID_TABLE<SCH_FIELD>* a, std::vector<SCH_FIELD>& b )
389{
390 for( size_t i = 0; i < a->size() && i < b.size(); ++i )
391 {
392 if( positioningChanged( a->at( i ), b.at( i ) ) )
393 return true;
394 }
395
396 return false;
397}
398
399
401{
403 return false;
404
405 if( !wxDialog::TransferDataFromWindow() )
406 return false;
407
408 // Don't allow text to disappear; it can be difficult to correct if you can't select it
409 if( !m_textSize.Validate( 0.01, 1000.0, EDA_UNITS::MILLIMETRES ) )
410 return false;
411
412 wxString text;
413
414 /* save old text in undo list if not already in edit */
415 if( m_currentLabel->GetEditFlags() == 0 )
416 {
418 false );
419 }
420
422
424 {
425 // labels need escaping
427
428 // convert any text variable cross-references to their UUIDs
430
431#ifdef __WXMAC__
432 // On macOS CTRL+Enter produces '\r' instead of '\n' regardless of EOL setting
433 text.Replace( "\r", "\n" );
434#endif
435
436 if( text.IsEmpty() && !m_currentLabel->IsNew() )
437 {
438 DisplayError( this, _( "Label can not be empty." ) );
439 return false;
440 }
441
443 }
444
445 bool doAutoplace = false;
446
447 // change all field positions from relative to absolute
448 for( SCH_FIELD& field : *m_fields )
449 {
450 field.Offset( m_currentLabel->GetPosition() );
451
452 if( field.GetCanonicalName() == wxT( "Netclass" ) )
453 {
454 field.SetLayer( LAYER_NETCLASS_REFS );
455 }
456 else if( field.GetCanonicalName() == wxT( "Intersheetrefs" ) )
457 {
458 if( field.IsVisible() != m_Parent->Schematic().Settings().m_IntersheetRefsShow )
459 {
460 DisplayInfoMessage( this, _( "Intersheet reference visibility is "
461 "controlled globally from "
462 "Schematic Setup > General > Formatting" ) );
463 }
464
465 field.SetLayer( LAYER_INTERSHEET_REFS );
466 }
467 else
468 {
469 field.SetLayer( LAYER_FIELDS );
470 }
471 }
472
475 else
476 doAutoplace = true;
477
479
480 if( m_shapeSizer->AreAnyItemsShown() )
481 {
482 if( m_input->GetValue() )
484 else if( m_output->GetValue() )
486 else if( m_bidirectional->GetValue() )
488 else if( m_triState->GetValue() )
490 else if( m_passive->GetValue() )
492 else if( m_dot->GetValue() )
494 else if( m_circle->GetValue() )
496 else if( m_diamond->GetValue() )
498 else if( m_rectangle->GetValue() )
500 }
501
503 {
505 m_italic->IsChecked() ) );
506 }
507
509 static_cast<SCH_DIRECTIVE_LABEL*>( m_currentLabel )->SetPinLength( m_textSize.GetValue() );
512
514 {
515 if( m_bold->IsChecked() )
516 {
517 m_currentLabel->SetBold( true );
519 }
520 else
521 {
522 m_currentLabel->SetBold( false );
523 m_currentLabel->SetTextThickness( 0 ); // Use default pen width
524 }
525 }
526
528
530
531 TEXT_SPIN_STYLE selectedSpinStyle= TEXT_SPIN_STYLE::LEFT;
532
533 if( m_spin0->IsChecked() )
534 selectedSpinStyle = TEXT_SPIN_STYLE::RIGHT;
535 else if( m_spin1->IsChecked() )
536 selectedSpinStyle = TEXT_SPIN_STYLE::LEFT;
537 else if( m_spin2->IsChecked() )
538 selectedSpinStyle = TEXT_SPIN_STYLE::UP;
539 else if( m_spin3->IsChecked() )
540 selectedSpinStyle = TEXT_SPIN_STYLE::BOTTOM;
541
544 else
546
547 if( m_currentLabel->GetTextSpinStyle() != selectedSpinStyle )
548 m_currentLabel->SetTextSpinStyle( selectedSpinStyle );
549
550 if( doAutoplace )
552
556
557 return true;
558}
559
560
561void DIALOG_LABEL_PROPERTIES::onSpinButton( wxCommandEvent& aEvent )
562{
563 for( BITMAP_BUTTON* btn : { m_spin0, m_spin1, m_spin2, m_spin3 } )
564 {
565 if( btn->IsChecked() && btn != aEvent.GetEventObject() )
566 btn->Check( false );
567 }
568}
569
570
571void DIALOG_LABEL_PROPERTIES::OnFormattingHelp( wxHyperlinkEvent& aEvent )
572{
574}
575
576
577void DIALOG_LABEL_PROPERTIES::OnAddField( wxCommandEvent& event )
578{
580 return;
581
582 int fieldID = m_fields->size();
583 wxString fieldName;
584
585 if( (int) fieldID == m_currentLabel->GetMandatoryFieldCount()
586 || m_fields->at( m_fields->size()-1 ).GetCanonicalName() == wxT( "Netclass" ) )
587 {
588 fieldName = wxT( "Netclass" );
589 }
590 else
591 {
592 fieldName = SCH_LABEL_BASE::GetDefaultFieldName( fieldName, true );
593 }
594
595 SCH_FIELD newField( wxPoint( 0, 0 ), fieldID, m_currentLabel, fieldName );
596
597 if( m_fields->size() > 0 )
598 {
599 newField.SetVisible( m_fields->at( m_fields->size() - 1 ).IsVisible() );
600 newField.SetTextAngle( m_fields->at( m_fields->size() - 1 ).GetTextAngle() );
601 newField.SetItalic( m_fields->at( m_fields->size() - 1 ).IsItalic() );
602 newField.SetBold( m_fields->at( m_fields->size() - 1 ).IsBold() );
603 }
604 else
605 {
606 newField.SetVisible( true );
607 newField.SetItalic( true );
608 }
609
610 m_fields->push_back( newField );
611
612 // notify the grid
613 wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
614 m_grid->ProcessTableMessage( msg );
615
616 m_grid->MakeCellVisible( m_fields->size() - 1, 0 );
617 m_grid->SetGridCursor( m_fields->size() - 1, fieldName == wxT( "Netclass" ) ? 1 : 0 );
618
619 m_grid->EnableCellEditControl();
620 m_grid->ShowCellEditControl();
621}
622
623
624void DIALOG_LABEL_PROPERTIES::OnDeleteField( wxCommandEvent& event )
625{
626 wxArrayInt selectedRows = m_grid->GetSelectedRows();
627
628 if( selectedRows.empty() && m_grid->GetGridCursorRow() >= 0 )
629 selectedRows.push_back( m_grid->GetGridCursorRow() );
630
631 if( selectedRows.empty() )
632 return;
633
634 for( int row : selectedRows )
635 {
636 if( row < m_currentLabel->GetMandatoryFieldCount() )
637 {
638 DisplayError( this, _( "The first field is mandatory." ) );
639 return;
640 }
641 }
642
643 m_grid->CommitPendingChanges( true /* quiet mode */ );
644
645 // Reverse sort so deleting a row doesn't change the indexes of the other rows.
646 selectedRows.Sort( []( int* first, int* second ) { return *second - *first; } );
647
648 for( int row : selectedRows )
649 {
650 m_fields->erase( m_fields->begin() + row );
651
652 // notify the grid
653 wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, row, 1 );
654 m_grid->ProcessTableMessage( msg );
655
656 if( m_grid->GetNumberRows() > 0 )
657 {
658 m_grid->MakeCellVisible( std::max( 0, row-1 ), m_grid->GetGridCursorCol() );
659 m_grid->SetGridCursor( std::max( 0, row-1 ), m_grid->GetGridCursorCol() );
660 }
661 }
662}
663
664
665void DIALOG_LABEL_PROPERTIES::OnMoveUp( wxCommandEvent& event )
666{
668 return;
669
670 int i = m_grid->GetGridCursorRow();
671
673 {
674 SCH_FIELD tmp = m_fields->at( (unsigned) i );
675 m_fields->erase( m_fields->begin() + i, m_fields->begin() + i + 1 );
676 m_fields->insert( m_fields->begin() + i - 1, tmp );
677 m_grid->ForceRefresh();
678
679 m_grid->SetGridCursor( i - 1, m_grid->GetGridCursorCol() );
680 m_grid->MakeCellVisible( m_grid->GetGridCursorRow(), m_grid->GetGridCursorCol() );
681 }
682 else
683 {
684 wxBell();
685 }
686}
687
688
689void DIALOG_LABEL_PROPERTIES::OnMoveDown( wxCommandEvent& event )
690{
692 return;
693
694 int i = m_grid->GetGridCursorRow();
695
696 if( i >= m_currentLabel->GetMandatoryFieldCount() && i < m_grid->GetNumberRows() - 1 )
697 {
698 SCH_FIELD tmp = m_fields->at( (unsigned) i );
699 m_fields->erase( m_fields->begin() + i, m_fields->begin() + i + 1 );
700 m_fields->insert( m_fields->begin() + i + 1, tmp );
701 m_grid->ForceRefresh();
702
703 m_grid->SetGridCursor( i + 1, m_grid->GetGridCursorCol() );
704 m_grid->MakeCellVisible( m_grid->GetGridCursorRow(), m_grid->GetGridCursorCol() );
705 }
706 else
707 {
708 wxBell();
709 }
710}
711
712
714{
715 m_width = aWidth;
716 // Account for scroll bars
717 aWidth -= ( m_grid->GetSize().x - m_grid->GetClientSize().x );
718
719 m_grid->AutoSizeColumn( 0 );
720 m_grid->SetColSize( 0, std::max( m_grid->GetColSize( 0 ), 72 ) );
721
722 int fixedColsWidth = m_grid->GetColSize( 0 );
723
724 for( int i = 2; i < m_grid->GetNumberCols(); i++ )
725 fixedColsWidth += m_grid->GetColSize( i );
726
727 m_grid->SetColSize( 1, std::max( aWidth - fixedColsWidth, 120 ) );
728}
729
730
731void DIALOG_LABEL_PROPERTIES::OnUpdateUI( wxUpdateUIEvent& event )
732{
733 wxString shownColumns = m_grid->GetShownColumns();
734
735 if( shownColumns != m_shownColumns )
736 {
737 m_shownColumns = shownColumns;
738
739 if( !m_grid->IsCellEditControlShown() )
740 AdjustGridColumns( m_grid->GetRect().GetWidth() );
741 }
742
743 // Handle a delayed focus
744 if( m_delayedFocusRow >= 0 && m_delayedFocusRow < m_grid->GetNumberRows() )
745 {
746 m_grid->SetFocus();
747 m_grid->MakeCellVisible( m_delayedFocusRow, m_delayedFocusColumn );
749 }
750
753}
754
755
756void DIALOG_LABEL_PROPERTIES::OnSizeGrid( wxSizeEvent& event )
757{
758 int new_size = event.GetSize().GetX();
759
760 if( m_width != new_size )
761 AdjustGridColumns( new_size );
762
763 // Always propagate for a grid repaint (needed if the height changes, as well as width)
764 event.Skip();
765}
766
767
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
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
@ pinorient_up
@ text_align_right
@ label_align_bottom
@ text_align_left
@ text_align_top
@ label_align_right
@ label_align_top
@ pinorient_right
@ label_align_left
@ pinorient_down
@ text_align_bottom
@ pinorient_left
A bitmap button widget that behaves like an AUI toolbar item's button when it is drawn.
Definition: bitmap_button.h:41
void SetIsRadioButton()
bool IsChecked() const
void SetBitmap(const wxBitmap &aBmp)
Set the bitmap shown when the button is enabled.
void Check(bool aCheck=true)
Check the control.
void SetIsSeparator()
Render button as a toolbar separator.
void SetIsCheckButton()
Setup the control as a two-state button (checked or unchecked).
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
void SetSwatchColor(const KIGFX::COLOR4D &aColor, bool aSendEvent)
Set the current swatch color directly.
KIGFX::COLOR4D GetSwatchColor() const
void SetDefaultColor(const KIGFX::COLOR4D &aColor)
Sets the color that will be chosen with the "Reset to Default" button in the chooser.
void SetSwatchBackground(const KIGFX::COLOR4D &aBackground)
Set the swatch background color.
Class DIALOG_LABEL_PROPERTIES_BASE.
void OnSizeGrid(wxSizeEvent &event) override
void OnMoveUp(wxCommandEvent &event) override
void OnMoveDown(wxCommandEvent &event) override
void OnEnterKey(wxCommandEvent &aEvent) override
void OnAddField(wxCommandEvent &event) override
SCH_NETNAME_VALIDATOR m_netNameValidator
void OnFormattingHelp(wxHyperlinkEvent &aEvent) override
FIELDS_GRID_TABLE< SCH_FIELD > * m_fields
DIALOG_LABEL_PROPERTIES(SCH_EDIT_FRAME *parent, SCH_LABEL_BASE *aLabel)
void OnUpdateUI(wxUpdateUIEvent &event) override
void onSpinButton(wxCommandEvent &aEvent)
void OnDeleteField(wxCommandEvent &event) override
void OnValueCharHook(wxKeyEvent &aEvent) override
void SetInitialFocus(wxWindow *aWindow)
Sets the window (usually a wxTextCtrl) that should be focused when the dialog is shown.
Definition: dialog_shim.h:97
void SetupStandardButtons(std::map< int, wxString > aLabels={})
std::string m_hash_key
Definition: dialog_shim.h:203
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
EDA_ITEM_FLAGS GetEditFlags() const
Definition: eda_item.h:147
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
bool IsNew() const
Definition: eda_item.h:103
void SetTextColor(const COLOR4D &aColor)
Definition: eda_text.h:194
COLOR4D GetTextColor() const
Definition: eda_text.h:195
bool IsItalic() const
Definition: eda_text.h:120
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:117
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:87
KIFONT::FONT * GetFont() const
Definition: eda_text.h:178
int GetTextWidth() const
Definition: eda_text.h:189
void Offset(const VECTOR2I &aOffset)
Definition: eda_text.cpp:389
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition: eda_text.h:139
virtual void SetVisible(bool aVisible)
Definition: eda_text.cpp:217
void SetTextThickness(int aWidth)
The TextThickness is that set by the user.
Definition: eda_text.cpp:185
void SetBold(bool aBold)
Definition: eda_text.cpp:209
bool IsBold() const
Definition: eda_text.h:123
GR_TEXT_V_ALIGN_T GetVertJustify() const
Definition: eda_text.h:142
void SetTextSize(const VECTOR2I &aNewSize)
Definition: eda_text.cpp:347
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:163
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition: eda_text.cpp:193
void SetItalic(bool aItalic)
Definition: eda_text.cpp:201
void SetFont(KIFONT::FONT *aFont)
Definition: eda_text.cpp:331
bool HaveFontSelection() const
Definition: font_choice.cpp:88
void SetFontSelection(KIFONT::FONT *aFont)
Definition: font_choice.cpp:67
KIFONT::FONT * GetFontSelection(bool aBold, bool aItalic) const
APP_SETTINGS_BASE * KifaceSettings() const
Definition: kiface_base.h:93
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:172
wxString ConvertKIIDsToRefs(const wxString &aSource) const
Definition: schematic.cpp:387
wxString ConvertRefsToKIIDs(const wxString &aSource) const
Definition: schematic.cpp:319
SCH_SHEET & Root() const
Definition: schematic.h:90
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
COLOR_SETTINGS * GetColorSettings(bool aForceRefresh=false) const override
Returns a pointer to the active color theme settings.
Schematic editor (Eeschema) main window.
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void SaveCopyInUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItemToCopy, UNDO_REDO aTypeCommand, bool aAppend, bool aDirtyConnectivity=true)
Create a copy of the current schematic item, and put it in the undo list.
SCHEMATIC & Schematic() const
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false, bool aUpdateRtree=false) override
Mark an item for refresh.
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:50
VECTOR2I GetPosition() const override
Definition: sch_field.cpp:1052
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:147
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:112
void ClearFieldsAutoplaced()
Definition: sch_item.h:418
void AutoAutoplaceFields(SCH_SCREEN *aScreen)
Autoplace fields only if correct to do so automatically.
Definition: sch_item.h:427
void SetFields(const std::vector< SCH_FIELD > &aFields)
Set multiple schematic fields.
Definition: sch_label.h:98
bool AutoRotateOnPlacement() const
autoRotateOnPlacement
Definition: sch_label.cpp:991
virtual bool AutoRotateOnPlacementSupported() const =0
AutoRotateOnPlacementSupported.
void SetAutoRotateOnPlacement(bool autoRotate=true)
setAutoRotateOnPlacement
Definition: sch_label.cpp:996
void SetShape(LABEL_FLAG_SHAPE aShape) override
Definition: sch_label.h:74
static const wxString GetDefaultFieldName(const wxString &aName, bool aUseDefaultName)
Definition: sch_label.cpp:183
LABEL_FLAG_SHAPE GetShape() const override
Definition: sch_label.h:73
virtual int GetMandatoryFieldCount()
Definition: sch_label.h:88
std::vector< SCH_FIELD > & GetFields()
Definition: sch_label.h:90
virtual wxString GetClass() const override=0
Return the class name.
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:613
SCH_SCREEN * GetNext()
SCH_SCREEN * GetFirst()
static HTML_MESSAGE_BOX * ShowSyntaxHelp(wxWindow *aParentWindow)
Definition: sch_label.cpp:1638
VECTOR2I GetPosition() const override
Definition: sch_text.h:205
TEXT_SPIN_STYLE GetTextSpinStyle() const
Definition: sch_text.h:148
virtual void SetTextSpinStyle(TEXT_SPIN_STYLE aSpinStyle)
Set a spin or rotation angle, along with specific horizontal and vertical justification styles with e...
Definition: sch_text.cpp:188
virtual long long int GetValue()
Return the current value in Internal Units.
virtual bool Validate(double aMin, double aMax, EDA_UNITS aUnits=EDA_UNITS::UNSCALED)
Validate the control against the given range, informing the user of any errors found.
virtual void SetValue(long long int aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion.
void ShowHideColumns(const wxString &shownColumns)
Show/hide the grid columns based on a tokenized string of shown column indexes.
Definition: wx_grid.cpp:172
void SetTable(wxGridTableBase *table, bool aTakeOwnership=false)
Hide wxGrid's SetTable() method with one which doesn't mess up the grid column widths when setting th...
Definition: wx_grid.cpp:93
void DestroyTable(wxGridTableBase *aTable)
Work-around for a bug in wxGrid which crashes when deleting the table if the cell edit control was no...
Definition: wx_grid.cpp:139
wxString GetShownColumns()
Get a tokenized string containing the shown column indexes.
Definition: wx_grid.cpp:153
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:226
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:280
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:320
This file is part of the common library.
static bool positioningChanged(const SCH_FIELD &a, const SCH_FIELD &b)
#define _(s)
@ FDC_VALUE
int GetPenSizeForBold(int aTextSize)
Definition: gr_text.cpp:40
@ LAYER_FIELDS
Definition: layer_ids.h:354
@ LAYER_NETCLASS_REFS
Definition: layer_ids.h:356
@ LAYER_SCHEMATIC_BACKGROUND
Definition: layer_ids.h:376
@ LAYER_INTERSHEET_REFS
Definition: layer_ids.h:355
#define UNIMPLEMENTED_FOR(type)
Definition: macros.h:120
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
@ L_BIDI
Definition: sch_text.h:99
@ L_TRISTATE
Definition: sch_text.h:100
@ L_UNSPECIFIED
Definition: sch_text.h:101
@ F_DOT
Definition: sch_text.h:104
@ F_ROUND
Definition: sch_text.h:105
@ L_OUTPUT
Definition: sch_text.h:98
@ F_DIAMOND
Definition: sch_text.h:106
@ L_INPUT
Definition: sch_text.h:97
@ F_RECTANGLE
Definition: sch_text.h:107
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_NETNAME
Definition: string_utils.h:54
@ SCH_DIRECTIVE_LABEL_T
Definition: typeinfo.h:153
@ SCH_LABEL_T
Definition: typeinfo.h:150
@ SCH_HIER_LABEL_T
Definition: typeinfo.h:152
@ SCH_SHEET_PIN_T
Definition: typeinfo.h:156
@ SCH_GLOBAL_LABEL_T
Definition: typeinfo.h:151