Loading common/base_struct.cpp +56 −33 Original line number Diff line number Diff line Loading @@ -171,7 +171,7 @@ EDA_TextStruct::EDA_TextStruct( const wxString& text ) m_Orient = 0; /* Orient in 0.1 degrees */ m_Attributs = 0; m_Mirror = false; // display mirror if true m_HJustify = GR_TEXT_HJUSTIFY_CENTER; m_HJustify = GR_TEXT_HJUSTIFY_LEFT; m_VJustify = GR_TEXT_VJUSTIFY_CENTER; /* Justifications Horiz et Vert du texte */ m_Width = 0; /* thickness */ m_Italic = false; /* true = italic shape */ Loading Loading @@ -264,7 +264,6 @@ void EDA_TextStruct::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, int aDrawMode, GRFillMode aDisplayMode, EDA_Colors aAnchor_color ) /***************************************************************/ /** Function Draw * @param aPanel = the current DrawPanel * @param aDC = the current Device Context Loading @@ -274,10 +273,30 @@ void EDA_TextStruct::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, * @param aDisplayMode = FILAIRE, FILLED or SKETCH * @param EDA_Colors aAnchor_color = anchor color ( UNSPECIFIED_COLOR = do not draw anchor ). */ { int width; wxPoint pos = m_Pos; wxArrayString* list = wxStringSplit( m_Text, '\n'); for( int i=0;i<list->Count();i++) { wxString txt = list->Item(i); wxSize size=DrawOneLine(aPanel,aDC,aOffset,aColor,aDrawMode,aDisplayMode,aAnchor_color,txt,pos); pos.y+=1.5*(size.y); } delete (list); } width = m_Width; wxSize EDA_TextStruct::DrawOneLine( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset, EDA_Colors aColor, int aDrawMode, GRFillMode aDisplayMode, EDA_Colors aAnchor_color, wxString txt, wxPoint pos ) { int width = m_Width; if( aDisplayMode == FILAIRE ) width = 0; Loading @@ -290,8 +309,8 @@ void EDA_TextStruct::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, int anchor_size = aPanel->GetScreen()->Unscale( 2 ); aAnchor_color = (EDA_Colors) (aAnchor_color & MASKCOLOR); int cX = m_Pos.x + aOffset.x; int cY = m_Pos.y + aOffset.y; int cX = pos.x + aOffset.x; int cY = pos.y + aOffset.y; GRLine( &aPanel->m_ClipBox, aDC, cX - anchor_size, cY, cX + anchor_size, cY, 0, aAnchor_color ); Loading @@ -302,17 +321,21 @@ void EDA_TextStruct::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, if( aDisplayMode == SKETCH ) width = -width; wxSize size = m_Size; if ( m_Mirror ) size.x = -size.x; DrawGraphicText( aPanel, aDC, aOffset + m_Pos, aColor, m_Text, aOffset + pos, aColor, txt, m_Orient, size, m_HJustify, m_VJustify, width, m_Italic ); return size; } /******************/ /* Class EDA_Rect */ /******************/ Loading common/common.cpp +32 −0 Original line number Diff line number Diff line Loading @@ -378,6 +378,38 @@ int ReturnValueFromString( int Units, const wxString& TextValue, return Value; } /** * Function wxStringSplit * Split a String to a String List when founding 'splitter' * @return the list * @param txt : wxString : a String text * @param splitter : wxChar : the 'split' character */ /**********************************************************/ wxArrayString* wxStringSplit(wxString txt, wxChar splitter) /**********************************************************/ { wxArrayString* list = new wxArrayString(); while (1) { int index=txt.Find(splitter); if (index == wxNOT_FOUND) break; wxString tmp; tmp = txt.Mid(0,index); txt = txt.Mid( index+1, txt.size() - index); list->Add(tmp); } if (!txt.IsEmpty()) { list->Add(txt); } return list; } /******************************************************************/ double To_User_Unit( bool is_metric, int val, int internal_unit_value ) Loading common/wxwineda.cpp +8 −3 Original line number Diff line number Diff line Loading @@ -12,13 +12,13 @@ /**********************************************************************************/ /* Classe WinEDA_EnterText pour entrer une ligne texte au clavier dans les frames */ /* Classe WinEDA_EnterText pour entrer une ou plusieurs ligne texte au clavier dans les frames */ /**********************************************************************************/ WinEDA_EnterText::WinEDA_EnterText( wxWindow* parent, const wxString& Title, const wxString& TextToEdit, wxBoxSizer* BoxSizer, const wxSize& Size ) const wxSize& Size, bool Multiline ) { m_Modify = FALSE; if( ! TextToEdit.IsEmpty() ) Loading @@ -28,7 +28,12 @@ WinEDA_EnterText::WinEDA_EnterText( wxWindow* parent, BoxSizer->Add( m_Title, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE, 5 ); m_FrameText = new wxTextCtrl( parent, -1, TextToEdit, wxDefaultPosition, Size ); long style = 0; if (Multiline) style = wxTE_MULTILINE; m_FrameText = new wxTextCtrl( parent, -1, TextToEdit, wxDefaultPosition, Size,style ); m_FrameText->SetInsertionPoint( 1 ); BoxSizer->Add( m_FrameText, Loading eeschema/class_text-label.cpp +45 −23 Original line number Diff line number Diff line Loading @@ -189,46 +189,68 @@ void SCH_TEXT::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, color = ReturnLayerColor( m_Layer ); GRSetDrawMode( DC, DrawMode ); wxArrayString* list = wxStringSplit(m_Text, '\n'); wxPoint pos; int orientation; GRTextHorizJustifyType Hjustify; GRTextVertJustifyType Vjustify; pos = m_Pos + offset; switch( m_Orient ) { case 0: /* Horiz Normal Orientation (left justified) */ DrawGraphicText( panel, DC, wxPoint( m_Pos.x + offset.x, m_Pos.y - TXTMARGE + offset.y ), color, m_Text, TEXT_ORIENT_HORIZ, m_Size, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM, width, m_Italic, true ); orientation = TEXT_ORIENT_HORIZ; Hjustify = GR_TEXT_HJUSTIFY_LEFT; Vjustify = GR_TEXT_VJUSTIFY_BOTTOM; pos.y-=TXTMARGE; break; case 1: /* Vert Orientation UP */ DrawGraphicText( panel, DC, wxPoint( m_Pos.x - TXTMARGE + offset.x, m_Pos.y + offset.y ), color, m_Text, TEXT_ORIENT_VERT, m_Size, GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_BOTTOM, width, m_Italic, true ); orientation = TEXT_ORIENT_VERT; Hjustify = GR_TEXT_HJUSTIFY_RIGHT; Vjustify = GR_TEXT_VJUSTIFY_BOTTOM; pos.x-=TXTMARGE; break; case 2: /* Horiz Orientation - Right justified */ DrawGraphicText( panel, DC, wxPoint( m_Pos.x + offset.x, m_Pos.y - TXTMARGE + offset.y ), color, m_Text, TEXT_ORIENT_HORIZ, m_Size, GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_BOTTOM, width, m_Italic, true ); orientation = TEXT_ORIENT_HORIZ; Hjustify = GR_TEXT_HJUSTIFY_RIGHT; Vjustify = GR_TEXT_VJUSTIFY_BOTTOM; pos.y-=TXTMARGE; break; case 3: /* Vert Orientation BOTTOM */ DrawGraphicText( panel, DC, wxPoint( m_Pos.x - TXTMARGE + offset.x, m_Pos.y + offset.y ), color, m_Text, TEXT_ORIENT_VERT, m_Size, GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_TOP, width, m_Italic, true ); orientation = TEXT_ORIENT_VERT; Hjustify = GR_TEXT_HJUSTIFY_RIGHT; Vjustify = GR_TEXT_VJUSTIFY_TOP; pos.x-=TXTMARGE; break; } for( int i=0;i<list->Count();i++) { wxString txt = list->Item(i); DrawGraphicText( panel, DC, pos, color, txt, orientation, m_Size, Hjustify, Vjustify, width, m_Italic, true ); if (orientation == TEXT_ORIENT_HORIZ) pos.y+= 1.5*(m_Size.y); else pos.x+= 1.5*(m_Size.x); } delete (list); if( m_IsDangling ) DrawDanglingSymbol( panel, DC, m_Pos + offset, color ); } Loading eeschema/dialog_edit_label.cpp +26 −12 Original line number Diff line number Diff line Loading @@ -21,8 +21,22 @@ int DialogLabelEditor::ShowModally( WinEDA_SchematicFrame* parent, SCH_TEXT * CurrentText ) { int ret; bool multiline; DialogLabelEditor* dialog = new DialogLabelEditor( parent, CurrentText ); 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. Loading @@ -35,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; Loading Loading @@ -67,6 +81,7 @@ void DialogLabelEditor::init() default: SetTitle( _( "Text Properties" ) ); m_TextLabel->Disconnect(wxEVT_COMMAND_TEXT_ENTER , wxCommandEventHandler ( DialogLabelEditor::onEnterKey ), NULL, this); break; } Loading Loading @@ -111,6 +126,14 @@ void DialogLabelEditor::init() } } /*! * wxTE_PROCESS_ENTER event handler for m_TextLabel */ void DialogLabelEditor::onEnterKey( wxCommandEvent& event ) { TextPropertiesAccept( event ); } /*! * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK Loading @@ -132,12 +155,3 @@ void DialogLabelEditor::OnButtonCANCEL_Click( wxCommandEvent& event ) EndModal( -1 ); } /*! * wxTE_PROCESS_ENTER event handler for m_TextLabel */ void DialogLabelEditor::onEnterKey( wxCommandEvent& event ) { TextPropertiesAccept( event ); } Loading
common/base_struct.cpp +56 −33 Original line number Diff line number Diff line Loading @@ -171,7 +171,7 @@ EDA_TextStruct::EDA_TextStruct( const wxString& text ) m_Orient = 0; /* Orient in 0.1 degrees */ m_Attributs = 0; m_Mirror = false; // display mirror if true m_HJustify = GR_TEXT_HJUSTIFY_CENTER; m_HJustify = GR_TEXT_HJUSTIFY_LEFT; m_VJustify = GR_TEXT_VJUSTIFY_CENTER; /* Justifications Horiz et Vert du texte */ m_Width = 0; /* thickness */ m_Italic = false; /* true = italic shape */ Loading Loading @@ -264,7 +264,6 @@ void EDA_TextStruct::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, int aDrawMode, GRFillMode aDisplayMode, EDA_Colors aAnchor_color ) /***************************************************************/ /** Function Draw * @param aPanel = the current DrawPanel * @param aDC = the current Device Context Loading @@ -274,10 +273,30 @@ void EDA_TextStruct::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, * @param aDisplayMode = FILAIRE, FILLED or SKETCH * @param EDA_Colors aAnchor_color = anchor color ( UNSPECIFIED_COLOR = do not draw anchor ). */ { int width; wxPoint pos = m_Pos; wxArrayString* list = wxStringSplit( m_Text, '\n'); for( int i=0;i<list->Count();i++) { wxString txt = list->Item(i); wxSize size=DrawOneLine(aPanel,aDC,aOffset,aColor,aDrawMode,aDisplayMode,aAnchor_color,txt,pos); pos.y+=1.5*(size.y); } delete (list); } width = m_Width; wxSize EDA_TextStruct::DrawOneLine( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset, EDA_Colors aColor, int aDrawMode, GRFillMode aDisplayMode, EDA_Colors aAnchor_color, wxString txt, wxPoint pos ) { int width = m_Width; if( aDisplayMode == FILAIRE ) width = 0; Loading @@ -290,8 +309,8 @@ void EDA_TextStruct::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, int anchor_size = aPanel->GetScreen()->Unscale( 2 ); aAnchor_color = (EDA_Colors) (aAnchor_color & MASKCOLOR); int cX = m_Pos.x + aOffset.x; int cY = m_Pos.y + aOffset.y; int cX = pos.x + aOffset.x; int cY = pos.y + aOffset.y; GRLine( &aPanel->m_ClipBox, aDC, cX - anchor_size, cY, cX + anchor_size, cY, 0, aAnchor_color ); Loading @@ -302,17 +321,21 @@ void EDA_TextStruct::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, if( aDisplayMode == SKETCH ) width = -width; wxSize size = m_Size; if ( m_Mirror ) size.x = -size.x; DrawGraphicText( aPanel, aDC, aOffset + m_Pos, aColor, m_Text, aOffset + pos, aColor, txt, m_Orient, size, m_HJustify, m_VJustify, width, m_Italic ); return size; } /******************/ /* Class EDA_Rect */ /******************/ Loading
common/common.cpp +32 −0 Original line number Diff line number Diff line Loading @@ -378,6 +378,38 @@ int ReturnValueFromString( int Units, const wxString& TextValue, return Value; } /** * Function wxStringSplit * Split a String to a String List when founding 'splitter' * @return the list * @param txt : wxString : a String text * @param splitter : wxChar : the 'split' character */ /**********************************************************/ wxArrayString* wxStringSplit(wxString txt, wxChar splitter) /**********************************************************/ { wxArrayString* list = new wxArrayString(); while (1) { int index=txt.Find(splitter); if (index == wxNOT_FOUND) break; wxString tmp; tmp = txt.Mid(0,index); txt = txt.Mid( index+1, txt.size() - index); list->Add(tmp); } if (!txt.IsEmpty()) { list->Add(txt); } return list; } /******************************************************************/ double To_User_Unit( bool is_metric, int val, int internal_unit_value ) Loading
common/wxwineda.cpp +8 −3 Original line number Diff line number Diff line Loading @@ -12,13 +12,13 @@ /**********************************************************************************/ /* Classe WinEDA_EnterText pour entrer une ligne texte au clavier dans les frames */ /* Classe WinEDA_EnterText pour entrer une ou plusieurs ligne texte au clavier dans les frames */ /**********************************************************************************/ WinEDA_EnterText::WinEDA_EnterText( wxWindow* parent, const wxString& Title, const wxString& TextToEdit, wxBoxSizer* BoxSizer, const wxSize& Size ) const wxSize& Size, bool Multiline ) { m_Modify = FALSE; if( ! TextToEdit.IsEmpty() ) Loading @@ -28,7 +28,12 @@ WinEDA_EnterText::WinEDA_EnterText( wxWindow* parent, BoxSizer->Add( m_Title, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE, 5 ); m_FrameText = new wxTextCtrl( parent, -1, TextToEdit, wxDefaultPosition, Size ); long style = 0; if (Multiline) style = wxTE_MULTILINE; m_FrameText = new wxTextCtrl( parent, -1, TextToEdit, wxDefaultPosition, Size,style ); m_FrameText->SetInsertionPoint( 1 ); BoxSizer->Add( m_FrameText, Loading
eeschema/class_text-label.cpp +45 −23 Original line number Diff line number Diff line Loading @@ -189,46 +189,68 @@ void SCH_TEXT::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, color = ReturnLayerColor( m_Layer ); GRSetDrawMode( DC, DrawMode ); wxArrayString* list = wxStringSplit(m_Text, '\n'); wxPoint pos; int orientation; GRTextHorizJustifyType Hjustify; GRTextVertJustifyType Vjustify; pos = m_Pos + offset; switch( m_Orient ) { case 0: /* Horiz Normal Orientation (left justified) */ DrawGraphicText( panel, DC, wxPoint( m_Pos.x + offset.x, m_Pos.y - TXTMARGE + offset.y ), color, m_Text, TEXT_ORIENT_HORIZ, m_Size, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM, width, m_Italic, true ); orientation = TEXT_ORIENT_HORIZ; Hjustify = GR_TEXT_HJUSTIFY_LEFT; Vjustify = GR_TEXT_VJUSTIFY_BOTTOM; pos.y-=TXTMARGE; break; case 1: /* Vert Orientation UP */ DrawGraphicText( panel, DC, wxPoint( m_Pos.x - TXTMARGE + offset.x, m_Pos.y + offset.y ), color, m_Text, TEXT_ORIENT_VERT, m_Size, GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_BOTTOM, width, m_Italic, true ); orientation = TEXT_ORIENT_VERT; Hjustify = GR_TEXT_HJUSTIFY_RIGHT; Vjustify = GR_TEXT_VJUSTIFY_BOTTOM; pos.x-=TXTMARGE; break; case 2: /* Horiz Orientation - Right justified */ DrawGraphicText( panel, DC, wxPoint( m_Pos.x + offset.x, m_Pos.y - TXTMARGE + offset.y ), color, m_Text, TEXT_ORIENT_HORIZ, m_Size, GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_BOTTOM, width, m_Italic, true ); orientation = TEXT_ORIENT_HORIZ; Hjustify = GR_TEXT_HJUSTIFY_RIGHT; Vjustify = GR_TEXT_VJUSTIFY_BOTTOM; pos.y-=TXTMARGE; break; case 3: /* Vert Orientation BOTTOM */ DrawGraphicText( panel, DC, wxPoint( m_Pos.x - TXTMARGE + offset.x, m_Pos.y + offset.y ), color, m_Text, TEXT_ORIENT_VERT, m_Size, GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_TOP, width, m_Italic, true ); orientation = TEXT_ORIENT_VERT; Hjustify = GR_TEXT_HJUSTIFY_RIGHT; Vjustify = GR_TEXT_VJUSTIFY_TOP; pos.x-=TXTMARGE; break; } for( int i=0;i<list->Count();i++) { wxString txt = list->Item(i); DrawGraphicText( panel, DC, pos, color, txt, orientation, m_Size, Hjustify, Vjustify, width, m_Italic, true ); if (orientation == TEXT_ORIENT_HORIZ) pos.y+= 1.5*(m_Size.y); else pos.x+= 1.5*(m_Size.x); } delete (list); if( m_IsDangling ) DrawDanglingSymbol( panel, DC, m_Pos + offset, color ); } Loading
eeschema/dialog_edit_label.cpp +26 −12 Original line number Diff line number Diff line Loading @@ -21,8 +21,22 @@ int DialogLabelEditor::ShowModally( WinEDA_SchematicFrame* parent, SCH_TEXT * CurrentText ) { int ret; bool multiline; DialogLabelEditor* dialog = new DialogLabelEditor( parent, CurrentText ); 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. Loading @@ -35,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; Loading Loading @@ -67,6 +81,7 @@ void DialogLabelEditor::init() default: SetTitle( _( "Text Properties" ) ); m_TextLabel->Disconnect(wxEVT_COMMAND_TEXT_ENTER , wxCommandEventHandler ( DialogLabelEditor::onEnterKey ), NULL, this); break; } Loading Loading @@ -111,6 +126,14 @@ void DialogLabelEditor::init() } } /*! * wxTE_PROCESS_ENTER event handler for m_TextLabel */ void DialogLabelEditor::onEnterKey( wxCommandEvent& event ) { TextPropertiesAccept( event ); } /*! * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK Loading @@ -132,12 +155,3 @@ void DialogLabelEditor::OnButtonCANCEL_Click( wxCommandEvent& event ) EndModal( -1 ); } /*! * wxTE_PROCESS_ENTER event handler for m_TextLabel */ void DialogLabelEditor::onEnterKey( wxCommandEvent& event ) { TextPropertiesAccept( event ); }