本文整理汇总了C++中PART_LIB::Save方法的典型用法代码示例。如果您正苦于以下问题:C++ PART_LIB::Save方法的具体用法?C++ PART_LIB::Save怎么用?C++ PART_LIB::Save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PART_LIB
的用法示例。
在下文中一共展示了PART_LIB::Save方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SaveActiveLibrary
bool LIB_EDIT_FRAME::SaveActiveLibrary( bool newFile )
{
wxFileName fn;
wxString msg;
m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor() );
PART_LIB* lib = GetCurLib();
// Just in case the library hasn't been cached yet.
lib->GetCount();
if( !lib )
{
DisplayError( this, _( "No library specified." ) );
return false;
}
wxString oldFileName = lib->GetFullFileName();
if( GetScreen()->IsModify() )
{
if( IsOK( this, _( "Include last component changes?" ) ) )
{
lib->EnableBuffering();
try
{
SaveOnePart( lib, false );
}
catch( ... )
{
lib->EnableBuffering( false );
msg.Printf( _( "Unexpected error occured saving part to '%s' symbol library." ),
lib->GetName() );
DisplayError( this, msg );
return false;
}
lib->EnableBuffering( false );
}
}
if( newFile )
{
PROJECT& prj = Prj();
SEARCH_STACK* search = prj.SchSearchS();
// Get a new name for the library
wxString default_path = prj.GetRString( PROJECT::SCH_LIB_PATH );
if( !default_path )
default_path = search->LastVisitedPath();
wxFileDialog dlg( this, _( "Part Library Name:" ), default_path,
wxEmptyString, SchematicLibraryFileWildcard,
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
if( dlg.ShowModal() == wxID_CANCEL )
return false;
fn = dlg.GetPath();
// The GTK file chooser doesn't return the file extension added to
// file name so add it here.
if( fn.GetExt().IsEmpty() )
fn.SetExt( SchematicLibraryFileExtension );
prj.SetRString( PROJECT::SCH_LIB_PATH, fn.GetPath() );
}
else
{
fn = wxFileName( lib->GetFullFileName() );
msg.Printf( _( "Modify library file '%s' ?" ), GetChars( fn.GetFullPath() ) );
if( !IsOK( this, msg ) )
return false;
}
// Verify the user has write privileges before attempting to save the library file.
if( !IsWritable( fn ) )
return false;
ClearMsgPanel();
wxFileName libFileName = fn;
wxFileName backupFileName = fn;
// Rename the old .lib file to .bak.
if( libFileName.FileExists() )
{
backupFileName.SetExt( "bak" );
if( backupFileName.FileExists() )
wxRemoveFile( backupFileName.GetFullPath() );
if( !wxRenameFile( libFileName.GetFullPath(), backupFileName.GetFullPath() ) )
{
libFileName.MakeAbsolute();
//.........这里部分代码省略.........