Commit 5fd409f8 authored by Wayne Stambaugh's avatar Wayne Stambaugh

Add user write permission tests to CVPcb and other minor fixes.

* Check user write permissions before saving project and net list files.
* Append read only to file name and path in title bar when the user
  does not have write privileges.
* Don't display file dialog every time the net list or project file is
  saved.
* Add save as and save project file as commands.
* Make capitalization of CVPcb consistent in all user strings.
* Doxygen comment and coding style policy fixes.
parent 8f1b5697
......@@ -4,6 +4,7 @@
#include "fctsys.h"
#include "appl_wxstruct.h"
#include "id.h"
#include "common.h"
#include "gestfich.h"
#include "param_config.h"
......@@ -16,15 +17,6 @@
#define GROUPEQU wxT("/cvpcb/libraries")
/**
* Return project file parameter list for CVPcb.
*
* Populate the project file parameter array specific to CVPcb if it hasn't
* already been populated and return a reference to the array to the caller.
* Creating the parameter list at run time has the advantage of being able
* to define local variables. The old method of statically building the array
* at compile time requiring global variable definitions.
*/
PARAM_CFG_ARRAY& CVPCB_MAINFRAME::GetProjectFileParameters( void )
{
if( !m_projectFileParams.empty() )
......@@ -48,19 +40,9 @@ PARAM_CFG_ARRAY& CVPCB_MAINFRAME::GetProjectFileParameters( void )
}
/**
* Reads the configuration
* 1 - bed cvpcb.cnf
* 2 - if not in path of <cvpcb.exe> / cvpcb.cnf
* 3 - If not found: init variables to default values
*
* Note:
* The path of the executable must be in cvpcb.exe.
*
*/
void CVPCB_MAINFRAME::LoadProjectFile( const wxString& FileName )
void CVPCB_MAINFRAME::LoadProjectFile( const wxString& aFileName )
{
wxFileName fn = FileName;
wxFileName fn = aFileName;
m_ModuleLibNames.Clear();
m_AliasLibNames.Clear();
......@@ -70,8 +52,7 @@ void CVPCB_MAINFRAME::LoadProjectFile( const wxString& FileName )
wxGetApp().RemoveLibraryPath( m_UserLibraryPath );
wxGetApp().ReadProjectConfig( fn.GetFullPath(), GROUP,
GetProjectFileParameters(), FALSE );
wxGetApp().ReadProjectConfig( fn.GetFullPath(), GROUP, GetProjectFileParameters(), false );
if( m_NetlistFileExtension.IsEmpty() )
m_NetlistFileExtension = wxT( "net" );
......@@ -81,24 +62,28 @@ void CVPCB_MAINFRAME::LoadProjectFile( const wxString& FileName )
}
void CVPCB_MAINFRAME::Update_Config( wxCommandEvent& event )
void CVPCB_MAINFRAME::SaveProjectFile( wxCommandEvent& aEvent )
{
SaveProjectFile( m_NetlistFileName.GetFullPath() );
}
wxFileName fn = m_NetlistFileName;
fn.SetExt( ProjectFileExtension );
void CVPCB_MAINFRAME::SaveProjectFile( const wxString& fileName )
{
wxFileName fn = fileName;
if( aEvent.GetId() == ID_SAVE_PROJECT_AS || !m_NetlistFileName.IsOk() )
{
wxFileDialog dlg( this, _( "Save Project File" ), fn.GetPath(),
wxEmptyString, ProjectFileWildcard, wxFD_SAVE );
fn.SetExt( ProjectFileExtension );
if( dlg.ShowModal() == wxID_CANCEL )
return;
fn = dlg.GetPath();
wxFileDialog dlg( this, _( "Save Project File" ), fn.GetPath(),
fn.GetFullName(), ProjectFileWildcard, wxFD_SAVE );
if( !fn.HasExt() )
fn.SetExt( ProjectFileExtension );
}
if( dlg.ShowModal() == wxID_CANCEL )
if( !IsWritable( fn ) )
return;
wxGetApp().WriteProjectConfig( dlg.GetPath(), GROUP,
GetProjectFileParameters() );
wxGetApp().WriteProjectConfig( fn.GetFullPath(), GROUP, GetProjectFileParameters() );
}
......@@ -32,60 +32,53 @@ static const wxString FootprintDocFileEntry( wxT( "footprints_doc_file" ) );
BEGIN_EVENT_TABLE( CVPCB_MAINFRAME, EDA_BASE_FRAME )
EVT_MENU_RANGE( wxID_FILE1, wxID_FILE9, CVPCB_MAINFRAME::LoadNetList )
// Menu events
EVT_MENU( ID_LOAD_PROJECT,
CVPCB_MAINFRAME::LoadNetList )
EVT_MENU( ID_SAVE_PROJECT,
CVPCB_MAINFRAME::SaveQuitCvpcb )
EVT_MENU( wxID_EXIT,
CVPCB_MAINFRAME::OnQuit )
EVT_MENU( wxID_HELP,
CVPCB_MAINFRAME::GetKicadHelp )
EVT_MENU( wxID_ABOUT,
CVPCB_MAINFRAME::GetKicadAbout )
EVT_MENU( wxID_PREFERENCES,
CVPCB_MAINFRAME::ConfigCvpcb )
EVT_MENU( ID_CONFIG_SAVE,
CVPCB_MAINFRAME::Update_Config )
EVT_MENU( ID_CVPCB_CONFIG_KEEP_OPEN_ON_SAVE,
CVPCB_MAINFRAME::OnKeepOpenOnSave )
EVT_MENU_RANGE( ID_LANGUAGE_CHOICE,
ID_LANGUAGE_CHOICE_END,
CVPCB_MAINFRAME::SetLanguage )
// Toolbar events
EVT_TOOL( ID_CVPCB_QUIT, CVPCB_MAINFRAME::OnQuit )
EVT_TOOL( ID_CVPCB_READ_INPUT_NETLIST, CVPCB_MAINFRAME::LoadNetList )
EVT_TOOL( ID_CVPCB_SAVEQUITCVPCB, CVPCB_MAINFRAME::SaveQuitCvpcb )
EVT_TOOL( ID_CVPCB_CREATE_CONFIGWINDOW, CVPCB_MAINFRAME::ConfigCvpcb )
EVT_TOOL( ID_CVPCB_CREATE_SCREENCMP, CVPCB_MAINFRAME::DisplayModule )
EVT_TOOL( ID_CVPCB_GOTO_FIRSTNA, CVPCB_MAINFRAME::ToFirstNA )
EVT_TOOL( ID_CVPCB_GOTO_PREVIOUSNA, CVPCB_MAINFRAME::ToPreviousNA )
EVT_TOOL( ID_CVPCB_DEL_ASSOCIATIONS, CVPCB_MAINFRAME::DelAssociations )
EVT_TOOL( ID_CVPCB_AUTO_ASSOCIE, CVPCB_MAINFRAME::AssocieModule )
EVT_TOOL( ID_CVPCB_CREATE_STUFF_FILE, CVPCB_MAINFRAME::WriteStuffList )
EVT_TOOL( ID_PCB_DISPLAY_FOOTPRINT_DOC, CVPCB_MAINFRAME::DisplayDocFile )
EVT_TOOL( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST,
CVPCB_MAINFRAME::OnSelectFilteringFootprint )
EVT_TOOL( ID_CVPCB_FOOTPRINT_DISPLAY_FULL_LIST,
CVPCB_MAINFRAME::OnSelectFilteringFootprint )
// Frame events
EVT_CHAR( CVPCB_MAINFRAME::OnChar )
EVT_CLOSE( CVPCB_MAINFRAME::OnCloseWindow )
EVT_SIZE( CVPCB_MAINFRAME::OnSize )
// List item events
EVT_LIST_ITEM_SELECTED( ID_CVPCB_FOOTPRINT_LIST, CVPCB_MAINFRAME::OnLeftClick )
EVT_LIST_ITEM_ACTIVATED( ID_CVPCB_FOOTPRINT_LIST, CVPCB_MAINFRAME::OnLeftDClick )
EVT_LIST_ITEM_SELECTED( ID_CVPCB_COMPONENT_LIST, CVPCB_MAINFRAME::OnSelectComponent )
EVT_UPDATE_UI( ID_CVPCB_CONFIG_KEEP_OPEN_ON_SAVE,
CVPCB_MAINFRAME::OnUpdateKeepOpenOnSave )
END_EVENT_TABLE() CVPCB_MAINFRAME::CVPCB_MAINFRAME( const wxString& title, long style ) :
EVT_MENU_RANGE( wxID_FILE1, wxID_FILE9, CVPCB_MAINFRAME::LoadNetList )
// Menu events
EVT_MENU( ID_LOAD_PROJECT, CVPCB_MAINFRAME::LoadNetList )
EVT_MENU( wxID_SAVE, CVPCB_MAINFRAME::SaveQuitCvpcb )
EVT_MENU( wxID_SAVEAS, CVPCB_MAINFRAME::SaveQuitCvpcb )
EVT_MENU( wxID_EXIT, CVPCB_MAINFRAME::OnQuit )
EVT_MENU( wxID_HELP, CVPCB_MAINFRAME::GetKicadHelp )
EVT_MENU( wxID_ABOUT, CVPCB_MAINFRAME::GetKicadAbout )
EVT_MENU( wxID_PREFERENCES, CVPCB_MAINFRAME::ConfigCvpcb )
EVT_MENU( ID_SAVE_PROJECT, CVPCB_MAINFRAME::SaveProjectFile )
EVT_MENU( ID_SAVE_PROJECT_AS, CVPCB_MAINFRAME::SaveProjectFile )
EVT_MENU( ID_CVPCB_CONFIG_KEEP_OPEN_ON_SAVE, CVPCB_MAINFRAME::OnKeepOpenOnSave )
EVT_MENU_RANGE( ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END, CVPCB_MAINFRAME::SetLanguage )
// Toolbar events
EVT_TOOL( ID_CVPCB_QUIT, CVPCB_MAINFRAME::OnQuit )
EVT_TOOL( ID_CVPCB_READ_INPUT_NETLIST, CVPCB_MAINFRAME::LoadNetList )
EVT_TOOL( ID_CVPCB_CREATE_CONFIGWINDOW, CVPCB_MAINFRAME::ConfigCvpcb )
EVT_TOOL( ID_CVPCB_CREATE_SCREENCMP, CVPCB_MAINFRAME::DisplayModule )
EVT_TOOL( ID_CVPCB_GOTO_FIRSTNA, CVPCB_MAINFRAME::ToFirstNA )
EVT_TOOL( ID_CVPCB_GOTO_PREVIOUSNA, CVPCB_MAINFRAME::ToPreviousNA )
EVT_TOOL( ID_CVPCB_DEL_ASSOCIATIONS, CVPCB_MAINFRAME::DelAssociations )
EVT_TOOL( ID_CVPCB_AUTO_ASSOCIE, CVPCB_MAINFRAME::AssocieModule )
EVT_TOOL( ID_CVPCB_CREATE_STUFF_FILE, CVPCB_MAINFRAME::WriteStuffList )
EVT_TOOL( ID_PCB_DISPLAY_FOOTPRINT_DOC, CVPCB_MAINFRAME::DisplayDocFile )
EVT_TOOL( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST,
CVPCB_MAINFRAME::OnSelectFilteringFootprint )
EVT_TOOL( ID_CVPCB_FOOTPRINT_DISPLAY_FULL_LIST,
CVPCB_MAINFRAME::OnSelectFilteringFootprint )
// Frame events
EVT_CHAR( CVPCB_MAINFRAME::OnChar )
EVT_CLOSE( CVPCB_MAINFRAME::OnCloseWindow )
EVT_SIZE( CVPCB_MAINFRAME::OnSize )
// List item events
EVT_LIST_ITEM_SELECTED( ID_CVPCB_FOOTPRINT_LIST, CVPCB_MAINFRAME::OnLeftClick )
EVT_LIST_ITEM_ACTIVATED( ID_CVPCB_FOOTPRINT_LIST, CVPCB_MAINFRAME::OnLeftDClick )
EVT_LIST_ITEM_SELECTED( ID_CVPCB_COMPONENT_LIST, CVPCB_MAINFRAME::OnSelectComponent )
EVT_UPDATE_UI( ID_CVPCB_CONFIG_KEEP_OPEN_ON_SAVE, CVPCB_MAINFRAME::OnUpdateKeepOpenOnSave )
END_EVENT_TABLE()
CVPCB_MAINFRAME::CVPCB_MAINFRAME( const wxString& title, long style ) :
EDA_BASE_FRAME( NULL, CVPCB_FRAME, title, wxDefaultPosition, wxDefaultSize, style )
{
m_FrameName = wxT( "CvpcbFrame" );
......@@ -116,8 +109,10 @@ END_EVENT_TABLE() CVPCB_MAINFRAME::CVPCB_MAINFRAME( const wxString& title, long
SetAutoLayout( true );
LoadSettings();
if( m_FrameSize.x < FRAME_MIN_SIZE_X )
m_FrameSize.x = FRAME_MIN_SIZE_X;
if( m_FrameSize.y < FRAME_MIN_SIZE_Y )
m_FrameSize.y = FRAME_MIN_SIZE_Y;
......@@ -154,16 +149,16 @@ END_EVENT_TABLE() CVPCB_MAINFRAME::CVPCB_MAINFRAME( const wxString& title, long
if( m_HToolBar )
m_auimgr.AddPane( m_HToolBar,
wxAuiPaneInfo( horiz ).Name( wxT( "m_HToolBar" ) ).Top() );
wxAuiPaneInfo( horiz ).Name( wxT( "m_HToolBar" ) ).Top() );
if( m_ListCmp )
m_auimgr.AddPane( m_ListCmp,
wxAuiPaneInfo( horiz ).Name( wxT( "m_ListCmp" ) ).CentrePane() );
wxAuiPaneInfo( horiz ).Name( wxT( "m_ListCmp" ) ).CentrePane() );
if( m_FootprintList )
m_auimgr.AddPane( m_FootprintList,
wxAuiPaneInfo( horiz ).Name( wxT( "m_FootprintList" ) ).
Right().BestSize( (int) ( m_FrameSize.x * 0.36 ), m_FrameSize.y ) );
wxAuiPaneInfo( horiz ).Name( wxT( "m_FootprintList" ) ).
Right().BestSize( (int) ( m_FrameSize.x * 0.36 ), m_FrameSize.y ) );
m_auimgr.Update();
}
......@@ -175,8 +170,7 @@ CVPCB_MAINFRAME::~CVPCB_MAINFRAME()
if( config )
{
int state = m_HToolBar->GetToolState(
ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST );
int state = m_HToolBar->GetToolState( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST );
config->Write( wxT( FILTERFOOTPRINTKEY ), state );
}
......@@ -184,12 +178,6 @@ CVPCB_MAINFRAME::~CVPCB_MAINFRAME()
}
/**
* Load Cvpcb main frame specific configuration settings.
*
* Don't forget to call this base method from any derived classes or the
* settings will not get loaded.
*/
void CVPCB_MAINFRAME::LoadSettings()
{
wxASSERT( wxGetApp().m_EDA_Config != NULL );
......@@ -203,12 +191,6 @@ void CVPCB_MAINFRAME::LoadSettings()
}
/**
* Save Cvpcb frame specific configuration settings.
*
* Don't forget to call this base method from any derived classes or the
* settings will not get saved.
*/
void CVPCB_MAINFRAME::SaveSettings()
{
wxASSERT( wxGetApp().m_EDA_Config != NULL );
......@@ -243,8 +225,7 @@ void CVPCB_MAINFRAME::OnCloseWindow( wxCloseEvent& Event )
wxMessageDialog dialog( this,
_( "Net and component list modified.\nSave before exit ?" ),
_( "Confirmation" ),
wxYES_NO | wxCANCEL | wxICON_EXCLAMATION |
wxYES_DEFAULT );
wxYES_NO | wxCANCEL | wxICON_EXCLAMATION | wxYES_DEFAULT );
ii = dialog.ShowModal();
......@@ -259,9 +240,12 @@ void CVPCB_MAINFRAME::OnCloseWindow( wxCloseEvent& Event )
case wxID_OK:
case wxID_YES:
diag = SaveNetList( wxEmptyString );
diag = SaveNetList( m_NetlistFileName.GetFullPath() );
if( diag > 0 )
{
m_modified = false;
}
else if( diag == 0 )
{
if( !IsOK( this, _( "Problem when saving files, exit anyway ?" ) ) )
......@@ -277,8 +261,7 @@ void CVPCB_MAINFRAME::OnCloseWindow( wxCloseEvent& Event )
// Close the help frame
if( wxGetApp().m_HtmlCtrl )
{
if( wxGetApp().m_HtmlCtrl->GetFrame() ) // returns NULL if no help
// frame active
if( wxGetApp().m_HtmlCtrl->GetFrame() ) // returns NULL if no help frame active
wxGetApp().m_HtmlCtrl->GetFrame()->Close( true );
}
......@@ -290,6 +273,7 @@ void CVPCB_MAINFRAME::OnCloseWindow( wxCloseEvent& Event )
// Close module display frame
if( m_DisplayFootprintFrame )
m_DisplayFootprintFrame->Close( true );
m_modified = false;
SaveSettings();
Destroy();
......@@ -331,7 +315,8 @@ void CVPCB_MAINFRAME::ToFirstNA( wxCommandEvent& event )
if( selection < 0 )
selection = 0;
BOOST_FOREACH( COMPONENT & component, m_components ) {
BOOST_FOREACH( COMPONENT & component, m_components )
{
if( component.m_Module.IsEmpty() && ii > selection )
{
m_ListCmp->SetSelection( ii );
......@@ -340,6 +325,7 @@ void CVPCB_MAINFRAME::ToFirstNA( wxCommandEvent& event )
ii++;
}
m_ListCmp->SetSelection( selection );
}
......@@ -358,32 +344,36 @@ void CVPCB_MAINFRAME::ToPreviousNA( wxCommandEvent& event )
if( selection < 0 )
selection = m_ListCmp->GetCount() - 1;
BOOST_REVERSE_FOREACH( COMPONENT & component, m_components ) {
BOOST_REVERSE_FOREACH( COMPONENT & component, m_components )
{
if( component.m_Module.IsEmpty() && ii < selection )
{
m_ListCmp->SetSelection( ii );
return;
}
ii--;
}
m_ListCmp->SetSelection( selection );
}
void CVPCB_MAINFRAME::SaveQuitCvpcb( wxCommandEvent& event )
void CVPCB_MAINFRAME::SaveQuitCvpcb( wxCommandEvent& aEvent )
{
if( SaveNetList( wxEmptyString ) > 0 )
if( aEvent.GetId() == wxID_SAVEAS )
m_NetlistFileName.Clear();
if( SaveNetList( m_NetlistFileName.GetFullPath() ) > 0 )
{
m_modified = false;
if( !m_KeepCvpcbOpen )
Close( true );
}
}
/* Removes all associations already made
*/
void CVPCB_MAINFRAME::DelAssociations( wxCommandEvent& event )
{
wxString Line;
......@@ -392,7 +382,8 @@ void CVPCB_MAINFRAME::DelAssociations( wxCommandEvent& event )
{
m_ListCmp->SetSelection( 0 );
BOOST_FOREACH( COMPONENT & component, m_components ) {
BOOST_FOREACH( COMPONENT & component, m_components )
{
component.m_Module.Empty();
SetNewPkg( wxEmptyString );
}
......@@ -405,10 +396,6 @@ void CVPCB_MAINFRAME::DelAssociations( wxCommandEvent& event )
}
/*
* Called when click on Load Netlist button or by file history menu entries
* Read a netlist selected by user
*/
void CVPCB_MAINFRAME::LoadNetList( wxCommandEvent& event )
{
wxString oldPath;
......@@ -440,18 +427,10 @@ void CVPCB_MAINFRAME::LoadNetList( wxCommandEvent& event )
/* Update the library search path list. */
if( wxGetApp().GetLibraryPathList().Index( oldPath ) != wxNOT_FOUND )
wxGetApp().GetLibraryPathList().Remove( oldPath );
wxGetApp().GetLibraryPathList().Insert( newFileName.GetPath(), 0 );
m_NetlistFileName = newFileName;
if( ReadNetList() )
{
SetTitle( wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion() +
wxT( " " ) + m_NetlistFileName.GetFullPath() );
}
else
{
SetTitle( wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion() );
}
ReadNetList();
}
......@@ -476,9 +455,6 @@ void CVPCB_MAINFRAME::DisplayModule( wxCommandEvent& event )
}
/** Vitual function SetLanguage
* called on a language menu selection
*/
void CVPCB_MAINFRAME::SetLanguage( wxCommandEvent& event )
{
EDA_BASE_FRAME::SetLanguage( event );
......@@ -487,8 +463,7 @@ void CVPCB_MAINFRAME::SetLanguage( wxCommandEvent& event )
void CVPCB_MAINFRAME::DisplayDocFile( wxCommandEvent& event )
{
GetAssociatedDocument( this, m_DocModulesFileName,
&wxGetApp().GetLibraryPathList() );
GetAssociatedDocument( this, m_DocModulesFileName, &wxGetApp().GetLibraryPathList() );
}
......@@ -515,6 +490,7 @@ void CVPCB_MAINFRAME::OnSelectComponent( wxListEvent& event )
}
selection = m_ListCmp->GetSelection();
if( selection < 0 )
{
m_FootprintList->SetActiveFootprintList( true, true );
......@@ -527,14 +503,11 @@ void CVPCB_MAINFRAME::OnSelectComponent( wxListEvent& event )
return;
}
m_FootprintList->SetFootprintFilteredList( &m_components[ selection ],
m_footprints );
m_FootprintList->SetFootprintFilteredList( &m_components[ selection ], m_footprints );
DisplayStatus();
}
/* Select full/filtered footprint display on tool click
*/
void CVPCB_MAINFRAME::OnSelectFilteringFootprint( wxCommandEvent& event )
{
switch( event.GetId() )
......@@ -563,15 +536,11 @@ void CVPCB_MAINFRAME::OnUpdateKeepOpenOnSave( wxUpdateUIEvent& event )
}
/** DisplayStatus()
* Displays info to the status line at bottom of the main frame
*/
void CVPCB_MAINFRAME::DisplayStatus()
{
wxString msg;
msg.Printf( _( "Components: %d (free: %d)" ),
m_components.size(), m_undefinedComponentCnt );
msg.Printf( _( "Components: %d (free: %d)" ), m_components.size(), m_undefinedComponentCnt );
SetStatusText( msg, 0 );
SetStatusText( wxEmptyString, 1 );
......@@ -580,25 +549,20 @@ void CVPCB_MAINFRAME::DisplayStatus()
{
if( m_FootprintList->m_UseFootprintFullList )
msg.Printf( _( "Footprints (All): %d" ),
m_FootprintList->m_ActiveFootprintList->GetCount() );
m_FootprintList->m_ActiveFootprintList->GetCount() );
else
msg.Printf( _( "Footprints (filtered): %d" ),
m_FootprintList->m_ActiveFootprintList->GetCount() );
m_FootprintList->m_ActiveFootprintList->GetCount() );
}
else
{
msg.Empty();
}
SetStatusText( msg, 2 );
}
/*
* Read the list of libraries (*.mod files) and populates m_footprints
* ( list of availaible modules in libs ).
* for each module are stored
* the module name
* documentation string
* associated keywords
*/
bool CVPCB_MAINFRAME::LoadFootprintFiles()
{
/* Check if there are footprint libraries in project file */
......@@ -615,6 +579,7 @@ bool CVPCB_MAINFRAME::LoadFootprintFiles()
if( !m_footprints.m_filesNotFound.IsEmpty() || !m_footprints.m_filesInvalid.IsEmpty() )
{
DIALOG_LOAD_ERROR dialog( NULL );
if( !m_footprints.m_filesNotFound.IsEmpty() )
{
wxString message = _( "Some files could not be found!" );
......@@ -628,8 +593,31 @@ bool CVPCB_MAINFRAME::LoadFootprintFiles()
dialog.MessageSet( _( "Some files are invalid!" ) );
dialog.ListSet( m_footprints.m_filesInvalid );
}
dialog.ShowModal();
}
return true;
}
void CVPCB_MAINFRAME::UpdateTitle()
{
wxString title;
if( m_NetlistFileName.IsOk() && m_NetlistFileName.FileExists() )
{
title = wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion() +
wxT( " " ) + m_NetlistFileName.GetFullPath();
if( !m_NetlistFileName.IsFileWritable() )
title += _( " [Read Only]" );
}
else
{
title = wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion() +
wxT( " " ) + _( " [no file]" );
}
SetTitle( title );
}
......@@ -41,12 +41,12 @@ const wxString titleLibLoadError( _( "Library Load Error" ) );
*/
void WinEDA_App::MacOpenFile(const wxString &fileName)
{
wxFileName filename = fileName;
wxString oldPath;
CVPCB_MAINFRAME * frame = ((CVPCB_MAINFRAME*)GetTopWindow());
wxFileName filename = fileName;
wxString oldPath;
CVPCB_MAINFRAME* frame = (CVPCB_MAINFRAME*) GetTopWindow();
if(!filename.FileExists())
return;
if( !filename.FileExists() )
return;
if( frame->m_NetlistFileName.DirExists() )
oldPath = frame->m_NetlistFileName.GetPath();
......@@ -54,39 +54,32 @@ void WinEDA_App::MacOpenFile(const wxString &fileName)
/* Update the library search path list. */
if( wxGetApp().GetLibraryPathList().Index( oldPath ) != wxNOT_FOUND )
wxGetApp().GetLibraryPathList().Remove( oldPath );
wxGetApp().GetLibraryPathList().Insert( filename.GetPath(), 0 );
frame->m_NetlistFileName = filename;
if( frame->ReadNetList() )
{
frame->SetTitle( wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion() +
wxT( " " ) + filename.GetFullPath() );
}
else
{
frame->SetTitle( wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion() );
}
frame->ReadNetList();
}
// Create a new application object
IMPLEMENT_APP( WinEDA_App )
/************************************/
/* Called to initialize the program */
/************************************/
bool WinEDA_App::OnInit()
{
wxFileName filename;
wxString message;
CVPCB_MAINFRAME* frame = NULL;
wxFileName filename;
wxString message;
CVPCB_MAINFRAME* frame = NULL;
InitEDA_Appl( wxT( "CvPCB" ), APP_TYPE_CVPCB );
InitEDA_Appl( wxT( "CVPcb" ), APP_TYPE_CVPCB );
if( m_Checker && m_Checker->IsAnotherRunning() )
{
if( !IsOK( NULL, _( "Cvpcb is already running, Continue?" ) ) )
if( !IsOK( NULL, _( "CVPcb is already running, Continue?" ) ) )
return false;
}
......@@ -126,9 +119,7 @@ bool WinEDA_App::OnInit()
frame->LoadFootprintFiles();
frame->m_NetlistFileExtension = wxT( "net" );
frame->m_NetlistFileName.Clear();
frame->SetTitle( GetTitle() + wxT( " " ) + GetBuildVersion() +
wxGetCwd() + wxFileName::GetPathSeparator() +
_( " [no file]" ) );
frame->UpdateTitle();
return true;
}
......@@ -44,60 +44,130 @@ protected:
bool m_isEESchemaNetlist;
PARAM_CFG_ARRAY m_projectFileParams;
public: CVPCB_MAINFRAME( const wxString& title,
long style = KICAD_DEFAULT_DRAWFRAME_STYLE );
public:
CVPCB_MAINFRAME( const wxString& title, long style = KICAD_DEFAULT_DRAWFRAME_STYLE );
~CVPCB_MAINFRAME();
void OnLeftClick( wxListEvent& event );
void OnLeftDClick( wxListEvent& event );
void OnSelectComponent( wxListEvent& event );
void Update_Config( wxCommandEvent& event );
void OnQuit( wxCommandEvent& event );
void OnCloseWindow( wxCloseEvent& Event );
void OnSize( wxSizeEvent& SizeEvent );
void OnChar( wxKeyEvent& event );
void ReCreateHToolbar();
virtual void ReCreateMenuBar();
/**
* Function SetLanguage
* is called on a language menu selection.
*/
void SetLanguage( wxCommandEvent& event );
void ToFirstNA( wxCommandEvent& event );
void ToPreviousNA( wxCommandEvent& event );
/**
* Function DelAssociations
* removes all component footprint associations already made
*/
void DelAssociations( wxCommandEvent& event );
void SaveProjectFile( wxCommandEvent& aEvent );
void SaveQuitCvpcb( wxCommandEvent& event );
/**
* Function LoadNetList
* reads a netlist selected by user when clicking on load netlist button or any entry
* in the file history menu.
*/
void LoadNetList( wxCommandEvent& event );
void ConfigCvpcb( wxCommandEvent& event );
void OnKeepOpenOnSave( wxCommandEvent& event );
void DisplayModule( wxCommandEvent& event );
void AssocieModule( wxCommandEvent& event );
void WriteStuffList( wxCommandEvent& event );
void DisplayDocFile( wxCommandEvent& event );
/**
* Function OnSelectFilteringFootprint
* is the command event handler for enabling and disabling footprint filtering.
*/
void OnSelectFilteringFootprint( wxCommandEvent& event );
void OnUpdateKeepOpenOnSave( wxUpdateUIEvent& event );
/**
* Function SetNewPkg
* set the module to the selected component and selects the next component.
*/
void SetNewPkg( const wxString& package );
void BuildCmpListBox();
void BuildFOOTPRINTS_LISTBOX();
void CreateScreenCmp();
int SaveNetList( const wxString& FullFileName );
int SaveComponentList( const wxString& FullFileName );
/**
* Function SaveNetList
* backup and save netlist (.net) file to \a aFullFileName.
*
* @param aFullFileName A reference wxString object containing the full path and
* file name of the netlist to save.
* @return 0 if an error occurred saving the netlist to \a aFullFileName.
*/
int SaveNetList( const wxString& aFullFileName );
/**
* Function SaveComponentList
* backup modules to file \a aFullFileName.
*
* @param aFullFileName Name of net list file to save.
* @returns 1 if OK, 0 if error.
*/
int SaveComponentList( const wxString& aFullFileName );
/**
* Function ReadNetList
* reads the netlist (.net) file defined by #m_NetlistFileName.
*/
bool ReadNetList();
int ReadSchematicNetlist();
void LoadProjectFile( const wxString& FileName );
void SaveProjectFile( const wxString& fileName );
/**
* Function LoadProjectFile
* reads the configuration parameter from the project (.pro) file \a aFileName
*/
void LoadProjectFile( const wxString& aFileName );
/**
* Function LoadSettings
* loads the CVPcb main frame specific configuration settings.
*
* Don't forget to call this base method from any derived classes or the
* settings will not get loaded.
*/
virtual void LoadSettings();
/**
* Function SaveSettings
* save the CVPcb frame specific configuration settings.
*
* Don't forget to call this base method from any derived classes or the
* settings will not get saved.
*/
virtual void SaveSettings();
/**
* Function DisplayStatus()
* Displays info to the status line at bottom of the main frame
* Function DisplayStatus
* displays info to the status line at bottom of the main frame.
*/
void DisplayStatus();
/**
* Function LoadFootprintFiles
* Read the list of libraries (*.mod files) and generate the list of modules.
* reads the list of footprint (*.mod files) and generate the list of footprints.
* for each module are stored
* the module name
* documentation string
......@@ -117,13 +187,38 @@ public: CVPCB_MAINFRAME( const wxString& title,
/**
* Function LoadComponentFile
* Loads the .cmp file that stores the component/footprint association.
* @param aCmpFileName = the full filename of .cmp file to load
* loads the .cmp file \a aCmpFileName that stores the component/footprint association.
*
* @param aFileName The full filename of .cmp file to load
*/
bool LoadComponentFile( const wxString& aCmpFileName );
bool LoadComponentFile( const wxString& aFileName );
/**
* Function GetProjectFileParameters
* return project file parameter list for CVPcb.
* <p>
* Populate the project file parameter array specific to CVPcb if it hasn't
* already been populated and return a reference to the array to the caller.
* Creating the parameter list at run time has the advantage of being able
* to define local variables. The old method of statically building the array
* at compile time requiring global variable definitions.
* </p>
*
* @return A reference to a PARAM_CFG_ARRAY contain the project settings for CVPcb.
*/
PARAM_CFG_ARRAY& GetProjectFileParameters( void );
/**
* Function UpdateTitle
* sets the main window title bar text.
* <p>
* If file name defined by CVPCB_MAINFRAME::m_NetlistFileName is not set, the title is
* set to the application name appended with no file. Otherwise, the title is set to
* the full path and file name and read only is appended to the title if the user does
* not have write access to the file.
*/
void UpdateTitle();
DECLARE_EVENT_TABLE()
};
......
......@@ -10,6 +10,7 @@
#include "common.h"
#include "confirm.h"
#include "gestfich.h"
#include "id.h"
#include "cvpcb.h"
#include "cvpcb_mainframe.h"
......@@ -59,15 +60,18 @@ void DIALOG_CVPCB_CONFIG::Init()
// Load user libs paths:
wxStringTokenizer Token( m_UserLibDirBufferImg, wxT( ";\n\r" ) );
while( Token.HasMoreTokens() )
{
wxString path = Token.GetNextToken();
if( wxFileName::DirExists( path ) )
m_listUserPaths->Append( path );
}
// Display actual libraries paths:
wxPathList libpaths = wxGetApp().GetLibraryPathList();
for( unsigned ii = 0; ii < libpaths.GetCount(); ii++ )
{
m_DefaultLibraryPathslistBox->Append( libpaths[ii] );
......@@ -102,25 +106,28 @@ void DIALOG_CVPCB_CONFIG::OnOkClick( wxCommandEvent& event )
if( m_LibPathChanged )
{
m_Parent->m_UserLibraryPath.Empty();
for( unsigned ii = 0; ii < m_listUserPaths->GetCount(); ii++ )
{
if( ii > 0 )
m_Parent->m_UserLibraryPath << wxT( ";" );
m_Parent->m_UserLibraryPath << m_listUserPaths->GetString( ii );
}
}
// Set new active library list if the lib list of if default path list
// was modified
// Set new active library list if the lib list of if default path list was modified
if( m_LibListChanged || m_LibPathChanged )
{
// Recreate lib list
m_Parent->m_ModuleLibNames.Clear();
for( unsigned ii = 0; ii < m_ListLibr->GetCount(); ii++ )
m_Parent->m_ModuleLibNames.Add( m_ListLibr->GetString( ii ) );
// Recreate equ list
m_Parent->m_AliasLibNames.Clear();
for( unsigned ii = 0; ii < m_ListEquiv->GetCount(); ii++ )
m_Parent->m_AliasLibNames.Add( m_ListEquiv->GetString( ii ) );
......@@ -128,7 +135,8 @@ void DIALOG_CVPCB_CONFIG::OnOkClick( wxCommandEvent& event )
m_Parent->BuildFOOTPRINTS_LISTBOX();
}
m_Parent->SaveProjectFile( m_Parent->m_NetlistFileName.GetFullPath() );
wxCommandEvent evt( ID_SAVE_PROJECT );
m_Parent->SaveProjectFile( evt );
EndModal( wxID_OK );
}
......@@ -144,6 +152,7 @@ void DIALOG_CVPCB_CONFIG::OnButtonUpClick( wxCommandEvent& event )
/********************************************************************/
{
wxListBox * list = m_ListLibr;
if( (event.GetId() == ID_EQU_UP) || (event.GetId() == ID_EQU_DOWN) )
{
list = m_ListEquiv;
......@@ -151,7 +160,8 @@ void DIALOG_CVPCB_CONFIG::OnButtonUpClick( wxCommandEvent& event )
wxArrayInt selections;
list->GetSelections(selections);
list->GetSelections( selections );
if ( selections.GetCount() <= 0 ) // No selection.
return;
......@@ -163,15 +173,16 @@ void DIALOG_CVPCB_CONFIG::OnButtonUpClick( wxCommandEvent& event )
for( size_t ii = 0; ii < selections.GetCount(); ii++ )
{
int jj = selections[ii];
EXCHG( libnames[jj], libnames[jj-1]);
EXCHG( libnames[jj], libnames[jj-1] );
}
list->Set(libnames);
list->Set( libnames );
// Reselect previously selected names
for( size_t ii = 0; ii < selections.GetCount(); ii++ )
{
int jj = selections[ii];
list->SetSelection(jj-1);
list->SetSelection( jj-1 );
}
m_LibListChanged = TRUE;
......@@ -183,6 +194,7 @@ void DIALOG_CVPCB_CONFIG::OnButtonDownClick( wxCommandEvent& event )
/*********************************************************************/
{
wxListBox * list = m_ListLibr;
if( (event.GetId() == ID_EQU_UP) || (event.GetId() == ID_EQU_DOWN) )
{
list = m_ListEquiv;
......@@ -190,7 +202,8 @@ void DIALOG_CVPCB_CONFIG::OnButtonDownClick( wxCommandEvent& event )
wxArrayInt selections;
list->GetSelections(selections);
list->GetSelections( selections );
if ( selections.GetCount() <= 0 ) // No selection.
return;
......@@ -205,7 +218,8 @@ void DIALOG_CVPCB_CONFIG::OnButtonDownClick( wxCommandEvent& event )
int jj = selections[ii];
EXCHG( libnames[jj], libnames[jj+1]);
}
list->Set(libnames);
list->Set( libnames );
// Reselect previously selected names
for( size_t ii = 0; ii < selections.GetCount(); ii++ )
......@@ -213,6 +227,7 @@ void DIALOG_CVPCB_CONFIG::OnButtonDownClick( wxCommandEvent& event )
int jj = selections[ii];
list->SetSelection(jj+1);
}
m_LibListChanged = TRUE;
}
......@@ -229,7 +244,8 @@ void DIALOG_CVPCB_CONFIG::OnRemoveLibClick( wxCommandEvent& event )
wxArrayInt selections;
list->GetSelections(selections);
list->GetSelections( selections );
for( int ii = selections.GetCount()-1; ii >= 0; ii-- )
{
list->Delete(selections[ii] );
......@@ -256,6 +272,7 @@ void DIALOG_CVPCB_CONFIG::OnAddOrInsertLibClick( wxCommandEvent& event )
wildcard = FootprintAliasFileWildcard;
wxListBox * list = m_ListEquiv;
if( (event.GetId() == ID_ADD_LIB) || (event.GetId() == ID_INSERT_LIB) )
{
list = m_ListLibr;
......@@ -266,6 +283,7 @@ void DIALOG_CVPCB_CONFIG::OnAddOrInsertLibClick( wxCommandEvent& event )
list->GetSelections(selections);
ii = selections.GetCount();
if( ii > 0 )
ii = selections[0];
else
......@@ -273,6 +291,7 @@ void DIALOG_CVPCB_CONFIG::OnAddOrInsertLibClick( wxCommandEvent& event )
wxString libpath;
libpath = m_DefaultLibraryPathslistBox->GetStringSelection();
if( libpath.IsEmpty() )
libpath = wxGetApp().ReturnLastVisitedLibraryPath();
......@@ -289,6 +308,7 @@ void DIALOG_CVPCB_CONFIG::OnAddOrInsertLibClick( wxCommandEvent& event )
for( unsigned jj = 0; jj < Filenames.GetCount(); jj++ )
{
fn = Filenames[jj];
if( jj == 0 )
wxGetApp().SaveLastVisitedLibraryPath( fn.GetPath() );
......@@ -300,15 +320,17 @@ void DIALOG_CVPCB_CONFIG::OnAddOrInsertLibClick( wxCommandEvent& event )
* is a sub path of these default paths
*/
libfilename = wxGetApp().ReturnFilenameWithRelativePathInLibPath( fn.GetFullPath() );
// Remove extension:
fn = libfilename;
fn.SetExt(wxEmptyString);
fn.SetExt( wxEmptyString );
libfilename = fn.GetFullPath();
// Add or insert new library name, if not already in list
if( list->FindString( libfilename, fn.IsCaseSensitive() ) == wxNOT_FOUND )
{
m_LibListChanged = TRUE;
if( ! insert )
list->Append( libfilename );
else
......@@ -344,25 +366,27 @@ void DIALOG_CVPCB_CONFIG::OnAddOrInsertPath( wxCommandEvent& event )
if( m_listUserPaths->FindString( path ) == wxNOT_FOUND )
{
int ipos = m_listUserPaths->GetCount();
if( event.GetId() == ID_INSERT_PATH )
{
if( ipos )
ipos--;
int jj = m_listUserPaths->GetSelection();
if( jj >= 0 )
ipos = jj;
}
// Ask the user if this is a relative path
int diag = wxMessageBox(
_( "Use a relative path?" ),
_( "Path type" ),
wxYES_NO | wxICON_QUESTION, this );
int diag = wxMessageBox( _( "Use a relative path?" ),
_( "Path type" ),
wxYES_NO | wxICON_QUESTION, this );
if( diag == wxYES )
{ // Make it relative
wxFileName fn = path;
fn.MakeRelativeTo( wxT(".") );
fn.MakeRelativeTo( wxT( "." ) );
path = fn.GetPathWithSep() + fn.GetFullName();
}
......@@ -373,13 +397,16 @@ void DIALOG_CVPCB_CONFIG::OnAddOrInsertPath( wxCommandEvent& event )
// Display actual libraries paths:
wxPathList libpaths = wxGetApp().GetLibraryPathList();
m_DefaultLibraryPathslistBox->Clear();
for( unsigned ii = 0; ii < libpaths.GetCount(); ii++ )
{
m_DefaultLibraryPathslistBox->Append( libpaths[ii] );
}
}
else
{
DisplayError( this, _( "Path already in use" ) );
}
wxGetApp().SaveLastVisitedLibraryPath( path );
}
......@@ -391,6 +418,7 @@ void DIALOG_CVPCB_CONFIG::OnRemoveUserPath( wxCommandEvent& event )
if( ii < 0 )
ii = m_listUserPaths->GetCount() - 1;
if( ii >= 0 )
{
wxGetApp().RemoveLibraryPath( m_listUserPaths->GetStringSelection() );
......@@ -401,6 +429,7 @@ void DIALOG_CVPCB_CONFIG::OnRemoveUserPath( wxCommandEvent& event )
// Display actual libraries paths:
wxPathList libpaths = wxGetApp().GetLibraryPathList();
m_DefaultLibraryPathslistBox->Clear();
for( unsigned ii = 0; ii < libpaths.GetCount(); ii++ )
{
m_DefaultLibraryPathslistBox->Append( libpaths[ii] );
......
......@@ -15,10 +15,7 @@
#include "build_version.h"
/*
* Set the module to the selected component
* Selects the next component
*/
void CVPCB_MAINFRAME::SetNewPkg( const wxString& package )
{
COMPONENT* Component;
......@@ -30,6 +27,7 @@ void CVPCB_MAINFRAME::SetNewPkg( const wxString& package )
return;
NumCmp = m_ListCmp->GetSelection();
if( NumCmp < 0 )
{
NumCmp = 0;
......@@ -46,9 +44,9 @@ void CVPCB_MAINFRAME::SetNewPkg( const wxString& package )
Component->m_Module = package;
msg.Printf( CMP_FORMAT, NumCmp + 1,
GetChars( Component->m_Reference ),
GetChars( Component->m_Value ),
GetChars( Component->m_Module ) );
GetChars( Component->m_Reference ),
GetChars( Component->m_Value ),
GetChars( Component->m_Module ) );
m_modified = true;
if( isUndefined )
......@@ -60,15 +58,13 @@ void CVPCB_MAINFRAME::SetNewPkg( const wxString& package )
// We activate next component:
if( NumCmp < (m_ListCmp->GetCount() - 1) )
NumCmp++;
m_ListCmp->SetSelection( NumCmp, TRUE );
DisplayStatus();
}
/*
* Read the netlist format and file components.
*/
bool CVPCB_MAINFRAME::ReadNetList()
{
wxString msg;
......@@ -81,6 +77,8 @@ bool CVPCB_MAINFRAME::ReadNetList()
msg.Printf( _( "File <%s> does not appear to be a valid Kicad net list file." ),
GetChars( m_NetlistFileName.GetFullPath() ) );
::wxMessageBox( msg, _( "File Error" ), wxOK | wxICON_ERROR, this );
m_NetlistFileName.Clear();
UpdateTitle();
return false;
}
......@@ -90,7 +88,7 @@ bool CVPCB_MAINFRAME::ReadNetList()
return false;
LoadProjectFile( m_NetlistFileName.GetFullPath() );
LoadFootprintFiles( );
LoadFootprintFiles();
BuildFOOTPRINTS_LISTBOX();
m_ListCmp->Clear();
......@@ -103,6 +101,7 @@ bool CVPCB_MAINFRAME::ReadNetList()
GetChars( component.m_Value ),
GetChars( component.m_Module ) );
m_ListCmp->AppendLine( msg );
if( component.m_Module.IsEmpty() )
m_undefinedComponentCnt += 1;
}
......@@ -112,9 +111,7 @@ bool CVPCB_MAINFRAME::ReadNetList()
DisplayStatus();
/* Update the title of the main window. */
SetTitle( wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion() +
wxT( " " ) + m_NetlistFileName.GetFullPath() );
UpdateTitle();
UpdateFileHistory( m_NetlistFileName.GetFullPath() );
......@@ -122,34 +119,40 @@ bool CVPCB_MAINFRAME::ReadNetList()
}
/*
* Backup and NetList cmp
* The full name of the netlist file must be in FFileName.
* The file name is deducted in cmp
*/
int CVPCB_MAINFRAME::SaveNetList( const wxString& fileName )
int CVPCB_MAINFRAME::SaveNetList( const wxString& aFullFileName )
{
wxFileName fn;
if( !fileName && m_NetlistFileName.IsOk() )
if( !aFullFileName.IsEmpty() && m_NetlistFileName.IsOk() )
{
fn = m_NetlistFileName;
}
else
fn = wxFileName( wxGetCwd(), _( "unamed" ), NetExtBuffer );
{
wxFileDialog dlg( this, _( "Save Net and Component List" ), wxGetCwd(),
wxEmptyString, NetlistFileWildcard, wxFD_SAVE );
if( dlg.ShowModal() == wxID_CANCEL )
return -1;
fn = dlg.GetPath();
wxFileDialog dlg( this, _( "Save Net and Component List" ), fn.GetPath(),
fn.GetFullName(), NetlistFileWildcard,
wxFD_SAVE/*| wxFD_OVERWRITE_PROMPT*/ );
if( !fn.HasExt() )
fn.SetExt( NetlistFileExtension );
if( dlg.ShowModal() == wxID_CANCEL )
return -1;
m_NetlistFileName = fn;
}
if( !IsWritable( fn.GetFullPath() ) )
return 0;
if( SaveComponentList( dlg.GetPath() ) == 0 )
if( SaveComponentList( fn.GetFullPath() ) == 0 )
{
DisplayError( this, _( "Unable to create component file (.cmp)" ) );
return 0;
}
FILE* netlist = wxFopen( dlg.GetPath(), wxT( "wt" ) );
FILE* netlist = wxFopen( fn.GetFullPath(), wxT( "wt" ) );
if( netlist == 0 )
{
......
......@@ -29,8 +29,9 @@ void CVPCB_MAINFRAME::ReCreateMenuBar()
// Delete all existing menus so they can be rebuilt.
// This allows language changes of the menu text on the fly.
menuBar->Freeze();
while( menuBar->GetMenuCount() )
delete menuBar->Remove(0);
delete menuBar->Remove( 0 );
// Recreate all menus:
......@@ -46,25 +47,34 @@ void CVPCB_MAINFRAME::ReCreateMenuBar()
// Open Recent submenu
static wxMenu* openRecentMenu;
// Add this menu to list menu managed by m_fileHistory
// (the file history will be updated when adding/removing files in history
if( openRecentMenu )
wxGetApp().m_fileHistory.RemoveMenu( openRecentMenu );
openRecentMenu = new wxMenu();
wxGetApp().m_fileHistory.UseMenu( openRecentMenu );
wxGetApp().m_fileHistory.AddFilesToMenu( );
wxGetApp().m_fileHistory.AddFilesToMenu();
ADD_MENUITEM_WITH_HELP_AND_SUBMENU( filesMenu, openRecentMenu, -1,
_( "Open &Recent" ),
_("Open a recent opened netlist document" ),
_( "Open a recent opened netlist document" ),
open_project_xpm );
// Separator
filesMenu->AppendSeparator();
// Save
ADD_MENUITEM_WITH_HELP( filesMenu,
wxID_SAVE,
_( "&Save\tCtrl+S" ),
_( "Save net list and footprint list files" ),
save_xpm );
// Save as
ADD_MENUITEM_WITH_HELP( filesMenu,
ID_SAVE_PROJECT,
_( "&Save As..." ),
wxID_SAVEAS,
_( "Save &As..." ),
_( "Save new net list and footprint list files" ),
save_xpm );
......@@ -75,7 +85,7 @@ void CVPCB_MAINFRAME::ReCreateMenuBar()
ADD_MENUITEM_WITH_HELP( filesMenu,
wxID_EXIT,
_( "&Quit" ),
_( "Quit CvPCB" ),
_( "Quit CVPcb" ),
exit_xpm );
// Menu Preferences:
......@@ -105,10 +115,14 @@ void CVPCB_MAINFRAME::ReCreateMenuBar()
// Separator
preferencesMenu->AppendSeparator();
ADD_MENUITEM_WITH_HELP( preferencesMenu, ID_CONFIG_SAVE,
_( "&Save Project File" ),
_( "Save changes to the project file" ),
save_setup_xpm );
ADD_MENUITEM_WITH_HELP( preferencesMenu, ID_SAVE_PROJECT,
_( "&Save Project File" ),
_( "Save changes to the project configuration file" ),
save_setup_xpm );
ADD_MENUITEM_WITH_HELP( preferencesMenu, ID_SAVE_PROJECT_AS,
_( "&Save Project File As" ),
_( "Save changes to the project configuration to a new file" ),
save_setup_xpm );
// Menu Help:
wxMenu* helpMenu = new wxMenu;
......@@ -118,13 +132,13 @@ void CVPCB_MAINFRAME::ReCreateMenuBar()
// Contents
ADD_MENUITEM_WITH_HELP( helpMenu, wxID_HELP, _( "&Contents" ),
_( "Open the Cvpcb handbook" ),
_( "Open the CVPcb handbook" ),
online_help_xpm );
// About
ADD_MENUITEM_WITH_HELP( helpMenu, wxID_ABOUT,
_( "&About CvPCB" ),
_( "About CvPCB schematic to pcb converter" ),
_( "&About CVPcb" ),
_( "About CVPcb schematic to pcb converter" ),
info_xpm );
// Create the menubar and append all submenus
......
......@@ -23,22 +23,17 @@ char EnteteCmpMod[] = { "Cmp-Mod V01" };
#define titleComponentLibErr _( "Component Library Error" )
/*
* Backup modules file.
*
* @param NetlistFullFileName - Name of net list file to save.
* @returns - 1 if OK, 0 if error.
*/
int CVPCB_MAINFRAME::SaveComponentList( const wxString& NetlistFullFileName )
int CVPCB_MAINFRAME::SaveComponentList( const wxString& aFullFileName )
{
FILE* dest;
wxFileName fn( NetlistFullFileName );
wxFileName fn( aFullFileName );
char Line[1024];
wxString Title = wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion();
fn.SetExt( ComponentFileExtension );
dest = wxFopen( fn.GetFullPath(), wxT( "wt" ) );
if( dest == NULL )
return 0;
......@@ -49,14 +44,10 @@ int CVPCB_MAINFRAME::SaveComponentList( const wxString& NetlistFullFileName )
BOOST_FOREACH( COMPONENT& component, m_components )
{
fprintf( dest, "\nBeginCmp\n" );
fprintf( dest, "TimeStamp = %s;\n",
TO_UTF8( component.m_TimeStamp ) );
fprintf( dest, "Reference = %s;\n",
TO_UTF8( component.m_Reference ) );
fprintf( dest, "ValeurCmp = %s;\n",
TO_UTF8( component.m_Value ) );
fprintf( dest, "IdModule = %s;\n",
TO_UTF8( component.m_Module ) );
fprintf( dest, "TimeStamp = %s;\n", TO_UTF8( component.m_TimeStamp ) );
fprintf( dest, "Reference = %s;\n", TO_UTF8( component.m_Reference ) );
fprintf( dest, "ValeurCmp = %s;\n", TO_UTF8( component.m_Value ) );
fprintf( dest, "IdModule = %s;\n", TO_UTF8( component.m_Module ) );
fprintf( dest, "EndCmp\n" );
}
......@@ -66,25 +57,22 @@ int CVPCB_MAINFRAME::SaveComponentList( const wxString& NetlistFullFileName )
}
/*
* Load list of associated components and footprints.
*/
bool CVPCB_MAINFRAME::LoadComponentFile( const wxString& fileName )
bool CVPCB_MAINFRAME::LoadComponentFile( const wxString& aFileName )
{
wxString timestamp, valeur, ilib, namecmp, msg;
bool read_cmp_data = FALSE, eof = FALSE;
bool read_cmp_data = false, eof = false;
char Line[1024], * ident, * data;
FILE* source;
wxFileName fn = fileName;
wxFileName fn = aFileName;
fn.SetExt( ComponentFileExtension );
source = wxFopen( fn.GetFullPath(), wxT( "rt" ) );
if( source == NULL )
{
msg.Printf( _( "Cannot open CvPcb component file <%s>." ),
msg.Printf( _( "Cannot open CVPcb component file <%s>." ),
GetChars( fn.GetFullPath() ) );
msg << wxT("\n") << _("This is normal if you are opening a new netlist file");
msg << wxT( "\n" ) << _( "This is normal if you are opening a new netlist file" );
wxMessageBox( msg, titleComponentLibErr, wxOK | wxICON_ERROR );
return false;
}
......@@ -115,23 +103,24 @@ bool CVPCB_MAINFRAME::LoadComponentFile( const wxString& fileName )
/* Search the beginning of the component description. */
if( strnicmp( Line, "BeginCmp", 8 ) != 0 )
continue;
timestamp.Empty();
valeur.Empty();
ilib.Empty();
namecmp.Empty();
read_cmp_data = TRUE;
read_cmp_data = true;
while( !eof && read_cmp_data )
{
if( fgets( Line, 1024, source ) == 0 )
{
eof = TRUE;
eof = true;
break;
}
if( strnicmp( Line, "EndCmp", 6 ) == 0 )
{
read_cmp_data = TRUE;
read_cmp_data = true;
break;
}
......@@ -141,38 +130,37 @@ bool CVPCB_MAINFRAME::LoadComponentFile( const wxString& fileName )
if( strnicmp( ident, "TimeStamp", 9 ) == 0 )
{
timestamp = FROM_UTF8( data );
timestamp.Trim( TRUE );
timestamp.Trim( FALSE );
timestamp.Trim( true );
timestamp.Trim( false );
continue;
}
if( strnicmp( ident, "Reference", 9 ) == 0 )
{
namecmp = FROM_UTF8( data );
namecmp.Trim( TRUE );
namecmp.Trim( FALSE );
namecmp.Trim( true );
namecmp.Trim( false );
continue;
}
if( strnicmp( ident, "ValeurCmp", 9 ) == 0 )
{
valeur = FROM_UTF8( data );
valeur.Trim( TRUE );
valeur.Trim( FALSE );
valeur.Trim( true );
valeur.Trim( false );
continue;
}
if( strnicmp( ident, "IdModule", 8 ) == 0 )
{
ilib = FROM_UTF8( data );
ilib.Trim( TRUE );
ilib.Trim( FALSE );
ilib.Trim( true );
ilib.Trim( false );
continue;
}
} /* End reading component description. */
/* Search corresponding component and NetList
* Update its parameters. */
/* Search corresponding component and NetList Update its parameters. */
BOOST_FOREACH( COMPONENT& component, m_components )
{
if( namecmp != component.m_Reference )
......
......@@ -22,64 +22,63 @@ void CVPCB_MAINFRAME::ReCreateHToolbar()
m_HToolBar = new EDA_TOOLBAR( TOOLBAR_MAIN, this, ID_H_TOOLBAR, TRUE );
m_HToolBar->AddTool( ID_CVPCB_READ_INPUT_NETLIST, wxEmptyString,
wxBitmap( open_document_xpm ),
_( "Open a net list file" ) );
wxBitmap( open_document_xpm ),
_( "Open a net list file" ) );
m_HToolBar->AddTool( ID_CVPCB_SAVEQUITCVPCB, wxEmptyString,
wxBitmap( save_xpm ),
_( "Save net list and footprint files" ) );
m_HToolBar->AddTool( wxID_SAVE, wxEmptyString, wxBitmap( save_xpm ),
_( "Save net list and footprint files" ) );
m_HToolBar->AddSeparator();
m_HToolBar->AddTool( ID_CVPCB_CREATE_CONFIGWINDOW, wxEmptyString,
wxBitmap( config_xpm ),
_( "Configuration" ) );
wxBitmap( config_xpm ),
_( "Configuration" ) );
m_HToolBar->AddSeparator();
m_HToolBar->AddTool( ID_CVPCB_CREATE_SCREENCMP, wxEmptyString,
wxBitmap( show_footprint_xpm ),
_( "View selected footprint" ) );
wxBitmap( show_footprint_xpm ),
_( "View selected footprint" ) );
m_HToolBar->AddTool( ID_CVPCB_AUTO_ASSOCIE, wxEmptyString,
wxBitmap( auto_associe_xpm ),
_( "Perform automatic footprint association" ) );
wxBitmap( auto_associe_xpm ),
_( "Perform automatic footprint association" ) );
m_HToolBar->AddSeparator();
m_HToolBar->AddTool( ID_CVPCB_GOTO_PREVIOUSNA, wxEmptyString,
wxBitmap( left_xpm ),
_( "Select previous free component" ) );
wxBitmap( left_xpm ),
_( "Select previous free component" ) );
m_HToolBar->AddTool( ID_CVPCB_GOTO_FIRSTNA, wxEmptyString,
wxBitmap( right_xpm ),
_( "Select next free component" ) );
wxBitmap( right_xpm ),
_( "Select next free component" ) );
m_HToolBar->AddSeparator();
m_HToolBar->AddTool( ID_CVPCB_DEL_ASSOCIATIONS, wxEmptyString,
wxBitmap( delete_association_xpm ),
_( "Delete all associations" ) );
wxBitmap( delete_association_xpm ),
_( "Delete all associations" ) );
m_HToolBar->AddSeparator();
m_HToolBar->AddTool( ID_CVPCB_CREATE_STUFF_FILE, wxEmptyString,
wxBitmap( export_footprint_names_xpm ),
_(
"Create export file (component/footprint list, \
used by eeschema to fill the footprint field of components)" ) );
wxBitmap( export_footprint_names_xpm ),
_( "Create export file (component/footprint list, \
used by eeschema to fill the footprint field of components)" ) );
m_HToolBar->AddSeparator();
m_HToolBar->AddTool( ID_PCB_DISPLAY_FOOTPRINT_DOC, wxEmptyString,
wxBitmap( datasheet_xpm ),
_( "Display footprints list documentation" ) );
wxBitmap( datasheet_xpm ),
_( "Display footprints list documentation" ) );
m_HToolBar->AddSeparator();
m_HToolBar->AddSeparator();
m_HToolBar->AddRadioTool( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST,
wxEmptyString,
wxBitmap( module_filtered_list_xpm ),
wxNullBitmap,
_( "Display the filtered footprint list for the current component" ) );
wxEmptyString,
wxBitmap( module_filtered_list_xpm ),
wxNullBitmap,
_( "Display the filtered footprint list for the current component" ) );
m_HToolBar->AddRadioTool( ID_CVPCB_FOOTPRINT_DISPLAY_FULL_LIST,
wxEmptyString, wxBitmap( module_full_list_xpm ),
wxNullBitmap,
_( "Display the full footprint list (without filtering)" ) );
wxEmptyString, wxBitmap( module_full_list_xpm ),
wxNullBitmap,
_( "Display the full footprint list (without filtering)" ) );
if( config )
{
......@@ -89,7 +88,6 @@ used by eeschema to fill the footprint field of components)"
m_HToolBar->ToggleTool( ID_CVPCB_FOOTPRINT_DISPLAY_FULL_LIST, !opt );
}
// after adding the buttons to the toolbar, must call Realize() to reflect
// the changes
// after adding the buttons to the toolbar, must call Realize() to reflect the changes
m_HToolBar->Realize();
}
......@@ -21,6 +21,7 @@ enum main_id
ID_LOAD_ONE_SHEET,
ID_NEW_PROJECT,
ID_SAVE_PROJECT,
ID_SAVE_PROJECT_AS,
ID_SAVE_ONE_SHEET,
ID_SAVE_ONE_SHEET_AS,
ID_LOAD_FILE,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment