7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-21 00:21:25 +00:00

Start expunging NULL.

Given that KiCad is a C++ project, we should really be using nullptr
instead of NULL.
This commit is contained in:
Wayne Stambaugh 2021-07-15 15:26:35 -04:00
parent 1e21daf781
commit bcd6bddfd4
86 changed files with 951 additions and 792 deletions

View File

@ -99,6 +99,7 @@ double To_User_Unit( EDA_UNITS aUnit, double aValue )
* could truncate the actual value
*/
// A lower-precision (for readability) version of StringFromValue()
wxString MessageTextFromValue( EDA_UNITS aUnits, int aValue, bool aAddUnitLabel,
EDA_DATA_TYPE aType )
@ -494,7 +495,7 @@ std::string FormatInternalUnits( int aValue )
len = snprintf( buf, sizeof(buf), "%.10f", engUnits );
// Make sure snprintf() didn't fail and the locale numeric separator is correct.
wxCHECK( len >= 0 && len < 50 && strchr( buf, ',' ) == NULL, std::string( "" ) );
wxCHECK( len >= 0 && len < 50 && strchr( buf, ',' ) == nullptr, std::string( "" ) );
while( --len > 0 && buf[len] == '0' )
buf[len] = '\0';
@ -509,7 +510,7 @@ std::string FormatInternalUnits( int aValue )
len = snprintf( buf, sizeof(buf), "%.10g", engUnits );
// Make sure snprintf() didn't fail and the locale numeric separator is correct.
wxCHECK( len >= 0 && len < 50 && strchr( buf, ',' ) == NULL , std::string( "" ) );
wxCHECK( len >= 0 && len < 50 && strchr( buf, ',' ) == nullptr , std::string( "" ) );
}
return std::string( buf, len );

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2021 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
@ -23,7 +23,7 @@
*/
/**
* @brief Implement a very basic GAL used to draw, plot and convert texts in segments
* Implement a very basic GAL used to draw, plot and convert texts in segments
* for DRC functions, using the common GAL functions.
* Draw functions use wxDC.
* Plot functions use a PLOTTER
@ -53,22 +53,20 @@ const VECTOR2D BASIC_GAL::transform( const VECTOR2D& aPoint ) const
}
// Draws a polyline given a list of points already transformed into the local coordinate
// system.
void BASIC_GAL::doDrawPolyline( const std::vector<wxPoint>& aLocalPointList )
{
if( m_DC )
{
if( m_isFillEnabled )
{
GRPoly( m_isClipped ? &m_clipBox : NULL, m_DC, aLocalPointList.size(),
GRPoly( m_isClipped ? &m_clipBox : nullptr, m_DC, aLocalPointList.size(),
&aLocalPointList[0], 0, GetLineWidth(), m_Color, m_Color );
}
else
{
for( unsigned ii = 1; ii < aLocalPointList.size(); ++ii )
{
GRCSegm( m_isClipped ? &m_clipBox : NULL, m_DC, aLocalPointList[ ii - 1],
GRCSegm( m_isClipped ? &m_clipBox : nullptr, m_DC, aLocalPointList[ ii - 1],
aLocalPointList[ii], GetLineWidth(), m_Color );
}
}
@ -132,13 +130,13 @@ void BASIC_GAL::DrawLine( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint
{
if( m_isFillEnabled )
{
GRLine( m_isClipped ? &m_clipBox : NULL, m_DC, startVector.x, startVector.y,
GRLine( m_isClipped ? &m_clipBox : nullptr, m_DC, startVector.x, startVector.y,
endVector.x, endVector.y, GetLineWidth(), m_Color );
}
else
{
GRCSegm( m_isClipped ? &m_clipBox : NULL, m_DC, startVector.x, startVector.y,
endVector.x, endVector.y, GetLineWidth(), 0, m_Color );
GRCSegm( m_isClipped ? &m_clipBox : nullptr, m_DC, startVector.x, startVector.y,
endVector.x, endVector.y, GetLineWidth(), 0, m_Color );
}
}
else if( m_plotter )
@ -149,7 +147,6 @@ void BASIC_GAL::DrawLine( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint
}
else if( m_callback )
{
m_callback( startVector.x, startVector.y,
endVector.x, endVector.y, m_callbackData );
m_callback( startVector.x, startVector.y, endVector.x, endVector.y, m_callbackData );
}
}

View File

@ -6,7 +6,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2017 jean-pierre.charras
* Copyright (C) 2011-2017 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2011-2021 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
@ -38,15 +38,11 @@
#include <wx/mstream.h>
/**********************/
/* class BITMAP_BASE */
/**********************/
BITMAP_BASE::BITMAP_BASE( const wxPoint& pos )
{
m_scale = 1.0; // 1.0 = original bitmap size
m_bitmap = NULL;
m_image = NULL;
m_bitmap = nullptr;
m_image = nullptr;
m_ppi = 300; // the bitmap definition. the default is 300PPI
m_pixelSizeIu = 254000.0 / m_ppi; // a pixel size value OK for bitmaps using 300 PPI
// for Eeschema which uses currently 254000PPI
@ -70,10 +66,6 @@ BITMAP_BASE::BITMAP_BASE( const BITMAP_BASE& aSchBitmap )
}
/**
* Function ImportData
* Copy aItem image to me and update m_bitmap
*/
void BITMAP_BASE::ImportData( BITMAP_BASE* aItem )
{
*m_image = *aItem->m_image;
@ -240,7 +232,7 @@ const EDA_RECT BITMAP_BASE::GetBoundingBox() const
void BITMAP_BASE::DrawBitmap( wxDC* aDC, const wxPoint& aPos )
{
if( m_bitmap == NULL )
if( m_bitmap == nullptr )
return;
wxPoint pos = aPos;
@ -342,7 +334,7 @@ void BITMAP_BASE::PlotImage( PLOTTER* aPlotter,
COLOR4D aDefaultColor,
int aDefaultPensize ) const
{
if( m_image == NULL )
if( m_image == nullptr )
return;
// These 2 lines are useful only for plotters that cannot plot a bitmap

View File

@ -2,6 +2,8 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright 2016-2017 CERN
* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
*
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
@ -53,35 +55,35 @@ COMMIT& COMMIT::Stage( EDA_ITEM* aItem, CHANGE_TYPE aChangeType )
switch( aChangeType & CHT_TYPE )
{
case CHT_ADD:
assert( m_changedItems.find( aItem ) == m_changedItems.end() );
makeEntry( aItem, CHT_ADD | flag );
return *this;
case CHT_ADD:
assert( m_changedItems.find( aItem ) == m_changedItems.end() );
makeEntry( aItem, CHT_ADD | flag );
return *this;
case CHT_REMOVE:
makeEntry( aItem, CHT_REMOVE | flag );
return *this;
case CHT_REMOVE:
makeEntry( aItem, CHT_REMOVE | flag );
return *this;
case CHT_MODIFY:
{
EDA_ITEM* parent = parentObject( aItem );
EDA_ITEM* clone = nullptr;
case CHT_MODIFY:
{
EDA_ITEM* parent = parentObject( aItem );
EDA_ITEM* clone = nullptr;
assert( parent );
assert( parent );
if( parent )
clone = parent->Clone();
if( parent )
clone = parent->Clone();
assert( clone );
assert( clone );
if( clone )
return createModified( parent, clone, flag );
if( clone )
return createModified( parent, clone, flag );
break;
}
break;
}
default:
assert( false );
default:
assert( false );
}
return *this;
@ -105,7 +107,7 @@ COMMIT& COMMIT::Stage( const PICKED_ITEMS_LIST& aItems, UNDO_REDO aModFlag )
{
UNDO_REDO change_type = aItems.GetPickedItemStatus( i );
EDA_ITEM* item = aItems.GetPickedItem( i );
EDA_ITEM* copy = NULL;
EDA_ITEM* copy = nullptr;
if( change_type == UNDO_REDO::UNSPECIFIED )
change_type = aModFlag;
@ -169,7 +171,8 @@ void COMMIT::makeEntry( EDA_ITEM* aItem, CHANGE_TYPE aType, EDA_ITEM* aCopy )
if( m_changedItems.find( aItem ) != m_changedItems.end() )
{
eraseIf( m_changes, [aItem] ( const COMMIT_LINE& aEnt ) {
eraseIf( m_changes, [aItem] ( const COMMIT_LINE& aEnt )
{
return aEnt.m_item == aItem;
} );
}

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2014-2020 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2021 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
@ -381,8 +381,8 @@ bool matchWild( const char* pat, const char* text, bool dot_special )
const char *m = pat,
*n = text,
*ma = NULL,
*na = NULL;
*ma = nullptr,
*na = nullptr;
int just = 0,
acount = 0,
count = 0;
@ -420,6 +420,7 @@ bool matchWild( const char* pat, const char* text, bool dot_special )
if( !*m )
return false;
}
if( !*m )
{
/*
@ -492,7 +493,7 @@ bool matchWild( const char* pat, const char* text, bool dot_special )
static wxInt64 EPOCH_OFFSET_IN_MSEC = wxLL(11644473600000);
static void ConvertFileTimeToWx( wxDateTime *dt, const FILETIME &ft )
static void ConvertFileTimeToWx( wxDateTime* dt, const FILETIME& ft )
{
wxLongLong t( ft.dwHighDateTime, ft.dwLowDateTime );
t /= 10000; // Convert hundreds of nanoseconds to milliseconds.
@ -505,13 +506,12 @@ static void ConvertFileTimeToWx( wxDateTime *dt, const FILETIME &ft )
/**
* TimestampDir
*
* This routine offers SIGNIFICANT performance benefits over using wxWidgets to gather
* timestamps from matching files in a directory.
* @param aDirPath the directory to search
* @param aFilespec a (wildcarded) file spec to match against
* @return a hash of the last-mod-dates of all matching files in the directory
*
* @param aDirPath is the directory to search.
* @param aFilespec is a (wildcarded) file spec to match against.
* @return a hash of the last-mod-dates of all matching files in the directory.
*/
long long TimestampDir( const wxString& aDirPath, const wxString& aFilespec )
{
@ -537,7 +537,9 @@ long long TimestampDir( const wxString& aDirPath, const wxString& aFilespec )
{
ConvertFileTimeToWx( &lastModDate, findData.ftLastWriteTime );
timestamp += lastModDate.GetValue().GetValue();
timestamp += findData.nFileSizeLow; // Get the file size (partial) as well to check for sneaky changes
// Get the file size (partial) as well to check for sneaky changes.
timestamp += findData.nFileSizeLow;
}
while ( FindNextFile( fileHandle, &findData ) != 0 );
}
@ -590,7 +592,9 @@ long long TimestampDir( const wxString& aDirPath, const wxString& aFilespec )
if( S_ISREG( entry_stat.st_mode ) ) // wxFileExists()
{
timestamp += entry_stat.st_mtime * 1000;
timestamp += entry_stat.st_size; // Get the file size as well to check for sneaky changes
// Get the file size as well to check for sneaky changes.
timestamp += entry_stat.st_size;
}
}
else
@ -607,13 +611,14 @@ long long TimestampDir( const wxString& aDirPath, const wxString& aFilespec )
return timestamp;
}
bool WarnUserIfOperatingSystemUnsupported()
{
if( !KIPLATFORM::APP::IsOperatingSystemUnsupported() )
return false;
wxMessageDialog dialog( NULL, _( "This operating system is not supported "
"by KiCad and its dependencies." ),
wxMessageDialog dialog( nullptr, _( "This operating system is not supported "
"by KiCad and its dependencies." ),
_( "Unsupported Operating System" ),
wxOK | wxICON_EXCLAMATION );

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2018-2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2018-2021 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
@ -111,7 +111,7 @@ DIALOG_COLOR_PICKER::~DIALOG_COLOR_PICKER()
{
swatch->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED,
wxMouseEventHandler( DIALOG_COLOR_PICKER::buttColorClick ),
NULL, this );
nullptr, this );
}
}
@ -183,10 +183,10 @@ void DIALOG_COLOR_PICKER::initDefinedColors( CUSTOM_COLORS_LIST* aPredefinedColo
swatch->Connect( wxEVT_LEFT_DOWN,
wxMouseEventHandler( DIALOG_COLOR_PICKER::buttColorClick ),
NULL, this );
nullptr, this );
swatch->Connect( wxEVT_LEFT_DCLICK,
wxMouseEventHandler( DIALOG_COLOR_PICKER::colorDClick ),
NULL, this );
nullptr, this );
};
// If no predefined list is given, build the default predefined colors:
@ -230,9 +230,12 @@ void DIALOG_COLOR_PICKER::createRGBBitmap()
int half_size = std::min( bmsize.x, bmsize.y )/2;
// We use here a Y axis from bottom to top and origin to center, So we need to map
// coordinated to write pixel in a wxImage
#define MAPX(xx) bmsize.x/2 + (xx)
#define MAPY(yy) bmsize.y/2 - (yy)
// coordinated to write pixel in a wxImage. MAPX and MAPY are defined above so they
// must be undefined here to prevent compiler warnings.
#undef MAPX
#undef MAPY
#define MAPX( xx ) bmsize.x / 2 + ( xx )
#define MAPY( yy ) bmsize.y / 2 - ( yy )
// Reserve room to draw cursors inside the bitmap
half_size -= m_cursorsSize/2;
@ -270,6 +273,7 @@ void DIALOG_COLOR_PICKER::createRGBBitmap()
// Red green area in y Z 3d axis
color.b = 0.0;
for( int xx = 0; xx < half_size; xx++ ) // green axis
{
color.g = inc * xx;
@ -283,6 +287,7 @@ void DIALOG_COLOR_PICKER::createRGBBitmap()
// Blue green area in x y 3d axis
color.r = 0.0;
for( int xx = 0; xx < half_size; xx++ ) // green axis
{
color.g = inc * xx;
@ -315,8 +320,8 @@ void DIALOG_COLOR_PICKER::createHSVBitmap()
// We use here a Y axis from bottom to top and origin to center, So we need to map
// coordinated to write pixel in a wxImage
#define MAPX(xx) bmsize.x/2 + (xx)
#define MAPY(yy) bmsize.y/2 - (yy)
#define MAPX( xx ) bmsize.x / 2 + ( xx )
#define MAPY( yy ) bmsize.y / 2 - ( yy )
wxImage img( bmsize ); // a temporary buffer to build the color map
@ -390,10 +395,10 @@ void DIALOG_COLOR_PICKER::drawRGBPalette()
wxBrush brush( wxColor( 0, 0, 0 ), wxBRUSHSTYLE_TRANSPARENT );
bitmapDC.SetPen( pen );
bitmapDC.SetBrush( brush );
int half_csize = m_cursorsSize/2;
int half_csize = m_cursorsSize / 2;
#define SLOPE_AXIS 50.0
double slope = SLOPE_AXIS/half_size;
double slope = SLOPE_AXIS / half_size;
// Red axis cursor (Z 3Daxis):
m_cursorBitmapRed.x = 0;
@ -425,6 +430,7 @@ void DIALOG_COLOR_PICKER::drawRGBPalette()
bitmapDC.DrawLine( 0, 0, -half_size, - half_size*slope ); // green axis (Y 3D axis)
m_RgbBitmap->SetBitmap( newBm );
/* Deselect the Tool Bitmap from DC,
* in order to delete the MemoryDC safely without deleting the bitmap */
bitmapDC.SelectObject( wxNullBitmap );
@ -438,7 +444,7 @@ void DIALOG_COLOR_PICKER::drawHSVPalette()
wxMemoryDC bitmapDC;
wxSize bmsize = m_bitmapHSV->GetSize();
int half_size = std::min( bmsize.x, bmsize.y )/2;
int half_size = std::min( bmsize.x, bmsize.y ) / 2;
wxBitmap newBm( *m_bitmapHSV );
bitmapDC.SelectObject( newBm );
@ -447,7 +453,7 @@ void DIALOG_COLOR_PICKER::drawHSVPalette()
bitmapDC.SetDeviceOrigin( half_size, half_size );
// Reserve room to draw cursors inside the bitmap
half_size -= m_cursorsSize/2;
half_size -= m_cursorsSize / 2;
// Draw the HSB cursor:
m_cursorBitmapHSV.x = cos( m_hue * M_PI / 180.0 ) * half_size * m_sat;
@ -464,6 +470,7 @@ void DIALOG_COLOR_PICKER::drawHSVPalette()
m_cursorsSize, m_cursorsSize );
m_HsvBitmap->SetBitmap( newBm );
/* Deselect the Tool Bitmap from DC,
* in order to delete the MemoryDC safely without deleting the bitmap
*/
@ -558,7 +565,7 @@ void DIALOG_COLOR_PICKER::onRGBMouseClick( wxMouseEvent& event )
// The cursor position is relative to the m_bitmapHSV wxBitmap center
wxSize bmsize = m_bitmapRGB->GetSize();
int half_size = std::min( bmsize.x, bmsize.y )/2;
int half_size = std::min( bmsize.x, bmsize.y ) / 2;
mousePos.x -= half_size;
mousePos.y -= half_size;
mousePos.y = -mousePos.y; // Use the bottom to top vertical axis
@ -608,12 +615,12 @@ void DIALOG_COLOR_PICKER::onRGBMouseDrag( wxMouseEvent& event )
// The cursor position is relative to the m_bitmapHSV wxBitmap center
wxPoint mousePos = event.GetPosition();
wxSize bmsize = m_bitmapRGB->GetSize();
int half_size = std::min( bmsize.x, bmsize.y )/2;
int half_size = std::min( bmsize.x, bmsize.y ) / 2;
mousePos.x -= half_size;
mousePos.y -= half_size;
mousePos.y = -mousePos.y; // Use the bottom to top vertical axis
mousePos.y = -mousePos.y; // Use the bottom to top vertical axis
half_size -= m_cursorsSize/2; // the actual half_size of the palette area
half_size -= m_cursorsSize / 2; // the actual half_size of the palette area
// Change colors according to the selected cursor:
if( m_selectedCursor == &m_cursorBitmapRed )
@ -683,6 +690,7 @@ bool DIALOG_COLOR_PICKER::setHSvaluesFromCursor( wxPoint aMouseCursor )
wxPoint mousePos = aMouseCursor;
wxSize bmsize = m_bitmapHSV->GetSize();
int half_size = std::min( bmsize.x, bmsize.y )/2;
// Make the cursor position relative to the m_bitmapHSV wxBitmap center
mousePos.x -= half_size;
mousePos.y -= half_size;
@ -698,7 +706,7 @@ bool DIALOG_COLOR_PICKER::setHSvaluesFromCursor( wxPoint aMouseCursor )
m_cursorBitmapHSV = mousePos;
// Set saturation and hue from new cursor position:
half_size -= m_cursorsSize/2; // the actual half_size of the palette area
half_size -= m_cursorsSize / 2; // the actual half_size of the palette area
m_sat = dist_from_centre / half_size;
if( m_sat > 1.0 )

View File

@ -2,7 +2,7 @@
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2015 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 2015-2018 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2015-2021 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
@ -110,8 +110,12 @@ DIALOG_CONFIGURE_PATHS::DIALOG_CONFIGURE_PATHS( wxWindow* aParent, FILENAME_RESO
m_sdbSizerOK->SetDefault();
// wxFormBuilder doesn't include this event...
m_EnvVars->Connect( wxEVT_GRID_CELL_CHANGING, wxGridEventHandler( DIALOG_CONFIGURE_PATHS::OnGridCellChanging ), NULL, this );
m_SearchPaths->Connect( wxEVT_GRID_CELL_CHANGING, wxGridEventHandler( DIALOG_CONFIGURE_PATHS::OnGridCellChanging ), NULL, this );
m_EnvVars->Connect( wxEVT_GRID_CELL_CHANGING,
wxGridEventHandler( DIALOG_CONFIGURE_PATHS::OnGridCellChanging ),
nullptr, this );
m_SearchPaths->Connect( wxEVT_GRID_CELL_CHANGING,
wxGridEventHandler( DIALOG_CONFIGURE_PATHS::OnGridCellChanging ),
nullptr, this );
GetSizer()->SetSizeHints( this );
Centre();
@ -127,8 +131,12 @@ DIALOG_CONFIGURE_PATHS::~DIALOG_CONFIGURE_PATHS()
if( m_helpDialog )
m_helpDialog->Destroy();
m_EnvVars->Disconnect( wxEVT_GRID_CELL_CHANGING, wxGridEventHandler( DIALOG_CONFIGURE_PATHS::OnGridCellChanging ), NULL, this );
m_SearchPaths->Disconnect( wxEVT_GRID_CELL_CHANGING, wxGridEventHandler( DIALOG_CONFIGURE_PATHS::OnGridCellChanging ), NULL, this );
m_EnvVars->Disconnect( wxEVT_GRID_CELL_CHANGING,
wxGridEventHandler( DIALOG_CONFIGURE_PATHS::OnGridCellChanging ),
nullptr, this );
m_SearchPaths->Disconnect( wxEVT_GRID_CELL_CHANGING,
wxGridEventHandler( DIALOG_CONFIGURE_PATHS::OnGridCellChanging ),
nullptr, this );
}
@ -200,7 +208,7 @@ void DIALOG_CONFIGURE_PATHS::AppendEnvVar( const wxString& aName, const wxString
void DIALOG_CONFIGURE_PATHS::AppendSearchPath( const wxString& aName, const wxString& aPath,
const wxString& aDescription )
const wxString& aDescription )
{
int i = m_SearchPaths->GetNumberRows();
@ -330,6 +338,7 @@ void DIALOG_CONFIGURE_PATHS::OnGridCellChanging( wxGridEvent& event )
else
m_errorMsg = _( "3D search path cannot be empty." );
}
m_errorGrid = dynamic_cast<wxGrid*>( event.GetEventObject() );
m_errorRow = row;
m_errorCol = col;
@ -355,7 +364,8 @@ void DIALOG_CONFIGURE_PATHS::OnGridCellChanging( wxGridEvent& event )
}
else if( col == TV_NAME_COL && m_EnvVars->GetCellValue( row, TV_NAME_COL ) != text )
{
if( text == PROJECT_VAR_NAME ) // This env var name is reserved and cannot be added here:
// This env var name is reserved and cannot be added here.
if( text == PROJECT_VAR_NAME )
{
wxMessageBox( wxString::Format(
_( "The name %s is reserved, and cannot be used here" ),
@ -363,7 +373,9 @@ void DIALOG_CONFIGURE_PATHS::OnGridCellChanging( wxGridEvent& event )
event.Veto();
}
else // Changing name; clear external flag
{
m_EnvVars->SetCellValue( row, TV_FLAG_COL, wxEmptyString );
}
}
}
}
@ -432,7 +444,8 @@ void DIALOG_CONFIGURE_PATHS::OnDeleteSearchPath( wxCommandEvent& event )
// if there are still rows in grid, make previous row visible
if( m_SearchPaths->GetNumberRows() )
{
m_SearchPaths->MakeCellVisible( std::max( 0, curRow-1 ), m_SearchPaths->GetGridCursorCol() );
m_SearchPaths->MakeCellVisible( std::max( 0, curRow-1 ),
m_SearchPaths->GetGridCursorCol() );
m_SearchPaths->SetGridCursor( std::max( 0, curRow-1 ), m_SearchPaths->GetGridCursorCol() );
}
}
@ -458,7 +471,9 @@ void DIALOG_CONFIGURE_PATHS::OnSearchPathMoveUp( wxCommandEvent& event )
m_SearchPaths->SetGridCursor( prevRow, m_SearchPaths->GetGridCursorCol() );
}
else
{
wxBell();
}
}
@ -482,7 +497,9 @@ void DIALOG_CONFIGURE_PATHS::OnSearchPathMoveDown( wxCommandEvent& event )
m_SearchPaths->SetGridCursor( nextRow, m_SearchPaths->GetGridCursorCol() );
}
else
{
wxBell();
}
}
@ -495,6 +512,7 @@ void DIALOG_CONFIGURE_PATHS::OnGridCellRightClick( wxGridEvent& aEvent )
wxMenu menu;
AddMenuItem( &menu, 1, _( "File Browser..." ), KiBitmap( BITMAPS::small_folder ) );
if( GetPopupMenuSelectionFromUser( menu ) == 1 )
{
wxDirDialog dlg( nullptr, _( "Select Path" ), m_curdir,
@ -525,13 +543,16 @@ void DIALOG_CONFIGURE_PATHS::OnUpdateUI( wxUpdateUIEvent& event )
width = m_SearchPaths->GetClientRect().GetWidth();
m_SearchPaths->AutoSizeColumn( SP_ALIAS_COL );
m_SearchPaths->SetColSize( SP_ALIAS_COL, std::max( m_SearchPaths->GetColSize( SP_ALIAS_COL ), 120 ) );
m_SearchPaths->SetColSize( SP_ALIAS_COL,
std::max( m_SearchPaths->GetColSize( SP_ALIAS_COL ), 120 ) );
m_SearchPaths->AutoSizeColumn( SP_PATH_COL );
m_SearchPaths->SetColSize( SP_PATH_COL, std::max( m_SearchPaths->GetColSize( SP_PATH_COL ), 300 ) );
m_SearchPaths->SetColSize( SP_PATH_COL,
std::max( m_SearchPaths->GetColSize( SP_PATH_COL ), 300 ) );
m_SearchPaths->SetColSize( SP_DESC_COL, width - ( m_SearchPaths->GetColSize( SP_ALIAS_COL )
+ m_SearchPaths->GetColSize( SP_PATH_COL ) ) );
m_SearchPaths->SetColSize( SP_DESC_COL, width -
( m_SearchPaths->GetColSize( SP_ALIAS_COL ) +
m_SearchPaths->GetColSize( SP_PATH_COL ) ) );
m_gridWidth = m_EnvVars->GetSize().GetX();
m_gridWidthsDirty = false;
}

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2019 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 2019-2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2019-2021 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
@ -69,7 +69,7 @@ DIALOG_GLOBAL_LIB_TABLE_CONFIG::DIALOG_GLOBAL_LIB_TABLE_CONFIG( wxWindow* aParen
m_filePicker1->Connect( wxEVT_UPDATE_UI,
wxUpdateUIEventHandler( DIALOG_GLOBAL_LIB_TABLE_CONFIG::onUpdateFilePicker ),
NULL, this );
nullptr, this );
wxButton* okButton = (wxButton *) FindWindowById( wxID_OK );
@ -84,7 +84,7 @@ DIALOG_GLOBAL_LIB_TABLE_CONFIG::~DIALOG_GLOBAL_LIB_TABLE_CONFIG()
{
m_filePicker1->Disconnect( wxEVT_UPDATE_UI,
wxUpdateUIEventHandler( DIALOG_GLOBAL_LIB_TABLE_CONFIG::onUpdateFilePicker ),
NULL, this );
nullptr, this );
}

View File

@ -535,7 +535,8 @@ bool DIALOG_PAGES_SETTINGS::SavePageSettings()
if( !success )
{
wxASSERT_MSG( false, _( "the translation for paper size must preserve original spellings" ) );
wxASSERT_MSG( false,
_( "the translation for paper size must preserve original spellings" ) );
m_pageInfo.SetType( PAGE_INFO::A4 );
}
@ -637,6 +638,7 @@ void DIALOG_PAGES_SETTINGS::UpdateDrawingSheetExample()
wxString pageFmtName = m_pageFmt[idx].BeforeFirst( ' ' );
bool portrait = clamped_layout_size.x < clamped_layout_size.y;
pageDUMMY.SetType( pageFmtName, portrait );
if( m_customFmt )
{
pageDUMMY.SetWidthMils( clamped_layout_size.x );
@ -665,7 +667,8 @@ void DIALOG_PAGES_SETTINGS::UpdateDrawingSheetExample()
renderSettings.SetLayerColor( LAYER_DRAWINGSHEET, color );
}
GRFilledRect( NULL, &memDC, 0, 0, m_layout_size.x, m_layout_size.y, bgColor, bgColor );
GRFilledRect( nullptr, &memDC, 0, 0, m_layout_size.x, m_layout_size.y, bgColor,
bgColor );
PrintDrawingSheet( &renderSettings, pageDUMMY, emptyString, emptyString, m_tb,
m_screen->GetPageCount(), m_screen->GetPageNumber(), 1, &Prj(),
@ -674,7 +677,8 @@ void DIALOG_PAGES_SETTINGS::UpdateDrawingSheetExample()
memDC.SelectObject( wxNullBitmap );
m_PageLayoutExampleBitmap->SetBitmap( *m_pageBitmap );
}
DS_DATA_MODEL::SetAltInstance( NULL );
DS_DATA_MODEL::SetAltInstance( nullptr );
// Refresh the dialog.
Layout();

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2018-2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2018-2021 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
@ -44,8 +44,8 @@ PANEL_COMMON_SETTINGS::PANEL_COMMON_SETTINGS( DIALOG_SHIM* aDialog, wxWindow* aP
m_dialog( aDialog ),
m_last_scale( -1 )
{
m_canvasScaleCtrl->SetRange(
DPI_SCALING::GetMinScaleFactor(), DPI_SCALING::GetMaxScaleFactor() );
m_canvasScaleCtrl->SetRange( DPI_SCALING::GetMinScaleFactor(),
DPI_SCALING::GetMaxScaleFactor() );
m_canvasScaleCtrl->SetDigits( dpi_scaling_precision );
m_canvasScaleCtrl->SetIncrement( dpi_scaling_increment );
m_canvasScaleCtrl->SetValue( DPI_SCALING::GetDefaultScaleFactor() );
@ -79,7 +79,7 @@ PANEL_COMMON_SETTINGS::PANEL_COMMON_SETTINGS( DIALOG_SHIM* aDialog, wxWindow* aP
m_canvasScaleCtrl->Connect( wxEVT_COMMAND_TEXT_UPDATED,
wxCommandEventHandler( PANEL_COMMON_SETTINGS::OnCanvasScaleChange ),
NULL, this );
nullptr, this );
}
@ -87,7 +87,7 @@ PANEL_COMMON_SETTINGS::~PANEL_COMMON_SETTINGS()
{
m_canvasScaleCtrl->Disconnect( wxEVT_COMMAND_TEXT_UPDATED,
wxCommandEventHandler( PANEL_COMMON_SETTINGS::OnCanvasScaleChange ),
NULL, this );
nullptr, this );
}

View File

@ -178,7 +178,7 @@ PANEL_SETUP_NETCLASSES::PANEL_SETUP_NETCLASSES( PAGED_DIALOG* aParent, NETCLASSE
// wxFormBuilder doesn't include this event...
m_netclassGrid->Connect( wxEVT_GRID_CELL_CHANGING,
wxGridEventHandler( PANEL_SETUP_NETCLASSES::OnNetclassGridCellChanging ),
NULL, this );
nullptr, this );
// Handle tooltips for grid
m_netclassGrid->GetGridColLabelWindow()->Bind( wxEVT_MOTION,
@ -204,7 +204,7 @@ PANEL_SETUP_NETCLASSES::~PANEL_SETUP_NETCLASSES()
m_netclassGrid->Disconnect( wxEVT_GRID_CELL_CHANGING,
wxGridEventHandler( PANEL_SETUP_NETCLASSES::OnNetclassGridCellChanging ),
NULL, this );
nullptr, this );
}
@ -373,7 +373,8 @@ bool PANEL_SETUP_NETCLASSES::TransferDataFromWindow()
// Copy other NetClasses:
for( int row = 1; row < m_netclassGrid->GetNumberRows(); ++row )
{
NETCLASSPTR nc = std::make_shared<NETCLASS>( m_netclassGrid->GetCellValue( row, GRID_NAME ) );
NETCLASSPTR nc = std::make_shared<NETCLASS>( m_netclassGrid->GetCellValue( row,
GRID_NAME ) );
if( m_netclasses->Add( nc ) )
gridRowToNetclass( m_Parent->GetUserUnits(), m_netclassGrid, row, nc );
@ -605,7 +606,7 @@ void PANEL_SETUP_NETCLASSES::onmembershipPanelSize( wxSizeEvent& event )
int c_row = m_membershipGrid->GetGridCursorRow();
int c_col = m_membershipGrid->GetGridCursorCol();
if( c_row >= 0 && c_col == 1 ) // this means the class name choice widget is selected (opened)
if( c_row >= 0 && c_col == 1 ) // this means the class name choice widget is selected (opened)
m_membershipGrid->SetGridCursor( c_row, 0 ); // Close it
event.Skip();

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2020-2021 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
@ -58,7 +58,9 @@ PANEL_TEXT_VARIABLES::PANEL_TEXT_VARIABLES( wxWindow* aParent, PROJECT* aProject
m_TextVars->SetSelectionMode( wxGrid::wxGridSelectionModes::wxGridSelectRows );
// wxFormBuilder doesn't include this event...
m_TextVars->Connect( wxEVT_GRID_CELL_CHANGING, wxGridEventHandler( PANEL_TEXT_VARIABLES::OnGridCellChanging ), NULL, this );
m_TextVars->Connect( wxEVT_GRID_CELL_CHANGING,
wxGridEventHandler( PANEL_TEXT_VARIABLES::OnGridCellChanging ),
nullptr, this );
}
@ -67,7 +69,9 @@ PANEL_TEXT_VARIABLES::~PANEL_TEXT_VARIABLES()
// Delete the GRID_TRICKS.
m_TextVars->PopEventHandler( true );
m_TextVars->Disconnect( wxEVT_GRID_CELL_CHANGING, wxGridEventHandler( PANEL_TEXT_VARIABLES::OnGridCellChanging ), NULL, this );
m_TextVars->Disconnect( wxEVT_GRID_CELL_CHANGING,
wxGridEventHandler( PANEL_TEXT_VARIABLES::OnGridCellChanging ),
nullptr, this );
}
@ -193,7 +197,8 @@ void PANEL_TEXT_VARIABLES::OnUpdateUI( wxUpdateUIEvent& event )
int width = m_TextVars->GetClientRect().GetWidth();
m_TextVars->AutoSizeColumn( TV_NAME_COL );
m_TextVars->SetColSize( TV_NAME_COL, std::max( m_TextVars->GetColSize( TV_NAME_COL ), 120 ) );
m_TextVars->SetColSize( TV_NAME_COL, std::max( m_TextVars->GetColSize( TV_NAME_COL ),
120 ) );
m_TextVars->SetColSize( TV_VALUE_COL, width - m_TextVars->GetColSize( TV_NAME_COL ) );
m_gridWidthsDirty = false;

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 CERN
* Copyright (C) 2015-2018 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2015-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
*
* This program is free software: you can redistribute it and/or modify it
@ -33,6 +33,7 @@
#include <wx/msgdlg.h>
#include <wx/menu.h>
WX_HTML_REPORT_PANEL::WX_HTML_REPORT_PANEL( wxWindow* parent,
wxWindowID id,
const wxPoint& pos,
@ -47,7 +48,7 @@ WX_HTML_REPORT_PANEL::WX_HTML_REPORT_PANEL( wxWindow* parent,
m_htmlView->SetPage( addHeader( "" ) );
Connect( wxEVT_COMMAND_MENU_SELECTED,
wxMenuEventHandler( WX_HTML_REPORT_PANEL::onMenuEvent ), NULL, this );
wxMenuEventHandler( WX_HTML_REPORT_PANEL::onMenuEvent ), nullptr, this );
}
@ -249,7 +250,8 @@ void WX_HTML_REPORT_PANEL::onMenuEvent( wxMenuEvent& event )
// Don't globally define this; different facilities use different definitions of "ALL"
static int RPT_SEVERITY_ALL = RPT_SEVERITY_WARNING | RPT_SEVERITY_ERROR | RPT_SEVERITY_INFO | RPT_SEVERITY_ACTION;
static int RPT_SEVERITY_ALL = RPT_SEVERITY_WARNING | RPT_SEVERITY_ERROR | RPT_SEVERITY_INFO |
RPT_SEVERITY_ACTION;
void WX_HTML_REPORT_PANEL::onCheckBoxShowAll( wxCommandEvent& event )

View File

@ -95,9 +95,11 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin
ShowScrollbars( wxSHOW_SB_ALWAYS, wxSHOW_SB_ALWAYS );
EnableScrolling( false, false ); // otherwise Zoom Auto disables GAL canvas
Connect( wxEVT_SIZE, wxSizeEventHandler( EDA_DRAW_PANEL_GAL::onSize ), NULL, this );
Connect( wxEVT_ENTER_WINDOW, wxMouseEventHandler( EDA_DRAW_PANEL_GAL::onEnter ), NULL, this );
Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( EDA_DRAW_PANEL_GAL::onLostFocus ), NULL, this );
Connect( wxEVT_SIZE, wxSizeEventHandler( EDA_DRAW_PANEL_GAL::onSize ), nullptr, this );
Connect( wxEVT_ENTER_WINDOW, wxMouseEventHandler( EDA_DRAW_PANEL_GAL::onEnter ), nullptr,
this );
Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( EDA_DRAW_PANEL_GAL::onLostFocus ), nullptr,
this );
const wxEventType events[] = {
// Binding both EVT_CHAR and EVT_CHAR_HOOK ensures that all key events,
@ -124,7 +126,7 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin
};
for( wxEventType eventType : events )
Connect( eventType, wxEventHandler( EDA_DRAW_PANEL_GAL::OnEvent ), NULL,
Connect( eventType, wxEventHandler( EDA_DRAW_PANEL_GAL::OnEvent ), nullptr,
m_eventDispatcher );
m_pendingRefresh = false;
@ -134,12 +136,12 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin
// Set up timer that prevents too frequent redraw commands
m_refreshTimer.SetOwner( this );
Connect( m_refreshTimer.GetId(), wxEVT_TIMER,
wxTimerEventHandler( EDA_DRAW_PANEL_GAL::onRefreshTimer ), NULL, this );
wxTimerEventHandler( EDA_DRAW_PANEL_GAL::onRefreshTimer ), nullptr, this );
// Set up timer to execute OnShow() method when the window appears on the screen
m_onShowTimer.SetOwner( this );
Connect( m_onShowTimer.GetId(), wxEVT_TIMER,
wxTimerEventHandler( EDA_DRAW_PANEL_GAL::onShowTimer ), NULL, this );
wxTimerEventHandler( EDA_DRAW_PANEL_GAL::onShowTimer ), nullptr, this );
m_onShowTimer.Start( 10 );
}
@ -346,7 +348,7 @@ void EDA_DRAW_PANEL_GAL::StartDrawing()
void EDA_DRAW_PANEL_GAL::StopDrawing()
{
m_drawingEnabled = false;
Disconnect( wxEVT_PAINT, wxPaintEventHandler( EDA_DRAW_PANEL_GAL::onPaint ), NULL, this );
Disconnect( wxEVT_PAINT, wxPaintEventHandler( EDA_DRAW_PANEL_GAL::onPaint ), nullptr, this );
m_pendingRefresh = false;
m_refreshTimer.Stop();
}
@ -377,7 +379,7 @@ void EDA_DRAW_PANEL_GAL::SetTopLayer( int aLayer )
bool EDA_DRAW_PANEL_GAL::SwitchBackend( GAL_TYPE aGalType )
{
// Do not do anything if the currently used GAL is correct
if( aGalType == m_backend && m_gal != NULL )
if( aGalType == m_backend && m_gal != nullptr )
return true;
VECTOR2D grid_size = m_gal ? m_gal->GetGridSize() : VECTOR2D();
@ -387,7 +389,7 @@ bool EDA_DRAW_PANEL_GAL::SwitchBackend( GAL_TYPE aGalType )
// Prevent refreshing canvas during backend switch
StopDrawing();
KIGFX::GAL* new_gal = NULL;
KIGFX::GAL* new_gal = nullptr;
try
{
@ -531,7 +533,8 @@ void EDA_DRAW_PANEL_GAL::onRefreshTimer( wxTimerEvent& aEvent )
{
m_drawing = false;
m_pendingRefresh = true;
Connect( wxEVT_PAINT, wxPaintEventHandler( EDA_DRAW_PANEL_GAL::onPaint ), NULL, this );
Connect( wxEVT_PAINT, wxPaintEventHandler( EDA_DRAW_PANEL_GAL::onPaint ), nullptr,
this );
m_drawingEnabled = true;
}
else

View File

@ -370,6 +370,7 @@ void DSNLEXER::NeedLEFT()
void DSNLEXER::NeedRIGHT()
{
int tok = NextTok();
if( tok != DSN_RIGHT )
Expecting( DSN_RIGHT );
}
@ -378,8 +379,10 @@ void DSNLEXER::NeedRIGHT()
int DSNLEXER::NeedSYMBOL()
{
int tok = NextTok();
if( !IsSymbol( tok ) )
Expecting( DSN_SYMBOL );
return tok;
}
@ -387,8 +390,10 @@ int DSNLEXER::NeedSYMBOL()
int DSNLEXER::NeedSYMBOLorNUMBER()
{
int tok = NextTok();
if( !IsSymbol( tok ) && tok!=DSN_NUMBER )
Expecting( "a symbol or number" );
return tok;
}
@ -396,21 +401,23 @@ int DSNLEXER::NeedSYMBOLorNUMBER()
int DSNLEXER::NeedNUMBER( const char* aExpectation )
{
int tok = NextTok();
if( tok != DSN_NUMBER )
{
wxString errText = wxString::Format(
_( "need a number for '%s'" ), wxString::FromUTF8( aExpectation ).GetData() );
wxString errText = wxString::Format( _( "need a number for '%s'" ),
wxString::FromUTF8( aExpectation ).GetData() );
THROW_PARSE_ERROR( errText, CurSource(), CurLine(), CurLineNumber(), CurOffset() );
}
return tok;
}
/**
* Function isSpace
* tests for whitespace. Our whitespace, by our definition, is a subset of ASCII,
* i.e. no bytes with MSB on can be considered whitespace, since they are likely part
* of a multibyte UTF8 character.
* Test for whitespace.
*
* Our whitespace, by our definition, is a subset of ASCII, i.e. no bytes with MSB on can be
* considered whitespace, since they are likely part of a multibyte UTF8 character.
*/
static bool isSpace( char cc )
{
@ -428,6 +435,7 @@ static bool isSpace( char cc )
return true;
}
}
return false;
}
@ -438,7 +446,7 @@ inline bool isDigit( char cc )
}
/// return true if @a cc is an s-expression separator character
///< @return true if @a cc is an s-expression separator character.
inline bool isSep( char cc )
{
return isSpace( cc ) || cc=='(' || cc==')';
@ -446,15 +454,13 @@ inline bool isSep( char cc )
/**
* Function isNumber
* returns true if the next sequence of text is a number:
* Return true if the next sequence of text is a number:
* either an integer, fixed point, or float with exponent. Stops scanning
* at the first non-number character, even if it is not whitespace.
*
* @param cp is the start of the current token.
* @param limit is the end of the current token.
*
* @return bool - true if input token is a number, else false.
* @return true if input token is a number, else false.
*/
static bool isNumber( const char* cp, const char* limit )
{
@ -522,6 +528,7 @@ L_read:
// blank lines are returned as "\n" and will have a len of 1.
// EOF will have a len of 0 and so is detectable.
int len = readLine();
if( len == 0 )
{
cur = start; // after readLine(), since start can change, set cur offset to start
@ -532,7 +539,7 @@ L_read:
cur = start; // after readLine() since start can change.
// skip leading whitespace
while( cur<limit && isSpace( *cur ) )
while( cur < limit && isSpace( *cur ) )
++cur;
// If the first non-blank character is #, this line is a comment.
@ -556,13 +563,15 @@ L_read:
goto exit;
}
else
{
goto L_read;
}
}
}
else
{
// skip leading whitespace
while( cur<limit && isSpace( *cur ) )
while( cur < limit && isSpace( *cur ) )
++cur;
}
@ -624,33 +633,42 @@ L_read:
case 'v': c = '\x0b'; break;
case 'x': // 1 or 2 byte hex escape sequence
for( i=0; i<2; ++i )
for( i = 0; i < 2; ++i )
{
if( !isxdigit( head[i] ) )
break;
tbuf[i] = head[i];
}
tbuf[i] = '\0';
if( i > 0 )
c = (char) strtoul( tbuf, NULL, 16 );
c = (char) strtoul( tbuf, nullptr, 16 );
else
c = 'x'; // a goofed hex escape sequence, interpret as 'x'
head += i;
break;
default: // 1-3 byte octal escape sequence
--head;
for( i=0; i<3; ++i )
{
if( head[i] < '0' || head[i] > '7' )
break;
tbuf[i] = head[i];
}
tbuf[i] = '\0';
if( i > 0 )
c = (char) strtoul( tbuf, NULL, 8 );
c = (char) strtoul( tbuf, nullptr, 8 );
else
c = '\\'; // a goofed octal escape sequence, interpret as '\'
head += i;
break;
}
@ -676,7 +694,6 @@ L_read:
cur - start + curText.length() );
}
}
else // is specctraMode, tests in this block should not occur in KiCad mode.
{
/* get the dash out of a <pin_reference> which is embedded for example
@ -694,7 +711,8 @@ L_read:
// switching the string_quote character
if( prevTok == DSN_STRING_QUOTE )
{
static const wxString errtxt( _("String delimiter must be a single character of ', \", or $"));
static const wxString errtxt( _("String delimiter must be a single character of "
"', \", or $") );
char cc = *cur;
switch( cc )

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2014 KiCad Developers, see CHANGELOG.TXT for contributors.
* Copyright (C) 2014-2021 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
@ -40,12 +40,6 @@ static const wxString HOSTNAME( wxT( "localhost" ) );
static char client_ipc_buffer[IPC_BUF_SIZE];
/**********************************/
/* Routines related to the server */
/**********************************/
/* Function to initialize a server socket
*/
void KIWAY_PLAYER::CreateServer( int service, bool local )
{
wxIPV4address addr;
@ -66,8 +60,6 @@ void KIWAY_PLAYER::CreateServer( int service, bool local )
}
/* Function called on every client request.
*/
void KIWAY_PLAYER::OnSockRequest( wxSocketEvent& evt )
{
size_t len;
@ -98,8 +90,6 @@ void KIWAY_PLAYER::OnSockRequest( wxSocketEvent& evt )
}
/* Function called when a connection is requested by a client.
*/
void KIWAY_PLAYER::OnSockRequestServer( wxSocketEvent& evt )
{
wxSocketBase* socket;
@ -107,7 +97,7 @@ void KIWAY_PLAYER::OnSockRequestServer( wxSocketEvent& evt )
socket = server->Accept();
if( socket == NULL )
if( socket == nullptr )
return;
m_sockets.push_back( socket );
@ -118,17 +108,14 @@ void KIWAY_PLAYER::OnSockRequestServer( wxSocketEvent& evt )
}
/**********************************/
/* Routines related to the CLIENT */
/**********************************/
/**
* Spins up a thread to send messages via a socket. No message queuing, if a message is in flight
* when another is posted with Send(), the second is just dropped.
* This is a workaround for "non-blocking" sockets not always being non-blocking, especially on
* Windows. It is kept fairly simple and not exposed to the outside world because it should be
* replaced in a future KiCad version with a real message queue of some sort, and unified with the
* Kiway messaging system.
* Spin up a thread to send messages via a socket.
*
* No message queuing, if a message is in flight when another is posted with Send(), the
* second is just dropped. This is a workaround for "non-blocking" sockets not always being
* non-blocking, especially on Windows. It is kept fairly simple and not exposed to the
* outside world because it should be replaced in a future KiCad version with a real message
* queue of some sort, and unified with the Kiway messaging system.
*/
class ASYNC_SOCKET_HOLDER
{
@ -173,10 +160,11 @@ public:
}
/**
* Attempts to send a message if the thread is available
* @param aService is the port number (i.e. service) to send to
* @param aMessage is the message to send
* @return true if the message was queued
* Attempt to send a message if the thread is available.
*
* @param aService is the port number (i.e. service) to send to.
* @param aMessage is the message to send.
* @return true if the message was queued.
*/
bool Send( int aService, const std::string& aMessage )
{
@ -303,12 +291,15 @@ private:
std::unique_ptr<ASYNC_SOCKET_HOLDER> socketHolder = nullptr;
/* Used by a client to sent (by a socket connection) a data to a server.
* - Open a Socket Client connection
* - Send the buffer cmdline
* - Close the socket connection
/**
* Used by a client to sent (by a socket connection) a data to a server.
* - Open a Socket Client connection.
* - Send the buffer cmdline.
* - Close the socket connection.
*
* service is the service number for the TC/IP connection
* @param aService is the service number for the TC/IP connection.
* @param aMessage is the message to send.
*/
bool SendCommand( int aService, const std::string& aMessage )
{

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2014-2019 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2014-2021 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
@ -85,7 +85,7 @@ bool GetAssociatedDocument( wxWindow* aParent, const wxString& aDocName, PROJECT
wxString command;
bool success = false;
#if defined(EESCHEMA)
#if defined( EESCHEMA )
SEARCH_STACK* aPaths = aProject ? aProject->SchSearchS() : nullptr;
#endif
@ -118,9 +118,8 @@ bool GetAssociatedDocument( wxWindow* aParent, const wxString& aDocName, PROJECT
docname.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );
#endif
/* Compute the full file name */
if( wxIsAbsolutePath( docname ) || aPaths == NULL )
if( wxIsAbsolutePath( docname ) || aPaths == nullptr )
fullfilename = docname;
/* If the file exists, this is a trivial case: return the filename
* "as this". the name can be an absolute path, or a relative path
@ -182,7 +181,7 @@ bool GetAssociatedDocument( wxWindow* aParent, const wxString& aDocName, PROJECT
mimeDatabase->AddFallbacks( EDAfallbacks );
filetype = mimeDatabase->GetFileTypeFromExtension( file_ext );
delete mimeDatabase;
mimeDatabase = NULL;
mimeDatabase = nullptr;
}
if( filetype )
@ -203,4 +202,4 @@ bool GetAssociatedDocument( wxWindow* aParent, const wxString& aDocName, PROJECT
}
return success;
}
}

View File

@ -82,7 +82,7 @@ const EDA_RECT EDA_ITEM::GetBoundingBox() const
EDA_ITEM* EDA_ITEM::Clone() const
{
wxCHECK_MSG( false, NULL, wxT( "Clone not implemented in derived class " ) + GetClass() +
wxCHECK_MSG( false, nullptr, wxT( "Clone not implemented in derived class " ) + GetClass() +
wxT( ". Bad programmer!" ) );
}
@ -146,7 +146,7 @@ bool EDA_ITEM::Replace( const wxFindReplaceData& aSearchData, wxString& aText )
{
wxString searchString = (aSearchData.GetFlags() & wxFR_MATCHCASE) ? aText : aText.Upper();
int result = searchString.Find( (aSearchData.GetFlags() & wxFR_MATCHCASE) ?
int result = searchString.Find( ( aSearchData.GetFlags() & wxFR_MATCHCASE ) ?
aSearchData.GetFindString() :
aSearchData.GetFindString().Upper() );
@ -171,11 +171,12 @@ bool EDA_ITEM::Replace( const wxFindReplaceData& aSearchData, wxString& aText )
bool EDA_ITEM::operator<( const EDA_ITEM& aItem ) const
{
wxFAIL_MSG( wxString::Format( wxT( "Less than operator not defined for item type %s." ),
GetClass() ) );
GetClass() ) );
return false;
}
EDA_ITEM& EDA_ITEM::operator=( const EDA_ITEM& aItem )
{
// do not call initVars()
@ -189,6 +190,7 @@ EDA_ITEM& EDA_ITEM::operator=( const EDA_ITEM& aItem )
return *this;
}
const BOX2I EDA_ITEM::ViewBBox() const
{
// Basic fallback
@ -205,12 +207,14 @@ void EDA_ITEM::ViewGetLayers( int aLayers[], int& aCount ) const
aLayers[0] = 0;
}
BITMAPS EDA_ITEM::GetMenuImage() const
{
return BITMAPS::dummy_item;
}
#if defined(DEBUG)
#if defined( DEBUG )
void EDA_ITEM::ShowDummy( std::ostream& os ) const
{
@ -236,9 +240,6 @@ std::ostream& EDA_ITEM::NestedSpace( int nestLevel, std::ostream& os )
#endif
static struct EDA_ITEM_DESC
{
EDA_ITEM_DESC()

View File

@ -614,14 +614,14 @@ std::vector<wxPoint> EDA_TEXT::TransformToSegmentList() const
for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
{
wxString txt = strings_list.Item( ii );
GRText( NULL, positions[ii], color, txt, GetDrawRotation(), size, GetHorizJustify(),
GRText( nullptr, positions[ii], color, txt, GetDrawRotation(), size, GetHorizJustify(),
GetVertJustify(), penWidth, IsItalic(), forceBold, addTextSegmToBuffer,
&cornerBuffer );
}
}
else
{
GRText( NULL, GetTextPos(), color, GetShownText(), GetDrawRotation(), size,
GRText( nullptr, GetTextPos(), color, GetShownText(), GetDrawRotation(), size,
GetHorizJustify(), GetVertJustify(), penWidth, IsItalic(), forceBold,
addTextSegmToBuffer, &cornerBuffer );
}
@ -671,13 +671,16 @@ static struct EDA_TEXT_DESC
&EDA_TEXT::GetTextThickness,
PROPERTY_DISPLAY::DISTANCE ) );
propMgr.AddProperty( new PROPERTY<EDA_TEXT, bool>( _HKI( "Italic" ),
&EDA_TEXT::SetItalic, &EDA_TEXT::IsItalic ) );
&EDA_TEXT::SetItalic,
&EDA_TEXT::IsItalic ) );
propMgr.AddProperty( new PROPERTY<EDA_TEXT, bool>( _HKI( "Bold" ),
&EDA_TEXT::SetBold, &EDA_TEXT::IsBold ) );
&EDA_TEXT::SetBold, &EDA_TEXT::IsBold ) );
propMgr.AddProperty( new PROPERTY<EDA_TEXT, bool>( _HKI( "Mirrored" ),
&EDA_TEXT::SetMirrored, &EDA_TEXT::IsMirrored ) );
&EDA_TEXT::SetMirrored,
&EDA_TEXT::IsMirrored ) );
propMgr.AddProperty( new PROPERTY<EDA_TEXT, bool>( _HKI( "Visible" ),
&EDA_TEXT::SetVisible, &EDA_TEXT::IsVisible ) );
&EDA_TEXT::SetVisible,
&EDA_TEXT::IsVisible ) );
propMgr.AddProperty( new PROPERTY<EDA_TEXT, int>( _HKI( "Width" ),
&EDA_TEXT::SetTextWidth,
&EDA_TEXT::GetTextWidth,

View File

@ -3,7 +3,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2007-2010 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2007 KiCad Developers, see change_log.txt for contributors.
* Copyright (C) 2007-2021 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
@ -53,7 +53,7 @@ char* FILTER_READER::ReadLine()
{
char* s;
while( ( s = reader.ReadLine() ) != NULL )
while( ( s = reader.ReadLine() ) != nullptr )
{
if( !strchr( "#\n\r", s[0] ) )
break;
@ -91,12 +91,12 @@ char* WHITESPACE_FILTER_READER::ReadLine()
{
char* s;
while( ( s = reader.ReadLine() ) != NULL )
while( ( s = reader.ReadLine() ) != nullptr )
{
while( s != NULL && strchr( " \t", *s ) )
while( s != nullptr && strchr( " \t", *s ) )
s++;
if( s != NULL && !strchr( "#\n\r", *s ) )
if( s != nullptr && !strchr( "#\n\r", *s ) )
break;
}

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2011 Jean-Pierre Charras, <jp.charras@wanadoo.fr>
* Copyright (C) 2013-2016 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2021 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
@ -43,7 +43,7 @@ FOOTPRINT_INFO* FOOTPRINT_LIST::GetFootprintInfo( const wxString& aLibNickname,
const wxString& aFootprintName )
{
if( aFootprintName.IsEmpty() )
return NULL;
return nullptr;
for( std::unique_ptr<FOOTPRINT_INFO>& fp : m_list )
{
@ -51,18 +51,18 @@ FOOTPRINT_INFO* FOOTPRINT_LIST::GetFootprintInfo( const wxString& aLibNickname,
return fp.get();
}
return NULL;
return nullptr;
}
FOOTPRINT_INFO* FOOTPRINT_LIST::GetFootprintInfo( const wxString& aFootprintName )
{
if( aFootprintName.IsEmpty() )
return NULL;
return nullptr;
LIB_ID fpid;
wxCHECK_MSG( fpid.Parse( aFootprintName ) < 0, NULL,
wxCHECK_MSG( fpid.Parse( aFootprintName ) < 0, nullptr,
wxString::Format( wxT( "'%s' is not a valid LIB_ID." ), aFootprintName ) );
return GetFootprintInfo( fpid.GetLibNickname(), fpid.GetLibItemName() );

View File

@ -467,7 +467,7 @@ FOOTPRINT* FP_LIB_TABLE::FootprintLoadWithOptionalNickname( const LIB_ID& aFootp
return ret;
}
return NULL;
return nullptr;
}
}

View File

@ -277,7 +277,8 @@ void CAIRO_GAL_BASE::DrawSegment( const VECTOR2D& aStartPoint, const VECTOR2D& a
cairo_move_to( m_currentContext, pa1.x, pa1.y );
cairo_line_to( m_currentContext, pb1.x, pb1.y );
cairo_arc( m_currentContext, pb.x, pb.y, rb, lineAngle - M_PI / 2.0, lineAngle + M_PI / 2.0 );
cairo_arc( m_currentContext, pb.x, pb.y, rb, lineAngle - M_PI / 2.0,
lineAngle + M_PI / 2.0 );
cairo_arc( m_currentContext, pa.x, pa.y, rb, lineAngle + M_PI / 2.0,
lineAngle + 3.0 * M_PI / 2.0 );
@ -811,7 +812,8 @@ void CAIRO_GAL_BASE::DrawGroup( int aGroupNumber )
double x = 1.0, y = 1.0;
cairo_device_to_user_distance( m_currentContext, &x, &y );
double minWidth = std::min( fabs( x ), fabs( y ) );
cairo_set_line_width( m_currentContext, std::max( it->m_Argument.DblArg[0], minWidth ) );
cairo_set_line_width( m_currentContext,
std::max( it->m_Argument.DblArg[0], minWidth ) );
break;
}
@ -1067,8 +1069,8 @@ void CAIRO_GAL_BASE::storePath()
{
if( m_isFillEnabled )
{
cairo_set_source_rgba( m_currentContext, m_fillColor.r, m_fillColor.g, m_fillColor.b,
m_fillColor.a );
cairo_set_source_rgba( m_currentContext, m_fillColor.r, m_fillColor.g,
m_fillColor.b, m_fillColor.a );
cairo_fill_preserve( m_currentContext );
}
@ -1231,7 +1233,7 @@ CAIRO_GAL::CAIRO_GAL( GAL_DISPLAY_OPTIONS& aDisplayOptions, wxWindow* aParent,
m_paintListener = aPaintListener;
// Connect the native cursor handler
Connect( wxEVT_SET_CURSOR, wxSetCursorEventHandler( CAIRO_GAL::onSetNativeCursor ), NULL,
Connect( wxEVT_SET_CURSOR, wxSetCursorEventHandler( CAIRO_GAL::onSetNativeCursor ), nullptr,
this );
// Connecting the event handlers
@ -1302,8 +1304,8 @@ void CAIRO_GAL::endDrawing()
pixman_image_create_bits( PIXMAN_a8r8g8b8, m_screenSize.x, m_screenSize.y,
(uint32_t*) m_bitmapBuffer, m_wxBufferWidth * 4 );
pixman_image_composite( PIXMAN_OP_SRC, srcImg, NULL, dstImg, 0, 0, 0, 0, 0, 0, m_screenSize.x,
m_screenSize.y );
pixman_image_composite( PIXMAN_OP_SRC, srcImg, nullptr, dstImg, 0, 0, 0, 0, 0, 0,
m_screenSize.x, m_screenSize.y );
// Free allocated memory
pixman_image_unref( srcImg );
@ -1519,7 +1521,8 @@ bool CAIRO_GAL::updatedGalDisplayOptions( const GAL_DISPLAY_OPTIONS& aOptions )
{
bool refresh = false;
if( m_validCompositor && aOptions.cairo_antialiasing_mode != m_compositor->GetAntialiasingMode() )
if( m_validCompositor &&
aOptions.cairo_antialiasing_mode != m_compositor->GetAntialiasingMode() )
{
m_compositor->SetAntialiasingMode( m_options.cairo_antialiasing_mode );
m_validCompositor = false;

View File

@ -54,7 +54,7 @@ GPU_MANAGER* GPU_MANAGER::MakeManager( VERTEX_CONTAINER* aContainer )
GPU_MANAGER::GPU_MANAGER( VERTEX_CONTAINER* aContainer ) :
m_isDrawing( false ),
m_container( aContainer ),
m_shader( NULL ),
m_shader( nullptr ),
m_shaderAttrib( 0 ),
m_enableDepthTest( true )
{
@ -73,7 +73,7 @@ void GPU_MANAGER::SetShader( SHADER& aShader )
if( m_shaderAttrib == -1 )
{
DisplayError( NULL, wxT( "Could not get the shader attribute location" ) );
DisplayError( nullptr, wxT( "Could not get the shader attribute location" ) );
}
}
@ -82,7 +82,7 @@ void GPU_MANAGER::SetShader( SHADER& aShader )
GPU_CACHED_MANAGER::GPU_CACHED_MANAGER( VERTEX_CONTAINER* aContainer ) :
GPU_MANAGER( aContainer ),
m_buffersInitialized( false ),
m_indicesPtr( NULL ),
m_indicesPtr( nullptr ),
m_indicesBuffer( 0 ),
m_indicesSize( 0 ),
m_indicesCapacity( 0 )
@ -184,7 +184,7 @@ void GPU_CACHED_MANAGER::EndDrawing()
glVertexPointer( COORD_STRIDE, GL_FLOAT, VERTEX_SIZE, (GLvoid*) COORD_OFFSET );
glColorPointer( COLOR_STRIDE, GL_UNSIGNED_BYTE, VERTEX_SIZE, (GLvoid*) COLOR_OFFSET );
if( m_shader != NULL ) // Use shader if applicable
if( m_shader != nullptr ) // Use shader if applicable
{
m_shader->Use();
glEnableVertexAttribArray( m_shaderAttrib );
@ -196,7 +196,7 @@ void GPU_CACHED_MANAGER::EndDrawing()
glBufferData( GL_ELEMENT_ARRAY_BUFFER, m_indicesSize * sizeof( int ), (GLvoid*) m_indices.get(),
GL_DYNAMIC_DRAW );
glDrawElements( GL_TRIANGLES, m_indicesSize, GL_UNSIGNED_INT, NULL );
glDrawElements( GL_TRIANGLES, m_indicesSize, GL_UNSIGNED_INT, nullptr );
#ifdef KICAD_GAL_PROFILE
wxLogTrace( traceGalProfile, wxT( "Cached manager size: %d" ), m_indicesSize );
@ -210,7 +210,7 @@ void GPU_CACHED_MANAGER::EndDrawing()
glDisableClientState( GL_COLOR_ARRAY );
glDisableClientState( GL_VERTEX_ARRAY );
if( m_shader != NULL )
if( m_shader != nullptr )
{
glDisableVertexAttribArray( m_shaderAttrib );
m_shader->Deactivate();
@ -287,7 +287,7 @@ void GPU_NONCACHED_MANAGER::EndDrawing()
glVertexPointer( COORD_STRIDE, GL_FLOAT, VERTEX_SIZE, coordinates );
glColorPointer( COLOR_STRIDE, GL_UNSIGNED_BYTE, VERTEX_SIZE, colors );
if( m_shader != NULL ) // Use shader if applicable
if( m_shader != nullptr ) // Use shader if applicable
{
GLfloat* shaders = (GLfloat*) ( vertices ) + SHADER_OFFSET / sizeof( GLfloat );
@ -307,7 +307,7 @@ void GPU_NONCACHED_MANAGER::EndDrawing()
glDisableClientState( GL_COLOR_ARRAY );
glDisableClientState( GL_VERTEX_ARRAY );
if( m_shader != NULL )
if( m_shader != nullptr )
{
glDisableVertexAttribArray( m_shaderAttrib );
m_shader->Deactivate();

View File

@ -73,7 +73,7 @@ VERTEX* NONCACHED_CONTAINER::Allocate( unsigned int aSize )
VERTEX* newVertices =
static_cast<VERTEX*>( realloc( m_vertices, m_currentSize * 2 * sizeof( VERTEX ) ) );
if( newVertices != NULL )
if( newVertices != nullptr )
{
m_vertices = newVertices;
m_freeSpace += m_currentSize;

Some files were not shown because too many files have changed in this diff Show More