Commit cd0b2316 authored by Wayne Stambaugh's avatar Wayne Stambaugh

Minor fixes, dead code removal, and coding policy fixes.

* Use version of DateAndTime that returns a wxString and delete the
  version that takes a char* as it is no longer required.
* Merge StrNumICmp() and StrLenNumICmp() into StrLenNumCmp() to create a
  single function for comparing strings with integers and remove a lot
  of duplicate code.
* Remove unused strupper from string.cpp.
* Use wxArrayString for sorting the EDA_LIST_DIALOG contents.
parent b88505dd
......@@ -42,9 +42,9 @@ BASE_SCREEN::BASE_SCREEN( KICAD_T aType ) : EDA_ITEM( aType )
{
m_drawList = NULL; /* Draw items list */
m_UndoRedoCountMax = 10; /* undo/Redo command Max depth, 10 is a reasonable value */
m_FirstRedraw = TRUE;
m_FirstRedraw = true;
m_ScreenNumber = 1;
m_NumberOfScreen = 1; /* Hierarchy: Root: ScreenNumber = 1 */
m_NumberOfScreen = 1; /* Hierarchy: Root: ScreenNumber = 1 */
m_Zoom = 32.0;
m_Grid.m_Size = wxRealPoint( 50, 50 ); /* Default grid size */
m_Grid.m_Id = ID_POPUP_GRID_LEVEL_50;
......
......@@ -44,8 +44,6 @@ void GERBER_PLOTTER::set_viewport( wxPoint aOffset, double aScale, bool aMirror
*/
bool GERBER_PLOTTER::start_plot( FILE* aFile )
{
char Line[1024];
wxASSERT( !output_file );
final_file = aFile;
......@@ -59,9 +57,9 @@ bool GERBER_PLOTTER::start_plot( FILE* aFile )
if( output_file == NULL )
return false;
DateAndTime( Line );
wxString Title = creator + wxT( " " ) + GetBuildVersion();
fprintf( output_file, "G04 (created by %s) date %s*\n", TO_UTF8( Title ), Line );
fprintf( output_file, "G04 (created by %s) date %s*\n",
TO_UTF8( Title ), TO_UTF8( DateAndTime() ) );
// Specify linear interpol (G01), unit = INCH (G70), abs format (G90):
fputs( "G01*\nG70*\nG90*\n", output_file );
......
/*
* confirm.cpp
* utilities to display some error, warning and info short messges
*/
* @file confirm.cpp
* utilities to display some error, warning and info short messges
*/
#include "fctsys.h"
#include "common.h"
......@@ -9,46 +9,35 @@
#include "wx/html/htmlwin.h"
#include "html_messagebox.h"
/* Display an error or warning message.
* TODO:
* If display time > 0 the dialog disappears after displayTime ( in 0.1 second )
*
*/
void DisplayError( wxWindow* parent, const wxString& text, int displaytime )
{
wxMessageDialog* dialog;
if( displaytime > 0 )
dialog = new wxMessageDialog( parent, text, _( "Warning" ),
wxOK | wxCENTRE | wxICON_INFORMATION );
wxOK | wxCENTRE | wxICON_INFORMATION );
else
dialog = new wxMessageDialog( parent, text, _( "Error" ),
wxOK | wxCENTRE | wxICON_ERROR );
wxOK | wxCENTRE | wxICON_ERROR );
dialog->ShowModal();
dialog->Destroy();
}
/* Display an informational message.
* TODO:
* If display time > 0 the message disappears after displayTime (in 0.1 second )
*/
void DisplayInfoMessage( wxWindow* parent, const wxString& text,
int displaytime )
void DisplayInfoMessage( wxWindow* parent, const wxString& text, int displaytime )
{
wxMessageDialog* dialog;
dialog = new wxMessageDialog( parent, text, _( "Info:" ),
wxOK | wxCENTRE | wxICON_INFORMATION );
wxOK | wxCENTRE | wxICON_INFORMATION );
dialog->ShowModal();
dialog->Destroy();
}
/* Display a simple message window in html format.
*/
void DisplayHtmlInfoMessage( wxWindow* parent, const wxString& title,
const wxString& text, const wxSize& size )
{
......@@ -63,10 +52,10 @@ bool IsOK( wxWindow* parent, const wxString& text )
{
int ii;
ii = wxMessageBox( text, _( "Confirmation" ),
wxYES_NO | wxCENTRE | wxICON_HAND, parent );
ii = wxMessageBox( text, _( "Confirmation" ), wxYES_NO | wxCENTRE | wxICON_HAND, parent );
if( ii == wxYES )
return TRUE;
return FALSE;
}
return true;
return false;
}
......@@ -18,9 +18,6 @@
static bool DrawPageOnClipboard( EDA_DRAW_FRAME* aFrame );
/* calls the function to copy the current page or the current bock to
* the clipboard
*/
void EDA_DRAW_FRAME::CopyToClipboard( wxCommandEvent& event )
{
DrawPageOnClipboard( this );
......@@ -41,7 +38,7 @@ void EDA_DRAW_FRAME::CopyToClipboard( wxCommandEvent& event )
*/
bool DrawPageOnClipboard( EDA_DRAW_FRAME* aFrame )
{
bool success = TRUE;
bool success = true;
#ifdef __WINDOWS__
int tmpzoom;
......@@ -58,7 +55,7 @@ bool DrawPageOnClipboard( EDA_DRAW_FRAME* aFrame )
if( screen->IsBlockActive() )
{
DrawBlock = TRUE;
DrawBlock = true;
DrawArea.SetX( screen->m_BlockLocate.GetX() );
DrawArea.SetY( screen->m_BlockLocate.GetY() );
DrawArea.SetWidth( screen->m_BlockLocate.GetWidth() );
......
/////////////////////////////////////////////////////////////////////////////
// Name: svg.cpp
// Purpose: SVG plot
// Author: Chris Elliott
......
/****************/
/* displlst.cpp */
/****************/
/**
* @file displlst.cpp
*/
#include "fctsys.h"
#include "wxstruct.h"
......@@ -27,16 +27,6 @@ BEGIN_EVENT_TABLE( EDA_LIST_DIALOG, wxDialog )
END_EVENT_TABLE()
/**
* Used to display a list of elements for selection, and display comment of info lines
* about the selected item.
* @param aParent = apointeur to the parent window
* @param aTitle = the title shown on top.
* @param aItemList = a wxArrayString: the list of elements.
* @param aRefText = an item name if an item must be preselected.
* @param aCallBackFunction callback function to display comments
* @param aPos = position of the dialog.
*/
EDA_LIST_DIALOG::EDA_LIST_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aTitle,
const wxArrayString& aItemList, const wxString& aRefText,
void(* aCallBackFunction)(wxString& Text), wxPoint aPos ) :
......@@ -155,39 +145,24 @@ void EDA_LIST_DIALOG::OnClose( wxCloseEvent& event )
/* Sort alphabetically, case insensitive.
*/
static int SortItems( const wxString** ptr1, const wxString** ptr2 )
static int SortItems( const wxString& item1, const wxString& item2 )
{
return StrNumICmp( (*ptr1)->GetData(), (*ptr2)->GetData() );
return StrNumCmp( item1, item2, INT_MAX, true );
}
void EDA_LIST_DIALOG:: SortList()
void EDA_LIST_DIALOG::SortList()
{
int ii, NbItems = m_listBox->GetCount();
const wxString** BufList;
wxArrayString list = m_listBox->GetStrings();
if( NbItems <= 0 )
if( list.IsEmpty() <= 0 )
return;
BufList = (const wxString**) MyZMalloc( 100 * NbItems * sizeof(wxString*) );
for( ii = 0; ii < NbItems; ii++ )
{
BufList[ii] = new wxString( m_listBox->GetString( ii ) );
}
qsort( BufList, NbItems, sizeof(wxString*),
( int( * ) ( const void*, const void* ) )SortItems );
list.Sort( SortItems );
m_listBox->Clear();
for( ii = 0; ii < NbItems; ii++ )
{
m_listBox->Append( *BufList[ii] );
delete BufList[ii];
}
free( BufList );
m_listBox->Append( list );
}
......
......@@ -102,11 +102,11 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( wxWindow* father, int idtype, const wxString& ti
m_toolId = ID_NO_TOOL_SELECTED;
m_ID_last_state = ID_NO_TOOL_SELECTED;
m_HTOOL_current_state = 0;
m_Draw_Axis = FALSE; // TRUE to draw axis.
m_Draw_Sheet_Ref = FALSE; // TRUE to display reference sheet.
m_Print_Sheet_Ref = TRUE; // TRUE to print reference sheet.
m_Draw_Auxiliary_Axis = FALSE; // TRUE draw auxiliary axis.
m_Draw_Grid_Axis = FALSE; // TRUE to draw the grid axis
m_Draw_Axis = false; // true to draw axis.
m_Draw_Sheet_Ref = false; // true to display reference sheet.
m_Print_Sheet_Ref = true; // true to print reference sheet.
m_Draw_Auxiliary_Axis = false; // true draw auxiliary axis.
m_Draw_Grid_Axis = false; // true to draw the grid axis
m_CursorShape = 0;
m_LastGridSizeId = 0;
m_DrawGrid = true; // hide/Show grid. default = show
......
///////////////////////
// Name: eda_dde.cpp //
///////////////////////
/**
* @file eda_dde.cpp
*/
#include "fctsys.h"
#include "eda_dde.h"
......@@ -43,11 +43,12 @@ WinEDA_Server* CreateServer( wxWindow* window, int service )
addr.Service( service );
server = new wxServer( addr );
if( server )
{
server->SetNotify( wxSOCKET_CONNECTION_FLAG );
server->SetEventHandler( *window, ID_EDA_SOCKET_EVENT_SERV );
server->Notify( TRUE );
server->Notify( true );
}
return server;
......@@ -65,14 +66,17 @@ void EDA_DRAW_FRAME::OnSockRequest( wxSocketEvent& evt )
{
case wxSOCKET_INPUT:
sock->Read( client_ipc_buffer, 1 );
if( sock->LastCount() == 0 )
break; // No data, occurs on opening connection
sock->Read( client_ipc_buffer + 1, IPC_BUF_SIZE - 2 );
len = 1 + sock->LastCount();
client_ipc_buffer[len] = 0;
if( RemoteFct )
RemoteFct( client_ipc_buffer );
break;
case wxSOCKET_LOST:
......@@ -94,10 +98,11 @@ void EDA_DRAW_FRAME::OnSockRequestServer( wxSocketEvent& evt )
wxSocketServer* server = (wxSocketServer*) evt.GetSocket();
sock2 = server->Accept();
if( sock2 == NULL )
return;
sock2->Notify( TRUE );
sock2->Notify( true );
sock2->SetEventHandler( *this, ID_EDA_SOCKET_EVENT );
sock2->SetNotify( wxSOCKET_INPUT_FLAG | wxSOCKET_LOST_FLAG );
}
......@@ -117,7 +122,7 @@ void EDA_DRAW_FRAME::OnSockRequestServer( wxSocketEvent& evt )
bool SendCommand( int service, const char* cmdline )
{
wxSocketClient* sock_client;
bool success = FALSE;
bool success = false;
wxIPV4address addr;
// Create a connexion
......@@ -176,12 +181,12 @@ bool SendCommand( int service, const char* cmdline )
sock_client = new wxSocketClient();
sock_client->SetTimeout( 2 ); // Time out in Seconds
sock_client->Connect( addr, FALSE );
sock_client->Connect( addr, false );
sock_client->WaitOnConnect( 0, 100 );
if( sock_client->Ok() && sock_client->IsConnected() )
{
success = TRUE;
success = true;
sock_client->SetFlags( wxSOCKET_NOWAIT /*wxSOCKET_WAITALL*/ );
sock_client->Write( cmdline, strlen( cmdline ) );
}
......
/***************/
/* eda_doc.cpp */
/***************/
/**
* @file eda_doc.cpp
*/
#include "fctsys.h"
#include "appl_wxstruct.h"
......@@ -14,24 +14,18 @@
#include "macros.h"
/* Read from Common config the Pdf browser choice
*/
void EDA_APP::ReadPdfBrowserInfos()
{
wxASSERT( m_EDA_CommonConfig != NULL );
m_PdfBrowserIsDefault =
m_EDA_CommonConfig->Read( wxT( "PdfBrowserIsDefault" ), true );
m_PdfBrowser = m_EDA_CommonConfig->Read( wxT( "PdfBrowserName" ),
wxEmptyString );
m_PdfBrowserIsDefault = m_EDA_CommonConfig->Read( wxT( "PdfBrowserIsDefault" ), true );
m_PdfBrowser = m_EDA_CommonConfig->Read( wxT( "PdfBrowserName" ), wxEmptyString );
if( m_PdfBrowser.IsEmpty() )
m_PdfBrowserIsDefault = true;
}
/* Write into Common config the Pdf browser choice
*/
void EDA_APP::WritePdfBrowserInfos()
{
wxASSERT( m_EDA_CommonConfig != NULL );
......@@ -39,8 +33,7 @@ void EDA_APP::WritePdfBrowserInfos()
if( m_PdfBrowser.IsEmpty() )
m_PdfBrowserIsDefault = true;
m_EDA_CommonConfig->Write( wxT( "PdfBrowserIsDefault" ),
m_PdfBrowserIsDefault );
m_EDA_CommonConfig->Write( wxT( "PdfBrowserIsDefault" ), m_PdfBrowserIsDefault );
m_EDA_CommonConfig->Write( wxT( "PdfBrowserName" ), m_PdfBrowser );
}
......@@ -68,41 +61,31 @@ static const wxFileTypeInfo EDAfallbacks[] =
};
/**
* Function GetAssociatedDocument
* open a document (file) with the suitable browser
* @param aFrame = main frame
* if DocName is starting by http: or ftp: or www. the default internet
* browser is launched
* @param aDocName = filename of file to open (Full filename or short filename)
* @param aPaths = a wxPathList to explore.
* if NULL or aDocName is a full filename, aPath is not used.
*/
bool GetAssociatedDocument( wxFrame* aFrame,
const wxString& aDocName,
const wxPathList* aPaths)
bool GetAssociatedDocument( wxFrame* aFrame,
const wxString& aDocName,
const wxPathList* aPaths)
{
wxString docname, fullfilename, file_ext;
wxString msg;
wxString command;
bool success = FALSE;
bool success = false;
// Is an internet url
static const wxString url_header[3] = { wxT( "http:" ), wxT( "ftp:" ),
wxT( "www." ) };
static const wxString url_header[3] = { wxT( "http:" ), wxT( "ftp:" ), wxT( "www." ) };
for( int ii = 0; ii < 3; ii++ )
{
if( aDocName.First( url_header[ii] ) == 0 ) //. seems an internet url
{
wxLaunchDefaultBrowser( aDocName );
return TRUE;
return true;
}
}
docname = aDocName;
#ifdef __WINDOWS__
#ifdef __WINDOWS__
docname.Replace( UNIX_STRING_DIR_SEP, WIN_STRING_DIR_SEP );
#else
docname.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );
......@@ -139,10 +122,10 @@ bool GetAssociatedDocument( wxFrame* aFrame,
mask,
aFrame,
wxFD_OPEN,
TRUE,
true,
wxPoint( -1, -1 ) );
if( fullfilename.IsEmpty() )
return FALSE;
return false;
}
if( !wxFileExists( fullfilename ) )
......@@ -150,11 +133,12 @@ bool GetAssociatedDocument( wxFrame* aFrame,
msg = _( "Doc File " );
msg << wxT("\"") << aDocName << wxT("\"") << _( " not found" );
DisplayError( aFrame, msg );
return FALSE;
return false;
}
wxFileName CurrentFileName( fullfilename );
file_ext = CurrentFileName.GetExt();
if( file_ext == wxT( "pdf" ) )
{
success = OpenPDF( fullfilename );
......@@ -182,14 +166,14 @@ bool GetAssociatedDocument( wxFrame* aFrame,
success = filetype->GetOpenCommand( &command, params );
delete filetype;
if( success )
success = ProcessExecute( command );
}
if( !success )
{
msg.Printf( _( "Unknown MIME type for doc file <%s>" ),
GetChars( fullfilename ) );
msg.Printf( _( "Unknown MIME type for doc file <%s>" ), GetChars( fullfilename ) );
DisplayError( aFrame, msg );
}
......@@ -197,13 +181,6 @@ bool GetAssociatedDocument( wxFrame* aFrame,
}
/* Search if the text Database found all the words in the KeyList.
* Give articles in keylist (keylist = Following Keywords
* Separated by spaces
* Returns:
* 0 if no keyword found
* 1 if keyword found
*/
int KeyWordOk( const wxString& KeyList, const wxString& Database )
{
wxString KeysCopy, DataList;
......@@ -226,6 +203,7 @@ int KeyWordOk( const wxString& KeyList, const wxString& Database )
while( Data.HasMoreTokens() )
{
wxString word = Data.GetNextToken();
if( word == Key )
return 1; // Key found !
}
......
......@@ -114,20 +114,6 @@ static wxString s_KicadBinaryPathList[] = {
};
/**
* Function MakeReducedFileName
* Calculate the "reduced" filename from
* @param fullfilename = full filename
* @param default_path = default path
* @param default_ext = default extension
*
* @return the "reduced" filename, i.e.:
* without path if it is default_path
* with ./ if the path is the current path
* without extension if extension is default_ext
*
* the new flename is in unix like notation ('/' as path separator)
*/
wxString MakeReducedFileName( const wxString& fullfilename,
const wxString& default_path,
const wxString& default_ext )
......@@ -140,8 +126,10 @@ wxString MakeReducedFileName( const wxString& fullfilename,
path = wxPathOnly( reduced_filename ) + UNIX_STRING_DIR_SEP;
reduced_filename.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );
Cwd.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );
if( Cwd.Last() != '/' )
Cwd += UNIX_STRING_DIR_SEP;
path.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );
#ifdef __WINDOWS__
......@@ -154,6 +142,7 @@ wxString MakeReducedFileName( const wxString& fullfilename,
// if the path is "default_path" -> remove it
wxString root_path = path.Left( Cwd.Length() );
if( root_path == Cwd )
{
reduced_filename.Remove( 0, Cwd.Length() );
......@@ -165,6 +154,7 @@ wxString MakeReducedFileName( const wxString& fullfilename,
Cwd.MakeLower();
#endif
Cwd.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );
if( path == Cwd )
{ // the path is the current path -> path = "./"
reduced_filename.Remove( 0, Cwd.Length() );
......@@ -181,28 +171,22 @@ wxString MakeReducedFileName( const wxString& fullfilename,
}
/**
* Function AddDelimiterString
* Add un " to the start and the end of string (if not already done).
* @param string = string to modify
*/
void AddDelimiterString( wxString& string )
{
wxString text;
if( !string.StartsWith( wxT( "\"" ) ) )
text = wxT( "\"" );
text += string;
if( (text.Last() != '"' ) || (text.length() <= 1) )
text += wxT( "\"" );
string = text;
}
/***********************************/
/* Selection Directory dialog box: */
/***********************************/
bool EDA_DirectorySelector( const wxString& Title,
wxString& Path,
int flag,
......@@ -210,7 +194,7 @@ bool EDA_DirectorySelector( const wxString& Title,
const wxPoint& Pos )
{
int ii;
bool selected = FALSE;
bool selected = false;
wxDirDialog* DirFrame = new wxDirDialog( Frame,
wxString( Title ),
......@@ -219,10 +203,11 @@ bool EDA_DirectorySelector( const wxString& Title,
Pos );
ii = DirFrame->ShowModal();
if( ii == wxID_OK )
{
Path = DirFrame->GetPath();
selected = TRUE;
selected = true;
}
DirFrame->Destroy();
......@@ -230,16 +215,6 @@ bool EDA_DirectorySelector( const wxString& Title,
}
/* Selection file dialog box:
* Dialog title
* Default path
* default filename
* default filename extension
* filter for filename list
* parent frame
* wxFD_SAVE, wxFD_OPEN ..
* true = keep the current path
*/
wxString EDA_FileSelector( const wxString& Title,
const wxString& Path,
const wxString& FileName,
......@@ -258,6 +233,7 @@ wxString EDA_FileSelector( const wxString& Title,
defaultname.Replace( wxT( "/" ), STRING_DIR_SEP );
defaultpath.Replace( wxT( "/" ), STRING_DIR_SEP );
if( defaultpath.IsEmpty() )
defaultpath = wxGetCwd();
......@@ -289,37 +265,18 @@ wxString EDA_FileSelector( const wxString& Title,
}
/**
* Function FindKicadHelpPath
* Find an absolute path for KiCad "help" (or "help/&ltlanguage&gt")
* Find path kicad/doc/help/xx/ or kicad/doc/help/:
* from BinDir
* else from environment variable KICAD
* else from one of s_HelpPathList
* typically c:/kicad/doc/help or /usr/share/kicad/help
* or /usr/local/share/kicad/help
* (must have kicad in path name)
*
* xx = iso639-1 language id (2 letters (generic) or 4 letters):
* fr = french (or fr_FR)
* en = English (or en_GB or en_US ...)
* de = deutch
* es = spanish
* pt = portuguese (or pt_BR ...)
*
* default = en (if not found = fr)
*
*/
wxString FindKicadHelpPath()
{
wxString FullPath, LangFullPath, tmp;
wxString LocaleString;
bool PathFound = FALSE;
bool PathFound = false;
/* find kicad/help/ */
tmp = wxGetApp().m_BinDir;
if( tmp.Last() == '/' )
tmp.RemoveLast();
FullPath = tmp.BeforeLast( '/' ); // cd ..
FullPath += wxT( "/doc/help/" );
LocaleString = wxGetApp().m_Locale->GetCanonicalName();
......@@ -331,44 +288,54 @@ wxString FindKicadHelpPath()
if( path_tmp.Contains( wxT( "kicad" ) ) )
{
if( wxDirExists( FullPath ) )
PathFound = TRUE;
PathFound = true;
}
/* find kicad/help/ from environment variable KICAD */
if( !PathFound && wxGetApp().m_Env_Defined )
{
FullPath = wxGetApp().m_KicadEnv + wxT( "/doc/help/" );
if( wxDirExists( FullPath ) )
PathFound = TRUE;
PathFound = true;
}
/* find kicad/help/ from "s_HelpPathList" */
int ii = 0;
while( !PathFound )
{
FullPath = s_HelpPathList[ii++];
if( FullPath == wxT( "end_list" ) )
break;
if( wxDirExists( FullPath ) )
PathFound = TRUE;
PathFound = true;
}
if( PathFound )
{
LangFullPath = FullPath + LocaleString + UNIX_STRING_DIR_SEP;
if( wxDirExists( LangFullPath ) )
return LangFullPath;
LangFullPath = FullPath + LocaleString.Left( 2 ) + UNIX_STRING_DIR_SEP;
if( wxDirExists( LangFullPath ) )
return LangFullPath;
LangFullPath = FullPath + wxT( "en/" );
if( wxDirExists( LangFullPath ) )
{
return LangFullPath;
}
else
{
LangFullPath = FullPath + wxT( "fr/" );
if( wxDirExists( LangFullPath ) )
return LangFullPath;
}
......@@ -378,17 +345,6 @@ wxString FindKicadHelpPath()
}
/* Search the executable file shortname in KiCad binary path
* and return full file name if found or shortname
* kicad binary path is
* kicad/bin
*
* kicad binary path is found from:
* BinDir
* or environment variable KICAD
* or (default) c:\kicad or /usr/local/kicad
* or default binary path
*/
wxString FindKicadFile( const wxString& shortname )
{
wxString FullFileName;
......@@ -397,15 +353,17 @@ wxString FindKicadFile( const wxString& shortname )
* the KiCad binary path.
*/
FullFileName = wxGetApp().m_BinDir + shortname;
if( wxFileExists( FullFileName ) )
return FullFileName;
/* Test the presence of the file in the directory shortname
* defined by the environment variable KiCAD.
* defined by the environment variable KiCad.
*/
if( wxGetApp().m_Env_Defined )
{
FullFileName = wxGetApp().m_KicadEnv + shortname;
if( wxFileExists( FullFileName ) )
return FullFileName;
}
......@@ -414,11 +372,14 @@ wxString FindKicadFile( const wxString& shortname )
* /usr/local/kicad/linux or c:/kicad/winexe
* (see s_KicadDataPathList) */
int ii = 0;
while( 1 )
{
if( s_KicadBinaryPathList[ii] == wxT( "end_list" ) )
break;
FullFileName = s_KicadBinaryPathList[ii++] + shortname;
if( wxFileExists( FullFileName ) )
return FullFileName;
}
......@@ -427,10 +388,7 @@ wxString FindKicadFile( const wxString& shortname )
}
/* Call the executable file "ExecFile", with params "param"
*/
int ExecuteFile( wxWindow* frame, const wxString& ExecFile,
const wxString& param )
int ExecuteFile( wxWindow* frame, const wxString& ExecFile, const wxString& param )
{
wxString FullFileName;
......@@ -441,6 +399,7 @@ int ExecuteFile( wxWindow* frame, const wxString& ExecFile,
{
if( !param.IsEmpty() )
FullFileName += wxT( " " ) + param;
ProcessExecute( FullFileName );
return 0;
}
......@@ -452,26 +411,16 @@ int ExecuteFile( wxWindow* frame, const wxString& ExecFile,
}
/* Return data path common KiCad.
* If environment variable defined KiCAD (KiCAD = path to kicad)
* Returns <KICAD> /;
* Otherwise returns <path of binaries> / (if "kicad" is in the path name)
* Otherwise returns / usr / share / kicad /
*
* Note:
* The \ are replaced by / (a la Unix)
*/
wxString ReturnKicadDatasPath()
{
bool PathFound = FALSE;
bool PathFound = false;
wxString data_path;
if( wxGetApp().m_Env_Defined ) // Path defined by the KICAD environment
// variable.
if( wxGetApp().m_Env_Defined ) // Path defined by the KICAD environment variable.
{
data_path = wxGetApp().m_KicadEnv;
PathFound = TRUE;
PathFound = true;
}
else // Path of executables.
{
......@@ -486,6 +435,7 @@ wxString ReturnKicadDatasPath()
#endif
if( tmp.Last() == '/' )
tmp.RemoveLast();
data_path = tmp.BeforeLast( '/' ); // id cd ../
data_path += UNIX_STRING_DIR_SEP;
......@@ -494,12 +444,15 @@ wxString ReturnKicadDatasPath()
// So we search for kicad/share/ first
wxString old_path = data_path;
data_path += wxT( "share/" );
if( wxDirExists( data_path ) )
PathFound = TRUE;
{
PathFound = true;
}
else if( wxDirExists( old_path ) )
{
data_path = old_path;
PathFound = TRUE;
PathFound = true;
}
}
}
......@@ -508,13 +461,16 @@ wxString ReturnKicadDatasPath()
* /usr/local/kicad/ or c:/kicad/
* (see s_KicadDataPathList) */
int ii = 0;
while( !PathFound )
{
if( s_KicadDataPathList[ii] == wxT( "end_list" ) )
break;
data_path = s_KicadDataPathList[ii++];
if( wxDirExists( data_path ) )
PathFound = TRUE;
PathFound = true;
}
if( PathFound )
......@@ -574,12 +530,6 @@ wxString& EDA_APP::GetEditorName()
}
/**
* Function OpenPDF
* run the PDF viewer and display a PDF file
* @param file = PDF file to open
* @return true is success, false if no PDF viewer found
*/
bool OpenPDF( const wxString& file )
{
wxString command;
......@@ -588,6 +538,7 @@ bool OpenPDF( const wxString& file )
bool success = false;
wxGetApp().ReadPdfBrowserInfos();
if( !wxGetApp().m_PdfBrowserIsDefault ) // Run the preferred PDF Browser
{
AddDelimiterString( filename );
......@@ -598,8 +549,10 @@ bool OpenPDF( const wxString& file )
wxFileType* filetype = NULL;
wxFileType::MessageParameters params( filename, type );
filetype = wxTheMimeTypesManager->GetFileTypeFromExtension( wxT( "pdf" ) );
if( filetype )
success = filetype->GetOpenCommand( &command, params );
delete filetype;
#ifndef __WINDOWS__
......@@ -611,6 +564,7 @@ bool OpenPDF( const wxString& file )
if( success && !command.IsEmpty() )
{
success = ProcessExecute( command );
if( success )
return success;
}
......@@ -654,6 +608,7 @@ bool OpenPDF( const wxString& file )
if( !command.IsEmpty() )
{
success = ProcessExecute( command );
if( !success )
{
wxString msg = _( "Problem while running the PDF viewer" );
......@@ -682,14 +637,15 @@ void OpenFile( const wxString& file )
wxString ext, type;
ext = CurrentFileName.GetExt();
wxFileType* filetype =
wxTheMimeTypesManager->GetFileTypeFromExtension( ext );
wxFileType* filetype = wxTheMimeTypesManager->GetFileTypeFromExtension( ext );
bool success = false;
wxFileType::MessageParameters params( filename, type );
if( filetype )
success = filetype->GetOpenCommand( &command, params );
delete filetype;
if( success && !command.IsEmpty() )
......
......@@ -110,7 +110,7 @@ DLIST<TRACK> g_CurrentTrackList;
BOARD* g_ModuleEditor_Pcb = NULL;
bool g_Zone_45_Only = FALSE;
bool g_Zone_45_Only = false;
// Default setting used when creating a new zone
ZONE_SETTING g_Zone_Default_Setting;
......
/*********************************************/
/* string.cpp */
/* some useful functions to handle strings */
/*********************************************/
/**
* @file string.cpp
* @brief Some useful functions to handle strings.
*/
#include "fctsys.h"
#include "macros.h"
......@@ -30,6 +30,7 @@ int ReadDelimitedText( wxString* aDest, const char* aSource )
if( cc == '\\' )
{
cc = *aSource++;
if( !cc )
break;
......@@ -40,7 +41,9 @@ int ReadDelimitedText( wxString* aDest, const char* aSource )
utf8 += cc;
}
else
{
utf8 += cc;
}
}
}
......@@ -50,7 +53,7 @@ int ReadDelimitedText( wxString* aDest, const char* aSource )
}
int ReadDelimitedText( char* aDest, const char* aSource, int aDestSize )
int ReadDelimitedText( char* aDest, const char* aSource, int aDestSize )
{
if( aDestSize <= 0 )
return 0;
......@@ -75,6 +78,7 @@ int ReadDelimitedText( char* aDest, const char* aSource, int aDestSize )
if( cc == '\\' )
{
cc = *aSource++;
if( !cc )
break;
......@@ -86,7 +90,9 @@ int ReadDelimitedText( char* aDest, const char* aSource, int aDestSize )
*aDest++ = cc;
}
else
{
*aDest++ = cc;
}
}
}
......@@ -118,7 +124,9 @@ std::string EscapedUTF8( const wxString& aString )
ret += '\\';
}
else
{
ret += *it;
}
}
ret += '"';
......@@ -127,9 +135,6 @@ std::string EscapedUTF8( const wxString& aString )
}
/* Remove leading and training spaces, tabs and end of line chars in text
* return a pointer on the first n char in text
*/
char* StrPurge( char* text )
{
static const char whitespace[] = " \t\n\r\f\v";
......@@ -149,168 +154,96 @@ char* StrPurge( char* text )
}
/* Read lines from File
* Skip void lines and comments (starting by #)
* return the first non void line.
* increments *LineNum for each line
*/
char* GetLine( FILE* File, char* Line, int* LineNum, int SizeLine )
{
do {
do {
if( fgets( Line, SizeLine, File ) == NULL )
return NULL;
if( LineNum )
*LineNum += 1;
} while( Line[0] == '#' || Line[0] == '\n' || Line[0] == '\r'
|| Line[0] == 0 );
} while( Line[0] == '#' || Line[0] == '\n' || Line[0] == '\r' || Line[0] == 0 );
strtok( Line, "\n\r" );
return Line;
}
/* return in aBuffer the date and time
* time is the local time.
*/
char* DateAndTime( char* aBuffer )
{
wxString datetime;
datetime = DateAndTime();
strcpy( aBuffer, TO_UTF8( datetime ) );
return aBuffer;
}
/* return the date and time in a wxString
* note: does the same thing than strftime()
* time is the local time.
*/
wxString DateAndTime()
{
wxString Line;
wxDateTime datetime = wxDateTime::Now();
datetime.SetCountry( wxDateTime::Country_Default );
Line = datetime.Format( wxDefaultDateTimeFormat, wxDateTime::Local );
return Line;
return datetime.Format( wxDefaultDateTimeFormat, wxDateTime::Local );
}
/*
* sort() function
* Same as strncmp() but numbers in strings
* are compared according to the value, not the ascii value of each digit
*/
int StrLenNumCmp( const wxChar* str1, const wxChar* str2, int NbMax )
int StrNumCmp( const wxChar* aString1, const wxChar* aString2, int aLength, bool aIgnoreCase )
{
int i;
int nb1 = 0, nb2 = 0;
if( ( str1 == NULL ) || ( str2 == NULL ) )
if( ( aString1 == NULL ) || ( aString2 == NULL ) )
return 0;
for( i = 0; i < NbMax; i++ )
for( i = 0; i < aLength; i++ )
{
if( isdigit( *str1 ) && isdigit( *str2 ) ) /* digit found */
if( isdigit( *aString1 ) && isdigit( *aString2 ) ) /* digit found */
{
nb1 = 0; nb2 = 0;
while( isdigit( *str1 ) )
nb1 = 0;
nb2 = 0;
while( isdigit( *aString1 ) )
{
nb1 = nb1 * 10 + *str1 - '0'; str1++;
nb1 = nb1 * 10 + *aString1 - '0';
aString1++;
}
while( isdigit( *str2 ) )
while( isdigit( *aString2 ) )
{
nb2 = nb2 * 10 + *str2 - '0'; str2++;
nb2 = nb2 * 10 + *aString2 - '0';
aString2++;
}
if( nb1 < nb2 )
return -1;
if( nb1 > nb2 )
return 1;
}
if( *str1 < *str2 )
return -1;
if( *str1 > *str2 )
return 1;
if( ( *str1 == 0 ) && ( *str2 == 0 ) )
return 0;
str1++; str2++;
}
return 0;
}
/*
* sort() function
* Same as stricmp() but numbers in strings
* are compared according to the value, not the ascii value of each digit
*/
int StrNumICmp( const wxChar* str1, const wxChar* str2 )
{
return StrLenNumICmp( str1, str2, 32735 );
}
/*
* sort() function
* Same as strnicmp() but numbers in strings
* are compared according to the value, not the ascii value of each digit
*/
int StrLenNumICmp( const wxChar* str1, const wxChar* str2, int NbMax )
{
int i;
int nb1 = 0, nb2 = 0;
if( ( str1 == NULL ) || ( str2 == NULL ) )
return 0;
for( i = 0; i < NbMax; i++ )
{
if( isdigit( *str1 ) && isdigit( *str2 ) ) /* find number */
if( aIgnoreCase )
{
nb1 = 0; nb2 = 0;
while( isdigit( *str1 ) )
{
nb1 = nb1 * 10 + *str1 - '0'; str1++;
}
if( toupper( *aString1 ) < toupper( *aString2 ) )
return -1;
while( isdigit( *str2 ) )
{
nb2 = nb2 * 10 + *str2 - '0'; str2++;
}
if( toupper( *aString1 ) > toupper( *aString2 ) )
return 1;
if( nb1 < nb2 )
if( ( *aString1 == 0 ) && ( *aString2 == 0 ) )
return 0;
}
else
{
if( *aString1 < *aString2 )
return -1;
if( nb1 > nb2 )
if( *aString1 > *aString2 )
return 1;
if( ( *aString1 == 0 ) && ( *aString2 == 0 ) )
return 0;
}
if( toupper( *str1 ) < toupper( *str2 ) )
return -1;
if( toupper( *str1 ) > toupper( *str2 ) )
return 1;
if( (*str1 == 0 ) && ( *str2 == 0 ) )
return 0;
str1++; str2++;
aString1++;
aString2++;
}
return 0;
}
/* compare a string to a pattern
* ( usual chars * and ? allowed).
* if case_sensitive == true, comparison is case sensitive
* return true if match else false
*/
bool WildCompareString( const wxString& pattern, const wxString& string_to_tst,
bool case_sensitive )
{
......@@ -336,7 +269,8 @@ bool WildCompareString( const wxString& pattern, const wxString& string_to_tst,
while( ( *string ) && ( *wild != '*' ) )
{
if( ( *wild != *string ) && ( *wild != '?' ) )
return FALSE;
return false;
wild++; string++;
}
......@@ -370,16 +304,13 @@ bool WildCompareString( const wxString& pattern, const wxString& string_to_tst,
}
/* Converts a string used to compensate for internalization of printf().
* Generated floats with a comma instead of point.
* Obsolete: use SetLocaleTo_C_standard instead
*/
char* to_point( char* Text )
{
char* line = Text;
if( Text == NULL )
return NULL;
for( ; *Text != 0; Text++ )
{
if( *Text == ',' )
......@@ -390,27 +321,6 @@ char* to_point( char* Text )
}
/* Convert string to upper case.
* Returns pointer to the converted string.
*/
char* strupper( char* Text )
{
char* code = Text;
if( Text )
{
while( *code )
{
if( ( *code >= 'a' ) && ( *code <= 'z' ) )
*code += 'A' - 'a';
code++;
}
}
return Text;
}
int RefDesStringCompare( const wxString& strFWord, const wxString& strSWord )
{
// The different sections of the first string
......@@ -422,10 +332,8 @@ int RefDesStringCompare( const wxString& strFWord, const wxString& strSWord )
int isEqual = 0; // The numerical results of a string compare
int iReturn = 0; // The variable that is being returned
long lFirstDigit = 0; /* The converted middle section of the first
*string */
long lSecondDigit = 0; /* The converted middle section of the second
*string */
long lFirstDigit = 0; // The converted middle section of the first string
long lSecondDigit = 0; // The converted middle section of the second string
// Split the two strings into separate parts
SplitString( strFWord, &strFWordBeg, &strFWordMid, &strFWordEnd );
......@@ -482,6 +390,7 @@ int SplitString( wxString strToSplit,
// Starting at the end of the string look for the first digit
int ii;
for( ii = (strToSplit.length() - 1); ii >= 0; ii-- )
{
if( isdigit( strToSplit[ii] ) )
......@@ -490,7 +399,9 @@ int SplitString( wxString strToSplit,
// If there were no digits then just set the single string
if( ii < 0 )
{
*strBeginning = strToSplit;
}
else
{
// Since there is at least one digit this is the trailing string
......@@ -498,6 +409,7 @@ int SplitString( wxString strToSplit,
// Go to the end of the digits
int position = ii + 1;
for( ; ii >= 0; ii-- )
{
if( !isdigit( strToSplit[ii] ) )
......@@ -509,7 +421,7 @@ int SplitString( wxString strToSplit,
*strDigits = strToSplit.substr( 0, position );
/* We were only looking for the last set of digits everything else is
*part of the preamble */
* part of the preamble */
else
{
*strDigits = strToSplit.substr( ii + 1, position - ii - 1 );
......
/*******************/
/* class_cvpcb.cpp */
/*******************/
/**
* @file class_cvpcb.cpp
*/
#include "fctsys.h"
#include "kicad_string.h"
......@@ -15,17 +15,19 @@ PIN::PIN()
m_Type = 0; /* Electrical type. */
}
bool operator<( const PIN& item1, const PIN& item2 )
{
return ( StrLenNumICmp( item1.m_Number.GetData(),
item2.m_Number.GetData(), 4 ) < 0 );
return StrNumCmp( item1.m_Number, item2.m_Number, 4, true ) < 0;
}
bool operator==( const PIN& item1, const PIN& item2 )
{
return ( item1.m_Number == item2.m_Number );
}
bool same_pin_number( const PIN* item1, const PIN* item2 )
{
wxASSERT( item1 != NULL && item2 != NULL );
......@@ -33,6 +35,7 @@ bool same_pin_number( const PIN* item1, const PIN* item2 )
return ( item1->m_Number == item2->m_Number );
}
bool same_pin_net( const PIN* item1, const PIN* item2 )
{
wxASSERT( item1 != NULL && item2 != NULL );
......@@ -47,13 +50,13 @@ COMPONENT::COMPONENT()
m_Multi = 0;
}
COMPONENT::~COMPONENT()
{
}
bool operator<( const COMPONENT& item1, const COMPONENT& item2 )
{
return ( StrNumICmp( item1.m_Reference.GetData(),
item2.m_Reference.GetData() ) < 0 );
return StrNumCmp( item1.m_Reference, item2.m_Reference, INT_MAX, true ) < 0;
}
......@@ -26,7 +26,6 @@ int CVPCB_MAINFRAME::SaveComponentList( const wxString& aFullFileName )
{
FILE* dest;
wxFileName fn( aFullFileName );
char Line[1024];
wxString Title = wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion();
fn.SetExt( ComponentFileExtension );
......@@ -38,7 +37,7 @@ int CVPCB_MAINFRAME::SaveComponentList( const wxString& aFullFileName )
fprintf( dest, "%s", EnteteCmpMod );
fprintf( dest, " Created by %s", TO_UTF8( Title ) );
fprintf( dest, " date = %s\n", DateAndTime( Line ) );
fprintf( dest, " date = %s\n", TO_UTF8( DateAndTime() ) );
BOOST_FOREACH( COMPONENT& component, m_components )
{
......
......@@ -67,14 +67,11 @@ static void RemoveDuplicatePins( COMPONENT& component )
int CVPCB_MAINFRAME::GenNetlistPcbnew( FILE* file,bool isEESchemaNetlist )
{
#define NETLIST_HEAD_STRING "EESchema Netlist Version 1.1"
char Line[1024];
DateAndTime( Line );
if( isEESchemaNetlist )
fprintf( file, "# %s created %s\n(\n", NETLIST_HEAD_STRING, Line );
fprintf( file, "# %s created %s\n(\n", NETLIST_HEAD_STRING, TO_UTF8( DateAndTime() ) );
else
fprintf( file, "( { netlist created %s }\n", Line );
fprintf( file, "( { netlist created %s }\n", TO_UTF8( DateAndTime() ) );
BOOST_FOREACH( COMPONENT& component, m_components )
......@@ -83,7 +80,6 @@ int CVPCB_MAINFRAME::GenNetlistPcbnew( FILE* file,bool isEESchemaNetlist )
if( !component.m_Module.IsEmpty() )
fprintf( file, "%s", TO_UTF8( component.m_Module ) );
else
fprintf( file, "$noname$" );
......@@ -97,9 +93,7 @@ int CVPCB_MAINFRAME::GenNetlistPcbnew( FILE* file,bool isEESchemaNetlist )
BOOST_FOREACH( PIN& pin, component.m_Pins )
{
if( !pin.m_Net.IsEmpty() )
fprintf( file, " ( %s %s )\n",
TO_UTF8( pin.m_Number ),
TO_UTF8( pin.m_Net ) );
fprintf( file, " ( %s %s )\n", TO_UTF8( pin.m_Number ), TO_UTF8( pin.m_Net ) );
else
fprintf( file, " ( %s ? )\n", TO_UTF8( pin.m_Number ) );
}
......
......@@ -721,11 +721,10 @@ bool LIB_COMPONENT::Load( LINE_READER& aLineReader, wxString& aErrorMsg )
/* Copy part name and prefix. */
LIB_FIELD& value = GetValueField();
strupper( componentName );
if( componentName[0] != '~' )
{
m_name = value.m_Text = FROM_UTF8( componentName );
m_name = value.m_Text = m_name.MakeUpper();
}
else
{
......
......@@ -772,9 +772,7 @@ bool CMP_LIBRARY::SaveDocFile( const wxString& aFullFileName )
return false;
}
char line[256];
if( fprintf( docfile, "%s Date: %s\n", DOCFILE_IDENT, DateAndTime( line ) ) < 0 )
if( fprintf( docfile, "%s Date: %s\n", DOCFILE_IDENT, TO_UTF8( DateAndTime() ) ) < 0 )
{
fclose( docfile );
return false;
......@@ -799,12 +797,8 @@ bool CMP_LIBRARY::SaveDocFile( const wxString& aFullFileName )
bool CMP_LIBRARY::SaveHeader( OUTPUTFORMATTER& aFormatter )
{
char BufLine[1024];
DateAndTime( BufLine );
aFormatter.Print( 0, "%s %d.%d Date: %s\n", LIBFILE_IDENT,
LIB_VERSION_MAJOR, LIB_VERSION_MINOR, BufLine );
LIB_VERSION_MAJOR, LIB_VERSION_MINOR, TO_UTF8( DateAndTime() ) );
aFormatter.Print( 0, "#encoding utf-8\n");
......
......@@ -460,7 +460,6 @@ void DIALOG_BUILD_BOM::GenereListeOfItems( const wxString& aFullFileName,
{
FILE* f;
int itemCount;
char Line[1024];
wxString msg;
if( ( f = wxFopen( aFullFileName, wxT( "wt" ) ) ) == NULL )
......@@ -481,11 +480,9 @@ void DIALOG_BUILD_BOM::GenereListeOfItems( const wxString& aFullFileName,
if( itemCount )
{
// creates the list file
DateAndTime( Line );
wxString Title = wxGetApp().GetAppName() + wxT( " " ) + GetBuildVersion();
fprintf( f, "%s >> Creation date: %s\n", TO_UTF8( Title ), Line );
fprintf( f, "%s >> Creation date: %s\n", TO_UTF8( Title ), TO_UTF8( DateAndTime() ) );
// sort component list
cmplist.SortByReferenceOnly();
......
......@@ -103,9 +103,7 @@ bool LIB_EDIT_FRAME::LoadComponentFromCurrentLib( LIB_ALIAS* aLibEntry )
GetScreen()->ClearUndoRedoList();
Zoom_Automatique( false );
DrawPanel->Refresh();
SetShowDeMorgan( m_component->HasConversion() );
m_HToolBar->Refresh();
return true;
}
......
......@@ -646,14 +646,11 @@ static XNODE* node( const wxString& aName, const wxString& aTextualContent = wxE
XNODE* EXPORT_HELP::makeGenericDesignHeader()
{
XNODE* xdesign = node( wxT("design") );
char date[128];
DateAndTime( date );
// the root sheet is a special sheet, call it source
xdesign->AddChild( node( wxT( "source" ), g_RootSheet->GetScreen()->GetFileName() ) );
xdesign->AddChild( node( wxT( "date" ), FROM_UTF8( date )) );
xdesign->AddChild( node( wxT( "date" ), DateAndTime() ) );
// which Eeschema tool
xdesign->AddChild( node( wxT( "tool" ), wxGetApp().GetAppName() + wxChar(' ') +
......@@ -1193,7 +1190,6 @@ bool EXPORT_HELP::WriteGENERICNetList( const wxString& aOutFileName )
bool EXPORT_HELP::WriteNetListPspice( FILE* f, bool use_netnames, bool aUsePrefix )
{
int ret = 0;
char line[1024];
int nbitems;
wxString text;
wxArrayString spiceCommandAtBeginFile;
......@@ -1208,9 +1204,8 @@ bool EXPORT_HELP::WriteNetListPspice( FILE* f, bool use_netnames, bool aUsePrefi
wxString delimeters = wxT( "{:,; }" );
wxString disableStr = wxT( "N" );
DateAndTime( line );
ret |= fprintf( f, "* %s (Spice format) creation date: %s\n\n", NETLIST_HEAD_STRING, line );
ret |= fprintf( f, "* %s (Spice format) creation date: %s\n\n",
NETLIST_HEAD_STRING, TO_UTF8( DateAndTime() ) );
// Prepare list of nets generation (not used here, but...
for( unsigned ii = 0; ii < g_NetObjectslist.size(); ii++ )
......@@ -1236,16 +1231,19 @@ bool EXPORT_HELP::WriteNetListPspice( FILE* f, bool use_netnames, bool aUsePrefi
SCH_TEXT* drawText = (SCH_TEXT*) item;
text = drawText->m_Text;
if( text.IsEmpty() )
continue;
ident = text.GetChar( 0 );
if( ident != '.' && ident != '-' && ident != '+' )
continue;
text.Remove( 0, 1 ); // Remove the first char.
text.Remove( 6 ); // text contains 6 char.
text.MakeLower();
if( ( text == wxT( "pspice" ) ) || ( text == wxT( "gnucap" ) ) )
{
// Put the Y position as an ascii string, for sort by vertical
......@@ -1484,18 +1482,17 @@ bool EXPORT_HELP::WriteNetListPCBNEW( FILE* f, bool with_pcbnew )
{
wxString field;
wxString footprint;
char dateBuf[256];
int ret = 0; // zero now, OR in the sign bit on error
wxString netName;
std::vector< SCH_REFERENCE > cmpList;
DateAndTime( dateBuf );
if( with_pcbnew )
ret |= fprintf( f, "# %s created %s\n(\n", NETLIST_HEAD_STRING, dateBuf );
ret |= fprintf( f, "# %s created %s\n(\n",
NETLIST_HEAD_STRING, TO_UTF8( DateAndTime() ) );
else
ret |= fprintf( f, "( { %s created %s }\n", NETLIST_HEAD_STRING, dateBuf );
ret |= fprintf( f, "( { %s created %s }\n",
NETLIST_HEAD_STRING, TO_UTF8( DateAndTime() ) );
// Prepare list of nets generation
for( unsigned ii = 0; ii < g_NetObjectslist.size(); ii++ )
......@@ -1860,15 +1857,13 @@ void EXPORT_HELP::WriteNetListCADSTAR( FILE* f )
wxString StartCmpDesc = StartLine + wxT( "ADD_COM" );
wxString msg;
wxString footprint;
char Line[1024];
SCH_SHEET_PATH* sheet;
EDA_ITEM* DrawList;
SCH_COMPONENT* Component;
wxString Title = wxGetApp().GetAppName() + wxT( " " ) + GetBuildVersion();
fprintf( f, "%sHEA\n", TO_UTF8( StartLine ) );
DateAndTime( Line );
fprintf( f, "%sTIM %s\n", TO_UTF8( StartLine ), Line );
fprintf( f, "%sTIM %s\n", TO_UTF8( StartLine ), TO_UTF8( DateAndTime() ) );
fprintf( f, "%sAPP ", TO_UTF8( StartLine ) );
fprintf( f, "\"%s\"\n", TO_UTF8( Title ) );
fprintf( f, "\n" );
......@@ -1887,6 +1882,7 @@ void EXPORT_HELP::WriteNetListCADSTAR( FILE* f )
for( DrawList = sheet->LastDrawList(); DrawList != NULL; DrawList = DrawList->Next() )
{
DrawList = Component = findNextComponentAndCreatePinList( DrawList, sheet );
if( Component == NULL )
break;
......
......@@ -46,6 +46,7 @@ private:
void cleanBoard();
};
GBR_TO_PCB_EXPORTER::GBR_TO_PCB_EXPORTER( GERBVIEW_FRAME * aFrame, FILE * aFile )
{
m_gerbview_frame = aFrame;
......@@ -53,13 +54,13 @@ GBR_TO_PCB_EXPORTER::GBR_TO_PCB_EXPORTER( GERBVIEW_FRAME * aFrame, FILE * aFile
m_pcb = new BOARD( NULL, m_gerbview_frame );
}
GBR_TO_PCB_EXPORTER::~GBR_TO_PCB_EXPORTER()
{
delete m_pcb;
}
/* Export data in Pcbnew format
* remember Pcbnew uses a Y reversed axis, so we must negate all Y coordinates
*/
......@@ -73,13 +74,14 @@ void GERBVIEW_FRAME::ExportDataInPcbnewFormat( wxCommandEvent& event )
{
if( g_GERBER_List[ii] != NULL )
no_used_layers = false;
ii++;
}
if( no_used_layers )
{
DisplayInfoMessage( this,
_( "None of the Gerber layers contain any data" ) );
_( "None of the Gerber layers contain any data" ) );
return;
}
......@@ -106,6 +108,7 @@ void GERBVIEW_FRAME::ExportDataInPcbnewFormat( wxCommandEvent& event )
LAYERS_MAP_DIALOG* dlg = new LAYERS_MAP_DIALOG( this );
int ok = dlg->ShowModal();
dlg->Destroy();
if( ok != wxID_OK )
return;
......@@ -116,17 +119,20 @@ void GERBVIEW_FRAME::ExportDataInPcbnewFormat( wxCommandEvent& event )
}
FILE * file = wxFopen( FullFileName, wxT( "wt" ) );
if( file == NULL )
{
msg = _( "Unable to create " ) + FullFileName;
DisplayError( this, msg );
return;
}
GBR_TO_PCB_EXPORTER gbr_exporter( this, file );
gbr_exporter.ExportPcb( dlg->GetLayersLookUpTable() );
fclose( file );
}
void GBR_TO_PCB_EXPORTER::cleanBoard()
{
// delete redundant vias
......@@ -138,9 +144,11 @@ void GBR_TO_PCB_EXPORTER::cleanBoard()
// Search and delete others vias
TRACK* next_track;
TRACK* alt_track = track->Next();
for( ; alt_track; alt_track = next_track )
{
next_track = alt_track->Next();
if( alt_track->m_Shape != VIA_THROUGH )
continue;
......@@ -154,6 +162,7 @@ void GBR_TO_PCB_EXPORTER::cleanBoard()
}
}
bool GBR_TO_PCB_EXPORTER::WriteSetup( )
{
fprintf( m_file, "$SETUP\n" );
......@@ -172,11 +181,13 @@ bool GBR_TO_PCB_EXPORTER::WriteGeneralDescrPcb( )
/* Print the copper layer count */
nbLayers = m_pcb->GetCopperLayerCount();
if( nbLayers <= 1 ) // Minimal layers count in Pcbnew is 2
{
nbLayers = 2;
m_pcb->SetCopperLayerCount(2);
}
fprintf( m_file, "$GENERAL\n" );
fprintf( m_file, "encoding utf-8\n");
fprintf( m_file, "LayerCount %d\n", nbLayers );
......@@ -201,22 +212,22 @@ bool GBR_TO_PCB_EXPORTER::WriteGeneralDescrPcb( )
*/
bool GBR_TO_PCB_EXPORTER::ExportPcb( int* LayerLookUpTable )
{
char line[256];
BOARD* gerberPcb = m_gerbview_frame->GetBoard();
// create an image of gerber data
BOARD_ITEM* item = gerberPcb->m_Drawings;
for( ; item; item = item->Next() )
{
GERBER_DRAW_ITEM* gerb_item = (GERBER_DRAW_ITEM*) item;
int layer = gerb_item->GetLayer();
int pcb_layer_number = LayerLookUpTable[layer];
if( pcb_layer_number < 0 || pcb_layer_number > LAST_NO_COPPER_LAYER )
continue;
if( pcb_layer_number > LAST_COPPER_LAYER )
export_non_copper_item( gerb_item, pcb_layer_number );
else
export_copper_item( gerb_item, pcb_layer_number );
}
......@@ -228,7 +239,7 @@ bool GBR_TO_PCB_EXPORTER::ExportPcb( int* LayerLookUpTable )
// write PCB header
fprintf( m_file, "PCBNEW-BOARD Version %d date %s\n\n", g_CurrentVersionPCB,
DateAndTime( line ) );
TO_UTF8( DateAndTime() ) );
WriteGeneralDescrPcb( );
WriteSetup( );
......@@ -273,6 +284,7 @@ void GBR_TO_PCB_EXPORTER::export_non_copper_item( GERBER_DRAW_ITEM* aGbrItem, in
m_pcb->Add( drawitem );
}
void GBR_TO_PCB_EXPORTER::export_copper_item( GERBER_DRAW_ITEM* aGbrItem, int aLayer )
{
switch( aGbrItem->m_Shape )
......@@ -294,6 +306,7 @@ void GBR_TO_PCB_EXPORTER::export_copper_item( GERBER_DRAW_ITEM* aGbrItem, int aL
}
}
void GBR_TO_PCB_EXPORTER::export_segline_copper_item( GERBER_DRAW_ITEM* aGbrItem, int aLayer )
{
TRACK * newtrack = new TRACK( m_pcb );
......@@ -309,6 +322,7 @@ void GBR_TO_PCB_EXPORTER::export_segline_copper_item( GERBER_DRAW_ITEM* aGbrItem
m_pcb->Add( newtrack );
}
void GBR_TO_PCB_EXPORTER::export_segarc_copper_item( GERBER_DRAW_ITEM* aGbrItem, int aLayer )
{
double a = atan2( (double)( aGbrItem->m_Start.y - aGbrItem->m_ArcCentre.y ),
......@@ -323,12 +337,15 @@ void GBR_TO_PCB_EXPORTER::export_segarc_copper_item( GERBER_DRAW_ITEM* aGbrItem,
* approximate arc by segments (16 segment per 360 deg)
*/
#define DELTA 3600/16
if( arc_angle < 0 )
{
NEGATE( arc_angle );
EXCHG( start, end );
}
wxPoint curr_start = start;
for( int rot = DELTA; rot < (arc_angle - DELTA); rot += DELTA )
{
TRACK * newtrack = new TRACK( m_pcb );
......@@ -344,6 +361,7 @@ void GBR_TO_PCB_EXPORTER::export_segarc_copper_item( GERBER_DRAW_ITEM* aGbrItem,
m_pcb->Add( newtrack );
curr_start = curr_end;
}
if( end != curr_start )
{
TRACK * newtrack = new TRACK( m_pcb );
......
......@@ -53,7 +53,7 @@ public:
wxString m_BinDir; /* KiCad executable path.*/
wxString m_KicadEnv; /* environment variable KICAD */
bool m_Env_Defined; // TRUE if environment KICAD is defined.
bool m_Env_Defined; // true if environment KICAD is defined.
wxLocale* m_Locale; // The current locale.
int m_LanguageId; // The current language setting.
......@@ -169,7 +169,7 @@ public: EDA_APP();
/**
* Function WriteProjectConfig
* Save the current "projet" parameters
* Save the current "project" parameters
* saved parameters are parameters that have the .m_Setup member set to false
* saving file is the .pro file project
*/
......@@ -202,7 +202,7 @@ public: EDA_APP();
/**
* Function ReadProjectConfig
* Read the current "projet" parameters
* Read the current "project" parameters
* Parameters are parameters that have the .m_Setup member set to false
* read file is the .pro file project
*
......@@ -237,7 +237,15 @@ public: EDA_APP();
const wxString& GroupName,
bool ForceUseLocalConfig );
/**
* Function ReadPdfBrowserInfos
* read the PDF browser choice from the common configuration.
*/
void ReadPdfBrowserInfos();
/* Function WritePdfBrowserInfos
* save the PDF browser choice to the common configuration.
*/
void WritePdfBrowserInfos();
/**
......
......@@ -113,10 +113,10 @@ public:
* view position (upper left corner of device)
*/
bool m_Center; /* Center on screen. If TRUE (0.0) is centered
bool m_Center; /* Center on screen. If true (0.0) is centered
* on screen coordinates can be < 0 and
* > 0 except for schematics.
* FALSE: when coordinates can only be >= 0
* false: when coordinates can only be >= 0
* Schematic */
bool m_FirstRedraw;
......
/******************************
* drawpanel.h:
* define class EDA_DRAW_PANEL
*************************************/
/**
* @file class_drawpanel.h:
* @brief EDA_DRAW_PANEL class definition.
*/
#ifndef PANEL_WXSTRUCT_H
#define PANEL_WXSTRUCT_H
......@@ -30,7 +30,7 @@ typedef void ( *END_MOUSE_CAPTURE_CALLBACK )( EDA_DRAW_PANEL* aPanel, wxDC* aDC
class EDA_DRAW_PANEL : public wxScrolledWindow
{
private:
int m_currentCursor; ///< Current mouse cursor shape id.
int m_currentCursor; ///< Current mouse cursor shape id.
int m_defaultCursor; ///< The default mouse cursor shape id.
bool m_showCrossHair; ///< Indicate if cross hair is to be shown.
int m_cursorLevel; ///< Index for cursor redraw in XOR mode.
......@@ -43,13 +43,13 @@ public:
int m_scrollIncrementY; // Y axis scroll increment in pixels per unit.
bool m_AbortRequest; // Flag to abort long commands
bool m_AbortEnable; // TRUE if abort button or menu to be displayed
bool m_AbortEnable; // true if abort button or menu to be displayed
bool m_AutoPAN_Enable; // TRUE to allow auto pan
bool m_AutoPAN_Request; // TRUE to request an auto pan (will be made only if
bool m_AutoPAN_Enable; // true to allow auto pan
bool m_AutoPAN_Request; // true to request an auto pan (will be made only if
// m_AutoPAN_Enable = true)
int m_IgnoreMouseEvents; // when non-zero (true), then ignore mouse events
bool m_Block_Enable; // TRUE to accept Block Commands
bool m_Block_Enable; // true to accept Block Commands
// useful to avoid false start block in certain cases
// (like switch from a sheet to an other sheet
......
......@@ -137,7 +137,7 @@ extern wxString g_ProductName;
/* Default user lib path can be left void, if the standard lib path is used */
extern wxString g_UserLibDirBuffer;
extern bool g_ShowPageLimits; // TRUE to display the page limits
extern bool g_ShowPageLimits; // true to display the page limits
/* File name extension definitions. */
extern const wxString ProjectFileExtension;
......
/**
* This file is part of the common libary
* This file is part of the common library
* @file confirm.h
* @see common.h
*/
......@@ -9,16 +9,37 @@
#define __INCLUDE__CONFIRM_H__ 1
void DisplayError( wxWindow* parent, const wxString& msg,
int displaytime = 0 );
void DisplayInfoMessage( wxWindow* parent, const wxString& msg,
int displaytime = 0 );
/**
* Function DisplayError
* displays an error or warning message box with \a aMessage.
*
* @warning Setting \a displaytime does not work. Do not use it.
*/
void DisplayError( wxWindow* parent, const wxString& aMessage, int displaytime = 0 );
bool IsOK( wxWindow* parent, const wxString& msg );
/**
* Function DisplayInfoMessage
* displays an informational message box with \a aMessage.
*
* @warning Setting \a displaytime does not work. Do not use it.
*/
void DisplayInfoMessage( wxWindow* parent, const wxString& aMessage, int displaytime = 0 );
void DisplayHtmlInfoMessage( wxWindow* parent, const wxString& title,
const wxString& msg,
const wxSize& size=wxDefaultSize );
/**
* Function IsOK
* gets the user response to \a aMessage.
*
* @return True if user selected the yes button, otherwise false.
*/
bool IsOK( wxWindow* parent, const wxString& aMessage );
/**
* Function DisplayHtmlInforMessage
* displays \a aMessage in HTML format.
*/
void DisplayHtmlInfoMessage( wxWindow* parent, const wxString& title,
const wxString& aMessage,
const wxSize& size = wxDefaultSize );
#endif /* __INCLUDE__CONFIRM_H__ */
......@@ -8,22 +8,20 @@
#define __INCLUDE__EDA_DOC_H__ 1
/* Search the text Database for found all the key words in the KeyList.
/**
* Function KeyWordOk
* searches \a aKeyList for any words found in \a aDatabase.
*
* Returns:
* 0 if no keyword is found
* 1 if keyword found.
* @return 0 if no keyword is found or 1 if keyword is found.
*/
int KeyWordOk( const wxString& KeyList,
const wxString& Database );
int KeyWordOk( const wxString& aKeyList, const wxString& aDatabase );
/**
* Function GetAssociatedDocument
* open a document (file) with the suitable browser
* @param aFrame = main frame
* @param aDocName = filename of file to open (Full filename or short filename)
* if DocName is starting by http: or ftp: or www. the default internet
* browser is launched
* if \a aDocName begins with http: or ftp: or www. the default internet browser is launched
* @param aPaths = a wxPathList to explore.
* if NULL or aDocName is a full filename, aPath is not used.
*/
......
......@@ -82,7 +82,8 @@ public:
/**
* Function ReadFootprintFiles
* Read the list of libraries (*.mod files) and populates m_List ( list of availaible modules in libs ).
* Read the list of libraries (*.mod files) and populates m_List ( list of availaible
* modules in libs ).
* for each module, are stored
* the module name
* documentation string
......@@ -104,8 +105,7 @@ public:
/* FOOTPRINT object list sort function. */
inline bool operator<( const FOOTPRINT_INFO& item1, const FOOTPRINT_INFO& item2 )
{
return ( StrNumICmp( item1.m_Module.GetData(),
item2.m_Module.GetData() ) < 0 );
return StrNumCmp( item1.m_Module, item2.m_Module, INT_MAX, true ) < 0;
}
#endif // _FOOTPRINT_INFO_H_
......@@ -22,16 +22,26 @@ class EDA_LIST_DIALOG;
* @param file = PDF file to open
* @return true is success, false if no PDF viewer found
*/
bool OpenPDF( const wxString& file );
void OpenFile( const wxString& file );
bool EDA_DirectorySelector( const wxString& Title,
wxString& Path,
int flag, /* reserve */
wxWindow* Frame,
const wxPoint& Pos );
bool OpenPDF( const wxString& file );
void OpenFile( const wxString& file );
bool EDA_DirectorySelector( const wxString& Title,
wxString& Path,
int flag, /* reserve */
wxWindow* Frame,
const wxPoint& Pos );
/* Selection file dialog box:
* Dialog title
* Default path
* default filename
* default filename extension
* filter for filename list
* parent frame
* wxFD_SAVE, wxFD_OPEN ..
* true = keep the current path
*/
wxString EDA_FileSelector( const wxString& Title,
const wxString& Path,
const wxString& FileName,
......@@ -43,13 +53,20 @@ wxString EDA_FileSelector( const wxString& Title,
const wxPoint& Pos = wxPoint( -1, -1 ) );
/* Return file name without path or extension.
/**
* Function MakeReducedFileName
* calculate the "reduced" filename from \a fullfilename.
*
* @param fullfilename = full filename
* @param default_path = default path
* @param default_ext = default extension
* @return the "reduced" filename, i.e.:
* without path if it is default_path
* with ./ if the path is the current path
* without extension if extension is default_ext
*
* If the path is in the default KiCad path, ./ is prepended to the
* file name. If the file name has the default extension, the file
* name is returned without an extension.
* the new filename is in unix like notation ('/' as path separator)
*/
wxString MakeReducedFileName( const wxString& fullfilename,
const wxString& default_path,
const wxString& default_ext );
......@@ -57,22 +74,67 @@ wxString MakeReducedFileName( const wxString& fullfilename,
EDA_LIST_DIALOG* GetFileNames( char* Directory, char* Mask );
int ExecuteFile( wxWindow* frame, const wxString& ExecFile,
const wxString& param = wxEmptyString );
void AddDelimiterString( wxString& string );
/* Find absolute path for kicad/help (or kicad/help/<language>) */
wxString FindKicadHelpPath();
/**
* Function ExecuteFile
* calls the executable file \a ExecFile with the command line parameters \a param.
*/
int ExecuteFile( wxWindow* frame, const wxString& ExecFile,
const wxString& param = wxEmptyString );
/* Return the KiCad common data path. */
wxString ReturnKicadDatasPath();
/**
* Function AddDelimiterString
* Add un " to the start and the end of string (if not already done).
* @param string = string to modify
*/
void AddDelimiterString( wxString& string );
/**
* Function FindKicadHelpPath
* finds the absolute path for KiCad "help" (or "help/&ltlanguage&gt")
* Find path kicad/doc/help/xx/ or kicad/doc/help/:
* from BinDir
* else from environment variable KICAD
* else from one of s_HelpPathList
* typically c:/kicad/doc/help or /usr/share/kicad/help
* or /usr/local/share/kicad/help
* (must have kicad in path name)
*
* xx = iso639-1 language id (2 letters (generic) or 4 letters):
* fr = french (or fr_FR)
* en = English (or en_GB or en_US ...)
* de = deutch
* es = spanish
* pt = portuguese (or pt_BR ...)
*
* default = en (if not found = fr)
*/
wxString FindKicadHelpPath();
/* Search the executable file shortname in KiCad binary path and return
* full file name if found or shortname */
wxString FindKicadFile( const wxString& shortname );
/**
* Function ReturnKicadDatasPath
* returns the data path common to KiCad.
* If environment variable KICAD is defined (KICAD = path to kicad)
* Returns \<KICAD\> /;
* Otherwise returns \<path of binaries\> / (if "kicad" is in the path name)
* Otherwise returns /usr /share/kicad/
*
* Note:
* The \\ are replaced by / (a la Unix)
*/
wxString ReturnKicadDatasPath();
/**
* Function FindKicadFile
* searches the executable file shortname in KiCad binary path and return full file
* name if found or shortname if the kicad binary path is kicad/bin.
*
* kicad binary path is found from:
* BinDir
* or environment variable KICAD
* or (default) c:\\kicad or /usr/local/kicad
* or default binary path
*/
wxString FindKicadFile( const wxString& shortname );
/**
* Quote return value of wxFileName::GetFullPath().
......@@ -83,7 +145,6 @@ wxString FindKicadFile( const wxString& shortname );
* @param format if provided, can be used to transform the nature of the
* wrapped filename to another platform.
*/
extern wxString QuoteFullPath( wxFileName& fn,
wxPathFormat format = wxPATH_NATIVE );
extern wxString QuoteFullPath( wxFileName& fn, wxPathFormat format = wxPATH_NATIVE );
#endif /* __INCLUDE__GESTFICH_H__ */
......@@ -11,9 +11,6 @@
#include <wx/string.h>
char* strupper( char* Text );
char* strlower( char* Text );
/**
* Function ReadDelimitedText
......@@ -28,7 +25,7 @@ char* strlower( char* Text );
* the number copied, due to escaping of double quotes and the escape byte itself.
* @deprecated should use the one which fetches a wxString, below.
*/
int ReadDelimitedText( char* aDest, const char* aSource, int aDestSize );
int ReadDelimitedText( char* aDest, const char* aSource, int aDestSize );
/**
* Function ReadDelimitedText
......@@ -52,63 +49,62 @@ int ReadDelimitedText( wxString* aDest, const char* aSource );
*/
std::string EscapedUTF8( const wxString& aString );
/* Read one line line from a file.
* Returns the first useful line read by eliminating blank lines and comments.
/**
* Function GetLine
* reads one line line from \a aFile.
* @return A pointer the first useful line read by eliminating blank lines and comments.
*/
char* GetLine( FILE* File,
char* Line,
int* LineNum = NULL,
int SizeLine = 255 );
char* GetLine( FILE* aFile, char* Line, int* LineNum = NULL, int SizeLine = 255 );
/* Remove leading and trailing whitespace.
/**
* Funxtion StrPurge
* removes leading and training spaces, tabs and end of line chars in \a text
* return a pointer on the first n char in text
*/
char* StrPurge( char* text );
char* StrPurge( char* text );
/*Return a string giving the current date and time.
*/
char* DateAndTime( char* line );
/**
* Function DateAndTime
* @return a string giving the current date and time.
*/
wxString DateAndTime();
/*
* Routine (compatible with qsort ()) to sort by alphabetical order.
* Equivalent to strncmp () but the numbers are compared by their integer
* value not by their ASCII code.
*/
int StrLenNumCmp( const wxChar* str1,
const wxChar* str2,
int NbMax );
/*
* Routine (compatible with qsort ()) to sort by case insensitive alphabetical
* order.
* Equivalent to strnicmp () but the numbers are compared by their integer
* value not by their ASCII code.
/**
* Function StrLenNumCmp
* is a routine compatible with qsort() to sort by alphabetical order.
*
* This function is equivalent to strncmp() or strnicmp() if \a aIgnoreCase is true
* except that strings containing numbers are compared by their integer value not
* by their ASCII code.
*
* @param aString1 A wxChar pointer to the reference string.
* @param aString2 A wxChar pointer to the comparison string.
* @param aLength The numbere of characters to compare. Set to -1 to compare
* the entire string.
* @param aIgnoreCase Use true to make the comparison case insensitive.
* @return An integer value of -1 if \a aString1 is less than \a aString2, 0 if
* \a aString1 is equal to \a aString2, or 1 if \a aString1 is greater
* than \a aString2.
*/
int StrNumICmp( const wxChar* str1,
const wxChar* str2 );
int StrNumCmp( const wxChar* aString1, const wxChar* aString2, int aLength = INT_MAX,
bool aIgnoreCase = false );
int StrLenNumICmp( const wxChar* str1,
const wxChar* str2,
int NbMax );
/* Compare string against wild card pattern using the usual rules.
* (Wildcards *,?).
* The reference string is "pattern"
* If case_sensitive == TRUE (default), exact comparison
* Returns TRUE if pattern matched otherwise FALSE.
/**
* Function WildCompareString
* compares a string against wild card (* and ?) pattern using the usual rules.
* @return true if pattern matched otherwise false.
*/
bool WildCompareString( const wxString& pattern,
const wxString& string_to_tst,
bool case_sensitive = true );
bool WildCompareString( const wxString& pattern,
const wxString& string_to_tst,
bool case_sensitive = TRUE );
/* Replaces decimal point with commas to generated international numbers.
/**
* Function to_point
* converts a string used to compensate for internalization of printf(). It generates
* floating point numbers with a comma instead of point.
* @deprecated Use SetLocaleTo_C_standard instead.
*/
char* to_point( char* Text );
char* to_point( char* Text );
/**
* Function RefDesStringCompare
......@@ -118,7 +114,7 @@ char* to_point( char* Text );
* return 0 if the strings are equal
* return 1 if the first string is greater than the second
*/
int RefDesStringCompare( const wxString& lhs, const wxString& rhs );
int RefDesStringCompare( const wxString& lhs, const wxString& rhs );
/**
* Function SplitString
......
......@@ -140,9 +140,9 @@ public:
int m_Default; ///< The default value of the parameter
public: PARAM_CFG_BOOL( const wxChar* ident, bool* ptparam,
int default_val = FALSE, const wxChar* group = NULL );
int default_val = false, const wxChar* group = NULL );
PARAM_CFG_BOOL( bool Insetup, const wxChar* ident, bool* ptparam,
int default_val = FALSE, const wxChar* group = NULL );
int default_val = false, const wxChar* group = NULL );
virtual void ReadParam( wxConfigBase* aConfig );
virtual void SaveParam( wxConfigBase* aConfig );
......
......@@ -53,7 +53,7 @@ public:
int DisplayModEdge;
int DisplayModText;
bool DisplayPcbTrackFill; /* FALSE = sketch , TRUE = filled */
bool DisplayPcbTrackFill; /* false = sketch , true = filled */
/// How trace clearances are displayed. @see TRACE_CLEARANCE_DISPLAY_MODE_T.
TRACE_CLEARANCE_DISPLAY_MODE_T ShowTrackClearanceMode;
......
......@@ -69,7 +69,7 @@ public:
int m_DisplayModEdge; // How to display module drawings (line/ filled / sketch)
int m_DisplayModText; // How to display module texts (line/ filled / sketch)
bool m_DisplayPcbTrackFill; // FALSE : tracks are show in sketch mode, TRUE = filled.
bool m_DisplayPcbTrackFill; // false : tracks are show in sketch mode, true = filled.
EDA_UNITS_T m_UserGridUnit;
wxRealPoint m_UserGridSize;
......
......@@ -714,7 +714,7 @@ private:
SCH_NO_CONNECT* AddNoConnect( wxDC* aDC, const wxPoint& aPosition );
// Junction
SCH_JUNCTION* AddJunction( wxDC* aDC, const wxPoint& aPosition, bool aPutInUndoList = FALSE );
SCH_JUNCTION* AddJunction( wxDC* aDC, const wxPoint& aPosition, bool aPutInUndoList = false );
/**
* Function MoveItem
......
......@@ -397,12 +397,12 @@ public:
// = 1000 for Eeschema, = 10000
// for Pcbnew and GerbView
bool m_Draw_Axis; // TRUE to show X and Y axis
bool m_Draw_Grid_Axis; // TRUE to show grid axis.
bool m_Draw_Sheet_Ref; // TRUE to show frame references
bool m_Draw_Axis; // true to show X and Y axis
bool m_Draw_Grid_Axis; // true to show grid axis.
bool m_Draw_Sheet_Ref; // true to show frame references
bool m_Print_Sheet_Ref; // TRUE to print frame references
bool m_Draw_Auxiliary_Axis; /* TRUE to show auxiliary axis.
bool m_Print_Sheet_Ref; // true to print frame references
bool m_Draw_Auxiliary_Axis; /* true to show auxiliary axis.
* Used in Pcbnew: the auxiliary
* axis is the origin of
* coordinates for drill, gerber
......@@ -712,6 +712,10 @@ public:
*/
virtual bool HandleBlockEnd( wxDC* DC );
/**
* Function CopyToClipboard
* copies the current page or the current block to the clipboard.
*/
void CopyToClipboard( wxCommandEvent& event );
/* interprocess communication */
......
......@@ -166,8 +166,7 @@ bool FOOTPRINT_LIBRARY::ReadSectionIndex()
bool FOOTPRINT_LIBRARY::WriteHeader()
{
char line[256];
fprintf( m_file, "%s %s\n", FOOTPRINT_LIBRARY_HEADER, DateAndTime( line ) );
fprintf( m_file, "%s %s\n", FOOTPRINT_LIBRARY_HEADER, TO_UTF8( DateAndTime() ) );
fprintf( m_file, "# encoding utf-8\n" );
return true;
}
......
......@@ -298,7 +298,7 @@ void GenDrillReportFile( FILE* aFile, BOARD* aPcb,
fprintf( aFile, "Drill report for %s\n", TO_UTF8( aBoardFilename ) );
fprintf( aFile, "Created on %s\n", DateAndTime( line ) );
fprintf( aFile, "Created on %s\n", TO_UTF8( DateAndTime() ) );
// List which Drill Unit option had been selected for the associated
// drill aFile.
......
......@@ -41,10 +41,10 @@ static void WriteDrawSegmentPcb( DRAWSEGMENT* PtDrawSegment, FILE* rptfile );
/* Sort function use by GenereModulesPosition() */
static int ListeModCmp( const void* o1, const void* o2 )
{
LIST_MOD* ref = (LIST_MOD*) o1;
LIST_MOD* cmp = (LIST_MOD*) o2;
LIST_MOD* ref = (LIST_MOD*) o1;
LIST_MOD* cmp = (LIST_MOD*) o2;
return StrLenNumCmp( ref->m_Reference, cmp->m_Reference, 16 );
return StrNumCmp( ref->m_Reference, cmp->m_Reference, 16 );
}
......@@ -79,7 +79,6 @@ void PCB_EDIT_FRAME::GenModulesPosition( wxCommandEvent& event )
MODULE* module;
LIST_MOD* Liste = 0;
char line[1024];
char Buff[80];
wxFileName fnFront;
wxFileName fnBack;
wxString msg;
......@@ -214,7 +213,7 @@ void PCB_EDIT_FRAME::GenModulesPosition( wxCommandEvent& event )
qsort( Liste, moduleCount, sizeof(LIST_MOD), ListeModCmp );
// Write file header
sprintf( line, "### Module positions - created on %s ###\n", DateAndTime( Buff ) );
sprintf( line, "### Module positions - created on %s ###\n", TO_UTF8( DateAndTime() ) );
fputs( line, fpFront );
if( doBoardBack )
......@@ -325,7 +324,7 @@ void PCB_EDIT_FRAME::GenModuleReport( wxCommandEvent& event )
double conv_unit;
MODULE* Module;
D_PAD* pad;
char line[1024], Buff[80];
char line[1024];
wxFileName fn;
wxString fnFront, msg;
FILE* rptfile;
......@@ -361,7 +360,7 @@ void PCB_EDIT_FRAME::GenModuleReport( wxCommandEvent& event )
SetLocaleTo_C_standard();
/* Generate header file comments.) */
sprintf( line, "## Module report - date %s\n", DateAndTime( Buff ) );
sprintf( line, "## Module report - date %s\n", TO_UTF8( DateAndTime() ) );
fputs( line, rptfile );
wxString Title = wxGetApp().GetAppName() + wxT( " " ) + GetBuildVersion();
......
......@@ -502,18 +502,14 @@ void EXCELLON_WRITER::WriteCoordinates( char* aLine, double aCoordX, double aCoo
*/
void EXCELLON_WRITER::WriteHeader()
{
char Line[256];
fputs( "M48\n", m_file ); // The beginning of a header
if( !m_minimalHeader )
{
DateAndTime( Line );
// The next 2 lines in EXCELLON files are comments:
wxString msg = wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion();
fprintf( m_file, ";DRILL file {%s} date %s\n", TO_UTF8( msg ),
Line );
TO_UTF8( DateAndTime() ) );
msg = wxT( ";FORMAT={" );
// Print precision:
......@@ -532,6 +528,7 @@ void EXCELLON_WRITER::WriteHeader()
* be added here
*/
msg << wxT( " / " );
const wxString zero_fmt[4] =
{
wxT( "decimal" ),
......
......@@ -1149,7 +1149,6 @@ int PCB_EDIT_FRAME::ReadPcbFile( LINE_READER* aReader, bool Append )
int PCB_EDIT_FRAME::SavePcbFormatAscii( FILE* aFile )
{
bool rc;
char line[256];
GetBoard()->m_Status_Pcb &= ~CONNEXION_OK;
......@@ -1161,7 +1160,7 @@ int PCB_EDIT_FRAME::SavePcbFormatAscii( FILE* aFile )
/* Writing file header. */
fprintf( aFile, "PCBNEW-BOARD Version %d date %s\n\n", g_CurrentVersionPCB,
DateAndTime( line ) );
TO_UTF8( DateAndTime() ) );
fprintf( aFile, "# Created by Pcbnew%s\n\n", TO_UTF8( GetBuildVersion() ) );
GetBoard()->SynchronizeNetsAndNetClasses();
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file moduleframe.cpp
* @brief Footprint (module) editor main window.
......@@ -29,9 +54,7 @@ static BOARD_DESIGN_SETTINGS s_ModuleEditorDesignSetting;
wxString FOOTPRINT_EDIT_FRAME::m_CurrentLib = wxEmptyString;
/******************************/
/* class FOOTPRINT_EDIT_FRAME */
/******************************/
BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME )
EVT_MENU_RANGE( ID_POPUP_PCB_ITEM_SELECTION_START, ID_POPUP_PCB_ITEM_SELECTION_END,
PCB_BASE_FRAME::ProcessItemSelection )
......@@ -88,7 +111,7 @@ BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME )
EVT_MENU( ID_PCB_DRAWINGS_WIDTHS_SETUP, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_MENU( ID_PCB_PAD_SETUP, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_MENU( ID_PCB_USER_GRID_SETUP, PCB_EDIT_FRAME::Process_Special_Functions )
EVT_MENU( ID_PCB_USER_GRID_SETUP, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
// Menu 3D Frame
EVT_MENU( ID_MENU_PCB_SHOW_3D_FRAME, FOOTPRINT_EDIT_FRAME::Show3D_Frame )
......
......@@ -189,7 +189,7 @@ int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& reference,
}
fgets( Line, sizeof(Line), FichCmp );
fprintf( NewFile, "Cmp-Mod V01 Genere par PcbNew le %s\n", DateAndTime( Line ) );
fprintf( NewFile, "Cmp-Mod V01 Genere par PcbNew le %s\n", TO_UTF8( DateAndTime() ) );
bool start_descr = false;
......@@ -616,7 +616,7 @@ void PCB_EDIT_FRAME::RecreateCmpFileFromBoard( wxCommandEvent& aEvent )
}
fgets( Line, sizeof(Line), FichCmp );
fprintf( FichCmp, "Cmp-Mod V01 Genere par PcbNew le %s\n", DateAndTime( Line ) );
fprintf( FichCmp, "Cmp-Mod V01 Genere par PcbNew le %s\n", TO_UTF8( DateAndTime() ) );
for( ; Module != NULL; Module = Module->Next() )
{
......
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