49 m_currentLabel( aLabel ),
50 m_activeTextEntry( nullptr ),
51 m_netNameValidator( true ),
53 m_textSize( aParent, m_textSizeLabel, m_textSizeCtrl, m_textSizeUnits, false ),
54 m_helpWindow( nullptr )
103 case SCH_LABEL_T: SetTitle(
_(
"Label Properties" ) );
break;
105 case SCH_SHEET_PIN_T: SetTitle(
_(
"Hierarchical Sheet Pin Properties" ) );
break;
110 m_grid->SetDefaultRowSize(
m_grid->GetDefaultRowSize() + 4 );
114 [&]( wxCommandEvent& aEvent )
118 m_grid->SetSelectionMode( wxGrid::wxGridSelectRows );
202 wxSizer* parentSizer =
m_autoRotate->GetContainingSizer();
204 parentSizer->Layout();
223 if( cfg->m_Appearance.edit_label_width > 0 && cfg->m_Appearance.edit_label_height > 0 )
224 SetSize( cfg->m_Appearance.edit_label_width, cfg->m_Appearance.edit_label_height );
234 cfg->m_Appearance.edit_label_width = GetSize().x;
235 cfg->m_Appearance.edit_label_height = GetSize().y;
242 m_grid->PopEventHandler(
true );
251 if( !wxDialog::TransferDataToWindow() )
268 std::set<wxString> existingLabels;
269 std::vector<std::shared_ptr<BUS_ALIAS>> busAliases;
294 std::set<std::shared_ptr<BUS_ALIAS>> sheetAliases = screen->GetBusAliases();
295 busAliases.insert( busAliases.end(), sheetAliases.begin(), sheetAliases.end() );
299 for(
const std::shared_ptr<BUS_ALIAS>& busAlias : busAliases )
300 existingLabels.insert( wxT(
"{" ) + busAlias->GetName() + wxT(
"}" ) );
302 wxArrayString existingLabelArray;
304 for(
const wxString& label : existingLabels )
305 existingLabelArray.push_back( label );
322 wxGridTableMessage msg(
m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED,
m_fields->size() );
323 m_grid->ProcessTableMessage( msg );
330 case LABEL_FLAG_SHAPE::L_INPUT:
m_input->SetValue(
true );
break;
331 case LABEL_FLAG_SHAPE::L_OUTPUT:
m_output->SetValue(
true );
break;
332 case LABEL_FLAG_SHAPE::L_BIDI:
m_bidirectional->SetValue(
true );
break;
333 case LABEL_FLAG_SHAPE::L_TRISTATE:
m_triState->SetValue(
true );
break;
334 case LABEL_FLAG_SHAPE::L_UNSPECIFIED:
m_passive->SetValue(
true );
break;
335 case LABEL_FLAG_SHAPE::F_DOT:
m_dot->SetValue(
true );
break;
336 case LABEL_FLAG_SHAPE::F_ROUND:
m_circle->SetValue(
true );
break;
337 case LABEL_FLAG_SHAPE::F_DIAMOND:
m_diamond->SetValue(
true );
break;
338 case LABEL_FLAG_SHAPE::F_RECTANGLE:
m_rectangle->SetValue(
true );
break;
373 wxPostEvent(
this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
379 if( aEvent.GetKeyCode() == WXK_TAB )
381 if( aEvent.ShiftDown() )
387 m_grid->SetFocusFromKbd();
388 m_grid->MakeCellVisible( 0, 0 );
389 m_grid->SetGridCursor( 0, 0 );
414 for(
size_t i = 0; i < a->size() && i < b.size(); ++i )
429 if( !wxDialog::TransferDataFromWindow() )
457 text.Replace( wxS(
"\r" ), wxS(
"\n" ) );
469 bool doAutoplace =
false;
476 if( field.GetCanonicalName() == wxT(
"Netclass" ) )
480 else if( field.GetCanonicalName() == wxT(
"Intersheetrefs" ) )
485 "controlled globally from "
486 "Schematic Setup > General > Formatting" ) );
506 const wxString& fieldText = field.
GetText();
508 if( fieldName.IsEmpty() && fieldText.IsEmpty() )
510 else if( fieldName == wxT(
"Netclass" ) && fieldText.IsEmpty() )
512 else if( fieldName.IsEmpty() )
530 else if(
m_dot->GetValue() )
607 if( btn->IsChecked() && btn != aEvent.GetEventObject() )
624 int fieldID = (int)
m_fields->size();
628 ||
m_fields->at(
m_fields->size()-1 ).GetCanonicalName() == wxT(
"Netclass" ) )
630 fieldName = wxT(
"Netclass" );
655 wxGridTableMessage msg(
m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
656 m_grid->ProcessTableMessage( msg );
661 m_grid->EnableCellEditControl();
662 m_grid->ShowCellEditControl();
668 wxArrayInt selectedRows =
m_grid->GetSelectedRows();
670 if( selectedRows.empty() &&
m_grid->GetGridCursorRow() >= 0 )
671 selectedRows.push_back(
m_grid->GetGridCursorRow() );
673 if( selectedRows.empty() )
676 for(
int row : selectedRows )
678 if( row < m_currentLabel->GetMandatoryFieldCount() )
688 selectedRows.Sort( [](
int* first,
int* second ) {
return *second - *first; } );
690 for(
int row : selectedRows )
695 wxGridTableMessage msg(
m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, row, 1 );
696 m_grid->ProcessTableMessage( msg );
698 if(
m_grid->GetNumberRows() > 0 )
700 m_grid->MakeCellVisible( std::max( 0, row-1 ),
m_grid->GetGridCursorCol() );
701 m_grid->SetGridCursor( std::max( 0, row-1 ),
m_grid->GetGridCursorCol() );
712 int i =
m_grid->GetGridCursorRow();
721 m_grid->SetGridCursor( i - 1,
m_grid->GetGridCursorCol() );
736 int i =
m_grid->GetGridCursorRow();
745 m_grid->SetGridCursor( i + 1,
m_grid->GetGridCursorCol() );
759 aWidth -= (
m_grid->GetSize().x -
m_grid->GetClientSize().x );
761 m_grid->AutoSizeColumn( 0 );
762 m_grid->SetColSize( 0, std::max( 72,
m_grid->GetColSize( 0 ) ) );
764 int fixedColsWidth =
m_grid->GetColSize( 0 );
766 for(
int i = 2; i <
m_grid->GetNumberCols(); i++ )
767 fixedColsWidth +=
m_grid->GetColSize( i );
769 m_grid->SetColSize( 1, std::max( 120, aWidth - fixedColsWidth ) );
781 if( !
m_grid->IsCellEditControlShown() )
800 int new_size =
event.GetSize().GetX();
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...
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.
wxStaticText * m_textSizeLabel
wxRadioButton * m_triState
COLOR_SWATCH * m_textColorSwatch
STD_BITMAP_BUTTON * m_bpMoveUp
wxFlexGridSizer * m_textEntrySizer
wxStaticBoxSizer * m_shapeSizer
wxRadioButton * m_diamond
BITMAP_BUTTON * m_separator3
STD_BITMAP_BUTTON * m_bpAdd
wxHyperlinkCtrl * m_syntaxHelp
wxRadioButton * m_rectangle
wxStaticText * m_labelCombo
wxComboBox * m_valueCombo
wxStaticText * m_labelSingleLine
wxRadioButton * m_passive
STD_BITMAP_BUTTON * m_bpMoveDown
STD_BITMAP_BUTTON * m_bpDelete
BITMAP_BUTTON * m_separator1
wxTextCtrl * m_textSizeCtrl
wxCheckBox * m_autoRotate
wxGridBagSizer * m_formattingGB
wxRadioButton * m_bidirectional
BITMAP_BUTTON * m_separator2
wxStaticText * m_fontLabel
wxTextCtrl * m_valueSingleLine
HTML_MESSAGE_BOX * m_helpWindow
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
void OnEnterKey(wxCommandEvent &aEvent) override
std::bitset< 64 > m_shownColumns
void OnAddField(wxCommandEvent &event) override
void AdjustGridColumns(int aWidth)
SCH_NETNAME_VALIDATOR m_netNameValidator
void OnFormattingHelp(wxHyperlinkEvent &aEvent) override
FIELDS_GRID_TABLE< SCH_FIELD > * m_fields
bool TransferDataFromWindow() override
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
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
virtual const wxString & GetText() const
Return the string associated with the text object.
KIFONT::FONT * GetFont() const
void Offset(const VECTOR2I &aOffset)
GR_TEXT_H_ALIGN_T GetHorizJustify() const
virtual void SetVisible(bool aVisible)
void SetTextThickness(int aWidth)
The TextThickness is that set by the user.
GR_TEXT_V_ALIGN_T GetVertJustify() const
void SetTextSize(const VECTOR2I &aNewSize)
virtual void SetText(const wxString &aText)
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
void SetItalic(bool aItalic)
void SetFont(KIFONT::FONT *aFont)
int GetNumberRows() override
bool HaveFontSelection() const
void SetFontSelection(KIFONT::FONT *aFont)
KIFONT::FONT * GetFontSelection(bool aBold, bool aItalic) 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.
Schematic editor (Eeschema) main window.
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,...
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
Searches the item hierarchy to find a SCHEMATIC.
void ClearFieldsAutoplaced()
void AutoAutoplaceFields(SCH_SCREEN *aScreen)
Autoplace fields only if correct to do so automatically.
void SetFields(const std::vector< SCH_FIELD > &aFields)
Set multiple schematic fields.
bool AutoRotateOnPlacement() const
autoRotateOnPlacement
virtual bool AutoRotateOnPlacementSupported() const =0
AutoRotateOnPlacementSupported.
void SetAutoRotateOnPlacement(bool autoRotate=true)
setAutoRotateOnPlacement
void SetShape(LABEL_FLAG_SHAPE aShape) override
static const wxString GetDefaultFieldName(const wxString &aName, bool aUseDefaultName)
LABEL_FLAG_SHAPE GetShape() const override
virtual int GetMandatoryFieldCount()
std::vector< SCH_FIELD > & GetFields()
virtual wxString GetClass() const override=0
Return the class name.
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
bool IsSymbolLikePowerGlobalLabel() const
SCH_FIELD * GetField(MANDATORY_FIELD_T aFieldType)
Return a mandatory field in this symbol.
static HTML_MESSAGE_BOX * ShowSyntaxHelp(wxWindow *aParentWindow)
VECTOR2I GetPosition() const override
TEXT_SPIN_STYLE GetTextSpinStyle() const
virtual void SetTextSpinStyle(TEXT_SPIN_STYLE aSpinStyle)
Set a spin or rotation angle, along with specific horizontal and vertical justification styles with e...
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.
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...
wxString GetShownColumnsAsString()
Get a tokenized string containing the shown column indexes.
std::bitset< 64 > GetShownColumns()
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
This file is part of the common library.
static bool positioningChanged(const SCH_FIELD &a, const SCH_FIELD &b)
int GetPenSizeForBold(int aTextSize)
@ LAYER_SCHEMATIC_BACKGROUND
#define UNIMPLEMENTED_FOR(type)
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
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:...
@ VALUE_FIELD
Field Value of part, i.e. "3.3K".
@ SCH_SYMBOL_LOCATE_POWER_T