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>
31#include <sch_edit_frame.h>
32#include <sch_validators.h>
33#include <tool/tool_manager.h>
34#include <gr_text.h>
35#include <confirm.h>
36#include <schematic.h>
39#include <string_utils.h>
42#include <kiface_base.h>
43#include <sch_label.h>
44
45
48 m_Parent( aParent ),
49 m_currentLabel( aLabel ),
50 m_activeTextEntry( nullptr ),
51 m_netNameValidator( true ),
52 m_fields( nullptr ),
53 m_textSize( aParent, m_textSizeLabel, m_textSizeCtrl, m_textSizeUnits, false ),
54 m_helpWindow( nullptr )
55{
56 COLOR_SETTINGS* colorSettings = m_Parent->GetColorSettings();
57 COLOR4D schematicBackground = colorSettings->GetColor( LAYER_SCHEMATIC_BACKGROUND );
58
60 m_width = 100; // Will be later set to a better value
63
65 {
68
69 m_labelSingleLine->Show( false );
70 m_valueSingleLine->Show( false );
71
72 m_valueCombo->SetValidator( m_netNameValidator );
73 }
74 else if( m_currentLabel->Type() == SCH_HIER_LABEL_T )
75 {
78
79 m_labelCombo->Show( false );
80 m_valueCombo->Show( false );
81
83 }
85 {
88
89 m_labelSingleLine->Show( false );
90 m_valueSingleLine->Show( false );
91 m_labelCombo->Show( false );
92 m_valueCombo->Show( false );
93 m_syntaxHelp->Show( false );
94 m_textEntrySizer->Show( false );
95
96 m_textSizeLabel->SetLabel( _( "Pin length:" ) );
97 }
98
99 switch( m_currentLabel->Type() )
100 {
101 case SCH_GLOBAL_LABEL_T: SetTitle( _( "Global Label Properties" ) ); break;
102 case SCH_HIER_LABEL_T: SetTitle( _( "Hierarchical Label Properties" ) ); break;
103 case SCH_LABEL_T: SetTitle( _( "Label Properties" ) ); break;
104 case SCH_DIRECTIVE_LABEL_T: SetTitle( _( "Directive Label Properties" ) ); break;
105 case SCH_SHEET_PIN_T: SetTitle( _( "Hierarchical Sheet Pin Properties" ) ); break;
106 default: UNIMPLEMENTED_FOR( m_currentLabel->GetClass() ); break;
107 }
108
109 // Give a bit more room for combobox editors
110 m_grid->SetDefaultRowSize( m_grid->GetDefaultRowSize() + 4 );
111
113 m_grid->PushEventHandler( new FIELDS_GRID_TRICKS( m_grid, this ) );
114 m_grid->SetSelectionMode( wxGrid::wxGridSelectRows );
115
116 // Show/hide columns according to user's preference
117 auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
118 wxASSERT( cfg );
119
120 if( cfg )
121 {
122 m_shownColumns = cfg->m_Appearance.edit_label_visible_columns;
124 }
125
126 // Configure button logos
131
133
138
140
145
147
148 m_textColorSwatch->SetDefaultColor( COLOR4D::UNSPECIFIED );
149 m_textColorSwatch->SetSwatchBackground( schematicBackground );
150
151 // Show/hide relevant controls
153 {
154 m_dot->Hide();
155 m_circle->Hide();
156 m_diamond->Hide();
157 m_rectangle->Hide();
158
163 }
165 {
166 m_input->Hide();
167 m_output->Hide();
168 m_bidirectional->Hide();
169 m_triState->Hide();
170 m_passive->Hide();
171
172 m_fontLabel->SetLabel( _( "Orientation:" ) );
173 m_fontCtrl->Hide();
174 m_separator1->Hide();
175 m_bold->Hide();
176 m_italic->Hide();
177 m_separator2->Hide();
182 m_separator3->Hide();
183
184 m_formattingGB->Detach( m_fontCtrl );
185 m_formattingGB->Detach( m_iconBar );
186 m_formattingGB->Add( m_iconBar, wxGBPosition( 0, 1 ), wxGBSpan( 1, 1 ), wxEXPAND|wxRIGHT, 5 );
187 }
188 else
189 {
190 m_shapeSizer->Show( false );
191
196 }
197
199 {
200 m_autoRotate->Hide();
201 wxSizer* parentSizer = m_autoRotate->GetContainingSizer();
202 parentSizer->Detach( m_autoRotate );
203 parentSizer->Layout();
204 }
205
207
208 // DIALOG_SHIM needs a unique hash_key because classname is not sufficient because the
209 // various versions have different controls so we want to store sizes for each version.
210 m_hash_key = TO_UTF8( GetTitle() );
211
212 m_spin0->Bind( wxEVT_BUTTON, &DIALOG_LABEL_PROPERTIES::onSpinButton, this );
213 m_spin1->Bind( wxEVT_BUTTON, &DIALOG_LABEL_PROPERTIES::onSpinButton, this );
214 m_spin2->Bind( wxEVT_BUTTON, &DIALOG_LABEL_PROPERTIES::onSpinButton, this );
215 m_spin3->Bind( wxEVT_BUTTON, &DIALOG_LABEL_PROPERTIES::onSpinButton, this );
216
217 // Now all widgets have the size fixed, call FinishDialogSettings
219
220 if( cfg && cfg->m_Appearance.edit_label_width > 0 && cfg->m_Appearance.edit_label_height > 0 )
221 SetSize( cfg->m_Appearance.edit_label_width, cfg->m_Appearance.edit_label_height );
222}
223
224
226{
227 EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
228 wxASSERT( cfg );
229
230 if( cfg )
231 {
233 cfg->m_Appearance.edit_label_width = GetSize().x;
234 cfg->m_Appearance.edit_label_height = GetSize().y;
235 }
236
237 // Prevents crash bug in wxGrid's d'tor
239
240 // Delete the GRID_TRICKS.
241 m_grid->PopEventHandler( true );
242
243 if( m_helpWindow )
244 m_helpWindow->Destroy();
245}
246
247
249{
250 if( !wxDialog::TransferDataToWindow() )
251 return false;
252
254 {
255 // show control characters in a human-readable format
256 wxString text = UnescapeString( m_currentLabel->GetText() );
257
258 // show text variable cross-references in a human-readable format
260
261 m_activeTextEntry->SetValue( text );
262 }
263
265 {
266 // Load the combobox with the existing labels of the same type
267 std::set<wxString> existingLabels;
268 std::vector<std::shared_ptr<BUS_ALIAS>> busAliases;
269 SCH_SCREENS allScreens( m_Parent->Schematic().Root() );
270
271 for( SCH_SCREEN* screen = allScreens.GetFirst(); screen; screen = allScreens.GetNext() )
272 {
273 for( SCH_ITEM* item : screen->Items().OfType( m_currentLabel->Type() ) )
274 {
275 const SCH_LABEL_BASE* label = static_cast<const SCH_LABEL_BASE*>( item );
276 existingLabels.insert( UnescapeString( label->GetText() ) );
277 }
278
279 // Add global power labels from power symbols
281 {
282 for( SCH_ITEM* item : screen->Items().OfType( SCH_SYMBOL_LOCATE_POWER_T ) )
283 {
284 const SCH_SYMBOL* power = static_cast<const SCH_SYMBOL*>( item );
285 existingLabels.insert( UnescapeString( power->GetValueFieldText( false ) ) );
286 }
287 }
288
289 std::set<std::shared_ptr<BUS_ALIAS>> sheetAliases = screen->GetBusAliases();
290 busAliases.insert( busAliases.end(), sheetAliases.begin(), sheetAliases.end() );
291 }
292
293 // Add bus aliases to label list
294 for( const std::shared_ptr<BUS_ALIAS>& busAlias : busAliases )
295 existingLabels.insert( wxT( "{" ) + busAlias->GetName() + wxT( "}" ) );
296
297 wxArrayString existingLabelArray;
298
299 for( const wxString& label : existingLabels )
300 existingLabelArray.push_back( label );
301
302 m_valueCombo->Append( existingLabelArray );
303 }
304
305 // Push a copy of each field into m_updateFields
306 for( SCH_FIELD& field : m_currentLabel->GetFields() )
307 {
308 SCH_FIELD field_copy( field );
309
310 // change offset to be symbol-relative
311 field_copy.Offset( -m_currentLabel->GetPosition() );
312
313 m_fields->push_back( field_copy );
314 }
315
316 // notify the grid
317 wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, m_fields->size() );
318 m_grid->ProcessTableMessage( msg );
319 AdjustGridColumns( m_grid->GetRect().GetWidth() );
320
321 if( m_shapeSizer->AreAnyItemsShown() )
322 {
323 switch( m_currentLabel->GetShape() )
324 {
325 case LABEL_FLAG_SHAPE::L_INPUT: m_input->SetValue( true ); break;
326 case LABEL_FLAG_SHAPE::L_OUTPUT: m_output->SetValue( true ); break;
327 case LABEL_FLAG_SHAPE::L_BIDI: m_bidirectional->SetValue( true ); break;
328 case LABEL_FLAG_SHAPE::L_TRISTATE: m_triState->SetValue( true ); break;
329 case LABEL_FLAG_SHAPE::L_UNSPECIFIED: m_passive->SetValue( true ); break;
330 case LABEL_FLAG_SHAPE::F_DOT: m_dot->SetValue( true ); break;
331 case LABEL_FLAG_SHAPE::F_ROUND: m_circle->SetValue( true ); break;
332 case LABEL_FLAG_SHAPE::F_DIAMOND: m_diamond->SetValue( true ); break;
333 case LABEL_FLAG_SHAPE::F_RECTANGLE: m_rectangle->SetValue( true ); break;
334 }
335 }
336
338
340 m_textSize.SetValue( static_cast<SCH_DIRECTIVE_LABEL*>( m_currentLabel )->GetPinLength() );
341 else
343
347
349 {
350 case TEXT_SPIN_STYLE::RIGHT: m_spin0->Check( true ); break;
351 case TEXT_SPIN_STYLE::LEFT: m_spin1->Check( true ); break;
352 case TEXT_SPIN_STYLE::UP: m_spin2->Check( true ); break;
353 case TEXT_SPIN_STYLE::BOTTOM: m_spin3->Check( true ); break;
354 }
355
358
359 return true;
360}
361
362
366void DIALOG_LABEL_PROPERTIES::OnEnterKey( wxCommandEvent& aEvent )
367{
368 wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
369}
370
371
373{
374 if( aEvent.GetKeyCode() == WXK_TAB )
375 {
376 if( aEvent.ShiftDown() )
377 {
378 m_textSizeCtrl->SetFocusFromKbd();
379 }
380 else if( !m_fields->empty() )
381 {
382 m_grid->SetFocusFromKbd();
383 m_grid->MakeCellVisible( 0, 0 );
384 m_grid->SetGridCursor( 0, 0 );
385 }
386 else
387 {
388 m_textSizeCtrl->SetFocusFromKbd();
389 }
390 }
391 else
392 {
393 aEvent.Skip();
394 }
395}
396
397
398static bool positioningChanged( const SCH_FIELD& a, const SCH_FIELD& b )
399{
400 return a.GetPosition() != b.GetPosition()
401 || a.GetHorizJustify() != b.GetHorizJustify()
402 || a.GetVertJustify() != b.GetVertJustify()
403 || a.GetTextAngle() != b.GetTextAngle();
404}
405
406
407static bool positioningChanged( FIELDS_GRID_TABLE<SCH_FIELD>* a, std::vector<SCH_FIELD>& b )
408{
409 for( size_t i = 0; i < a->size() && i < b.size(); ++i )
410 {
411 if( positioningChanged( a->at( i ), b.at( i ) ) )
412 return true;
413 }
414
415 return false;
416}
417
418
420{
422 return false;
423
424 if( !wxDialog::TransferDataFromWindow() )
425 return false;
426
427 // Don't allow text to disappear; it can be difficult to correct if you can't select it
428 if( !m_textSize.Validate( 0.01, 1000.0, EDA_UNITS::MILLIMETRES ) )
429 return false;
430
431 wxString text;
432
433 /* save old text in undo list if not already in edit */
434 if( m_currentLabel->GetEditFlags() == 0 )
435 {
437 false );
438 }
439
441
443 {
444 // labels need escaping
446
447 // convert any text variable cross-references to their UUIDs
449
450#ifdef __WXMAC__
451 // On macOS CTRL+Enter produces '\r' instead of '\n' regardless of EOL setting
452 text.Replace( wxS( "\r" ), wxS( "\n" ) );
453#endif
454
455 if( text.IsEmpty() && !m_currentLabel->IsNew() )
456 {
457 DisplayError( this, _( "Label can not be empty." ) );
458 return false;
459 }
460
462 }
463
464 bool doAutoplace = false;
465
466 // change all field positions from relative to absolute
467 for( SCH_FIELD& field : *m_fields )
468 {
469 field.Offset( m_currentLabel->GetPosition() );
470
471 if( field.GetCanonicalName() == wxT( "Netclass" ) )
472 {
473 field.SetLayer( LAYER_NETCLASS_REFS );
474 }
475 else if( field.GetCanonicalName() == wxT( "Intersheetrefs" ) )
476 {
477 if( field.IsVisible() != m_Parent->Schematic().Settings().m_IntersheetRefsShow )
478 {
479 DisplayInfoMessage( this, _( "Intersheet reference visibility is "
480 "controlled globally from "
481 "Schematic Setup > General > Formatting" ) );
482 }
483
484 field.SetLayer( LAYER_INTERSHEET_REFS );
485 }
486 else
487 {
488 field.SetLayer( LAYER_FIELDS );
489 }
490 }
491
494 else
495 doAutoplace = true;
496
498
499 if( m_shapeSizer->AreAnyItemsShown() )
500 {
501 if( m_input->GetValue() )
503 else if( m_output->GetValue() )
505 else if( m_bidirectional->GetValue() )
507 else if( m_triState->GetValue() )
509 else if( m_passive->GetValue() )
511 else if( m_dot->GetValue() )
513 else if( m_circle->GetValue() )
515 else if( m_diamond->GetValue() )
517 else if( m_rectangle->GetValue() )
519 }
520
522 {
524 m_italic->IsChecked() ) );
525 }
526
528 static_cast<SCH_DIRECTIVE_LABEL*>( m_currentLabel )->SetPinLength( m_textSize.GetValue() );
531
533 {
534 if( m_bold->IsChecked() )
535 {
536 m_currentLabel->SetBold( true );
538 }
539 else
540 {
541 m_currentLabel->SetBold( false );
542 m_currentLabel->SetTextThickness( 0 ); // Use default pen width
543 }
544 }
545
547
549
550 TEXT_SPIN_STYLE selectedSpinStyle= TEXT_SPIN_STYLE::LEFT;
551
552 if( m_spin0->IsChecked() )
553 selectedSpinStyle = TEXT_SPIN_STYLE::RIGHT;
554 else if( m_spin1->IsChecked() )
555 selectedSpinStyle = TEXT_SPIN_STYLE::LEFT;
556 else if( m_spin2->IsChecked() )
557 selectedSpinStyle = TEXT_SPIN_STYLE::UP;
558 else if( m_spin3->IsChecked() )
559 selectedSpinStyle = TEXT_SPIN_STYLE::BOTTOM;
560
562 {
563 SCH_EDIT_FRAME* frame = static_cast<SCH_EDIT_FRAME*>( m_parentFrame );
565 frame->AutoRotateItem( frame->GetScreen(), m_currentLabel );
566 }
567 else
569
571 && m_currentLabel->GetTextSpinStyle() != selectedSpinStyle )
572 m_currentLabel->SetTextSpinStyle( selectedSpinStyle );
573
574 if( doAutoplace )
576
580
581 return true;
582}
583
584
585void DIALOG_LABEL_PROPERTIES::onSpinButton( wxCommandEvent& aEvent )
586{
587 for( BITMAP_BUTTON* btn : { m_spin0, m_spin1, m_spin2, m_spin3 } )
588 {
589 if( btn->IsChecked() && btn != aEvent.GetEventObject() )
590 btn->Check( false );
591 }
592}
593
594
595void DIALOG_LABEL_PROPERTIES::OnFormattingHelp( wxHyperlinkEvent& aEvent )
596{
598}
599
600
601void DIALOG_LABEL_PROPERTIES::OnAddField( wxCommandEvent& event )
602{
604 return;
605
606 int fieldID = m_fields->size();
607 wxString fieldName;
608
609 if( (int) fieldID == m_currentLabel->GetMandatoryFieldCount()
610 || m_fields->at( m_fields->size()-1 ).GetCanonicalName() == wxT( "Netclass" ) )
611 {
612 fieldName = wxT( "Netclass" );
613 }
614 else
615 {
616 fieldName = SCH_LABEL_BASE::GetDefaultFieldName( fieldName, true );
617 }
618
619 SCH_FIELD newField( wxPoint( 0, 0 ), fieldID, m_currentLabel, fieldName );
620
621 if( m_fields->size() > 0 )
622 {
623 newField.SetVisible( m_fields->at( m_fields->size() - 1 ).IsVisible() );
624 newField.SetTextAngle( m_fields->at( m_fields->size() - 1 ).GetTextAngle() );
625 newField.SetItalic( m_fields->at( m_fields->size() - 1 ).IsItalic() );
626 newField.SetBold( m_fields->at( m_fields->size() - 1 ).IsBold() );
627 }
628 else
629 {
630 newField.SetVisible( true );
631 newField.SetItalic( true );
632 }
633
634 m_fields->push_back( newField );
635
636 // notify the grid
637 wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
638 m_grid->ProcessTableMessage( msg );
639
640 m_grid->MakeCellVisible( m_fields->size() - 1, 0 );
641 m_grid->SetGridCursor( m_fields->size() - 1, fieldName == wxT( "Netclass" ) ? 1 : 0 );
642
643 m_grid->EnableCellEditControl();
644 m_grid->ShowCellEditControl();
645}
646
647
648void DIALOG_LABEL_PROPERTIES::OnDeleteField( wxCommandEvent& event )
649{
650 wxArrayInt selectedRows = m_grid->GetSelectedRows();
651
652 if( selectedRows.empty() && m_grid->GetGridCursorRow() >= 0 )
653 selectedRows.push_back( m_grid->GetGridCursorRow() );
654
655 if( selectedRows.empty() )
656 return;
657
658 for( int row : selectedRows )
659 {
660 if( row < m_currentLabel->GetMandatoryFieldCount() )
661 {
662 DisplayError( this, _( "The first field is mandatory." ) );
663 return;
664 }
665 }
666
667 m_grid->CommitPendingChanges( true /* quiet mode */ );
668
669 // Reverse sort so deleting a row doesn't change the indexes of the other rows.
670 selectedRows.Sort( []( int* first, int* second ) { return *second - *first; } );
671
672 for( int row : selectedRows )
673 {
674 m_fields->erase( m_fields->begin() + row );
675
676 // notify the grid
677 wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, row, 1 );
678 m_grid->ProcessTableMessage( msg );
679
680 if( m_grid->GetNumberRows() > 0 )
681 {
682 m_grid->MakeCellVisible( std::max( 0, row-1 ), m_grid->GetGridCursorCol() );
683 m_grid->SetGridCursor( std::max( 0, row-1 ), m_grid->GetGridCursorCol() );
684 }
685 }
686}
687
688
689void DIALOG_LABEL_PROPERTIES::OnMoveUp( wxCommandEvent& event )
690{
692 return;
693
694 int i = m_grid->GetGridCursorRow();
695
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
713void DIALOG_LABEL_PROPERTIES::OnMoveDown( wxCommandEvent& event )
714{
716 return;
717
718 int i = m_grid->GetGridCursorRow();
719
720 if( i >= m_currentLabel->GetMandatoryFieldCount() && i < m_grid->GetNumberRows() - 1 )
721 {
722 SCH_FIELD tmp = m_fields->at( (unsigned) i );
723 m_fields->erase( m_fields->begin() + i, m_fields->begin() + i + 1 );
724 m_fields->insert( m_fields->begin() + i + 1, tmp );
725 m_grid->ForceRefresh();
726
727 m_grid->SetGridCursor( i + 1, m_grid->GetGridCursorCol() );
728 m_grid->MakeCellVisible( m_grid->GetGridCursorRow(), m_grid->GetGridCursorCol() );
729 }
730 else
731 {
732 wxBell();
733 }
734}
735
736
738{
739 m_width = aWidth;
740 // Account for scroll bars
741 aWidth -= ( m_grid->GetSize().x - m_grid->GetClientSize().x );
742
743 m_grid->AutoSizeColumn( 0 );
744 m_grid->SetColSize( 0, std::max( 72, m_grid->GetColSize( 0 ) ) );
745
746 int fixedColsWidth = m_grid->GetColSize( 0 );
747
748 for( int i = 2; i < m_grid->GetNumberCols(); i++ )
749 fixedColsWidth += m_grid->GetColSize( i );
750
751 m_grid->SetColSize( 1, std::max( 120, aWidth - fixedColsWidth ) );
752}
753
754
755void DIALOG_LABEL_PROPERTIES::OnUpdateUI( wxUpdateUIEvent& event )
756{
757 wxString shownColumns = m_grid->GetShownColumns();
758
759 if( shownColumns != m_shownColumns )
760 {
761 m_shownColumns = shownColumns;
762
763 if( !m_grid->IsCellEditControlShown() )
764 AdjustGridColumns( m_grid->GetRect().GetWidth() );
765 }
766
767 // Handle a delayed focus
768 if( m_delayedFocusRow >= 0 && m_delayedFocusRow < m_grid->GetNumberRows() )
769 {
770 m_grid->SetFocus();
771 m_grid->MakeCellVisible( m_delayedFocusRow, m_delayedFocusColumn );
773 }
774
777}
778
779
780void DIALOG_LABEL_PROPERTIES::OnSizeGrid( wxSizeEvent& event )
781{
782 int new_size = event.GetSize().GetX();
783
784 if( m_width != new_size )
785 AdjustGridColumns( new_size );
786
787 // Always propagate for a grid repaint (needed if the height changes, as well as width)
788 event.Skip();
789}
790
791
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...
EDA_BASE_FRAME * m_parentFrame
Definition: dialog_shim.h:220
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:145
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:204
COLOR4D GetTextColor() const
Definition: eda_text.h:205
bool IsItalic() const
Definition: eda_text.h:130
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:120
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:188
int GetTextWidth() const
Definition: eda_text.h:199
void Offset(const VECTOR2I &aOffset)
Definition: eda_text.cpp:389
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition: eda_text.h:149
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:133
GR_TEXT_V_ALIGN_T GetVertJustify() const
Definition: eda_text.h:152
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:203
wxString ConvertKIIDsToRefs(const wxString &aSource) const
Definition: schematic.cpp:451
wxString ConvertRefsToKIIDs(const wxString &aSource) const
Definition: schematic.cpp:383
SCH_SHEET & Root() const
Definition: schematic.h:91
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 and update other data struc...
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.
void AutoRotateItem(SCH_SCREEN *aScreen, SCH_ITEM *aItem)
Automatically set the rotation of an item (if the item supports it)
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:51
VECTOR2I GetPosition() const override
Definition: sch_field.cpp:1061
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:427
void AutoAutoplaceFields(SCH_SCREEN *aScreen)
Autoplace fields only if correct to do so automatically.
Definition: sch_item.h:436
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:1002
virtual bool AutoRotateOnPlacementSupported() const =0
AutoRotateOnPlacementSupported.
void SetAutoRotateOnPlacement(bool autoRotate=true)
setAutoRotateOnPlacement
Definition: sch_label.cpp:1007
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:656
SCH_SCREEN * GetNext()
SCH_SCREEN * GetFirst()
Schematic symbol object.
Definition: sch_symbol.h:81
const wxString GetValueFieldText(bool aResolve) const
Definition: sch_symbol.cpp:813
static HTML_MESSAGE_BOX * ShowSyntaxHelp(wxWindow *aParentWindow)
Definition: sch_label.cpp:1649
VECTOR2I GetPosition() const override
Definition: sch_text.h:203
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
void SetBitmap(const wxBitmap &aBmp)
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:295
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:164
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:262
wxString GetShownColumns()
Get a tokenized string containing the shown column indexes.
Definition: wx_grid.cpp:276
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:423
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:300
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:352
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:154
@ SCH_LABEL_T
Definition: typeinfo.h:151
@ SCH_HIER_LABEL_T
Definition: typeinfo.h:153
@ SCH_SHEET_PIN_T
Definition: typeinfo.h:157
@ SCH_SYMBOL_LOCATE_POWER_T
Definition: typeinfo.h:180
@ SCH_GLOBAL_LABEL_T
Definition: typeinfo.h:152