diff --git a/eeschema/dialogs/dialog_edit_label.cpp b/eeschema/dialogs/dialog_edit_label.cpp index 2f04451fc9..445497d6a3 100644 --- a/eeschema/dialogs/dialog_edit_label.cpp +++ b/eeschema/dialogs/dialog_edit_label.cpp @@ -72,7 +72,7 @@ public: private: virtual void OnEnterKey( wxCommandEvent& aEvent ) override; - void OnCharHook( wxKeyEvent& aEvent ); + void OnCharHook( wxKeyEvent& aEvt ); bool TransferDataToWindow() override; bool TransferDataFromWindow() override; @@ -119,7 +119,7 @@ DIALOG_LABEL_EDITOR::DIALOG_LABEL_EDITOR( SCH_EDIT_FRAME* aParent, SCH_TEXT* aTe if( m_CurrentText->IsMultilineAllowed() ) { m_activeTextCtrl = m_valueMultiLine; - m_activeTextEntry = m_valueMultiLine; + m_activeTextEntry = nullptr; m_labelSingleLine->Show( false ); m_valueSingleLine->Show( false ); m_labelCombo->Show( false ); m_valueCombo->Show( false ); @@ -183,7 +183,10 @@ bool DIALOG_LABEL_EDITOR::TransferDataToWindow() if( !wxDialog::TransferDataToWindow() ) return false; - m_activeTextEntry->SetValue( UnescapeString( m_CurrentText->GetText() ) ); + if( m_activeTextEntry ) + m_activeTextEntry->SetValue( UnescapeString( m_CurrentText->GetText() ) ); + else + m_valueMultiLine->SetValue( UnescapeString( m_CurrentText->GetText() ) ); if( m_valueCombo->IsShown() ) { @@ -240,28 +243,70 @@ void DIALOG_LABEL_EDITOR::OnEnterKey( wxCommandEvent& aEvent ) } +static bool isCtrl( int aChar, const wxKeyEvent& e ) +{ + return e.GetKeyCode() == aChar && e.ControlDown() && !e.AltDown() && !e.ShiftDown() && !e.MetaDown(); +} + +static bool isShiftCtrl( int aChar, const wxKeyEvent& e ) +{ + return e.GetKeyCode() == aChar && e.ControlDown() && !e.AltDown() && e.ShiftDown() && !e.MetaDown(); +} + /*! * wxEVT_CHAR_HOOK event handler for multi-line control */ -void DIALOG_LABEL_EDITOR::OnCharHook( wxKeyEvent& aEvent ) +void DIALOG_LABEL_EDITOR::OnCharHook( wxKeyEvent& aEvt ) { - if( aEvent.GetKeyCode() == WXK_TAB ) + if( aEvt.GetKeyCode() == WXK_TAB ) { - int flags = 0; - if( !aEvent.ShiftDown() ) - flags |= wxNavigationKeyEvent::IsForward; - if( aEvent.ControlDown() ) - flags |= wxNavigationKeyEvent::WinChange; - NavigateIn( flags ); + if( aEvt.ControlDown() ) + { + int flags = 0; + if( !aEvt.ShiftDown() ) + flags |= wxNavigationKeyEvent::IsForward; + NavigateIn( flags ); + } + else + { + m_valueMultiLine->Tab(); + } } - else if( aEvent.GetKeyCode() == WXK_RETURN && aEvent.ShiftDown() ) + else if( aEvt.GetKeyCode() == WXK_RETURN && aEvt.ShiftDown() ) { wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) ); } + else if( m_valueMultiLine->IsShown() && isCtrl( 'Z', aEvt ) ) + { + m_valueMultiLine->Undo(); + } +#if defined( __WXMAC__ ) + else if( isShiftCtrl( 'Z', aEvt ) ) + { + m_valueMultiLine->Redo(); + } +#else + else if( isCtrl( 'Y', aEvt ) ) + { + m_valueMultiLine->Redo(); + } +#endif + else if( isCtrl( 'X', aEvt ) ) + { + m_valueMultiLine->Cut(); + } + else if( isCtrl( 'C', aEvt ) ) + { + m_valueMultiLine->Copy(); + } + else if( isCtrl( 'V', aEvt ) ) + { + m_valueMultiLine->Paste(); + } else { - aEvent.Skip(); + aEvt.Skip(); } } @@ -284,7 +329,7 @@ bool DIALOG_LABEL_EDITOR::TransferDataFromWindow() // Escape string only if is is a label. For a simple graphic text do not change anything if( m_CurrentText->Type() == SCH_TEXT_T ) - text = m_activeTextEntry->GetValue(); + text = m_valueMultiLine->GetValue(); else text = EscapeString( m_activeTextEntry->GetValue(), CTX_NETNAME ); diff --git a/eeschema/dialogs/dialog_edit_label_base.cpp b/eeschema/dialogs/dialog_edit_label_base.cpp index 1bee819d14..a40b592111 100644 --- a/eeschema/dialogs/dialog_edit_label_base.cpp +++ b/eeschema/dialogs/dialog_edit_label_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 26 2018) +// C++ code generated with wxFormBuilder (version Dec 30 2017) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -12,103 +12,131 @@ DIALOG_LABEL_EDITOR_BASE::DIALOG_LABEL_EDITOR_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) { this->SetSizeHints( wxDefaultSize, wxDefaultSize ); - + wxBoxSizer* bMainSizer; bMainSizer = new wxBoxSizer( wxVERTICAL ); - + m_textEntrySizer = new wxFlexGridSizer( 4, 2, 3, 3 ); m_textEntrySizer->AddGrowableCol( 1 ); m_textEntrySizer->AddGrowableRow( 1 ); m_textEntrySizer->SetFlexibleDirection( wxBOTH ); m_textEntrySizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - + m_labelSingleLine = new wxStaticText( this, wxID_ANY, _("Label:"), wxDefaultPosition, wxDefaultSize, 0 ); m_labelSingleLine->Wrap( -1 ); m_labelSingleLine->SetToolTip( _("Enter the text to be used within the schematic") ); - + m_textEntrySizer->Add( m_labelSingleLine, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 3 ); - + m_valueSingleLine = new wxTextCtrl( this, wxID_VALUESINGLE, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER|wxTE_RICH ); m_valueSingleLine->SetMinSize( wxSize( 360,-1 ) ); - + m_textEntrySizer->Add( m_valueSingleLine, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT, 3 ); - + m_labelMultiLine = new wxStaticText( this, wxID_ANY, _("Text:"), wxDefaultPosition, wxDefaultSize, 0 ); m_labelMultiLine->Wrap( -1 ); m_textEntrySizer->Add( m_labelMultiLine, 0, wxRIGHT, 5 ); - - m_valueMultiLine = new wxTextCtrl( this, wxID_VALUEMULTI, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE ); - m_valueMultiLine->SetMinSize( wxSize( 480,72 ) ); - - m_textEntrySizer->Add( m_valueMultiLine, 1, wxEXPAND|wxBOTTOM|wxLEFT, 3 ); - + + m_valueMultiLine = new wxStyledTextCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString ); + m_valueMultiLine->SetUseTabs( true ); + m_valueMultiLine->SetTabWidth( 4 ); + m_valueMultiLine->SetIndent( 4 ); + m_valueMultiLine->SetTabIndents( false ); + m_valueMultiLine->SetBackSpaceUnIndents( false ); + m_valueMultiLine->SetViewEOL( false ); + m_valueMultiLine->SetViewWhiteSpace( false ); + m_valueMultiLine->SetMarginWidth( 2, 0 ); + m_valueMultiLine->SetIndentationGuides( false ); + m_valueMultiLine->SetMarginWidth( 1, 0 ); + m_valueMultiLine->SetMarginWidth( 0, 0 ); + m_valueMultiLine->MarkerDefine( wxSTC_MARKNUM_FOLDER, wxSTC_MARK_BOXPLUS ); + m_valueMultiLine->MarkerSetBackground( wxSTC_MARKNUM_FOLDER, wxColour( wxT("BLACK") ) ); + m_valueMultiLine->MarkerSetForeground( wxSTC_MARKNUM_FOLDER, wxColour( wxT("WHITE") ) ); + m_valueMultiLine->MarkerDefine( wxSTC_MARKNUM_FOLDEROPEN, wxSTC_MARK_BOXMINUS ); + m_valueMultiLine->MarkerSetBackground( wxSTC_MARKNUM_FOLDEROPEN, wxColour( wxT("BLACK") ) ); + m_valueMultiLine->MarkerSetForeground( wxSTC_MARKNUM_FOLDEROPEN, wxColour( wxT("WHITE") ) ); + m_valueMultiLine->MarkerDefine( wxSTC_MARKNUM_FOLDERSUB, wxSTC_MARK_EMPTY ); + m_valueMultiLine->MarkerDefine( wxSTC_MARKNUM_FOLDEREND, wxSTC_MARK_BOXPLUS ); + m_valueMultiLine->MarkerSetBackground( wxSTC_MARKNUM_FOLDEREND, wxColour( wxT("BLACK") ) ); + m_valueMultiLine->MarkerSetForeground( wxSTC_MARKNUM_FOLDEREND, wxColour( wxT("WHITE") ) ); + m_valueMultiLine->MarkerDefine( wxSTC_MARKNUM_FOLDEROPENMID, wxSTC_MARK_BOXMINUS ); + m_valueMultiLine->MarkerSetBackground( wxSTC_MARKNUM_FOLDEROPENMID, wxColour( wxT("BLACK") ) ); + m_valueMultiLine->MarkerSetForeground( wxSTC_MARKNUM_FOLDEROPENMID, wxColour( wxT("WHITE") ) ); + m_valueMultiLine->MarkerDefine( wxSTC_MARKNUM_FOLDERMIDTAIL, wxSTC_MARK_EMPTY ); + m_valueMultiLine->MarkerDefine( wxSTC_MARKNUM_FOLDERTAIL, wxSTC_MARK_EMPTY ); + m_valueMultiLine->SetSelBackground( true, wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT ) ); + m_valueMultiLine->SetSelForeground( true, wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHTTEXT ) ); + m_valueMultiLine->SetMinSize( wxSize( 480,100 ) ); + + m_textEntrySizer->Add( m_valueMultiLine, 1, wxEXPAND | wxALL, 5 ); + m_labelCombo = new wxStaticText( this, wxID_ANY, _("Label:"), wxDefaultPosition, wxDefaultSize, 0 ); m_labelCombo->Wrap( -1 ); m_textEntrySizer->Add( m_labelCombo, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); - - m_valueCombo = new wxComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxTE_PROCESS_ENTER ); + + m_valueCombo = new wxComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxTE_PROCESS_ENTER ); m_valueCombo->SetMinSize( wxSize( 360,-1 ) ); - + m_textEntrySizer->Add( m_valueCombo, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); - + m_textSizeLabel = new wxStaticText( this, wxID_ANY, _("Text Size:"), wxDefaultPosition, wxDefaultSize, 0 ); m_textSizeLabel->Wrap( -1 ); m_textEntrySizer->Add( m_textSizeLabel, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 3 ); - + wxBoxSizer* bSizeCtrlSizer; bSizeCtrlSizer = new wxBoxSizer( wxHORIZONTAL ); - + m_textSizeCtrl = new wxTextCtrl( this, wxID_SIZE, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); bSizeCtrlSizer->Add( m_textSizeCtrl, 0, wxEXPAND|wxLEFT|wxRIGHT, 3 ); - + m_textSizeUnits = new wxStaticText( this, wxID_ANY, _("units"), wxDefaultPosition, wxDefaultSize, 0 ); m_textSizeUnits->Wrap( -1 ); bSizeCtrlSizer->Add( m_textSizeUnits, 0, wxALIGN_CENTER_VERTICAL, 2 ); - - + + m_textEntrySizer->Add( bSizeCtrlSizer, 1, wxEXPAND|wxALIGN_CENTER_VERTICAL, 3 ); - - + + bMainSizer->Add( m_textEntrySizer, 1, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 12 ); - + wxBoxSizer* m_OptionsSizer; m_OptionsSizer = new wxBoxSizer( wxHORIZONTAL ); - + wxString m_TextOrientChoices[] = { _("Right"), _("Up"), _("Left"), _("Down") }; int m_TextOrientNChoices = sizeof( m_TextOrientChoices ) / sizeof( wxString ); m_TextOrient = new wxRadioBox( this, wxID_ANY, _("Orientation"), wxDefaultPosition, wxDefaultSize, m_TextOrientNChoices, m_TextOrientChoices, 1, wxRA_SPECIFY_COLS ); m_TextOrient->SetSelection( 0 ); m_OptionsSizer->Add( m_TextOrient, 1, wxRIGHT|wxTOP|wxEXPAND, 3 ); - + wxString m_TextStyleChoices[] = { _("Normal"), _("Italic"), _("Bold"), _("Bold and italic") }; int m_TextStyleNChoices = sizeof( m_TextStyleChoices ) / sizeof( wxString ); m_TextStyle = new wxRadioBox( this, wxID_ANY, _("Style"), wxDefaultPosition, wxDefaultSize, m_TextStyleNChoices, m_TextStyleChoices, 1, wxRA_SPECIFY_COLS ); m_TextStyle->SetSelection( 3 ); m_OptionsSizer->Add( m_TextStyle, 1, wxLEFT|wxRIGHT|wxTOP|wxEXPAND, 3 ); - + wxString m_TextShapeChoices[] = { _("Input"), _("Output"), _("Bidirectional"), _("Tri-state"), _("Passive") }; int m_TextShapeNChoices = sizeof( m_TextShapeChoices ) / sizeof( wxString ); m_TextShape = new wxRadioBox( this, wxID_ANY, _("Shape"), wxDefaultPosition, wxDefaultSize, m_TextShapeNChoices, m_TextShapeChoices, 1, wxRA_SPECIFY_COLS ); m_TextShape->SetSelection( 3 ); m_OptionsSizer->Add( m_TextShape, 1, wxEXPAND|wxTOP|wxLEFT, 3 ); - - + + bMainSizer->Add( m_OptionsSizer, 0, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 10 ); - + m_sdbSizer1 = new wxStdDialogButtonSizer(); m_sdbSizer1OK = new wxButton( this, wxID_OK ); m_sdbSizer1->AddButton( m_sdbSizer1OK ); m_sdbSizer1Cancel = new wxButton( this, wxID_CANCEL ); m_sdbSizer1->AddButton( m_sdbSizer1Cancel ); m_sdbSizer1->Realize(); - + bMainSizer->Add( m_sdbSizer1, 0, wxALL|wxEXPAND, 5 ); - - + + this->SetSizer( bMainSizer ); this->Layout(); bMainSizer->Fit( this ); - + // Connect Events m_valueSingleLine->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_LABEL_EDITOR_BASE::OnEnterKey ), NULL, this ); m_valueCombo->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_LABEL_EDITOR_BASE::OnEnterKey ), NULL, this ); @@ -119,5 +147,5 @@ DIALOG_LABEL_EDITOR_BASE::~DIALOG_LABEL_EDITOR_BASE() // Disconnect Events m_valueSingleLine->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_LABEL_EDITOR_BASE::OnEnterKey ), NULL, this ); m_valueCombo->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_LABEL_EDITOR_BASE::OnEnterKey ), NULL, this ); - + } diff --git a/eeschema/dialogs/dialog_edit_label_base.fbp b/eeschema/dialogs/dialog_edit_label_base.fbp index 1882c41b29..72c7a5e020 100644 --- a/eeschema/dialogs/dialog_edit_label_base.fbp +++ b/eeschema/dialogs/dialog_edit_label_base.fbp @@ -1,6 +1,6 @@ - + C++ @@ -14,7 +14,6 @@ dialog_edit_label_base 1000 none - 1 dialog_edit_label_base @@ -53,6 +52,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + bMainSizer @@ -107,7 +142,6 @@ 0 wxID_ANY Label: - 0 0 @@ -133,6 +167,29 @@ -1 + + + + + + + + + + + + + + + + + + + + + + + @@ -197,7 +254,33 @@ + + + + + + + + + + + + + + + + + + + + + + + OnEnterKey + + + @@ -233,7 +316,6 @@ 0 wxID_ANY Text: - 0 0 @@ -259,13 +341,36 @@ -1 + + + + + + + + + + + + + + + + + + + + + + + - 3 - wxEXPAND|wxBOTTOM|wxLEFT + 5 + wxEXPAND | wxALL 1 - + 1 1 1 @@ -274,6 +379,7 @@ + 0 @@ -289,17 +395,19 @@ 1 1 + 0 0 0 - wxID_VALUEMULTI + wxID_ANY + 0 + 0 0 - 0 - 480,72 + 480,100 1 m_valueMultiLine 1 @@ -311,18 +419,40 @@ Resizable 1 - wxTE_MULTILINE - + ; forward_declare + 0 + 4 0 - - wxFILTER_NONE - wxDefaultValidator - - + 1 + 0 + 0 + + + + + + + + + + + + + + + + + + + + + + + @@ -358,7 +488,6 @@ 0 wxID_ANY Label: - 0 0 @@ -384,6 +513,29 @@ -1 + + + + + + + + + + + + + + + + + + + + + + + @@ -449,7 +601,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + OnEnterKey + @@ -485,7 +664,6 @@ 0 wxID_ANY Text Size: - 0 0 @@ -511,6 +689,29 @@ -1 + + + + + + + + + + + + + + + + + + + + + + + @@ -584,6 +785,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -619,7 +847,6 @@ 0 wxID_ANY units - 0 0 @@ -645,6 +872,29 @@ -1 + + + + + + + + + + + + + + + + + + + + + + + @@ -724,6 +974,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -790,6 +1064,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -856,6 +1154,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -876,6 +1198,14 @@ m_sdbSizer1 protected + + + + + + + + diff --git a/eeschema/dialogs/dialog_edit_label_base.h b/eeschema/dialogs/dialog_edit_label_base.h index cc84ae606a..49a3929842 100644 --- a/eeschema/dialogs/dialog_edit_label_base.h +++ b/eeschema/dialogs/dialog_edit_label_base.h @@ -1,11 +1,12 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 26 2018) +// C++ code generated with wxFormBuilder (version Dec 30 2017) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// -#pragma once +#ifndef __DIALOG_EDIT_LABEL_BASE_H__ +#define __DIALOG_EDIT_LABEL_BASE_H__ #include #include @@ -18,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -32,20 +34,19 @@ class DIALOG_LABEL_EDITOR_BASE : public DIALOG_SHIM { private: - + protected: enum { wxID_VALUESINGLE = 1000, - wxID_VALUEMULTI, wxID_SIZE }; - + wxFlexGridSizer* m_textEntrySizer; wxStaticText* m_labelSingleLine; wxTextCtrl* m_valueSingleLine; wxStaticText* m_labelMultiLine; - wxTextCtrl* m_valueMultiLine; + wxStyledTextCtrl* m_valueMultiLine; wxStaticText* m_labelCombo; wxComboBox* m_valueCombo; wxStaticText* m_textSizeLabel; @@ -57,15 +58,16 @@ class DIALOG_LABEL_EDITOR_BASE : public DIALOG_SHIM wxStdDialogButtonSizer* m_sdbSizer1; wxButton* m_sdbSizer1OK; wxButton* m_sdbSizer1Cancel; - + // Virtual event handlers, overide them in your derived class virtual void OnEnterKey( wxCommandEvent& event ) { event.Skip(); } - - + + public: - - DIALOG_LABEL_EDITOR_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Text Editor"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + + DIALOG_LABEL_EDITOR_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Text Editor"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DIALOG_LABEL_EDITOR_BASE(); - + }; +#endif //__DIALOG_EDIT_LABEL_BASE_H__