void DIALOG_NETLIST::OnOpenNetlistClick( wxCommandEvent& event )
{
    wxString lastPath = wxFileName( Prj().GetProjectFullName() ).GetPath();

    wxString lastNetlistRead = m_parent->GetLastNetListRead();

    if( !lastNetlistRead.IsEmpty() && !wxFileName::FileExists( lastNetlistRead ) )
    {
        lastNetlistRead = wxEmptyString;
    }
    else
    {
        wxFileName fn = lastNetlistRead;
        lastPath = fn.GetPath();
        lastNetlistRead = fn.GetFullName();
    }

    wxLogDebug( wxT( "Last net list read path '%s', file name '%s'." ),
                GetChars( lastPath ), GetChars( lastNetlistRead ) );

    wxFileDialog FilesDialog( this, _( "Select Netlist" ), lastPath, lastNetlistRead,
                              NetlistFileWildcard, wxFD_DEFAULT_STYLE | wxFD_FILE_MUST_EXIST );

    if( FilesDialog.ShowModal() != wxID_OK )
        return;

    m_NetlistFilenameCtrl->SetValue( FilesDialog.GetPath() );
}
Beispiel #2
0
void DIALOG_CVPCB_CONFIG::OnBrowseModDocFile( wxCommandEvent& event )
{
    wxString FullFileName;
    wxString docpath, filename;

    docpath = wxGetApp().ReturnLastVisitedLibraryPath( wxT( "doc" ) );

    wxFileDialog FilesDialog( this, _( "Footprint document file:" ), docpath,
                              wxEmptyString, PdfFileWildcard,
                              wxFD_DEFAULT_STYLE | wxFD_FILE_MUST_EXIST );

    if( FilesDialog.ShowModal() != wxID_OK )
        return;

    FullFileName = FilesDialog.GetPath();

    /* If the path is already in the library search paths
     * list, just add the library name to the list.  Otherwise, add
     * the library name with the full or relative path.
     * the relative path, when possible is preferable,
     * because it preserve use of default libraries paths, when the path is
     * a sub path of these default paths
     */
    wxFileName fn = FullFileName;
    wxGetApp().SaveLastVisitedLibraryPath( fn.GetPath() );

    filename = wxGetApp().ReturnFilenameWithRelativePathInLibPath( FullFileName );
    m_TextHelpModulesFileName->SetValue( filename );
}
/* Insert or add a library to the library list:
 *   The new library is put in list before (insert button) the selection,
 *   or added (add button) to end of list
 */
void DIALOG_CONFIG_EQUFILES::OnAddFiles( wxCommandEvent& event )
{
    wxString   equFilename, wildcard;
    wxFileName fn;

    wildcard = EquFilesWildcard;
    wxListBox* list = m_ListEquiv;

    // Get a default path to open the file dialog:
    wxString libpath;
    wxArrayInt selectedRows	= m_gridEnvVars->GetSelectedRows();

    int row = selectedRows.GetCount() ? selectedRows[0] :
                m_gridEnvVars->GetGridCursorRow();

    libpath = m_gridEnvVars->GetCellValue( wxGridCellCoords( row, 1 ) );

    wxFileDialog FilesDialog( this, _( "Equ files:" ), libpath,
                              wxEmptyString, wildcard,
                              wxFD_DEFAULT_STYLE | wxFD_MULTIPLE );

    if( FilesDialog.ShowModal() != wxID_OK )
        return;

    wxArrayString Filenames;
    FilesDialog.GetPaths( Filenames );

    for( unsigned jj = 0; jj < Filenames.GetCount(); jj++ )
    {
        fn = Filenames[jj];
        equFilename.Empty();

        if( isPathRelativeAllowed() ) // try to use relative path
        {
            for( row = 0; row < getEnvVarCount(); row++ )
            {
                libpath = m_gridEnvVars->GetCellValue( wxGridCellCoords( row, 1 ) );

                if( fn.MakeRelativeTo( libpath ) )
                {
                    equFilename.Printf( wxT("${%s}%c%s"),
                                        GetChars( m_gridEnvVars->GetCellValue( wxGridCellCoords( row, 0 ) ) ),
                                        fn.GetPathSeparator(),
                                        GetChars( fn.GetFullPath() ) );
                    break;
                }
            }
        }

        if( equFilename.IsEmpty() )
            equFilename = Filenames[jj];

        // Add or insert new library name, if not already in list
        if( list->FindString( equFilename, fn.IsCaseSensitive() ) == wxNOT_FOUND )
        {
            m_ListChanged = true;
            equFilename.Replace( wxT("\\"), wxT("/") );     // Use unix separators only.
            list->Append( equFilename );
        }
        else
        {
            wxString msg;
            msg.Printf( _( "File '%s' already exists in list" ), equFilename.GetData() );
            DisplayError( this, msg );
        }
    }
}
Beispiel #4
0
/* Insert or add a library to the library list:
 *   The new library is put in list before (insert button) the selection,
 *   or added (add button) to end of list
 * The real list (m_Parent->m_ComponentLibFiles) is not changed, so the change
 * can be canceled
 */
void DIALOG_EESCHEMA_CONFIG::OnAddOrInsertLibClick( wxCommandEvent& event )
{
    int        ii;
    wxString   libfilename;
    wxFileName fn;
    wxArrayInt selections;

    m_ListLibr->GetSelections( selections );

    ii = selections.GetCount();

    if( ii > 0 )
        ii = selections[0];
    else
        ii = 0;

    wxString libpath;
    libpath = m_DefaultLibraryPathslistBox->GetStringSelection();

    if ( libpath.IsEmpty() )
        libpath = wxGetApp().ReturnLastVisitedLibraryPath();

    wxFileDialog FilesDialog( this, _( "Library files:" ), libpath,
                              wxEmptyString, CompLibFileWildcard,
                              wxFD_DEFAULT_STYLE | wxFD_MULTIPLE );

    if( FilesDialog.ShowModal() != wxID_OK )
        return;

    wxArrayString Filenames;
    FilesDialog.GetPaths( Filenames );

    for( unsigned jj = 0; jj < Filenames.GetCount(); jj++ )
    {
        fn = Filenames[jj];

        if ( jj == 0 )
            wxGetApp().SaveLastVisitedLibraryPath( fn.GetPath() );

        /* If the library path is already in the library search paths
         * list, just add the library name to the list.  Otherwise, add
         * the library name with the full or relative path.
         * the relative path, when possible is preferable,
         * because it preserve use of default libraries paths, when the path
         * is a sub path of these default paths
         */
        libfilename = wxGetApp().ReturnFilenameWithRelativePathInLibPath( fn.GetFullPath() );

        // Remove extension:
        fn = libfilename;
        fn.SetExt(wxEmptyString);
        libfilename = fn.GetFullPath();

        //Add or insert new library name, if not already in list
        if( m_ListLibr->FindString( libfilename, fn.IsCaseSensitive() ) == wxNOT_FOUND )
        {
            m_LibListChanged = true;

            if( event.GetId() == ID_ADD_LIB )
                m_ListLibr->Append( libfilename );
            else
                m_ListLibr->Insert( libfilename, ii++ );
        }
        else
        {
            wxString msg = wxT( "<" ) + libfilename + wxT( "> : " ) +
                           _( "Library already in use" );
            DisplayError( this, msg );
        }
    }
}