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 ) :
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;
}
......
......@@ -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
};
......
......@@ -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;
......
......@@ -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(){};
......
......@@ -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 );
......
......@@ -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();
};
......
......@@ -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;
......
......@@ -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;
......
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