Commit f2b0e185 authored by jean-pierre charras's avatar jean-pierre charras
Browse files

Minor fixes to prepare wxWidget 2.9.1 use:

* store selected language by name instead of wx language id (that changes between wxWidgets version)
* accept always comma and point as flotating point separator.
parent ede820b4
Loading
Loading
Loading
Loading
+11 −0
Original line number Original line Diff line number Diff line
@@ -99,6 +99,17 @@ void BASE_SCREEN::SetPageSize( wxSize& aPageSize )
}
}




/**
 * Function GetScalingFactor
 * @return the the current scale used to draw items on screen
 * draw coordinates are user coordinates * GetScalingFactor( )
 */
double BASE_SCREEN::GetScalingFactor() const
{
    double scale = (double) m_ZoomScalar / (double) GetZoom();
    return scale;
}

/**
/**
 * Function SetScalingFactor
 * Function SetScalingFactor
 * calculates the .m_Zoom member to have a given scaling factor
 * calculates the .m_Zoom member to have a given scaling factor
+1 −1
Original line number Original line Diff line number Diff line
@@ -6,7 +6,7 @@
#endif
#endif


#ifndef KICAD_BUILD_VERSION
#ifndef KICAD_BUILD_VERSION
#define KICAD_BUILD_VERSION "(2011-03-30)"
#define KICAD_BUILD_VERSION "(2011-04-01)"
#endif
#endif


// uncomment this line only when creating a stable version
// uncomment this line only when creating a stable version
+4 −0
Original line number Original line Diff line number Diff line
@@ -397,6 +397,10 @@ int ReturnValueFromString( UserUnitType aUnit, const wxString& TextValue,


    /* Convert the period in decimal point */
    /* Convert the period in decimal point */
    buf.Replace( wxT( "." ), wxString( decimal_point, 1 ) );
    buf.Replace( wxT( "." ), wxString( decimal_point, 1 ) );
    // An ugly fix needed by WxWidgets 2.9.1 that sometimes
    // back to a point as separator, although the separator is the comma
    // TODO: remove this line if WxWidgets 2.9.2 fixes this issue
    buf.Replace( wxT( "," ), wxString( decimal_point, 1 ) );


    /* Find the end of the numeric part */
    /* Find the end of the numeric part */
    unsigned brk_point = 0;
    unsigned brk_point = 0;
+43 −9
Original line number Original line Diff line number Diff line
@@ -81,6 +81,9 @@ struct LANGUAGE_DESCR


/**
/**
 * Language list struct
 * Language list struct
 * Note: because this list is not created on the fly, wxTranslation
 * must be called when a language name must be displayed after translation.
 * Do don change this behavior, because m_Lang_Label is also used as key in config
 */
 */
static struct LANGUAGE_DESCR s_Language_List[] =
static struct LANGUAGE_DESCR s_Language_List[] =
{
{
@@ -249,7 +252,7 @@ WinEDA_App::WinEDA_App()
    m_EDA_Config  = NULL;
    m_EDA_Config  = NULL;
    m_Env_Defined = FALSE;
    m_Env_Defined = FALSE;
    m_LanguageId  = wxLANGUAGE_DEFAULT;
    m_LanguageId  = wxLANGUAGE_DEFAULT;
    m_PdfBrowserIsDefault = TRUE;
    m_PdfBrowserIsDefault = true;
    m_Locale = NULL;
    m_Locale = NULL;
    m_ProjectConfig    = NULL;
    m_ProjectConfig    = NULL;
    m_EDA_CommonConfig = NULL;
    m_EDA_CommonConfig = NULL;
@@ -337,9 +340,20 @@ void WinEDA_App::InitEDA_Appl( const wxString& aName, id_app_type aId )
    ReadPdfBrowserInfos();
    ReadPdfBrowserInfos();


    // Internationalization: loading the kicad suitable Dictionary
    // Internationalization: loading the kicad suitable Dictionary
    m_EDA_CommonConfig->Read( languageCfgKey, &m_LanguageId, wxLANGUAGE_DEFAULT );
    wxString languageSel;
    m_EDA_CommonConfig->Read( languageCfgKey, &languageSel);
    m_LanguageId = wxLANGUAGE_DEFAULT;
    // Search for the current selection
    for( unsigned int ii = 0; ii < LANGUAGE_DESCR_COUNT; ii++ )
    {
        if( s_Language_List[ii].m_Lang_Label == languageSel )
        {
            m_LanguageId = s_Language_List[ii].m_WX_Lang_Identifier;
            break;
        }
    }


    bool succes = SetLanguage( TRUE );
    bool succes = SetLanguage( true );
    if( !succes )
    if( !succes )
    {
    {
    }
    }
@@ -459,7 +473,7 @@ bool WinEDA_App::SetBinDir()
    while( m_BinDir.Last() != '/' && !m_BinDir.IsEmpty() )
    while( m_BinDir.Last() != '/' && !m_BinDir.IsEmpty() )
        m_BinDir.RemoveLast();
        m_BinDir.RemoveLast();


    return TRUE;
    return true;
}
}




@@ -627,7 +641,19 @@ void WinEDA_App::GetSettings(bool aReopenLastUsedDirectory)
    m_HelpSize.x = 500;
    m_HelpSize.x = 500;
    m_HelpSize.y = 400;
    m_HelpSize.y = 400;


    m_LanguageId = m_EDA_CommonConfig->Read( languageCfgKey, wxLANGUAGE_DEFAULT );
    wxString languageSel;
    m_EDA_CommonConfig->Read( languageCfgKey, &languageSel);
    m_LanguageId = wxLANGUAGE_DEFAULT;
    // Search for the current selection
    for( unsigned int ii = 0; ii < LANGUAGE_DESCR_COUNT; ii++ )
    {
        if( s_Language_List[ii].m_Lang_Label == languageSel )
        {
            m_LanguageId = s_Language_List[ii].m_WX_Lang_Identifier;
            break;
        }
    }

    m_EditorName = m_EDA_CommonConfig->Read( wxT( "Editor" ) );
    m_EditorName = m_EDA_CommonConfig->Read( wxT( "Editor" ) );


    m_fileHistory.Load( *m_EDA_Config );
    m_fileHistory.Load( *m_EDA_Config );
@@ -717,7 +743,17 @@ bool WinEDA_App::SetLanguage( bool first_time )


    if( !first_time )
    if( !first_time )
    {
    {
        m_EDA_CommonConfig->Write( languageCfgKey, m_LanguageId );
        wxString languageSel;
        // Search for the current selection
        for( unsigned int ii = 0; ii < LANGUAGE_DESCR_COUNT; ii++ )
        {
            if( s_Language_List[ii].m_WX_Lang_Identifier == m_LanguageId )
            {
                languageSel = s_Language_List[ii].m_Lang_Label;
                break;
            }
        }
        m_EDA_CommonConfig->Write( languageCfgKey, languageSel );
    }
    }


    // Test if floating point notation is working (bug in cross compilation, using wine)
    // Test if floating point notation is working (bug in cross compilation, using wine)
@@ -758,12 +794,10 @@ bool WinEDA_App::SetLanguage( bool first_time )
 */
 */
void WinEDA_App::SetLanguageIdentifier( int menu_id )
void WinEDA_App::SetLanguageIdentifier( int menu_id )
{
{
    unsigned int ii;

    wxLogDebug( wxT( "Select language ID %d from %d possible languages." ),
    wxLogDebug( wxT( "Select language ID %d from %d possible languages." ),
                menu_id, LANGUAGE_DESCR_COUNT );
                menu_id, LANGUAGE_DESCR_COUNT );


    for( ii = 0; ii < LANGUAGE_DESCR_COUNT; ii++ )
    for( unsigned int ii = 0; ii < LANGUAGE_DESCR_COUNT; ii++ )
    {
    {
        if( menu_id == s_Language_List[ii].m_KI_Lang_Identifier )
        if( menu_id == s_Language_List[ii].m_KI_Lang_Identifier )
        {
        {
+1 −1
Original line number Original line Diff line number Diff line
@@ -502,7 +502,7 @@ void LIB_POLYLINE::EndEdit( const wxPoint& aPosition, bool aAbort )
        if( m_PolyPoints.size() > 2 // do not delete last two points... keep it alive
        if( m_PolyPoints.size() > 2 // do not delete last two points... keep it alive
            && ( m_ModifyIndex > 0
            && ( m_ModifyIndex > 0
                 && m_PolyPoints[ m_ModifyIndex ] == m_PolyPoints[ m_ModifyIndex - 1 ]
                 && m_PolyPoints[ m_ModifyIndex ] == m_PolyPoints[ m_ModifyIndex - 1 ]
                 || m_ModifyIndex < m_PolyPoints.size() - 1
                 || m_ModifyIndex < (int)m_PolyPoints.size() - 1
                 && m_PolyPoints[ m_ModifyIndex ] == m_PolyPoints[ m_ModifyIndex + 1 ] ) )
                 && m_PolyPoints[ m_ModifyIndex ] == m_PolyPoints[ m_ModifyIndex + 1 ] ) )
        {
        {
            m_PolyPoints.erase( m_PolyPoints.begin() + m_ModifyIndex ); // delete a point on this
            m_PolyPoints.erase( m_PolyPoints.begin() + m_ModifyIndex ); // delete a point on this
Loading