Pl_Editor: fix minor issues in multi-lines texts

Others: fix very minor issues.
This commit is contained in:
jean-pierre charras 2013-08-18 17:49:04 +02:00
parent 87eb527d67
commit d04ab1fe75
11 changed files with 1434 additions and 1423 deletions

View File

@ -462,6 +462,43 @@ void WORKSHEET_DATAITEM_TEXT::IncrementLabel( int aIncr )
m_FullText << (wxChar) ( aIncr + lbchar ); m_FullText << (wxChar) ( aIncr + lbchar );
} }
// Replace the '\''n' sequence by EOL
// and the sequence '\''\' by only one '\' in m_FullText
// if m_FullTextis a multiline text (i;e.contains '\n') return true
bool WORKSHEET_DATAITEM_TEXT::ReplaceAntiSlashSequence()
{
bool multiline = false;
for( unsigned ii = 0; ii < m_FullText.Len(); ii++ )
{
if( m_FullText[ii] == '\n' )
multiline = true;
else if( m_FullText[ii] == '\\' )
{
if( ++ii >= m_FullText.Len() )
break;
if( m_FullText[ii] == '\\' )
{
// a double \\ sequence is replaced by a single \ char
m_FullText.Remove(ii, 1);
ii--;
}
else if( m_FullText[ii] == 'n' )
{
// Replace the "\n" sequence by a EOL char
multiline = true;
m_FullText[ii] = '\n';
m_FullText.Remove(ii-1, 1);
ii--;
}
}
}
return multiline;
}
void WORKSHEET_DATAITEM_TEXT::SetConstrainedTextSize() void WORKSHEET_DATAITEM_TEXT::SetConstrainedTextSize()
{ {
m_ConstrainedTextSize = m_TextSize; m_ConstrainedTextSize = m_TextSize;
@ -501,3 +538,4 @@ void WORKSHEET_DATAITEM_TEXT::SetConstrainedTextSize()
m_ConstrainedTextSize.y *= m_BoundingBoxSize.y / size.y; m_ConstrainedTextSize.y *= m_BoundingBoxSize.y / size.y;
} }
} }

View File

@ -152,8 +152,7 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
else else
{ {
wsText->m_FullText = BuildFullText( wsText->m_TextBase ); wsText->m_FullText = BuildFullText( wsText->m_TextBase );
if( wsText->m_FullText.Replace( wxT("\\n" ), wxT("\n") ) > 0 ) multilines = wsText->ReplaceAntiSlashSequence();
multilines = true;
} }
if( wsText->m_FullText.IsEmpty() ) if( wsText->m_FullText.IsEmpty() )

View File

@ -136,8 +136,8 @@ wxString WS_DRAW_ITEM_LIST::BuildFullText( const wxString& aTextbase )
msg << aTextbase[ii]; msg << aTextbase[ii];
continue; continue;
} }
ii++;
if( ii >= aTextbase.Len() ) if( ++ii >= aTextbase.Len() )
break; break;
wxChar format = aTextbase[ii]; wxChar format = aTextbase[ii];

View File

@ -420,6 +420,14 @@ public:
*/ */
void SetConstrainedTextSize(); void SetConstrainedTextSize();
/** Replace the '\''n' sequence by EOL
* and the sequence '\''\' by only one '\'
* inside m_FullText
* @return true if the EOL symbol is found or is inserted (multiline text)
*/
bool ReplaceAntiSlashSequence();
/** /**
* @return true is a bold font should be selected * @return true is a bold font should be selected
*/ */

View File

@ -98,7 +98,7 @@ public:
} }
catch( IO_ERROR ioe ) catch( IO_ERROR ioe )
{ {
wxMessageBox( ioe.errorText, _("Write Page Layout Error" ) ); wxMessageBox( ioe.errorText, _("Error writing page layout descr file" ) );
} }
} }
@ -125,7 +125,7 @@ public:
} }
catch( IO_ERROR ioe ) catch( IO_ERROR ioe )
{ {
wxMessageBox( ioe.errorText, _("Write Page Layout Error" ) ); wxMessageBox( ioe.errorText, _("Error writing page layout descr file" ) );
} }
} }

View File

@ -194,9 +194,10 @@ void PROPERTIES_FRAME::CopyPrmsFromItemToPanel( WORKSHEET_DATAITEM* aItem )
m_SizerTextIncrementLabel->Show( true ); m_SizerTextIncrementLabel->Show( true );
WORKSHEET_DATAITEM_TEXT* item = (WORKSHEET_DATAITEM_TEXT*) aItem; WORKSHEET_DATAITEM_TEXT* item = (WORKSHEET_DATAITEM_TEXT*) aItem;
wxString text = item->m_TextBase; item->m_FullText = item->m_TextBase;
text.Replace(wxT("\\n"), wxT("\n") ); // Replace our '\' 'n' sequence by the EOL char
m_textCtrlText->SetValue( text ); item->ReplaceAntiSlashSequence();;
m_textCtrlText->SetValue( item->m_FullText );
msg.Printf( wxT("%d"), item->m_IncrementLabel ); msg.Printf( wxT("%d"), item->m_IncrementLabel );
m_textCtrlTextIncrement->SetValue( msg ); m_textCtrlTextIncrement->SetValue( msg );
@ -285,7 +286,12 @@ void PROPERTIES_FRAME::OnAcceptPrms( wxCommandEvent& event )
WORKSHEET_DATAITEM* item = m_parent->GetSelectedItem(); WORKSHEET_DATAITEM* item = m_parent->GetSelectedItem();
if( item ) if( item )
{
CopyPrmsFromPanelToItem( item ); CopyPrmsFromPanelToItem( item );
// Be sure what is displayed is waht is set for item
// (mainly, texts can be modified if they contain "\n")
CopyPrmsFromItemToPanel( item );
}
CopyPrmsFromPanelToGeneral(); CopyPrmsFromPanelToGeneral();
@ -392,7 +398,6 @@ bool PROPERTIES_FRAME::CopyPrmsFromPanelToItem( WORKSHEET_DATAITEM* aItem )
WORKSHEET_DATAITEM_TEXT* item = (WORKSHEET_DATAITEM_TEXT*) aItem; WORKSHEET_DATAITEM_TEXT* item = (WORKSHEET_DATAITEM_TEXT*) aItem;
item->m_TextBase = m_textCtrlText->GetValue(); item->m_TextBase = m_textCtrlText->GetValue();
item->m_TextBase.Replace( wxT("\n"), wxT("\\n") );
msg = m_textCtrlTextIncrement->GetValue(); msg = m_textCtrlTextIncrement->GetValue();
msg.ToLong( &itmp ); msg.ToLong( &itmp );

View File

@ -25,8 +25,6 @@
#include <transline.h> #include <transline.h>
#include <units.h> #include <units.h>
using namespace std;
#ifndef INFINITY #ifndef INFINITY
#define INFINITY std::numeric_limits<double>::infinity() #define INFINITY std::numeric_limits<double>::infinity()
@ -37,13 +35,6 @@ using namespace std;
#define M_PI_2 (M_PI/2) #define M_PI_2 (M_PI/2)
#endif #endif
#ifndef HAVE_CMATH_ISINF
inline bool isinf(double x)
{
return x == INFINITY; // return true if x is infinity
}
#endif
// Functions to Read/Write parameters in pcb_calculator main frame: // Functions to Read/Write parameters in pcb_calculator main frame:
// They are wrapper to actual functions, so all transline functions do not // They are wrapper to actual functions, so all transline functions do not
@ -148,7 +139,7 @@ void TRANSLINE::ellipke( double arg, double& k, double& e )
k = INFINITY; // infinite k = INFINITY; // infinite
e = 0; e = 0;
} }
else if( isinf( arg ) && arg < 0 ) else if( std::isinf( arg ) && arg < 0 )
{ {
k = 0; k = 0;
e = INFINITY; // infinite e = INFINITY; // infinite

View File

@ -58,15 +58,6 @@ inline double atanh( double x )
} }
#endif #endif
#ifndef M_PI
#define M_PI 3.1415926535897932384626433832795029 /* pi */
#endif
#ifndef M_E
#define M_E 2.7182818284590452353602874713526625 /* e */
#endif
#define MU0 12.566370614e-7 // magnetic constant #define MU0 12.566370614e-7 // magnetic constant
#define C0 299792458.0 // speed of light in vacuum #define C0 299792458.0 // speed of light in vacuum
#define ZF0 376.73031346958504364963 // wave resistance in vacuum #define ZF0 376.73031346958504364963 // wave resistance in vacuum

View File

@ -22,20 +22,17 @@ DIALOG_PADS_MASK_CLEARANCE_BASE::DIALOG_PADS_MASK_CLEARANCE_BASE( wxWindow* pare
bMainSizer = new wxBoxSizer( wxVERTICAL ); bMainSizer = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bMainUpperSizer; wxBoxSizer* bMainUpperSizer;
bMainUpperSizer = new wxBoxSizer( wxHORIZONTAL ); bMainUpperSizer = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer* sbMiddleRightSizer;
sbMiddleRightSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Dimensions:") ), wxVERTICAL );
m_staticTextInfo = new wxStaticText( this, wxID_ANY, _("Note: For clearance values:\n- a positive value means a mask bigger than a pad\n- a negative value means a mask smaller than a pad\n"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextInfo = new wxStaticText( this, wxID_ANY, _("Note: For clearance values:\n- a positive value means a mask bigger than a pad\n- a negative value means a mask smaller than a pad\n"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextInfo->Wrap( -1 ); m_staticTextInfo->Wrap( -1 );
sbMiddleRightSizer->Add( m_staticTextInfo, 0, wxALIGN_CENTER_HORIZONTAL|wxRIGHT|wxLEFT, 5 ); bMainUpperSizer->Add( m_staticTextInfo, 0, wxALIGN_CENTER_HORIZONTAL|wxTOP|wxRIGHT|wxLEFT, 5 );
m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
sbMiddleRightSizer->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 ); bMainUpperSizer->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 );
wxFlexGridSizer* fgGridSolderMaskSizer; wxFlexGridSizer* fgGridSolderMaskSizer;
fgGridSolderMaskSizer = new wxFlexGridSizer( 4, 3, 0, 0 ); fgGridSolderMaskSizer = new wxFlexGridSizer( 0, 3, 0, 0 );
fgGridSolderMaskSizer->AddGrowableCol( 1 ); fgGridSolderMaskSizer->AddGrowableCol( 1 );
fgGridSolderMaskSizer->SetFlexibleDirection( wxBOTH ); fgGridSolderMaskSizer->SetFlexibleDirection( wxBOTH );
fgGridSolderMaskSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); fgGridSolderMaskSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
@ -106,17 +103,14 @@ DIALOG_PADS_MASK_CLEARANCE_BASE::DIALOG_PADS_MASK_CLEARANCE_BASE( wxWindow* pare
fgGridSolderMaskSizer->Add( m_SolderPasteRatioMarginUnits, 0, wxTOP|wxBOTTOM|wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 ); fgGridSolderMaskSizer->Add( m_SolderPasteRatioMarginUnits, 0, wxTOP|wxBOTTOM|wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 );
sbMiddleRightSizer->Add( fgGridSolderMaskSizer, 1, wxEXPAND, 5 ); bMainUpperSizer->Add( fgGridSolderMaskSizer, 1, wxEXPAND, 5 );
m_staticline11 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bMainUpperSizer->Add( sbMiddleRightSizer, 1, wxEXPAND, 5 ); bMainUpperSizer->Add( m_staticline11, 0, wxEXPAND | wxALL, 5 );
bMainSizer->Add( bMainUpperSizer, 1, wxEXPAND, 5 ); bMainSizer->Add( bMainUpperSizer, 1, wxEXPAND, 5 );
m_staticline11 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bMainSizer->Add( m_staticline11, 0, wxEXPAND | wxALL, 5 );
m_sdbButtonsSizer = new wxStdDialogButtonSizer(); m_sdbButtonsSizer = new wxStdDialogButtonSizer();
m_sdbButtonsSizerOK = new wxButton( this, wxID_OK ); m_sdbButtonsSizerOK = new wxButton( this, wxID_OK );
m_sdbButtonsSizer->AddButton( m_sdbButtonsSizerOK ); m_sdbButtonsSizer->AddButton( m_sdbButtonsSizerOK );
@ -124,7 +118,7 @@ DIALOG_PADS_MASK_CLEARANCE_BASE::DIALOG_PADS_MASK_CLEARANCE_BASE( wxWindow* pare
m_sdbButtonsSizer->AddButton( m_sdbButtonsSizerCancel ); m_sdbButtonsSizer->AddButton( m_sdbButtonsSizerCancel );
m_sdbButtonsSizer->Realize(); m_sdbButtonsSizer->Realize();
bMainSizer->Add( m_sdbButtonsSizer, 0, wxBOTTOM|wxALIGN_RIGHT, 5 ); bMainSizer->Add( m_sdbButtonsSizer, 0, wxALIGN_RIGHT|wxTOP|wxBOTTOM, 5 );
this->SetSizer( bMainSizer ); this->SetSizer( bMainSizer );

View File

@ -42,7 +42,7 @@
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="name">DIALOG_PADS_MASK_CLEARANCE_BASE</property> <property name="name">DIALOG_PADS_MASK_CLEARANCE_BASE</property>
<property name="pos"></property> <property name="pos"></property>
<property name="size">361,292</property> <property name="size">361,304</property>
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property> <property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
<property name="subclass">DIALOG_SHIM; dialog_shim.h</property> <property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
<property name="title">Pads Mask Clearance</property> <property name="title">Pads Mask Clearance</property>
@ -98,23 +98,11 @@
<object class="wxBoxSizer" expanded="1"> <object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="name">bMainUpperSizer</property> <property name="name">bMainUpperSizer</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxStaticBoxSizer" expanded="1">
<property name="id">wxID_ANY</property>
<property name="label">Dimensions:</property>
<property name="minimum_size"></property>
<property name="name">sbMiddleRightSizer</property>
<property name="orient">wxVERTICAL</property> <property name="orient">wxVERTICAL</property>
<property name="permission">none</property> <property name="permission">none</property>
<event name="OnUpdateUI"></event>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxALIGN_CENTER_HORIZONTAL|wxRIGHT|wxLEFT</property> <property name="flag">wxALIGN_CENTER_HORIZONTAL|wxTOP|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property> <property name="proportion">0</property>
<object class="wxStaticText" expanded="1"> <object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property> <property name="BottomDockable">1</property>
@ -290,7 +278,7 @@
<property name="name">fgGridSolderMaskSizer</property> <property name="name">fgGridSolderMaskSizer</property>
<property name="non_flexible_grow_mode">wxFLEX_GROWMODE_SPECIFIED</property> <property name="non_flexible_grow_mode">wxFLEX_GROWMODE_SPECIFIED</property>
<property name="permission">none</property> <property name="permission">none</property>
<property name="rows">4</property> <property name="rows">0</property>
<property name="vgap">0</property> <property name="vgap">0</property>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">5</property>
@ -1565,10 +1553,6 @@
</object> </object>
</object> </object>
</object> </object>
</object>
</object>
</object>
</object>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxEXPAND | wxALL</property> <property name="flag">wxEXPAND | wxALL</property>
@ -1650,9 +1634,11 @@
<event name="OnUpdateUI"></event> <event name="OnUpdateUI"></event>
</object> </object>
</object> </object>
</object>
</object>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxBOTTOM|wxALIGN_RIGHT</property> <property name="flag">wxALIGN_RIGHT|wxTOP|wxBOTTOM</property>
<property name="proportion">0</property> <property name="proportion">0</property>
<object class="wxStdDialogButtonSizer" expanded="1"> <object class="wxStdDialogButtonSizer" expanded="1">
<property name="Apply">0</property> <property name="Apply">0</property>

View File

@ -23,7 +23,6 @@ class DIALOG_SHIM;
#include <wx/statline.h> #include <wx/statline.h>
#include <wx/textctrl.h> #include <wx/textctrl.h>
#include <wx/sizer.h> #include <wx/sizer.h>
#include <wx/statbox.h>
#include <wx/button.h> #include <wx/button.h>
#include <wx/dialog.h> #include <wx/dialog.h>
@ -72,7 +71,7 @@ class DIALOG_PADS_MASK_CLEARANCE_BASE : public DIALOG_SHIM
public: public:
DIALOG_PADS_MASK_CLEARANCE_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Pads Mask Clearance"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 361,292 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); DIALOG_PADS_MASK_CLEARANCE_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Pads Mask Clearance"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 361,304 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_PADS_MASK_CLEARANCE_BASE(); ~DIALOG_PADS_MASK_CLEARANCE_BASE();
}; };