Commit 0f54a686 authored by charras's avatar charras

Solved: eeschema crashes when create a new sheet. Added comments in...

Solved: eeschema crashes when create a new sheet. Added comments in gestfich.cpp to explain the default paths used by kicad to find help files and lib files
parent 8d9b8a98
...@@ -5,6 +5,15 @@ Started 2007-June-11 ...@@ -5,6 +5,15 @@ Started 2007-June-11
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.
2008-Mar-30 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================
+eeschema
Solved: eeschema crashes when create a new sheet, using the default filename and enter it.
+all:
Added comments in gestfich.cpp to explain the default paths used by kicad to find help files and lib files
2008-Mar-30 UPDATE Jonas Diemer <diemer-at-gmx.de> 2008-Mar-30 UPDATE Jonas Diemer <diemer-at-gmx.de>
================================================================================ ================================================================================
+eeschema +eeschema
......
...@@ -32,6 +32,37 @@ ...@@ -32,6 +32,37 @@
#include "wxstruct.h" #include "wxstruct.h"
#include "macros.h" #include "macros.h"
/* List of default paths used to locate help files and kicad library files.
*
* Under windows, kicad search its files from the binary path file (first argument when running "main")
* So for a standard install, default paths are not mandatory, but they exist, just in case.
* kicad is often installed in c:/Program Files/kicad or c:/kicad (or d: or e: ... )
* and the directory "share" has no meaning under windows.
*
* Under linux, the problem is more complex.
* In fact there are 3 cases:
* 1 - When released in a distribution:
* binaries are in /usr/bin, kicad libs in /usr/share/kicad/ and doc in /usr/share/doc/kicad/
* 2 - When compiled by an user:
* binaries also can be in /usr/local/bin, kicad libs in /usr/local/share/kicad/ and doc in /usr/local/share/doc/kicad/
* 3 - When in an "universal tarball" or build for a server:
* all files are in /usr/local/kicad
* This is mandatory when kicad is installed on a server (in a school for instance) because one can export /usr/local/kicad
* and obviously the others paths cannot be used
* (cannot be mounted by the client, because they are already used).
*
* in cases 1 and 2 kicad files cannot be found from the binary path.
* in case 3 kicad files can be found from the binary path only if this is a kicad binary file which is launched.
* But if an user creates a symbolic link to the actual binary file to run kicad, the binary path is not good
* and the defaults paths must be used
*
* Note:
* kicad uses first the bin path lo locace kicad tree.
* if not found kicad uses the environment variable KICAD to find its files
* and at last kicad uses the default paths.
* So we can export (linux and windows) the variable KICAD:
* like export KICAD=/my_path/kicad if /my_path/kicad is not a default path
*/
// Path list for online help // Path list for online help
static wxString s_HelpPathList[] = { static wxString s_HelpPathList[] = {
...@@ -43,29 +74,28 @@ static wxString s_HelpPathList[] = { ...@@ -43,29 +74,28 @@ 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/share/doc/kicad/" ), // TODO: must be removed wxT( "/usr/local/kicad/" ), // default install for "universal tarballs" and build for a server
#endif #endif
wxT( "end_list" ) // End of list symbol, do not change wxT( "end_list" ) // End of list symbol, do not change
}; };
// Path list for kicad data files // Path list for kicad data files
static wxString s_KicadDataPathList[] = { static wxString s_KicadDataPathList[] = {
#ifdef __WINDOWS__ #ifdef __WINDOWS__
wxT( "c:/kicad/" ), // TODO: must be removed wxT( "c:/kicad/" ),
wxT( "d:/kicad/" ), // TODO: must be removed wxT( "d:/kicad/" ),
wxT( "c:/kicad/share/" ), wxT( "c:/kicad/share/" ),
wxT( "d:/kicad/share/" ), wxT( "d:/kicad/share/" ),
wxT( "c:/Program Files/kicad/" ), // TODO: must be removed wxT( "c:/Program Files/kicad/" ),
wxT( "d:/Program Files/kicad/" ), // TODO: must be removed wxT( "d:/Program Files/kicad/" ),
wxT( "c:/Program Files/kicad/share/" ), wxT( "c:/Program Files/kicad/share/" ),
wxT( "d:/Program Files/kicad/share/" ), wxT( "d:/Program Files/kicad/share/" ),
#else #else
wxT( "/usr/share/kicad/" ), wxT( "/usr/share/kicad/" ),
wxT( "/usr/local/share/kicad/" ), wxT( "/usr/local/share/kicad/" ),
wxT( "/usr/local/kicad/share/kicad/" ), // TODO: must be removed wxT( "/usr/local/kicad/" ), // default install for "universal tarballs" and build for a server
wxT( "/usr/local/kicad/" ), // TODO: must be removed
#endif #endif
wxT( "end_list" ) // End of list symbol, do not change wxT( "end_list" ) // End of list symbol, do not change
}; };
// Path list for kicad binary files // Path list for kicad binary files
...@@ -73,20 +103,20 @@ static wxString s_KicadBinaryPathList[] = { ...@@ -73,20 +103,20 @@ static wxString s_KicadBinaryPathList[] = {
#ifdef __WINDOWS__ #ifdef __WINDOWS__
wxT( "c:/kicad/bin/" ), wxT( "c:/kicad/bin/" ),
wxT( "d:/kicad/bin/" ), wxT( "d:/kicad/bin/" ),
wxT( "c:/kicad/winexe/" ), // TODO: must be removed wxT( "c:/kicad/winexe/" ), // TODO: must be removed
wxT( "d:/kicad/winexe/" ), // TODO: must be removed wxT( "d:/kicad/winexe/" ), // TODO: must be removed
wxT( "c:/Program Files/kicad/bin/" ), wxT( "c:/Program Files/kicad/bin/" ),
wxT( "d:/Program Files/kicad/bin/" ), wxT( "d:/Program Files/kicad/bin/" ),
wxT( "c:/Program Files/kicad/winexe/" ), // TODO: must be removed wxT( "c:/Program Files/kicad/winexe/" ), // TODO: must be removed
wxT( "d:/Program Files/kicad/winexe/" ), // TODO: must be removed wxT( "d:/Program Files/kicad/winexe/" ), // TODO: must be removed
#else #else
wxT( "/usr/bin/" ), wxT( "/usr/bin/" ),
wxT( "/usr/local/bin/" ), wxT( "/usr/local/bin/" ),
wxT( "/usr/local/kicad/bin/" ), wxT( "/usr/local/kicad/bin/" ),
wxT( "/usr/local/kicad/linux/" ), // TODO: must be removed wxT( "/usr/local/kicad/linux/" ), // TODO: must be removed
wxT( "/usr/local/kicad/linux-non_unicode/" ), // TODO: must be removed wxT( "/usr/local/kicad/linux-non_unicode/" ), // TODO: must be removed
#endif #endif
wxT( "end_list" ) // End of list symbol, do not change wxT( "end_list" ) // End of list symbol, do not change
}; };
extern WinEDA_App* g_EDA_Appl; extern WinEDA_App* g_EDA_Appl;
...@@ -124,6 +154,7 @@ wxString MakeReducedFileName( const wxString& fullfilename, ...@@ -124,6 +154,7 @@ wxString MakeReducedFileName( const wxString& fullfilename,
path.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP ); path.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );
#ifdef __WINDOWS__ #ifdef __WINDOWS__
// names are case insensitive under windows // names are case insensitive under windows
path.MakeLower(); path.MakeLower();
Cwd.MakeLower(); Cwd.MakeLower();
...@@ -182,14 +213,14 @@ wxString MakeFileName( const wxString& dir, ...@@ -182,14 +213,14 @@ wxString MakeFileName( const wxString& dir,
{ {
if( !wxIsAbsolutePath( shortname ) ) if( !wxIsAbsolutePath( shortname ) )
{ {
if( ! shortname.StartsWith(wxT("./")) && ! shortname.StartsWith(wxT("../")) ) if( !shortname.StartsWith( wxT( "./" ) ) && !shortname.StartsWith( wxT( "../" ) ) )
{ /* no absolute path in shortname, add dir to shortname */ { /* no absolute path in shortname, add dir to shortname */
fullfilename = dir; fullfilename = dir;
} }
} }
} }
fullfilename += shortname; // Add shortname to dir or use shortname only fullfilename += shortname; // Add shortname to dir or use shortname only
fullfilename.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP ); fullfilename.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );
...@@ -207,7 +238,7 @@ wxString MakeFileName( const wxString& dir, ...@@ -207,7 +238,7 @@ wxString MakeFileName( const wxString& dir,
fullfilename += ext; fullfilename += ext;
break; break;
} }
if( fullfilename.GetChar( ii ) == '.' ) /* extension exists, do nothing */ if( fullfilename.GetChar( ii ) == '.' ) /* extension exists, do nothing */
break; break;
} }
...@@ -317,25 +348,26 @@ wxString EDA_FileSelector( const wxString& Title, /* Dialog ti ...@@ -317,25 +348,26 @@ wxString EDA_FileSelector( const wxString& Title, /* Dialog ti
wxSetWorkingDirectory( defaultpath ); wxSetWorkingDirectory( defaultpath );
#if 0 && defined(DEBUG) #if 0 && defined (DEBUG)
printf("defaultpath=\"%s\" defaultname=\"%s\" Ext=\"%s\" Mask=\"%s\" flag=%d keep_working_directory=%d\n", printf(
CONV_TO_UTF8(defaultpath), "defaultpath=\"%s\" defaultname=\"%s\" Ext=\"%s\" Mask=\"%s\" flag=%d keep_working_directory=%d\n",
CONV_TO_UTF8(defaultname), CONV_TO_UTF8( defaultpath ),
CONV_TO_UTF8(Ext), CONV_TO_UTF8( defaultname ),
CONV_TO_UTF8(Mask), CONV_TO_UTF8( Ext ),
flag, CONV_TO_UTF8( Mask ),
keep_working_directory flag,
); keep_working_directory
);
#endif #endif
fullfilename = wxFileSelector( wxString( Title ), fullfilename = wxFileSelector( wxString( Title ),
defaultpath, defaultpath,
defaultname, defaultname,
Ext, Ext,
Mask, Mask,
flag,/* open mode wxFD_OPEN, wxFD_SAVE .. */ flag, /* open mode wxFD_OPEN, wxFD_SAVE .. */
Frame, Frame,
Pos.x, Pos.y ); Pos.x, Pos.y );
if( keep_working_directory ) if( keep_working_directory )
wxSetWorkingDirectory( curr_cwd ); wxSetWorkingDirectory( curr_cwd );
...@@ -347,6 +379,7 @@ wxString EDA_FileSelector( const wxString& Title, /* Dialog ti ...@@ -347,6 +379,7 @@ wxString EDA_FileSelector( const wxString& Title, /* Dialog ti
/********************************************************/ /********************************************************/
wxString FindKicadHelpPath() wxString FindKicadHelpPath()
/********************************************************/ /********************************************************/
/** Function FindKicadHelpPath /** Function FindKicadHelpPath
* Find an absolute path for KiCad "help" (or "help/<language>") * Find an absolute path for KiCad "help" (or "help/<language>")
* Find path kicad/doc/help/xx/ or kicad/doc/help/: * Find path kicad/doc/help/xx/ or kicad/doc/help/:
...@@ -371,6 +404,7 @@ wxString FindKicadHelpPath() ...@@ -371,6 +404,7 @@ wxString FindKicadHelpPath()
wxString FullPath, LangFullPath, tmp; wxString FullPath, LangFullPath, tmp;
wxString LocaleString; wxString LocaleString;
bool PathFound = FALSE; bool PathFound = FALSE;
/* find kicad/help/ */ /* find kicad/help/ */
tmp = g_EDA_Appl->m_BinDir; tmp = g_EDA_Appl->m_BinDir;
if( tmp.Last() == '/' ) if( tmp.Last() == '/' )
...@@ -378,7 +412,7 @@ wxString FindKicadHelpPath() ...@@ -378,7 +412,7 @@ wxString FindKicadHelpPath()
FullPath = tmp.BeforeLast( '/' ); // cd .. FullPath = tmp.BeforeLast( '/' ); // cd ..
FullPath += wxT( "/help/" ); FullPath += wxT( "/help/" );
LocaleString = g_EDA_Appl->m_Locale->GetCanonicalName(); LocaleString = g_EDA_Appl->m_Locale->GetCanonicalName();
wxString path_tmp = FullPath; wxString path_tmp = FullPath;
#ifdef __WINDOWS__ #ifdef __WINDOWS__
path_tmp.MakeLower(); path_tmp.MakeLower();
...@@ -576,7 +610,7 @@ wxString ReturnKicadDatasPath() ...@@ -576,7 +610,7 @@ wxString ReturnKicadDatasPath()
} }
else // Chemin cherche par le chemin des executables else // Chemin cherche par le chemin des executables
{ {
// le chemin est bindir../ // le chemin est bindir../
wxString tmp = g_EDA_Appl->m_BinDir; wxString tmp = g_EDA_Appl->m_BinDir;
#ifdef __WINDOWS__ #ifdef __WINDOWS__
tmp.MakeLower(); tmp.MakeLower();
...@@ -643,14 +677,14 @@ wxString GetEditorName() ...@@ -643,14 +677,14 @@ wxString GetEditorName()
mask += wxT( ".exe" ); mask += wxT( ".exe" );
#endif #endif
editorname = EDA_FileSelector( _( "Prefered Editor:" ), editorname = EDA_FileSelector( _( "Prefered Editor:" ),
wxEmptyString, /* Default path */ wxEmptyString, /* Default path */
wxEmptyString, /* default filename */ wxEmptyString, /* default filename */
wxEmptyString, /* default filename extension */ wxEmptyString, /* default filename extension */
mask, /* filter for filename list */ mask, /* filter for filename list */
NULL, /* parent frame */ NULL, /* parent frame */
wxFD_OPEN, /* wxFD_SAVE, wxFD_OPEN ..*/ wxFD_OPEN, /* wxFD_SAVE, wxFD_OPEN ..*/
TRUE /* true = keep the current path */ TRUE /* true = keep the current path */
); );
} }
if( ( !editorname.IsEmpty() ) && g_EDA_Appl->m_EDA_CommonConfig ) if( ( !editorname.IsEmpty() ) && g_EDA_Appl->m_EDA_CommonConfig )
......
...@@ -372,8 +372,8 @@ bool DrawSheetStruct::LocatePathOfScreen( SCH_SCREEN* screen, DrawSheetPath* lis ...@@ -372,8 +372,8 @@ bool DrawSheetStruct::LocatePathOfScreen( SCH_SCREEN* screen, DrawSheetPath* lis
{ {
//search the existing hierarchy for an instance of screen "FileName". //search the existing hierarchy for an instance of screen "FileName".
//don't bother looking at the root sheet - it must be unique, //don't bother looking at the root sheet - it must be unique,
//no other references to its m_s otherwise there would be loops //no other references to its m_AssociatedScreen otherwise there would be loops
//in the heirarchy. //in the hierarchy.
//search the existing hierarchy for an instance of screen "FileName". //search the existing hierarchy for an instance of screen "FileName".
if( m_AssociatedScreen ) if( m_AssociatedScreen )
{ {
...@@ -482,7 +482,7 @@ void DrawSheetStruct::SetFileName( const wxString& aFilename ) ...@@ -482,7 +482,7 @@ void DrawSheetStruct::SetFileName( const wxString& aFilename )
* Set a new filename and manage data and associated screen * Set a new filename and manage data and associated screen
* The main difficulty is the filename change in a complex hierarchy. * The main difficulty is the filename change in a complex hierarchy.
* - if new filename is not already used: change to the new name (and if an existing file is found, load it on request) * - if new filename is not already used: change to the new name (and if an existing file is found, load it on request)
* - if new filename is already used (a complex hierarchy) : reference the sheet. * - if new filename is already used (a complex hierarchy) : reference the sheet.
*/ */
bool DrawSheetStruct::ChangeFileName( WinEDA_SchematicFrame * aFrame, const wxString& aFileName ) bool DrawSheetStruct::ChangeFileName( WinEDA_SchematicFrame * aFrame, const wxString& aFileName )
......
...@@ -99,11 +99,11 @@ WinEDA_SheetPropertiesFrame::WinEDA_SheetPropertiesFrame( WinEDA_SchematicFrame* ...@@ -99,11 +99,11 @@ WinEDA_SheetPropertiesFrame::WinEDA_SheetPropertiesFrame( WinEDA_SchematicFrame*
AddUnitSymbol( *m_SheetNameTextSize ); AddUnitSymbol( *m_SheetNameTextSize );
PutValueInLocalUnits( *m_SheetNameSize, m_CurrentSheet->m_SheetNameSize, PutValueInLocalUnits( *m_SheetNameSize, m_CurrentSheet->m_SheetNameSize,
m_Parent->m_InternalUnits ); m_Parent->m_InternalUnits );
AddUnitSymbol( *m_FileNameTextSize ); AddUnitSymbol( *m_FileNameTextSize );
PutValueInLocalUnits( *m_FileNameSize, m_CurrentSheet->m_FileNameSize, PutValueInLocalUnits( *m_FileNameSize, m_CurrentSheet->m_FileNameSize,
m_Parent->m_InternalUnits ); m_Parent->m_InternalUnits );
} }
...@@ -163,55 +163,55 @@ void WinEDA_SheetPropertiesFrame::CreateControls() ...@@ -163,55 +163,55 @@ void WinEDA_SheetPropertiesFrame::CreateControls()
itemBoxSizer3->Add( itemBoxSizer4, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); itemBoxSizer3->Add( itemBoxSizer4, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
wxStaticText* itemStaticText5 = new wxStaticText( itemDialog1, wxID_STATIC, _( wxStaticText* itemStaticText5 = new wxStaticText( itemDialog1, wxID_STATIC, _(
"Filename:" ), wxDefaultPosition, "Filename:" ), wxDefaultPosition,
wxDefaultSize, 0 ); wxDefaultSize, 0 );
itemBoxSizer4->Add( itemStaticText5, itemBoxSizer4->Add( itemStaticText5,
0, 0,
wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE,
5 ); 5 );
m_FileNameWin = m_FileNameWin =
new wxTextCtrl( itemDialog1, ID_TEXTCTRL1, _T( "" ), wxDefaultPosition, wxSize( 300, new wxTextCtrl( itemDialog1, ID_TEXTCTRL1, _T( "" ), wxDefaultPosition, wxSize( 300,
-1 ), -1 ),
wxTE_PROCESS_ENTER ); wxTE_PROCESS_ENTER );
itemBoxSizer4->Add( m_FileNameWin, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM, 5 ); itemBoxSizer4->Add( m_FileNameWin, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
wxStaticText* itemStaticText7 = new wxStaticText( itemDialog1, wxID_STATIC, _( wxStaticText* itemStaticText7 = new wxStaticText( itemDialog1, wxID_STATIC, _(
"Sheetname:" ), wxDefaultPosition, "Sheetname:" ), wxDefaultPosition,
wxDefaultSize, 0 ); wxDefaultSize, 0 );
itemBoxSizer4->Add( itemStaticText7, itemBoxSizer4->Add( itemStaticText7,
0, 0,
wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE,
5 ); 5 );
m_SheetNameWin = m_SheetNameWin =
new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T( "" ), wxDefaultPosition, wxSize( 300, new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T( "" ), wxDefaultPosition, wxSize( 300,
-1 ), 0 ); -1 ), 0 );
itemBoxSizer4->Add( m_SheetNameWin, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM, 5 ); itemBoxSizer4->Add( m_SheetNameWin, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
wxBoxSizer* itemBoxSizer9 = new wxBoxSizer( wxVERTICAL ); wxBoxSizer* itemBoxSizer9 = new wxBoxSizer( wxVERTICAL );
itemBoxSizer3->Add( itemBoxSizer9, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); itemBoxSizer3->Add( itemBoxSizer9, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
m_FileNameTextSize = new wxStaticText( itemDialog1, wxID_STATIC, _( m_FileNameTextSize = new wxStaticText( itemDialog1, wxID_STATIC, _(
"Size" ), wxDefaultPosition, wxDefaultSize, 0 ); "Size" ), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer9->Add( m_FileNameTextSize, itemBoxSizer9->Add( m_FileNameTextSize,
0, 0,
wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE,
5 ); 5 );
m_FileNameSize = new wxTextCtrl( itemDialog1, ID_TEXTCTRL2, _T( m_FileNameSize = new wxTextCtrl( itemDialog1, ID_TEXTCTRL2, _T(
"" ), wxDefaultPosition, wxDefaultSize, 0 ); "" ), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer9->Add( m_FileNameSize, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM, 5 ); itemBoxSizer9->Add( m_FileNameSize, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
m_SheetNameTextSize = new wxStaticText( itemDialog1, wxID_STATIC, _( m_SheetNameTextSize = new wxStaticText( itemDialog1, wxID_STATIC, _(
"Size" ), wxDefaultPosition, wxDefaultSize, 0 ); "Size" ), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer9->Add( m_SheetNameTextSize, itemBoxSizer9->Add( m_SheetNameTextSize,
0, 0,
wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE,
5 ); 5 );
m_SheetNameSize = new wxTextCtrl( itemDialog1, ID_TEXTCTRL3, _T( m_SheetNameSize = new wxTextCtrl( itemDialog1, ID_TEXTCTRL3, _T(
"" ), wxDefaultPosition, wxDefaultSize, 0 ); "" ), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer9->Add( m_SheetNameSize, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM, 5 ); itemBoxSizer9->Add( m_SheetNameSize, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
itemBoxSizer2->Add( 5, 5, 1, wxGROW | wxALL, 5 ); itemBoxSizer2->Add( 5, 5, 1, wxGROW | wxALL, 5 );
...@@ -220,12 +220,12 @@ void WinEDA_SheetPropertiesFrame::CreateControls() ...@@ -220,12 +220,12 @@ void WinEDA_SheetPropertiesFrame::CreateControls()
itemBoxSizer2->Add( itemBoxSizer15, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5 ); itemBoxSizer2->Add( itemBoxSizer15, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5 );
wxButton* itemButton16 = new wxButton( itemDialog1, wxID_CANCEL, _( wxButton* itemButton16 = new wxButton( itemDialog1, wxID_CANCEL, _(
"&Cancel" ), wxDefaultPosition, wxDefaultSize, 0 ); "&Cancel" ), wxDefaultPosition, wxDefaultSize, 0 );
itemButton16->SetForegroundColour( wxColour( 0, 0, 255 ) ); itemButton16->SetForegroundColour( wxColour( 0, 0, 255 ) );
itemBoxSizer15->Add( itemButton16, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); itemBoxSizer15->Add( itemButton16, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
wxButton* itemButton17 = new wxButton( itemDialog1, wxID_OK, _( wxButton* itemButton17 = new wxButton( itemDialog1, wxID_OK, _(
"&OK" ), wxDefaultPosition, wxDefaultSize, 0 ); "&OK" ), wxDefaultPosition, wxDefaultSize, 0 );
itemButton17->SetForegroundColour( wxColour( 196, 0, 0 ) ); itemButton17->SetForegroundColour( wxColour( 196, 0, 0 ) );
itemBoxSizer15->Add( itemButton17, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); itemBoxSizer15->Add( itemButton17, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
...@@ -300,29 +300,36 @@ void WinEDA_SheetPropertiesFrame::SheetPropertiesAccept( wxCommandEvent& event ) ...@@ -300,29 +300,36 @@ void WinEDA_SheetPropertiesFrame::SheetPropertiesAccept( wxCommandEvent& event )
} }
ChangeFileNameExt( FileName, g_SchExtBuffer ); ChangeFileNameExt( FileName, g_SchExtBuffer );
if ( (FileName != m_CurrentSheet->GetFileName()) )
{ /* m_CurrentSheet->m_AssociatedScreen must be a valide screen, and the sheet must have a valid associated filename,
msg = _("Changing a Filename can change all the schematic structure and cannot be undone" ); * so we must call m_CurrentSheet->ChangeFileName to set a filename,
msg << wxT("\n"); * AND always when a new sheet is created ( when m_CurrentSheet->m_AssociatedScreen is null ),
msg << _("Ok to continue renaming?"); * to create or set an Associated Screen
if( m_CurrentSheet->m_AssociatedScreen == 0 || IsOK( NULL, msg) ) */
{ //do not prompt on a new sheet. in fact, we should not allow a sheet to be created if( ( FileName != m_CurrentSheet->GetFileName() )
//without a valid associated filename to be read from. || ( m_CurrentSheet->m_AssociatedScreen == NULL) )
m_Parent->GetScreen()->ClearUndoRedoList(); {
m_CurrentSheet->ChangeFileName(m_Parent, FileName); msg = _( "Changing a Filename can change all the schematic structure and cannot be undone" );
} msg << wxT( "\n" );
} msg << _( "Ok to continue renaming?" );
if( m_CurrentSheet->m_AssociatedScreen == NULL || IsOK( NULL, msg ) )
{ //do not prompt on a new sheet. in fact, we should not allow a sheet to be created
//without a valid associated filename to be read from.
m_Parent->GetScreen()->ClearUndoRedoList();
m_CurrentSheet->ChangeFileName( m_Parent, FileName ); // set filename and the associated screen
}
}
msg = m_FileNameSize->GetValue(); msg = m_FileNameSize->GetValue();
m_CurrentSheet->m_FileNameSize = m_CurrentSheet->m_FileNameSize =
ReturnValueFromString( g_UnitMetric, ReturnValueFromString( g_UnitMetric,
msg, m_Parent->m_InternalUnits ); msg, m_Parent->m_InternalUnits );
m_CurrentSheet->m_SheetName = m_SheetNameWin->GetValue(); m_CurrentSheet->m_SheetName = m_SheetNameWin->GetValue();
msg = m_SheetNameSize->GetValue(); msg = m_SheetNameSize->GetValue();
m_CurrentSheet->m_SheetNameSize = m_CurrentSheet->m_SheetNameSize =
ReturnValueFromString( g_UnitMetric, ReturnValueFromString( g_UnitMetric,
msg, m_Parent->m_InternalUnits ); msg, m_Parent->m_InternalUnits );
if( ( m_CurrentSheet->m_SheetName.IsEmpty() ) ) if( ( m_CurrentSheet->m_SheetName.IsEmpty() ) )
{ {
...@@ -422,8 +429,8 @@ void WinEDA_SchematicFrame::ReSizeSheet( DrawSheetStruct* Sheet, wxDC* DC ) ...@@ -422,8 +429,8 @@ void WinEDA_SchematicFrame::ReSizeSheet( DrawSheetStruct* Sheet, wxDC* DC )
while( sheetlabel ) while( sheetlabel )
{ {
s_SheetMindx = MAX( s_SheetMindx, s_SheetMindx = MAX( s_SheetMindx,
(int) ( (sheetlabel->GetLength() + (int) ( (sheetlabel->GetLength() +
1) * sheetlabel->m_Size.x ) ); 1) * sheetlabel->m_Size.x ) );
s_SheetMindy = MAX( s_SheetMindy, sheetlabel->m_Pos.y - Sheet->m_Pos.y ); s_SheetMindy = MAX( s_SheetMindy, sheetlabel->m_Pos.y - Sheet->m_Pos.y );
sheetlabel = (DrawSheetLabelStruct*) sheetlabel->Pnext; sheetlabel = (DrawSheetLabelStruct*) sheetlabel->Pnext;
} }
...@@ -475,9 +482,9 @@ static void DeplaceSheet( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) ...@@ -475,9 +482,9 @@ static void DeplaceSheet( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
if( Sheet->m_Flags & IS_RESIZED ) if( Sheet->m_Flags & IS_RESIZED )
{ {
Sheet->m_Size.x = MAX( s_SheetMindx, Sheet->m_Size.x = MAX( s_SheetMindx,
screen->m_Curseur.x - Sheet->m_Pos.x ); screen->m_Curseur.x - Sheet->m_Pos.x );
Sheet->m_Size.y = MAX( s_SheetMindy, Sheet->m_Size.y = MAX( s_SheetMindy,
screen->m_Curseur.y - Sheet->m_Pos.y ); screen->m_Curseur.y - Sheet->m_Pos.y );
SheetLabel = Sheet->m_Label; SheetLabel = Sheet->m_Label;
while( SheetLabel ) while( SheetLabel )
{ {
......
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