Disallow '/' in labels, Step 2: disallow not allowed chars in all labels (local, global, hierarchical, and sheet pin)
Currently, if a old label already containing a '/' (or a space) is edited, it is accepted, but no new not allowed char can be added to the label. (Previously, a sheet pin label was not filtered)
This commit is contained in:
parent
04d1d503ee
commit
0e493a3f91
|
@ -183,10 +183,8 @@ void DIALOG_LABEL_EDITOR::InitDialog()
|
|||
wxTextValidator* validator = (wxTextValidator*) m_textLabel->GetValidator();
|
||||
|
||||
// Add invalid label characters to this list.
|
||||
if( m_CurrentText->GetClass() == wxT( "SCH_LABEL" ) )
|
||||
validator->SetCharExcludes( wxT( " /" ) );
|
||||
else
|
||||
validator->SetCharExcludes( wxT( " " ) );
|
||||
// for any label type but SCH_TEXT_T (that has the multiline allowed)
|
||||
validator->SetCharExcludes( wxT( " /" ) );
|
||||
}
|
||||
|
||||
m_textLabel->SetValue( m_CurrentText->GetText() );
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2010 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 2015 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||
* Copyright (C) 2018 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -48,6 +48,10 @@ DIALOG_SCH_EDIT_SHEET_PIN::DIALOG_SCH_EDIT_SHEET_PIN( wxWindow* parent ) :
|
|||
m_textName->SetFocus();
|
||||
m_sdbSizerOK->SetDefault();
|
||||
|
||||
// Set invalid label characters list:
|
||||
wxTextValidator* validator = static_cast<wxTextValidator*>( m_textName->GetValidator() );
|
||||
validator->SetCharExcludes( " /" );
|
||||
|
||||
// Now all widgets have the size fixed, call FinishDialogSettings
|
||||
FinishDialogSettings();
|
||||
|
||||
|
@ -56,3 +60,15 @@ DIALOG_SCH_EDIT_SHEET_PIN::DIALOG_SCH_EDIT_SHEET_PIN( wxWindow* parent ) :
|
|||
// Force it to be raised
|
||||
Raise();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DIALOG_SCH_EDIT_SHEET_PIN::onOKButton( wxCommandEvent& event )
|
||||
{
|
||||
// Disable wxWidgets message if a pin name has not allowed chars
|
||||
// (It happens only when editing a old sheet pin name that can contains not allowed chars)
|
||||
wxTextValidator* validator = static_cast<wxTextValidator*>( m_textName->GetValidator() );
|
||||
validator->SetCharExcludes( "" );
|
||||
|
||||
event.Skip();
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2010 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 2014 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||
* Copyright (C) 2018 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -41,7 +41,10 @@ class DIALOG_SCH_EDIT_SHEET_PIN : public DIALOG_SCH_EDIT_SHEET_PIN_BASE
|
|||
public:
|
||||
DIALOG_SCH_EDIT_SHEET_PIN( wxWindow* parent );
|
||||
|
||||
void SetLabelName( const wxString& aName ) { m_textName->SetValue( aName ); }
|
||||
// Set the label text in m_textName.
|
||||
// Because m_textName uses a wxTextValidator, the label text must be stored in the
|
||||
// validator string
|
||||
void SetLabelName( const wxString& aName ) { m_labelString = aName; }
|
||||
wxString GetLabelName() const { return m_textName->GetValue(); }
|
||||
|
||||
void SetTextHeight( const wxString& aHeight ) { m_textHeight->SetValue( aHeight ); }
|
||||
|
@ -56,6 +59,9 @@ public:
|
|||
|
||||
void SetTextHeightUnits( const wxString& aUnit ) { m_staticHeightUnits->SetLabel( aUnit ); }
|
||||
void SetTextWidthUnits( const wxString& aUnit ) { m_staticWidthUnits->SetLabel( aUnit ); }
|
||||
|
||||
private:
|
||||
void onOKButton( wxCommandEvent& event ) override;
|
||||
};
|
||||
|
||||
#endif // __dialog_sch_edit_sheet_pin__
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Nov 22 2017)
|
||||
// C++ code generated with wxFormBuilder (version Jul 2 2017)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
// PLEASE DO "NOT" EDIT THIS FILE!
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "dialog_sch_edit_sheet_pin_base.h"
|
||||
|
@ -30,6 +30,8 @@ DIALOG_SCH_EDIT_SHEET_PIN_BASE::DIALOG_SCH_EDIT_SHEET_PIN_BASE( wxWindow* parent
|
|||
fgSizer1->Add( m_staticText1, 0, wxALIGN_CENTER_VERTICAL|wxALL, 6 );
|
||||
|
||||
m_textName = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_textName->SetValidator( wxTextValidator( wxFILTER_EXCLUDE_CHAR_LIST, &m_labelString ) );
|
||||
|
||||
fgSizer1->Add( m_textName, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 6 );
|
||||
|
||||
|
||||
|
@ -93,8 +95,14 @@ DIALOG_SCH_EDIT_SHEET_PIN_BASE::DIALOG_SCH_EDIT_SHEET_PIN_BASE( wxWindow* parent
|
|||
m_mainSizer->Fit( this );
|
||||
|
||||
this->Centre( wxBOTH );
|
||||
|
||||
// Connect Events
|
||||
m_sdbSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SCH_EDIT_SHEET_PIN_BASE::onOKButton ), NULL, this );
|
||||
}
|
||||
|
||||
DIALOG_SCH_EDIT_SHEET_PIN_BASE::~DIALOG_SCH_EDIT_SHEET_PIN_BASE()
|
||||
{
|
||||
// Disconnect Events
|
||||
m_sdbSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SCH_EDIT_SHEET_PIN_BASE::onOKButton ), NULL, this );
|
||||
|
||||
}
|
||||
|
|
|
@ -255,10 +255,10 @@
|
|||
<property name="subclass"></property>
|
||||
<property name="toolbar_pane">0</property>
|
||||
<property name="tooltip"></property>
|
||||
<property name="validator_data_type"></property>
|
||||
<property name="validator_style">wxFILTER_NONE</property>
|
||||
<property name="validator_type">wxDefaultValidator</property>
|
||||
<property name="validator_variable"></property>
|
||||
<property name="validator_data_type">wxString</property>
|
||||
<property name="validator_style">wxFILTER_EXCLUDE_CHAR_LIST</property>
|
||||
<property name="validator_type">wxTextValidator</property>
|
||||
<property name="validator_variable">m_labelString</property>
|
||||
<property name="value"></property>
|
||||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
|
@ -1032,7 +1032,7 @@
|
|||
<event name="OnContextHelpButtonClick"></event>
|
||||
<event name="OnHelpButtonClick"></event>
|
||||
<event name="OnNoButtonClick"></event>
|
||||
<event name="OnOKButtonClick"></event>
|
||||
<event name="OnOKButtonClick">onOKButton</event>
|
||||
<event name="OnSaveButtonClick"></event>
|
||||
<event name="OnYesButtonClick"></event>
|
||||
</object>
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Nov 22 2017)
|
||||
// C++ code generated with wxFormBuilder (version Jul 2 2017)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
// PLEASE DO "NOT" EDIT THIS FILE!
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __DIALOG_SCH_EDIT_SHEET_PIN_BASE_H__
|
||||
|
@ -11,6 +11,8 @@
|
|||
#include <wx/artprov.h>
|
||||
#include <wx/xrc/xmlres.h>
|
||||
#include <wx/intl.h>
|
||||
class DIALOG_SHIM;
|
||||
|
||||
#include "dialog_shim.h"
|
||||
#include <wx/string.h>
|
||||
#include <wx/stattext.h>
|
||||
|
@ -19,6 +21,7 @@
|
|||
#include <wx/colour.h>
|
||||
#include <wx/settings.h>
|
||||
#include <wx/textctrl.h>
|
||||
#include <wx/valtext.h>
|
||||
#include <wx/choice.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/button.h>
|
||||
|
@ -48,8 +51,13 @@ class DIALOG_SCH_EDIT_SHEET_PIN_BASE : public DIALOG_SHIM
|
|||
wxStdDialogButtonSizer* m_sdbSizer;
|
||||
wxButton* m_sdbSizerOK;
|
||||
wxButton* m_sdbSizerCancel;
|
||||
|
||||
// Virtual event handlers, overide them in your derived class
|
||||
virtual void onOKButton( wxCommandEvent& event ) { event.Skip(); }
|
||||
|
||||
|
||||
public:
|
||||
wxString m_labelString;
|
||||
|
||||
DIALOG_SCH_EDIT_SHEET_PIN_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Sheet Pin Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
|
||||
~DIALOG_SCH_EDIT_SHEET_PIN_BASE();
|
||||
|
|
Loading…
Reference in New Issue