Commit c64a6937 authored by Wayne Stambaugh's avatar Wayne Stambaugh

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

* Add general purpose user write permission test function to base
  window class.
* Check user write permissions before saving project, schematic and
  library files.
* Remove displaying file dialog every time the project file is saved.
* Display absolute paths for non-root sheet file in title bar.
* Remove redundant command table entry from schematic editor.
* Remove unused variables to fix GCC 4.6 warnings.
* The usual Doxygen comment and coding style policy fixes.
parent 2b453357
......@@ -851,7 +851,7 @@ void D_PAD::Draw3D( Pcb3D_GLCanvas* glcanvas )
dx, dx0, dy, dy0,
delta_cx, delta_cy,
xc, yc;
int angle, delta_angle;
int angle;
double scale;
double zpos;
wxPoint shape_pos;
......@@ -933,14 +933,12 @@ void D_PAD::Draw3D( Pcb3D_GLCanvas* glcanvas )
delta_cx = dx - dy;
delta_cy = 0;
w = m_Size.y * scale;
delta_angle = angle + 900;
}
else /* Vertical ellipse */
{
delta_cx = 0;
delta_cy = dy - dx;
w = m_Size.x * scale;
delta_angle = angle;
}
RotatePoint( &delta_cx, &delta_cy, angle );
{
......
......@@ -291,7 +291,6 @@ double* ReadCoordsList( FILE* file, char* text_buffer, int* bufsize,
char* text;
bool HasData = FALSE;
bool StartData = FALSE;
bool EndData = FALSE;
bool EndNode = FALSE;
char string_num[512];
......@@ -338,7 +337,6 @@ double* ReadCoordsList( FILE* file, char* text_buffer, int* bufsize,
if( *text == ']' )
{
StartData = FALSE;
EndData = TRUE;
}
break;
......
......@@ -445,3 +445,35 @@ void EDA_BASE_FRAME::CopyVersionInfoToClipboard( wxCommandEvent& event )
wxTheClipboard->SetData( new wxTextDataObject( tmp ) );
wxTheClipboard->Close();
}
bool EDA_BASE_FRAME::IsWritable( const wxFileName& aFileName )
{
wxString msg;
wxCHECK_MSG( aFileName.IsOk(), false, wxT( "Invalid file name object. Bad programmer!" ) );
if( aFileName.IsDir() && !aFileName.IsDirWritable() )
{
msg.Printf( _( "You do not have write permissions to folder <%s>." ),
GetChars( aFileName.GetPath() ) );
}
else if( !aFileName.FileExists() && !aFileName.IsDirWritable() )
{
msg.Printf( _( "You do not have write permissions to save file <%s> to folder <%s>." ),
GetChars( aFileName.GetFullName() ), GetChars( aFileName.GetPath() ) );
}
else if( aFileName.FileExists() && !aFileName.IsFileWritable() )
{
msg.Printf( _( "You do not have write permissions to save file <%s>." ),
GetChars( aFileName.GetFullPath() ) );
}
if( !msg.IsEmpty() )
{
DisplayError( this, msg );
return false;
}
return true;
}
......@@ -197,7 +197,7 @@ void DIALOG_EESCHEMA_CONFIG::OnOkClick( wxCommandEvent& event )
LIB_EDIT_FRAME::EnsureActiveLibExists();
}
m_Parent->SaveProjectFile( this, false );
m_Parent->SaveProjectFile();
EndModal( wxID_OK );
}
......
......@@ -79,16 +79,21 @@ void SCH_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
// Window title format:
// [filename sheetpath] (/path/to/filedir)
// Often the /path/to/filedir is blank because of the FullFileName argument
// passed to LoadOneEEFile() which currently omits the path on non-root schematics.
wxFileName t( GetScreen()->GetFileName() );
// Often the /path/to/filedir is blank because of the FullFileName argument
// passed to LoadOneEEFile() which omits the path on non-root schematics.
// Making the path absolute solves this problem.
t.MakeAbsolute();
title = wxChar( '[' );
title << t.GetName() << wxChar( ' ' );
title << m_CurrentSheet->PathHumanReadable() << wxChar( ']' );
title << wxChar( ' ' );
title << wxChar( '(' ) << t.GetPath() << wxChar( ')' );
if( !t.IsFileWritable() )
title << _( " [Read Only]" );
#endif
SetTitle( title );
......
......@@ -59,7 +59,7 @@ void LIB_EDIT_FRAME::Process_Config( wxCommandEvent& event )
switch( id )
{
case ID_CONFIG_SAVE:
schFrame->SaveProjectFile( this, false );
schFrame->SaveProjectFile();
break;
case ID_CONFIG_READ:
......@@ -74,7 +74,7 @@ void LIB_EDIT_FRAME::Process_Config( wxCommandEvent& event )
if( dlg.ShowModal() == wxID_CANCEL )
break;
schFrame->LoadProjectFile( dlg.GetPath(), TRUE );
schFrame->LoadProjectFile( dlg.GetPath(), true );
}
break;
......@@ -127,7 +127,7 @@ void SCH_EDIT_FRAME::Process_Config( wxCommandEvent& event )
switch( id )
{
case ID_CONFIG_SAVE:
SaveProjectFile( this, false );
SaveProjectFile();
break;
case ID_CONFIG_READ:
......@@ -142,7 +142,7 @@ void SCH_EDIT_FRAME::Process_Config( wxCommandEvent& event )
if( dlg.ShowModal() == wxID_CANCEL )
break;
LoadProjectFile( dlg.GetPath(), TRUE );
LoadProjectFile( dlg.GetPath(), true );
}
break;
......@@ -251,15 +251,6 @@ void SCH_EDIT_FRAME::OnSetOptions( wxCommandEvent& event )
}
/**
* Return project file parameter list for EESchema.
*
* Populate the project file parameter array specific to EESchema 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& SCH_EDIT_FRAME::GetProjectFileParameters( void )
{
if( !m_projectFileParams.empty() )
......@@ -344,19 +335,16 @@ PARAM_CFG_ARRAY& SCH_EDIT_FRAME::GetProjectFileParameters( void )
}
/*
* Load the Kicad project file (*.pro) settings specific to EESchema.
*/
bool SCH_EDIT_FRAME::LoadProjectFile( const wxString& CfgFileName, bool ForceRereadConfig )
bool SCH_EDIT_FRAME::LoadProjectFile( const wxString& aFileName, bool aForceReread )
{
wxFileName fn;
bool IsRead = TRUE;
bool IsRead = true;
wxArrayString liblist_tmp = m_ComponentLibFiles;
if( CfgFileName.IsEmpty() )
if( aFileName.IsEmpty() )
fn = g_RootSheet->GetScreen()->GetFileName();
else
fn = CfgFileName;
fn = aFileName;
m_ComponentLibFiles.Clear();
......@@ -368,16 +356,16 @@ bool SCH_EDIT_FRAME::LoadProjectFile( const wxString& CfgFileName, bool ForceRer
if( !wxGetApp().ReadProjectConfig( fn.GetFullPath(), GROUP,
GetProjectFileParameters(),
ForceRereadConfig ? FALSE : TRUE ) )
!aForceReread ) )
{
m_ComponentLibFiles = liblist_tmp;
IsRead = FALSE;
IsRead = false;
}
/* User library path takes precedent over default library search paths. */
wxGetApp().InsertLibraryPath( m_UserLibraryPath, 1 );
/* If the list is void, force loadind the library "power.lib" that is
/* If the list is void, force loading the library "power.lib" that is
* the "standard" library for power symbols.
*/
if( m_ComponentLibFiles.GetCount() == 0 )
......@@ -390,26 +378,17 @@ bool SCH_EDIT_FRAME::LoadProjectFile( const wxString& CfgFileName, bool ForceRer
}
/*
* Save the Kicad project file (*.pro) settings specific to EESchema.
*/
void SCH_EDIT_FRAME::SaveProjectFile( wxWindow* displayframe, bool askoverwrite )
void SCH_EDIT_FRAME::SaveProjectFile()
{
wxFileName fn;
fn = g_RootSheet->GetScreen()->GetFileName(); /*ConfigFileName*/
fn.SetExt( ProjectFileExtension );
int options = wxFD_SAVE;
if( askoverwrite )
options |= wxFD_OVERWRITE_PROMPT;
wxFileDialog dlg( displayframe, _( "Save Project Settings" ), wxGetCwd(),
fn.GetFullName(), ProjectFileWildcard, options );
if( dlg.ShowModal() == wxID_CANCEL )
if( !IsWritable( fn ) )
return;
wxGetApp().WriteProjectConfig( dlg.GetPath(), GROUP, GetProjectFileParameters() );
wxGetApp().WriteProjectConfig( fn.GetFullPath(), GROUP, GetProjectFileParameters() );
}
......@@ -437,22 +416,7 @@ static const wxString FieldNamesEntry( wxT( "FieldNames" ) );
static const wxString SpiceNetNamesEntry( wxT( "SpiceUseNetNames" ) );
static const wxString SimulatorCommandEntry( wxT( "SimCmdLine" ) );
/*
* Return the EESchema applications settings list.
*
* This replaces the old statically define list that had the project
* file settings and the application settings mixed together. This
* was confusing and caused some settings to get saved and loaded
* incorrectly. Currently, only the settings that are needed at start
* up by the main window are defined here. There are other locally used
* settings scattered thoughout the EESchema source code. If you need
* to define a configuration setting that need to be loaded at run time,
* this is the place to define it.
*
* TODO: Define the configuration variables as member variables instead of
* global variables or move them to the object class where they are
* used.
*/
PARAM_CFG_ARRAY& SCH_EDIT_FRAME::GetConfigurationSettings( void )
{
if( !m_configSettings.empty() )
......@@ -545,9 +509,6 @@ PARAM_CFG_ARRAY& SCH_EDIT_FRAME::GetConfigurationSettings( void )
}
/*
* Load the EESchema configuration parameters.
*/
void SCH_EDIT_FRAME::LoadSettings()
{
wxASSERT( wxGetApp().m_EDA_Config != NULL );
......@@ -560,7 +521,7 @@ void SCH_EDIT_FRAME::LoadSettings()
wxGetApp().ReadCurrentSetupValues( GetConfigurationSettings() );
// This is eqired until someone gets rid of the global variable g_LayerDescription().
// This is required until someone gets rid of the global variable g_LayerDescription().
m_GridColor = g_LayerDescr.LayerColor[LAYER_GRID];
g_DrawDefaultLineThickness = cfg->Read( DefaultDrawLineWidthEntry,(long) 6 );
......@@ -644,9 +605,6 @@ void SCH_EDIT_FRAME::LoadSettings()
}
/*
* Save the EESchema configuration parameters.
*/
void SCH_EDIT_FRAME::SaveSettings()
{
wxASSERT( wxGetApp().m_EDA_Config != NULL );
......@@ -718,4 +676,3 @@ void SCH_EDIT_FRAME::SaveSettings()
cfg->Write( FieldNamesEntry, record );
}
......@@ -17,31 +17,28 @@
#include "sch_sheet.h"
/*****************************************************************************
* Routine to save an EESchema file. *
* FileSave controls how the file is to be saved - under what name. *
* Returns true if the file has been saved. *
*****************************************************************************/
bool SCH_EDIT_FRAME::SaveEEFile( SCH_SCREEN* screen, int FileSave )
bool SCH_EDIT_FRAME::SaveEEFile( SCH_SCREEN* aScreen, int aSaveType )
{
wxString msg;
wxFileName schematicFileName, backupFileName;
FILE* f;
if( screen == NULL )
screen = GetScreen();
if( aScreen == NULL )
aScreen = GetScreen();
/* If no name exists in the window yet - save as new. */
if( screen->GetFileName().IsEmpty() )
FileSave = FILE_SAVE_NEW;
if( aScreen->GetFileName().IsEmpty() )
aSaveType = FILE_SAVE_NEW;
switch( FileSave )
switch( aSaveType )
{
case FILE_SAVE_AS:
schematicFileName = screen->GetFileName();
schematicFileName = aScreen->GetFileName();
backupFileName = schematicFileName;
if( !IsWritable( schematicFileName ) )
return false;
/* Rename the old file to a '.bak' one: */
if( schematicFileName.FileExists() )
{
......@@ -50,23 +47,29 @@ bool SCH_EDIT_FRAME::SaveEEFile( SCH_SCREEN* screen, int FileSave )
if( !wxRenameFile( schematicFileName.GetFullPath(), backupFileName.GetFullPath() ) )
{
DisplayError( this, wxT( "Warning: unable to rename old file" ) );
DisplayError( this, _( "Could not save backup of file <" ) +
schematicFileName.GetFullPath() + wxT( ">." ) );
}
}
break;
case FILE_SAVE_NEW:
{
schematicFileName = aScreen->GetFileName();
wxFileDialog dlg( this, _( "Schematic Files" ), wxGetCwd(),
screen->GetFileName(), SchematicFileWildcard,
schematicFileName.GetFullName(), SchematicFileWildcard,
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
if( dlg.ShowModal() == wxID_CANCEL )
return false;
screen->SetFileName( dlg.GetPath() );
aScreen->SetFileName( dlg.GetPath() );
schematicFileName = dlg.GetPath();
if( !IsWritable( schematicFileName ) )
return false;
break;
}
......@@ -81,19 +84,21 @@ bool SCH_EDIT_FRAME::SaveEEFile( SCH_SCREEN* screen, int FileSave )
return false;
}
if( FileSave == FILE_SAVE_NEW )
screen->SetFileName( schematicFileName.GetFullPath() );
if( aSaveType == FILE_SAVE_NEW )
aScreen->SetFileName( schematicFileName.GetFullPath() );
bool success = screen->Save( f );
bool success = aScreen->Save( f );
if( !success )
{
DisplayError( this, _( "File write operation failed." ) );
}
else
{
screen->ClrModify();
aScreen->ClrModify();
wxString msg;
msg.Printf( wxT("File %s saved"), GetChars(screen->GetFileName() ) );
SetStatusText(msg, 0);
msg.Printf( _( "File %s saved" ), GetChars( aScreen->GetFileName() ) );
SetStatusText( msg, 0 );
}
......@@ -103,18 +108,12 @@ bool SCH_EDIT_FRAME::SaveEEFile( SCH_SCREEN* screen, int FileSave )
}
/* Commands to save project or the current page.
*/
void SCH_EDIT_FRAME::Save_File( wxCommandEvent& event )
{
int id = event.GetId();
switch( id )
{
case ID_SAVE_PROJECT: /* Update Schematic File */
SaveProject();
break;
case ID_SAVE_ONE_SHEET: /* Update Schematic File */
SaveEEFile( NULL, FILE_SAVE_AS );
break;
......@@ -130,13 +129,7 @@ void SCH_EDIT_FRAME::Save_File( wxCommandEvent& event )
}
/**
* Load an entire project
*
* Schematic root file and its subhierarchies, the configuration and the libs
* which are not already loaded)
*/
bool SCH_EDIT_FRAME::LoadOneEEProject( const wxString& FileName, bool IsNew )
bool SCH_EDIT_FRAME::LoadOneEEProject( const wxString& aFileName, bool aIsNew )
{
SCH_SCREEN* screen;
wxString FullFileName, msg;
......@@ -155,9 +148,9 @@ bool SCH_EDIT_FRAME::LoadOneEEProject( const wxString& FileName, bool IsNew )
return false;
}
FullFileName = FileName;
FullFileName = aFileName;
if( ( FullFileName.IsEmpty() ) && !IsNew )
if( ( FullFileName.IsEmpty() ) && !aIsNew )
{
wxFileDialog dlg( this, _( "Open Schematic" ), wxGetCwd(),
wxEmptyString, SchematicFileWildcard,
......@@ -184,6 +177,7 @@ bool SCH_EDIT_FRAME::LoadOneEEProject( const wxString& FileName, bool IsNew )
fn.MakeAbsolute();
FullFileName = fn.GetFullPath();
}
wxLogDebug( wxT( "Loading schematic " ) + FullFileName );
wxSetWorkingDirectory( fn.GetPath() );
......@@ -196,7 +190,7 @@ bool SCH_EDIT_FRAME::LoadOneEEProject( const wxString& FileName, bool IsNew )
screen->ClrModify();
if( IsNew )
if( aIsNew )
{
screen->m_CurrentSheetDesc = &g_Sheet_A4;
screen->SetZoom( 32 );
......@@ -263,6 +257,7 @@ bool SCH_EDIT_FRAME::LoadOneEEProject( const wxString& FileName, bool IsNew )
{
LibCache->SetCache();
msg += wxT( " OK" );
if ( use_oldcachename ) // set the new name
{
fn.SetName( cachename );
......@@ -312,28 +307,27 @@ bool SCH_EDIT_FRAME::LoadOneEEProject( const wxString& FileName, bool IsNew )
}
/**
* Save the entire project and create an archive for components.
*
* The library archive name is &ltroot_name&gt-cache.lib
*/
void SCH_EDIT_FRAME::SaveProject()
void SCH_EDIT_FRAME::OnSaveProject( wxCommandEvent& aEvent )
{
SCH_SCREEN* screen;
wxFileName fn;
wxFileName tmp;
SCH_SCREENS ScreenList;
fn = g_RootSheet->GetFileName();
tmp.AssignDir( fn.GetPath() );
if( !IsWritable( tmp ) )
return;
for( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() )
{
D( printf( "SaveEEFile, %s\n", TO_UTF8( screen->GetFileName() ) ); )
SaveEEFile( screen, FILE_SAVE_AS );
}
/* Archive components in current directory. */
fn = g_RootSheet->GetFileName();
wxString cachename = fn.GetName() + wxT( "-cache" );
fn.SetName( cachename );
fn.SetExt( CompLibFileExtension );
LibArchive( this, fn.GetFullPath() );
}
......@@ -286,13 +286,8 @@ void LIB_EDIT_FRAME::SaveActiveLibrary( wxCommandEvent& event )
}
// Verify the user has write privileges before attempting to save the library file.
if( !fn.IsDirWritable() )
{
DisplayError( this,
wxString::Format( _( "You do not have permission to write to file <%s>." ),
GetChars( fn.GetFullPath() ) ) );
if( !IsWritable( fn ) )
return;
}
bool success = m_library->Save( fn.GetFullPath(), true );
......
......@@ -318,7 +318,7 @@ private:
*
* @param aLibEntry A pointer to the LIB_ALIAS object to load.
* @param aLibrary A pointer to the CMP_LIBRARY object to load \a aLibEntry from.
* @returns True if a copy of \aLibEntry was successfully loaded from \aLibrary.
* @returns True if a copy of \a aLibEntry was successfully loaded from \aLibrary.
*/
bool LoadOneLibraryPartAux( LIB_ALIAS* aLibEntry, CMP_LIBRARY* aLibrary );
......
......@@ -27,11 +27,7 @@ bool ReadSchemaDescr( LINE_READER* aLine, wxString& aMsgDiag, BASE_SCREEN* Windo
static void LoadLayers( LINE_READER* aLine );
/**
* Routine to load an EESchema file.
* Returns true if file has been loaded (at least partially.)
*/
bool SCH_EDIT_FRAME::LoadOneEEFile( SCH_SCREEN* screen, const wxString& FullFileName )
bool SCH_EDIT_FRAME::LoadOneEEFile( SCH_SCREEN* aScreen, const wxString& aFullFileName )
{
char Name1[256];
bool itemLoaded = false;
......@@ -41,35 +37,35 @@ bool SCH_EDIT_FRAME::LoadOneEEFile( SCH_SCREEN* screen, const wxString& FullFile
wxString MsgDiag; // Error and log messages
char* line;
if( screen == NULL )
if( aScreen == NULL )
return FALSE;
if( FullFileName.IsEmpty() )
if( aFullFileName.IsEmpty() )
return FALSE;
screen->SetCurItem( NULL );
screen->SetFileName( FullFileName );
aScreen->SetCurItem( NULL );
aScreen->SetFileName( aFullFileName );
// D(printf("LoadOneEEFile:%s\n", TO_UTF8( FullFileName ) ); )
// D(printf("LoadOneEEFile:%s\n", TO_UTF8( aFullFileName ) ); )
FILE* f;
if( ( f = wxFopen( FullFileName, wxT( "rt" ) ) ) == NULL )
if( ( f = wxFopen( aFullFileName, wxT( "rt" ) ) ) == NULL )
{
MsgDiag = _( "Failed to open " ) + FullFileName;
MsgDiag = _( "Failed to open " ) + aFullFileName;
DisplayError( this, MsgDiag );
return FALSE;
}
// reader now owns the open FILE.
FILE_LINE_READER reader( f, FullFileName );
FILE_LINE_READER reader( f, aFullFileName );
MsgDiag = _( "Loading " ) + screen->GetFileName();
MsgDiag = _( "Loading " ) + aScreen->GetFileName();
PrintMsg( MsgDiag );
if( !reader.ReadLine()
|| strncmp( (char*)reader + 9, SCHEMATIC_HEAD_STRING, sizeof(SCHEMATIC_HEAD_STRING) - 1 ) != 0 )
{
MsgDiag = FullFileName + _( " is NOT an EESchema file!" );
MsgDiag = aFullFileName + _( " is NOT an EESchema file!" );
DisplayError( this, MsgDiag );
return FALSE;
}
......@@ -87,7 +83,7 @@ bool SCH_EDIT_FRAME::LoadOneEEFile( SCH_SCREEN* screen, const wxString& FullFile
if( version > EESCHEMA_VERSION )
{
MsgDiag = FullFileName + _( " was created by a more recent \
MsgDiag = aFullFileName + _( " was created by a more recent \
version of EESchema and may not load correctly. Please consider updating!" );
DisplayInfoMessage( this, MsgDiag );
}
......@@ -96,7 +92,7 @@ version of EESchema and may not load correctly. Please consider updating!" );
// Compile it if the new version is unreadable by previous eeschema versions
else if( version < EESCHEMA_VERSION )
{
MsgDiag = FullFileName + _( " was created by an older version of \
MsgDiag = aFullFileName + _( " was created by an older version of \
EESchema. It will be stored in the new file format when you save this file \
again." );
......@@ -106,7 +102,7 @@ again." );
if( !reader.ReadLine() || strncmp( reader, "LIBS:", 5 ) != 0 )
{
MsgDiag = FullFileName + _( " is NOT an EESchema file!" );
MsgDiag = aFullFileName + _( " is NOT an EESchema file!" );
DisplayError( this, MsgDiag );
return FALSE;
}
......@@ -131,7 +127,7 @@ again." );
else if( line[1] == 'S' )
item = new SCH_SHEET();
else if( line[1] == 'D' )
itemLoaded = ReadSchemaDescr( &reader, MsgDiag, screen );
itemLoaded = ReadSchemaDescr( &reader, MsgDiag, aScreen );
break;
case 'L': // Its a library item.
......@@ -197,8 +193,8 @@ again." );
}
else
{
item->SetNext( screen->GetDrawItems() );
screen->SetDrawItems( item );
item->SetNext( aScreen->GetDrawItems() );
aScreen->SetDrawItems( item );
}
}
......@@ -212,23 +208,23 @@ again." );
/* GetDrawItems() was constructed in reverse order - reverse it back: */
Phead = NULL;
while( screen->GetDrawItems() )
while( aScreen->GetDrawItems() )
{
Pnext = screen->GetDrawItems();
screen->SetDrawItems( screen->GetDrawItems()->Next() );
Pnext = aScreen->GetDrawItems();
aScreen->SetDrawItems( aScreen->GetDrawItems()->Next() );
Pnext->SetNext( Phead );
Phead = Pnext;
}
screen->SetDrawItems( Phead );
aScreen->SetDrawItems( Phead );
#if 0 && defined (DEBUG)
screen->Show( 0, std::cout );
aScreen->Show( 0, std::cout );
#endif
screen->TestDanglingEnds();
aScreen->TestDanglingEnds();
MsgDiag = _( "Done Loading " ) + screen->GetFileName();
MsgDiag = _( "Done Loading " ) + aScreen->GetFileName();
PrintMsg( MsgDiag );
return true; // Although it may be that file is only partially loaded.
......
......@@ -55,10 +55,9 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
EVT_TOOL( ID_NEW_PROJECT, SCH_EDIT_FRAME::OnNewProject )
EVT_TOOL( ID_LOAD_PROJECT, SCH_EDIT_FRAME::OnLoadProject )
EVT_MENU( ID_SAVE_PROJECT, SCH_EDIT_FRAME::Save_File )
EVT_MENU( ID_SAVE_PROJECT, SCH_EDIT_FRAME::OnSaveProject )
EVT_MENU( ID_SAVE_ONE_SHEET, SCH_EDIT_FRAME::Save_File )
EVT_MENU( ID_SAVE_ONE_SHEET_AS, SCH_EDIT_FRAME::Save_File )
EVT_TOOL( ID_SAVE_PROJECT, SCH_EDIT_FRAME::Save_File )
EVT_MENU( ID_GEN_PLOT_PS, SCH_EDIT_FRAME::ToPlot_PS )
EVT_MENU( ID_GEN_PLOT_HPGL, SCH_EDIT_FRAME::ToPlot_HPGL )
EVT_MENU( ID_GEN_PLOT_SVG, SCH_EDIT_FRAME::SVG_Print )
......@@ -385,7 +384,7 @@ void SCH_EDIT_FRAME::SaveUndoItemInUndoList( SCH_ITEM* aItem )
}
void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent )
{
if( m_LibeditFrame && !m_LibeditFrame->Close() ) // Can close component editor?
return;
......@@ -405,7 +404,7 @@ void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
switch( dialog.ShowModal() )
{
case wxID_CANCEL:
Event.Veto();
aEvent.Veto();
return;
case wxID_NO:
......@@ -413,7 +412,8 @@ void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
case wxID_OK:
case wxID_YES:
SaveProject();
wxCommandEvent tmp( ID_SAVE_PROJECT );
OnSaveProject( tmp );
break;
}
}
......
......@@ -26,7 +26,7 @@ private:
* The only constructor allowing direct input of numeric value
* in internal units. As this is not allowed in public, it's private.
* Length objects elsewhere are created indirectly
* @param unit Length in internal units.
* @param units Length in internal units.
*/
LENGTH( int units )
{
......
......@@ -142,9 +142,35 @@ public:
void GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 );
/**
* Function GetProjectFileParameters
* returns the project file parameter list for EESchema.
*
*<p?
* Populate the project file parameter array specific to EESchema 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 required global variable definitions.
* </p>
*/
PARAM_CFG_ARRAY& GetProjectFileParameters( void );
void SaveProjectFile( wxWindow* displayframe, bool askoverwrite = true );
bool LoadProjectFile( const wxString& CfgFileName, bool ForceRereadConfig );
/**
* Function SaveProjectFile
* saves changes to the project settings to the project (.pro) file.
*/
void SaveProjectFile();
/**
* Function LoadProjectFile
* soads the Kicad project file (*.pro) settings specific to EESchema.
*
* @param aFileName The project file name to load.
* @param aForceReread Force the project file to be reread if true.
* @return True if the project file was loaded correctly.
*/
bool LoadProjectFile( const wxString& aFileName, bool aForceReread );
/**
* Function GetDefaultFieldName
......@@ -190,8 +216,20 @@ public:
m_TemplateFieldNames.DeleteAllTemplateFieldNames();
}
/**
* Function GetConfigurationSettings
* returns the EESchema applications settings.
* <p>
* This replaces the old statically define list that had the project file settings and
* the application settings mixed together. This was confusing and caused some settings
* to get saved and loaded incorrectly. Currently, only the settings that are needed at
* start up by the main window are defined here. There are other locally used settings
* scattered throughout the EESchema source code. If you need to define a configuration
* setting that need to be loaded at run time, this is the place to define it.
* </p>
*/
PARAM_CFG_ARRAY& GetConfigurationSettings( void );
void LoadSettings();
void SaveSettings();
......@@ -443,9 +481,42 @@ public:
// read and save files
void Save_File( wxCommandEvent& event );
void SaveProject();
bool LoadOneEEProject( const wxString& FileName, bool IsNew );
bool LoadOneEEFile( SCH_SCREEN* screen, const wxString& FullFileName );
/**
* Function OnSaveProject
* is the command event handler to save the entire project and create a component library
* archive.
*
* The component library archive name is &ltroot_name&gt-cache.lib
*/
void OnSaveProject( wxCommandEvent& aEvent );
/**
* Function LoadOneEEProject
* load an entire project into the schematic editor.
*
* This function loads schematic root file and it's subhierarchies, the project
* configuration, and the component libraries which are not already loaded.
*
* @param aFileName The full path an file name to load.
* @param aIsNew True indicates that this is a new project and the default project
* template is loaded.
* @return True if the project loaded properly.
*/
bool LoadOneEEProject( const wxString& aFileName, bool aIsNew );
/**
* Function LoadOneEEFile
* loads the schematic (.sch) file \a aFullFileName into \a aScreen.
*
* @param aScreen Pointer to the associated SCH_SCREEN object in which to load
* \a aFullFileName.
* @param aFullFileName A reference to a wxString object containing the absolute path
* and file name to load.
* @return True if \a aFullFileName has been loaded (at least partially.)
*/
bool LoadOneEEFile( SCH_SCREEN* aScreen, const wxString& aFullFileName );
bool ReadInputStuffFile();
/**
......@@ -466,7 +537,16 @@ public:
*/
bool ProcessStuffFile( FILE* aFilename, bool aSetFieldsAttributeToVisible );
bool SaveEEFile( SCH_SCREEN* screen, int FileSave );
/**
* Function SaveEEFile
* saves \a aScreen to a schematic file.
*
* @param aScreen A pointer to the SCH_SCREEN object to save. A NULL pointer saves
* the current screen.
* @param aSaveType Controls how the file is to be saved.
* @return True if the file has been saved.
*/
bool SaveEEFile( SCH_SCREEN* aScreen, int aSaveType );
// General search:
......
......@@ -223,6 +223,20 @@ public:
* Needed when the language is changed
*/
virtual void ReCreateMenuBar();
/**
* Function IsWritable
* checks if \a aFileName can be written.
* <p>
* The function performs a number of tests on \a aFileName to verify that it can
* be saved. The file name is tested for validity and if the user has write
* permissions.
* </p>
*
* @param aFileName The full path and/or file name of the file to test.
* @return False if \a aFileName cannot be written.
*/
bool IsWritable( const wxFileName& aFileName );
};
......
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