Commit 0cdcd78b authored by charras's avatar charras

doc update.

parent 8c61ac42
...@@ -277,14 +277,23 @@ void* MyMalloc( size_t nb_octets ) ...@@ -277,14 +277,23 @@ void* MyMalloc( size_t nb_octets )
} }
/**************************************************************/
bool ProcessExecute( const wxString& aCommandLine, int aFlags ) bool ProcessExecute( const wxString& aCommandLine, int aFlags )
/**************************************************************/
/**
* Function ProcessExecute
* runs a child process.
* @param aCommandLine The process and any arguments to it all in a single string.
* @param aFlags The same args as allowed for wxExecute()
* @return bool - true if success, else false
*/
{ {
#ifdef __WINDOWS__ #ifdef __WINDOWS__
wxExecute(aCommandLine); int pid = wxExecute(aCommandLine);
return true; return pid ? true : false;
#else #else
wxProcess* process = wxProcess::Open( aCommandLine, aFlags ); wxProcess* process = wxProcess::Open( aCommandLine, aFlags );
return process != NULL; return (process != NULL) ? true : false;
#endif #endif
} }
......
...@@ -54,27 +54,21 @@ void WinEDA_App::WritePdfBrowserInfos() ...@@ -54,27 +54,21 @@ void WinEDA_App::WritePdfBrowserInfos()
} }
// Mime type extensions // Mime type extensions (PDF files are not considered here)
static wxMimeTypesManager* mimeDatabase; static wxMimeTypesManager* mimeDatabase;
static const wxFileTypeInfo EDAfallbacks[] = static const wxFileTypeInfo EDAfallbacks[] =
{ {
wxFileTypeInfo( wxT( "text/pdf" ),
wxT( "xpdf %s" ),
wxT( "xpdf -p %s" ),
wxT( "pdf document (from Kicad)" ),
wxT( "pdf" ), wxT( "PDF" ), NULL ),
wxFileTypeInfo( wxT( "text/html" ), wxFileTypeInfo( wxT( "text/html" ),
wxT( "wxhtml %s" ), wxT( "wxhtml %s" ),
wxT( "wxhtml %s" ), wxT( "wxhtml %s" ),
wxT( "html document (from Kicad)" ), wxT( "html document (from Kicad)" ),
wxT( "htm" ), wxT( "html" ), NULL ), wxT( "htm" ), wxT( "html" ),NULL ),
wxFileTypeInfo( wxT( "application/sch" ), wxFileTypeInfo( wxT( "application/sch" ),
wxT( "eeschema %s" ), wxT( "eeschema %s" ),
wxT( "eeschema -p %s" ), wxT( "eeschema -p %s" ),
wxT( "sch document (from Kicad)" ), wxT( "sch document (from Kicad)" ),
wxT( "sch" ), wxT( "SCH" ), NULL ), wxT( "sch" ), wxT( "SCH" ), NULL ),
// must terminate the table with this! // must terminate the table with this!
wxFileTypeInfo() wxFileTypeInfo()
...@@ -87,15 +81,15 @@ bool GetAssociatedDocument( wxFrame* frame, const wxString& LibPath, ...@@ -87,15 +81,15 @@ bool GetAssociatedDocument( wxFrame* frame, const wxString& LibPath,
/*********************************************************************/ /*********************************************************************/
/* Launch the viewer for the doc file DocName (mime type) /* Launch the viewer for the doc file DocName (mime type)
* LibPath is the doc file search path: * LibPath is the doc file search path:
* (kicad/library) * (kicad/library)
* DocName is the short filename with ext. Wildcarts are allowed * DocName is the short filename with ext. Wildcarts are allowed
* Seach file is made in LibPath/doc/DocName * Seach file is made in LibPath/doc/DocName
* *
* if DocName is starting by http: or ftp: or www. the default internet browser is launched * if DocName is starting by http: or ftp: or www. the default internet browser is launched
*/ */
{ {
wxString docpath, fullfilename; wxString docpath, fullfilename, file_ext;
wxString Line; wxString Line;
wxString command; wxString command;
bool success = FALSE; bool success = FALSE;
...@@ -146,7 +140,7 @@ bool GetAssociatedDocument( wxFrame* frame, const wxString& LibPath, ...@@ -146,7 +140,7 @@ bool GetAssociatedDocument( wxFrame* frame, const wxString& LibPath,
wxFD_OPEN, /* wxSAVE, wxFD_OPEN ..*/ wxFD_OPEN, /* wxSAVE, wxFD_OPEN ..*/
TRUE, /* true = ne change pas le repertoire courant */ TRUE, /* true = ne change pas le repertoire courant */
wxPoint( -1, -1 ) wxPoint( -1, -1 )
); );
if( fullfilename.IsEmpty() ) if( fullfilename.IsEmpty() )
return FALSE; return FALSE;
} }
...@@ -158,83 +152,46 @@ bool GetAssociatedDocument( wxFrame* frame, const wxString& LibPath, ...@@ -158,83 +152,46 @@ bool GetAssociatedDocument( wxFrame* frame, const wxString& LibPath,
return FALSE; return FALSE;
} }
/* Try to launch some browser (usefull under linux) */ wxFileName CurrentFileName( fullfilename );
g_EDA_Appl->ReadPdfBrowserInfos(); file_ext = CurrentFileName.GetExt();
if( g_EDA_Appl->m_PdfBrowserIsDefault )
if( file_ext == wxT( "pdf" ) )
{ {
wxFileType* filetype; success = OpenPDF( fullfilename );
wxFileName CurrentFileName( fullfilename ); return success;
}
wxString ext, type;
ext = CurrentFileName.GetExt();
filetype = wxTheMimeTypesManager->GetFileTypeFromExtension( ext );
if( !filetype ) // 2ieme tentative /* Try to launch some browser (usefull under linux) */
{ wxFileType* filetype;
mimeDatabase = new wxMimeTypesManager;
mimeDatabase->AddFallbacks( EDAfallbacks );
filetype = mimeDatabase->GetFileTypeFromExtension( ext );
delete mimeDatabase;
mimeDatabase = NULL;
}
if( filetype ) wxString type;
{ filetype = wxTheMimeTypesManager->GetFileTypeFromExtension( file_ext );
wxFileType::MessageParameters params( fullfilename, type );
success = filetype->GetOpenCommand( &command, params ); if( !filetype ) // 2ieme tentative
delete filetype; {
if( success ) mimeDatabase = new wxMimeTypesManager;
ProcessExecute( command ); mimeDatabase->AddFallbacks( EDAfallbacks );
} filetype = mimeDatabase->GetFileTypeFromExtension( file_ext );
delete mimeDatabase;
mimeDatabase = NULL;
}
if( !success ) if( filetype )
{ {
#ifdef __LINUX__ wxFileType::MessageParameters params( fullfilename, type );
if( ext == wxT( "pdf" ) )
{ success = filetype->GetOpenCommand( &command, params );
success = TRUE; command.Empty(); delete filetype;
if( wxFileExists( wxT( "/usr/bin/kpdf" ) ) ) if( success )
command = wxT( "kpdf " ) + fullfilename; success = ProcessExecute( command );
else if( wxFileExists( wxT( "/usr/bin/konqueror" ) ) )
command = wxT( "konqueror " ) + fullfilename;
else if( wxFileExists( wxT( "/usr/bin/gpdf" ) ) )
command = wxT( "gpdf " ) + fullfilename;
if( wxFileExists( wxT( "/usr/bin/xpdf" ) ) )
command = wxT( "xpdf " ) + fullfilename;
if( command.IsEmpty() ) // not started
{
DisplayError( frame,
_( " Cannot find the PDF viewer (kpdf, gpdf, konqueror or xpdf) in /usr/bin/" ) );
success = FALSE;
}
else
ProcessExecute( command );
}
else
#endif
{
Line.Printf( _( "Unknown MIME type for Doc File [%s] (%s)" ),
fullfilename.GetData(), ext.GetData() );
DisplayError( frame, Line );
}
}
} }
else
if( !success )
{ {
command = g_EDA_Appl->m_PdfBrowser; Line.Printf( _( "Unknown MIME type for Doc File [%s]" ),
if( wxFileExists( command ) ) fullfilename.GetData() );
{ DisplayError( frame, Line );
success = TRUE;
AddDelimiterString( fullfilename );
command += wxT( " " ) + fullfilename;
ProcessExecute( command );
}
else
{
Line.Printf( _( "Cannot find Pdf viewer %s" ), command.GetData() );
DisplayError( frame, Line );
}
} }
return success; return success;
...@@ -246,11 +203,11 @@ int KeyWordOk( const wxString& KeyList, const wxString& Database ) ...@@ -246,11 +203,11 @@ int KeyWordOk( const wxString& KeyList, const wxString& Database )
/******************************************************************/ /******************************************************************/
/* Recherche si dans le texte Database on retrouve tous les mots /* Recherche si dans le texte Database on retrouve tous les mots
* cles donnes dans KeyList ( KeyList = suite de mots cles * cles donnes dans KeyList ( KeyList = suite de mots cles
* separes par des espaces * separes par des espaces
* Retourne: * Retourne:
* 0 si aucun mot cle trouv * 0 si aucun mot cle trouv
* 1 si mot cle trouv * 1 si mot cle trouv
*/ */
{ {
wxString KeysCopy, DataList; wxString KeysCopy, DataList;
...@@ -265,7 +222,7 @@ int KeyWordOk( const wxString& KeyList, const wxString& Database ) ...@@ -265,7 +222,7 @@ int KeyWordOk( const wxString& KeyList, const wxString& Database )
while( Token.HasMoreTokens() ) while( Token.HasMoreTokens() )
{ {
wxString Key = Token.GetNextToken(); wxString Key = Token.GetNextToken();
// Search Key in Datalist: // Search Key in Datalist:
wxStringTokenizer Data( DataList, wxT( " \n\r" ) ); wxStringTokenizer Data( DataList, wxT( " \n\r" ) );
...@@ -274,7 +231,7 @@ int KeyWordOk( const wxString& KeyList, const wxString& Database ) ...@@ -274,7 +231,7 @@ int KeyWordOk( const wxString& KeyList, const wxString& Database )
{ {
wxString word = Data.GetNextToken(); wxString word = Data.GetNextToken();
if( word == Key ) if( word == Key )
return 1; // Key found ! return 1; // Key found !
} }
} }
......
...@@ -74,8 +74,8 @@ static wxString s_HelpPathList[] = { ...@@ -74,8 +74,8 @@ static wxString s_HelpPathList[] = {
#else #else
wxT( "/usr/share/doc/kicad/help/" ), wxT( "/usr/share/doc/kicad/help/" ),
wxT( "/usr/local/share/doc/kicad/help/" ), wxT( "/usr/local/share/doc/kicad/help/" ),
wxT( "/usr/local/kicad/doc/" ), // default install for "universal tarballs" and build for a server (new) wxT( "/usr/local/kicad/doc/help/" ), // default install for "universal tarballs" and build for a server (new)
// wxT( "/usr/local/kicad/" ), // default install for "universal tarballs" and build for a server (old) wxT( "/usr/local/kicad/help/" ), // default install for "universal tarballs" and build for a server (old)
#endif #endif
wxT( "end_list" ) // End of list symbol, do not change wxT( "end_list" ) // End of list symbol, do not change
}; };
...@@ -701,64 +701,101 @@ wxString GetEditorName() ...@@ -701,64 +701,101 @@ wxString GetEditorName()
return g_EditorName; return g_EditorName;
} }
/***********************************/
void OpenPDF( const wxString& file ) bool OpenPDF( const wxString& file )
/***********************************/
/** Function OpenPDF
* run the PDF viewer and display a PDF file
* @param file = PDF file to open
* @return true is success, false if no PDF viewer found
*/
{ {
wxString command; wxString command;
wxString filename = file; wxString filename = file;
wxString type; wxString type;
bool success = false;
g_EDA_Appl->ReadPdfBrowserInfos(); g_EDA_Appl->ReadPdfBrowserInfos();
if( !g_EDA_Appl->m_PdfBrowserIsDefault ) if( !g_EDA_Appl->m_PdfBrowserIsDefault ) // Run the prefered PDF Browser
{ {
AddDelimiterString( filename ); AddDelimiterString( filename );
command = g_EDA_Appl->m_PdfBrowser + filename; command = g_EDA_Appl->m_PdfBrowser + wxT( " " ) + filename;
} }
else else
{ {
bool success = false;
wxFileType* filetype = NULL; wxFileType* filetype = NULL;
wxFileType::MessageParameters params( filename, type ); wxFileType::MessageParameters params( filename, type );
filetype = wxTheMimeTypesManager->GetFileTypeFromExtension( wxT( "pdf" ) );
filetype = wxTheMimeTypesManager->GetFileTypeFromExtension( wxT( ".pdf" ) );
if( filetype ) if( filetype )
success = filetype->GetOpenCommand( &command, params ); success = filetype->GetOpenCommand( &command, params );
delete filetype; delete filetype;
#ifndef __WINDOWS__
// Bug ? under linux wxWidgets returns acroread as PDF viewer,even it not exists
if ( command.StartsWith(wxT("acroread")) ) // Workaround
success = false;
#endif
if( success && !command.IsEmpty() )
{
success = ProcessExecute( command );
}
else
success = false;
if( !success ) if( !success )
{ {
AddDelimiterString( filename );
command.Empty(); command.Empty();
#ifndef __WINDOWS__
AddDelimiterString( filename );
/* here is a list of PDF viewers candidates */
const static wxString tries[] = const static wxString tries[] =
{ {
wxT( "/usr/bin/evince" ), wxT( "/usr/bin/evince" ),
wxT( "/usr/bin/xpdf" ),
wxT( "/usr/bin/konqueror" ),
wxT( "/usr/bin/gpdf" ), wxT( "/usr/bin/gpdf" ),
wxT( "/usr/bin/konqueror" ),
wxT( "/usr/bin/kpdf" ),
wxT( "/usr/bin/xpdf" ),
wxT( "" ), wxT( "" ),
}; };
for( int i = 0; ; i++ ) for( int ii = 0; ; ii++ )
{ {
if( tries[i].IsEmpty() ) if( tries[ii].IsEmpty() )
break; break;
if( wxFileExists( tries[i] ) ) if( wxFileExists( tries[ii] ) )
{ {
command = tries[i] + wxT( " " ) + filename; command = tries[ii] + wxT( " " ) + filename;
break;
} }
} }
#endif
} }
} }
if( !command.IsEmpty() ) if( !command.IsEmpty() )
ProcessExecute( command ); {
} success = ProcessExecute( command );
if ( !success )
{
wxString msg = _("Problem while running the PDF viewer");
msg << wxT("\n command is") << command;
DisplayError( NULL, msg );
}
}
else
{
wxString msg = _("Unable to find a PDF viewer for");
msg << wxT(" ") << filename;
DisplayError( NULL, msg );
success = false;
}
return success;
}
/*************************************/
void OpenFile( const wxString& file ) void OpenFile( const wxString& file )
/*************************************/
{ {
wxString command; wxString command;
wxString filename = file; wxString filename = file;
......
...@@ -309,7 +309,7 @@ void WinEDA_BasePcbFrame::Block_Move( wxDC* DC ) ...@@ -309,7 +309,7 @@ void WinEDA_BasePcbFrame::Block_Move( wxDC* DC )
* Function to move items in the current selected block * Function to move items in the current selected block
*/ */
{ {
int deltaX, deltaY; wxPoint delta;
wxPoint oldpos; wxPoint oldpos;
oldpos = GetScreen()->m_Curseur; oldpos = GetScreen()->m_Curseur;
...@@ -321,8 +321,7 @@ void WinEDA_BasePcbFrame::Block_Move( wxDC* DC ) ...@@ -321,8 +321,7 @@ void WinEDA_BasePcbFrame::Block_Move( wxDC* DC )
GetScreen()->BlockLocate.Normalize(); GetScreen()->BlockLocate.Normalize();
/* calcul du vecteur de deplacement pour les deplacements suivants */ /* calcul du vecteur de deplacement pour les deplacements suivants */
deltaX = GetScreen()->BlockLocate.m_MoveVector.x; delta = GetScreen()->BlockLocate.m_MoveVector;
deltaY = GetScreen()->BlockLocate.m_MoveVector.y;
/* Move the Track segments in block */ /* Move the Track segments in block */
TRACK* track = m_Pcb->m_Track; TRACK* track = m_Pcb->m_Track;
...@@ -332,9 +331,13 @@ void WinEDA_BasePcbFrame::Block_Move( wxDC* DC ) ...@@ -332,9 +331,13 @@ void WinEDA_BasePcbFrame::Block_Move( wxDC* DC )
{ {
m_Pcb->m_Status_Pcb = 0; m_Pcb->m_Status_Pcb = 0;
track->Draw( DrawPanel, DC, GR_XOR ); // erase the display track->Draw( DrawPanel, DC, GR_XOR ); // erase the display
track->m_Start.x += deltaX; track->m_Start.y += deltaY; track->m_Start += delta;
track->m_End.x += deltaX; track->m_End.y += deltaY; track->m_End += delta;
track->m_Param += deltaX; track->SetSubNet( track->GetSubNet() + deltaY ); // the two parameters are used in gerbview to store centre coordinates for arcs.
// move this centre
track->m_Param += delta.x;
track->SetSubNet( track->GetSubNet() + delta.y );
track->Draw( DrawPanel, DC, GR_OR ); // redraw the moved track track->Draw( DrawPanel, DC, GR_OR ); // redraw the moved track
} }
track = track->Next(); track = track->Next();
...@@ -344,12 +347,15 @@ void WinEDA_BasePcbFrame::Block_Move( wxDC* DC ) ...@@ -344,12 +347,15 @@ void WinEDA_BasePcbFrame::Block_Move( wxDC* DC )
SEGZONE * zsegment= m_Pcb->m_Zone; SEGZONE * zsegment= m_Pcb->m_Zone;
while( zsegment ) while( zsegment )
{ {
if( IsSegmentInBox( GetScreen()->BlockLocate, track ) ) if( IsSegmentInBox( GetScreen()->BlockLocate, zsegment ) )
{ {
zsegment->Draw( DrawPanel, DC, GR_XOR ); // erase the display zsegment->Draw( DrawPanel, DC, GR_XOR ); // erase the display
zsegment->m_Start.x += deltaX; track->m_Start.y += deltaY; zsegment->m_Start += delta;
zsegment->m_End.x += deltaX; track->m_End.y += deltaY; zsegment->m_End += delta;
zsegment->m_Param += deltaX; track->SetSubNet( track->GetSubNet() + deltaY ); // the two parameters are used in gerbview to store centre coordinates for arcs.
// move this centre
zsegment->m_Param += delta.x;
zsegment->SetSubNet( zsegment->GetSubNet() + delta.y );
zsegment->Draw( DrawPanel, DC, GR_OR ); // redraw the moved zone zegment zsegment->Draw( DrawPanel, DC, GR_OR ); // redraw the moved zone zegment
} }
zsegment = zsegment->Next(); zsegment = zsegment->Next();
...@@ -407,7 +413,7 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC ) ...@@ -407,7 +413,7 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC )
while( zsegment ) while( zsegment )
{ {
SEGZONE * next_zsegment = zsegment->Next(); SEGZONE * next_zsegment = zsegment->Next();
if( IsSegmentInBox( GetScreen()->BlockLocate, track ) ) if( IsSegmentInBox( GetScreen()->BlockLocate, zsegment ) )
{ {
/* this zone segment must be duplicated */ /* this zone segment must be duplicated */
SEGZONE * new_zsegment = (SEGZONE*) zsegment->Copy(); SEGZONE * new_zsegment = (SEGZONE*) zsegment->Copy();
......
...@@ -9,7 +9,7 @@ COMMON_GLOBL wxString g_BuildVersion ...@@ -9,7 +9,7 @@ COMMON_GLOBL wxString g_BuildVersion
# include "config.h" # include "config.h"
(wxT(KICAD_SVN_VERSION)) (wxT(KICAD_SVN_VERSION))
# else # else
(wxT("(20080530-r1107)")) (wxT("(20080622-r1138)"))
# endif # endif
#endif #endif
; ;
......
...@@ -448,9 +448,15 @@ int Get_Message( const wxString& titre, wxString& buffer, wxWindow* frame ); ...@@ -448,9 +448,15 @@ int Get_Message( const wxString& titre, wxString& buffer, wxWindow* frame );
/************************/ /************************/
wxString GetEditorName(); // Return the prefered editor name wxString GetEditorName(); // Return the prefered editor name
void OpenPDF( const wxString& file );
void OpenFile( const wxString& file );
/** Function OpenPDF
* run the PDF viewer and display a PDF file
* @param file = PDF file to open
* @return true is success, false if no PDF viewer found
*/
bool OpenPDF( const wxString& file );
void OpenFile( const wxString& file );
bool EDA_DirectorySelector( const wxString& Title, /* Titre de la fenetre */ bool EDA_DirectorySelector( const wxString& Title, /* Titre de la fenetre */
wxString& Path, /* Chemin par defaut */ wxString& Path, /* Chemin par defaut */
......
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