Commit f3e4682f authored by charras's avatar charras

eeschema: some fixes, see CHANGELOG

parent 54ee98bb
...@@ -4,6 +4,23 @@ KiCad ChangeLog 2009 ...@@ -4,6 +4,23 @@ KiCad ChangeLog 2009
Please add newer entries at the top, list the date and your name with Please add newer entries at the top, list the date and your name with
email address. email address.
2009-apr-12 UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
================================================================================
++eeschema:
Default libraries path are now differents for pcbnew and eeschema (as it do)
Fixed: bad library search path for schematic component docs (docs were not found)
Added: display actual lib paths in eeschema lib config dialog.
These next fix give the same behavior than "old" version
Use relative paths in libraries and doc filenames when possible
i.e when a file is found in a sub path in a default path
(very important for Windows/linux/mac compatibility of projects and their configs)
TODO: allows user to add paths in list. Currently the user path for lib is broken
(but the new code could allow the user to add more than one user path)
TODO: do the same for pcbnew and cvpcb
2009-apr-10 UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr> 2009-apr-10 UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
================================================================================ ================================================================================
++eeschema: ++eeschema:
......
...@@ -84,7 +84,7 @@ bool GetAssociatedDocument( wxFrame* aFrame, ...@@ -84,7 +84,7 @@ bool GetAssociatedDocument( wxFrame* aFrame,
const wxPathList* aPaths) const wxPathList* aPaths)
{ {
wxString fullfilename, file_ext; wxString docname, fullfilename, file_ext;
wxString msg; wxString msg;
wxString command; wxString command;
bool success = FALSE; bool success = FALSE;
...@@ -101,6 +101,14 @@ bool GetAssociatedDocument( wxFrame* aFrame, ...@@ -101,6 +101,14 @@ bool GetAssociatedDocument( wxFrame* aFrame,
} }
} }
docname = aDocName;
#ifdef __WINDOWS__
docname.Replace( UNIX_STRING_DIR_SEP, WIN_STRING_DIR_SEP );
#else
docname.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );
#endif
/* Compute the full file name */ /* Compute the full file name */
if( wxIsAbsolutePath( aDocName ) || aPaths == NULL) if( wxIsAbsolutePath( aDocName ) || aPaths == NULL)
fullfilename = aDocName; fullfilename = aDocName;
...@@ -109,12 +117,6 @@ bool GetAssociatedDocument( wxFrame* aFrame, ...@@ -109,12 +117,6 @@ bool GetAssociatedDocument( wxFrame* aFrame,
fullfilename = aPaths->FindValidPath( aDocName ); fullfilename = aPaths->FindValidPath( aDocName );
} }
#ifdef __WINDOWS__
fullfilename.Replace( UNIX_STRING_DIR_SEP, WIN_STRING_DIR_SEP );
#else
fullfilename.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );
#endif
wxString mask( wxT( "*" ) ), extension; wxString mask( wxT( "*" ) ), extension;
#ifdef __WINDOWS__ #ifdef __WINDOWS__
......
...@@ -258,14 +258,20 @@ WinEDA_App::~WinEDA_App() ...@@ -258,14 +258,20 @@ WinEDA_App::~WinEDA_App()
} }
/** /** Function InitEDA_Appl
* TODO brief * initialise some general parameters
* - Default paths (help, libs, bin)and configuration flies names
* - Language and locale
* - fonts
* @param aName : used as paths in configuration files
* @param aId = flag : APP_TYPE_EESCHEMA, APP_TYPE_PCBNEW..
* used to choose what default library path must be used
*/ */
void WinEDA_App::InitEDA_Appl( const wxString& name ) void WinEDA_App::InitEDA_Appl( const wxString& aName, id_app_type aId )
{ {
wxString EnvLang; wxString EnvLang;
m_Id = aId;
m_Checker = new wxSingleInstanceChecker( name.Lower() + wxT( "-" ) + m_Checker = new wxSingleInstanceChecker( aName.Lower() + wxT( "-" ) +
wxGetUserId() ); wxGetUserId() );
/* Init kicad environment /* Init kicad environment
...@@ -283,17 +289,17 @@ void WinEDA_App::InitEDA_Appl( const wxString& name ) ...@@ -283,17 +289,17 @@ void WinEDA_App::InitEDA_Appl( const wxString& name )
/* Prepare On Line Help. Use only lower case for help filenames, in order to /* Prepare On Line Help. Use only lower case for help filenames, in order to
* avoid problems with upper/lower case filenames under windows and unix */ * avoid problems with upper/lower case filenames under windows and unix */
#if defined ONLINE_HELP_FILES_FORMAT_IS_HTML #if defined ONLINE_HELP_FILES_FORMAT_IS_HTML
m_HelpFileName = name.Lower() + wxT( ".html" ); m_HelpFileName = aName.Lower() + wxT( ".html" );
#elif defined ONLINE_HELP_FILES_FORMAT_IS_PDF #elif defined ONLINE_HELP_FILES_FORMAT_IS_PDF
m_HelpFileName = name.Lower() + wxT( ".pdf" ); m_HelpFileName = aName.Lower() + wxT( ".pdf" );
#else #else
#error Help files format not defined #error Help files format not defined
#endif #endif
/* Init parameters for configuration */ /* Init parameters for configuration */
SetVendorName( wxT( "kicad" ) ); SetVendorName( wxT( "kicad" ) );
SetAppName( name.Lower() ); SetAppName( aName.Lower() );
SetTitle( name ); SetTitle( aName );
m_EDA_Config = new wxConfig( ); m_EDA_Config = new wxConfig( );
wxASSERT( m_EDA_Config != NULL ); wxASSERT( m_EDA_Config != NULL );
m_EDA_CommonConfig = new wxConfig( CommonConfigPath ); m_EDA_CommonConfig = new wxConfig( CommonConfigPath );
...@@ -320,7 +326,7 @@ void WinEDA_App::InitEDA_Appl( const wxString& name ) ...@@ -320,7 +326,7 @@ void WinEDA_App::InitEDA_Appl( const wxString& name )
g_FixedFont = new wxFont( g_FixedFontPointSize, wxFONTFAMILY_MODERN, g_FixedFont = new wxFont( g_FixedFontPointSize, wxFONTFAMILY_MODERN,
wxNORMAL, wxNORMAL ); wxNORMAL, wxNORMAL );
/* TODO installation des gestionnaires de visu d'images (pour help) TODO*/ /* Install some image handlers, mainly for help */
wxImage::AddHandler( new wxPNGHandler ); wxImage::AddHandler( new wxPNGHandler );
wxImage::AddHandler( new wxGIFHandler ); wxImage::AddHandler( new wxGIFHandler );
wxImage::AddHandler( new wxJPEGHandler ); wxImage::AddHandler( new wxJPEGHandler );
...@@ -478,6 +484,8 @@ void WinEDA_App::SetDefaultSearchPaths( void ) ...@@ -478,6 +484,8 @@ void WinEDA_App::SetDefaultSearchPaths( void )
size_t i; size_t i;
wxString path = m_BinDir; wxString path = m_BinDir;
m_searchPaths.Clear();
#ifdef __WINDOWS__ #ifdef __WINDOWS__
/* m_BinDir path is in unix notation. /* m_BinDir path is in unix notation.
* But wxFileName expect (to work fine) native notation * But wxFileName expect (to work fine) native notation
...@@ -528,11 +536,14 @@ void WinEDA_App::SetDefaultSearchPaths( void ) ...@@ -528,11 +536,14 @@ void WinEDA_App::SetDefaultSearchPaths( void )
} }
else else
{ {
/* Add schematic library file path to search path list. */
fn.Clear(); fn.Clear();
fn.SetPath( m_searchPaths[i] ); fn.SetPath( m_searchPaths[i] );
/* Add schematic library file path to search path list.
* we must add <kicad path>/library and <kicad path>/library/doc
*/
if ( m_Id == APP_TYPE_EESCHEMA )
{
fn.AppendDir( wxT( "library") ); fn.AppendDir( wxT( "library") );
if( fn.IsDirReadable() ) if( fn.IsDirReadable() )
{ {
wxLogDebug( wxT( "Adding <%s> to library search path list" ), wxLogDebug( wxT( "Adding <%s> to library search path list" ),
...@@ -541,18 +552,18 @@ void WinEDA_App::SetDefaultSearchPaths( void ) ...@@ -541,18 +552,18 @@ void WinEDA_App::SetDefaultSearchPaths( void )
} }
/* Add schematic doc file path (library/doc)to search path list. */ /* Add schematic doc file path (library/doc)to search path list. */
fn.RemoveLastDir();
fn.AppendDir( wxT( "doc") ); fn.AppendDir( wxT( "doc") );
if( fn.IsDirReadable() ) if( fn.IsDirReadable() )
{ {
wxLogDebug( wxT( "Adding <%s> to library search path list" ), wxLogDebug( wxT( "Adding <%s> to library search path list" ),
fn.GetPath().c_str() ); fn.GetPath().c_str() );
m_libSearchPaths.Add( fn.GetPath() ); m_libSearchPaths.Add( fn.GetPath() );
} }
fn.RemoveLastDir();
fn.RemoveLastDir(); // point to <kicad path>
}
/* Add kicad template file path to search path list. */ /* Add kicad template file path to search path list. */
fn.RemoveLastDir();
fn.AppendDir( wxT( "template" ) ); fn.AppendDir( wxT( "template" ) );
if( fn.IsDirReadable() ) if( fn.IsDirReadable() )
...@@ -561,9 +572,11 @@ void WinEDA_App::SetDefaultSearchPaths( void ) ...@@ -561,9 +572,11 @@ void WinEDA_App::SetDefaultSearchPaths( void )
fn.GetPath().c_str() ); fn.GetPath().c_str() );
m_libSearchPaths.Add( fn.GetPath() ); m_libSearchPaths.Add( fn.GetPath() );
} }
fn.RemoveLastDir();
/* Add PCB library file path to search path list. */ /* Add PCB library file path to search path list. */
fn.RemoveLastDir(); if ( (m_Id == APP_TYPE_PCBNEW) || (m_Id == APP_TYPE_CVPCB) )
{
fn.AppendDir( wxT( "modules" ) ); fn.AppendDir( wxT( "modules" ) );
if( fn.IsDirReadable() ) if( fn.IsDirReadable() )
...@@ -584,6 +597,7 @@ void WinEDA_App::SetDefaultSearchPaths( void ) ...@@ -584,6 +597,7 @@ void WinEDA_App::SetDefaultSearchPaths( void )
} }
} }
} }
}
} }
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "fctsys.h" #include "fctsys.h"
#include "appl_wxstruct.h" #include "appl_wxstruct.h"
#include "wxstruct.h"
#include "common.h" #include "common.h"
#include "confirm.h" #include "confirm.h"
#include "gestfich.h" #include "gestfich.h"
...@@ -64,7 +65,7 @@ bool WinEDA_App::OnInit() ...@@ -64,7 +65,7 @@ bool WinEDA_App::OnInit()
wxString currCWD = wxGetCwd(); wxString currCWD = wxGetCwd();
WinEDA_CvpcbFrame* frame = NULL; WinEDA_CvpcbFrame* frame = NULL;
InitEDA_Appl( wxT( "CVpcb" ) ); InitEDA_Appl( wxT( "CVpcb" ), APP_TYPE_CVPCB );
if( m_Checker && m_Checker->IsAnotherRunning() ) if( m_Checker && m_Checker->IsAnotherRunning() )
{ {
......
...@@ -54,9 +54,9 @@ public: ...@@ -54,9 +54,9 @@ public:
void WinEDA_SchematicFrame::InstallConfigFrame( const wxPoint& pos ) void WinEDA_SchematicFrame::InstallConfigFrame( const wxPoint& pos )
/******************************************************************/ /******************************************************************/
{ {
DIALOG_EESCHEMA_CONFIG* CfgFrame = new DIALOG_EESCHEMA_CONFIG( this ); DIALOG_EESCHEMA_CONFIG CfgFrame( this );
CfgFrame->ShowModal(); CfgFrame->Destroy(); CfgFrame.ShowModal();
} }
...@@ -126,6 +126,13 @@ void DIALOG_EESCHEMA_CONFIG::Init() ...@@ -126,6 +126,13 @@ void DIALOG_EESCHEMA_CONFIG::Init()
m_ListLibr->InsertItems( g_LibName_List, 0 ); m_ListLibr->InsertItems( g_LibName_List, 0 );
m_LibDirCtrl->SetValue( g_UserLibDirBuffer ); m_LibDirCtrl->SetValue( g_UserLibDirBuffer );
// Display actual libraries paths:
wxPathList libpaths = wxGetApp().GetLibraryPathList();
for( unsigned ii = 0; ii < libpaths.GetCount(); ii++ )
{
m_DefaultLibraryPathslistBox->Append( libpaths[ii]);
}
} }
...@@ -148,6 +155,7 @@ void DIALOG_EESCHEMA_CONFIG::OnOkClick( wxCommandEvent& event ) ...@@ -148,6 +155,7 @@ void DIALOG_EESCHEMA_CONFIG::OnOkClick( wxCommandEvent& event )
if ( g_UserLibDirBuffer != m_LibDirCtrl->GetValue() ) if ( g_UserLibDirBuffer != m_LibDirCtrl->GetValue() )
{ {
g_UserLibDirBuffer = m_LibDirCtrl->GetValue(); g_UserLibDirBuffer = m_LibDirCtrl->GetValue();
wxGetApp().SetDefaultSearchPaths( );
m_LibListChanged = true; m_LibListChanged = true;
} }
...@@ -206,7 +214,7 @@ void DIALOG_EESCHEMA_CONFIG::OnAddOrInsertLibClick( wxCommandEvent& event ) ...@@ -206,7 +214,7 @@ void DIALOG_EESCHEMA_CONFIG::OnAddOrInsertLibClick( wxCommandEvent& event )
*/ */
{ {
int ii; int ii;
wxString tmp; wxString libfilename;
wxFileName fn; wxFileName fn;
ii = m_ListLibr->GetSelection(); ii = m_ListLibr->GetSelection();
...@@ -233,24 +241,38 @@ void DIALOG_EESCHEMA_CONFIG::OnAddOrInsertLibClick( wxCommandEvent& event ) ...@@ -233,24 +241,38 @@ void DIALOG_EESCHEMA_CONFIG::OnAddOrInsertLibClick( wxCommandEvent& event )
/* If the library path is already in the library search paths /* If the library path is already in the library search paths
* list, just add the library name to the list. Otherwise, add * list, just add the library name to the list. Otherwise, add
* the library name with the full path. */ * the library name with the full or relative path.
if( wxGetApp().GetLibraryPathList().Index( fn.GetPath() ) == wxNOT_FOUND ) * the relative path, when possible is preferable,
tmp = fn.GetPathWithSep() + fn.GetName(); * because it preserve use of default libraries paths, when the path is a sub path of these default paths
else *
tmp = fn.GetName(); */
if( wxGetApp().GetLibraryPathList().Index( fn.GetPath() ) != wxNOT_FOUND ) // Ok, trivial case
libfilename = fn.GetName();
else // not in the default, : see if this file is in a subpath:
{
libfilename = fn.GetPathWithSep() + fn.GetName();
for ( unsigned kk = 0; kk < wxGetApp().GetLibraryPathList().GetCount(); kk ++ )
{
if( fn.MakeRelativeTo(wxGetApp().GetLibraryPathList()[kk] ) )
{
libfilename = fn.GetPathWithSep() + fn.GetName();
break;
}
}
}
//Add or insert new library name, if not already in list //Add or insert new library name, if not already in list
if( m_ListLibr->FindString( tmp, fn.IsCaseSensitive() ) == wxNOT_FOUND ) if( m_ListLibr->FindString( libfilename, fn.IsCaseSensitive() ) == wxNOT_FOUND )
{ {
m_LibListChanged = TRUE; m_LibListChanged = TRUE;
if( event.GetId() == ID_ADD_LIB ) if( event.GetId() == ID_ADD_LIB )
m_ListLibr->Append( tmp ); m_ListLibr->Append( libfilename );
else else
m_ListLibr->Insert( tmp, ii++ ); m_ListLibr->Insert( libfilename, ii++ );
} }
else else
{ {
wxString msg = wxT( "<" ) + tmp + wxT( "> : " ) + wxString msg = wxT( "<" ) + libfilename + wxT( "> : " ) +
_( "Library already in use" ); _( "Library already in use" );
DisplayError( this, msg ); DisplayError( this, msg );
} }
......
...@@ -124,15 +124,29 @@ DIALOG_EESCHEMA_CONFIG_FBP::DIALOG_EESCHEMA_CONFIG_FBP( wxWindow* parent, wxWind ...@@ -124,15 +124,29 @@ DIALOG_EESCHEMA_CONFIG_FBP::DIALOG_EESCHEMA_CONFIG_FBP( wxWindow* parent, wxWind
bMainSizer->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 ); bMainSizer->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 );
wxStaticBoxSizer* sbLibPathSizer; wxStaticBoxSizer* sbLibPathSizer;
sbLibPathSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Default library file path:") ), wxHORIZONTAL ); sbLibPathSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Libraries Files Main Default Path:") ), wxVERTICAL );
wxBoxSizer* bUserLibPathSizer;
bUserLibPathSizer = new wxBoxSizer( wxHORIZONTAL );
m_LibDirCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_LibDirCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_LibDirCtrl->SetToolTip( _("Default path to search libraries which have no absolute path in name,\nor a name which does not start by ./ or ../\nIf void, the default path is kicad/share/library") ); m_LibDirCtrl->SetToolTip( _("Default path to search libraries which have no absolute path in name,\nor a name which does not start by ./ or ../\nIf void, the default path is kicad/share/library") );
sbLibPathSizer->Add( m_LibDirCtrl, 1, wxALL, 5 ); bUserLibPathSizer->Add( m_LibDirCtrl, 1, wxALL, 5 );
m_buttonBrowse = new wxButton( this, ID_LIB_PATH_SEL, _("Browse"), wxDefaultPosition, wxDefaultSize, 0 ); m_buttonBrowse = new wxButton( this, ID_LIB_PATH_SEL, _("Browse"), wxDefaultPosition, wxDefaultSize, 0 );
sbLibPathSizer->Add( m_buttonBrowse, 0, wxALL, 5 ); bUserLibPathSizer->Add( m_buttonBrowse, 0, wxALL, 5 );
sbLibPathSizer->Add( bUserLibPathSizer, 1, wxEXPAND, 5 );
m_staticTextcurrenpaths = new wxStaticText( this, wxID_ANY, _("Current Libraries Full Paths in Use:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextcurrenpaths->Wrap( -1 );
sbLibPathSizer->Add( m_staticTextcurrenpaths, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_DefaultLibraryPathslistBox = new wxListBox( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_NEEDED_SB );
m_DefaultLibraryPathslistBox->SetMinSize( wxSize( -1,70 ) );
sbLibPathSizer->Add( m_DefaultLibraryPathslistBox, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
bMainSizer->Add( sbLibPathSizer, 0, wxEXPAND, 5 ); bMainSizer->Add( sbLibPathSizer, 0, wxEXPAND, 5 );
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="name">DIALOG_EESCHEMA_CONFIG_FBP</property> <property name="name">DIALOG_EESCHEMA_CONFIG_FBP</property>
<property name="pos"></property> <property name="pos"></property>
<property name="size">593,400</property> <property name="size">593,445</property>
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property> <property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
<property name="subclass"></property> <property name="subclass"></property>
<property name="title"></property> <property name="title"></property>
...@@ -995,12 +995,21 @@ ...@@ -995,12 +995,21 @@
<property name="proportion">0</property> <property name="proportion">0</property>
<object class="wxStaticBoxSizer" expanded="1"> <object class="wxStaticBoxSizer" expanded="1">
<property name="id">wxID_ANY</property> <property name="id">wxID_ANY</property>
<property name="label">Default library file path:</property> <property name="label">Libraries Files Main Default Path:</property>
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="name">sbLibPathSizer</property> <property name="name">sbLibPathSizer</property>
<property name="orient">wxHORIZONTAL</property> <property name="orient">wxVERTICAL</property>
<property name="permission">none</property> <property name="permission">none</property>
<event name="OnUpdateUI"></event> <event name="OnUpdateUI"></event>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bUserLibPathSizer</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxALL</property> <property name="flag">wxALL</property>
...@@ -1110,6 +1119,111 @@ ...@@ -1110,6 +1119,111 @@
</object> </object>
</object> </object>
</object> </object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxTOP|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="bg"></property>
<property name="context_help"></property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="font"></property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Current Libraries Full Paths in Use:</property>
<property name="maximum_size"></property>
<property name="minimum_size"></property>
<property name="name">m_staticTextcurrenpaths</property>
<property name="permission">protected</property>
<property name="pos"></property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxListBox" expanded="1">
<property name="bg"></property>
<property name="choices"></property>
<property name="context_help"></property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="font"></property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="maximum_size"></property>
<property name="minimum_size">-1,70</property>
<property name="name">m_DefaultLibraryPathslistBox</property>
<property name="permission">protected</property>
<property name="pos"></property>
<property name="size"></property>
<property name="style">wxLB_NEEDED_SB</property>
<property name="subclass"></property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnListBox"></event>
<event name="OnListBoxDClick"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
</object>
</object>
</object> </object>
</object> </object>
</object> </object>
......
...@@ -62,6 +62,8 @@ class DIALOG_EESCHEMA_CONFIG_FBP : public wxDialog ...@@ -62,6 +62,8 @@ class DIALOG_EESCHEMA_CONFIG_FBP : public wxDialog
wxStaticLine* m_staticline1; wxStaticLine* m_staticline1;
wxTextCtrl* m_LibDirCtrl; wxTextCtrl* m_LibDirCtrl;
wxButton* m_buttonBrowse; wxButton* m_buttonBrowse;
wxStaticText* m_staticTextcurrenpaths;
wxListBox* m_DefaultLibraryPathslistBox;
// Virtual event handlers, overide them in your derived class // Virtual event handlers, overide them in your derived class
virtual void OnCloseWindow( wxCloseEvent& event ){ event.Skip(); } virtual void OnCloseWindow( wxCloseEvent& event ){ event.Skip(); }
...@@ -74,7 +76,7 @@ class DIALOG_EESCHEMA_CONFIG_FBP : public wxDialog ...@@ -74,7 +76,7 @@ class DIALOG_EESCHEMA_CONFIG_FBP : public wxDialog
public: public:
DIALOG_EESCHEMA_CONFIG_FBP( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 593,400 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); DIALOG_EESCHEMA_CONFIG_FBP( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 593,445 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_EESCHEMA_CONFIG_FBP(); ~DIALOG_EESCHEMA_CONFIG_FBP();
}; };
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
#include "appl_wxstruct.h"
#include "common.h" #include "common.h"
#include "confirm.h" #include "confirm.h"
#include "gestfich.h" #include "gestfich.h"
...@@ -391,7 +392,8 @@ void WinEDA_PartPropertiesFrame::PartPropertiesAccept( wxCommandEvent& event ) ...@@ -391,7 +392,8 @@ void WinEDA_PartPropertiesFrame::PartPropertiesAccept( wxCommandEvent& event )
for( ii = 0; ii < jj; ii++ ) for( ii = 0; ii < jj; ii++ )
{ {
if( LocateAlias( CurrentLibEntry->m_AliasList, m_PartAliasList->GetString( ii ) ) < 0 ) if( LocateAlias( CurrentLibEntry->m_AliasList, m_PartAliasList->GetString( ii ) ) < 0 )
{ // new alias must be created {
// new alias must be created
CurrentLibEntry->m_AliasList.Add( m_PartAliasList->GetString( ii ) ); CurrentLibEntry->m_AliasList.Add( m_PartAliasList->GetString( ii ) );
CurrentLibEntry->m_AliasList.Add( wxEmptyString ); // Add a void doc string CurrentLibEntry->m_AliasList.Add( wxEmptyString ); // Add a void doc string
CurrentLibEntry->m_AliasList.Add( wxEmptyString ); // Add a void keyword list string CurrentLibEntry->m_AliasList.Add( wxEmptyString ); // Add a void keyword list string
...@@ -528,7 +530,7 @@ void WinEDA_PartPropertiesFrame::AddAliasOfPart( wxCommandEvent& WXUNUSED (event ...@@ -528,7 +530,7 @@ void WinEDA_PartPropertiesFrame::AddAliasOfPart( wxCommandEvent& WXUNUSED (event
if( CurrentLibEntry == NULL ) if( CurrentLibEntry == NULL )
return; return;
if( Get_Message( _( "New alias:" ), _("Component Alias"), Line, this ) != 0 ) if( Get_Message( _( "New alias:" ), _( "Component Alias" ), Line, this ) != 0 )
return; return;
Line.Replace( wxT( " " ), wxT( "_" ) ); Line.Replace( wxT( " " ), wxT( "_" ) );
...@@ -770,7 +772,35 @@ void WinEDA_PartPropertiesFrame::BrowseAndSelectDocFile( wxCommandEvent& event ) ...@@ -770,7 +772,35 @@ void WinEDA_PartPropertiesFrame::BrowseAndSelectDocFile( wxCommandEvent& event )
return; return;
// Suppression du chemin par defaut pour le fichier de doc: // Suppression du chemin par defaut pour le fichier de doc:
filename = MakeReducedFileName( FullFileName, docpath, wxEmptyString );
/* If the library path is already in the library search paths
* list, just add the library name to the list. Otherwise, add
* the library name with the full or relative path.
* the relative path, when possible is preferable,
* because it preserve use of default libraries paths, when the path is a sub path of these default paths
*
*/
wxFileName fn = FullFileName;
int pathlen = -1; // path len, used to find the better subpath within defualts paths
if( wxGetApp().GetLibraryPathList().Index( fn.GetPath() ) != wxNOT_FOUND ) // Ok, trivial case
filename = fn.GetName();
else // not in the default, : see if this file is in a subpath:
{
filename = fn.GetPathWithSep() + fn.GetName();
for( unsigned kk = 0; kk < wxGetApp().GetLibraryPathList().GetCount(); kk++ )
{
if( fn.MakeRelativeTo( wxGetApp().GetLibraryPathList()[kk] ) )
{
if( pathlen < 0 // a subpath is found
|| pathlen > (int) fn.GetPath().Len() ) // a better subpath if found
{
filename = fn.GetPathWithSep() + fn.GetName();
pathlen = fn.GetPath().Len();
}
fn = FullFileName; //Try to find a better subpath
}
}
}
m_Docfile->SetValue( filename ); m_Docfile->SetValue( filename );
} }
...@@ -802,7 +832,7 @@ void WinEDA_PartPropertiesFrame::AddFootprintFilter( wxCommandEvent& WXUNUSED (e ...@@ -802,7 +832,7 @@ void WinEDA_PartPropertiesFrame::AddFootprintFilter( wxCommandEvent& WXUNUSED (e
if( CurrentLibEntry == NULL ) if( CurrentLibEntry == NULL )
return; return;
if( Get_Message( _( "New FootprintFilter:" ), _("Footprint Filter"), Line, this ) != 0 ) if( Get_Message( _( "New FootprintFilter:" ), _( "Footprint Filter" ), Line, this ) != 0 )
return; return;
Line.Replace( wxT( " " ), wxT( "_" ) ); Line.Replace( wxT( " " ), wxT( "_" ) );
......
...@@ -148,7 +148,7 @@ bool WinEDA_App::OnInit() ...@@ -148,7 +148,7 @@ bool WinEDA_App::OnInit()
g_DebugLevel = 0; // Debug level */ g_DebugLevel = 0; // Debug level */
InitEDA_Appl( wxT( "EESchema" ) ); InitEDA_Appl( wxT( "EESchema" ), APP_TYPE_EESCHEMA );
if( m_Checker && m_Checker->IsAnotherRunning() ) if( m_Checker && m_Checker->IsAnotherRunning() )
{ {
......
...@@ -39,7 +39,7 @@ bool WinEDA_App::OnInit() ...@@ -39,7 +39,7 @@ bool WinEDA_App::OnInit()
wxFileName fn; wxFileName fn;
WinEDA_GerberFrame* frame = NULL; WinEDA_GerberFrame* frame = NULL;
InitEDA_Appl( wxT( "GerbView" ) ); InitEDA_Appl( wxT( "GerbView" ), APP_TYPE_GERBVIEW );
ScreenPcb = new PCB_SCREEN(); ScreenPcb = new PCB_SCREEN();
ScreenPcb->m_CurrentSheetDesc = &g_Sheet_GERBER; ScreenPcb->m_CurrentSheetDesc = &g_Sheet_GERBER;
......
...@@ -15,6 +15,14 @@ ...@@ -15,6 +15,14 @@
#include <wx/config.h> #include <wx/config.h>
#include <wx/filename.h> #include <wx/filename.h>
enum id_app_type {
APP_TYPE_UNKOWN,
APP_TYPE_EESCHEMA,
APP_TYPE_PCBNEW,
APP_TYPE_CVPCB,
APP_TYPE_GERBVIEW,
APP_TYPE_KICAD,
};
class wxConfigBase; class wxConfigBase;
class wxFileConfig; class wxFileConfig;
...@@ -30,6 +38,9 @@ class wxHtmlHelpController; ...@@ -30,6 +38,9 @@ class wxHtmlHelpController;
class WinEDA_App : public wxApp class WinEDA_App : public wxApp
{ {
public: public:
id_app_type m_Id; /* Used mainly to handle default paths libs
* m_Id = APP_TYPE_EESCHEMA, APP_TYPE_PCBNEW ...
*/
wxString m_Project; wxString m_Project;
wxSingleInstanceChecker* m_Checker; wxSingleInstanceChecker* m_Checker;
...@@ -72,7 +83,18 @@ public: ...@@ -72,7 +83,18 @@ public:
bool SetBinDir(); bool SetBinDir();
void SetDefaultSearchPaths( void ); void SetDefaultSearchPaths( void );
void InitEDA_Appl( const wxString& name );
/** Function InitEDA_Appl
* initialise some general parameters
* - Default paths (help, libs, bin)and configuration flies names
* - Language and locale
* - fonts
* @param aName : used as paths in configuration files
* @param aId = flag : LIBRARY_TYPE_EESCHEMA or LIBRARY_TYPE_PCBNEW
* used to choose what default library path must be used
*/
void InitEDA_Appl( const wxString& aName, id_app_type aId = APP_TYPE_UNKOWN);
bool SetLanguage( bool first_time = FALSE ); bool SetLanguage( bool first_time = FALSE );
/** Function AddMenuLanguageList /** Function AddMenuLanguageList
...@@ -97,6 +119,7 @@ public: ...@@ -97,6 +119,7 @@ public:
void WriteProjectConfig( const wxString& local_config_filename, void WriteProjectConfig( const wxString& local_config_filename,
const wxString& GroupName, const wxString& GroupName,
PARAM_CFG_BASE** List ); PARAM_CFG_BASE** List );
/** Function SaveCurrentSetupValues() /** Function SaveCurrentSetupValues()
* Save the current setup values in m_EDA_Config * Save the current setup values in m_EDA_Config
* saved parameters are parameters that have the .m_Setup member set to true * saved parameters are parameters that have the .m_Setup member set to true
...@@ -133,10 +156,13 @@ public: ...@@ -133,10 +156,13 @@ public:
wxPathList& GetLibraryPathList() { return m_libSearchPaths; } wxPathList& GetLibraryPathList() { return m_libSearchPaths; }
wxString FindLibraryPath( const wxString& fileName ); wxString FindLibraryPath( const wxString& fileName );
wxString FindLibraryPath( const wxFileName& fileName ) wxString FindLibraryPath( const wxFileName& fileName )
{ {
return FindLibraryPath( fileName.GetFullPath() ); return FindLibraryPath( fileName.GetFullPath() );
} }
void RemoveLibraryPath( const wxString& path ); void RemoveLibraryPath( const wxString& path );
void InsertLibraryPath( const wxString& path, size_t index ); void InsertLibraryPath( const wxString& path, size_t index );
}; };
...@@ -146,6 +172,6 @@ public: ...@@ -146,6 +172,6 @@ public:
* of the application pointer all over the place or worse yet in a global * of the application pointer all over the place or worse yet in a global
* variable. * variable.
*/ */
DECLARE_APP(WinEDA_App); DECLARE_APP( WinEDA_App );
#endif /* APPL_WXSTRUCT_H */ #endif /* APPL_WXSTRUCT_H */
...@@ -369,7 +369,7 @@ bool WinEDA_App::OnInit() ...@@ -369,7 +369,7 @@ bool WinEDA_App::OnInit()
{ {
WinEDA_MainFrame* frame; WinEDA_MainFrame* frame;
InitEDA_Appl( wxT( "KiCad" ) ); InitEDA_Appl( wxT( "KiCad" ), APP_TYPE_KICAD );
/* init kicad */ /* init kicad */
GetSettings(); // read current setup GetSettings(); // read current setup
......
...@@ -96,7 +96,7 @@ bool WinEDA_App::OnInit() ...@@ -96,7 +96,7 @@ bool WinEDA_App::OnInit()
wxFileName fn; wxFileName fn;
WinEDA_PcbFrame* frame = NULL; WinEDA_PcbFrame* frame = NULL;
InitEDA_Appl( wxT( "PCBnew" ) ); InitEDA_Appl( wxT( "PCBnew" ), APP_TYPE_PCBNEW );
if( m_Checker && m_Checker->IsAnotherRunning() ) if( m_Checker && m_Checker->IsAnotherRunning() )
{ {
......
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