48 m_currentLabel( aLabel ),
49 m_activeTextEntry( nullptr ),
50 m_netNameValidator( true ),
52 m_textSize( aParent, m_textSizeLabel, m_textSizeCtrl, m_textSizeUnits, false ),
53 m_helpWindow( nullptr ),
54 m_labelList( nullptr )
58 bool multiLine =
false;
61 multiLine = cfg->m_Appearance.edit_label_multiple;
78 if( multiLine && aNew )
100 if( multiLine && aNew )
139 case SCH_LABEL_T: SetTitle(
_(
"Label Properties" ) );
break;
141 case SCH_SHEET_PIN_T: SetTitle(
_(
"Hierarchical Sheet Pin Properties" ) );
break;
147 [&]( wxCommandEvent& aEvent )
151 m_grid->SetSelectionMode( wxGrid::wxGridSelectRows );
235 wxSizer* parentSizer =
m_autoRotate->GetContainingSizer();
237 parentSizer->Layout();
256 if( cfg->m_Appearance.edit_label_width > 0 && cfg->m_Appearance.edit_label_height > 0 )
257 SetSize( cfg->m_Appearance.edit_label_width, cfg->m_Appearance.edit_label_height );
267 cfg->m_Appearance.edit_label_width = GetSize().x;
268 cfg->m_Appearance.edit_label_height = GetSize().y;
269 cfg->m_Appearance.edit_label_multiple =
m_cbMultiLine->IsChecked();
276 m_grid->PopEventHandler(
true );
285 if( !wxDialog::TransferDataToWindow() )
302 std::set<wxString> existingLabels;
303 std::vector<std::shared_ptr<BUS_ALIAS>> busAliases;
349 auto& sheetAliases = screen->GetBusAliases();
350 busAliases.insert( busAliases.end(), sheetAliases.begin(), sheetAliases.end() );
354 for(
const std::shared_ptr<BUS_ALIAS>& busAlias : busAliases )
355 existingLabels.insert( wxT(
"{" ) + busAlias->GetName() + wxT(
"}" ) );
357 for(
const wxString& label : existingLabels )
380 wxGridTableMessage msg(
m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, (
int)
m_fields->size() );
381 m_grid->ProcessTableMessage( msg );
388 case LABEL_FLAG_SHAPE::L_INPUT:
m_input->SetValue(
true );
break;
389 case LABEL_FLAG_SHAPE::L_OUTPUT:
m_output->SetValue(
true );
break;
390 case LABEL_FLAG_SHAPE::L_BIDI:
m_bidirectional->SetValue(
true );
break;
391 case LABEL_FLAG_SHAPE::L_TRISTATE:
m_triState->SetValue(
true );
break;
392 case LABEL_FLAG_SHAPE::L_UNSPECIFIED:
m_passive->SetValue(
true );
break;
393 case LABEL_FLAG_SHAPE::F_DOT:
m_dot->SetValue(
true );
break;
394 case LABEL_FLAG_SHAPE::F_ROUND:
m_circle->SetValue(
true );
break;
395 case LABEL_FLAG_SHAPE::F_DIAMOND:
m_diamond->SetValue(
true );
break;
396 case LABEL_FLAG_SHAPE::F_RECTANGLE:
m_rectangle->SetValue(
true );
break;
428 wxPostEvent(
this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
437 if( aEvent.GetKeyCode() == WXK_RETURN )
439 wxPostEvent(
this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
441 else if( aEvent.GetKeyCode() == WXK_SPACE )
458 if( aEvent.GetKeyCode() == WXK_TAB )
460 if( aEvent.ShiftDown() )
466 m_grid->SetFocusFromKbd();
467 m_grid->MakeCellVisible( 0, 0 );
468 m_grid->SetGridCursor( 0, 0 );
493 for(
size_t i = 0; i < a->size() && i < b.size(); ++i )
508 if( !wxDialog::TransferDataFromWindow() )
534 text.Replace( wxS(
"\r" ), wxS(
"\n" ) );
551 if( field.GetCanonicalName() == wxT(
"Netclass" ) )
555 else if( field.GetId() == FIELD_T::INTERSHEET_REFS )
559 DisplayInfoMessage(
this,
_(
"Intersheet reference visibility is controlled globally from "
560 "Schematic Setup > General > Formatting" ) );
578 const wxString& fieldText = field.
GetText();
580 if( fieldName.IsEmpty() && fieldText.IsEmpty() )
585 else if( fieldName == wxT(
"Netclass" ) && fieldText.IsEmpty() )
588 int netclassFieldCount = 0;
592 if(
m_fields->at( jj ).GetCanonicalName() == wxT(
"Netclass" ) )
593 netclassFieldCount++;
596 if( netclassFieldCount > 1 )
599 else if( fieldName.IsEmpty() )
610 if( !field.IsMandatory() )
611 field.SetOrdinal( ordinal++ );
669 if( !commit.
Empty() )
671 commit.
Push(
_(
"Edit Label Properties" ) );
677 text.Replace( wxS(
"\r" ), wxS(
"\n" ) );
678 wxArrayString lines = wxSplit(
text,
'\n' );
680 for(
const wxString& line : lines )
683 text.Trim(
false ).Trim(
true );
697 m_labelList->push_back( std::unique_ptr<SCH_LABEL_BASE>( label ) );
704 m_labelList->push_back( std::unique_ptr<SCH_LABEL_BASE>( label ) );
711 m_labelList->push_back( std::unique_ptr<SCH_LABEL_BASE>( label ) );
722 m_labelList->push_back( std::unique_ptr<SCH_LABEL_BASE>( label ) );
733 if( btn->IsChecked() && btn != aEvent.GetEventObject() )
748 [&]() -> std::pair<int, int>
750 wxString fieldName = wxT(
"Netclass" );
754 if( field.GetId() != FIELD_T::INTERSHEET_REFS && field.GetName() != wxT(
"Netclass" ) )
756 fieldName = wxEmptyString;
780 wxGridTableMessage msg(
m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
781 m_grid->ProcessTableMessage( msg );
792 if( row < m_currentLabel->GetMandatoryFieldCount() )
805 wxGridTableMessage msg(
m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, row, 1 );
806 m_grid->ProcessTableMessage( msg );
820 std::swap( *(
m_fields->begin() + row ), *(
m_fields->begin() + row - 1 ) );
835 std::swap( *(
m_fields->begin() + row ), *(
m_fields->begin() + row + 1 ) );
845 aWidth -= (
m_grid->GetSize().x -
m_grid->GetClientSize().x );
847 m_grid->AutoSizeColumn( 0 );
848 m_grid->SetColSize( 0, std::max( 72,
m_grid->GetColSize( 0 ) ) );
850 int fixedColsWidth =
m_grid->GetColSize( 0 );
852 for(
int i = 2; i <
m_grid->GetNumberCols(); i++ )
853 fixedColsWidth +=
m_grid->GetColSize( i );
855 m_grid->SetColSize( 1, std::max( 120, aWidth - fixedColsWidth ) );
867 if( !
m_grid->IsCellEditControlShown() )
886 int new_size =
event.GetSize().GetX();
914 m_valueCombo->SetValue( multiText.BeforeFirst(
'\n' ) );
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
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.
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
Class DIALOG_LABEL_PROPERTIES_BASE.
wxStaticText * m_textSizeLabel
wxRadioButton * m_triState
COLOR_SWATCH * m_textColorSwatch
STD_BITMAP_BUTTON * m_bpMoveUp
wxFlexGridSizer * m_textEntrySizer
wxStaticText * m_labelMultiLine
wxStaticBoxSizer * m_shapeSizer
wxRadioButton * m_diamond
BITMAP_BUTTON * m_separator3
wxTextCtrl * m_valueMultiLine
STD_BITMAP_BUTTON * m_bpAdd
wxHyperlinkCtrl * m_syntaxHelp
wxRadioButton * m_rectangle
wxStaticText * m_labelCombo
wxStaticText * m_labelSingleLine
wxRadioButton * m_passive
wxCheckBox * m_cbMultiLine
STD_BITMAP_BUTTON * m_bpMoveDown
STD_BITMAP_BUTTON * m_bpDelete
BITMAP_BUTTON * m_separator1
wxTextCtrl * m_textSizeCtrl
wxCheckBox * m_autoRotate
wxGridBagSizer * m_formattingGB
FILTER_COMBOBOX * m_valueCombo
wxRadioButton * m_bidirectional
BITMAP_BUTTON * m_separator2
wxStaticText * m_fontLabel
wxTextCtrl * m_valueSingleLine
HTML_MESSAGE_BOX * m_helpWindow
std::list< std::unique_ptr< SCH_LABEL_BASE > > * m_labelList
void OnSizeGrid(wxSizeEvent &event) override
~DIALOG_LABEL_PROPERTIES()
wxTextEntry * m_activeTextEntry
SCH_LABEL_BASE * m_currentLabel
void OnMoveUp(wxCommandEvent &event) override
void OnMoveDown(wxCommandEvent &event) override
DIALOG_LABEL_PROPERTIES(SCH_EDIT_FRAME *parent, SCH_LABEL_BASE *aLabel, bool aNew)
void OnEnterKey(wxCommandEvent &aEvent) override
wxEVT_COMMAND_ENTER event handler for single-line control.
std::bitset< 64 > m_shownColumns
void OnAddField(wxCommandEvent &event) override
void AdjustGridColumns(int aWidth)
SCH_NETNAME_VALIDATOR m_netNameValidator
void OnFormattingHelp(wxHyperlinkEvent &aEvent) override
bool TransferDataFromWindow() override
void OnCBValueCharHook(wxKeyEvent &aEvent) override
wxArrayString m_existingLabelArray
void OnUpdateUI(wxUpdateUIEvent &event) override
void onSpinButton(wxCommandEvent &aEvent)
void onMultiLabelCheck(wxCommandEvent &aEvent) override
FIELDS_GRID_TABLE * m_fields
void OnDeleteField(wxCommandEvent &event) override
void OnValueCharHook(wxKeyEvent &aEvent) override
bool TransferDataToWindow() override
SCH_EDIT_FRAME * m_Parent
void SetInitialFocus(wxWindow *aWindow)
Sets the window (usually a wxTextCtrl) that should be focused when the dialog is shown.
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...
EDA_BASE_FRAME * m_parentFrame
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
EDA_ITEM_FLAGS GetEditFlags() const
KICAD_T Type() const
Returns the type of object.
void SetTextColor(const COLOR4D &aColor)
COLOR4D GetTextColor() const
const EDA_ANGLE & GetTextAngle() const
void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true)
virtual const wxString & GetText() const
Return the string associated with the text object.
KIFONT::FONT * GetFont() const
void SetAttributes(const EDA_TEXT &aSrc, bool aSetPosition=true)
Set the text attributes from another instance.
void Offset(const VECTOR2I &aOffset)
GR_TEXT_H_ALIGN_T GetHorizJustify() const
virtual void SetVisible(bool aVisible)
void SetBold(bool aBold)
Set the text to be bold - this will also update the font if needed.
GR_TEXT_V_ALIGN_T GetVertJustify() const
virtual void SetText(const wxString &aText)
void SetItalic(bool aItalic)
Set the text to be italic - this will also update the font if needed.
void SetFont(KIFONT::FONT *aFont)
int GetNumberRows() override
void push_back(const SCH_FIELD &field)
virtual void SetSelectedString(const wxString &aString)
virtual void SetStringList(const wxArrayString &aStringList)
void SetFontSelection(KIFONT::FONT *aFont, bool aSilentMode=false)
Set the selection in wxChoice widget.
KIFONT::FONT * GetFontSelection(bool aBold, bool aItalic, bool aForDrawingSheet=false) const
bool HaveFontSelection() const
APP_SETTINGS_BASE * KifaceSettings() const
A color representation with 4 components: red, green, blue, alpha.
bool m_IntersheetRefsShow
SCHEMATIC_SETTINGS & Settings() const
wxString ConvertKIIDsToRefs(const wxString &aSource) const
wxString ConvertRefsToKIIDs(const wxString &aSource) const
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.
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Execute the changes.
Schematic editor (Eeschema) main window.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
SCHEMATIC & Schematic() const
void AutoRotateItem(SCH_SCREEN *aScreen, SCH_ITEM *aItem)
Automatically set the rotation of an item (if the item supports it).
VECTOR2I GetPosition() const override
wxString GetCanonicalName() const
Get a non-language-specific name for a field which can be used for storage, variable look-up,...
void SetName(const wxString &aName)
Base class for any item which can be embedded within the SCHEMATIC container class,...
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
void SetFieldsAutoplaced(AUTOPLACE_ALGO aAlgo)
AUTOPLACE_ALGO GetFieldsAutoplaced() const
Return whether the fields have been automatically placed.
void SetFields(const std::vector< SCH_FIELD > &aFields)
Set multiple schematic fields.
bool AutoRotateOnPlacement() const
autoRotateOnPlacement
SPIN_STYLE GetSpinStyle() const
void SetShape(LABEL_FLAG_SHAPE aShape)
LABEL_FLAG_SHAPE GetShape() const
virtual bool AutoRotateOnPlacementSupported() const =0
void SetAutoRotateOnPlacement(bool autoRotate=true)
static const wxString GetDefaultFieldName(const wxString &aName, bool aUseDefaultName)
void AutoplaceFields(SCH_SCREEN *aScreen, AUTOPLACE_ALGO aAlgo) override
virtual int GetMandatoryFieldCount()
std::vector< SCH_FIELD > & GetFields()
virtual wxString GetClass() const override=0
Return the class name.
virtual void SetSpinStyle(SPIN_STYLE aSpinStyle)
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
bool IsSymbolLikePowerGlobalLabel() const
bool IsSymbolLikePowerLocalLabel() const
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this symbol.
static HTML_MESSAGE_BOX * ShowSyntaxHelp(wxWindow *aParentWindow)
VECTOR2I GetPosition() const override
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.
void OnMoveRowUp(const std::function< void(int row)> &aMover)
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...
void DestroyTable(wxGridTableBase *aTable)
Work-around for a bug in wxGrid which crashes when deleting the table if the cell edit control was no...
void OnDeleteRows(const std::function< void(int row)> &aDeleter)
Handles a row deletion event.
wxString GetShownColumnsAsString()
Get a tokenized string containing the shown column indexes.
void OnAddRow(const std::function< std::pair< int, int >()> &aAdder)
std::bitset< 64 > GetShownColumns()
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
void DisplayError(wxWindow *aParent, const wxString &aText)
Display an error or warning message box with aMessage.
This file is part of the common library.
static bool positioningChanged(const SCH_FIELD &a, const SCH_FIELD &b)
@ LAYER_SCHEMATIC_BACKGROUND
#define UNIMPLEMENTED_FOR(type)
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:...
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
@ SCH_SYMBOL_LOCATE_POWER_T