diff --git a/eeschema/class_text-label.cpp b/eeschema/class_text-label.cpp index 1c3e3150ca..103cce4a9f 100644 --- a/eeschema/class_text-label.cpp +++ b/eeschema/class_text-label.cpp @@ -84,6 +84,7 @@ SCH_TEXT::SCH_TEXT( const wxPoint& pos, const wxString& text, KICAD_T aType ) : m_Pos = pos; m_Shape = 0; m_IsDangling = FALSE; + m_MultilineAllowed=true; } @@ -243,7 +244,6 @@ void SCH_TEXT::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& aOffset, DrawDanglingSymbol( panel, DC, m_Pos + aOffset, color ); } - /** * Function Save * writes the data structures for this object out to a FILE in "*.brd" format. @@ -257,15 +257,28 @@ bool SCH_TEXT::Save( FILE* aFile ) const if( m_Italic ) shape = "Italic"; + + wxString text=m_Text; + + for (;;) + { + int i=text.find('\n'); + if (i==wxNOT_FOUND) + break; + + text.erase(i,1); + text.insert(i,_("\\n")); + } + if( fprintf( aFile, "Text Notes %-4d %-4d %-4d %-4d %s %d\n%s\n", - m_Pos.x, m_Pos.y, - m_Orient, m_Size.x, - shape, m_Width, - CONV_TO_UTF8( m_Text ) ) == EOF ) + m_Pos.x, m_Pos.y, + m_Orient, m_Size.x, + shape, m_Width, + CONV_TO_UTF8( text ) ) == EOF ) { success = false; } - + return success; } diff --git a/eeschema/class_text-label.h b/eeschema/class_text-label.h index d5e81b9a1f..0e2db2196d 100644 --- a/eeschema/class_text-label.h +++ b/eeschema/class_text-label.h @@ -22,15 +22,16 @@ typedef enum { extern const char* SheetLabelType[]; extern int* TemplateShape[5][4]; - class SCH_TEXT : public SCH_ITEM , public EDA_TextStruct { + public: int m_Layer; int m_Shape; bool m_IsDangling; // TRUE if not connected - + + public: SCH_TEXT( const wxPoint& pos = wxPoint( 0, 0 ), const wxString& text = wxEmptyString, KICAD_T aType = TYPE_SCH_TEXT ); @@ -71,6 +72,8 @@ public: #endif + + }; diff --git a/eeschema/dialog_edit_label.cpp b/eeschema/dialog_edit_label.cpp index 23ecc2dc79..e2259db1cb 100644 --- a/eeschema/dialog_edit_label.cpp +++ b/eeschema/dialog_edit_label.cpp @@ -21,7 +21,22 @@ int DialogLabelEditor::ShowModally( WinEDA_SchematicFrame* parent, SCH_TEXT * CurrentText ) { int ret; - DialogLabelEditor* dialog = new DialogLabelEditor( parent, CurrentText ); + bool multiline; + + switch( CurrentText->Type() ) + { + case TYPE_SCH_GLOBALLABEL: + case TYPE_SCH_HIERLABEL: + case TYPE_SCH_LABEL: + multiline = false; + break; + + default: + multiline = true; + break; + } + + DialogLabelEditor* dialog = new DialogLabelEditor( parent, CurrentText, multiline ); // doing any post construction resizing is better done here than in // OnInitDialog() since it tends to flash/redraw the dialog less. @@ -34,8 +49,8 @@ int DialogLabelEditor::ShowModally( WinEDA_SchematicFrame* parent, SCH_TEXT * C -DialogLabelEditor::DialogLabelEditor( WinEDA_SchematicFrame* parent, SCH_TEXT* CurrentText ) : - DialogLabelEditor_Base( parent ) +DialogLabelEditor::DialogLabelEditor( WinEDA_SchematicFrame* parent, SCH_TEXT* CurrentText,bool multiline ) : + DialogLabelEditor_Base( parent,wxID_ANY,multiline ) { m_Parent = parent; m_CurrentText = CurrentText; diff --git a/eeschema/dialog_edit_label.h b/eeschema/dialog_edit_label.h index b6c2d16a2e..6346a9cd71 100644 --- a/eeschema/dialog_edit_label.h +++ b/eeschema/dialog_edit_label.h @@ -18,7 +18,7 @@ private: protected: // these are protected so that the static ShowModally() gets used. - DialogLabelEditor( WinEDA_SchematicFrame* parent, SCH_TEXT * CurrentText); + DialogLabelEditor( WinEDA_SchematicFrame* parent, SCH_TEXT * CurrentText, bool multiline); ~DialogLabelEditor(){}; diff --git a/eeschema/dialog_edit_label_base.cpp b/eeschema/dialog_edit_label_base.cpp index cc4c884917..b1e73773e7 100644 --- a/eeschema/dialog_edit_label_base.cpp +++ b/eeschema/dialog_edit_label_base.cpp @@ -9,7 +9,7 @@ /////////////////////////////////////////////////////////////////////////// -DialogLabelEditor_Base::DialogLabelEditor_Base( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style ) +DialogLabelEditor_Base::DialogLabelEditor_Base( wxWindow* parent, wxWindowID id, bool multiline,const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style ) { this->SetSizeHints( wxDefaultSize, wxDefaultSize ); @@ -22,7 +22,10 @@ DialogLabelEditor_Base::DialogLabelEditor_Base( wxWindow* parent, wxWindowID id, m_staticText1->Wrap( -1 ); bSizerTextCtrl->Add( m_staticText1, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); - m_TextLabel = new wxTextCtrl( this, wxID_VALUE, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER ); + if (multiline) + m_TextLabel = new wxTextCtrl( this, wxID_VALUE, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER | wxTE_MULTILINE ); + else + 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") ); bSizerTextCtrl->Add( m_TextLabel, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); diff --git a/eeschema/dialog_edit_label_base.h b/eeschema/dialog_edit_label_base.h index fa3b1b2c52..63188a3371 100644 --- a/eeschema/dialog_edit_label_base.h +++ b/eeschema/dialog_edit_label_base.h @@ -57,7 +57,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( 600,216 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + DialogLabelEditor_Base( wxWindow* parent, wxWindowID id = wxID_ANY, bool multiline=false, const wxString& title = _("Text Editor"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 600,216 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DialogLabelEditor_Base(); }; diff --git a/eeschema/load_one_schematic_file.cpp b/eeschema/load_one_schematic_file.cpp index 5878133ae4..3d998ff404 100644 --- a/eeschema/load_one_schematic_file.cpp +++ b/eeschema/load_one_schematic_file.cpp @@ -148,6 +148,20 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, else if( Line[1] == 'D' ) Failed = ReadSchemaDescr( this, Line, f, MsgDiag, &LineCount, screen ); + else if( Line[1] == 'T' ) //text part + { + printf("**** TEXT PART\n"); + SCH_ITEM* Struct; + Struct = ReadTextDescr( f, MsgDiag, Line, sizeof(Line), + &LineCount, version); + if( Struct ) + { + Struct->SetNext( screen->EEDrawList ); + screen->EEDrawList = Struct; + } + else + Failed = true; + } break; diff --git a/eeschema/read_from_file_schematic_items_descriptions.cpp b/eeschema/read_from_file_schematic_items_descriptions.cpp index 686943a521..0507ae50af 100644 --- a/eeschema/read_from_file_schematic_items_descriptions.cpp +++ b/eeschema/read_from_file_schematic_items_descriptions.cpp @@ -132,8 +132,17 @@ SCH_ITEM* ReadTextDescr( FILE* aFile, } else { - SCH_TEXT* TextStruct = - new SCH_TEXT( pos, CONV_FROM_UTF8( text ) ); + wxString val= CONV_FROM_UTF8( text ); + for (;;) + { + int i=val.find(_("\\n")); + if (i==wxNOT_FOUND) + break; + + val.erase(i,2); + val.insert(i,_("\n")); + } + SCH_TEXT* TextStruct = new SCH_TEXT( pos, val ); TextStruct->m_Size.x = TextStruct->m_Size.y = size; TextStruct->m_Orient = orient;