Commit 20cb87a8 authored by charras's avatar charras

better handling of libraries paths (removed g_RealLibraryBuffer that had no...

better handling of libraries paths (removed g_RealLibraryBuffer that had no sense with the new code), mainly in Eeschema
TODO: better handling of user lib paths (more than one path)
parent 89e7f965
......@@ -8,7 +8,7 @@
#include "appl_wxstruct.h"
#define BUILD_VERSION wxT("(20090406-unstable)")
#define BUILD_VERSION wxT("(20090414-unstable)")
wxString g_BuildVersion
......
......@@ -66,7 +66,6 @@ const wxString AllFilesWildcard( _( "All files (*)|*") );
wxString g_ProductName = wxT( "KiCad E.D.A. " );
bool g_ShowPageLimits = true;
int g_GridColor = DARKGRAY;
wxString g_RealLibDirBuffer;
wxString g_UserLibDirBuffer;
int g_DebugLevel;
int g_MouseOldButtons;
......@@ -96,6 +95,11 @@ int g_UnitMetric; // display units mm = 1, inches = 0, cm = 2
/* Draw color for moving objects: */
int g_GhostColor;
/* predefined colors used in kicad.
* Please: if you change a value, remember these values are carefully chosen
* to have good results in pcbnew, that uses the ORed value of basic colors
* when displaying superimposed objects
*/
StructColors ColorRefs[NBCOLOR] =
{
{ 0, 0, 0, BLACK, wxT("BLACK"), DARKDARKGRAY},
......
......@@ -700,7 +700,7 @@ void WinEDA_App::SaveSettings()
m_EDA_Config->Write( wxT( "SdtFontType" ), g_StdFont->GetFaceName() );
#if wxCHECK_VERSION( 2, 9, 0 )
#warning under wxWidgets 3.0, see how to replace the next lines
#warning TODO: under wxWidgets 3.0, see how to replace the next lines
#else
m_EDA_Config->Write( wxT( "SdtFontStyle" ), g_StdFont->GetStyle() );
m_EDA_Config->Write( wxT( "SdtFontWeight" ), g_StdFont->GetWeight() );
......@@ -1030,23 +1030,78 @@ wxString WinEDA_App::GetLibraryFile( const wxString& filename )
return FindFileInSearchPaths( filename, &subdirs );
}
/** ReturnLastVisitedLibraryPath
* Returns the last visited library directory, or (if void) the first
* path in lib path list ( but not the CWD )
* @param aSubPathToSearch = Prefered sub path to search in path list (defualt = empty string)
*/
wxString s_LastVisitedLibPath; // Last lib directoty used when adding libraries
wxString WinEDA_App::ReturnLastVisitedLibraryPath( const wxString & aSubPathToSearch )
{
if ( ! s_LastVisitedLibPath.IsEmpty() )
return s_LastVisitedLibPath;
/**
wxString path;
/* Initialize default path to the main default lib path
* this is the second path in list (the first is the project path)
*/
unsigned pcount = wxGetApp().GetLibraryPathList().GetCount();
if ( pcount )
{
unsigned ipath = 0;
if ( wxGetApp().GetLibraryPathList()[0] == wxGetCwd() )
ipath = 1;
// First choice fo path:
if ( ipath < pcount )
path = wxGetApp().GetLibraryPathList()[ipath];
// Search a sub path matching aSubPathToSearch
if ( ! aSubPathToSearch.IsEmpty() )
{
for ( ; ipath < pcount; ipath++ )
{
if ( wxGetApp().GetLibraryPathList()[ipath].Contains( aSubPathToSearch ) )
{
path = wxGetApp().GetLibraryPathList()[ipath];
break;
}
}
}
}
if ( path.IsEmpty() )
path = wxGetCwd();
return path;
}
void WinEDA_App::SaveLastVisitedLibraryPath( const wxString & aPath)
{
s_LastVisitedLibPath = aPath;
}
/** FindLibraryPath
* Kicad saves user defined library files that are not in the standard
* library search path list with the full file path. Calling the library
* search path list with a user library file will fail. This helper method
* solves that problem.
*
* Returns a wxEmptyString if library file is not found.
* @param fileName
* @return a wxEmptyString if library file is not found.
*/
wxString WinEDA_App::FindLibraryPath( const wxString& fileName )
wxString WinEDA_App::FindLibraryPath( const wxString& aFileName )
{
if( wxFileName::FileExists( fileName ) )
return fileName;
if( wxFileName::FileExists( aFileName ) )
return aFileName;
else
return m_libSearchPaths.FindValidPath( fileName );
return m_libSearchPaths.FindValidPath( aFileName );
}
/** Function RemoveLibraryPath
* Removes the given ptah from the libary path list
* @param path = the path to remove
*/
void WinEDA_App::RemoveLibraryPath( const wxString& path )
{
if( m_libSearchPaths.Index( path, wxFileName::IsCaseSensitive() ) != wxNOT_FOUND )
......
......@@ -1462,67 +1462,6 @@ void GRSFilledRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
}
/*******************************/
/* Routines used to draw texts */
/*******************************/
/*********************************************/
void GRSetFont( wxDC* DC, wxFont* Font )
/*********************************************/
/* Routine to set the current font */
{
DC->SetFont( *Font );
}
/*********************************************************/
void GRSetTextFgColor( wxDC* DC, int Color )
/*********************************************************/
/* Set the foreground color used to draw texts */
{
DC->SetTextForeground( wxColour( ColorRefs[Color].m_Red,
ColorRefs[Color].m_Green,
ColorRefs[Color].m_Blue ) );
}
void GRSetTextFgColor( wxDC* DC, wxFont*, int Color )
{
DC->SetTextForeground( wxColour( ColorRefs[Color].m_Red,
ColorRefs[Color].m_Green,
ColorRefs[Color].m_Blue ) );
}
/********************************/
void GRResetTextFgColor( wxDC* DC )
/********************************/
/* Set the foreground color used to draw texts to the default value */
{
GRSetTextFgColor( DC, Text_Color );
}
/*********************************************************/
void GRSetTextBgColor( wxDC* DC, int Color )
/*********************************************************/
/* Set the background color used to draw texts */
{
Color &= MASKCOLOR; // keep only the bits used to select the color
DC->SetTextBackground( wxColour( ColorRefs[Color].m_Red,
ColorRefs[Color].m_Green,
ColorRefs[Color].m_Blue ) );
}
void GRSetTextBgColor( wxDC* DC, wxFont*, int Color )
{
Color &= MASKCOLOR; // keep only the bits used to select the color
DC->SetTextBackground( wxColour( ColorRefs[Color].m_Red,
ColorRefs[Color].m_Green,
ColorRefs[Color].m_Blue ) );
}
#ifdef USE_CLIP_FILLED_POLYGONS
/** Function ClipAndDrawFilledPoly
......
......@@ -340,7 +340,7 @@ PARAM_CFG_INT::PARAM_CFG_INT( bool Insetup, const wxChar* ident, int* ptparam,
/** ReadParam
* read the value of parameter thi stored in aConfig
* read the value of parameter this stored in aConfig
* @param aConfig = the wxConfigBase that store the parameter
*/
void PARAM_CFG_INT::ReadParam( wxConfigBase* aConfig )
......@@ -357,7 +357,7 @@ void PARAM_CFG_INT::ReadParam( wxConfigBase* aConfig )
/** SaveParam
* the the value of parameter thi stored in aConfig
* save the value of parameter this stored in aConfig
* @param aConfig = the wxConfigBase that can store the parameter
*/
void PARAM_CFG_INT::SaveParam( wxConfigBase* aConfig )
......@@ -394,7 +394,7 @@ PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR( bool Insetup,
/** ReadParam
* read the value of parameter thi stored in aConfig
* read the value of parameter this stored in aConfig
* @param aConfig = the wxConfigBase that store the parameter
*/
void PARAM_CFG_SETCOLOR::ReadParam( wxConfigBase* aConfig )
......@@ -410,7 +410,7 @@ void PARAM_CFG_SETCOLOR::ReadParam( wxConfigBase* aConfig )
/** SaveParam
* the the value of parameter thi stored in aConfig
* save the the value of parameter this stored in aConfig
* @param aConfig = the wxConfigBase that can store the parameter
*/
void PARAM_CFG_SETCOLOR::SaveParam( wxConfigBase* aConfig )
......@@ -451,7 +451,7 @@ PARAM_CFG_DOUBLE::PARAM_CFG_DOUBLE( bool Insetup,
/** ReadParam
* read the value of parameter thi stored in aConfig
* read the value of parameter this stored in aConfig
* @param aConfig = the wxConfigBase that store the parameter
*/
void PARAM_CFG_DOUBLE::ReadParam( wxConfigBase* aConfig )
......@@ -475,7 +475,7 @@ void PARAM_CFG_DOUBLE::ReadParam( wxConfigBase* aConfig )
/** SaveParam
* the the value of parameter thi stored in aConfig
* save the the value of parameter this stored in aConfig
* @param aConfig = the wxConfigBase that can store the parameter
*/
void PARAM_CFG_DOUBLE::SaveParam( wxConfigBase* aConfig )
......@@ -511,7 +511,7 @@ PARAM_CFG_BOOL::PARAM_CFG_BOOL( bool Insetup,
/** ReadParam
* read the value of parameter thi stored in aConfig
* read the value of parameter this stored in aConfig
* @param aConfig = the wxConfigBase that store the parameter
*/
void PARAM_CFG_BOOL::ReadParam( wxConfigBase* aConfig )
......@@ -525,7 +525,7 @@ void PARAM_CFG_BOOL::ReadParam( wxConfigBase* aConfig )
/** SaveParam
* the the value of parameter thi stored in aConfig
* save the the value of parameter this stored in aConfig
* @param aConfig = the wxConfigBase that can store the parameter
*/
void PARAM_CFG_BOOL::SaveParam( wxConfigBase* aConfig )
......@@ -557,7 +557,7 @@ PARAM_CFG_WXSTRING::PARAM_CFG_WXSTRING( bool Insetup, const wxChar* ident,
/** ReadParam
* read the value of parameter thi stored in aConfig
* read the value of parameter this stored in aConfig
* @param aConfig = the wxConfigBase that store the parameter
*/
void PARAM_CFG_WXSTRING::ReadParam( wxConfigBase* aConfig )
......@@ -569,7 +569,7 @@ void PARAM_CFG_WXSTRING::ReadParam( wxConfigBase* aConfig )
/** SaveParam
* the the value of parameter thi stored in aConfig
* save the value of parameter this stored in aConfig
* @param aConfig = the wxConfigBase that can store the parameter
*/
void PARAM_CFG_WXSTRING::SaveParam( wxConfigBase* aConfig )
......@@ -591,7 +591,7 @@ PARAM_CFG_LIBNAME_LIST::PARAM_CFG_LIBNAME_LIST( const wxChar* ident,
/** ReadParam
* read the value of parameter thi stored in aConfig
* read the value of parameter this stored in aConfig
* @param aConfig = the wxConfigBase that store the parameter
*/
void PARAM_CFG_LIBNAME_LIST::ReadParam( wxConfigBase* aConfig )
......@@ -615,7 +615,7 @@ void PARAM_CFG_LIBNAME_LIST::ReadParam( wxConfigBase* aConfig )
/** SaveParam
* the the value of parameter thi stored in aConfig
* save the value of parameter this in aConfig (list of parameters)
* @param aConfig = the wxConfigBase that can store the parameter
*/
void PARAM_CFG_LIBNAME_LIST::SaveParam( wxConfigBase* aConfig )
......
......@@ -14,7 +14,6 @@
#include "protos.h"
#include "cvstruct.h"
/*****************************************/
/* classe pour la frame de Configuration */
/*****************************************/
......@@ -202,7 +201,24 @@ void KiConfigCvpcbFrame::LibAddFct( wxCommandEvent& event )
Update();
wxFileDialog dlg( this, _( "Foot Print Library Files" ), g_RealLibDirBuffer,
wxString libpath = m_LibDirCtrl->GetValue();
if ( libpath.IsEmpty() )
libpath = wxGetApp().ReturnLastVisitedLibraryPath();
if ( libpath.IsEmpty() )
{ /* Initialize default path to the main default lib path
* this is the second path in list (the first is the project path)
*/
ii = wxGetApp().GetLibraryPathList().GetCount();
if ( ii > 2 )
ii = 2;
if ( ii > 0 )
libpath = wxGetApp().GetLibraryPathList()[ii-1];
else
libpath = wxGetCwd();
}
wxFileDialog dlg( this, _( "Foot Print Library Files" ), libpath,
wxEmptyString, ModuleFileWildcard,
wxFD_OPEN | wxFD_MULTIPLE | wxFD_FILE_MUST_EXIST );
......@@ -218,7 +234,10 @@ void KiConfigCvpcbFrame::LibAddFct( wxCommandEvent& event )
{
fn = Filenames[jj];
/* If the library path is already in the library search paths
if ( jj == 0 )
wxGetApp().SaveLastVisitedLibraryPath( fn.GetPath() );
/* 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 path. */
if( wxGetApp().GetLibraryPathList().Index( fn.GetPath() ) == wxNOT_FOUND )
......@@ -281,8 +300,24 @@ void KiConfigCvpcbFrame::EquAddFct( wxCommandEvent& event )
Update();
wxString libpath = m_LibDirCtrl->GetValue();
if ( libpath.IsEmpty() )
libpath = wxGetApp().ReturnLastVisitedLibraryPath();
if ( libpath.IsEmpty() )
{ /* Initialize default path to the main default lib path
* this is the second path in list (the first is the project path)
*/
ii = wxGetApp().GetLibraryPathList().GetCount();
if ( ii > 2 )
ii = 2;
if ( ii > 0 )
libpath = wxGetApp().GetLibraryPathList()[ii-1];
else
libpath = wxGetCwd();
}
wxFileDialog dlg( this, _( "Open Footprint Alias Files" ),
g_RealLibDirBuffer, wxEmptyString, EquivFileWildcard,
libpath, wxEmptyString, EquivFileWildcard,
wxFD_OPEN | wxFD_MULTIPLE | wxFD_FILE_MUST_EXIST );
if( dlg.ShowModal() == wxID_CANCEL )
......@@ -298,6 +333,9 @@ void KiConfigCvpcbFrame::EquAddFct( wxCommandEvent& event )
{
fn = Filenames[jj];
if ( jj == 0 )
wxGetApp().SaveLastVisitedLibraryPath( fn.GetPath() );
/* Use the file name without extension if the library path is
* already in the default library search path. Otherwise, use
* the full path and file name without the extension. */
......
......@@ -1037,6 +1037,7 @@ void LibDrawPin::DisplayInfo( WinEDA_DrawFrame* frame )
}
frame->MsgPanel->Affiche_1_Parametre( 62, _( "Orient" ), Text, MAGENTA );
wxMessageBox(wxT("Pin!"));
}
......
......@@ -77,6 +77,7 @@ SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( bool Include
if( Pin )
{
/* Force display pin infos (the previous display could be a component info) */
Pin->Display_Infos( this );
if( LibItem )
......@@ -187,7 +188,7 @@ SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( const wxPoin
LibItem->GetRef( GetSheet() ),
LibItem->GetField( VALUE )->m_Text,
CYAN );
if( IncludePin == TRUE )
if( IncludePin )
return LibItem;
}
......
......@@ -33,15 +33,16 @@ private:
private:
// Virtual event handlers, overide them in your derived class
// event handlers, overiding the fbp handlers
void Init();
virtual void OnCloseWindow( wxCloseEvent& event );
virtual void OnSaveCfgClick( wxCommandEvent& event );
virtual void OnRemoveLibClick( wxCommandEvent& event );
virtual void OnAddOrInsertLibClick( wxCommandEvent& event );
virtual void OnLibPathSelClick( wxCommandEvent& event );
virtual void OnOkClick( wxCommandEvent& event );
virtual void OnCancelClick( wxCommandEvent& event );
void OnCloseWindow( wxCloseEvent& event );
void OnSaveCfgClick( wxCommandEvent& event );
void OnRemoveLibClick( wxCommandEvent& event );
void OnAddOrInsertLibClick( wxCommandEvent& event );
void OnLibPathSelClick( wxCommandEvent& event );
void OnOkClick( wxCommandEvent& event );
void OnCancelClick( wxCommandEvent& event );
void OnRemoveUserPath( wxCommandEvent& event );
public:
......@@ -154,8 +155,9 @@ void DIALOG_EESCHEMA_CONFIG::OnOkClick( wxCommandEvent& event )
// Set new default path lib
if ( g_UserLibDirBuffer != m_LibDirCtrl->GetValue() )
{
wxGetApp().RemoveLibraryPath( g_UserLibDirBuffer );
g_UserLibDirBuffer = m_LibDirCtrl->GetValue();
wxGetApp().SetDefaultSearchPaths( );
wxGetApp().InsertLibraryPath( g_UserLibDirBuffer, 1 );
m_LibListChanged = true;
}
......@@ -223,7 +225,7 @@ void DIALOG_EESCHEMA_CONFIG::OnAddOrInsertLibClick( wxCommandEvent& event )
wxString libpath = m_LibDirCtrl->GetValue();
if ( libpath.IsEmpty() )
libpath = g_RealLibDirBuffer;
libpath = wxGetApp().ReturnLastVisitedLibraryPath();
wxFileDialog FilesDialog( this, _( "Library files:" ), libpath,
wxEmptyString, CompLibFileWildcard,
......@@ -235,9 +237,11 @@ void DIALOG_EESCHEMA_CONFIG::OnAddOrInsertLibClick( wxCommandEvent& event )
wxArrayString Filenames;
FilesDialog.GetPaths( Filenames );
for( unsigned jj = 0; jj < Filenames.GetCount(); jj++ )
for( unsigned jj = 0; jj < Filenames.GetCount(); jj++ )
{
fn = Filenames[jj];
if ( jj == 0 )
wxGetApp().SaveLastVisitedLibraryPath( fn.GetPath() );
/* If the library path is already in the library search paths
* list, just add the library name to the list. Otherwise, add
......@@ -296,7 +300,7 @@ void DIALOG_EESCHEMA_CONFIG::OnLibPathSelClick( wxCommandEvent& event )
{
wxString path = m_LibDirCtrl->GetValue();
if ( path.IsEmpty() )
path = g_RealLibDirBuffer;
path = wxGetApp().ReturnLastVisitedLibraryPath();
bool select = EDA_DirectorySelector( _( " Default Path for libraries" ), /* Titre de la fenetre */
path, /* Chemin par defaut */
......@@ -308,4 +312,14 @@ void DIALOG_EESCHEMA_CONFIG::OnLibPathSelClick( wxCommandEvent& event )
return;
m_LibDirCtrl->SetValue( path );
wxGetApp().SaveLastVisitedLibraryPath( path );
}
/***********************************************************************/
void DIALOG_EESCHEMA_CONFIG::OnRemoveUserPath( wxCommandEvent& event )
/***********************************************************************/
{
m_LibDirCtrl->Clear( );
}
......@@ -82,11 +82,11 @@ DIALOG_EESCHEMA_CONFIG_FBP::DIALOG_EESCHEMA_CONFIG_FBP( wxWindow* parent, wxWind
wxBoxSizer* bRightSizer;
bRightSizer = new wxBoxSizer( wxVERTICAL );
m_buttonRemove = new wxButton( this, ID_REMOVE_LIB, _("Remove"), wxDefaultPosition, wxDefaultSize, 0 );
m_buttonRemove->SetForegroundColour( wxColour( 186, 1, 38 ) );
m_buttonRemove->SetToolTip( _("Unload the selected library") );
m_buttonRemoveLib = new wxButton( this, ID_REMOVE_LIB, _("Remove"), wxDefaultPosition, wxDefaultSize, 0 );
m_buttonRemoveLib->SetForegroundColour( wxColour( 186, 1, 38 ) );
m_buttonRemoveLib->SetToolTip( _("Unload the selected library") );
bRightSizer->Add( m_buttonRemove, 0, wxALL, 5 );
bRightSizer->Add( m_buttonRemoveLib, 0, wxALL, 5 );
m_buttonAdd = new wxButton( this, ID_ADD_LIB, _("Add"), wxDefaultPosition, wxDefaultSize, 0 );
m_buttonAdd->SetForegroundColour( wxColour( 13, 118, 1 ) );
......@@ -124,26 +124,45 @@ DIALOG_EESCHEMA_CONFIG_FBP::DIALOG_EESCHEMA_CONFIG_FBP( wxWindow* parent, wxWind
bMainSizer->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 );
wxStaticBoxSizer* sbLibPathSizer;
sbLibPathSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Libraries Files Main Default Path:") ), wxVERTICAL );
sbLibPathSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Path for Libraries Files:") ), wxVERTICAL );
wxBoxSizer* bUserLibPathSizer;
bUserLibPathSizer = new wxBoxSizer( wxHORIZONTAL );
wxStaticBoxSizer* sbSizer4;
sbSizer4 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("User Path:") ), wxHORIZONTAL );
wxBoxSizer* bUserListSizer;
bUserListSizer = new wxBoxSizer( wxVERTICAL );
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") );
bUserLibPathSizer->Add( m_LibDirCtrl, 1, wxALL, 5 );
bUserListSizer->Add( m_LibDirCtrl, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
sbSizer4->Add( bUserListSizer, 1, wxALIGN_CENTER_VERTICAL, 5 );
wxBoxSizer* bUserPathsButtonsSizer;
bUserPathsButtonsSizer = new wxBoxSizer( wxVERTICAL );
m_buttonBrowse = new wxButton( this, ID_LIB_PATH_SEL, _("Browse"), wxDefaultPosition, wxDefaultSize, 0 );
bUserLibPathSizer->Add( m_buttonBrowse, 0, wxALL, 5 );
bUserPathsButtonsSizer->Add( m_buttonBrowse, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
m_buttonRemovePath = new wxButton( this, wxID_ANY, _("Remove"), wxDefaultPosition, wxDefaultSize, 0 );
bUserPathsButtonsSizer->Add( m_buttonRemovePath, 0, wxALL, 5 );
sbSizer4->Add( bUserPathsButtonsSizer, 0, wxEXPAND, 5 );
bUserLibPathSizer->Add( sbSizer4, 1, wxEXPAND, 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 = new wxStaticText( this, wxID_ANY, _("Current Full Paths (for Libraries and Doc Files) 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->SetToolTip( _("Paths (system paths and user paths) used to search and load libraries files and component doc files.\nSorted by decreasing priority order.") );
m_DefaultLibraryPathslistBox->SetMinSize( wxSize( -1,70 ) );
sbLibPathSizer->Add( m_DefaultLibraryPathslistBox, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
......@@ -155,24 +174,26 @@ DIALOG_EESCHEMA_CONFIG_FBP::DIALOG_EESCHEMA_CONFIG_FBP( wxWindow* parent, wxWind
// Connect Events
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnCloseWindow ) );
m_buttonRemove->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnRemoveLibClick ), NULL, this );
m_buttonRemoveLib->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnRemoveLibClick ), NULL, this );
m_buttonAdd->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnAddOrInsertLibClick ), NULL, this );
m_buttonIns->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnAddOrInsertLibClick ), NULL, this );
m_buttonOk->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnOkClick ), NULL, this );
m_buttonCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnCancelClick ), NULL, this );
m_buttonSave->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnSaveCfgClick ), NULL, this );
m_buttonBrowse->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnLibPathSelClick ), NULL, this );
m_buttonRemovePath->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnRemoveUserPath ), NULL, this );
}
DIALOG_EESCHEMA_CONFIG_FBP::~DIALOG_EESCHEMA_CONFIG_FBP()
{
// Disconnect Events
this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnCloseWindow ) );
m_buttonRemove->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnRemoveLibClick ), NULL, this );
m_buttonRemoveLib->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnRemoveLibClick ), NULL, this );
m_buttonAdd->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnAddOrInsertLibClick ), NULL, this );
m_buttonIns->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnAddOrInsertLibClick ), NULL, this );
m_buttonOk->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnOkClick ), NULL, this );
m_buttonCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnCancelClick ), NULL, this );
m_buttonSave->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnSaveCfgClick ), NULL, this );
m_buttonBrowse->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnLibPathSelClick ), NULL, this );
m_buttonRemovePath->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnRemoveUserPath ), NULL, this );
}
This diff is collapsed.
......@@ -52,7 +52,7 @@ class DIALOG_EESCHEMA_CONFIG_FBP : public wxDialog
wxStaticText* m_InfoSchFileExt;
wxStaticText* m_staticTextlibList;
wxListBox* m_ListLibr;
wxButton* m_buttonRemove;
wxButton* m_buttonRemoveLib;
wxButton* m_buttonAdd;
wxButton* m_buttonIns;
......@@ -62,6 +62,7 @@ class DIALOG_EESCHEMA_CONFIG_FBP : public wxDialog
wxStaticLine* m_staticline1;
wxTextCtrl* m_LibDirCtrl;
wxButton* m_buttonBrowse;
wxButton* m_buttonRemovePath;
wxStaticText* m_staticTextcurrenpaths;
wxListBox* m_DefaultLibraryPathslistBox;
......@@ -73,10 +74,11 @@ class DIALOG_EESCHEMA_CONFIG_FBP : public wxDialog
virtual void OnCancelClick( wxCommandEvent& event ){ event.Skip(); }
virtual void OnSaveCfgClick( wxCommandEvent& event ){ event.Skip(); }
virtual void OnLibPathSelClick( wxCommandEvent& event ){ event.Skip(); }
virtual void OnRemoveUserPath( wxCommandEvent& event ){ event.Skip(); }
public:
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( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 593,500 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_EESCHEMA_CONFIG_FBP();
};
......
......@@ -3,7 +3,6 @@
/**************************************************************/
#include "fctsys.h"
#include "gr_basic.h"
#include "appl_wxstruct.h"
#include "common.h"
#include "confirm.h"
......@@ -753,12 +752,11 @@ void WinEDA_PartPropertiesFrame::BrowseAndSelectDocFile( wxCommandEvent& event )
/****************************************************************************/
{
wxString FullFileName, mask;
wxString docpath, filename;
wxString docpath( g_RealLibDirBuffer ), filename;
docpath = wxGetApp().ReturnLastVisitedLibraryPath(wxT( "doc" ));
docpath += wxT( "doc" );
docpath += STRING_DIR_SEP;
mask = wxT( "*" );
mask = wxT( "*" );
FullFileName = EDA_FileSelector( _( "Doc Files" ),
docpath, /* Chemin par defaut */
wxEmptyString, /* nom fichier par defaut */
......@@ -771,8 +769,6 @@ void WinEDA_PartPropertiesFrame::BrowseAndSelectDocFile( wxCommandEvent& event )
if( FullFileName.IsEmpty() )
return;
// Suppression du chemin par defaut pour le fichier de doc:
/* 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.
......@@ -781,6 +777,7 @@ void WinEDA_PartPropertiesFrame::BrowseAndSelectDocFile( wxCommandEvent& event )
*
*/
wxFileName fn = FullFileName;
wxGetApp().SaveLastVisitedLibraryPath( fn.GetPath() );
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();
......
......@@ -2,10 +2,6 @@
/* eeschema.cpp - module principal */
/***********************************/
#ifdef __GNUG__
#pragma implementation
#endif
#include "fctsys.h"
#include "appl_wxstruct.h"
#include "common.h"
......
This diff is collapsed.
......@@ -258,8 +258,7 @@ void WinEDA_LibeditFrame::SaveActiveLibrary()
return;
}
fn = wxFileName( g_RealLibDirBuffer, CurrentLib->m_Name,
CompLibFileExtension );
fn = wxFileName( CurrentLib->m_FullFileName );
msg = _( "Modify Library File \"" ) + fn.GetFullPath() + _( "\"?" );
......
......@@ -21,7 +21,10 @@
/* Routines locales */
static void ShowMoveField( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
/* if the field is the reference, return reference like schematic, i.e U -> U? or U?A
* or the field text for others
*/
static wxString ReturnFieldFullText( LibDrawField* aField);
/* Variables locales */
extern int CurrentUnit;
......@@ -76,6 +79,33 @@ void WinEDA_LibeditFrame::StartMoveField( wxDC* DC, LibDrawField* field )
}
/* if the field is the reference, return reference like schematic, i.e U -> U? or U?A
* or the field text for others
*/
static wxString ReturnFieldFullText( LibDrawField* aField)
{
if ( aField->m_FieldId != REFERENCE )
return aField->m_Text;
wxString text = aField->m_Text;
if( CurrentLibEntry->m_UnitCount > 1 )
{
#if defined(KICAD_GOST)
text.Printf( wxT( "%s?.%c" ),
aField->m_Text.m_Text.GetData(), CurrentUnit + '1' - 1 );
#else
text.Printf( wxT( "%s?%c" ),
aField->m_Text.GetData(), CurrentUnit + 'A' - 1 );
#endif
}
else
text << wxT( "?" );
return text;
}
/*****************************************************************/
/* Routine d'affichage du texte 'Field' en cours de deplacement. */
/* Routine normalement attachee au curseur */
......@@ -103,9 +133,7 @@ static void ShowMoveField( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
break;
}
wxString text = Field->m_Text;
if( Field->m_FieldId == REFERENCE )
text << wxT( "?" );
wxString text = ReturnFieldFullText( Field );
int TransMat[2][2];
TransMat[0][0] = 1; TransMat[1][1] = -1;
......@@ -166,7 +194,7 @@ void WinEDA_LibeditFrame::PlaceField( wxDC* DC, LibDrawField* Field )
GRSetDrawMode( DC, GR_DEFAULT_DRAWMODE );
DrawGraphicText( DrawPanel, DC, wxPoint( Field->m_Pos.x, -Field->m_Pos.y ),
color, Field->m_Text,
color, ReturnFieldFullText( Field ),
Field->m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ,
Field->m_Size,
Field->m_HJustify, Field->m_VJustify, LineWidth );
......@@ -218,7 +246,7 @@ void WinEDA_LibeditFrame::EditField( wxDC* DC, LibDrawField* Field )
GRSetDrawMode( DC, g_XorMode );
DrawGraphicText( DrawPanel, DC, wxPoint( Field->m_Pos.x, -Field->m_Pos.y ),
color, Field->m_Text,
color, ReturnFieldFullText( Field ),
Field->m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ,
Field->m_Size,
Field->m_HJustify, Field->m_VJustify, LineWidth );
......@@ -235,7 +263,7 @@ void WinEDA_LibeditFrame::EditField( wxDC* DC, LibDrawField* Field )
GRSetDrawMode( DC, GR_DEFAULT_DRAWMODE );
DrawGraphicText( DrawPanel, DC, wxPoint( Field->m_Pos.x, -Field->m_Pos.y ),
color, Field->m_Text,
color, ReturnFieldFullText( Field ),
Field->m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ,
Field->m_Size,
Field->m_HJustify, Field->m_VJustify, LineWidth );
......@@ -286,7 +314,7 @@ void WinEDA_LibeditFrame::RotateField( wxDC* DC, LibDrawField* Field )
GRSetDrawMode( DC, g_XorMode );
int LineWidth = MAX( Field->m_Width, g_DrawMinimunLineWidth );
DrawGraphicText( DrawPanel, DC, wxPoint( Field->m_Pos.x, -Field->m_Pos.y ),
color, Field->m_Text,
color, ReturnFieldFullText( Field ),
Field->m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ,
Field->m_Size,
Field->m_HJustify, Field->m_VJustify, LineWidth );
......@@ -300,7 +328,7 @@ void WinEDA_LibeditFrame::RotateField( wxDC* DC, LibDrawField* Field )
GRSetDrawMode( DC, GR_DEFAULT_DRAWMODE );
DrawGraphicText( DrawPanel, DC, wxPoint( Field->m_Pos.x, -Field->m_Pos.y ),
color, Field->m_Text,
color, ReturnFieldFullText( Field ),
Field->m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ,
Field->m_Size,
Field->m_HJustify, Field->m_VJustify, LineWidth );
......
......@@ -71,7 +71,7 @@ void WinEDA_SchematicFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
}
else
{
DrawStruct = SchematicGeneralLocateAndDisplay();
DrawStruct = SchematicGeneralLocateAndDisplay(true);
}
}
......
......@@ -78,10 +78,9 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos,
return true;
}
// Simple localisation des elements si possible
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{
DrawStruct = SchematicGeneralLocateAndDisplay( FALSE );
{ // Just try to locate items at cursor position
DrawStruct = SchematicGeneralLocateAndDisplay( false );
if( DrawStruct && (DrawStruct->Type() == DRAW_SHEET_STRUCT_TYPE) )
{
Hierarchical_PIN_Sheet_Struct* slabel;
......@@ -92,7 +91,7 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos,
}
}
// If Command in progress: put the menu "cancel" and "end tool"
// If Command in progress: add "cancel" and "end tool" menu
if( m_ID_current_state )
{
if( DrawStruct && DrawStruct->m_Flags )
......
......@@ -9,6 +9,7 @@
#include "fctsys.h"
#include "gr_basic.h"
#include "appl_wxstruct.h"
#include "common.h"
#include "class_drawpanel.h"
#include "confirm.h"
......@@ -54,8 +55,10 @@ void WinEDA_LibeditFrame::LoadOneSymbol( void )
DrawPanel->m_IgnoreMouseEvents = TRUE;
mask = wxT( "*" ) + g_SymbolExtBuffer;
wxString default_lib_path = wxGetApp().ReturnLastVisitedLibraryPath();
FullFileName = EDA_FileSelector( _( "Import symbol drawings:" ),
g_RealLibDirBuffer, /* Chemin par defaut */
default_lib_path, /* Chemin par defaut */
wxEmptyString, /* nom fichier par defaut */
g_SymbolExtBuffer, /* extension par defaut */
mask, /* Masque d'affichage */
......@@ -71,6 +74,8 @@ void WinEDA_LibeditFrame::LoadOneSymbol( void )
if( FullFileName.IsEmpty() )
return;
wxFileName fn = FullFileName;
wxGetApp().SaveLastVisitedLibraryPath(fn.GetPath() );
/* Load data */
ImportFile = wxFopen( FullFileName, wxT( "rt" ) );
......@@ -159,9 +164,10 @@ void WinEDA_LibeditFrame::SaveOneSymbol()
return;
/* Creation du fichier symbole */
wxString default_lib_path = wxGetApp().ReturnLastVisitedLibraryPath();
mask = wxT( "*" ) + g_SymbolExtBuffer;
FullFileName = EDA_FileSelector( _( "Export symbol drawings:" ),
g_RealLibDirBuffer, /* Chemin par defaut */
default_lib_path, /* Chemin par defaut */
wxEmptyString, /* nom fichier par defaut */
g_SymbolExtBuffer, /* extension par defaut */
mask, /* Masque d'affichage */
......@@ -172,6 +178,9 @@ void WinEDA_LibeditFrame::SaveOneSymbol()
if( FullFileName.IsEmpty() )
return;
wxFileName fn = FullFileName;
wxGetApp().SaveLastVisitedLibraryPath(fn.GetPath() );
ExportFile = wxFopen( FullFileName, wxT( "wt" ) );
if( ExportFile == NULL )
{
......
......@@ -124,7 +124,7 @@ void WinEDA_ViewlibFrame::DisplayLibInfos()
msg << wxT( " [" );
if( Lib )
msg << g_CurrentViewLibraryName;
msg << Lib->m_FullFileName;
else
msg += _( "none selected" );
......
......@@ -86,7 +86,7 @@ public:
/** Function InitEDA_Appl
* initialise some general parameters
* - Default paths (help, libs, bin)and configuration flies names
* - Default paths (help, libs, bin)and configuration files names
* - Language and locale
* - fonts
* @param aName : used as paths in configuration files
......@@ -157,12 +157,32 @@ public:
wxPathList& GetLibraryPathList() { return m_libSearchPaths; }
wxString FindLibraryPath( const wxString& fileName );
/** FindLibraryPath
* Kicad saves user defined library files that are not in the standard
* library search path list with the full file path. Calling the library
* search path list with a user library file will fail. This helper method
* solves that problem.
* @param fileName
* @return a wxEmptyString if library file is not found.
*/
wxString FindLibraryPath( const wxFileName& fileName )
{
return FindLibraryPath( fileName.GetFullPath() );
}
/** ReturnLastVisitedLibraryPath
* Returns the last visited library directory, or (if void) the first
* path in lib path list ( but not the CWD )
* @param aSubPathToSearch = Prefered sub path to search in path list
*/
wxString ReturnLastVisitedLibraryPath( const wxString & aSubPathToSearch = wxEmptyString);
void SaveLastVisitedLibraryPath( const wxString & aPath);
/** Function RemoveLibraryPath
* Removes the given ptah from the libary path list
* @param path = the path to remove
*/
void RemoveLibraryPath( const wxString& path );
void InsertLibraryPath( const wxString& path, size_t index );
};
......
......@@ -146,12 +146,8 @@ extern Ki_PageDescr* g_SheetSizeList[];
extern wxString g_ProductName;
/* Gestion des librairies */
extern wxString g_RealLibDirBuffer; // Chemin reel des librairies de module
// = UserLibDirBuffer si non vide
// = chemin par defaut sinon
extern wxString g_UserLibDirBuffer; // Chemin des librairies de module donne par
// le file de config
/* Default user lib path can be left void, if the standard lib path is used */
extern wxString g_UserLibDirBuffer;
extern int g_DebugLevel; // 0= Pas de debug */
extern int g_MouseOldButtons;
......
......@@ -187,15 +187,6 @@ void GRSRect(EDA_Rect * ClipBox, wxDC * DC, int x1, int y1,
void GRSRect(EDA_Rect * ClipBox, wxDC * DC, int x1, int y1,
int x2, int y2, int width, int Color);
/* Routines relatives a l'affichage des textes */
void GRSetFont(wxDC * DC, wxFont * Font);
void GRResetTextFgColor(wxDC * DC);
void GRSetTextFgColor(wxDC * DC, int Color);
void GRSetTextFgColor(wxDC * DC, wxFont * Font, int Color);
int GRGetTextFgColor(wxDC * DC, wxFont * Font);
void GRSetTextBgColor(wxDC * DC, int Color);
void GRSetTextBgColor(wxDC * DC, wxFont * Font, int Color);
int GRGetTextBgColor(wxDC * DC, wxFont * Font);
#endif /* define GR_BASIC */
......@@ -5,6 +5,7 @@
/************************************************/
#include "confirm.h"
#include "appl_wxstruct.h"
#include "dialog_edit_module.h"
#include <wx/version.h>
......@@ -484,10 +485,10 @@ void Panel3D_Ctrl::Browse3DLib( wxCommandEvent& event )
/***************************************************/
{
wxString fullfilename, shortfilename;
wxString fullpath = g_RealLibDirBuffer;
wxString fullpath;
wxString mask = wxT( "*" );
fullpath += LIB3D_PATH;
fullpath = wxGetApp().ReturnLastVisitedLibraryPath(LIB3D_PATH);
mask += g_Shapes3DExtBuffer;
#ifdef __WINDOWS__
fullpath.Replace( wxT( "/" ), wxT( "\\" ) );
......
......@@ -168,7 +168,7 @@ void WinEDA_ModuleEditFrame::Export_Module( MODULE* ptmod, bool createlib )
fn.SetExt( createlib ? ModuleFileExtension : ModExportFileExtension );
if( createlib )
path = g_RealLibDirBuffer;
path = wxGetApp().ReturnLastVisitedLibraryPath();
else if( Config )
Config->Read( EXPORT_IMPORT_LASTPATH_KEY, &path );
......@@ -182,6 +182,7 @@ void WinEDA_ModuleEditFrame::Export_Module( MODULE* ptmod, bool createlib )
return;
fn = dlg.GetPath();
wxGetApp().SaveLastVisitedLibraryPath( fn.GetPath() );
/* Generation du fichier Empreinte */
if( ( file = wxFopen( fn.GetFullPath(), wxT( "wt" ) ) ) == NULL )
......@@ -401,7 +402,7 @@ void WinEDA_BasePcbFrame::Archive_Modules( const wxString& LibName,
int ii, NbModules = 0;
float Pas;
MODULE* Module;
wxString fileName = LibName;
wxString fileName = LibName, path;
if( GetBoard()->m_Modules == NULL )
{
......@@ -409,9 +410,10 @@ void WinEDA_BasePcbFrame::Archive_Modules( const wxString& LibName,
return;
}
path = wxGetApp().ReturnLastVisitedLibraryPath();
if( LibName.IsEmpty() )
{
wxFileDialog dlg( this, _( "Library" ), g_RealLibDirBuffer,
wxFileDialog dlg( this, _( "Library" ), path,
wxEmptyString, ModuleFileWildcard,
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
......@@ -421,6 +423,8 @@ void WinEDA_BasePcbFrame::Archive_Modules( const wxString& LibName,
fileName = dlg.GetPath();
}
wxFileName fn(fileName);
wxGetApp().SaveLastVisitedLibraryPath( fn.GetPath() );
bool file_exists = wxFileExists( fileName );
if( !NewModulesOnly && file_exists )
......
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