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 !
}
......
This diff is collapsed.
......@@ -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;
......
This diff is collapsed.
/*******************/
/* 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