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.
This commit is contained in:
Wayne Stambaugh 2011-08-24 15:44:05 -04:00
parent 8f1b569736
commit 5fd409f826
10 changed files with 408 additions and 316 deletions

View File

@ -4,6 +4,7 @@
#include "fctsys.h" #include "fctsys.h"
#include "appl_wxstruct.h" #include "appl_wxstruct.h"
#include "id.h"
#include "common.h" #include "common.h"
#include "gestfich.h" #include "gestfich.h"
#include "param_config.h" #include "param_config.h"
@ -16,15 +17,6 @@
#define GROUPEQU wxT("/cvpcb/libraries") #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 ) PARAM_CFG_ARRAY& CVPCB_MAINFRAME::GetProjectFileParameters( void )
{ {
if( !m_projectFileParams.empty() ) if( !m_projectFileParams.empty() )
@ -48,19 +40,9 @@ PARAM_CFG_ARRAY& CVPCB_MAINFRAME::GetProjectFileParameters( void )
} }
/** void CVPCB_MAINFRAME::LoadProjectFile( const wxString& aFileName )
* 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 )
{ {
wxFileName fn = FileName; wxFileName fn = aFileName;
m_ModuleLibNames.Clear(); m_ModuleLibNames.Clear();
m_AliasLibNames.Clear(); m_AliasLibNames.Clear();
@ -70,8 +52,7 @@ void CVPCB_MAINFRAME::LoadProjectFile( const wxString& FileName )
wxGetApp().RemoveLibraryPath( m_UserLibraryPath ); wxGetApp().RemoveLibraryPath( m_UserLibraryPath );
wxGetApp().ReadProjectConfig( fn.GetFullPath(), GROUP, wxGetApp().ReadProjectConfig( fn.GetFullPath(), GROUP, GetProjectFileParameters(), false );
GetProjectFileParameters(), FALSE );
if( m_NetlistFileExtension.IsEmpty() ) if( m_NetlistFileExtension.IsEmpty() )
m_NetlistFileExtension = wxT( "net" ); 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;
}
void CVPCB_MAINFRAME::SaveProjectFile( const wxString& fileName )
{
wxFileName fn = fileName;
fn.SetExt( ProjectFileExtension ); fn.SetExt( ProjectFileExtension );
wxFileDialog dlg( this, _( "Save Project File" ), fn.GetPath(), if( aEvent.GetId() == ID_SAVE_PROJECT_AS || !m_NetlistFileName.IsOk() )
fn.GetFullName(), ProjectFileWildcard, wxFD_SAVE ); {
wxFileDialog dlg( this, _( "Save Project File" ), fn.GetPath(),
wxEmptyString, ProjectFileWildcard, wxFD_SAVE );
if( dlg.ShowModal() == wxID_CANCEL ) if( dlg.ShowModal() == wxID_CANCEL )
return;
fn = dlg.GetPath();
if( !fn.HasExt() )
fn.SetExt( ProjectFileExtension );
}
if( !IsWritable( fn ) )
return; return;
wxGetApp().WriteProjectConfig( dlg.GetPath(), GROUP, wxGetApp().WriteProjectConfig( fn.GetFullPath(), GROUP, GetProjectFileParameters() );
GetProjectFileParameters() );
} }

View File

@ -32,60 +32,53 @@ static const wxString FootprintDocFileEntry( wxT( "footprints_doc_file" ) );
BEGIN_EVENT_TABLE( CVPCB_MAINFRAME, EDA_BASE_FRAME ) BEGIN_EVENT_TABLE( CVPCB_MAINFRAME, EDA_BASE_FRAME )
EVT_MENU_RANGE( wxID_FILE1, wxID_FILE9, CVPCB_MAINFRAME::LoadNetList ) EVT_MENU_RANGE( wxID_FILE1, wxID_FILE9, CVPCB_MAINFRAME::LoadNetList )
// Menu events // Menu events
EVT_MENU( ID_LOAD_PROJECT, EVT_MENU( ID_LOAD_PROJECT, CVPCB_MAINFRAME::LoadNetList )
CVPCB_MAINFRAME::LoadNetList ) EVT_MENU( wxID_SAVE, CVPCB_MAINFRAME::SaveQuitCvpcb )
EVT_MENU( ID_SAVE_PROJECT, EVT_MENU( wxID_SAVEAS, CVPCB_MAINFRAME::SaveQuitCvpcb )
CVPCB_MAINFRAME::SaveQuitCvpcb ) EVT_MENU( wxID_EXIT, CVPCB_MAINFRAME::OnQuit )
EVT_MENU( wxID_EXIT, EVT_MENU( wxID_HELP, CVPCB_MAINFRAME::GetKicadHelp )
CVPCB_MAINFRAME::OnQuit ) EVT_MENU( wxID_ABOUT, CVPCB_MAINFRAME::GetKicadAbout )
EVT_MENU( wxID_HELP, EVT_MENU( wxID_PREFERENCES, CVPCB_MAINFRAME::ConfigCvpcb )
CVPCB_MAINFRAME::GetKicadHelp ) EVT_MENU( ID_SAVE_PROJECT, CVPCB_MAINFRAME::SaveProjectFile )
EVT_MENU( wxID_ABOUT, EVT_MENU( ID_SAVE_PROJECT_AS, CVPCB_MAINFRAME::SaveProjectFile )
CVPCB_MAINFRAME::GetKicadAbout ) EVT_MENU( ID_CVPCB_CONFIG_KEEP_OPEN_ON_SAVE, CVPCB_MAINFRAME::OnKeepOpenOnSave )
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, EVT_MENU_RANGE( ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END, CVPCB_MAINFRAME::SetLanguage )
ID_LANGUAGE_CHOICE_END,
CVPCB_MAINFRAME::SetLanguage )
// Toolbar events // Toolbar events
EVT_TOOL( ID_CVPCB_QUIT, CVPCB_MAINFRAME::OnQuit ) EVT_TOOL( ID_CVPCB_QUIT, CVPCB_MAINFRAME::OnQuit )
EVT_TOOL( ID_CVPCB_READ_INPUT_NETLIST, CVPCB_MAINFRAME::LoadNetList ) 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_CONFIGWINDOW, CVPCB_MAINFRAME::ConfigCvpcb ) EVT_TOOL( ID_CVPCB_CREATE_SCREENCMP, CVPCB_MAINFRAME::DisplayModule )
EVT_TOOL( ID_CVPCB_CREATE_SCREENCMP, CVPCB_MAINFRAME::DisplayModule ) EVT_TOOL( ID_CVPCB_GOTO_FIRSTNA, CVPCB_MAINFRAME::ToFirstNA )
EVT_TOOL( ID_CVPCB_GOTO_FIRSTNA, CVPCB_MAINFRAME::ToFirstNA ) EVT_TOOL( ID_CVPCB_GOTO_PREVIOUSNA, CVPCB_MAINFRAME::ToPreviousNA )
EVT_TOOL( ID_CVPCB_GOTO_PREVIOUSNA, CVPCB_MAINFRAME::ToPreviousNA ) EVT_TOOL( ID_CVPCB_DEL_ASSOCIATIONS, CVPCB_MAINFRAME::DelAssociations )
EVT_TOOL( ID_CVPCB_DEL_ASSOCIATIONS, CVPCB_MAINFRAME::DelAssociations ) EVT_TOOL( ID_CVPCB_AUTO_ASSOCIE, CVPCB_MAINFRAME::AssocieModule )
EVT_TOOL( ID_CVPCB_AUTO_ASSOCIE, CVPCB_MAINFRAME::AssocieModule ) EVT_TOOL( ID_CVPCB_CREATE_STUFF_FILE, CVPCB_MAINFRAME::WriteStuffList )
EVT_TOOL( ID_CVPCB_CREATE_STUFF_FILE, CVPCB_MAINFRAME::WriteStuffList ) EVT_TOOL( ID_PCB_DISPLAY_FOOTPRINT_DOC, CVPCB_MAINFRAME::DisplayDocFile )
EVT_TOOL( ID_PCB_DISPLAY_FOOTPRINT_DOC, CVPCB_MAINFRAME::DisplayDocFile ) EVT_TOOL( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST,
EVT_TOOL( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST, CVPCB_MAINFRAME::OnSelectFilteringFootprint )
CVPCB_MAINFRAME::OnSelectFilteringFootprint ) EVT_TOOL( ID_CVPCB_FOOTPRINT_DISPLAY_FULL_LIST,
EVT_TOOL( ID_CVPCB_FOOTPRINT_DISPLAY_FULL_LIST, CVPCB_MAINFRAME::OnSelectFilteringFootprint )
CVPCB_MAINFRAME::OnSelectFilteringFootprint )
// Frame events // Frame events
EVT_CHAR( CVPCB_MAINFRAME::OnChar ) EVT_CHAR( CVPCB_MAINFRAME::OnChar )
EVT_CLOSE( CVPCB_MAINFRAME::OnCloseWindow ) EVT_CLOSE( CVPCB_MAINFRAME::OnCloseWindow )
EVT_SIZE( CVPCB_MAINFRAME::OnSize ) EVT_SIZE( CVPCB_MAINFRAME::OnSize )
// List item events // List item events
EVT_LIST_ITEM_SELECTED( ID_CVPCB_FOOTPRINT_LIST, CVPCB_MAINFRAME::OnLeftClick ) 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_ACTIVATED( ID_CVPCB_FOOTPRINT_LIST, CVPCB_MAINFRAME::OnLeftDClick )
EVT_LIST_ITEM_SELECTED( ID_CVPCB_COMPONENT_LIST, CVPCB_MAINFRAME::OnSelectComponent ) EVT_LIST_ITEM_SELECTED( ID_CVPCB_COMPONENT_LIST, CVPCB_MAINFRAME::OnSelectComponent )
EVT_UPDATE_UI( ID_CVPCB_CONFIG_KEEP_OPEN_ON_SAVE, EVT_UPDATE_UI( ID_CVPCB_CONFIG_KEEP_OPEN_ON_SAVE, CVPCB_MAINFRAME::OnUpdateKeepOpenOnSave )
CVPCB_MAINFRAME::OnUpdateKeepOpenOnSave ) END_EVENT_TABLE()
END_EVENT_TABLE() CVPCB_MAINFRAME::CVPCB_MAINFRAME( const wxString& title, long style ) :
CVPCB_MAINFRAME::CVPCB_MAINFRAME( const wxString& title, long style ) :
EDA_BASE_FRAME( NULL, CVPCB_FRAME, title, wxDefaultPosition, wxDefaultSize, style ) EDA_BASE_FRAME( NULL, CVPCB_FRAME, title, wxDefaultPosition, wxDefaultSize, style )
{ {
m_FrameName = wxT( "CvpcbFrame" ); m_FrameName = wxT( "CvpcbFrame" );
@ -116,8 +109,10 @@ END_EVENT_TABLE() CVPCB_MAINFRAME::CVPCB_MAINFRAME( const wxString& title, long
SetAutoLayout( true ); SetAutoLayout( true );
LoadSettings(); LoadSettings();
if( m_FrameSize.x < FRAME_MIN_SIZE_X ) if( m_FrameSize.x < FRAME_MIN_SIZE_X )
m_FrameSize.x = FRAME_MIN_SIZE_X; m_FrameSize.x = FRAME_MIN_SIZE_X;
if( m_FrameSize.y < FRAME_MIN_SIZE_Y ) if( m_FrameSize.y < FRAME_MIN_SIZE_Y )
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 ) if( m_HToolBar )
m_auimgr.AddPane( m_HToolBar, m_auimgr.AddPane( m_HToolBar,
wxAuiPaneInfo( horiz ).Name( wxT( "m_HToolBar" ) ).Top() ); wxAuiPaneInfo( horiz ).Name( wxT( "m_HToolBar" ) ).Top() );
if( m_ListCmp ) if( m_ListCmp )
m_auimgr.AddPane( m_ListCmp, m_auimgr.AddPane( m_ListCmp,
wxAuiPaneInfo( horiz ).Name( wxT( "m_ListCmp" ) ).CentrePane() ); wxAuiPaneInfo( horiz ).Name( wxT( "m_ListCmp" ) ).CentrePane() );
if( m_FootprintList ) if( m_FootprintList )
m_auimgr.AddPane( m_FootprintList, m_auimgr.AddPane( m_FootprintList,
wxAuiPaneInfo( horiz ).Name( wxT( "m_FootprintList" ) ). wxAuiPaneInfo( horiz ).Name( wxT( "m_FootprintList" ) ).
Right().BestSize( (int) ( m_FrameSize.x * 0.36 ), m_FrameSize.y ) ); Right().BestSize( (int) ( m_FrameSize.x * 0.36 ), m_FrameSize.y ) );
m_auimgr.Update(); m_auimgr.Update();
} }
@ -175,8 +170,7 @@ CVPCB_MAINFRAME::~CVPCB_MAINFRAME()
if( config ) if( config )
{ {
int state = m_HToolBar->GetToolState( int state = m_HToolBar->GetToolState( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST );
ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST );
config->Write( wxT( FILTERFOOTPRINTKEY ), state ); 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() void CVPCB_MAINFRAME::LoadSettings()
{ {
wxASSERT( wxGetApp().m_EDA_Config != NULL ); 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() void CVPCB_MAINFRAME::SaveSettings()
{ {
wxASSERT( wxGetApp().m_EDA_Config != NULL ); wxASSERT( wxGetApp().m_EDA_Config != NULL );
@ -243,8 +225,7 @@ void CVPCB_MAINFRAME::OnCloseWindow( wxCloseEvent& Event )
wxMessageDialog dialog( this, wxMessageDialog dialog( this,
_( "Net and component list modified.\nSave before exit ?" ), _( "Net and component list modified.\nSave before exit ?" ),
_( "Confirmation" ), _( "Confirmation" ),
wxYES_NO | wxCANCEL | wxICON_EXCLAMATION | wxYES_NO | wxCANCEL | wxICON_EXCLAMATION | wxYES_DEFAULT );
wxYES_DEFAULT );
ii = dialog.ShowModal(); ii = dialog.ShowModal();
@ -259,9 +240,12 @@ void CVPCB_MAINFRAME::OnCloseWindow( wxCloseEvent& Event )
case wxID_OK: case wxID_OK:
case wxID_YES: case wxID_YES:
diag = SaveNetList( wxEmptyString ); diag = SaveNetList( m_NetlistFileName.GetFullPath() );
if( diag > 0 ) if( diag > 0 )
{
m_modified = false; m_modified = false;
}
else if( diag == 0 ) else if( diag == 0 )
{ {
if( !IsOK( this, _( "Problem when saving files, exit anyway ?" ) ) ) if( !IsOK( this, _( "Problem when saving files, exit anyway ?" ) ) )
@ -277,8 +261,7 @@ void CVPCB_MAINFRAME::OnCloseWindow( wxCloseEvent& Event )
// Close the help frame // Close the help frame
if( wxGetApp().m_HtmlCtrl ) if( wxGetApp().m_HtmlCtrl )
{ {
if( wxGetApp().m_HtmlCtrl->GetFrame() ) // returns NULL if no help if( wxGetApp().m_HtmlCtrl->GetFrame() ) // returns NULL if no help frame active
// frame active
wxGetApp().m_HtmlCtrl->GetFrame()->Close( true ); wxGetApp().m_HtmlCtrl->GetFrame()->Close( true );
} }
@ -290,6 +273,7 @@ void CVPCB_MAINFRAME::OnCloseWindow( wxCloseEvent& Event )
// Close module display frame // Close module display frame
if( m_DisplayFootprintFrame ) if( m_DisplayFootprintFrame )
m_DisplayFootprintFrame->Close( true ); m_DisplayFootprintFrame->Close( true );
m_modified = false; m_modified = false;
SaveSettings(); SaveSettings();
Destroy(); Destroy();
@ -331,7 +315,8 @@ void CVPCB_MAINFRAME::ToFirstNA( wxCommandEvent& event )
if( selection < 0 ) if( selection < 0 )
selection = 0; selection = 0;
BOOST_FOREACH( COMPONENT & component, m_components ) { BOOST_FOREACH( COMPONENT & component, m_components )
{
if( component.m_Module.IsEmpty() && ii > selection ) if( component.m_Module.IsEmpty() && ii > selection )
{ {
m_ListCmp->SetSelection( ii ); m_ListCmp->SetSelection( ii );
@ -340,6 +325,7 @@ void CVPCB_MAINFRAME::ToFirstNA( wxCommandEvent& event )
ii++; ii++;
} }
m_ListCmp->SetSelection( selection ); m_ListCmp->SetSelection( selection );
} }
@ -358,32 +344,36 @@ void CVPCB_MAINFRAME::ToPreviousNA( wxCommandEvent& event )
if( selection < 0 ) if( selection < 0 )
selection = m_ListCmp->GetCount() - 1; 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 ) if( component.m_Module.IsEmpty() && ii < selection )
{ {
m_ListCmp->SetSelection( ii ); m_ListCmp->SetSelection( ii );
return; return;
} }
ii--; ii--;
} }
m_ListCmp->SetSelection( selection ); 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; m_modified = false;
if( !m_KeepCvpcbOpen ) if( !m_KeepCvpcbOpen )
Close( true ); Close( true );
} }
} }
/* Removes all associations already made
*/
void CVPCB_MAINFRAME::DelAssociations( wxCommandEvent& event ) void CVPCB_MAINFRAME::DelAssociations( wxCommandEvent& event )
{ {
wxString Line; wxString Line;
@ -392,7 +382,8 @@ void CVPCB_MAINFRAME::DelAssociations( wxCommandEvent& event )
{ {
m_ListCmp->SetSelection( 0 ); m_ListCmp->SetSelection( 0 );
BOOST_FOREACH( COMPONENT & component, m_components ) { BOOST_FOREACH( COMPONENT & component, m_components )
{
component.m_Module.Empty(); component.m_Module.Empty();
SetNewPkg( wxEmptyString ); 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 ) void CVPCB_MAINFRAME::LoadNetList( wxCommandEvent& event )
{ {
wxString oldPath; wxString oldPath;
@ -440,18 +427,10 @@ void CVPCB_MAINFRAME::LoadNetList( wxCommandEvent& event )
/* Update the library search path list. */ /* Update the library search path list. */
if( wxGetApp().GetLibraryPathList().Index( oldPath ) != wxNOT_FOUND ) if( wxGetApp().GetLibraryPathList().Index( oldPath ) != wxNOT_FOUND )
wxGetApp().GetLibraryPathList().Remove( oldPath ); wxGetApp().GetLibraryPathList().Remove( oldPath );
wxGetApp().GetLibraryPathList().Insert( newFileName.GetPath(), 0 ); wxGetApp().GetLibraryPathList().Insert( newFileName.GetPath(), 0 );
m_NetlistFileName = newFileName; m_NetlistFileName = newFileName;
ReadNetList();
if( ReadNetList() )
{
SetTitle( wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion() +
wxT( " " ) + m_NetlistFileName.GetFullPath() );
}
else
{
SetTitle( wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion() );
}
} }
@ -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 ) void CVPCB_MAINFRAME::SetLanguage( wxCommandEvent& event )
{ {
EDA_BASE_FRAME::SetLanguage( event ); EDA_BASE_FRAME::SetLanguage( event );
@ -487,8 +463,7 @@ void CVPCB_MAINFRAME::SetLanguage( wxCommandEvent& event )
void CVPCB_MAINFRAME::DisplayDocFile( wxCommandEvent& event ) void CVPCB_MAINFRAME::DisplayDocFile( wxCommandEvent& event )
{ {
GetAssociatedDocument( this, m_DocModulesFileName, GetAssociatedDocument( this, m_DocModulesFileName, &wxGetApp().GetLibraryPathList() );
&wxGetApp().GetLibraryPathList() );
} }
@ -515,6 +490,7 @@ void CVPCB_MAINFRAME::OnSelectComponent( wxListEvent& event )
} }
selection = m_ListCmp->GetSelection(); selection = m_ListCmp->GetSelection();
if( selection < 0 ) if( selection < 0 )
{ {
m_FootprintList->SetActiveFootprintList( true, true ); m_FootprintList->SetActiveFootprintList( true, true );
@ -527,14 +503,11 @@ void CVPCB_MAINFRAME::OnSelectComponent( wxListEvent& event )
return; return;
} }
m_FootprintList->SetFootprintFilteredList( &m_components[ selection ], m_FootprintList->SetFootprintFilteredList( &m_components[ selection ], m_footprints );
m_footprints );
DisplayStatus(); DisplayStatus();
} }
/* Select full/filtered footprint display on tool click
*/
void CVPCB_MAINFRAME::OnSelectFilteringFootprint( wxCommandEvent& event ) void CVPCB_MAINFRAME::OnSelectFilteringFootprint( wxCommandEvent& event )
{ {
switch( event.GetId() ) 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() void CVPCB_MAINFRAME::DisplayStatus()
{ {
wxString msg; wxString msg;
msg.Printf( _( "Components: %d (free: %d)" ), msg.Printf( _( "Components: %d (free: %d)" ), m_components.size(), m_undefinedComponentCnt );
m_components.size(), m_undefinedComponentCnt );
SetStatusText( msg, 0 ); SetStatusText( msg, 0 );
SetStatusText( wxEmptyString, 1 ); SetStatusText( wxEmptyString, 1 );
@ -580,25 +549,20 @@ void CVPCB_MAINFRAME::DisplayStatus()
{ {
if( m_FootprintList->m_UseFootprintFullList ) if( m_FootprintList->m_UseFootprintFullList )
msg.Printf( _( "Footprints (All): %d" ), msg.Printf( _( "Footprints (All): %d" ),
m_FootprintList->m_ActiveFootprintList->GetCount() ); m_FootprintList->m_ActiveFootprintList->GetCount() );
else else
msg.Printf( _( "Footprints (filtered): %d" ), msg.Printf( _( "Footprints (filtered): %d" ),
m_FootprintList->m_ActiveFootprintList->GetCount() ); m_FootprintList->m_ActiveFootprintList->GetCount() );
} }
else else
{
msg.Empty(); msg.Empty();
}
SetStatusText( msg, 2 ); 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() bool CVPCB_MAINFRAME::LoadFootprintFiles()
{ {
/* Check if there are footprint libraries in project file */ /* 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() ) if( !m_footprints.m_filesNotFound.IsEmpty() || !m_footprints.m_filesInvalid.IsEmpty() )
{ {
DIALOG_LOAD_ERROR dialog( NULL ); DIALOG_LOAD_ERROR dialog( NULL );
if( !m_footprints.m_filesNotFound.IsEmpty() ) if( !m_footprints.m_filesNotFound.IsEmpty() )
{ {
wxString message = _( "Some files could not be found!" ); wxString message = _( "Some files could not be found!" );
@ -628,8 +593,31 @@ bool CVPCB_MAINFRAME::LoadFootprintFiles()
dialog.MessageSet( _( "Some files are invalid!" ) ); dialog.MessageSet( _( "Some files are invalid!" ) );
dialog.ListSet( m_footprints.m_filesInvalid ); dialog.ListSet( m_footprints.m_filesInvalid );
} }
dialog.ShowModal(); dialog.ShowModal();
} }
return true; 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 );
}

View File

@ -41,12 +41,12 @@ const wxString titleLibLoadError( _( "Library Load Error" ) );
*/ */
void WinEDA_App::MacOpenFile(const wxString &fileName) void WinEDA_App::MacOpenFile(const wxString &fileName)
{ {
wxFileName filename = fileName; wxFileName filename = fileName;
wxString oldPath; wxString oldPath;
CVPCB_MAINFRAME * frame = ((CVPCB_MAINFRAME*)GetTopWindow()); CVPCB_MAINFRAME* frame = (CVPCB_MAINFRAME*) GetTopWindow();
if(!filename.FileExists()) if( !filename.FileExists() )
return; return;
if( frame->m_NetlistFileName.DirExists() ) if( frame->m_NetlistFileName.DirExists() )
oldPath = frame->m_NetlistFileName.GetPath(); oldPath = frame->m_NetlistFileName.GetPath();
@ -54,39 +54,32 @@ void WinEDA_App::MacOpenFile(const wxString &fileName)
/* Update the library search path list. */ /* Update the library search path list. */
if( wxGetApp().GetLibraryPathList().Index( oldPath ) != wxNOT_FOUND ) if( wxGetApp().GetLibraryPathList().Index( oldPath ) != wxNOT_FOUND )
wxGetApp().GetLibraryPathList().Remove( oldPath ); wxGetApp().GetLibraryPathList().Remove( oldPath );
wxGetApp().GetLibraryPathList().Insert( filename.GetPath(), 0 ); wxGetApp().GetLibraryPathList().Insert( filename.GetPath(), 0 );
frame->m_NetlistFileName = filename; frame->m_NetlistFileName = filename;
frame->ReadNetList();
if( frame->ReadNetList() )
{
frame->SetTitle( wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion() +
wxT( " " ) + filename.GetFullPath() );
}
else
{
frame->SetTitle( wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion() );
}
} }
// Create a new application object // Create a new application object
IMPLEMENT_APP( WinEDA_App ) IMPLEMENT_APP( WinEDA_App )
/************************************/ /************************************/
/* Called to initialize the program */ /* Called to initialize the program */
/************************************/ /************************************/
bool WinEDA_App::OnInit() bool WinEDA_App::OnInit()
{ {
wxFileName filename; wxFileName filename;
wxString message; wxString message;
CVPCB_MAINFRAME* frame = NULL; 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( m_Checker && m_Checker->IsAnotherRunning() )
{ {
if( !IsOK( NULL, _( "Cvpcb is already running, Continue?" ) ) ) if( !IsOK( NULL, _( "CVPcb is already running, Continue?" ) ) )
return false; return false;
} }
@ -126,9 +119,7 @@ bool WinEDA_App::OnInit()
frame->LoadFootprintFiles(); frame->LoadFootprintFiles();
frame->m_NetlistFileExtension = wxT( "net" ); frame->m_NetlistFileExtension = wxT( "net" );
frame->m_NetlistFileName.Clear(); frame->m_NetlistFileName.Clear();
frame->SetTitle( GetTitle() + wxT( " " ) + GetBuildVersion() + frame->UpdateTitle();
wxGetCwd() + wxFileName::GetPathSeparator() +
_( " [no file]" ) );
return true; return true;
} }

View File

@ -44,60 +44,130 @@ protected:
bool m_isEESchemaNetlist; bool m_isEESchemaNetlist;
PARAM_CFG_ARRAY m_projectFileParams; PARAM_CFG_ARRAY m_projectFileParams;
public: CVPCB_MAINFRAME( const wxString& title, public:
long style = KICAD_DEFAULT_DRAWFRAME_STYLE ); CVPCB_MAINFRAME( const wxString& title, long style = KICAD_DEFAULT_DRAWFRAME_STYLE );
~CVPCB_MAINFRAME(); ~CVPCB_MAINFRAME();
void OnLeftClick( wxListEvent& event ); void OnLeftClick( wxListEvent& event );
void OnLeftDClick( wxListEvent& event ); void OnLeftDClick( wxListEvent& event );
void OnSelectComponent( wxListEvent& event ); void OnSelectComponent( wxListEvent& event );
void Update_Config( wxCommandEvent& event );
void OnQuit( wxCommandEvent& event ); void OnQuit( wxCommandEvent& event );
void OnCloseWindow( wxCloseEvent& Event ); void OnCloseWindow( wxCloseEvent& Event );
void OnSize( wxSizeEvent& SizeEvent ); void OnSize( wxSizeEvent& SizeEvent );
void OnChar( wxKeyEvent& event ); void OnChar( wxKeyEvent& event );
void ReCreateHToolbar(); void ReCreateHToolbar();
virtual void ReCreateMenuBar(); virtual void ReCreateMenuBar();
/**
* Function SetLanguage
* is called on a language menu selection.
*/
void SetLanguage( wxCommandEvent& event ); void SetLanguage( wxCommandEvent& event );
void ToFirstNA( wxCommandEvent& event ); void ToFirstNA( wxCommandEvent& event );
void ToPreviousNA( wxCommandEvent& event ); void ToPreviousNA( wxCommandEvent& event );
/**
* Function DelAssociations
* removes all component footprint associations already made
*/
void DelAssociations( wxCommandEvent& event ); void DelAssociations( wxCommandEvent& event );
void SaveProjectFile( wxCommandEvent& aEvent );
void SaveQuitCvpcb( wxCommandEvent& event ); 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 LoadNetList( wxCommandEvent& event );
void ConfigCvpcb( wxCommandEvent& event ); void ConfigCvpcb( wxCommandEvent& event );
void OnKeepOpenOnSave( wxCommandEvent& event ); void OnKeepOpenOnSave( wxCommandEvent& event );
void DisplayModule( wxCommandEvent& event ); void DisplayModule( wxCommandEvent& event );
void AssocieModule( wxCommandEvent& event ); void AssocieModule( wxCommandEvent& event );
void WriteStuffList( wxCommandEvent& event ); void WriteStuffList( wxCommandEvent& event );
void DisplayDocFile( wxCommandEvent& event ); void DisplayDocFile( wxCommandEvent& event );
/**
* Function OnSelectFilteringFootprint
* is the command event handler for enabling and disabling footprint filtering.
*/
void OnSelectFilteringFootprint( wxCommandEvent& event ); void OnSelectFilteringFootprint( wxCommandEvent& event );
void OnUpdateKeepOpenOnSave( wxUpdateUIEvent& 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 SetNewPkg( const wxString& package );
void BuildCmpListBox(); void BuildCmpListBox();
void BuildFOOTPRINTS_LISTBOX(); void BuildFOOTPRINTS_LISTBOX();
void CreateScreenCmp(); 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(); bool ReadNetList();
int ReadSchematicNetlist(); 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(); 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(); virtual void SaveSettings();
/** /**
* Function DisplayStatus() * Function DisplayStatus
* Displays info to the status line at bottom of the main frame * displays info to the status line at bottom of the main frame.
*/ */
void DisplayStatus(); void DisplayStatus();
/** /**
* Function LoadFootprintFiles * 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 * for each module are stored
* the module name * the module name
* documentation string * documentation string
@ -117,13 +187,38 @@ public: CVPCB_MAINFRAME( const wxString& title,
/** /**
* Function LoadComponentFile * Function LoadComponentFile
* Loads the .cmp file that stores the component/footprint association. * loads the .cmp file \a aCmpFileName that stores the component/footprint association.
* @param aCmpFileName = the full filename of .cmp file to load *
* @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 ); 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() DECLARE_EVENT_TABLE()
}; };

View File

@ -10,6 +10,7 @@
#include "common.h" #include "common.h"
#include "confirm.h" #include "confirm.h"
#include "gestfich.h" #include "gestfich.h"
#include "id.h"
#include "cvpcb.h" #include "cvpcb.h"
#include "cvpcb_mainframe.h" #include "cvpcb_mainframe.h"
@ -59,15 +60,18 @@ void DIALOG_CVPCB_CONFIG::Init()
// Load user libs paths: // Load user libs paths:
wxStringTokenizer Token( m_UserLibDirBufferImg, wxT( ";\n\r" ) ); wxStringTokenizer Token( m_UserLibDirBufferImg, wxT( ";\n\r" ) );
while( Token.HasMoreTokens() ) while( Token.HasMoreTokens() )
{ {
wxString path = Token.GetNextToken(); wxString path = Token.GetNextToken();
if( wxFileName::DirExists( path ) ) if( wxFileName::DirExists( path ) )
m_listUserPaths->Append( path ); m_listUserPaths->Append( path );
} }
// Display actual libraries paths: // Display actual libraries paths:
wxPathList libpaths = wxGetApp().GetLibraryPathList(); wxPathList libpaths = wxGetApp().GetLibraryPathList();
for( unsigned ii = 0; ii < libpaths.GetCount(); ii++ ) for( unsigned ii = 0; ii < libpaths.GetCount(); ii++ )
{ {
m_DefaultLibraryPathslistBox->Append( libpaths[ii] ); m_DefaultLibraryPathslistBox->Append( libpaths[ii] );
@ -102,25 +106,28 @@ void DIALOG_CVPCB_CONFIG::OnOkClick( wxCommandEvent& event )
if( m_LibPathChanged ) if( m_LibPathChanged )
{ {
m_Parent->m_UserLibraryPath.Empty(); m_Parent->m_UserLibraryPath.Empty();
for( unsigned ii = 0; ii < m_listUserPaths->GetCount(); ii++ ) for( unsigned ii = 0; ii < m_listUserPaths->GetCount(); ii++ )
{ {
if( ii > 0 ) if( ii > 0 )
m_Parent->m_UserLibraryPath << wxT( ";" ); m_Parent->m_UserLibraryPath << wxT( ";" );
m_Parent->m_UserLibraryPath << m_listUserPaths->GetString( ii ); m_Parent->m_UserLibraryPath << m_listUserPaths->GetString( ii );
} }
} }
// Set new active library list if the lib list of if default path list // Set new active library list if the lib list of if default path list was modified
// was modified
if( m_LibListChanged || m_LibPathChanged ) if( m_LibListChanged || m_LibPathChanged )
{ {
// Recreate lib list // Recreate lib list
m_Parent->m_ModuleLibNames.Clear(); m_Parent->m_ModuleLibNames.Clear();
for( unsigned ii = 0; ii < m_ListLibr->GetCount(); ii++ ) for( unsigned ii = 0; ii < m_ListLibr->GetCount(); ii++ )
m_Parent->m_ModuleLibNames.Add( m_ListLibr->GetString( ii ) ); m_Parent->m_ModuleLibNames.Add( m_ListLibr->GetString( ii ) );
// Recreate equ list // Recreate equ list
m_Parent->m_AliasLibNames.Clear(); m_Parent->m_AliasLibNames.Clear();
for( unsigned ii = 0; ii < m_ListEquiv->GetCount(); ii++ ) for( unsigned ii = 0; ii < m_ListEquiv->GetCount(); ii++ )
m_Parent->m_AliasLibNames.Add( m_ListEquiv->GetString( 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->BuildFOOTPRINTS_LISTBOX();
} }
m_Parent->SaveProjectFile( m_Parent->m_NetlistFileName.GetFullPath() ); wxCommandEvent evt( ID_SAVE_PROJECT );
m_Parent->SaveProjectFile( evt );
EndModal( wxID_OK ); EndModal( wxID_OK );
} }
@ -144,6 +152,7 @@ void DIALOG_CVPCB_CONFIG::OnButtonUpClick( wxCommandEvent& event )
/********************************************************************/ /********************************************************************/
{ {
wxListBox * list = m_ListLibr; wxListBox * list = m_ListLibr;
if( (event.GetId() == ID_EQU_UP) || (event.GetId() == ID_EQU_DOWN) ) if( (event.GetId() == ID_EQU_UP) || (event.GetId() == ID_EQU_DOWN) )
{ {
list = m_ListEquiv; list = m_ListEquiv;
@ -151,7 +160,8 @@ void DIALOG_CVPCB_CONFIG::OnButtonUpClick( wxCommandEvent& event )
wxArrayInt selections; wxArrayInt selections;
list->GetSelections(selections); list->GetSelections( selections );
if ( selections.GetCount() <= 0 ) // No selection. if ( selections.GetCount() <= 0 ) // No selection.
return; return;
@ -163,15 +173,16 @@ void DIALOG_CVPCB_CONFIG::OnButtonUpClick( wxCommandEvent& event )
for( size_t ii = 0; ii < selections.GetCount(); ii++ ) for( size_t ii = 0; ii < selections.GetCount(); ii++ )
{ {
int jj = selections[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 // Reselect previously selected names
for( size_t ii = 0; ii < selections.GetCount(); ii++ ) for( size_t ii = 0; ii < selections.GetCount(); ii++ )
{ {
int jj = selections[ii]; int jj = selections[ii];
list->SetSelection(jj-1); list->SetSelection( jj-1 );
} }
m_LibListChanged = TRUE; m_LibListChanged = TRUE;
@ -183,6 +194,7 @@ void DIALOG_CVPCB_CONFIG::OnButtonDownClick( wxCommandEvent& event )
/*********************************************************************/ /*********************************************************************/
{ {
wxListBox * list = m_ListLibr; wxListBox * list = m_ListLibr;
if( (event.GetId() == ID_EQU_UP) || (event.GetId() == ID_EQU_DOWN) ) if( (event.GetId() == ID_EQU_UP) || (event.GetId() == ID_EQU_DOWN) )
{ {
list = m_ListEquiv; list = m_ListEquiv;
@ -190,7 +202,8 @@ void DIALOG_CVPCB_CONFIG::OnButtonDownClick( wxCommandEvent& event )
wxArrayInt selections; wxArrayInt selections;
list->GetSelections(selections); list->GetSelections( selections );
if ( selections.GetCount() <= 0 ) // No selection. if ( selections.GetCount() <= 0 ) // No selection.
return; return;
@ -205,7 +218,8 @@ void DIALOG_CVPCB_CONFIG::OnButtonDownClick( wxCommandEvent& event )
int jj = selections[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 // Reselect previously selected names
for( size_t ii = 0; ii < selections.GetCount(); ii++ ) for( size_t ii = 0; ii < selections.GetCount(); ii++ )
@ -213,6 +227,7 @@ void DIALOG_CVPCB_CONFIG::OnButtonDownClick( wxCommandEvent& event )
int jj = selections[ii]; int jj = selections[ii];
list->SetSelection(jj+1); list->SetSelection(jj+1);
} }
m_LibListChanged = TRUE; m_LibListChanged = TRUE;
} }
@ -229,7 +244,8 @@ void DIALOG_CVPCB_CONFIG::OnRemoveLibClick( wxCommandEvent& event )
wxArrayInt selections; wxArrayInt selections;
list->GetSelections(selections); list->GetSelections( selections );
for( int ii = selections.GetCount()-1; ii >= 0; ii-- ) for( int ii = selections.GetCount()-1; ii >= 0; ii-- )
{ {
list->Delete(selections[ii] ); list->Delete(selections[ii] );
@ -256,6 +272,7 @@ void DIALOG_CVPCB_CONFIG::OnAddOrInsertLibClick( wxCommandEvent& event )
wildcard = FootprintAliasFileWildcard; wildcard = FootprintAliasFileWildcard;
wxListBox * list = m_ListEquiv; wxListBox * list = m_ListEquiv;
if( (event.GetId() == ID_ADD_LIB) || (event.GetId() == ID_INSERT_LIB) ) if( (event.GetId() == ID_ADD_LIB) || (event.GetId() == ID_INSERT_LIB) )
{ {
list = m_ListLibr; list = m_ListLibr;
@ -266,6 +283,7 @@ void DIALOG_CVPCB_CONFIG::OnAddOrInsertLibClick( wxCommandEvent& event )
list->GetSelections(selections); list->GetSelections(selections);
ii = selections.GetCount(); ii = selections.GetCount();
if( ii > 0 ) if( ii > 0 )
ii = selections[0]; ii = selections[0];
else else
@ -273,6 +291,7 @@ void DIALOG_CVPCB_CONFIG::OnAddOrInsertLibClick( wxCommandEvent& event )
wxString libpath; wxString libpath;
libpath = m_DefaultLibraryPathslistBox->GetStringSelection(); libpath = m_DefaultLibraryPathslistBox->GetStringSelection();
if( libpath.IsEmpty() ) if( libpath.IsEmpty() )
libpath = wxGetApp().ReturnLastVisitedLibraryPath(); libpath = wxGetApp().ReturnLastVisitedLibraryPath();
@ -289,6 +308,7 @@ void DIALOG_CVPCB_CONFIG::OnAddOrInsertLibClick( wxCommandEvent& event )
for( unsigned jj = 0; jj < Filenames.GetCount(); jj++ ) for( unsigned jj = 0; jj < Filenames.GetCount(); jj++ )
{ {
fn = Filenames[jj]; fn = Filenames[jj];
if( jj == 0 ) if( jj == 0 )
wxGetApp().SaveLastVisitedLibraryPath( fn.GetPath() ); wxGetApp().SaveLastVisitedLibraryPath( fn.GetPath() );
@ -300,15 +320,17 @@ void DIALOG_CVPCB_CONFIG::OnAddOrInsertLibClick( wxCommandEvent& event )
* is a sub path of these default paths * is a sub path of these default paths
*/ */
libfilename = wxGetApp().ReturnFilenameWithRelativePathInLibPath( fn.GetFullPath() ); libfilename = wxGetApp().ReturnFilenameWithRelativePathInLibPath( fn.GetFullPath() );
// Remove extension: // Remove extension:
fn = libfilename; fn = libfilename;
fn.SetExt(wxEmptyString); fn.SetExt( wxEmptyString );
libfilename = fn.GetFullPath(); libfilename = fn.GetFullPath();
// Add or insert new library name, if not already in list // Add or insert new library name, if not already in list
if( list->FindString( libfilename, fn.IsCaseSensitive() ) == wxNOT_FOUND ) if( list->FindString( libfilename, fn.IsCaseSensitive() ) == wxNOT_FOUND )
{ {
m_LibListChanged = TRUE; m_LibListChanged = TRUE;
if( ! insert ) if( ! insert )
list->Append( libfilename ); list->Append( libfilename );
else else
@ -344,25 +366,27 @@ void DIALOG_CVPCB_CONFIG::OnAddOrInsertPath( wxCommandEvent& event )
if( m_listUserPaths->FindString( path ) == wxNOT_FOUND ) if( m_listUserPaths->FindString( path ) == wxNOT_FOUND )
{ {
int ipos = m_listUserPaths->GetCount(); int ipos = m_listUserPaths->GetCount();
if( event.GetId() == ID_INSERT_PATH ) if( event.GetId() == ID_INSERT_PATH )
{ {
if( ipos ) if( ipos )
ipos--; ipos--;
int jj = m_listUserPaths->GetSelection(); int jj = m_listUserPaths->GetSelection();
if( jj >= 0 ) if( jj >= 0 )
ipos = jj; ipos = jj;
} }
// Ask the user if this is a relative path // Ask the user if this is a relative path
int diag = wxMessageBox( int diag = wxMessageBox( _( "Use a relative path?" ),
_( "Use a relative path?" ), _( "Path type" ),
_( "Path type" ), wxYES_NO | wxICON_QUESTION, this );
wxYES_NO | wxICON_QUESTION, this );
if( diag == wxYES ) if( diag == wxYES )
{ // Make it relative { // Make it relative
wxFileName fn = path; wxFileName fn = path;
fn.MakeRelativeTo( wxT(".") ); fn.MakeRelativeTo( wxT( "." ) );
path = fn.GetPathWithSep() + fn.GetFullName(); path = fn.GetPathWithSep() + fn.GetFullName();
} }
@ -373,13 +397,16 @@ void DIALOG_CVPCB_CONFIG::OnAddOrInsertPath( wxCommandEvent& event )
// Display actual libraries paths: // Display actual libraries paths:
wxPathList libpaths = wxGetApp().GetLibraryPathList(); wxPathList libpaths = wxGetApp().GetLibraryPathList();
m_DefaultLibraryPathslistBox->Clear(); m_DefaultLibraryPathslistBox->Clear();
for( unsigned ii = 0; ii < libpaths.GetCount(); ii++ ) for( unsigned ii = 0; ii < libpaths.GetCount(); ii++ )
{ {
m_DefaultLibraryPathslistBox->Append( libpaths[ii] ); m_DefaultLibraryPathslistBox->Append( libpaths[ii] );
} }
} }
else else
{
DisplayError( this, _( "Path already in use" ) ); DisplayError( this, _( "Path already in use" ) );
}
wxGetApp().SaveLastVisitedLibraryPath( path ); wxGetApp().SaveLastVisitedLibraryPath( path );
} }
@ -391,6 +418,7 @@ void DIALOG_CVPCB_CONFIG::OnRemoveUserPath( wxCommandEvent& event )
if( ii < 0 ) if( ii < 0 )
ii = m_listUserPaths->GetCount() - 1; ii = m_listUserPaths->GetCount() - 1;
if( ii >= 0 ) if( ii >= 0 )
{ {
wxGetApp().RemoveLibraryPath( m_listUserPaths->GetStringSelection() ); wxGetApp().RemoveLibraryPath( m_listUserPaths->GetStringSelection() );
@ -401,6 +429,7 @@ void DIALOG_CVPCB_CONFIG::OnRemoveUserPath( wxCommandEvent& event )
// Display actual libraries paths: // Display actual libraries paths:
wxPathList libpaths = wxGetApp().GetLibraryPathList(); wxPathList libpaths = wxGetApp().GetLibraryPathList();
m_DefaultLibraryPathslistBox->Clear(); m_DefaultLibraryPathslistBox->Clear();
for( unsigned ii = 0; ii < libpaths.GetCount(); ii++ ) for( unsigned ii = 0; ii < libpaths.GetCount(); ii++ )
{ {
m_DefaultLibraryPathslistBox->Append( libpaths[ii] ); m_DefaultLibraryPathslistBox->Append( libpaths[ii] );

View File

@ -15,10 +15,7 @@
#include "build_version.h" #include "build_version.h"
/*
* Set the module to the selected component
* Selects the next component
*/
void CVPCB_MAINFRAME::SetNewPkg( const wxString& package ) void CVPCB_MAINFRAME::SetNewPkg( const wxString& package )
{ {
COMPONENT* Component; COMPONENT* Component;
@ -30,6 +27,7 @@ void CVPCB_MAINFRAME::SetNewPkg( const wxString& package )
return; return;
NumCmp = m_ListCmp->GetSelection(); NumCmp = m_ListCmp->GetSelection();
if( NumCmp < 0 ) if( NumCmp < 0 )
{ {
NumCmp = 0; NumCmp = 0;
@ -46,9 +44,9 @@ void CVPCB_MAINFRAME::SetNewPkg( const wxString& package )
Component->m_Module = package; Component->m_Module = package;
msg.Printf( CMP_FORMAT, NumCmp + 1, msg.Printf( CMP_FORMAT, NumCmp + 1,
GetChars( Component->m_Reference ), GetChars( Component->m_Reference ),
GetChars( Component->m_Value ), GetChars( Component->m_Value ),
GetChars( Component->m_Module ) ); GetChars( Component->m_Module ) );
m_modified = true; m_modified = true;
if( isUndefined ) if( isUndefined )
@ -60,15 +58,13 @@ void CVPCB_MAINFRAME::SetNewPkg( const wxString& package )
// We activate next component: // We activate next component:
if( NumCmp < (m_ListCmp->GetCount() - 1) ) if( NumCmp < (m_ListCmp->GetCount() - 1) )
NumCmp++; NumCmp++;
m_ListCmp->SetSelection( NumCmp, TRUE ); m_ListCmp->SetSelection( NumCmp, TRUE );
DisplayStatus(); DisplayStatus();
} }
/*
* Read the netlist format and file components.
*/
bool CVPCB_MAINFRAME::ReadNetList() bool CVPCB_MAINFRAME::ReadNetList()
{ {
wxString msg; 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." ), msg.Printf( _( "File <%s> does not appear to be a valid Kicad net list file." ),
GetChars( m_NetlistFileName.GetFullPath() ) ); GetChars( m_NetlistFileName.GetFullPath() ) );
::wxMessageBox( msg, _( "File Error" ), wxOK | wxICON_ERROR, this ); ::wxMessageBox( msg, _( "File Error" ), wxOK | wxICON_ERROR, this );
m_NetlistFileName.Clear();
UpdateTitle();
return false; return false;
} }
@ -90,7 +88,7 @@ bool CVPCB_MAINFRAME::ReadNetList()
return false; return false;
LoadProjectFile( m_NetlistFileName.GetFullPath() ); LoadProjectFile( m_NetlistFileName.GetFullPath() );
LoadFootprintFiles( ); LoadFootprintFiles();
BuildFOOTPRINTS_LISTBOX(); BuildFOOTPRINTS_LISTBOX();
m_ListCmp->Clear(); m_ListCmp->Clear();
@ -103,6 +101,7 @@ bool CVPCB_MAINFRAME::ReadNetList()
GetChars( component.m_Value ), GetChars( component.m_Value ),
GetChars( component.m_Module ) ); GetChars( component.m_Module ) );
m_ListCmp->AppendLine( msg ); m_ListCmp->AppendLine( msg );
if( component.m_Module.IsEmpty() ) if( component.m_Module.IsEmpty() )
m_undefinedComponentCnt += 1; m_undefinedComponentCnt += 1;
} }
@ -112,9 +111,7 @@ bool CVPCB_MAINFRAME::ReadNetList()
DisplayStatus(); DisplayStatus();
/* Update the title of the main window. */ UpdateTitle();
SetTitle( wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion() +
wxT( " " ) + m_NetlistFileName.GetFullPath() );
UpdateFileHistory( m_NetlistFileName.GetFullPath() ); UpdateFileHistory( m_NetlistFileName.GetFullPath() );
@ -122,34 +119,40 @@ bool CVPCB_MAINFRAME::ReadNetList()
} }
/* int CVPCB_MAINFRAME::SaveNetList( const wxString& aFullFileName )
* 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 )
{ {
wxFileName fn; wxFileName fn;
if( !fileName && m_NetlistFileName.IsOk() ) if( !aFullFileName.IsEmpty() && m_NetlistFileName.IsOk() )
{
fn = m_NetlistFileName; fn = m_NetlistFileName;
}
else else
fn = wxFileName( wxGetCwd(), _( "unamed" ), NetExtBuffer ); {
wxFileDialog dlg( this, _( "Save Net and Component List" ), wxGetCwd(),
wxEmptyString, NetlistFileWildcard, wxFD_SAVE );
wxFileDialog dlg( this, _( "Save Net and Component List" ), fn.GetPath(), if( dlg.ShowModal() == wxID_CANCEL )
fn.GetFullName(), NetlistFileWildcard, return -1;
wxFD_SAVE/*| wxFD_OVERWRITE_PROMPT*/ );
if( dlg.ShowModal() == wxID_CANCEL ) fn = dlg.GetPath();
return -1;
if( SaveComponentList( dlg.GetPath() ) == 0 ) if( !fn.HasExt() )
fn.SetExt( NetlistFileExtension );
m_NetlistFileName = fn;
}
if( !IsWritable( fn.GetFullPath() ) )
return 0;
if( SaveComponentList( fn.GetFullPath() ) == 0 )
{ {
DisplayError( this, _( "Unable to create component file (.cmp)" ) ); DisplayError( this, _( "Unable to create component file (.cmp)" ) );
return 0; return 0;
} }
FILE* netlist = wxFopen( dlg.GetPath(), wxT( "wt" ) ); FILE* netlist = wxFopen( fn.GetFullPath(), wxT( "wt" ) );
if( netlist == 0 ) if( netlist == 0 )
{ {

View File

@ -29,8 +29,9 @@ void CVPCB_MAINFRAME::ReCreateMenuBar()
// Delete all existing menus so they can be rebuilt. // Delete all existing menus so they can be rebuilt.
// This allows language changes of the menu text on the fly. // This allows language changes of the menu text on the fly.
menuBar->Freeze(); menuBar->Freeze();
while( menuBar->GetMenuCount() ) while( menuBar->GetMenuCount() )
delete menuBar->Remove(0); delete menuBar->Remove( 0 );
// Recreate all menus: // Recreate all menus:
@ -46,25 +47,34 @@ void CVPCB_MAINFRAME::ReCreateMenuBar()
// Open Recent submenu // Open Recent submenu
static wxMenu* openRecentMenu; static wxMenu* openRecentMenu;
// Add this menu to list menu managed by m_fileHistory // Add this menu to list menu managed by m_fileHistory
// (the file history will be updated when adding/removing files in history // (the file history will be updated when adding/removing files in history
if( openRecentMenu ) if( openRecentMenu )
wxGetApp().m_fileHistory.RemoveMenu( openRecentMenu ); wxGetApp().m_fileHistory.RemoveMenu( openRecentMenu );
openRecentMenu = new wxMenu(); openRecentMenu = new wxMenu();
wxGetApp().m_fileHistory.UseMenu( openRecentMenu ); wxGetApp().m_fileHistory.UseMenu( openRecentMenu );
wxGetApp().m_fileHistory.AddFilesToMenu( ); wxGetApp().m_fileHistory.AddFilesToMenu();
ADD_MENUITEM_WITH_HELP_AND_SUBMENU( filesMenu, openRecentMenu, -1, ADD_MENUITEM_WITH_HELP_AND_SUBMENU( filesMenu, openRecentMenu, -1,
_( "Open &Recent" ), _( "Open &Recent" ),
_("Open a recent opened netlist document" ), _( "Open a recent opened netlist document" ),
open_project_xpm ); open_project_xpm );
// Separator // Separator
filesMenu->AppendSeparator(); filesMenu->AppendSeparator();
// Save
ADD_MENUITEM_WITH_HELP( filesMenu,
wxID_SAVE,
_( "&Save\tCtrl+S" ),
_( "Save net list and footprint list files" ),
save_xpm );
// Save as // Save as
ADD_MENUITEM_WITH_HELP( filesMenu, ADD_MENUITEM_WITH_HELP( filesMenu,
ID_SAVE_PROJECT, wxID_SAVEAS,
_( "&Save As..." ), _( "Save &As..." ),
_( "Save new net list and footprint list files" ), _( "Save new net list and footprint list files" ),
save_xpm ); save_xpm );
@ -75,7 +85,7 @@ void CVPCB_MAINFRAME::ReCreateMenuBar()
ADD_MENUITEM_WITH_HELP( filesMenu, ADD_MENUITEM_WITH_HELP( filesMenu,
wxID_EXIT, wxID_EXIT,
_( "&Quit" ), _( "&Quit" ),
_( "Quit CvPCB" ), _( "Quit CVPcb" ),
exit_xpm ); exit_xpm );
// Menu Preferences: // Menu Preferences:
@ -105,10 +115,14 @@ void CVPCB_MAINFRAME::ReCreateMenuBar()
// Separator // Separator
preferencesMenu->AppendSeparator(); preferencesMenu->AppendSeparator();
ADD_MENUITEM_WITH_HELP( preferencesMenu, ID_CONFIG_SAVE, ADD_MENUITEM_WITH_HELP( preferencesMenu, ID_SAVE_PROJECT,
_( "&Save Project File" ), _( "&Save Project File" ),
_( "Save changes to the project file" ), _( "Save changes to the project configuration file" ),
save_setup_xpm ); 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: // Menu Help:
wxMenu* helpMenu = new wxMenu; wxMenu* helpMenu = new wxMenu;
@ -118,13 +132,13 @@ void CVPCB_MAINFRAME::ReCreateMenuBar()
// Contents // Contents
ADD_MENUITEM_WITH_HELP( helpMenu, wxID_HELP, _( "&Contents" ), ADD_MENUITEM_WITH_HELP( helpMenu, wxID_HELP, _( "&Contents" ),
_( "Open the Cvpcb handbook" ), _( "Open the CVPcb handbook" ),
online_help_xpm ); online_help_xpm );
// About // About
ADD_MENUITEM_WITH_HELP( helpMenu, wxID_ABOUT, ADD_MENUITEM_WITH_HELP( helpMenu, wxID_ABOUT,
_( "&About CvPCB" ), _( "&About CVPcb" ),
_( "About CvPCB schematic to pcb converter" ), _( "About CVPcb schematic to pcb converter" ),
info_xpm ); info_xpm );
// Create the menubar and append all submenus // Create the menubar and append all submenus

View File

@ -23,22 +23,17 @@ char EnteteCmpMod[] = { "Cmp-Mod V01" };
#define titleComponentLibErr _( "Component Library Error" ) #define titleComponentLibErr _( "Component Library Error" )
/* int CVPCB_MAINFRAME::SaveComponentList( const wxString& aFullFileName )
* 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 )
{ {
FILE* dest; FILE* dest;
wxFileName fn( NetlistFullFileName ); wxFileName fn( aFullFileName );
char Line[1024]; char Line[1024];
wxString Title = wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion(); wxString Title = wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion();
fn.SetExt( ComponentFileExtension ); fn.SetExt( ComponentFileExtension );
dest = wxFopen( fn.GetFullPath(), wxT( "wt" ) ); dest = wxFopen( fn.GetFullPath(), wxT( "wt" ) );
if( dest == NULL ) if( dest == NULL )
return 0; return 0;
@ -49,14 +44,10 @@ int CVPCB_MAINFRAME::SaveComponentList( const wxString& NetlistFullFileName )
BOOST_FOREACH( COMPONENT& component, m_components ) BOOST_FOREACH( COMPONENT& component, m_components )
{ {
fprintf( dest, "\nBeginCmp\n" ); fprintf( dest, "\nBeginCmp\n" );
fprintf( dest, "TimeStamp = %s;\n", fprintf( dest, "TimeStamp = %s;\n", TO_UTF8( component.m_TimeStamp ) );
TO_UTF8( component.m_TimeStamp ) ); fprintf( dest, "Reference = %s;\n", TO_UTF8( component.m_Reference ) );
fprintf( dest, "Reference = %s;\n", fprintf( dest, "ValeurCmp = %s;\n", TO_UTF8( component.m_Value ) );
TO_UTF8( component.m_Reference ) ); fprintf( dest, "IdModule = %s;\n", TO_UTF8( component.m_Module ) );
fprintf( dest, "ValeurCmp = %s;\n",
TO_UTF8( component.m_Value ) );
fprintf( dest, "IdModule = %s;\n",
TO_UTF8( component.m_Module ) );
fprintf( dest, "EndCmp\n" ); fprintf( dest, "EndCmp\n" );
} }
@ -66,25 +57,22 @@ int CVPCB_MAINFRAME::SaveComponentList( const wxString& NetlistFullFileName )
} }
/* bool CVPCB_MAINFRAME::LoadComponentFile( const wxString& aFileName )
* Load list of associated components and footprints.
*/
bool CVPCB_MAINFRAME::LoadComponentFile( const wxString& fileName )
{ {
wxString timestamp, valeur, ilib, namecmp, msg; 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; char Line[1024], * ident, * data;
FILE* source; FILE* source;
wxFileName fn = fileName; wxFileName fn = aFileName;
fn.SetExt( ComponentFileExtension ); fn.SetExt( ComponentFileExtension );
source = wxFopen( fn.GetFullPath(), wxT( "rt" ) ); source = wxFopen( fn.GetFullPath(), wxT( "rt" ) );
if( source == NULL ) if( source == NULL )
{ {
msg.Printf( _( "Cannot open CvPcb component file <%s>." ), msg.Printf( _( "Cannot open CVPcb component file <%s>." ),
GetChars( fn.GetFullPath() ) ); 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 ); wxMessageBox( msg, titleComponentLibErr, wxOK | wxICON_ERROR );
return false; return false;
} }
@ -115,23 +103,24 @@ bool CVPCB_MAINFRAME::LoadComponentFile( const wxString& fileName )
/* Search the beginning of the component description. */ /* Search the beginning of the component description. */
if( strnicmp( Line, "BeginCmp", 8 ) != 0 ) if( strnicmp( Line, "BeginCmp", 8 ) != 0 )
continue; continue;
timestamp.Empty(); timestamp.Empty();
valeur.Empty(); valeur.Empty();
ilib.Empty(); ilib.Empty();
namecmp.Empty(); namecmp.Empty();
read_cmp_data = TRUE; read_cmp_data = true;
while( !eof && read_cmp_data ) while( !eof && read_cmp_data )
{ {
if( fgets( Line, 1024, source ) == 0 ) if( fgets( Line, 1024, source ) == 0 )
{ {
eof = TRUE; eof = true;
break; break;
} }
if( strnicmp( Line, "EndCmp", 6 ) == 0 ) if( strnicmp( Line, "EndCmp", 6 ) == 0 )
{ {
read_cmp_data = TRUE; read_cmp_data = true;
break; break;
} }
@ -141,38 +130,37 @@ bool CVPCB_MAINFRAME::LoadComponentFile( const wxString& fileName )
if( strnicmp( ident, "TimeStamp", 9 ) == 0 ) if( strnicmp( ident, "TimeStamp", 9 ) == 0 )
{ {
timestamp = FROM_UTF8( data ); timestamp = FROM_UTF8( data );
timestamp.Trim( TRUE ); timestamp.Trim( true );
timestamp.Trim( FALSE ); timestamp.Trim( false );
continue; continue;
} }
if( strnicmp( ident, "Reference", 9 ) == 0 ) if( strnicmp( ident, "Reference", 9 ) == 0 )
{ {
namecmp = FROM_UTF8( data ); namecmp = FROM_UTF8( data );
namecmp.Trim( TRUE ); namecmp.Trim( true );
namecmp.Trim( FALSE ); namecmp.Trim( false );
continue; continue;
} }
if( strnicmp( ident, "ValeurCmp", 9 ) == 0 ) if( strnicmp( ident, "ValeurCmp", 9 ) == 0 )
{ {
valeur = FROM_UTF8( data ); valeur = FROM_UTF8( data );
valeur.Trim( TRUE ); valeur.Trim( true );
valeur.Trim( FALSE ); valeur.Trim( false );
continue; continue;
} }
if( strnicmp( ident, "IdModule", 8 ) == 0 ) if( strnicmp( ident, "IdModule", 8 ) == 0 )
{ {
ilib = FROM_UTF8( data ); ilib = FROM_UTF8( data );
ilib.Trim( TRUE ); ilib.Trim( true );
ilib.Trim( FALSE ); ilib.Trim( false );
continue; continue;
} }
} /* End reading component description. */ } /* End reading component description. */
/* Search corresponding component and NetList /* Search corresponding component and NetList Update its parameters. */
* Update its parameters. */
BOOST_FOREACH( COMPONENT& component, m_components ) BOOST_FOREACH( COMPONENT& component, m_components )
{ {
if( namecmp != component.m_Reference ) if( namecmp != component.m_Reference )

View File

@ -22,64 +22,63 @@ void CVPCB_MAINFRAME::ReCreateHToolbar()
m_HToolBar = new EDA_TOOLBAR( TOOLBAR_MAIN, this, ID_H_TOOLBAR, TRUE ); m_HToolBar = new EDA_TOOLBAR( TOOLBAR_MAIN, this, ID_H_TOOLBAR, TRUE );
m_HToolBar->AddTool( ID_CVPCB_READ_INPUT_NETLIST, wxEmptyString, m_HToolBar->AddTool( ID_CVPCB_READ_INPUT_NETLIST, wxEmptyString,
wxBitmap( open_document_xpm ), wxBitmap( open_document_xpm ),
_( "Open a net list file" ) ); _( "Open a net list file" ) );
m_HToolBar->AddTool( ID_CVPCB_SAVEQUITCVPCB, wxEmptyString, m_HToolBar->AddTool( wxID_SAVE, wxEmptyString, wxBitmap( save_xpm ),
wxBitmap( save_xpm ), _( "Save net list and footprint files" ) );
_( "Save net list and footprint files" ) );
m_HToolBar->AddSeparator(); m_HToolBar->AddSeparator();
m_HToolBar->AddTool( ID_CVPCB_CREATE_CONFIGWINDOW, wxEmptyString, m_HToolBar->AddTool( ID_CVPCB_CREATE_CONFIGWINDOW, wxEmptyString,
wxBitmap( config_xpm ), wxBitmap( config_xpm ),
_( "Configuration" ) ); _( "Configuration" ) );
m_HToolBar->AddSeparator(); m_HToolBar->AddSeparator();
m_HToolBar->AddTool( ID_CVPCB_CREATE_SCREENCMP, wxEmptyString, m_HToolBar->AddTool( ID_CVPCB_CREATE_SCREENCMP, wxEmptyString,
wxBitmap( show_footprint_xpm ), wxBitmap( show_footprint_xpm ),
_( "View selected footprint" ) ); _( "View selected footprint" ) );
m_HToolBar->AddTool( ID_CVPCB_AUTO_ASSOCIE, wxEmptyString, m_HToolBar->AddTool( ID_CVPCB_AUTO_ASSOCIE, wxEmptyString,
wxBitmap( auto_associe_xpm ), wxBitmap( auto_associe_xpm ),
_( "Perform automatic footprint association" ) ); _( "Perform automatic footprint association" ) );
m_HToolBar->AddSeparator(); m_HToolBar->AddSeparator();
m_HToolBar->AddTool( ID_CVPCB_GOTO_PREVIOUSNA, wxEmptyString, m_HToolBar->AddTool( ID_CVPCB_GOTO_PREVIOUSNA, wxEmptyString,
wxBitmap( left_xpm ), wxBitmap( left_xpm ),
_( "Select previous free component" ) ); _( "Select previous free component" ) );
m_HToolBar->AddTool( ID_CVPCB_GOTO_FIRSTNA, wxEmptyString, m_HToolBar->AddTool( ID_CVPCB_GOTO_FIRSTNA, wxEmptyString,
wxBitmap( right_xpm ), wxBitmap( right_xpm ),
_( "Select next free component" ) ); _( "Select next free component" ) );
m_HToolBar->AddSeparator(); m_HToolBar->AddSeparator();
m_HToolBar->AddTool( ID_CVPCB_DEL_ASSOCIATIONS, wxEmptyString, m_HToolBar->AddTool( ID_CVPCB_DEL_ASSOCIATIONS, wxEmptyString,
wxBitmap( delete_association_xpm ), wxBitmap( delete_association_xpm ),
_( "Delete all associations" ) ); _( "Delete all associations" ) );
m_HToolBar->AddSeparator(); m_HToolBar->AddSeparator();
m_HToolBar->AddTool( ID_CVPCB_CREATE_STUFF_FILE, wxEmptyString, m_HToolBar->AddTool( ID_CVPCB_CREATE_STUFF_FILE, wxEmptyString,
wxBitmap( export_footprint_names_xpm ), wxBitmap( export_footprint_names_xpm ),
_( _( "Create export file (component/footprint list, \
"Create export file (component/footprint list, \ used by eeschema to fill the footprint field of components)" ) );
used by eeschema to fill the footprint field of components)" ) );
m_HToolBar->AddSeparator(); m_HToolBar->AddSeparator();
m_HToolBar->AddTool( ID_PCB_DISPLAY_FOOTPRINT_DOC, wxEmptyString, m_HToolBar->AddTool( ID_PCB_DISPLAY_FOOTPRINT_DOC, wxEmptyString,
wxBitmap( datasheet_xpm ), wxBitmap( datasheet_xpm ),
_( "Display footprints list documentation" ) ); _( "Display footprints list documentation" ) );
m_HToolBar->AddSeparator(); m_HToolBar->AddSeparator();
m_HToolBar->AddSeparator(); m_HToolBar->AddSeparator();
m_HToolBar->AddRadioTool( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST, m_HToolBar->AddRadioTool( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST,
wxEmptyString, wxEmptyString,
wxBitmap( module_filtered_list_xpm ), wxBitmap( module_filtered_list_xpm ),
wxNullBitmap, wxNullBitmap,
_( "Display the filtered footprint list for the current component" ) ); _( "Display the filtered footprint list for the current component" ) );
m_HToolBar->AddRadioTool( ID_CVPCB_FOOTPRINT_DISPLAY_FULL_LIST, m_HToolBar->AddRadioTool( ID_CVPCB_FOOTPRINT_DISPLAY_FULL_LIST,
wxEmptyString, wxBitmap( module_full_list_xpm ), wxEmptyString, wxBitmap( module_full_list_xpm ),
wxNullBitmap, wxNullBitmap,
_( "Display the full footprint list (without filtering)" ) ); _( "Display the full footprint list (without filtering)" ) );
if( config ) 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 ); m_HToolBar->ToggleTool( ID_CVPCB_FOOTPRINT_DISPLAY_FULL_LIST, !opt );
} }
// after adding the buttons to the toolbar, must call Realize() to reflect // after adding the buttons to the toolbar, must call Realize() to reflect the changes
// the changes
m_HToolBar->Realize(); m_HToolBar->Realize();
} }

View File

@ -21,6 +21,7 @@ enum main_id
ID_LOAD_ONE_SHEET, ID_LOAD_ONE_SHEET,
ID_NEW_PROJECT, ID_NEW_PROJECT,
ID_SAVE_PROJECT, ID_SAVE_PROJECT,
ID_SAVE_PROJECT_AS,
ID_SAVE_ONE_SHEET, ID_SAVE_ONE_SHEET,
ID_SAVE_ONE_SHEET_AS, ID_SAVE_ONE_SHEET_AS,
ID_LOAD_FILE, ID_LOAD_FILE,