Commit 1f7fc494 authored by drannou's avatar drannou

multiline feature for eeschema with 'save schematic' bug fix

parent 4757c175
...@@ -84,6 +84,7 @@ SCH_TEXT::SCH_TEXT( const wxPoint& pos, const wxString& text, KICAD_T aType ) : ...@@ -84,6 +84,7 @@ SCH_TEXT::SCH_TEXT( const wxPoint& pos, const wxString& text, KICAD_T aType ) :
m_Pos = pos; m_Pos = pos;
m_Shape = 0; m_Shape = 0;
m_IsDangling = FALSE; m_IsDangling = FALSE;
m_MultilineAllowed=true;
} }
...@@ -243,7 +244,6 @@ void SCH_TEXT::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& aOffset, ...@@ -243,7 +244,6 @@ void SCH_TEXT::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& aOffset,
DrawDanglingSymbol( panel, DC, m_Pos + aOffset, color ); DrawDanglingSymbol( panel, DC, m_Pos + aOffset, color );
} }
/** /**
* Function Save * Function Save
* writes the data structures for this object out to a FILE in "*.brd" format. * writes the data structures for this object out to a FILE in "*.brd" format.
...@@ -257,11 +257,24 @@ bool SCH_TEXT::Save( FILE* aFile ) const ...@@ -257,11 +257,24 @@ bool SCH_TEXT::Save( FILE* aFile ) const
if( m_Italic ) if( m_Italic )
shape = "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", if( fprintf( aFile, "Text Notes %-4d %-4d %-4d %-4d %s %d\n%s\n",
m_Pos.x, m_Pos.y, m_Pos.x, m_Pos.y,
m_Orient, m_Size.x, m_Orient, m_Size.x,
shape, m_Width, shape, m_Width,
CONV_TO_UTF8( m_Text ) ) == EOF ) CONV_TO_UTF8( text ) ) == EOF )
{ {
success = false; success = false;
} }
......
...@@ -22,15 +22,16 @@ typedef enum { ...@@ -22,15 +22,16 @@ typedef enum {
extern const char* SheetLabelType[]; extern const char* SheetLabelType[];
extern int* TemplateShape[5][4]; extern int* TemplateShape[5][4];
class SCH_TEXT : public SCH_ITEM class SCH_TEXT : public SCH_ITEM
, public EDA_TextStruct , public EDA_TextStruct
{ {
public: public:
int m_Layer; int m_Layer;
int m_Shape; int m_Shape;
bool m_IsDangling; // TRUE if not connected bool m_IsDangling; // TRUE if not connected
public: public:
SCH_TEXT( const wxPoint& pos = wxPoint( 0, 0 ), const wxString& text = wxEmptyString, SCH_TEXT( const wxPoint& pos = wxPoint( 0, 0 ), const wxString& text = wxEmptyString,
KICAD_T aType = TYPE_SCH_TEXT ); KICAD_T aType = TYPE_SCH_TEXT );
...@@ -71,6 +72,8 @@ public: ...@@ -71,6 +72,8 @@ public:
#endif #endif
}; };
......
...@@ -21,7 +21,22 @@ ...@@ -21,7 +21,22 @@
int DialogLabelEditor::ShowModally( WinEDA_SchematicFrame* parent, SCH_TEXT * CurrentText ) int DialogLabelEditor::ShowModally( WinEDA_SchematicFrame* parent, SCH_TEXT * CurrentText )
{ {
int ret; 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 // doing any post construction resizing is better done here than in
// OnInitDialog() since it tends to flash/redraw the dialog less. // OnInitDialog() since it tends to flash/redraw the dialog less.
...@@ -34,8 +49,8 @@ int DialogLabelEditor::ShowModally( WinEDA_SchematicFrame* parent, SCH_TEXT * C ...@@ -34,8 +49,8 @@ int DialogLabelEditor::ShowModally( WinEDA_SchematicFrame* parent, SCH_TEXT * C
DialogLabelEditor::DialogLabelEditor( WinEDA_SchematicFrame* parent, SCH_TEXT* CurrentText ) : DialogLabelEditor::DialogLabelEditor( WinEDA_SchematicFrame* parent, SCH_TEXT* CurrentText,bool multiline ) :
DialogLabelEditor_Base( parent ) DialogLabelEditor_Base( parent,wxID_ANY,multiline )
{ {
m_Parent = parent; m_Parent = parent;
m_CurrentText = CurrentText; m_CurrentText = CurrentText;
......
...@@ -18,7 +18,7 @@ private: ...@@ -18,7 +18,7 @@ private:
protected: protected:
// these are protected so that the static ShowModally() gets used. // 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(){}; ~DialogLabelEditor(){};
......
...@@ -9,7 +9,7 @@ ...@@ -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 ); this->SetSizeHints( wxDefaultSize, wxDefaultSize );
...@@ -22,6 +22,9 @@ DialogLabelEditor_Base::DialogLabelEditor_Base( wxWindow* parent, wxWindowID id, ...@@ -22,6 +22,9 @@ DialogLabelEditor_Base::DialogLabelEditor_Base( wxWindow* parent, wxWindowID id,
m_staticText1->Wrap( -1 ); m_staticText1->Wrap( -1 );
bSizerTextCtrl->Add( m_staticText1, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); bSizerTextCtrl->Add( m_staticText1, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
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 = new wxTextCtrl( this, wxID_VALUE, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
m_TextLabel->SetToolTip( _("Enter the text to be used within the schematic") ); m_TextLabel->SetToolTip( _("Enter the text to be used within the schematic") );
......
...@@ -57,7 +57,7 @@ class DialogLabelEditor_Base : public wxDialog ...@@ -57,7 +57,7 @@ class DialogLabelEditor_Base : public wxDialog
public: 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(); ~DialogLabelEditor_Base();
}; };
......
...@@ -148,6 +148,20 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, ...@@ -148,6 +148,20 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen,
else if( Line[1] == 'D' ) else if( Line[1] == 'D' )
Failed = ReadSchemaDescr( this, Line, f, MsgDiag, &LineCount, Failed = ReadSchemaDescr( this, Line, f, MsgDiag, &LineCount,
screen ); 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; break;
......
...@@ -132,8 +132,17 @@ SCH_ITEM* ReadTextDescr( FILE* aFile, ...@@ -132,8 +132,17 @@ SCH_ITEM* ReadTextDescr( FILE* aFile,
} }
else else
{ {
SCH_TEXT* TextStruct = wxString val= CONV_FROM_UTF8( text );
new SCH_TEXT( pos, 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_Size.x = TextStruct->m_Size.y = size;
TextStruct->m_Orient = orient; TextStruct->m_Orient = orient;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment