Commit cc661bdc authored by stambaughw's avatar stambaughw
Browse files

Minor search path updates, initial UI clean up, and more wxDC zoom work.

* Add default OS program install path(s) to search path list as fail safe.
* Remove unnecessary wxGetApp calls in WinEDA_App class methods.
* Remove non-standard message panel font and changed background to system menu color.
* Remove italic fonts from menus.
* Remove non-standard font in Kicad app project tree.
* Remove font selection dialog menu items from apps for removed fonts.
* Remove all global variables and settings associated with the removed fonts.
* Fixed PCBNew export and import library file dialog response tests from wxCANCEL to wxID_CANCEL.
parent 50d1bcb1
Loading
Loading
Loading
Loading
+0 −14
Original line number Original line Diff line number Diff line
@@ -39,7 +39,6 @@ WinEDA_BasicFrame::WinEDA_BasicFrame( wxWindow* father,
    wxSize minsize;
    wxSize minsize;


    m_Ident  = idtype;
    m_Ident  = idtype;
    SetFont( *g_StdFont );
    m_HToolBar       = NULL;
    m_HToolBar       = NULL;
    m_FrameIsActive  = TRUE;
    m_FrameIsActive  = TRUE;
    m_MsgFrameHeight = MSG_PANEL_DEFAULT_HEIGHT;
    m_MsgFrameHeight = MSG_PANEL_DEFAULT_HEIGHT;
@@ -302,19 +301,6 @@ void WinEDA_BasicFrame::ProcessFontPreferences( int id )
    case ID_PREFERENCES_FONT:
    case ID_PREFERENCES_FONT:
        break;
        break;


    case ID_PREFERENCES_FONT_STATUS:
        font = wxGetFontFromUser( this, *g_StdFont );
        if( font.Ok() )
        {
            int pointsize = font.GetPointSize();
            *g_StdFont = font;
            SetFont( *g_StdFont );
            if( GetStatusBar() )
                GetStatusBar()->SetFont( *g_StdFont );
            g_StdFontPointSize = pointsize;
        }
        break;

    case ID_PREFERENCES_FONT_DIALOG:
    case ID_PREFERENCES_FONT_DIALOG:
        font = wxGetFontFromUser( this, *g_DialogFont );
        font = wxGetFontFromUser( this, *g_DialogFont );
        if( font.Ok() )
        if( font.Ok() )
+0 −5
Original line number Original line Diff line number Diff line
@@ -70,16 +70,11 @@ wxString g_UserLibDirBuffer;
int         g_DebugLevel;
int         g_DebugLevel;
int         g_MouseOldButtons;
int         g_MouseOldButtons;
int         g_KeyPressed;
int         g_KeyPressed;
wxFont*     g_StdFont = NULL;
wxFont*     g_DialogFont = NULL;   /* Normal font used in dialog box */
wxFont*     g_DialogFont = NULL;   /* Normal font used in dialog box */
wxFont*     g_ItalicFont = NULL;   /* Italic font used in dialog box */
wxFont*     g_MsgFont = NULL;      /* Italic font used in message panel */
wxFont*     g_FixedFont = NULL;    /* Affichage de Texte en fenetres de dialogue,
wxFont*     g_FixedFont = NULL;    /* Affichage de Texte en fenetres de dialogue,
                                    * fonte a pas fixe)*/
                                    * fonte a pas fixe)*/
int         g_StdFontPointSize;    /* taille de la fonte */
int         g_DialogFontPointSize; /* taille de la fonte */
int         g_DialogFontPointSize; /* taille de la fonte */
int         g_FixedFontPointSize;  /* taille de la fonte */
int         g_FixedFontPointSize;  /* taille de la fonte */
int         g_MsgFontPointSize;    /* taille de la fonte */
int         g_FontMinPointSize;    /* taille minimum des fontes */
int         g_FontMinPointSize;    /* taille minimum des fontes */




+2 −25
Original line number Original line Diff line number Diff line
@@ -128,16 +128,6 @@ void WinEDA_DrawFrame::AddFontSelectionMenu( wxMenu* main_menu )
                  _( "Dialog boxes" ),
                  _( "Dialog boxes" ),
                  fonts_xpm );
                  fonts_xpm );


    ADD_MENUITEM( fontmenu,
                  ID_PREFERENCES_FONT_INFOSCREEN,
                  _( "Lists" ),
                  fonts_xpm );

    ADD_MENUITEM( fontmenu,
                  ID_PREFERENCES_FONT_STATUS,
                  _( "Status box" ),
                  fonts_xpm );

    ADD_MENUITEM_WITH_HELP_AND_SUBMENU( main_menu,
    ADD_MENUITEM_WITH_HELP_AND_SUBMENU( main_menu,
                                        fontmenu,
                                        fontmenu,
                                        ID_PREFERENCES_FONT,
                                        ID_PREFERENCES_FONT,
@@ -151,30 +141,17 @@ void WinEDA_DrawFrame::ProcessFontPreferences( wxCommandEvent& event )
/********************************************************************/
/********************************************************************/
{
{
    int    id = event.GetId();
    int    id = event.GetId();
    wxFont font;


    switch( id )
    switch( id )
    {
    {
    case ID_PREFERENCES_FONT:
    case ID_PREFERENCES_FONT:
    case ID_PREFERENCES_FONT_DIALOG:
    case ID_PREFERENCES_FONT_DIALOG:
    case ID_PREFERENCES_FONT_STATUS:
        WinEDA_BasicFrame::ProcessFontPreferences( id );
        WinEDA_BasicFrame::ProcessFontPreferences( id );
        break;
        break;


    case ID_PREFERENCES_FONT_INFOSCREEN:
    {
        font = wxGetFontFromUser( this, *g_MsgFont );
        if( font.Ok() )
        {
            int pointsize = font.GetPointSize();
            *g_MsgFont = font;
            g_MsgFontPointSize = pointsize;
        }
        break;
    }

    default:
    default:
        DisplayError( this, wxT( "WinEDA_DrawFrame::ProcessFontPreferences Internal Error" ) );
        DisplayError( this, wxT( "WinEDA_DrawFrame::ProcessFontPreferences " \
                                 "Internal Error" ) );
        break;
        break;
    }
    }
}
}
+30 −12
Original line number Original line Diff line number Diff line
@@ -201,14 +201,13 @@ void WinEDA_DrawPanel::PrepareGraphicContext( wxDC* DC )
    wxPoint origin = GetScreen()->m_DrawOrg;
    wxPoint origin = GetScreen()->m_DrawOrg;
    wxLogDebug( wxT( "DC user scale factor: %0.3f, X origin: %d, Y " \
    wxLogDebug( wxT( "DC user scale factor: %0.3f, X origin: %d, Y " \
                     "origin: %d" ), scale, origin.x, origin.y );
                     "origin: %d" ), scale, origin.x, origin.y );
    DoPrepareDC( *DC );
    int ppuX, ppuY, startX, startY;
    GetScrollPixelsPerUnit(& ppuX, & ppuY);
    GetViewStart(& startX, & startY);
    DC->SetDeviceOrigin( origin.x - startX * ppuX, origin.y - startY * ppuY );
    DC->SetUserScale( scale, scale );
    DC->SetUserScale( scale, scale );
    DC->SetLogicalOrigin( origin.x, origin.y );
    wxSize size = GetScreen()->ReturnPageSize() * 2 * scale;

//    DC->SetLogicalOrigin( origin.x, origin.y );
    int x, y;
    wxPoint logicalPos = GetScreen()->m_Curseur - origin;;
    CalcScrolledPosition( logicalPos.x, logicalPos.y, &x, &y );
    Scroll( x, y );
#endif
#endif
    SetBoundaryBox();
    SetBoundaryBox();
}
}
@@ -549,9 +548,24 @@ void WinEDA_DrawPanel::EraseScreen( wxDC* DC )
{
{
    GRSetDrawMode( DC, GR_COPY );
    GRSetDrawMode( DC, GR_COPY );


#ifndef WX_ZOOM
    GRSFilledRect( &m_ClipBox, DC, m_ClipBox.GetX(), m_ClipBox.GetY(),
                   m_ClipBox.GetRight(), m_ClipBox.GetBottom(),
                   g_DrawBgColor, g_DrawBgColor );
#else
    EDA_Rect tmp = m_ClipBox;

    m_ClipBox.m_Pos.x = DC->DeviceToLogicalX( m_ClipBox.m_Pos.x );
    m_ClipBox.m_Pos.y = DC->DeviceToLogicalY( m_ClipBox.m_Pos.y );
    m_ClipBox.m_Size.SetWidth( DC->DeviceToLogicalXRel( m_ClipBox.m_Size.GetWidth() ) );
    m_ClipBox.m_Size.SetHeight( DC->DeviceToLogicalYRel( m_ClipBox.m_Size.GetHeight() ) );

    GRSFilledRect( &m_ClipBox, DC, m_ClipBox.GetX(), m_ClipBox.GetY(),
    GRSFilledRect( &m_ClipBox, DC, m_ClipBox.GetX(), m_ClipBox.GetY(),
                   m_ClipBox.GetRight(), m_ClipBox.GetBottom(),
                   m_ClipBox.GetRight(), m_ClipBox.GetBottom(),
                   g_DrawBgColor, g_DrawBgColor );
                   g_DrawBgColor, g_DrawBgColor );

    m_ClipBox = tmp;
#endif
}
}




@@ -604,7 +618,7 @@ void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event )
    m_ClipBox.m_Pos.x = paintDC.DeviceToLogicalX( m_ClipBox.m_Pos.x );
    m_ClipBox.m_Pos.x = paintDC.DeviceToLogicalX( m_ClipBox.m_Pos.x );
    m_ClipBox.m_Pos.y = paintDC.DeviceToLogicalY( m_ClipBox.m_Pos.y );
    m_ClipBox.m_Pos.y = paintDC.DeviceToLogicalY( m_ClipBox.m_Pos.y );
    m_ClipBox.m_Size.SetWidth( paintDC.DeviceToLogicalXRel( m_ClipBox.m_Size.GetWidth() ) );
    m_ClipBox.m_Size.SetWidth( paintDC.DeviceToLogicalXRel( m_ClipBox.m_Size.GetWidth() ) );
    m_ClipBox.m_Size.SetHeight( paintDC.DeviceToLogicalXRel( m_ClipBox.m_Size.GetHeight() ) );
    m_ClipBox.m_Size.SetHeight( paintDC.DeviceToLogicalYRel( m_ClipBox.m_Size.GetHeight() ) );
#else
#else
    PaintClipBox.Offset( org );
    PaintClipBox.Offset( org );
    m_ClipBox.SetX( PaintClipBox.GetX() );
    m_ClipBox.SetX( PaintClipBox.GetX() );
@@ -665,9 +679,7 @@ void WinEDA_DrawPanel::ReDraw( wxDC* DC, bool erasebg )
    }
    }


    if( erasebg )
    if( erasebg )
        PrepareGraphicContext( DC );
        EraseScreen( DC );

    DC->SetFont( *g_StdFont );


    SetBackgroundColour( wxColour( ColorRefs[g_DrawBgColor].m_Red,
    SetBackgroundColour( wxColour( ColorRefs[g_DrawBgColor].m_Red,
                                   ColorRefs[g_DrawBgColor].m_Green,
                                   ColorRefs[g_DrawBgColor].m_Green,
@@ -744,10 +756,16 @@ void WinEDA_DrawPanel::DrawBackGround( wxDC* DC )
    screen->Unscale( size );
    screen->Unscale( size );


#ifdef WX_ZOOM
#ifdef WX_ZOOM
    screen_grid_size = screen->GetGrid();

    if( DC->LogicalToDeviceXRel( (int) screen_grid_size.x ) < 5
        || DC->LogicalToDeviceYRel( (int) screen_grid_size.y ) < 5 )
        drawgrid = false;

    org.x = DC->DeviceToLogicalX( org.x );
    org.x = DC->DeviceToLogicalX( org.x );
    org.y = DC->DeviceToLogicalY( org.y );
    org.y = DC->DeviceToLogicalY( org.y );
    size.SetWidth( DC->DeviceToLogicalXRel( size.GetWidth() ) );
    size.SetWidth( DC->DeviceToLogicalXRel( size.GetWidth() ) );
    size.SetHeight( DC->DeviceToLogicalXRel( size.GetHeight() ) );
    size.SetHeight( DC->DeviceToLogicalYRel( size.GetHeight() ) );
#endif
#endif


    if( drawgrid )
    if( drawgrid )
+55 −86
Original line number Original line Diff line number Diff line
@@ -247,11 +247,8 @@ WinEDA_App::~WinEDA_App()
    if( m_EDA_CommonConfig )
    if( m_EDA_CommonConfig )
        delete m_EDA_CommonConfig;
        delete m_EDA_CommonConfig;
    delete m_EDA_Config;
    delete m_EDA_Config;
    delete g_StdFont;
    delete g_DialogFont;
    delete g_DialogFont;
    delete g_ItalicFont;
    delete g_FixedFont;
    delete g_FixedFont;
    delete g_MsgFont;
    if( m_Checker )
    if( m_Checker )
        delete m_Checker;
        delete m_Checker;
    delete m_Locale;
    delete m_Locale;
@@ -306,23 +303,12 @@ void WinEDA_App::InitEDA_Appl( const wxString& aName, id_app_type aId )
    wxASSERT( m_EDA_CommonConfig != NULL );
    wxASSERT( m_EDA_CommonConfig != NULL );


    /* Create the fonts used in dialogs and messages */
    /* Create the fonts used in dialogs and messages */
    g_StdFontPointSize    = FONT_DEFAULT_SIZE;
    g_MsgFontPointSize    = FONT_DEFAULT_SIZE;
    g_DialogFontPointSize = FONT_DEFAULT_SIZE;
    g_DialogFontPointSize = FONT_DEFAULT_SIZE;
    g_FixedFontPointSize  = FONT_DEFAULT_SIZE;
    g_FixedFontPointSize  = FONT_DEFAULT_SIZE;


    g_StdFont = new wxFont( g_StdFontPointSize, wxFONTFAMILY_ROMAN,
                            wxNORMAL, wxNORMAL );

    g_MsgFont = new wxFont( g_StdFontPointSize, wxFONTFAMILY_ROMAN,
                            wxNORMAL, wxNORMAL );

    g_DialogFont = new wxFont( g_DialogFontPointSize, wxFONTFAMILY_ROMAN,
    g_DialogFont = new wxFont( g_DialogFontPointSize, wxFONTFAMILY_ROMAN,
                               wxNORMAL, wxNORMAL );
                               wxNORMAL, wxNORMAL );


    g_ItalicFont = new wxFont( g_DialogFontPointSize, wxFONTFAMILY_ROMAN,
                               wxFONTSTYLE_ITALIC, wxNORMAL );

    g_FixedFont = new wxFont( g_FixedFontPointSize, wxFONTFAMILY_MODERN,
    g_FixedFont = new wxFont( g_FixedFontPointSize, wxFONTFAMILY_MODERN,
                              wxNORMAL, wxNORMAL );
                              wxNORMAL, wxNORMAL );


@@ -483,6 +469,7 @@ void WinEDA_App::SetDefaultSearchPaths( void )
{
{
    size_t     i;
    size_t     i;
    wxString   path = m_BinDir;
    wxString   path = m_BinDir;
    wxPathList tmp;


    m_searchPaths.Clear();
    m_searchPaths.Clear();


@@ -497,7 +484,6 @@ void WinEDA_App::SetDefaultSearchPaths( void )
#endif
#endif
    wxFileName fn( path, wxEmptyString );
    wxFileName fn( path, wxEmptyString );



    /* User environment variable path is the first search path.  Chances are
    /* User environment variable path is the first search path.  Chances are
     * if the user is savvy enough to set an environment variable they know
     * if the user is savvy enough to set an environment variable they know
     * what they are doing. */
     * what they are doing. */
@@ -522,15 +508,44 @@ void WinEDA_App::SetDefaultSearchPaths( void )
    fn.AppendDir( wxT( "kicad" ) );
    fn.AppendDir( wxT( "kicad" ) );
    m_searchPaths.Add( fn.GetPath() );
    m_searchPaths.Add( fn.GetPath() );


    /* The normal OS program file install paths allow for binary to be
     * installed in a different path from the library files.  This is
     * useful for development purposes so the library and documentation
     * files do not need to be installed separately.  If someone can
     * figure out a way to implement this without #ifdef, please do. */
#ifdef __WXMSW__
    tmp.AddEnvList( wxT( "PROGRAMFILES" ) );
#else
    tmp.AddEnvList( wxT( "PATH" ) );
#endif

    for( i = 0; i < tmp.GetCount(); i++ )
    {
        fn = wxFileName( tmp[i], wxEmptyString );

        if( fn.GetPath().AfterLast( fn.GetPathSeparator() ) == wxT( "bin" ) )
            fn.RemoveLastDir();

        m_searchPaths.Add( fn.GetPath() );
        fn.AppendDir( wxT( "kicad" ) );
        m_searchPaths.Add( fn.GetPath() );
        fn.AppendDir( wxT( "share" ) );
        m_searchPaths.Add( fn.GetPath() );
        fn.RemoveLastDir();
        fn.RemoveLastDir();
        fn.AppendDir( wxT( "share" ) );
        m_searchPaths.Add( fn.GetPath() );
        fn.AppendDir( wxT( "kicad" ) );
        m_searchPaths.Add( fn.GetPath() );
    }

    /* Remove all non-existent paths from the list. */
    /* Remove all non-existent paths from the list. */
    for( i = 0; i < m_searchPaths.GetCount(); i++ )
    for( i = 0; i < m_searchPaths.GetCount(); i++ )
    {
    {
        wxLogDebug( wxT( "Checking if search path <" ) +
                    m_searchPaths[i] + wxT( "> exists." ) );
        if( !wxFileName::IsDirReadable( m_searchPaths[i] ) )
        if( !wxFileName::IsDirReadable( m_searchPaths[i] ) )
        {
        {
            wxLogDebug( wxT( "Removing non-existent path <" ) +
            wxLogDebug( wxT( "Removing <" ) + m_searchPaths[i] +
                        m_searchPaths[i] + wxT( "> from search path list." ) );
                        wxT( "> from search path list." ) );
            m_searchPaths.RemoveAt( i );
            m_searchPaths.RemoveAt( i );
            i -= 1;
            i -= 1;
        }
        }
@@ -546,7 +561,7 @@ void WinEDA_App::SetDefaultSearchPaths( void )
                fn.AppendDir( wxT( "library") );
                fn.AppendDir( wxT( "library") );
                if( fn.IsDirReadable() )
                if( fn.IsDirReadable() )
                {
                {
                    wxLogDebug( wxT( "Adding <%s> to library search path list" ),
                    wxLogDebug( wxT( "Adding <%s> to search path list" ),
                                fn.GetPath().c_str() );
                                fn.GetPath().c_str() );
                    m_libSearchPaths.Add( fn.GetPath() );
                    m_libSearchPaths.Add( fn.GetPath() );
                }
                }
@@ -555,7 +570,7 @@ void WinEDA_App::SetDefaultSearchPaths( void )
                fn.AppendDir( wxT( "doc") );
                fn.AppendDir( wxT( "doc") );
                if( fn.IsDirReadable() )
                if( fn.IsDirReadable() )
                {
                {
                    wxLogDebug( wxT( "Adding <%s> to library search path list" ),
                    wxLogDebug( wxT( "Adding <%s> to search path list" ),
                                fn.GetPath().c_str() );
                                fn.GetPath().c_str() );
                    m_libSearchPaths.Add( fn.GetPath() );
                    m_libSearchPaths.Add( fn.GetPath() );
                }
                }
@@ -568,7 +583,7 @@ void WinEDA_App::SetDefaultSearchPaths( void )


            if( fn.IsDirReadable() )
            if( fn.IsDirReadable() )
            {
            {
                wxLogDebug( wxT( "Adding <%s> to library search path list" ),
                wxLogDebug( wxT( "Adding <%s> to search path list" ),
                            fn.GetPath().c_str() );
                            fn.GetPath().c_str() );
                m_libSearchPaths.Add( fn.GetPath() );
                m_libSearchPaths.Add( fn.GetPath() );
            }
            }
@@ -591,7 +606,7 @@ void WinEDA_App::SetDefaultSearchPaths( void )


                if( fn.IsDirReadable() )
                if( fn.IsDirReadable() )
                {
                {
                    wxLogDebug( wxT( "Adding <%s> to library search path list" ),
                    wxLogDebug( wxT( "Adding <%s> to search path list" ),
                                fn.GetPath().c_str() );
                                fn.GetPath().c_str() );
                    m_libSearchPaths.Add( fn.GetPath() );
                    m_libSearchPaths.Add( fn.GetPath() );
                }
                }
@@ -625,44 +640,11 @@ void WinEDA_App::GetSettings()
    m_fileHistory.Load( *m_EDA_Config );
    m_fileHistory.Load( *m_EDA_Config );


    /* Set default font sizes */
    /* Set default font sizes */
    g_StdFontPointSize = m_EDA_Config->Read( wxT( "SdtFontSize" ),
                                             FONT_DEFAULT_SIZE );
    g_MsgFontPointSize = m_EDA_Config->Read( wxT( "MsgFontSize" ),
                                             FONT_DEFAULT_SIZE );
    g_DialogFontPointSize = m_EDA_Config->Read( wxT( "DialogFontSize" ),
    g_DialogFontPointSize = m_EDA_Config->Read( wxT( "DialogFontSize" ),
                                                FONT_DEFAULT_SIZE );
                                                FONT_DEFAULT_SIZE );
    g_FixedFontPointSize = m_EDA_Config->Read( wxT( "FixedFontSize" ),
    g_FixedFontPointSize = m_EDA_Config->Read( wxT( "FixedFontSize" ),
                                               FONT_DEFAULT_SIZE );
                                               FONT_DEFAULT_SIZE );


    /* Std font type */
    Line = m_EDA_Config->Read( wxT( "SdtFontType" ), wxEmptyString );
    if( !Line.IsEmpty() )
        g_StdFont->SetFaceName( Line );

    /* Sdt font style */
    ii = m_EDA_Config->Read( wxT( "SdtFontStyle" ), wxFONTFAMILY_ROMAN );
    g_StdFont->SetStyle( ii );

    /* Sdt font weight */
    ii = m_EDA_Config->Read( wxT( "SdtFontWeight" ), wxNORMAL );
    g_StdFont->SetWeight( ii );
    g_StdFont->SetPointSize( g_StdFontPointSize );

    /* Msg font type */
    Line = m_EDA_Config->Read( wxT( "MsgFontType" ), wxEmptyString );
    if( !Line.IsEmpty() )
        g_MsgFont->SetFaceName( Line );

    /* Msg font style */
    ii = m_EDA_Config->Read( wxT( "MsgFontStyle" ), wxFONTFAMILY_ROMAN );
    g_MsgFont->SetStyle( ii );

    /* Msg font weight */
    ii = m_EDA_Config->Read( wxT( "MsgFontWeight" ), wxNORMAL );
    g_MsgFont->SetWeight( ii );
    g_MsgFont->SetPointSize( g_MsgFontPointSize );


    Line = m_EDA_Config->Read( wxT( "DialogFontType" ), wxEmptyString );
    Line = m_EDA_Config->Read( wxT( "DialogFontType" ), wxEmptyString );
    if( !Line.IsEmpty() )
    if( !Line.IsEmpty() )
        g_DialogFont->SetFaceName( Line );
        g_DialogFont->SetFaceName( Line );
@@ -696,21 +678,10 @@ void WinEDA_App::SaveSettings()
    wxASSERT( m_EDA_Config != NULL );
    wxASSERT( m_EDA_Config != NULL );


    /* Sdt font settings */
    /* Sdt font settings */
    m_EDA_Config->Write( wxT( "SdtFontSize" ), g_StdFontPointSize );
    m_EDA_Config->Write( wxT( "SdtFontType" ), g_StdFont->GetFaceName() );


#if wxCHECK_VERSION( 2, 9, 0 )
#if wxCHECK_VERSION( 2, 9, 0 )
#warning TODO: under wxWidgets 3.0, see how to replace the next lines
#warning TODO: under wxWidgets 3.0, see how to replace the next lines
#else
#else
    m_EDA_Config->Write( wxT( "SdtFontStyle" ), g_StdFont->GetStyle() );
    m_EDA_Config->Write( wxT( "SdtFontWeight" ), g_StdFont->GetWeight() );

    /* Msg font settings */
    m_EDA_Config->Write( wxT( "MsgFontSize" ), g_MsgFontPointSize );
    m_EDA_Config->Write( wxT( "MsgFontType" ), g_MsgFont->GetFaceName() );
    m_EDA_Config->Write( wxT( "MsgFontStyle" ), g_MsgFont->GetStyle() );
    m_EDA_Config->Write( wxT( "MsgFontWeight" ), g_MsgFont->GetWeight() );

    /* Dialog font settings */
    /* Dialog font settings */
    m_EDA_Config->Write( wxT( "DialogFontSize" ), g_DialogFontPointSize );
    m_EDA_Config->Write( wxT( "DialogFontSize" ), g_DialogFontPointSize );
    m_EDA_Config->Write( wxT( "DialogFontType" ), g_DialogFont->GetFaceName() );
    m_EDA_Config->Write( wxT( "DialogFontType" ), g_DialogFont->GetFaceName() );
@@ -1035,36 +1006,35 @@ wxString WinEDA_App::GetLibraryFile( const wxString& filename )
 * path in lib path list ( but not the CWD )
 * path in lib path list ( but not the CWD )
 * @param aSubPathToSearch = Prefered sub path to search in path list (defualt = empty string)
 * @param aSubPathToSearch = Prefered sub path to search in path list (defualt = empty string)
 */
 */
wxString s_LastVisitedLibPath;      // Last lib directoty used when adding libraries
wxString WinEDA_App::ReturnLastVisitedLibraryPath( const wxString & aSubPathToSearch )
wxString WinEDA_App::ReturnLastVisitedLibraryPath( const wxString & aSubPathToSearch )
{
{
    if ( ! s_LastVisitedLibPath.IsEmpty() )
    if ( m_LastVisitedLibPath )
        return s_LastVisitedLibPath;
        return m_LastVisitedLibPath;


    wxString path;
    wxString path;


   /* Initialize default path to the main default lib path
   /* Initialize default path to the main default lib path
    * this is the second path in list (the first is the project path)
    * this is the second path in list (the first is the project path)
    */
    */
    unsigned pcount = wxGetApp().GetLibraryPathList().GetCount();
    unsigned pcount = m_libSearchPaths.GetCount();
    if ( pcount )
    if ( pcount )
    {
    {
        unsigned ipath = 0;
        unsigned ipath = 0;
        if ( wxGetApp().GetLibraryPathList()[0] == wxGetCwd() )
        if ( m_libSearchPaths[0] == wxGetCwd() )
            ipath = 1;
            ipath = 1;


        // First choice fo path:
        // First choice of path:
        if ( ipath < pcount )
        if ( ipath < pcount )
            path = wxGetApp().GetLibraryPathList()[ipath];
            path = m_libSearchPaths[ipath];


        // Search a sub path matching aSubPathToSearch
        // Search a sub path matching aSubPathToSearch
        if ( ! aSubPathToSearch.IsEmpty() )
        if ( ! aSubPathToSearch.IsEmpty() )
        {
        {
            for ( ; ipath < pcount; ipath++ )
            for ( ; ipath < pcount; ipath++ )
            {
            {
                if ( wxGetApp().GetLibraryPathList()[ipath].Contains( aSubPathToSearch ) )
                if ( m_libSearchPaths[ipath].Contains( aSubPathToSearch ) )
                {
                {
                    path = wxGetApp().GetLibraryPathList()[ipath];
                    path = m_libSearchPaths[ipath];
                    break;
                    break;
                }
                }
            }
            }
@@ -1078,7 +1048,7 @@ wxString WinEDA_App::ReturnLastVisitedLibraryPath( const wxString & aSubPathToSe


void WinEDA_App::SaveLastVisitedLibraryPath( const wxString & aPath)
void WinEDA_App::SaveLastVisitedLibraryPath( const wxString & aPath)
{
{
    s_LastVisitedLibPath = aPath;
    m_LastVisitedLibPath = aPath;
}
}


/** ReturnFilenameWithRelativePathInLibPath
/** ReturnFilenameWithRelativePathInLibPath
@@ -1098,14 +1068,14 @@ wxString WinEDA_App::ReturnFilenameWithRelativePathInLibPath(const wxString & aF
    wxFileName fn = aFullFilename;
    wxFileName fn = aFullFilename;
    wxString filename = aFullFilename;
    wxString filename = aFullFilename;
    int        pathlen = -1;                                                    // path len, used to find the better subpath within defualts paths
    int        pathlen = -1;                                                    // path len, used to find the better subpath within defualts paths
    if( GetLibraryPathList().Index( fn.GetPath() ) != wxNOT_FOUND )  // Ok, trivial case
    if( m_libSearchPaths.Index( fn.GetPath() ) != wxNOT_FOUND )  // Ok, trivial case
        filename = fn.GetName();
        filename = fn.GetName();
    else                                                                        // not in the default, : see if this file is in a subpath:
    else                                                                        // not in the default, : see if this file is in a subpath:
    {
    {
        filename = fn.GetPathWithSep() + fn.GetFullName();
        filename = fn.GetPathWithSep() + fn.GetFullName();
        for( unsigned kk = 0; kk < wxGetApp().GetLibraryPathList().GetCount(); kk++ )
        for( unsigned kk = 0; kk < m_libSearchPaths.GetCount(); kk++ )
        {
        {
            if( fn.MakeRelativeTo(GetLibraryPathList()[kk] ) )
            if( fn.MakeRelativeTo(m_libSearchPaths[kk] ) )
            {
            {
                if( pathlen < 0                             // a subpath is found
                if( pathlen < 0                             // a subpath is found
                   || pathlen > (int) fn.GetPath().Len() )  // a better subpath if found
                   || pathlen > (int) fn.GetPath().Len() )  // a better subpath if found
@@ -1122,7 +1092,6 @@ wxString WinEDA_App::ReturnFilenameWithRelativePathInLibPath(const wxString & aF
}
}





/** FindLibraryPath
/** FindLibraryPath
 * Kicad saves user defined library files that are not in the standard
 * Kicad saves user defined library files that are not in the standard
 * library search path list with the full file path.  Calling the library
 * library search path list with the full file path.  Calling the library
@@ -1140,7 +1109,7 @@ wxString WinEDA_App::FindLibraryPath( const wxString& aFileName )
}
}


/** Function RemoveLibraryPath
/** Function RemoveLibraryPath
 * Removes the given ptah from the libary path list
 * Removes the given path from the library path list
 * @param path = the path to remove
 * @param path = the path to remove
 */
 */
void WinEDA_App::RemoveLibraryPath( const wxString& path )
void WinEDA_App::RemoveLibraryPath( const wxString& path )
Loading