Commit 20cb87a8 authored by charras's avatar charras
Browse files

better handling of libraries paths (removed g_RealLibraryBuffer that had no...

better handling of libraries paths (removed g_RealLibraryBuffer that had no sense with the new code), mainly in Eeschema
TODO: better handling of user lib paths (more than one path)
parent 89e7f965
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@
#include "appl_wxstruct.h"


#define BUILD_VERSION wxT("(20090406-unstable)")
#define BUILD_VERSION wxT("(20090414-unstable)")

wxString g_BuildVersion

+5 −1
Original line number Diff line number Diff line
@@ -66,7 +66,6 @@ const wxString AllFilesWildcard( _( "All files (*)|*") );
wxString    g_ProductName = wxT( "KiCad E.D.A.  " );
bool        g_ShowPageLimits = true;
int         g_GridColor = DARKGRAY;
wxString    g_RealLibDirBuffer;
wxString    g_UserLibDirBuffer;
int         g_DebugLevel;
int         g_MouseOldButtons;
@@ -96,6 +95,11 @@ int g_UnitMetric; // display units mm = 1, inches = 0, cm = 2
/* Draw color for moving objects: */
int         g_GhostColor;

/* predefined colors used in kicad.
 * Please: if you change a value, remember these values are carefully chosen
 * to have good results in pcbnew, that uses the ORed value of basic colors
 * when displaying superimposed objects
 */
StructColors ColorRefs[NBCOLOR] =
{
    { 0,  0,   0,  BLACK, wxT("BLACK"), DARKDARKGRAY},
+63 −8
Original line number Diff line number Diff line
@@ -700,7 +700,7 @@ void WinEDA_App::SaveSettings()
    m_EDA_Config->Write( wxT( "SdtFontType" ), g_StdFont->GetFaceName() );

#if wxCHECK_VERSION( 2, 9, 0 )
#warning 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
    m_EDA_Config->Write( wxT( "SdtFontStyle" ), g_StdFont->GetStyle() );
    m_EDA_Config->Write( wxT( "SdtFontWeight" ), g_StdFont->GetWeight() );
@@ -1030,23 +1030,78 @@ wxString WinEDA_App::GetLibraryFile( const wxString& filename )
    return FindFileInSearchPaths( filename, &subdirs );
}

/** ReturnLastVisitedLibraryPath
 * Returns the last visited library directory, or (if void) the first
 * path in lib path list ( but not the CWD )
 * @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 )
{
    if ( ! s_LastVisitedLibPath.IsEmpty() )
        return s_LastVisitedLibPath;

/**
    wxString path;

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

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

        // Search a sub path matching aSubPathToSearch
        if ( ! aSubPathToSearch.IsEmpty() )
        {
            for ( ; ipath < pcount; ipath++ )
            {
                if ( wxGetApp().GetLibraryPathList()[ipath].Contains( aSubPathToSearch ) )
                {
                    path = wxGetApp().GetLibraryPathList()[ipath];
                    break;
                }
            }
        }
    }

    if ( path.IsEmpty() )
        path = wxGetCwd();
    return path;
}

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


/** FindLibraryPath
 * Kicad saves user defined library files that are not in the standard
 * library search path list with the full file path.  Calling the library
 * search path list with a user library file will fail.  This helper method
 * solves that problem.
 *
 * Returns a wxEmptyString if library file is not found.
 * @param fileName
 * @return a wxEmptyString if library file is not found.
 */
wxString WinEDA_App::FindLibraryPath( const wxString& fileName )
wxString WinEDA_App::FindLibraryPath( const wxString& aFileName )
{
    if( wxFileName::FileExists( fileName ) )
        return fileName;
    if( wxFileName::FileExists( aFileName ) )
        return aFileName;
    else
        return m_libSearchPaths.FindValidPath( fileName );
        return m_libSearchPaths.FindValidPath( aFileName );
}

/** Function RemoveLibraryPath
 * Removes the given ptah from the libary path list
 * @param path = the path to remove
 */
void WinEDA_App::RemoveLibraryPath( const wxString& path )
{
    if( m_libSearchPaths.Index( path, wxFileName::IsCaseSensitive() ) != wxNOT_FOUND )
+0 −61
Original line number Diff line number Diff line
@@ -1462,67 +1462,6 @@ void GRSFilledRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
}


/*******************************/
/* Routines used to draw texts */
/*******************************/

/*********************************************/
void GRSetFont( wxDC* DC, wxFont* Font )
/*********************************************/
/* Routine to set the current font */
{
    DC->SetFont( *Font );
}


/*********************************************************/
void GRSetTextFgColor( wxDC* DC, int Color )
/*********************************************************/
/* Set the foreground color used to draw texts */
{
    DC->SetTextForeground( wxColour( ColorRefs[Color].m_Red,
                                     ColorRefs[Color].m_Green,
                                     ColorRefs[Color].m_Blue ) );
}


void GRSetTextFgColor( wxDC* DC, wxFont*, int Color )
{
    DC->SetTextForeground( wxColour( ColorRefs[Color].m_Red,
                                     ColorRefs[Color].m_Green,
                                     ColorRefs[Color].m_Blue ) );
}


/********************************/
void GRResetTextFgColor( wxDC* DC )
/********************************/
/* Set the foreground color used to draw texts to the default value */
{
    GRSetTextFgColor( DC, Text_Color );
}


/*********************************************************/
void GRSetTextBgColor( wxDC* DC, int Color )
/*********************************************************/
/* Set the background color used to draw texts */
{
    Color &= MASKCOLOR; // keep only the bits used to select the color
    DC->SetTextBackground( wxColour( ColorRefs[Color].m_Red,
                                     ColorRefs[Color].m_Green,
                                     ColorRefs[Color].m_Blue ) );
}


void GRSetTextBgColor( wxDC* DC, wxFont*, int Color )
{
    Color &= MASKCOLOR; // keep only the bits used to select the color
    DC->SetTextBackground( wxColour( ColorRefs[Color].m_Red,
                                     ColorRefs[Color].m_Green,
                                     ColorRefs[Color].m_Blue ) );
}

#ifdef USE_CLIP_FILLED_POLYGONS

/** Function ClipAndDrawFilledPoly
+12 −12
Original line number Diff line number Diff line
@@ -340,7 +340,7 @@ PARAM_CFG_INT::PARAM_CFG_INT( bool Insetup, const wxChar* ident, int* ptparam,


/** ReadParam
 * read the value of parameter thi stored in aConfig
 * read the value of parameter this stored in aConfig
 * @param aConfig = the wxConfigBase that store the parameter
 */
void PARAM_CFG_INT::ReadParam( wxConfigBase* aConfig )
@@ -357,7 +357,7 @@ void PARAM_CFG_INT::ReadParam( wxConfigBase* aConfig )


/** SaveParam
 * the the value of parameter thi stored in aConfig
 * save the value of parameter this stored in aConfig
 * @param aConfig = the wxConfigBase that can store the parameter
 */
void PARAM_CFG_INT::SaveParam( wxConfigBase* aConfig )
@@ -394,7 +394,7 @@ PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR( bool Insetup,


/** ReadParam
 * read the value of parameter thi stored in aConfig
 * read the value of parameter this stored in aConfig
 * @param aConfig = the wxConfigBase that store the parameter
 */
void PARAM_CFG_SETCOLOR::ReadParam( wxConfigBase* aConfig )
@@ -410,7 +410,7 @@ void PARAM_CFG_SETCOLOR::ReadParam( wxConfigBase* aConfig )


/** SaveParam
 * the the value of parameter thi stored in aConfig
 * save the the value of parameter this stored in aConfig
 * @param aConfig = the wxConfigBase that can store the parameter
 */
void PARAM_CFG_SETCOLOR::SaveParam( wxConfigBase* aConfig )
@@ -451,7 +451,7 @@ PARAM_CFG_DOUBLE::PARAM_CFG_DOUBLE( bool Insetup,


/** ReadParam
 * read the value of parameter thi stored in aConfig
 * read the value of parameter this stored in aConfig
 * @param aConfig = the wxConfigBase that store the parameter
 */
void PARAM_CFG_DOUBLE::ReadParam( wxConfigBase* aConfig )
@@ -475,7 +475,7 @@ void PARAM_CFG_DOUBLE::ReadParam( wxConfigBase* aConfig )


/** SaveParam
 * the the value of parameter thi stored in aConfig
 * save the the value of parameter this stored in aConfig
 * @param aConfig = the wxConfigBase that can store the parameter
 */
void PARAM_CFG_DOUBLE::SaveParam( wxConfigBase* aConfig )
@@ -511,7 +511,7 @@ PARAM_CFG_BOOL::PARAM_CFG_BOOL( bool Insetup,


/** ReadParam
 * read the value of parameter thi stored in aConfig
 * read the value of parameter this stored in aConfig
 * @param aConfig = the wxConfigBase that store the parameter
 */
void PARAM_CFG_BOOL::ReadParam( wxConfigBase* aConfig )
@@ -525,7 +525,7 @@ void PARAM_CFG_BOOL::ReadParam( wxConfigBase* aConfig )


/** SaveParam
 * the the value of parameter thi stored in aConfig
 * save the the value of parameter this stored in aConfig
 * @param aConfig = the wxConfigBase that can store the parameter
 */
void PARAM_CFG_BOOL::SaveParam( wxConfigBase* aConfig )
@@ -557,7 +557,7 @@ PARAM_CFG_WXSTRING::PARAM_CFG_WXSTRING( bool Insetup, const wxChar* ident,


/** ReadParam
 * read the value of parameter thi stored in aConfig
 * read the value of parameter this stored in aConfig
 * @param aConfig = the wxConfigBase that store the parameter
 */
void PARAM_CFG_WXSTRING::ReadParam( wxConfigBase* aConfig )
@@ -569,7 +569,7 @@ void PARAM_CFG_WXSTRING::ReadParam( wxConfigBase* aConfig )


/** SaveParam
 * the the value of parameter thi stored in aConfig
 * save the value of parameter this stored in aConfig
 * @param aConfig = the wxConfigBase that can store the parameter
 */
void PARAM_CFG_WXSTRING::SaveParam( wxConfigBase* aConfig )
@@ -591,7 +591,7 @@ PARAM_CFG_LIBNAME_LIST::PARAM_CFG_LIBNAME_LIST( const wxChar* ident,


/** ReadParam
 * read the value of parameter thi stored in aConfig
 * read the value of parameter this stored in aConfig
 * @param aConfig = the wxConfigBase that store the parameter
 */
void PARAM_CFG_LIBNAME_LIST::ReadParam( wxConfigBase* aConfig )
@@ -615,7 +615,7 @@ void PARAM_CFG_LIBNAME_LIST::ReadParam( wxConfigBase* aConfig )


/** SaveParam
 * the the value of parameter thi stored in aConfig
 * save the value of parameter this in aConfig (list of parameters)
 * @param aConfig = the wxConfigBase that can store the parameter
 */
void PARAM_CFG_LIBNAME_LIST::SaveParam( wxConfigBase* aConfig )
Loading