From 95316beba129c00e6df7b42193add4a7d66e2771 Mon Sep 17 00:00:00 2001 From: charras Date: Tue, 30 Mar 2010 10:10:33 +0000 Subject: [PATCH] fixed other issue in dialog edit multiline text --- eeschema/dialog_edit_label.cpp | 19 ++- eeschema/dialog_edit_label.h | 1 + eeschema/dialog_edit_label_base.cpp | 25 +++- eeschema/dialog_edit_label_base.fbp | 172 +++++++++++++++++++--------- eeschema/dialog_edit_label_base.h | 8 +- 5 files changed, 151 insertions(+), 74 deletions(-) diff --git a/eeschema/dialog_edit_label.cpp b/eeschema/dialog_edit_label.cpp index b5f62d9483..6a29d545b7 100644 --- a/eeschema/dialog_edit_label.cpp +++ b/eeschema/dialog_edit_label.cpp @@ -55,20 +55,15 @@ void DialogLabelEditor::InitDialog() if( m_CurrentText->m_MultilineAllowed ) { - /* Multiline text edit control must be created because changing the text - * control style to multiline must be done when the control is created. - */ - m_textControlSizer->Detach( m_textLabel ); - m_textLabel->Destroy(); - m_textLabel = NULL; - m_textLabel = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, - wxDefaultSize, wxTE_MULTILINE | wxTE_PROCESS_ENTER ); - m_textLabel->SetToolTip( _("Enter the text to be used within the schematic") ); - m_textLabel->SetMinSize( wxSize( -1, 60 ) ); - m_textControlSizer->Insert( 1, m_textLabel, 0, wxLEFT | wxEXPAND, 3 ); - m_textControlSizer->RecalcSizes(); + m_textLabel = m_textLabelMultiLine; + m_textLabelSingleLine->Show(false); multiLine = true; } + else + { + m_textLabel = m_textLabelSingleLine; + m_textLabelMultiLine->Show(false); + } m_textLabel->SetValue( m_CurrentText->m_Text ); m_textLabel->SetFocus(); diff --git a/eeschema/dialog_edit_label.h b/eeschema/dialog_edit_label.h index 1ffedc4821..c95d51c0a0 100644 --- a/eeschema/dialog_edit_label.h +++ b/eeschema/dialog_edit_label.h @@ -15,6 +15,7 @@ class DialogLabelEditor : public DialogLabelEditor_Base private: WinEDA_SchematicFrame* m_Parent; SCH_TEXT* m_CurrentText; + wxTextCtrl * m_textLabel; public: DialogLabelEditor( WinEDA_SchematicFrame* parent, SCH_TEXT* aTextItem ); diff --git a/eeschema/dialog_edit_label_base.cpp b/eeschema/dialog_edit_label_base.cpp index 0845c11e39..8df3d12af7 100644 --- a/eeschema/dialog_edit_label_base.cpp +++ b/eeschema/dialog_edit_label_base.cpp @@ -17,6 +17,8 @@ DialogLabelEditor_Base::DialogLabelEditor_Base( wxWindow* parent, wxWindowID id, bMainSizer = new wxBoxSizer( wxVERTICAL ); m_textControlSizer = new wxFlexGridSizer( 2, 2, 3, 3 ); + m_textControlSizer->AddGrowableCol( 1 ); + m_textControlSizer->AddGrowableRow( 0 ); m_textControlSizer->SetFlexibleDirection( wxBOTH ); m_textControlSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); @@ -24,10 +26,20 @@ DialogLabelEditor_Base::DialogLabelEditor_Base( wxWindow* parent, wxWindowID id, m_staticText1->Wrap( -1 ); m_textControlSizer->Add( m_staticText1, 0, wxRIGHT, 3 ); - m_textLabel = new wxTextCtrl( this, wxID_VALUE, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER ); - m_textLabel->SetToolTip( _("Enter the text to be used within the schematic") ); + wxBoxSizer* bSizeText; + bSizeText = new wxBoxSizer( wxVERTICAL ); - m_textControlSizer->Add( m_textLabel, 0, wxEXPAND|wxLEFT, 3 ); + m_textLabelSingleLine = new wxTextCtrl( this, wxID_VALUESINGLE, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER ); + m_textLabelSingleLine->SetToolTip( _("Enter the text to be used within the schematic") ); + + bSizeText->Add( m_textLabelSingleLine, 0, wxEXPAND|wxLEFT, 3 ); + + m_textLabelMultiLine = new wxTextCtrl( this, wxID_VALUEMULTI, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_PROCESS_ENTER ); + m_textLabelMultiLine->SetToolTip( _("Enter the text to be used within the schematic") ); + + bSizeText->Add( m_textLabelMultiLine, 1, wxEXPAND|wxLEFT, 5 ); + + m_textControlSizer->Add( bSizeText, 1, wxEXPAND, 5 ); m_SizeTitle = new wxStaticText( this, wxID_ANY, _("&Size:"), wxDefaultPosition, wxDefaultSize, 0 ); m_SizeTitle->Wrap( -1 ); @@ -80,10 +92,10 @@ DialogLabelEditor_Base::DialogLabelEditor_Base( wxWindow* parent, wxWindowID id, this->SetSizer( bMainSizer ); this->Layout(); - bMainSizer->Fit( this ); // Connect Events - m_textLabel->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DialogLabelEditor_Base::OnEnterKey ), NULL, this ); + m_textLabelSingleLine->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DialogLabelEditor_Base::OnEnterKey ), NULL, this ); + m_textLabelMultiLine->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DialogLabelEditor_Base::OnEnterKey ), NULL, this ); m_sdbSizer1Cancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DialogLabelEditor_Base::OnCancelClick ), NULL, this ); m_sdbSizer1OK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DialogLabelEditor_Base::OnOkClick ), NULL, this ); } @@ -91,7 +103,8 @@ DialogLabelEditor_Base::DialogLabelEditor_Base( wxWindow* parent, wxWindowID id, DialogLabelEditor_Base::~DialogLabelEditor_Base() { // Disconnect Events - m_textLabel->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DialogLabelEditor_Base::OnEnterKey ), NULL, this ); + m_textLabelSingleLine->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DialogLabelEditor_Base::OnEnterKey ), NULL, this ); + m_textLabelMultiLine->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DialogLabelEditor_Base::OnEnterKey ), NULL, this ); m_sdbSizer1Cancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DialogLabelEditor_Base::OnCancelClick ), NULL, this ); m_sdbSizer1OK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DialogLabelEditor_Base::OnOkClick ), NULL, this ); } diff --git a/eeschema/dialog_edit_label_base.fbp b/eeschema/dialog_edit_label_base.fbp index 0dd2949570..4d3210eb73 100644 --- a/eeschema/dialog_edit_label_base.fbp +++ b/eeschema/dialog_edit_label_base.fbp @@ -32,7 +32,7 @@ DialogLabelEditor_Base - -1,-1 + 359,347 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER Text Editor @@ -82,8 +82,8 @@ 2 wxBOTH - - + 1 + 0 3 m_textControlSizer @@ -144,57 +144,123 @@ 3 - wxEXPAND|wxLEFT - 0 - - - - 1 - - - 0 - wxID_VALUE - - 0 + wxEXPAND + 1 + - m_textLabel - protected - - - wxTE_PROCESS_ENTER - - Enter the text to be used within the schematic - - - - - - - - - - - - - - - - - - - - - - - - - - - - OnEnterKey - - - + bSizeText + wxVERTICAL + none + + 3 + wxEXPAND|wxLEFT + 0 + + + + 1 + + + 0 + wxID_VALUESINGLE + + 0 + + m_textLabelSingleLine + protected + + + wxTE_PROCESS_ENTER + + Enter the text to be used within the schematic + + + + + + + + + + + + + + + + + + + + + + + + + + + + OnEnterKey + + + + + + + 3 + wxEXPAND|wxLEFT + 1 + + + + 1 + + + 0 + wxID_VALUEMULTI + + 0 + + m_textLabelMultiLine + protected + + + wxTE_MULTILINE|wxTE_PROCESS_ENTER + + Enter the text to be used within the schematic + + + + + + + + + + + + + + + + + + + + + + + + + + + + OnEnterKey + + + + + diff --git a/eeschema/dialog_edit_label_base.h b/eeschema/dialog_edit_label_base.h index d6c93301a2..74fe3ac917 100644 --- a/eeschema/dialog_edit_label_base.h +++ b/eeschema/dialog_edit_label_base.h @@ -34,13 +34,15 @@ class DialogLabelEditor_Base : public wxDialog protected: enum { - wxID_VALUE = 1000, + wxID_VALUESINGLE = 1000, + wxID_VALUEMULTI, wxID_SIZE, }; wxFlexGridSizer* m_textControlSizer; wxStaticText* m_staticText1; - wxTextCtrl* m_textLabel; + wxTextCtrl* m_textLabelSingleLine; + wxTextCtrl* m_textLabelMultiLine; wxStaticText* m_SizeTitle; wxTextCtrl* m_TextSize; wxStaticText* m_staticSizeUnits; @@ -58,7 +60,7 @@ class DialogLabelEditor_Base : public wxDialog public: - DialogLabelEditor_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 ); + DialogLabelEditor_Base( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Text Editor"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 359,347 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DialogLabelEditor_Base(); };