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;

View File

@ -199,7 +199,7 @@ unsigned int OPENGL_COMPOSITOR::CreateBuffer( VECTOR2U aDimensions )
// Set texture parameters
glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA8, aDimensions.x, aDimensions.y, 0, GL_RGBA,
GL_UNSIGNED_BYTE, NULL );
GL_UNSIGNED_BYTE, nullptr );
checkGlError( "creating framebuffer texture", __FILE__, __LINE__ );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );

View File

@ -79,7 +79,7 @@ using namespace KIGFX::BUILTIN_FONT;
static void InitTesselatorCallbacks( GLUtesselator* aTesselator );
static const int glAttributes[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_DEPTH_SIZE, 8, 0 };
wxGLContext* OPENGL_GAL::m_glMainContext = NULL;
wxGLContext* OPENGL_GAL::m_glMainContext = nullptr;
int OPENGL_GAL::m_instanceCounter = 0;
GLuint OPENGL_GAL::g_fontTexture = 0;
bool OPENGL_GAL::m_isBitmapFontLoaded = false;
@ -210,7 +210,7 @@ OPENGL_GAL::OPENGL_GAL( GAL_DISPLAY_OPTIONS& aDisplayOptions, wxWindow* aParent,
m_isContextLocked( false ),
m_lockClientCookie( 0 )
{
if( m_glMainContext == NULL )
if( m_glMainContext == nullptr )
{
m_glMainContext = GL_CONTEXT_MANAGER::Get().CreateCtx( this );
@ -237,7 +237,7 @@ OPENGL_GAL::OPENGL_GAL( GAL_DISPLAY_OPTIONS& aDisplayOptions, wxWindow* aParent,
m_groupCounter = 0;
// Connect the native cursor handler
Connect( wxEVT_SET_CURSOR, wxSetCursorEventHandler( OPENGL_GAL::onSetNativeCursor ), NULL,
Connect( wxEVT_SET_CURSOR, wxSetCursorEventHandler( OPENGL_GAL::onSetNativeCursor ), nullptr,
this );
// Connecting the event handlers
@ -325,7 +325,7 @@ OPENGL_GAL::~OPENGL_GAL()
GL_CONTEXT_MANAGER::Get().UnlockCtx( m_glMainContext );
GL_CONTEXT_MANAGER::Get().DestroyCtx( m_glMainContext );
m_glMainContext = NULL;
m_glMainContext = nullptr;
}
}
@ -334,8 +334,8 @@ wxString OPENGL_GAL::CheckFeatures( GAL_DISPLAY_OPTIONS& aOptions )
{
wxString retVal = wxEmptyString;
wxFrame* testFrame = new wxFrame( NULL, wxID_ANY, wxT( "" ), wxDefaultPosition, wxSize( 1, 1 ),
wxFRAME_TOOL_WINDOW | wxNO_BORDER );
wxFrame* testFrame = new wxFrame( nullptr, wxID_ANY, wxT( "" ), wxDefaultPosition,
wxSize( 1, 1 ), wxFRAME_TOOL_WINDOW | wxNO_BORDER );
KIGFX::OPENGL_GAL* opengl_gal = nullptr;
@ -407,7 +407,8 @@ double OPENGL_GAL::getWorldPixelSize() const
VECTOR2D OPENGL_GAL::getScreenPixelSize() const
{
double sf = GetScaleFactor();
return VECTOR2D( 2.0 / (double) ( m_screenSize.x * sf ), 2.0 / (double) ( m_screenSize.y * sf ) );
return VECTOR2D( 2.0 / (double) ( m_screenSize.x * sf ), 2.0 /
(double) ( m_screenSize.y * sf ) );
}
@ -449,6 +450,7 @@ void OPENGL_GAL::beginDrawing()
wxLogVerbose( "Could not create a framebuffer for overlays.\n" );
m_overlayBuffer = 0;
}
m_isFramebufferInitialized = true;
}
@ -2199,7 +2201,7 @@ void OPENGL_GAL::init()
if( !m_glPrivContext )
throw std::runtime_error( "Could not create a private OpenGL context" );
if( m_tesselator == NULL )
if( m_tesselator == nullptr )
throw std::runtime_error( "Could not create the m_tesselator" );
// End initialization checks
@ -2332,6 +2334,7 @@ inline double round_to_half_pixel( double f, double r )
return ( ceil( f / r ) - 0.5 ) * r;
}
void OPENGL_GAL::ComputeWorldScreenMatrix()
{
computeWorldScale();

View File

@ -79,6 +79,7 @@ SHADER::~SHADER()
}
}
bool SHADER::LoadShaderFromFile( SHADER_TYPE aShaderType, const std::string& aShaderSourceName )
{
// Load shader sources
@ -253,7 +254,7 @@ bool SHADER::loadShaderFromStringArray( SHADER_TYPE aShaderType, const char** aA
programInfo( programNumber );
// Attach the sources
glShaderSource( shaderNumber, aSize, (const GLchar**) aArray, NULL );
glShaderSource( shaderNumber, aSize, (const GLchar**) aArray, nullptr );
programInfo( programNumber );
// Compile and attach shader to the program

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2019 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2019 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
@ -33,6 +33,7 @@
#include <gbr_metadata.h>
#include <utf8.h>
wxString GbrMakeCreationDateAttributeString( GBR_NC_STRING_FORMAT aFormat )
{
// creates the CreationDate attribute:
@ -41,9 +42,11 @@ wxString GbrMakeCreationDateAttributeString( GBR_NC_STRING_FORMAT aFormat )
// the date the Gerber file was effectively created,
// not the time the project of PCB was started
wxDateTime date( wxDateTime::GetTimeNow() );
// Date format: see http://www.cplusplus.com/reference/ctime/strftime
wxString timezone_offset; // ISO 8601 offset from UTC in timezone
timezone_offset = date.Format( "%z" ); // Extract the time zone offset
// The time zone offset format is +mm or +hhmm (or -mm or -hhmm)
// (mm = number of minutes, hh = number of hours. 1h00mn is returned as +0100)
// we want +(or -) hh:mm
@ -87,7 +90,8 @@ wxString GbrMakeProjectGUIDfromString( const wxString& aText )
* M = '1' or '4' (UUID version: 1 (basic) or 4 (random)) (we use 4: UUID random)
* and
* N = '8' or '9' or 'A|a' or 'B|b' : UUID variant 1: 2 MSB bits have meaning) (we use N = 9)
* N = 1000 or 1001 or 1010 or 1011 : 10xx means Variant 1 (Variant2: 110x and 111x are reserved)
* N = 1000 or 1001 or 1010 or 1011 : 10xx means Variant 1 (Variant2: 110x and 111x are
* reserved)
*/
wxString guid;
@ -158,7 +162,8 @@ std::string GBR_APERTURE_METADATA::FormatAttribute( GBR_APERTURE_ATTRIB aAttribu
// generate a string to print a Gerber Aperture attribute
switch( aAttribute )
{
case GBR_APERTURE_ATTRIB_END: // Dummy value (aAttribute must be < GBR_APERTURE_ATTRIB_END)
// Dummy value (aAttribute must be < GBR_APERTURE_ATTRIB_END).
case GBR_APERTURE_ATTRIB_END:
case GBR_APERTURE_ATTRIB_NONE: // idle command: do nothing
break;
@ -211,11 +216,13 @@ std::string GBR_APERTURE_METADATA::FormatAttribute( GBR_APERTURE_ATTRIB aAttribu
attribute_string = "TA.AperFunction,BGAPad,CuDef";
break;
case GBR_APERTURE_ATTRIB_CONNECTORPAD: // print info associated to a flashed edge connector pad (outer layers)
case GBR_APERTURE_ATTRIB_CONNECTORPAD:
// print info associated to a flashed edge connector pad (outer layers)
attribute_string = "TA.AperFunction,ConnectorPad";
break;
case GBR_APERTURE_ATTRIB_WASHERPAD: // print info associated to flashed mechanical pads (NPTH)
case GBR_APERTURE_ATTRIB_WASHERPAD:
// print info associated to flashed mechanical pads (NPTH)
attribute_string = "TA.AperFunction,WasherPad";
break;
@ -239,13 +246,13 @@ std::string GBR_APERTURE_METADATA::FormatAttribute( GBR_APERTURE_ATTRIB aAttribu
attribute_string = "TA.AperFunction,FiducialPad,Local";
break;
case GBR_APERTURE_ATTRIB_CASTELLATEDPAD: // print info associated to a flashed castellated pad
// (typically for SMDs)
case GBR_APERTURE_ATTRIB_CASTELLATEDPAD:
// print info associated to a flashed castellated pad (typically for SMDs)
attribute_string = "TA.AperFunction,CastellatedPad";
break;
case GBR_APERTURE_ATTRIB_CASTELLATEDDRILL: // print info associated to a flashed castellated pad
// in drill files
case GBR_APERTURE_ATTRIB_CASTELLATEDDRILL:
// print info associated to a flashed castellated pad in drill files
attribute_string = "TA.AperFunction,CastellatedDrill";
break;
@ -363,9 +370,9 @@ wxString FormatStringFromGerber( const wxString& aString )
{
// make the inverse conversion of FormatStringToGerber()
// It converts a "normalized" gerber string containing escape sequences
// and convert it to a 16 bits unicode char
// and return a wxString (unicode 16) from the gerber string
// Note the initial gerber string can already contain unicode chars.
// and convert it to a 16 bits Unicode char
// and return a wxString (Unicode 16) from the gerber string
// Note the initial gerber string can already contain Unicode chars.
wxString txt; // The string converted from Gerber string
unsigned count = aString.Length();
@ -377,9 +384,9 @@ wxString FormatStringFromGerber( const wxString& aString )
if( code == '\\' && ii < count-5 && aString[ii+1] == 'u' )
{
// Note the latest Gerber X2 spec (2019 06) uses \uXXXX to encode
// the unicode XXXX hexadecimal value
// the Unicode XXXX hexadecimal value
// If 4 chars next to 'u' are hexadecimal chars,
// Convert these 4 hexadecimal digits to a 16 bit unicode
// Convert these 4 hexadecimal digits to a 16 bit Unicode
// (Gerber allows only 4 hexadecimal digits)
// If an error occurs, the escape sequence is not translated,
// and used "as this"
@ -416,20 +423,23 @@ wxString FormatStringFromGerber( const wxString& aString )
}
}
else
{
txt.Append( aString[ii] );
}
}
return txt;
}
wxString ConvertNotAllowedCharsInGerber( const wxString& aString, bool aAllowUtf8Chars, bool aQuoteString )
wxString ConvertNotAllowedCharsInGerber( const wxString& aString, bool aAllowUtf8Chars,
bool aQuoteString )
{
/* format string means convert any code > 0x7E and unautorized codes to a hexadecimal
* 16 bits sequence unicode
* However if aAllowUtf8Chars is true only unautorized codes will be escaped, because some
/* format string means convert any code > 0x7E and unauthorized codes to a hexadecimal
* 16 bits sequence Unicode
* However if aAllowUtf8Chars is true only unauthorized codes will be escaped, because some
* Gerber files accept UTF8 chars.
* unautorized codes are ',' '*' '%' '\' '"' and are used as separators in Gerber files
* unauthorized codes are ',' '*' '%' '\' '"' and are used as separators in Gerber files
*/
wxString txt;
@ -466,13 +476,15 @@ wxString ConvertNotAllowedCharsInGerber( const wxString& aString, bool aAllowUtf
{
// Convert code to 4 hexadecimal digit
// (Gerber allows only 4 hexadecimal digit) in escape seq:
// "\uXXXX", XXXX is the unicode 16 bits hexa value
// "\uXXXX", XXXX is the Unicode 16 bits hexa value
char hexa[32];
sprintf( hexa,"\\u%4.4X", code & 0xFFFF);
txt += hexa;
}
else
{
txt += code;
}
}
if( aQuoteString )
@ -500,9 +512,10 @@ std::string GBR_DATA_FIELD::GetGerberString() const
std::string FormatStringToGerber( const wxString& aString )
{
wxString converted;
/* format string means convert any code > 0x7E and unautorized codes to a hexadecimal
* 16 bits sequence unicode
* unautorized codes are ',' '*' '%' '\'
/* format string means convert any code > 0x7E and unauthorized codes to a hexadecimal
* 16 bits sequence Unicode
* unauthorized codes are ',' '*' '%' '\'
* This conversion is not made for quoted strings, because if the string is
* quoted, the conversion is expected to be already made, and the returned string must use
* UTF8 encoding
@ -512,18 +525,20 @@ std::string FormatStringToGerber( const wxString& aString )
else
converted = aString;
// Convert the char string to std::string. Be careful when converting awxString to
// Convert the char string to std::string. Be careful when converting a wxString to
// a std::string: using static_cast<const char*> is mandatory
std::string txt = static_cast<const char*>( converted.utf8_str() );
return txt;
}
// Netname and Pan num fields cannot be empty in Gerber files
// Normalized names must be used, if any
#define NO_NET_NAME wxT( "N/C" ) // net name of not connected pads (one pad net) (normalized)
#define NO_PAD_NAME wxT( "" ) // pad name of pads without pad name/number (not normalized)
bool FormatNetAttribute( std::string& aPrintedText, std::string& aLastNetAttributes,
const GBR_NETLIST_METADATA* aData, bool& aClearPreviousAttributes,
bool aUseX1StructuredComment )
@ -546,7 +561,7 @@ bool FormatNetAttribute( std::string& aPrintedText, std::string& aLastNetAttribu
// print a Gerber net attribute record.
// it is added to the object attributes dictionary
// On file, only modified or new attributes are printed.
if( aData == NULL )
if( aData == nullptr )
return false;
std::string pad_attribute_string;
@ -565,8 +580,10 @@ bool FormatNetAttribute( std::string& aPrintedText, std::string& aLastNetAttribu
pad_attribute_string += FormatStringToGerber( aData->m_Cmpref ) + ",";
if( aData->m_Padname.IsEmpty() )
{
// Happens for "mechanical" or never connected pads
pad_attribute_string += FormatStringToGerber( NO_PAD_NAME );
}
else
{
pad_attribute_string += aData->m_Padname.GetGerberString();
@ -605,7 +622,9 @@ bool FormatNetAttribute( std::string& aPrintedText, std::string& aLastNetAttribu
}
}
else
{
net_attribute_string += FormatStringToGerber( aData->m_Netname );
}
net_attribute_string += eol_string;
}
@ -633,7 +652,7 @@ bool FormatNetAttribute( std::string& aPrintedText, std::string& aLastNetAttribu
if( aLastNetAttributes != full_attribute_string )
{
// first, remove no longer existing attributes.
// Because in Kicad the full attribute list is evaluated for each object,
// Because in KiCad the full attribute list is evaluated for each object,
// the entire dictionary is cleared
// If m_TryKeepPreviousAttributes is true, only the no longer existing attribute
// is cleared.
@ -650,12 +669,16 @@ bool FormatNetAttribute( std::string& aPrintedText, std::string& aLastNetAttribu
else
clearDict = true;
}
else if( aLastNetAttributes.find( pad_attribute_string )
== std::string::npos ) // This attribute has changed
else if( aLastNetAttributes.find( pad_attribute_string ) == std::string::npos )
{
// This attribute has changed
short_attribute_string += pad_attribute_string;
}
}
else // New attribute
{
short_attribute_string += pad_attribute_string;
}
if( aLastNetAttributes.find( "TO.N," ) != std::string::npos )
{
@ -666,12 +689,16 @@ bool FormatNetAttribute( std::string& aPrintedText, std::string& aLastNetAttribu
else
clearDict = true;
}
else if( aLastNetAttributes.find( net_attribute_string )
== std::string::npos ) // This attribute has changed
else if( aLastNetAttributes.find( net_attribute_string ) == std::string::npos )
{
// This attribute has changed.
short_attribute_string += net_attribute_string;
}
}
else // New attribute
{
short_attribute_string += net_attribute_string;
}
if( aLastNetAttributes.find( "TO.C," ) != std::string::npos )
{
@ -687,14 +714,20 @@ bool FormatNetAttribute( std::string& aPrintedText, std::string& aLastNetAttribu
short_attribute_string.insert( 0, prepend_string + "TO.C" + eol_string );
}
else
{
clearDict = true;
}
}
else if( aLastNetAttributes.find( cmp_attribute_string )
== std::string::npos ) // This attribute has changed
else if( aLastNetAttributes.find( cmp_attribute_string ) == std::string::npos )
{
// This attribute has changed.
short_attribute_string += cmp_attribute_string;
}
}
else // New attribute
{
short_attribute_string += cmp_attribute_string;
}
aClearPreviousAttributes = clearDict;
@ -710,8 +743,6 @@ bool FormatNetAttribute( std::string& aPrintedText, std::string& aLastNetAttribu
}
/************ class GBR_CMP_PNP_METADATA *************/
void GBR_CMP_PNP_METADATA::ClearData()
{
// Clear all strings
@ -722,6 +753,8 @@ void GBR_CMP_PNP_METADATA::ClearData()
m_Value.Clear();
m_MountType = MOUNT_TYPE_UNSPECIFIED;
}
/**
* @return a string containing the formatted metadata in X2 syntax.
* one line by non empty data
@ -730,7 +763,7 @@ void GBR_CMP_PNP_METADATA::ClearData()
wxString GBR_CMP_PNP_METADATA::FormatCmpPnPMetadata()
{
wxString text;
wxString start_of_line( "%TO.");
wxString start_of_line( "%TO." );
wxString end_of_line( "*%\n" );
wxString mounType[] =

View File

@ -73,7 +73,7 @@ wxString EDA_FILE_SELECTOR( const wxString& aTitle,
if( defaultpath.IsEmpty() )
{
if( aMruPath == NULL )
if( aMruPath == nullptr )
defaultpath = wxGetCwd();
else
defaultpath = *aMruPath;
@ -246,14 +246,14 @@ bool OpenPDF( const wxString& file )
{
wxString msg;
msg.Printf( _( "Problem while running the PDF viewer.\nCommand is '%s'." ), command );
DisplayError( NULL, msg );
DisplayError( nullptr, msg );
}
}
else
{
wxString msg;
msg.Printf( _( "Unable to find a PDF viewer for '%s'." ), file );
DisplayError( NULL, msg );
DisplayError( nullptr, msg );
}
return false;
@ -316,10 +316,10 @@ bool doPrintFile( const wxString& file, bool aDryRun )
if( !application.IsEmpty() )
{
printCommand.Printf( "osascript -e 'tell application \"%s\"' "
"-e ' set srcFileRef to (open POSIX file \"%s\")' "
"-e ' activate' "
"-e ' print srcFileRef print dialog true' "
"-e 'end tell' ",
"-e ' set srcFileRef to (open POSIX file \"%s\")' "
"-e ' activate' "
"-e ' print srcFileRef print dialog true' "
"-e 'end tell' ",
application,
file );

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2016 CERN
* Copyright (C) 2017 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2017-2021 KiCad Developers, see AUTHORS.txt for contributors.
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
* This program is free software; you can redistribute it and/or
@ -26,6 +26,7 @@
#include <gl_context_mgr.h>
#include <wx/debug.h>
GL_CONTEXT_MANAGER& GL_CONTEXT_MANAGER::Get()
{
static GL_CONTEXT_MANAGER instance;
@ -33,6 +34,7 @@ GL_CONTEXT_MANAGER& GL_CONTEXT_MANAGER::Get()
return instance;
}
wxGLContext* GL_CONTEXT_MANAGER::CreateCtx( wxGLCanvas* aCanvas, const wxGLContext* aOther )
{
wxGLContext* context = new wxGLContext( aCanvas, aOther );
@ -66,7 +68,7 @@ void GL_CONTEXT_MANAGER::DestroyCtx( wxGLContext* aContext )
}
if( m_glCtx == aContext )
m_glCtx = NULL;
m_glCtx = nullptr;
}
@ -78,7 +80,7 @@ void GL_CONTEXT_MANAGER::DeleteAll()
delete ctx.first;
m_glContexts.clear();
m_glCtx = NULL;
m_glCtx = nullptr;
m_glCtxMutex.unlock();
}
@ -109,7 +111,7 @@ void GL_CONTEXT_MANAGER::UnlockCtx( wxGLContext* aContext )
if( m_glCtx == aContext )
{
m_glCtxMutex.unlock();
m_glCtx = NULL;
m_glCtx = nullptr;
}
else
{
@ -120,7 +122,7 @@ void GL_CONTEXT_MANAGER::UnlockCtx( wxGLContext* aContext )
GL_CONTEXT_MANAGER::GL_CONTEXT_MANAGER()
: m_glCtx( NULL )
: m_glCtx( nullptr )
{
}

View File

@ -2,8 +2,8 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@gmail.com>
* 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 as published by the
@ -93,9 +93,10 @@ static int xcliplo = 0,
static COLOR4D s_DC_lastcolor( 0, 0, 0, 0 );
static COLOR4D s_DC_lastbrushcolor( 0, 0, 0, 0 );
static bool s_DC_lastbrushfill = false;
static wxDC* s_DC_lastDC = NULL;
static wxDC* s_DC_lastDC = nullptr;
static void WinClipAndDrawLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int width )
static void WinClipAndDrawLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int width )
{
GRLastMoveToX = x2;
GRLastMoveToY = y2;
@ -120,17 +121,17 @@ void GRResetPenAndBrush( wxDC* DC )
GRSetBrush( DC, BLACK ); // Force no fill
s_DC_lastbrushcolor = COLOR4D::UNSPECIFIED;
s_DC_lastcolor = COLOR4D::UNSPECIFIED;
s_DC_lastDC = NULL;
s_DC_lastDC = nullptr;
}
/**
* Function GRSetColorPen
* sets a pen style, width, color, and alpha into the given device context.
* Set a pen style, width, color, and alpha into the given device context.
*/
void GRSetColorPen( wxDC* DC, COLOR4D Color, int width, wxPenStyle style )
{
wxDash dots[2] = { 1, 3 };
// Under OSX and while printing when wxPen is set to 0, renderer follows the request drawing
// nothing & in the bitmap world the minimum is enough to light a pixel, in vectorial one not
if( width <= 1 )
@ -147,21 +148,25 @@ void GRSetColorPen( wxDC* DC, COLOR4D Color, int width, wxPenStyle style )
{
wxPen pen;
pen.SetColour( Color.ToColour() );
if( style == wxPENSTYLE_DOT )
{
style = wxPENSTYLE_USER_DASH;
pen.SetDashes( 2, dots );
}
pen.SetWidth( width );
pen.SetStyle( style );
DC->SetPen( pen );
}
else
{
// Should be not needed, but on Linux, in printing process
// the curr pen settings needs to be sometimes re-initialized
// Clearly, this is due to a bug, related to SetBrush(),
// but we have to live with it, at least on wxWidgets 3.0
DC->SetPen( curr_pen );
}
}
@ -193,8 +198,7 @@ void GRSetBrush( wxDC* DC, COLOR4D Color, bool fill )
/**
* Function GRForceBlackPen
* @param flagforce True to force a black pen whenever the asked color
* @param flagforce True to force a black pen whenever the asked color.
*/
void GRForceBlackPen( bool flagforce )
{
@ -203,8 +207,7 @@ void GRForceBlackPen( bool flagforce )
/**
* Function GetGRForceBlackPenState
* @return s_ForceBlackPen (True if a black pen was forced)
* @return true if a black pen was forced.
*/
bool GetGRForceBlackPenState( void )
{
@ -242,7 +245,8 @@ void GRLine( EDA_RECT* ClipBox,
}
void GRLine( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd, int aWidth, COLOR4D aColor, wxPenStyle aStyle )
void GRLine( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd, int aWidth,
COLOR4D aColor, wxPenStyle aStyle )
{
GRLine( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aWidth, aColor, aStyle );
}
@ -267,16 +271,14 @@ void GRLineTo( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int width, COLOR4D Col
}
/**
* Function GRLineArray
* draws an array of lines (not a polygon).
* @param aClipBox = the clip box
* @param aDC = the device context into which drawing should occur.
* @param aLines = a list of pair of coordinate in user space: a pair for each line.
* @param aWidth = the width of each line.
* @param aColor = color to draw the lines
* Draw an array of lines (not a polygon).
*
* @param aClipBox is the clip box.
* @param aDC is the device context into which drawing should occur.
* @param aLines is a list of pair of coordinate in user space: a pair for each line.
* @param aWidth is the width of each line.
* @param aColor is the color to draw the lines.
* @see COLOR4D
*/
void GRLineArray( EDA_RECT* aClipBox, wxDC* aDC, std::vector<wxPoint>& aLines,
@ -296,7 +298,7 @@ void GRLineArray( EDA_RECT* aClipBox, wxDC* aDC, std::vector<wxPoint>& aLines,
int y1 = aLines[i].y;
int x2 = aLines[i + 1].x;
int y2 = aLines[i + 1].y;
if( ( aClipBox == NULL ) || !ClipLine( aClipBox, x1, y1, x2, y2 ) )
if( ( aClipBox == nullptr ) || !ClipLine( aClipBox, x1, y1, x2, y2 ) )
aDC->DrawLine( x1, y1, x2, y2 );
}
@ -306,6 +308,7 @@ void GRLineArray( EDA_RECT* aClipBox, wxDC* aDC, std::vector<wxPoint>& aLines,
aClipBox->Inflate(-aWidth/2);
}
// Draw the outline of a thick segment with rounded ends
void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int width, int aPenSize, COLOR4D Color )
@ -322,7 +325,6 @@ void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
return;
}
if( width <= 2 ) /* single line or 2 pixels */
{
GRSetColorPen( DC, Color, width );
@ -371,7 +373,6 @@ void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
else
DC->DrawArc( start, end, org );
// second edge
start.x = len;
start.y = -radius;
@ -469,7 +470,7 @@ static bool IsGRSPolyDrawable( EDA_RECT* ClipBox, int n, const wxPoint* Points )
* Draw a new polyline and fill it if Fill, in screen space.
*/
static void GRSPoly( EDA_RECT* ClipBox, wxDC* DC, int n, const wxPoint* Points, bool Fill,
int width, COLOR4D Color, COLOR4D BgColor )
int width, COLOR4D Color, COLOR4D BgColor )
{
if( !IsGRSPolyDrawable( ClipBox, n, Points ) )
return;
@ -489,6 +490,7 @@ static void GRSPoly( EDA_RECT* ClipBox, wxDC* DC, int n, const wxPoint* Points,
{
GRMoveTo( Points[0].x, Points[0].y );
for( int i = 1; i < n; ++i )
{
GRLineTo( ClipBox, DC, Points[i].x, Points[i].y, width, Color );
@ -501,7 +503,7 @@ static void GRSPoly( EDA_RECT* ClipBox, wxDC* DC, int n, const wxPoint* Points,
* Draw a new closed polyline and fill it if Fill, in screen space.
*/
static void GRSClosedPoly( EDA_RECT* aClipBox, wxDC* aDC, int aPointCount, const wxPoint* aPoints,
bool aFill, int aWidth, COLOR4D aColor, COLOR4D aBgColor )
bool aFill, int aWidth, COLOR4D aColor, COLOR4D aBgColor )
{
if( !IsGRSPolyDrawable( aClipBox, aPointCount, aPoints ) )
return;
@ -518,6 +520,7 @@ static void GRSClosedPoly( EDA_RECT* aClipBox, wxDC* aDC, int aPointCount, const
{
GRMoveTo( aPoints[0].x, aPoints[0].y );
for( int i = 1; i < aPointCount; ++i )
{
GRLineTo( aClipBox, aDC, aPoints[i].x, aPoints[i].y, aWidth, aColor );
@ -538,7 +541,7 @@ static void GRSClosedPoly( EDA_RECT* aClipBox, wxDC* aDC, int aPointCount, const
* Draw a new polyline and fill it if Fill, in drawing space.
*/
void GRPoly( EDA_RECT* ClipBox, wxDC* DC, int n, const wxPoint* Points, bool Fill, int width,
COLOR4D Color, COLOR4D BgColor )
COLOR4D Color, COLOR4D BgColor )
{
GRSPoly( ClipBox, DC, n, Points, Fill, width, Color, BgColor );
}
@ -548,14 +551,14 @@ void GRPoly( EDA_RECT* ClipBox, wxDC* DC, int n, const wxPoint* Points, bool Fil
* Draw a closed polyline and fill it if Fill, in object space.
*/
void GRClosedPoly( EDA_RECT* ClipBox, wxDC* DC, int n, const wxPoint* Points, bool Fill,
COLOR4D Color, COLOR4D BgColor )
COLOR4D Color, COLOR4D BgColor )
{
GRClosedPoly( ClipBox, DC, n, Points, Fill, 0, Color, BgColor );
}
void GRClosedPoly( EDA_RECT* ClipBox, wxDC* DC, int n, const wxPoint* Points, bool Fill, int width,
COLOR4D Color, COLOR4D BgColor )
COLOR4D Color, COLOR4D BgColor )
{
GRSClosedPoly( ClipBox, DC, n, Points, Fill, width, Color, BgColor );
}
@ -608,7 +611,8 @@ void GRCircle( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int r, COLOR4D Color )
}
void GRCircle( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, int aWidth, COLOR4D aColor )
void GRCircle( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, int aWidth,
COLOR4D aColor )
{
GRCircle( aClipBox, aDC, aPos.x, aPos.y, aRadius, aWidth, aColor );
}
@ -763,10 +767,13 @@ void GRArc( EDA_RECT* ClipBox, wxDC* DC, int xc, int yc, double StAngle,
if( x < ( x0 - radius ) )
return;
if( y < ( y0 - radius ) )
return;
if( x > ( xm + radius ) )
return;
if( y > ( ym + radius ) )
return;
}
@ -845,7 +852,8 @@ void GRRect( EDA_RECT* aClipBox, wxDC* aDC, int x1, int y1, int x2, int y2, COLO
}
void GRRectPs( EDA_RECT* aClipBox, wxDC* aDC, const EDA_RECT& aRect, COLOR4D aColor, wxPenStyle aStyle )
void GRRectPs( EDA_RECT* aClipBox, wxDC* aDC, const EDA_RECT& aRect, COLOR4D aColor,
wxPenStyle aStyle )
{
int x1 = aRect.GetX();
int y1 = aRect.GetY();
@ -899,18 +907,16 @@ void GRFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
/*
* Draw a rectangle in screen space.
*/
void GRSRect( EDA_RECT* aClipBox, wxDC* aDC, int x1, int y1, int x2, int y2,
int aWidth, COLOR4D aColor, wxPenStyle aStyle )
{
wxPoint points[5];
points[0] = wxPoint(x1, y1);
points[1] = wxPoint(x1, y2);
points[2] = wxPoint(x2, y2);
points[3] = wxPoint(x2, y1);
points[0] = wxPoint( x1, y1 );
points[1] = wxPoint( x1, y2 );
points[2] = wxPoint( x2, y2 );
points[3] = wxPoint( x2, y1 );
points[4] = points[0];
GRSClosedPoly( aClipBox, aDC, 5, points, NOT_FILLED, aWidth,
aColor, aColor );
GRSClosedPoly( aClipBox, aDC, 5, points, NOT_FILLED, aWidth, aColor, aColor );
}
@ -918,43 +924,41 @@ void GRSFilledRect( EDA_RECT* aClipBox, wxDC* aDC, int x1, int y1, int x2, int y
int aWidth, COLOR4D aColor, COLOR4D aBgColor )
{
wxPoint points[5];
points[0] = wxPoint(x1, y1);
points[1] = wxPoint(x1, y2);
points[2] = wxPoint(x2, y2);
points[3] = wxPoint(x2, y1);
points[0] = wxPoint( x1, y1 );
points[1] = wxPoint( x1, y2 );
points[2] = wxPoint( x2, y2 );
points[3] = wxPoint( x2, y1 );
points[4] = points[0];
GRSetBrush( aDC, aBgColor, FILLED );
GRSetColorPen( aDC, aBgColor, aWidth );
if( aClipBox && (aWidth > 0) )
if( aClipBox && ( aWidth > 0 ) )
{
EDA_RECT clipbox(*aClipBox);
clipbox.Inflate(aWidth);
ClipAndDrawPoly(&clipbox, aDC, points, 5); // polygon approach is more accurate
EDA_RECT clipbox( *aClipBox );
clipbox.Inflate( aWidth );
ClipAndDrawPoly( &clipbox, aDC, points, 5 ); // polygon approach is more accurate
}
else
{
ClipAndDrawPoly(aClipBox, aDC, points, 5 );
}
}
/**
* Function ClipAndDrawPoly
* Used to clip a polygon and draw it as Filled Polygon
* uses the Sutherland and Hodgman algo to clip the given poly against a
* rectangle. This rectangle is the drawing area this is useful under
* Linux (2009) because filled polygons are incorrectly drawn if they have
* too large coordinates (seems due to integer overflows in calculations)
* Could be removed in some years, if become unnecessary.
* Used to clip a polygon and draw it as Filled Polygon.
*
* Uses the Sutherland and Hodgman algo to clip the given poly against a rectangle. This
* rectangle is the drawing area this is useful under Linux (2009) because filled polygons
* are incorrectly drawn if they have too large coordinates (seems due to integer overflows
* in calculations). Could be removed in some years, if become unnecessary.
*/
/* Note: aClipBox == NULL is legal, so if aClipBox == NULL,
* the polygon is drawn, but not clipped
*/
#include <SutherlandHodgmanClipPoly.h>
void ClipAndDrawPoly( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint* Points, int n )
{
if( aClipBox == NULL )
if( aClipBox == nullptr )
{
aDC->DrawPolygon( n, Points );
return;
@ -987,8 +991,7 @@ void ClipAndDrawPoly( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint* Points, int
}
void GRBezier( EDA_RECT* aClipBox, wxDC* aDC,
std::vector<wxPoint>& aPoint,
void GRBezier( EDA_RECT* aClipBox, wxDC* aDC, std::vector<wxPoint>& aPoint,
int aWidth, COLOR4D aColor )
{
std::vector<wxPoint> output;
@ -1000,17 +1003,12 @@ void GRBezier( EDA_RECT* aClipBox, wxDC* aDC,
}
void GRDrawAnchor( EDA_RECT *aClipBox, wxDC *aDC, int x, int y,
int aSize, COLOR4D aColor )
void GRDrawAnchor( EDA_RECT *aClipBox, wxDC *aDC, int x, int y, int aSize, COLOR4D aColor )
{
int anchor_size = aDC->DeviceToLogicalXRel( aSize );
GRLine( aClipBox, aDC,
x - anchor_size, y,
x + anchor_size, y, 0, aColor );
GRLine( aClipBox, aDC,
x, y - anchor_size,
x, y + anchor_size, 0, aColor );
GRLine( aClipBox, aDC, x - anchor_size, y, x + anchor_size, y, 0, aColor );
GRLine( aClipBox, aDC, x, y - anchor_size, x, y + anchor_size, 0, aColor );
}

View File

@ -230,6 +230,6 @@ void PLOTTER::Text( const wxPoint& aPos,
SetColor( aColor );
SetCurrentLineWidth( aPenWidth, aData );
GRText( NULL, aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, aPenWidth,
GRText( nullptr, aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, aPenWidth,
aItalic, aBold, nullptr, nullptr, this );
}

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2012-18 KiCad Developers, see change_log.txt for contributors.
* Copyright (C) 2012-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,14 +43,21 @@ GRID_TRICKS::GRID_TRICKS( WX_GRID* aGrid ):
m_sel_row_count = 0;
m_sel_col_count = 0;
aGrid->Connect( wxEVT_GRID_CELL_LEFT_CLICK, wxGridEventHandler( GRID_TRICKS::onGridCellLeftClick ), NULL, this );
aGrid->Connect( wxEVT_GRID_CELL_LEFT_DCLICK, wxGridEventHandler( GRID_TRICKS::onGridCellLeftDClick ), NULL, this );
aGrid->Connect( wxEVT_GRID_CELL_RIGHT_CLICK, wxGridEventHandler( GRID_TRICKS::onGridCellRightClick ), NULL, this );
aGrid->Connect( wxEVT_GRID_LABEL_RIGHT_CLICK, wxGridEventHandler( GRID_TRICKS::onGridLabelRightClick ), NULL, this );
aGrid->Connect( wxEVT_GRID_LABEL_LEFT_CLICK, wxGridEventHandler( GRID_TRICKS::onGridLabelLeftClick ), NULL, this );
aGrid->Connect( GRIDTRICKS_FIRST_ID, GRIDTRICKS_LAST_ID, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GRID_TRICKS::onPopupSelection ), NULL, this );
aGrid->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( GRID_TRICKS::onKeyDown ), NULL, this );
aGrid->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( GRID_TRICKS::onUpdateUI ), NULL, this );
aGrid->Connect( wxEVT_GRID_CELL_LEFT_CLICK,
wxGridEventHandler( GRID_TRICKS::onGridCellLeftClick ), nullptr, this );
aGrid->Connect( wxEVT_GRID_CELL_LEFT_DCLICK,
wxGridEventHandler( GRID_TRICKS::onGridCellLeftDClick ), nullptr, this );
aGrid->Connect( wxEVT_GRID_CELL_RIGHT_CLICK,
wxGridEventHandler( GRID_TRICKS::onGridCellRightClick ), nullptr, this );
aGrid->Connect( wxEVT_GRID_LABEL_RIGHT_CLICK,
wxGridEventHandler( GRID_TRICKS::onGridLabelRightClick ), nullptr, this );
aGrid->Connect( wxEVT_GRID_LABEL_LEFT_CLICK,
wxGridEventHandler( GRID_TRICKS::onGridLabelLeftClick ), nullptr, this );
aGrid->Connect( GRIDTRICKS_FIRST_ID, GRIDTRICKS_LAST_ID, wxEVT_COMMAND_MENU_SELECTED,
wxCommandEventHandler( GRID_TRICKS::onPopupSelection ), nullptr, this );
aGrid->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( GRID_TRICKS::onKeyDown ), nullptr, this );
aGrid->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( GRID_TRICKS::onUpdateUI ),
nullptr, this );
}
@ -238,10 +245,13 @@ void GRID_TRICKS::onGridLabelRightClick( wxGridEvent& )
void GRID_TRICKS::showPopupMenu( wxMenu& menu )
{
menu.Append( GRIDTRICKS_ID_CUT, _( "Cut" ) + "\tCtrl+X", _( "Clear selected cells placing original contents on clipboard" ) );
menu.Append( GRIDTRICKS_ID_COPY, _( "Copy" ) + "\tCtrl+C", _( "Copy selected cells to clipboard" ) );
menu.Append( GRIDTRICKS_ID_PASTE, _( "Paste" ) + "\tCtrl+V", _( "Paste clipboard cells to matrix at current cell" ) );
menu.Append( GRIDTRICKS_ID_DELETE, _( "Delete" ) + "\tDel", _( "Delete selected cells" ) );
menu.Append( GRIDTRICKS_ID_CUT, _( "Cut" ) + "\tCtrl+X",
_( "Clear selected cells placing original contents on clipboard" ) );
menu.Append( GRIDTRICKS_ID_COPY, _( "Copy" ) + "\tCtrl+C",
_( "Copy selected cells to clipboard" ) );
menu.Append( GRIDTRICKS_ID_PASTE, _( "Paste" ) + "\tCtrl+V",
_( "Paste clipboard cells to matrix at current cell" ) );
menu.Append( GRIDTRICKS_ID_DELETE, _( "Delete" ) + "\tDel", _( "Delete selected cells" ) );
menu.Append( GRIDTRICKS_ID_SELECT, _( "Select All" ) + "\tCtrl+A", _( "Select all cells" ) );
getSelectedArea();
@ -457,9 +467,13 @@ void GRID_TRICKS::onKeyDown( wxKeyEvent& ev )
break;
if( !test->GetChildren().empty() )
{
test = test->GetChildren().front();
}
else if( test->GetNextSibling() )
{
test = test->GetNextSibling();
}
else
{
while( test )

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Mark Roszko <mark.roszko@gmail.com>
* Copyright (C) 2015 KiCad Developers, see CHANGELOG.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
@ -45,7 +45,7 @@ static size_t write_callback( void* contents, size_t size, size_t nmemb, void* u
KICAD_CURL_EASY::KICAD_CURL_EASY() :
m_headers( NULL )
m_headers( nullptr )
{
// Call KICAD_CURL::Init() from in here everytime, but only the first time
// will incur any overhead. This strategy ensures that libcurl is never loaded
@ -120,6 +120,7 @@ bool KICAD_CURL_EASY::SetUserAgent( const std::string& aAgent )
{
return true;
}
return false;
}
@ -130,6 +131,7 @@ bool KICAD_CURL_EASY::SetURL( const std::string& aURL )
{
return true;
}
return false;
}
@ -140,6 +142,7 @@ bool KICAD_CURL_EASY::SetFollowRedirects( bool aFollow )
{
return true;
}
return false;
}

View File

@ -99,10 +99,10 @@ KIID::KIID( const wxString& aString ) : m_uuid(), m_cached_timestamp( 0 )
for( int i = 0; i < 4; ++i )
{
wxString octet = aString.substr( i * 2, 2 );
m_uuid.data[i + 12] = strtol( octet.data(), NULL, 16 );
m_uuid.data[i + 12] = strtol( octet.data(), nullptr, 16 );
}
m_cached_timestamp = strtol( aString.c_str(), NULL, 16 );
m_cached_timestamp = strtol( aString.c_str(), nullptr, 16 );
}
else
{
@ -111,7 +111,7 @@ KIID::KIID( const wxString& aString ) : m_uuid(), m_cached_timestamp( 0 )
m_uuid = stringGenerator( aString.wc_str() );
if( IsLegacyTimestamp() )
m_cached_timestamp = strtol( aString.substr( 28 ).c_str(), NULL, 16 );
m_cached_timestamp = strtol( aString.substr( 28 ).c_str(), nullptr, 16 );
}
catch( ... )
{
@ -177,7 +177,7 @@ KIID::KIID( timestamp_t aTimestamp )
for( int i = 0; i < 4; ++i )
{
wxString octet = str.substr( i * 2, 2 );
m_uuid.data[i + 12] = strtol( octet.data(), NULL, 16 );
m_uuid.data[i + 12] = strtol( octet.data(), nullptr, 16 );
}
}

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2014 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2014-2020 KiCad Developers, see CHANGELOG.TXT for contributors.
* Copyright (C) 2014-2021 KiCad Developers, see CHANGELOG.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
@ -83,12 +83,16 @@ void KIWAY::SetTop( wxFrame* aTop )
#if 0
if( m_top )
{
m_top->Disconnect( wxEVT_DESTROY, wxWindowDestroyEventHandler( KIWAY::player_destroy_handler ), NULL, this );
m_top->Disconnect( wxEVT_DESTROY,
wxWindowDestroyEventHandler( KIWAY::player_destroy_handler ),
nullptr, this );
}
if( aTop )
{
aTop->Connect( wxEVT_DESTROY, wxWindowDestroyEventHandler( KIWAY::player_destroy_handler ), NULL, this );
aTop->Connect( wxEVT_DESTROY,
wxWindowDestroyEventHandler( KIWAY::player_destroy_handler ),
nullptr, this );
}
#endif
@ -188,7 +192,7 @@ PROJECT& KIWAY::Prj() const
}
KIFACE* KIWAY::KiFACE( FACE_T aFaceId, bool doLoad )
KIFACE* KIWAY::KiFACE( FACE_T aFaceId, bool doLoad )
{
// Since this will be called from python, cannot assume that code will
// not pass a bad aFaceId.
@ -198,7 +202,7 @@ KIFACE* KIWAY::KiFACE( FACE_T aFaceId, bool doLoad )
// way it gets some explanatory text.
wxASSERT_MSG( 0, wxT( "caller has a bug, passed a bad aFaceId" ) );
return NULL;
return nullptr;
}
// return the previously loaded KIFACE, if it was.
@ -208,7 +212,7 @@ KIFACE* KIWAY::KiFACE( FACE_T aFaceId, bool doLoad )
wxString msg;
// DSO with KIFACE has not been loaded yet, does caller want to load it?
if( doLoad )
if( doLoad )
{
wxString dname = dso_search_path( aFaceId );
@ -227,7 +231,7 @@ KIFACE* KIWAY::KiFACE( FACE_T aFaceId, bool doLoad )
wxDynamicLibrary dso;
void* addr = NULL;
void* addr = nullptr;
// For some reason wxDynamicLibrary::Load() crashes in some languages
// (chinese for instance) when loading the dynamic library.
@ -252,7 +256,7 @@ KIFACE* KIWAY::KiFACE( FACE_T aFaceId, bool doLoad )
msg.Printf( _( "Failed to load kiface library '%s'." ), dname );
THROW_IO_ERROR( msg );
}
else if( ( addr = dso.GetSymbol( wxT( KIFACE_INSTANCE_NAME_AND_VERSION ) ) ) == NULL )
else if( ( addr = dso.GetSymbol( wxT( KIFACE_INSTANCE_NAME_AND_VERSION ) ) ) == nullptr )
{
// Failure: error reporting UI was done via wxLogSysError().
// No further reporting required here. Assume the same thing applies here as
@ -290,9 +294,8 @@ KIFACE* KIWAY::KiFACE( FACE_T aFaceId, bool doLoad )
// to exist, and we did not find one. If we do not find one, this is an
// installation bug.
msg = wxString::Format( _(
"Fatal Installation Bug. File:\n"
"\"%s\"\ncould not be loaded\n" ), dname );
msg = wxString::Format( _( "Fatal Installation Bug. File:\n"
"\"%s\"\ncould not be loaded\n" ), dname );
if( ! wxFileExists( dname ) )
msg << _( "It is missing.\n" );
@ -310,7 +313,7 @@ KIFACE* KIWAY::KiFACE( FACE_T aFaceId, bool doLoad )
THROW_IO_ERROR( msg );
}
return NULL;
return nullptr;
}
@ -363,11 +366,11 @@ KIWAY_PLAYER* KIWAY::GetPlayerFrame( FRAME_T aFrameType )
wxWindowID storedId = m_playerFrameId[aFrameType];
if( storedId == wxID_NONE )
return NULL;
return nullptr;
wxWindow* frame = wxWindow::FindWindowById( storedId );
// Since wxWindow::FindWindow*() is not cheap (especially if the window does not exist),
// Since wxWindow::FindWindow*() is not cheap (especially if the window does not exist),
// clear invalid entries to save CPU on repeated calls that do not lead to frame creation
if( !frame )
m_playerFrameId[aFrameType].compare_exchange_strong( storedId, wxID_NONE );
@ -447,7 +450,7 @@ bool KIWAY::PlayerClose( FRAME_T aFrameType, bool doForce )
KIWAY_PLAYER* frame = GetPlayerFrame( aFrameType );
if( frame == NULL ) // Already closed
if( frame == nullptr ) // Already closed
return true;
if( frame->NonUserClose( doForce ) )
@ -470,7 +473,8 @@ bool KIWAY::PlayersClose( bool doForce )
}
void KIWAY::ExpressMail( FRAME_T aDestination, MAIL_T aCommand, std::string& aPayload, wxWindow* aSource )
void KIWAY::ExpressMail( FRAME_T aDestination, MAIL_T aCommand, std::string& aPayload,
wxWindow* aSource )
{
KIWAY_EXPRESS mail( aDestination, aCommand, aPayload, aSource );

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2004-2015 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
@ -163,7 +163,7 @@ const wxString& PGM_BASE::GetEditorName( bool aCanShowFileChooser )
// If we still don't have an editor name show a dialog asking the user to select one
if( !editorname && aCanShowFileChooser )
{
DisplayInfoMessage( NULL, _( "No default editor found, you must choose it" ) );
DisplayInfoMessage( nullptr, _( "No default editor found, you must choose it" ) );
editorname = AskUserForPreferredEditor();
}
@ -195,7 +195,7 @@ const wxString PGM_BASE::AskUserForPreferredEditor( const wxString& aDefaultEdit
// Show the modal editor and return the file chosen (may be empty if the user cancels
// the dialog).
return EDA_FILE_SELECTOR( _( "Select Preferred Editor" ), path, name, ext, mask, NULL,
return EDA_FILE_SELECTOR( _( "Select Preferred Editor" ), path, name, ext, mask, nullptr,
wxFD_OPEN | wxFD_FILE_MUST_EXIST, true );
}
@ -233,13 +233,13 @@ bool PGM_BASE::InitPgm( bool aHeadless )
App().SetAppName( pgm_name );
// Install some image handlers, mainly for help
if( wxImage::FindHandler( wxBITMAP_TYPE_PNG ) == NULL )
if( wxImage::FindHandler( wxBITMAP_TYPE_PNG ) == nullptr )
wxImage::AddHandler( new wxPNGHandler );
if( wxImage::FindHandler( wxBITMAP_TYPE_GIF ) == NULL )
if( wxImage::FindHandler( wxBITMAP_TYPE_GIF ) == nullptr )
wxImage::AddHandler( new wxGIFHandler );
if( wxImage::FindHandler( wxBITMAP_TYPE_JPEG ) == NULL )
if( wxImage::FindHandler( wxBITMAP_TYPE_JPEG ) == nullptr )
wxImage::AddHandler( new wxJPEGHandler );
wxFileSystem::AddHandler( new wxZipFSHandler );
@ -563,7 +563,7 @@ void PGM_BASE::SetLanguagePath()
wxLocale::AddCatalogLookupPathPrefix( fn.GetPath() );
}
// Append path for macOS install
// Append path for macOS install
fn.RemoveLastDir();
fn.RemoveLastDir();
fn.RemoveLastDir();

View File

@ -391,7 +391,7 @@ bool DXF_PLOTTER::EndPlot()
" 0\n"
"EOF\n", m_outputFile );
fclose( m_outputFile );
m_outputFile = NULL;
m_outputFile = nullptr;
return true;
}
@ -493,7 +493,7 @@ void DXF_PLOTTER::PlotPoly( const std::vector<wxPoint>& aCornerList,
MoveTo( aCornerList[0] );
for( unsigned ii = 1; ii < aCornerList.size(); ii++ )
ThickSegment( aCornerList[ii-1], aCornerList[ii], aWidth, FILLED, NULL );
ThickSegment( aCornerList[ii-1], aCornerList[ii], aWidth, FILLED, nullptr );
return;
}
@ -623,9 +623,6 @@ void DXF_PLOTTER::ThickSegment( const wxPoint& aStart, const wxPoint& aEnd, int
}
/* Plot an arc in DXF format
* Filling is not supported
*/
void DXF_PLOTTER::Arc( const wxPoint& centre, double StAngle, double EndAngle, int radius,
FILL_TYPE fill, int width )
{

View File

@ -553,7 +553,7 @@ void PDF_PLOTTER::closePdfStream()
else
{
// NULL means memos owns the memory, but provide a hint on optimum size needed.
wxMemoryOutputStream memos( NULL, std::max( 2000l, stream_len ) ) ;
wxMemoryOutputStream memos( nullptr, std::max( 2000l, stream_len ) ) ;
{
/* Somewhat standard parameters to compress in DEFLATE. The PDF spec is
@ -752,7 +752,7 @@ bool PDF_PLOTTER::EndPlot()
// The info dictionary
int infoDictHandle = startPdfObject();
char date_buf[250];
time_t ltime = time( NULL );
time_t ltime = time( nullptr );
strftime( date_buf, 250, "D:%Y%m%d%H%M%S", localtime( &ltime ) );
if( m_title.IsEmpty() )
@ -811,7 +811,7 @@ bool PDF_PLOTTER::EndPlot()
(unsigned long) xrefTable.size(), catalogHandle, infoDictHandle, xref_start );
fclose( m_outputFile );
m_outputFile = NULL;
m_outputFile = nullptr;
return true;
}

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* 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
@ -145,7 +145,7 @@ void PlotDrawingSheet( PLOTTER* plotter, const PROJECT* aProject, const TITLE_BL
DS_DRAW_ITEM_BITMAP* drawItem = (DS_DRAW_ITEM_BITMAP*) item;
DS_DATA_ITEM_BITMAP* bitmap = (DS_DATA_ITEM_BITMAP*) drawItem->GetPeer();
if( bitmap->m_ImageBitmap == NULL )
if( bitmap->m_ImageBitmap == nullptr )
break;
bitmap->m_ImageBitmap->PlotImage( plotter, drawItem->GetPosition(), plotColor,

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2017-2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2017-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
@ -83,7 +83,7 @@ bool PLOTTER::OpenFile( const wxString& aFullFilename )
// but only for most of them
m_outputFile = wxFopen( m_filename, wxT( "wt" ) );
if( m_outputFile == NULL )
if( m_outputFile == nullptr )
return false ;
return true;
@ -136,6 +136,7 @@ double PLOTTER::userToDeviceSize( double size ) const
#define IU_PER_MILS ( m_IUsPerDecimil * 10 )
double PLOTTER::GetDotMarkLenIU() const
{
return userToDeviceSize( DOT_MARK_LEN( GetCurrentLineWidth() ) );
@ -157,7 +158,7 @@ double PLOTTER::GetDashGapLenIU() const
void PLOTTER::Arc( const SHAPE_ARC& aArc )
{
Arc( wxPoint( aArc.GetCenter() ), aArc.GetStartAngle(), aArc.GetEndAngle(), aArc.GetRadius(),
FILL_TYPE::NO_FILL, aArc.GetWidth() );
FILL_TYPE::NO_FILL, aArc.GetWidth() );
}
@ -237,8 +238,7 @@ void PLOTTER::BezierCurve( const wxPoint& aStart, const wxPoint& aControl1,
void PLOTTER::PlotImage(const wxImage & aImage, const wxPoint& aPos, double aScaleFactor )
{
wxSize size( aImage.GetWidth() * aScaleFactor,
aImage.GetHeight() * aScaleFactor );
wxSize size( aImage.GetWidth() * aScaleFactor, aImage.GetHeight() * aScaleFactor );
wxPoint start = aPos;
start.x -= size.x / 2;
@ -338,6 +338,7 @@ void PLOTTER::markerVBar( const wxPoint& pos, int radius )
void PLOTTER::Marker( const wxPoint& position, int diametre, unsigned aShapeId )
{
int radius = diametre / 2;
/* Marker are composed by a series of 'parts' superimposed; not every
combination make sense, obviously. Since they are used in order I
tried to keep the uglier/more complex constructions at the end.
@ -347,72 +348,73 @@ void PLOTTER::Marker( const wxPoint& position, int diametre, unsigned aShapeId )
If Visual C++ supported the 0b literals they would be optimally
and easily encoded as an integer array. We have to do with octal */
static const unsigned char marker_patterns[MARKER_COUNT] = {
// Bit order: O Square Lozenge - | \ /
// First choice: simple shapes
0003, // X
0100, // O
0014, // +
0040, // Sq
0020, // Lz
// Two simple shapes
0103, // X O
0017, // X +
0043, // X Sq
0023, // X Lz
0114, // O +
0140, // O Sq
0120, // O Lz
0054, // + Sq
0034, // + Lz
0060, // Sq Lz
// Three simple shapes
0117, // X O +
0143, // X O Sq
0123, // X O Lz
0057, // X + Sq
0037, // X + Lz
0063, // X Sq Lz
0154, // O + Sq
0134, // O + Lz
0074, // + Sq Lz
// Four simple shapes
0174, // O Sq Lz +
0163, // X O Sq Lz
0157, // X O Sq +
0137, // X O Lz +
0077, // X Sq Lz +
// This draws *everything *
0177, // X O Sq Lz +
// Here we use the single bars... so the cross is forbidden
0110, // O -
0104, // O |
0101, // O /
0050, // Sq -
0044, // Sq |
0041, // Sq /
0030, // Lz -
0024, // Lz |
0021, // Lz /
0150, // O Sq -
0144, // O Sq |
0141, // O Sq /
0130, // O Lz -
0124, // O Lz |
0121, // O Lz /
0070, // Sq Lz -
0064, // Sq Lz |
0061, // Sq Lz /
0170, // O Sq Lz -
0164, // O Sq Lz |
0161, // O Sq Lz /
// Last resort: the backlash component (easy to confound)
0102, // \ O
0042, // \ Sq
0022, // \ Lz
0142, // \ O Sq
0122, // \ O Lz
0062, // \ Sq Lz
0162 // \ O Sq Lz
// Bit order: O Square Lozenge - | \ /
// First choice: simple shapes
0003, // X
0100, // O
0014, // +
0040, // Sq
0020, // Lz
// Two simple shapes
0103, // X O
0017, // X +
0043, // X Sq
0023, // X Lz
0114, // O +
0140, // O Sq
0120, // O Lz
0054, // + Sq
0034, // + Lz
0060, // Sq Lz
// Three simple shapes
0117, // X O +
0143, // X O Sq
0123, // X O Lz
0057, // X + Sq
0037, // X + Lz
0063, // X Sq Lz
0154, // O + Sq
0134, // O + Lz
0074, // + Sq Lz
// Four simple shapes
0174, // O Sq Lz +
0163, // X O Sq Lz
0157, // X O Sq +
0137, // X O Lz +
0077, // X Sq Lz +
// This draws *everything *
0177, // X O Sq Lz +
// Here we use the single bars... so the cross is forbidden
0110, // O -
0104, // O |
0101, // O /
0050, // Sq -
0044, // Sq |
0041, // Sq /
0030, // Lz -
0024, // Lz |
0021, // Lz /
0150, // O Sq -
0144, // O Sq |
0141, // O Sq /
0130, // O Lz -
0124, // O Lz |
0121, // O Lz /
0070, // Sq Lz -
0064, // Sq Lz |
0061, // Sq Lz /
0170, // O Sq Lz -
0164, // O Sq Lz |
0161, // O Sq Lz /
// Last resort: the backlash component (easy to confound)
0102, // \ O
0042, // \ Sq
0022, // \ Lz
0142, // \ O Sq
0122, // \ O Lz
0062, // \ Sq Lz
0162 // \ O Sq Lz
};
if( aShapeId >= MARKER_COUNT )
{
@ -421,22 +423,29 @@ void PLOTTER::Marker( const wxPoint& position, int diametre, unsigned aShapeId )
}
else
{
// Decode the pattern and draw the corresponding parts
unsigned char pat = marker_patterns[aShapeId];
if( pat & 0001 )
markerSlash( position, radius );
if( pat & 0002 )
markerBackSlash( position, radius );
if( pat & 0004 )
markerVBar( position, radius );
if( pat & 0010 )
markerHBar( position, radius );
if( pat & 0020 )
markerLozenge( position, radius );
if( pat & 0040 )
markerSquare( position, radius );
if( pat & 0100 )
markerCircle( position, radius );
// Decode the pattern and draw the corresponding parts
unsigned char pat = marker_patterns[aShapeId];
if( pat & 0001 )
markerSlash( position, radius );
if( pat & 0002 )
markerBackSlash( position, radius );
if( pat & 0004 )
markerVBar( position, radius );
if( pat & 0010 )
markerHBar( position, radius );
if( pat & 0020 )
markerLozenge( position, radius );
if( pat & 0040 )
markerSquare( position, radius );
if( pat & 0100 )
markerCircle( position, radius );
}
}
@ -458,7 +467,7 @@ void PLOTTER::segmentAsOval( const wxPoint& start, const wxPoint& end, int width
size.x = KiROUND( EuclideanNorm( size ) ) + width;
size.y = width;
FlashPadOval( center, size, orient, tracemode, NULL );
FlashPadOval( center, size, orient, tracemode, nullptr );
}
@ -538,7 +547,9 @@ void PLOTTER::ThickArc( const wxPoint& centre, double StAngle, double EndAngle,
int radius, int width, OUTLINE_MODE tracemode, void* aData )
{
if( tracemode == FILLED )
{
Arc( centre, StAngle, EndAngle, radius, FILL_TYPE::NO_FILL, width );
}
else
{
SetCurrentLineWidth( -1 );
@ -554,19 +565,21 @@ void PLOTTER::ThickRect( const wxPoint& p1, const wxPoint& p2, int width,
OUTLINE_MODE tracemode, void* aData )
{
if( tracemode == FILLED )
{
Rect( p1, p2, FILL_TYPE::NO_FILL, width );
}
else
{
SetCurrentLineWidth( -1 );
wxPoint offsetp1( p1.x - (width - m_currentPenWidth) / 2,
p1.y - (width - m_currentPenWidth) / 2 );
wxPoint offsetp2( p2.x + (width - m_currentPenWidth) / 2,
p2.y + (width - m_currentPenWidth) / 2 );
p2.y + (width - m_currentPenWidth) / 2 );
Rect( offsetp1, offsetp2, FILL_TYPE::NO_FILL, -1 );
offsetp1.x += (width - m_currentPenWidth);
offsetp1.y += (width - m_currentPenWidth);
offsetp2.x -= (width - m_currentPenWidth);
offsetp2.y -= (width - m_currentPenWidth);
offsetp1.x += ( width - m_currentPenWidth );
offsetp1.y += ( width - m_currentPenWidth );
offsetp2.x -= ( width - m_currentPenWidth );
offsetp2.y -= ( width - m_currentPenWidth );
Rect( offsetp1, offsetp2, FILL_TYPE::NO_FILL, -1 );
}
}
@ -603,7 +616,7 @@ void PLOTTER::FilledCircle( const wxPoint& pos, int diametre, OUTLINE_MODE trace
void PLOTTER::PlotPoly( const SHAPE_LINE_CHAIN& aCornerList, FILL_TYPE aFill,
int aWidth, void * aData )
int aWidth, void* aData )
{
std::vector<wxPoint> cornerList;
cornerList.reserve( aCornerList.PointCount() );

View File

@ -1000,14 +1000,16 @@ CADSTAR_ARCHIVE_PARSER::READABILITY CADSTAR_ARCHIVE_PARSER::ParseReadability( XN
}
void CADSTAR_ARCHIVE_PARSER::ATTRIBUTE_LOCATION::ParseIdentifiers( XNODE* aNode, PARSER_CONTEXT* aContext )
void CADSTAR_ARCHIVE_PARSER::ATTRIBUTE_LOCATION::ParseIdentifiers( XNODE* aNode,
PARSER_CONTEXT* aContext )
{
TextCodeID = GetXmlAttributeIDString( aNode, 0 );
LayerID = GetXmlAttributeIDString( aNode, 1 );
}
bool CADSTAR_ARCHIVE_PARSER::ATTRIBUTE_LOCATION::ParseSubNode( XNODE* aChildNode, PARSER_CONTEXT* aContext )
bool CADSTAR_ARCHIVE_PARSER::ATTRIBUTE_LOCATION::ParseSubNode( XNODE* aChildNode,
PARSER_CONTEXT* aContext )
{
wxString cNodeName = aChildNode->GetName();
@ -1758,7 +1760,8 @@ void CADSTAR_ARCHIVE_PARSER::PART::PART_PIN::Parse( XNODE* aNode, PARSER_CONTEXT
}
void CADSTAR_ARCHIVE_PARSER::PART::DEFINITION::PIN_EQUIVALENCE::Parse( XNODE* aNode, PARSER_CONTEXT* aContext )
void CADSTAR_ARCHIVE_PARSER::PART::DEFINITION::PIN_EQUIVALENCE::Parse( XNODE* aNode,
PARSER_CONTEXT* aContext )
{
wxASSERT( aNode->GetName() == wxT( "PINEQUIVALENCE" ) );
@ -1781,7 +1784,8 @@ void CADSTAR_ARCHIVE_PARSER::PART::DEFINITION::PIN_EQUIVALENCE::Parse( XNODE* aN
}
void CADSTAR_ARCHIVE_PARSER::PART::DEFINITION::SWAP_GATE::Parse( XNODE* aNode, PARSER_CONTEXT* aContext )
void CADSTAR_ARCHIVE_PARSER::PART::DEFINITION::SWAP_GATE::Parse( XNODE* aNode,
PARSER_CONTEXT* aContext )
{
wxASSERT( aNode->GetName() == wxT( "SWAPGATE" ) );
@ -1804,7 +1808,8 @@ void CADSTAR_ARCHIVE_PARSER::PART::DEFINITION::SWAP_GATE::Parse( XNODE* aNode, P
}
void CADSTAR_ARCHIVE_PARSER::PART::DEFINITION::SWAP_GROUP::Parse( XNODE* aNode, PARSER_CONTEXT* aContext )
void CADSTAR_ARCHIVE_PARSER::PART::DEFINITION::SWAP_GROUP::Parse( XNODE* aNode,
PARSER_CONTEXT* aContext )
{
wxASSERT( aNode->GetName() == wxT( "SWAPGROUP" ) );
@ -1961,7 +1966,8 @@ void CADSTAR_ARCHIVE_PARSER::PARTS::Parse( XNODE* aNode, PARSER_CONTEXT* aContex
}
void CADSTAR_ARCHIVE_PARSER::NET::JUNCTION::ParseIdentifiers( XNODE* aNode, PARSER_CONTEXT* aContext )
void CADSTAR_ARCHIVE_PARSER::NET::JUNCTION::ParseIdentifiers( XNODE* aNode,
PARSER_CONTEXT* aContext )
{
wxASSERT( aNode->GetName() == wxT( "JPT" ) );
@ -1970,7 +1976,8 @@ void CADSTAR_ARCHIVE_PARSER::NET::JUNCTION::ParseIdentifiers( XNODE* aNode, PARS
}
bool CADSTAR_ARCHIVE_PARSER::NET::JUNCTION::ParseSubNode( XNODE* aChildNode, PARSER_CONTEXT* aContext )
bool CADSTAR_ARCHIVE_PARSER::NET::JUNCTION::ParseSubNode( XNODE* aChildNode,
PARSER_CONTEXT* aContext )
{
wxString cNodeName = aChildNode->GetName();
@ -2004,7 +2011,8 @@ void CADSTAR_ARCHIVE_PARSER::NET::JUNCTION::Parse( XNODE* aNode, PARSER_CONTEXT*
}
void CADSTAR_ARCHIVE_PARSER::NET::CONNECTION::ParseIdentifiers( XNODE* aNode, PARSER_CONTEXT* aContext )
void CADSTAR_ARCHIVE_PARSER::NET::CONNECTION::ParseIdentifiers( XNODE* aNode,
PARSER_CONTEXT* aContext )
{
wxASSERT( aNode->GetName() == wxT( "CONN" ) );
@ -2014,7 +2022,8 @@ void CADSTAR_ARCHIVE_PARSER::NET::CONNECTION::ParseIdentifiers( XNODE* aNode, PA
}
bool CADSTAR_ARCHIVE_PARSER::NET::CONNECTION::ParseSubNode( XNODE* aChildNode, PARSER_CONTEXT* aContext )
bool CADSTAR_ARCHIVE_PARSER::NET::CONNECTION::ParseSubNode( XNODE* aChildNode,
PARSER_CONTEXT* aContext )
{
wxString cNodeName = aChildNode->GetName();
@ -2302,11 +2311,11 @@ void CADSTAR_ARCHIVE_PARSER::InsertAttributeAtEnd( XNODE* aNode, wxString aValue
}
XNODE* CADSTAR_ARCHIVE_PARSER::LoadArchiveFile(
const wxString& aFileName, const wxString& aFileTypeIdentifier )
XNODE* CADSTAR_ARCHIVE_PARSER::LoadArchiveFile( const wxString& aFileName,
const wxString& aFileTypeIdentifier )
{
KEYWORD emptyKeywords[1] = {};
XNODE * iNode = NULL, *cNode = NULL;
XNODE * iNode = nullptr, *cNode = nullptr;
int tok;
bool cadstarFileCheckDone = false;
wxString str;
@ -2371,7 +2380,7 @@ XNODE* CADSTAR_ARCHIVE_PARSER::LoadArchiveFile(
}
// Not enough closing brackets
if( iNode != NULL )
if( iNode != nullptr )
THROW_IO_ERROR( _( "The selected file is not valid or might be corrupt!" ) );
// Throw if no data was parsed
@ -2380,7 +2389,7 @@ XNODE* CADSTAR_ARCHIVE_PARSER::LoadArchiveFile(
else
THROW_IO_ERROR( _( "The selected file is not valid or might be corrupt!" ) );
return NULL;
return nullptr;
}
@ -2390,8 +2399,8 @@ bool CADSTAR_ARCHIVE_PARSER::IsValidAttribute( wxXmlAttribute* aAttribute )
}
wxString CADSTAR_ARCHIVE_PARSER::GetXmlAttributeIDString(
XNODE* aNode, unsigned int aID, bool aIsRequired )
wxString CADSTAR_ARCHIVE_PARSER::GetXmlAttributeIDString( XNODE* aNode, unsigned int aID,
bool aIsRequired )
{
wxString attrName, retVal;
attrName = "attr";
@ -2409,8 +2418,8 @@ wxString CADSTAR_ARCHIVE_PARSER::GetXmlAttributeIDString(
}
long CADSTAR_ARCHIVE_PARSER::GetXmlAttributeIDLong(
XNODE* aNode, unsigned int aID, bool aIsRequired )
long CADSTAR_ARCHIVE_PARSER::GetXmlAttributeIDLong( XNODE* aNode, unsigned int aID,
bool aIsRequired )
{
long retVal;
bool success = GetXmlAttributeIDString( aNode, aID, aIsRequired ).ToLong( &retVal );
@ -2441,8 +2450,8 @@ void CADSTAR_ARCHIVE_PARSER::CheckNoNextNodes( XNODE* aNode )
}
void CADSTAR_ARCHIVE_PARSER::ParseChildEValue(
XNODE* aNode, PARSER_CONTEXT* aContext, EVALUE& aValueToParse )
void CADSTAR_ARCHIVE_PARSER::ParseChildEValue( XNODE* aNode, PARSER_CONTEXT* aContext,
EVALUE& aValueToParse )
{
if( aNode->GetChildren()->GetName() == wxT( "E" ) )
aValueToParse.Parse( aNode->GetChildren(), aContext );

View File

@ -195,7 +195,7 @@ EROT Convert<EROT>( const wxString& aRot )
+ 1 // skip leading 'R'
+ int( value.spin ) // skip optional leading 'S'
+ int( value.mirror ), // skip optional leading 'M'
NULL );
nullptr );
return value;
}

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2014-2018 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
@ -42,7 +42,7 @@ PROJECT::PROJECT() :
m_projectFile( nullptr ),
m_localSettings( nullptr )
{
memset( m_elems, 0, sizeof(m_elems) );
memset( m_elems, 0, sizeof( m_elems ) );
}
@ -52,7 +52,7 @@ void PROJECT::ElemsClear()
// be in the same link image as PROJECT.
for( unsigned i = 0; i < arrayDim( m_elems ); ++i )
{
SetElem( ELEM_T( i ), NULL );
SetElem( ELEM_T( i ), nullptr );
}
}
@ -246,19 +246,18 @@ const wxString& PROJECT::GetRString( RSTRING_T aIndex )
PROJECT::_ELEM* PROJECT::GetElem( ELEM_T aIndex )
{
// This is virtual, so implement it out of line
if( unsigned( aIndex ) < arrayDim( m_elems ) )
{
return m_elems[aIndex];
}
return NULL;
return nullptr;
}
void PROJECT::SetElem( ELEM_T aIndex, _ELEM* aElem )
{
// This is virtual, so implement it out of line
if( unsigned( aIndex ) < arrayDim( m_elems ) )
{
delete m_elems[aIndex];
@ -308,12 +307,12 @@ FP_LIB_TABLE* PROJECT::PcbFootprintLibs( KIWAY& aKiway )
}
catch( const IO_ERROR& ioe )
{
DisplayErrorMessage( NULL, _( "Error loading project footprint library table." ),
DisplayErrorMessage( nullptr, _( "Error loading project footprint library table." ),
ioe.What() );
}
catch( ... )
{
DisplayErrorMessage( NULL, _( "Error loading project footprint library table." ) );
DisplayErrorMessage( nullptr, _( "Error loading project footprint library table." ) );
}
}

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
@ -178,7 +178,7 @@ RC_TREE_MODEL::RC_TREE_MODEL( EDA_DRAW_FRAME* aParentFrame, wxDataViewCtrl* aVie
{
m_view->GetMainWindow()->Connect( wxEVT_SIZE,
wxSizeEventHandler( RC_TREE_MODEL::onSizeView ),
NULL, this );
nullptr, this );
}
@ -258,7 +258,7 @@ void RC_TREE_MODEL::rebuildModel( RC_ITEMS_PROVIDER* aProvider, int aSeverities
// The fastest method to update wxDataViewCtrl is to rebuild from
// scratch by calling Cleared(). Linux requires to reassociate model to
// display data, but Windows will create multiple associations.
// On MacOS, this crashes kicad. See https://gitlab.com/kicad/code/kicad/issues/3666
// On MacOS, this crashes KiCad. See https://gitlab.com/kicad/code/kicad/issues/3666
// and https://gitlab.com/kicad/code/kicad/issues/3653
m_view->AssociateModel( this );
#endif
@ -321,7 +321,7 @@ wxDataViewItem RC_TREE_MODEL::GetParent( wxDataViewItem const& aItem ) const
unsigned int RC_TREE_MODEL::GetChildren( wxDataViewItem const& aItem,
wxDataViewItemArray& aChildren ) const
wxDataViewItemArray& aChildren ) const
{
const RC_TREE_NODE* node = ToNode( aItem );
const std::vector<RC_TREE_NODE*>& children = node ? node->m_Children : m_tree;
@ -333,9 +333,6 @@ unsigned int RC_TREE_MODEL::GetChildren( wxDataViewItem const& aItem,
}
/**
* Called by the wxDataView to fetch an item's value.
*/
void RC_TREE_MODEL::GetValue( wxVariant& aVariant,
wxDataViewItem const& aItem,
unsigned int aCol ) const
@ -400,10 +397,6 @@ void RC_TREE_MODEL::GetValue( wxVariant& aVariant,
}
/**
* Called by the wxDataView to fetch an item's formatting. Return true iff the
* item has non-default attributes.
*/
bool RC_TREE_MODEL::GetAttr( wxDataViewItem const& aItem,
unsigned int aCol,
wxDataViewItemAttr& aAttr ) const

View File

@ -4,8 +4,8 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2015 KiCad Developers, see change_log.txt for contributors.
* Copyright (C) 2013 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 2013-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
@ -42,72 +42,81 @@ REPORTER& REPORTER::Report( const char* aText, SEVERITY aSeverity )
REPORTER& WX_TEXT_CTRL_REPORTER::Report( const wxString& aText, SEVERITY aSeverity )
{
wxCHECK_MSG( m_textCtrl != NULL, *this,
wxCHECK_MSG( m_textCtrl != nullptr, *this,
wxT( "No wxTextCtrl object defined in WX_TEXT_CTRL_REPORTER." ) );
m_textCtrl->AppendText( aText + wxS( "\n" ) );
return *this;
}
bool WX_TEXT_CTRL_REPORTER::HasMessage() const
{
return !m_textCtrl->IsEmpty();
}
REPORTER& WX_STRING_REPORTER::Report( const wxString& aText, SEVERITY aSeverity )
{
wxCHECK_MSG( m_string != NULL, *this,
wxCHECK_MSG( m_string != nullptr, *this,
wxT( "No wxString object defined in WX_STRING_REPORTER." ) );
*m_string << aText << wxS( "\n" );
return *this;
}
bool WX_STRING_REPORTER::HasMessage() const
{
return !m_string->IsEmpty();
}
REPORTER& WX_HTML_PANEL_REPORTER::Report( const wxString& aText, SEVERITY aSeverity )
{
wxCHECK_MSG( m_panel != NULL, *this,
wxCHECK_MSG( m_panel != nullptr, *this,
wxT( "No WX_HTML_REPORT_PANEL object defined in WX_HTML_PANEL_REPORTER." ) );
m_panel->Report( aText, aSeverity );
return *this;
}
REPORTER& WX_HTML_PANEL_REPORTER::ReportTail( const wxString& aText, SEVERITY aSeverity )
{
wxCHECK_MSG( m_panel != NULL, *this,
wxCHECK_MSG( m_panel != nullptr, *this,
wxT( "No WX_HTML_REPORT_PANEL object defined in WX_HTML_PANEL_REPORTER." ) );
m_panel->Report( aText, aSeverity, LOC_TAIL );
return *this;
}
REPORTER& WX_HTML_PANEL_REPORTER::ReportHead( const wxString& aText, SEVERITY aSeverity )
{
wxCHECK_MSG( m_panel != NULL, *this,
wxCHECK_MSG( m_panel != nullptr, *this,
wxT( "No WX_HTML_REPORT_PANEL object defined in WX_HTML_PANEL_REPORTER." ) );
m_panel->Report( aText, aSeverity, LOC_HEAD );
return *this;
}
bool WX_HTML_PANEL_REPORTER::HasMessage() const
{
return m_panel->Count( RPT_SEVERITY_ERROR | RPT_SEVERITY_WARNING ) > 0;
}
REPORTER& NULL_REPORTER::Report( const wxString& aText, SEVERITY aSeverity )
{
return *this;
}
REPORTER& NULL_REPORTER::GetInstance()
{
static REPORTER* s_nullReporter = NULL;
static REPORTER* s_nullReporter = nullptr;
if( !s_nullReporter )
s_nullReporter = new NULL_REPORTER();
@ -182,6 +191,7 @@ REPORTER& STATUSBAR_REPORTER::Report( const wxString& aText, SEVERITY aSeverity
return *this;
}
bool STATUSBAR_REPORTER::HasMessage() const
{
if( m_statusBar )

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2007-2011 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2017 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2017-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
@ -104,7 +104,7 @@ std::string StrPrintf( const char* format, ... )
//-----<LINE_READER>------------------------------------------------------
LINE_READER::LINE_READER( unsigned aMaxLineLength ) :
m_length( 0 ), m_lineNum( 0 ), m_line( NULL ),
m_length( 0 ), m_lineNum( 0 ), m_line( nullptr ),
m_capacity( 0 ), m_maxLineLength( aMaxLineLength )
{
if( aMaxLineLength != 0 )
@ -159,8 +159,8 @@ void LINE_READER::expandCapacity( unsigned aNewsize )
}
FILE_LINE_READER::FILE_LINE_READER( const wxString& aFileName,
unsigned aStartingLineNumber, unsigned aMaxLineLength ):
FILE_LINE_READER::FILE_LINE_READER( const wxString& aFileName, unsigned aStartingLineNumber,
unsigned aMaxLineLength ):
LINE_READER( aMaxLineLength ), m_iOwn( true )
{
m_fp = wxFopen( aFileName, wxT( "rt" ) );
@ -215,7 +215,7 @@ char* FILE_LINE_READER::ReadLine()
{
m_length = 0;
for(;;)
for( ;; )
{
if( m_length >= m_maxLineLength )
THROW_IO_ERROR( _( "Maximum line length exceeded" ) );
@ -241,7 +241,7 @@ char* FILE_LINE_READER::ReadLine()
// leads to better error reporting when we hit an end of file.
++m_lineNum;
return m_length ? m_line : NULL;
return m_length ? m_line : nullptr;
}
@ -294,11 +294,12 @@ char* STRING_LINE_READER::ReadLine()
++m_lineNum; // this gets incremented even if no bytes were read
m_line[m_length] = 0;
return m_length ? m_line : NULL;
return m_length ? m_line : nullptr;
}
INPUTSTREAM_LINE_READER::INPUTSTREAM_LINE_READER( wxInputStream* aStream, const wxString& aSource ) :
INPUTSTREAM_LINE_READER::INPUTSTREAM_LINE_READER( wxInputStream* aStream,
const wxString& aSource ) :
LINE_READER( LINE_READER_LINE_DEFAULT_MAX ),
m_stream( aStream )
{
@ -310,7 +311,7 @@ char* INPUTSTREAM_LINE_READER::ReadLine()
{
m_length = 0;
for(;;)
for( ;; )
{
if( m_length >= m_maxLineLength )
THROW_IO_ERROR( _( "Maximum line length exceeded" ) );
@ -336,7 +337,7 @@ char* INPUTSTREAM_LINE_READER::ReadLine()
// leads to better error reporting when we hit an end of file.
++m_lineNum;
return m_length ? m_line : NULL;
return m_length ? m_line : nullptr;
}
@ -361,8 +362,8 @@ const char* OUTPUTFORMATTER::GetQuoteChar( const char* wrapee, const char* quote
for( ; *wrapee; ++wrapee, isFirst = false )
{
static const char quoteThese[] = "\t ()"
"%" // per Alfons of freerouting.net, he does not like this unquoted as of 1-Feb-2008
"{}" // guessing that these are problems too
"%" // per Alfons of freerouting.net, he does not like this unquoted as of 1-Feb-2008
"{}" // guessing that these are problems too
;
// if the string to be wrapped (wrapee) has a delimiter in it,
@ -383,6 +384,7 @@ const char* OUTPUTFORMATTER::GetQuoteChar( const char* wrapee ) const
return GetQuoteChar( wrapee, quoteChar );
}
int OUTPUTFORMATTER::vprint( const char* fmt, va_list ap )
{
// This function can call vsnprintf twice.
@ -522,7 +524,6 @@ void STRING_FORMATTER::StripUseless()
}
}
//-----<FILE_OUTPUTFORMATTER>----------------------------------------
FILE_OUTPUTFORMATTER::FILE_OUTPUTFORMATTER( const wxString& aFileName, const wxChar* aMode,
char aQuoteChar ):
@ -550,8 +551,6 @@ void FILE_OUTPUTFORMATTER::write( const char* aOutBuf, int aCount )
}
//-----<STREAM_OUTPUTFORMATTER>--------------------------------------
void STREAM_OUTPUTFORMATTER::write( const char* aOutBuf, int aCount )
{
int lastWrite;

View File

@ -2,6 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2014-2015 CERN
* Copyright (C) 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
@ -39,7 +40,7 @@ STATUS_POPUP::STATUS_POPUP( wxWindow* aParent ) :
m_panel->SetSizer( m_topSizer );
m_panel->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) );
Connect( wxEVT_TIMER, wxTimerEventHandler( STATUS_POPUP::onExpire ), NULL, this );
Connect( wxEVT_TIMER, wxTimerEventHandler( STATUS_POPUP::onExpire ), nullptr, this );
#ifdef __WXOSX_MAC__
// Key events from popups don't get put through the wxWidgets event system on OSX,

View File

@ -2,6 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* Copyright (C) 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
@ -36,17 +37,17 @@
kicad::stream::stream()
{
m_buf = NULL;
m_stream = NULL;
m_buf = nullptr;
m_stream = nullptr;
}
kicad::stream::~stream()
{
if( NULL != m_stream )
if( nullptr != m_stream )
delete m_stream;
if( NULL != m_buf )
if( nullptr != m_buf )
{
m_buf->close(); // ensure file is closed regardless of m_buf's destructor
delete m_buf;
@ -56,13 +57,13 @@ kicad::stream::~stream()
std::iostream* kicad::stream::Open( const char* aFileName, std::ios_base::openmode aMode )
{
if( NULL != m_stream )
if( nullptr != m_stream )
{
delete m_stream;
m_stream = NULL;
m_stream = nullptr;
}
if( NULL != m_buf )
if( nullptr != m_buf )
{
m_buf->close();
delete m_buf;

View File

@ -493,8 +493,8 @@ char* StrPurge( char* text )
char* GetLine( FILE* File, char* Line, int* LineNum, int SizeLine )
{
do {
if( fgets( Line, SizeLine, File ) == NULL )
return NULL;
if( fgets( Line, SizeLine, File ) == nullptr )
return nullptr;
if( LineNum )
*LineNum += 1;
@ -597,7 +597,7 @@ int StrNumCmp( const wxString& aString1, const wxString& aString2, bool aIgnoreC
bool WildCompareString( const wxString& pattern, const wxString& string_to_tst,
bool case_sensitive )
{
const wxChar* cp = NULL, * mp = NULL;
const wxChar* cp = nullptr, * mp = nullptr;
const wxChar* wild, * str;
wxString _pattern, _string_to_tst;
@ -721,9 +721,13 @@ int ValueStringCompare( wxString strFWord, wxString strSWord )
int isEqual = strFWordBeg.CmpNoCase( strSWordBeg );
if( isEqual > 0 )
{
return 1;
}
else if( isEqual < 0 )
{
return -1;
}
else
{
// If the first sections are equal compare their digits

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 CERN
* Copyright (C) 2019 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2019-2021 KiCad Developers, see AUTHORS.txt for contributors.
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
* This program is free software; you can redistribute it and/or
@ -67,9 +67,11 @@ void ACTION_MANAGER::RegisterAction( TOOL_ACTION* aAction )
}
void ACTION_MANAGER::SetConditions( const TOOL_ACTION& aAction, const ACTION_CONDITIONS& aConditions )
void ACTION_MANAGER::SetConditions( const TOOL_ACTION& aAction,
const ACTION_CONDITIONS& aConditions )
{
// Remove any existing handlers with the old conditions to ensure the UI layer doesn't have stale data
// Remove any existing handlers with the old conditions to ensure the UI layer doesn't have
// stale data.
if( m_toolMgr )
m_toolMgr->GetToolHolder()->UnregisterUIUpdateHandler( aAction );
@ -112,7 +114,7 @@ TOOL_ACTION* ACTION_MANAGER::FindAction( const std::string& aActionName ) const
if( it != m_actionNameIndex.end() )
return it->second;
return NULL;
return nullptr;
}
@ -150,7 +152,7 @@ bool ACTION_MANAGER::RunHotKey( int aHotKey ) const
// Choose the action that has the highest priority on the active tools stack
// If there is none, run the global action associated with the hot key
int highestPriority = -1, priority = -1;
const TOOL_ACTION* context = NULL; // pointer to context action of the highest priority tool
const TOOL_ACTION* context = nullptr; // pointer to context action of the highest priority tool
std::vector<const TOOL_ACTION*> global; // pointers to global actions
// if there is no context action

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013-2019 CERN
* Copyright (C) 2013-2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2013-2021 KiCad Developers, see AUTHORS.txt for contributors.
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
@ -59,7 +59,7 @@ ACTION_MENU::ACTION_MENU( bool isContextMenu, TOOL_INTERACTIVE* aTool ) :
ACTION_MENU::~ACTION_MENU()
{
// Set parent to NULL to prevent submenus from unregistering from a notexisting object
// Set parent to NULL to prevent submenus from unregistering from a nonexistent object
for( auto menu : m_submenus )
menu->SetParent( nullptr );
@ -78,13 +78,9 @@ void ACTION_MENU::SetIcon( BITMAPS aIcon )
void ACTION_MENU::setupEvents()
{
// See wxWidgets hack in TOOL_DISPATCHER::DispatchWxEvent().
// Connect( wxEVT_MENU_OPEN, wxMenuEventHandler( ACTION_MENU::OnMenuEvent ), NULL, this );
// Connect( wxEVT_MENU_HIGHLIGHT, wxMenuEventHandler( ACTION_MENU::OnMenuEvent ), NULL, this );
// Connect( wxEVT_MENU_CLOSE, wxMenuEventHandler( ACTION_MENU::OnMenuEvent ), NULL, this );
Connect( wxEVT_COMMAND_MENU_SELECTED, wxMenuEventHandler( ACTION_MENU::OnMenuEvent ), NULL, this );
Connect( wxEVT_IDLE, wxIdleEventHandler( ACTION_MENU::OnIdle ), NULL, this );
Connect( wxEVT_COMMAND_MENU_SELECTED, wxMenuEventHandler( ACTION_MENU::OnMenuEvent ), nullptr,
this );
Connect( wxEVT_IDLE, wxIdleEventHandler( ACTION_MENU::OnIdle ), nullptr, this );
}
@ -325,7 +321,8 @@ ACTION_MENU* ACTION_MENU::create() const
ACTION_MENU* menu = new ACTION_MENU( false );
wxASSERT_MSG( typeid( *this ) == typeid( *menu ),
wxString::Format( "You need to override create() method for class %s", typeid(*this).name() ) );
wxString::Format( "You need to override create() method for class %s",
typeid( *this ).name() ) );
return menu;
}
@ -381,6 +378,7 @@ void ACTION_MENU::updateHotKeys()
static int g_last_menu_highlighted_id = 0;
// We need to store the position of the mouse when the menu was opened so it can be passed
// to the command event generated when the menu item is selected.
static VECTOR2D g_menu_open_position;
@ -488,17 +486,17 @@ void ACTION_MENU::OnMenuEvent( wxMenuEvent& aEvent )
wxMenu* menu = nullptr;
FindItem( m_selected, &menu );
// This conditional compilation is probably not needed.
// It will be removed later, for the Kicad V 6.x version.
// But in "old" 3.0 version, the "&& menu != this" contition was added to avoid hang
// This hang is no longer encountered in wxWidgets 3.0.4 version, and this condition is no longer needed.
// And in 3.1.2, we have to remove it, as "menu != this" never happens
// ("menu != this" always happens in 3.1.1 and older!).
#if wxCHECK_VERSION(3, 1, 2)
// This conditional compilation is probably not needed.
// It will be removed later, for the Kicad V 6.x version.
// But in "old" 3.0 version, the "&& menu != this" contition was added to avoid
// hang. This hang is no longer encountered in wxWidgets 3.0.4 version, and this
// condition is no longer needed. And in 3.1.2, we have to remove it, as
// "menu != this" never happens ("menu != this" always happens in 3.1.1 and older!).
#if wxCHECK_VERSION( 3, 1, 2 )
if( menu )
#else
#else
if( menu && menu != this )
#endif
#endif
{
ACTION_MENU* cxmenu = static_cast<ACTION_MENU*>( menu );
evt = cxmenu->eventHandler( aEvent );
@ -645,11 +643,12 @@ wxMenuItem* ACTION_MENU::appendCopy( const wxMenuItem* aSource )
// On Windows, for Checkable Menu items, adding a bitmap adds also
// our predefined checked alternate bitmap
// On other OS, wxITEM_CHECK and wxITEM_RADIO Menu items do not use custom bitmaps.
#if defined(_WIN32)
// On Windows, AddBitmapToMenuItem() uses the unchecked bitmap for wxITEM_CHECK and wxITEM_RADIO menuitems
// and autoamtically adds a checked bitmap.
#if defined( _WIN32 )
// On Windows, AddBitmapToMenuItem() uses the unchecked bitmap for wxITEM_CHECK and
// wxITEM_RADIO menuitems and autoamtically adds a checked bitmap.
// For other menuitrms, use the "checked" bitmap.
bool use_checked_bm = ( aSource->GetKind() == wxITEM_CHECK || aSource->GetKind() == wxITEM_RADIO ) ? false : true;
bool use_checked_bm = ( aSource->GetKind() == wxITEM_CHECK ||
aSource->GetKind() == wxITEM_RADIO ) ? false : true;
const wxBitmap& src_bitmap = aSource->GetBitmap( use_checked_bm );
#else
const wxBitmap& src_bitmap = aSource->GetBitmap();

View File

@ -2,8 +2,8 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2014-2016 CERN
* @author Maciej Suminski <maciej.suminski@cern.ch>
* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -50,6 +50,7 @@
wxString COMMON_CONTROL::m_bugReportUrl =
"https://gitlab.com/kicad/code/kicad/issues/new?issue[description]=%s";
/// Issue template to use for reporting bugs (this should not be translated)
wxString COMMON_CONTROL::m_bugReportTemplate =
"<!-- Before Creating a New Issue:\n"
@ -216,7 +217,7 @@ int COMMON_CONTROL::ShowHelp( const TOOL_EVENT& aEvent )
msg = wxString::Format( _( "Help file '%s' or\n'%s' could not be found.\n"
"Do you want to access the KiCad online help?" ),
names[0], names[1] );
wxMessageDialog dlg( NULL, msg, _( "File Not Found" ),
wxMessageDialog dlg( nullptr, msg, _( "File Not Found" ),
wxYES_NO | wxNO_DEFAULT | wxCANCEL );
if( dlg.ShowModal() != wxID_YES )
@ -236,7 +237,7 @@ int COMMON_CONTROL::ShowHelp( const TOOL_EVENT& aEvent )
msg = wxString::Format( _( "Help file '%s' could not be found.\n"
"Do you want to access the KiCad online help?" ),
base_name );
wxMessageDialog dlg( NULL, msg, _( "File Not Found" ),
wxMessageDialog dlg( nullptr, msg, _( "File Not Found" ),
wxYES_NO | wxNO_DEFAULT | wxCANCEL );
if( dlg.ShowModal() != wxID_YES )
@ -268,6 +269,7 @@ int COMMON_CONTROL::GetInvolved( const TOOL_EVENT& aEvent )
URL_GET_INVOLVED );
wxMessageBox( msg, _( "Get involved with KiCad" ), wxOK, m_frame );
}
return 0;
}
@ -282,6 +284,7 @@ int COMMON_CONTROL::Donate( const TOOL_EVENT& aEvent )
URL_DONATE );
wxMessageBox( msg, _( "Donate to KiCad" ), wxOK, m_frame );
}
return 0;
}

View File

@ -2,6 +2,7 @@
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2014 CERN
* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
* This program is free software; you can redistribute it and/or
@ -33,6 +34,7 @@
#include <utility>
#include <geometry/geometry_utils.h>
void EC_VERTICAL::Apply( EDIT_POINT& aHandle )
{
VECTOR2I point = aHandle.GetPosition();
@ -92,7 +94,7 @@ void EC_CIRCLE::Apply( EDIT_POINT& aHandle )
EC_CONVERGING::EC_CONVERGING( EDIT_LINE& aLine, EDIT_POINTS& aPoints ) :
EDIT_CONSTRAINT<EDIT_LINE>( aLine ),
m_colinearConstraint( NULL ), m_editPoints( aPoints )
m_colinearConstraint( nullptr ), m_editPoints( aPoints )
{
// Dragged segment endings
EDIT_POINT& origin = aLine.GetOrigin();

View File

@ -2,6 +2,7 @@
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2014-2019 CERN
* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
* This program is free software; you can redistribute it and/or
@ -28,6 +29,7 @@
#include <math/util.h> // for KiROUND
#include "tool/edit_points.h"
bool EDIT_POINT::WithinPoint( const VECTOR2I& aPoint, unsigned int aSize ) const
{
// Corners of the EDIT_POINT square
@ -64,7 +66,7 @@ EDIT_POINT* EDIT_POINTS::FindPoint( const VECTOR2I& aLocation, KIGFX::VIEW *aVie
return &line;
}
return NULL;
return nullptr;
}
@ -145,7 +147,7 @@ EDIT_POINT* EDIT_POINTS::Previous( const EDIT_POINT& aPoint, bool aTraverseConto
}
}
return NULL;
return nullptr;
}
@ -162,7 +164,7 @@ EDIT_LINE* EDIT_POINTS::Previous( const EDIT_LINE& aLine )
}
}
return NULL;
return nullptr;
}
@ -182,7 +184,7 @@ EDIT_POINT* EDIT_POINTS::Next( const EDIT_POINT& aPoint, bool aTraverseContours
}
}
return NULL;
return nullptr;
}
@ -199,7 +201,7 @@ EDIT_LINE* EDIT_POINTS::Next( const EDIT_LINE& aLine )
}
}
return NULL;
return nullptr;
}

View File

@ -173,7 +173,7 @@ struct TOOL_MANAGER::TOOL_STATE
}
else
{
cofunc = NULL;
cofunc = nullptr;
return false;
}
}
@ -189,8 +189,8 @@ private:
shutdown = false;
pendingWait = false;
pendingContextMenu = false;
cofunc = NULL;
contextMenu = NULL;
cofunc = nullptr;
contextMenu = nullptr;
contextMenuTrigger = CMENU_OFF;
vcSettings.Reset();
transitions.clear();
@ -231,11 +231,11 @@ TOOL_MANAGER::~TOOL_MANAGER()
void TOOL_MANAGER::RegisterTool( TOOL_BASE* aTool )
{
wxASSERT_MSG( m_toolNameIndex.find( aTool->GetName() ) == m_toolNameIndex.end(),
wxT( "Adding two tools with the same name may result in unexpected behaviour.") );
wxT( "Adding two tools with the same name may result in unexpected behavior.") );
wxASSERT_MSG( m_toolIdIndex.find( aTool->GetId() ) == m_toolIdIndex.end(),
wxT( "Adding two tools with the same ID may result in unexpected behaviour.") );
wxT( "Adding two tools with the same ID may result in unexpected behavior.") );
wxASSERT_MSG( m_toolTypes.find( typeid( *aTool ).name() ) == m_toolTypes.end(),
wxT( "Adding two tools of the same type may result in unexpected behaviour.") );
wxT( "Adding two tools of the same type may result in unexpected behavior.") );
m_toolOrder.push_back( aTool );
@ -387,7 +387,7 @@ int TOOL_MANAGER::GetHotKey( const TOOL_ACTION& aAction ) const
bool TOOL_MANAGER::invokeTool( TOOL_BASE* aTool )
{
wxASSERT( aTool != NULL );
wxASSERT( aTool != nullptr );
TOOL_EVENT evt( TC_COMMAND, TA_ACTIVATE, aTool->GetName() );
evt.SetMousePosition( GetCursorPosition() );
@ -402,7 +402,7 @@ bool TOOL_MANAGER::invokeTool( TOOL_BASE* aTool )
bool TOOL_MANAGER::runTool( TOOL_BASE* aTool )
{
wxASSERT( aTool != NULL );
wxASSERT( aTool != nullptr );
if( !isRegistered( aTool ) )
{
@ -413,7 +413,7 @@ bool TOOL_MANAGER::runTool( TOOL_BASE* aTool )
TOOL_ID id = aTool->GetId();
wxLogTrace( kicadTraceToolStack, "TOOL_MANAGER::runTool - running tool %s",
aTool->GetName() );
aTool->GetName() );
if( aTool->GetType() == INTERACTIVE )
static_cast<TOOL_INTERACTIVE*>( aTool )->resetTransitions();
@ -466,7 +466,7 @@ void TOOL_MANAGER::ShutdownTool( TOOL_ID aToolId )
ShutdownTool( tool );
wxLogTrace( kicadTraceToolStack, "TOOL_MANAGER::ShutdownTool - no tool with ID %d",
aToolId );
aToolId );
}
@ -478,19 +478,20 @@ void TOOL_MANAGER::ShutdownTool( const std::string& aToolName )
ShutdownTool( tool );
wxLogTrace( kicadTraceToolStack, "TOOL_MANAGER::ShutdownTool - no tool with name %s",
aToolName );
aToolName );
}
void TOOL_MANAGER::ShutdownTool( TOOL_BASE* aTool )
{
wxASSERT( aTool != NULL );
wxASSERT( aTool != nullptr );
TOOL_ID id = aTool->GetId();
if( isActive( aTool ) )
{
TOOL_MANAGER::ID_LIST::iterator it = std::find( m_activeTools.begin(), m_activeTools.end(), id );
TOOL_MANAGER::ID_LIST::iterator it = std::find( m_activeTools.begin(),
m_activeTools.end(), id );
TOOL_STATE* st = m_toolIdIndex[*it];
@ -526,7 +527,7 @@ TOOL_BASE* TOOL_MANAGER::FindTool( int aId ) const
if( it != m_toolIdIndex.end() )
return it->second->theTool;
return NULL;
return nullptr;
}
@ -537,7 +538,7 @@ TOOL_BASE* TOOL_MANAGER::FindTool( const std::string& aName ) const
if( it != m_toolNameIndex.end() )
return it->second->theTool;
return NULL;
return nullptr;
}
@ -664,7 +665,7 @@ bool TOOL_MANAGER::dispatchInternal( TOOL_EVENT& aEvent )
bool handled = false;
wxLogTrace( kicadTraceToolStack, "TOOL_MANAGER::dispatchInternal - received event: %s",
aEvent.Format() );
aEvent.Format() );
auto it = m_activeTools.begin();
@ -785,7 +786,7 @@ bool TOOL_MANAGER::dispatchInternal( TOOL_EVENT& aEvent )
}
wxLogTrace( kicadTraceToolStack, "TOOL_MANAGER::dispatchInternal - %s handle event: %s",
( handled ? "Did" : "Did not" ), aEvent.Format() );
( handled ? "Did" : "Did not" ), aEvent.Format() );
return handled;
}
@ -803,7 +804,7 @@ bool TOOL_MANAGER::DispatchHotKey( const TOOL_EVENT& aEvent )
bool TOOL_MANAGER::dispatchActivation( const TOOL_EVENT& aEvent )
{
wxLogTrace( kicadTraceToolStack, "TOOL_MANAGER::dispatchActivation - Received event: %s",
aEvent.Format() );
aEvent.Format() );
if( aEvent.IsActivate() )
{
@ -880,7 +881,7 @@ void TOOL_MANAGER::DispatchContextMenu( const TOOL_EVENT& aEvent )
if( wxWindow* frame = dynamic_cast<wxWindow*>( m_frame ) )
frame->PopupMenu( menu.get() );
// If a menu is cancelled then notify tool
// If a menu is canceled then notify tool
if( menu->GetSelected() < 0 )
{
TOOL_EVENT evt( TC_COMMAND, TA_CHOICE_MENU_CHOICE, -1 );
@ -988,7 +989,7 @@ bool TOOL_MANAGER::SaveClipboard( const std::string& aTextUTF8 )
if( wxTheClipboard->Open() )
{
// Store the UTF8 string as unicode string in clipboard:
// Store the UTF8 string as Unicode string in clipboard:
wxTheClipboard->SetData( new wxTextDataObject( wxString( aTextUTF8.c_str(),
wxConvUTF8 ) ) );
@ -1016,7 +1017,7 @@ std::string TOOL_MANAGER::GetClipboardUTF8() const
wxTextDataObject data;
wxTheClipboard->GetData( data );
// The clipboard is expected containing a unicode string, so return it
// The clipboard is expected containing a Unicode string, so return it
// as UTF8 string
result = data.GetText().utf8_str();
}

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2017 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2017-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
@ -31,7 +31,7 @@
ZOOM_TOOL::ZOOM_TOOL() :
TOOL_INTERACTIVE( "common.Control.zoomTool" )
{
m_frame = NULL;
m_frame = nullptr;
}

View File

@ -196,7 +196,7 @@ const char* GetVirtualKeyCodeName(int keycode)
#undef WXK_
default:
return NULL;
return nullptr;
}
}

View File

@ -2,8 +2,8 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2018 jp.charras at wanadoo.fr
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2018 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 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
@ -27,23 +27,12 @@
#include <undo_redo_container.h>
/*
ITEM_PICKER::ITEM_PICKER( EDA_ITEM* aItem, UNDO_REDO aUndoRedoStatus )
{
m_undoRedoStatus = aUndoRedoStatus;
SetItem( aItem );
m_pickerFlags = 0;
m_link = nullptr;
m_screen = nullptr;
}
*/
ITEM_PICKER::ITEM_PICKER()
{
m_undoRedoStatus = UNDO_REDO::UNSPECIFIED;
SetItem( nullptr );
m_pickerFlags = 0;
m_link = NULL;
m_link = nullptr;
m_screen = nullptr;
}
@ -53,7 +42,7 @@ ITEM_PICKER::ITEM_PICKER( BASE_SCREEN* aScreen, EDA_ITEM* aItem, UNDO_REDO aUndo
m_undoRedoStatus = aUndoRedoStatus;
SetItem( aItem );
m_pickerFlags = 0;
m_link = NULL;
m_link = nullptr;
m_screen = aScreen;
}
@ -131,7 +120,8 @@ void PICKED_ITEMS_LIST::ClearListAndDeleteItems()
while( GetCount() > 0 )
{
ITEM_PICKER wrapper = PopItem();
if( wrapper.GetItem() == NULL ) // No more item in list.
if( wrapper.GetItem() == nullptr ) // No more items in list.
break;
// The Link is an undo construct; it is always owned by the undo/redo container
@ -168,7 +158,7 @@ EDA_ITEM* PICKED_ITEMS_LIST::GetPickedItem( unsigned int aIdx ) const
if( aIdx < m_ItemsList.size() )
return m_ItemsList[aIdx].GetItem();
return NULL;
return nullptr;
}
@ -177,7 +167,7 @@ BASE_SCREEN* PICKED_ITEMS_LIST::GetScreenForItem( unsigned int aIdx ) const
if( aIdx < m_ItemsList.size() )
return m_ItemsList[aIdx].GetScreen();
return NULL;
return nullptr;
}
@ -186,7 +176,7 @@ EDA_ITEM* PICKED_ITEMS_LIST::GetPickedItemLink( unsigned int aIdx ) const
if( aIdx < m_ItemsList.size() )
return m_ItemsList[aIdx].GetLink();
return NULL;
return nullptr;
}
@ -288,6 +278,7 @@ void PICKED_ITEMS_LIST::CopyList( const PICKED_ITEMS_LIST& aSource )
void PICKED_ITEMS_LIST::ReversePickersListOrder()
{
std::vector <ITEM_PICKER> tmp;
while( !m_ItemsList.empty() )
{
tmp.push_back( m_ItemsList.back() );
@ -298,10 +289,6 @@ void PICKED_ITEMS_LIST::ReversePickersListOrder()
}
/**********************************************/
/********** UNDO_REDO_CONTAINER ***************/
/**********************************************/
UNDO_REDO_CONTAINER::UNDO_REDO_CONTAINER()
{
}
@ -337,5 +324,5 @@ PICKED_ITEMS_LIST* UNDO_REDO_CONTAINER::PopCommand()
return item;
}
return NULL;
return nullptr;
}

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013-2017 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2013-2017 KiCad Developers, see CHANGELOG.TXT for contributors.
* Copyright (C) 2013-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
@ -28,11 +28,6 @@
#include <wx/buffer.h>
#include <vector>
/* THROW_IO_ERROR needs this, but it includes this file, so until some
factoring of THROW_IO_ERROR into a separate header, defer and use the asserts.
#include <richio.h>
*/
#include <cassert>
@ -193,7 +188,7 @@ bool IsUTF8( const char* aString )
while( next < end )
{
int charLen = UTF8::uni_forward( next, NULL );
int charLen = UTF8::uni_forward( next, nullptr );
if( charLen == 0 )
return false;
@ -231,7 +226,9 @@ UTF8::UTF8( const wchar_t* txt )
UTF8& UTF8::operator+=( unsigned w_ch )
{
if( w_ch <= 0x7F )
{
m_s.operator+=( char( w_ch ) );
}
else
{
//TODO: Remove wchar use. Replace with std::byte*

View File

@ -265,8 +265,8 @@ VIEW::VIEW( bool aIsDynamic ) :
m_scale( 4.0 ),
m_minScale( 0.2 ), m_maxScale( 50000.0 ),
m_mirrorX( false ), m_mirrorY( false ),
m_painter( NULL ),
m_gal( NULL ),
m_painter( nullptr ),
m_gal( nullptr ),
m_dynamic( aIsDynamic ),
m_useDrawPriority( false ),
m_nextDrawPriority( 0 ),
@ -1138,7 +1138,7 @@ void VIEW::Redraw()
// The view rtree uses integer positions. Large screens can overflow
// this size so in this case, simply set the rectangle to the full rtree
if( rect.GetWidth() > std::numeric_limits<int>::max() ||
rect.GetHeight() > std::numeric_limits<int>::max() )
rect.GetHeight() > std::numeric_limits<int>::max() )
recti.SetMaximum();
redrawRect( recti );

View File

@ -84,55 +84,55 @@ WX_VIEW_CONTROLS::WX_VIEW_CONTROLS( VIEW* aView, EDA_DRAW_PANEL_GAL* aParentPane
LoadSettings();
m_parentPanel->Connect( wxEVT_MOTION,
wxMouseEventHandler( WX_VIEW_CONTROLS::onMotion ), NULL, this );
wxMouseEventHandler( WX_VIEW_CONTROLS::onMotion ), nullptr, this );
#if wxCHECK_VERSION( 3, 1, 0 ) || defined( USE_OSX_MAGNIFY_EVENT )
m_parentPanel->Connect( wxEVT_MAGNIFY,
wxMouseEventHandler( WX_VIEW_CONTROLS::onMagnify ), NULL, this );
wxMouseEventHandler( WX_VIEW_CONTROLS::onMagnify ), nullptr, this );
#endif
m_parentPanel->Connect( wxEVT_MOUSEWHEEL,
wxMouseEventHandler( WX_VIEW_CONTROLS::onWheel ), NULL, this );
wxMouseEventHandler( WX_VIEW_CONTROLS::onWheel ), nullptr, this );
m_parentPanel->Connect( wxEVT_MIDDLE_UP,
wxMouseEventHandler( WX_VIEW_CONTROLS::onButton ), NULL, this );
wxMouseEventHandler( WX_VIEW_CONTROLS::onButton ), nullptr, this );
m_parentPanel->Connect( wxEVT_MIDDLE_DOWN,
wxMouseEventHandler( WX_VIEW_CONTROLS::onButton ), NULL, this );
wxMouseEventHandler( WX_VIEW_CONTROLS::onButton ), nullptr, this );
m_parentPanel->Connect( wxEVT_LEFT_UP,
wxMouseEventHandler( WX_VIEW_CONTROLS::onButton ), NULL, this );
wxMouseEventHandler( WX_VIEW_CONTROLS::onButton ), nullptr, this );
m_parentPanel->Connect( wxEVT_LEFT_DOWN,
wxMouseEventHandler( WX_VIEW_CONTROLS::onButton ), NULL, this );
wxMouseEventHandler( WX_VIEW_CONTROLS::onButton ), nullptr, this );
m_parentPanel->Connect( wxEVT_RIGHT_UP,
wxMouseEventHandler( WX_VIEW_CONTROLS::onButton ), NULL, this );
wxMouseEventHandler( WX_VIEW_CONTROLS::onButton ), nullptr, this );
m_parentPanel->Connect( wxEVT_RIGHT_DOWN,
wxMouseEventHandler( WX_VIEW_CONTROLS::onButton ), NULL, this );
wxMouseEventHandler( WX_VIEW_CONTROLS::onButton ), nullptr, this );
#if defined __WXMSW__
m_parentPanel->Connect( wxEVT_ENTER_WINDOW,
wxMouseEventHandler( WX_VIEW_CONTROLS::onEnter ), NULL, this );
wxMouseEventHandler( WX_VIEW_CONTROLS::onEnter ), nullptr, this );
#endif
m_parentPanel->Connect( wxEVT_LEAVE_WINDOW,
wxMouseEventHandler( WX_VIEW_CONTROLS::onLeave ), NULL, this );
wxMouseEventHandler( WX_VIEW_CONTROLS::onLeave ), nullptr, this );
m_parentPanel->Connect( wxEVT_SCROLLWIN_THUMBTRACK,
wxScrollWinEventHandler( WX_VIEW_CONTROLS::onScroll ), NULL, this );
wxScrollWinEventHandler( WX_VIEW_CONTROLS::onScroll ), nullptr, this );
m_parentPanel->Connect( wxEVT_SCROLLWIN_PAGEUP,
wxScrollWinEventHandler( WX_VIEW_CONTROLS::onScroll ), NULL, this );
wxScrollWinEventHandler( WX_VIEW_CONTROLS::onScroll ), nullptr, this );
m_parentPanel->Connect( wxEVT_SCROLLWIN_PAGEDOWN,
wxScrollWinEventHandler( WX_VIEW_CONTROLS::onScroll ), NULL, this );
wxScrollWinEventHandler( WX_VIEW_CONTROLS::onScroll ), nullptr, this );
m_parentPanel->Connect( wxEVT_SCROLLWIN_BOTTOM,
wxScrollWinEventHandler( WX_VIEW_CONTROLS::onScroll ), NULL, this );
wxScrollWinEventHandler( WX_VIEW_CONTROLS::onScroll ), nullptr, this );
m_parentPanel->Connect( wxEVT_SCROLLWIN_TOP,
wxScrollWinEventHandler( WX_VIEW_CONTROLS::onScroll ), NULL, this );
wxScrollWinEventHandler( WX_VIEW_CONTROLS::onScroll ), nullptr, this );
m_parentPanel->Connect( wxEVT_SCROLLWIN_LINEUP,
wxScrollWinEventHandler( WX_VIEW_CONTROLS::onScroll ), NULL, this );
wxScrollWinEventHandler( WX_VIEW_CONTROLS::onScroll ), nullptr, this );
m_parentPanel->Connect( wxEVT_SCROLLWIN_LINEDOWN,
wxScrollWinEventHandler( WX_VIEW_CONTROLS::onScroll ), NULL, this );
wxScrollWinEventHandler( WX_VIEW_CONTROLS::onScroll ), nullptr, this );
#if defined USE_MOUSE_CAPTURE
m_parentPanel->Connect( wxEVT_MOUSE_CAPTURE_LOST,
wxMouseEventHandler( WX_VIEW_CONTROLS::onCaptureLost ), NULL, this );
wxMouseEventHandler( WX_VIEW_CONTROLS::onCaptureLost ), nullptr, this );
#endif
m_cursorWarped = false;
m_panTimer.SetOwner( this );
this->Connect( wxEVT_TIMER, wxTimerEventHandler( WX_VIEW_CONTROLS::onTimer ), NULL, this );
this->Connect( wxEVT_TIMER, wxTimerEventHandler( WX_VIEW_CONTROLS::onTimer ), nullptr, this );
m_settings.m_lastKeyboardCursorPositionValid = false;
m_settings.m_lastKeyboardCursorPosition = { 0.0, 0.0 };
@ -399,6 +399,7 @@ void WX_VIEW_CONTROLS::onButton( wxMouseEvent& aEvent )
m_dragStartPoint = VECTOR2D( aEvent.GetX(), aEvent.GetY() );
m_lookStartPoint = m_view->GetCenter();
m_state = DRAG_PANNING;
#if defined USE_MOUSE_CAPTURE
if( !m_parentPanel->HasCapture() )
m_parentPanel->CaptureMouse();
@ -411,6 +412,7 @@ void WX_VIEW_CONTROLS::onButton( wxMouseEvent& aEvent )
m_zoomStartPoint = m_dragStartPoint;
m_initialZoomScale = m_view->GetScale();
m_state = DRAG_ZOOMING;
#if defined USE_MOUSE_CAPTURE
if( !m_parentPanel->HasCapture() )
m_parentPanel->CaptureMouse();
@ -427,6 +429,7 @@ void WX_VIEW_CONTROLS::onButton( wxMouseEvent& aEvent )
if( aEvent.MiddleUp() || aEvent.LeftUp() || aEvent.RightUp() )
{
m_state = IDLE;
#if defined USE_MOUSE_CAPTURE
if( !m_settings.m_cursorCaptured && m_parentPanel->HasCapture() )
m_parentPanel->ReleaseMouse();
@ -451,8 +454,9 @@ void WX_VIEW_CONTROLS::onEnter( wxMouseEvent& aEvent )
}
#if defined( _WIN32 )
// Win32 transmits mouse move and wheel events to all controls below the mouse regardless of focus
// Forcing the focus here will cause the EDA FRAMES to immediately become the top level active window
// Win32 transmits mouse move and wheel events to all controls below the mouse regardless
// of focus. Forcing the focus here will cause the EDA FRAMES to immediately become the
// top level active window.
if( m_parentPanel->GetParent() != nullptr )
{
// this assumes the parent panel's parent is the eda window
@ -479,11 +483,12 @@ void WX_VIEW_CONTROLS::onCaptureLost( wxMouseEvent& aEvent )
// This method must be present to suppress the capture-lost assertion
// Set the flag to allow calling m_parentPanel->CaptureMouse()
// Nots: One cannot call m_parentPanel->CaptureMouse() twice, thit is not accepted
// Note: One cannot call m_parentPanel->CaptureMouse() twice, this is not accepted
// by wxWidgets (MSW specific) so we need this guard
m_parentPanel->m_MouseCapturedLost = true;
}
void WX_VIEW_CONTROLS::onTimer( wxTimerEvent& aEvent )
{
switch( m_state )
@ -572,10 +577,7 @@ void WX_VIEW_CONTROLS::onScroll( wxScrollWinEvent& aEvent )
else if( type == wxEVT_SCROLLWIN_LINEDOWN )
dist = -linePanDelta;
else
{
wxASSERT( "Unhandled event type" );
return;
}
wxCHECK_MSG( false, /* void */, wxT( "Unhandled event type" ) );
VECTOR2D scroll = m_view->ToWorld( m_view->GetScreenPixelSize(), false ) * dist;
@ -698,7 +700,8 @@ void WX_VIEW_CONTROLS::SetCursorPosition( const VECTOR2D& aPosition, bool aWarpV
}
void WX_VIEW_CONTROLS::SetCrossHairCursorPosition( const VECTOR2D& aPosition, bool aWarpView = true )
void WX_VIEW_CONTROLS::SetCrossHairCursorPosition( const VECTOR2D& aPosition,
bool aWarpView = true )
{
m_updateCursor = false;
@ -714,7 +717,7 @@ void WX_VIEW_CONTROLS::SetCrossHairCursorPosition( const VECTOR2D& aPosition, bo
void WX_VIEW_CONTROLS::WarpCursor( const VECTOR2D& aPosition, bool aWorldCoordinates,
bool aWarpView )
bool aWarpView )
{
if( aWorldCoordinates )
{
@ -764,10 +767,10 @@ bool WX_VIEW_CONTROLS::handleAutoPanning( const wxMouseEvent& aEvent )
if( m_cursorWarped || ( m_settings.m_lastKeyboardCursorPositionValid && p == pKey ) )
{
// last cursor move event came from keyboard cursor control. If auto-panning is enabled and
// the next position is inside the autopan zone, check if it really came from a mouse event, otherwise
// disable autopan temporarily. Also temporarily disable autopan if the cursor is in the autopan zone
// because the application warped the cursor.
// last cursor move event came from keyboard cursor control. If auto-panning is enabled
// and the next position is inside the autopan zone, check if it really came from a mouse
// event, otherwise disable autopan temporarily. Also temporarily disable autopan if the
// cursor is in the autopan zone because the application warped the cursor.
m_cursorWarped = false;
return true;
@ -777,7 +780,7 @@ bool WX_VIEW_CONTROLS::handleAutoPanning( const wxMouseEvent& aEvent )
// Compute areas where autopanning is active
int borderStart = std::min( m_settings.m_autoPanMargin * m_view->GetScreenPixelSize().x,
m_settings.m_autoPanMargin * m_view->GetScreenPixelSize().y );
m_settings.m_autoPanMargin * m_view->GetScreenPixelSize().y );
borderStart = std::max( borderStart, 2 );
int borderEndX = m_view->GetScreenPixelSize().x - borderStart;
int borderEndY = m_view->GetScreenPixelSize().y - borderStart;
@ -829,8 +832,7 @@ bool WX_VIEW_CONTROLS::handleAutoPanning( const wxMouseEvent& aEvent )
return false;
}
wxASSERT_MSG( false, wxT( "This line should never be reached" ) );
return false; // Should not be reached, just avoid the compiler warnings..
wxCHECK_MSG( false, false, wxT( "This line should never be reached" ) );
}
@ -903,12 +905,14 @@ void WX_VIEW_CONTROLS::UpdateScrollbars()
m_scrollScale.x = 2e3 / viewport.GetWidth(); // TODO it does not have to be updated so often
m_scrollScale.y = 2e3 / viewport.GetHeight();
VECTOR2I newScroll( ( viewport.Centre().x - boundary.GetLeft() ) * m_scrollScale.x,
( viewport.Centre().y - boundary.GetTop() ) * m_scrollScale.y );
( viewport.Centre().y - boundary.GetTop() ) * m_scrollScale.y );
// We add the width of the scroll bar thumb to the range because the scroll range is given by
// the full bar while the position is given by the left/top position of the thumb
VECTOR2I newRange( m_scrollScale.x * boundary.GetWidth() + m_parentPanel->GetScrollThumb( wxSB_HORIZONTAL ),
m_scrollScale.y * boundary.GetHeight() + m_parentPanel->GetScrollThumb( wxSB_VERTICAL ) );
VECTOR2I newRange( m_scrollScale.x * boundary.GetWidth() +
m_parentPanel->GetScrollThumb( wxSB_HORIZONTAL ),
m_scrollScale.y * boundary.GetHeight() +
m_parentPanel->GetScrollThumb( wxSB_VERTICAL ) );
// Flip scroll direction in flipped view
if( m_view->IsMirroredX() )
@ -919,12 +923,14 @@ void WX_VIEW_CONTROLS::UpdateScrollbars()
if( m_scrollPos != newScroll || newRange.x != m_parentPanel->GetScrollRange( wxSB_HORIZONTAL )
|| newRange.y != m_parentPanel->GetScrollRange( wxSB_VERTICAL ) )
{
m_parentPanel->SetScrollbars( 1, 1, newRange.x, newRange.y, newScroll.x, newScroll.y, true );
m_parentPanel->SetScrollbars( 1, 1, newRange.x, newRange.y, newScroll.x, newScroll.y,
true );
m_scrollPos = newScroll;
#if !defined( __APPLE__ ) && !defined( WIN32 )
// Trigger a mouse refresh to get the canvas update in GTK (re-draws the scrollbars).
// Note that this causes an infinite loop on OSX and Windows (in certain cases) as it generates a paint event.
// Note that this causes an infinite loop on OSX and Windows (in certain cases) as it
// generates a paint event.
refreshMouse();
#endif
}

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2018 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
@ -29,9 +29,6 @@
#include <bitmaps.h>
//---- Grid helpers: custom wxGridCellRenderer that renders icon and a label ------------
GRID_CELL_ICON_TEXT_RENDERER::GRID_CELL_ICON_TEXT_RENDERER( const std::vector<BITMAPS>& icons,
const wxArrayString& names ) :
m_icons( icons ),
@ -39,6 +36,7 @@ GRID_CELL_ICON_TEXT_RENDERER::GRID_CELL_ICON_TEXT_RENDERER( const std::vector<BI
{
}
void GRID_CELL_ICON_TEXT_RENDERER::Draw( wxGrid& aGrid, wxGridCellAttr& aAttr, wxDC& aDC,
const wxRect& aRect, int aRow, int aCol, bool isSelected )
{
@ -60,9 +58,10 @@ void GRID_CELL_ICON_TEXT_RENDERER::Draw( wxGrid& aGrid, wxGridCellAttr& aAttr, w
bitmap = KiBitmap( m_icons[ position ] );
aDC.DrawBitmap( bitmap, rect.GetLeft() + 3, rect.GetTop() + 2, true );
}
// still need a bitmap to fetch the width
else
else // still need a bitmap to fetch the width
{
bitmap = KiBitmap( m_icons[ 0 ] );
}
// draw the text
rect.SetLeft( rect.GetLeft() + bitmap.GetWidth() + 7 );
@ -83,11 +82,8 @@ wxSize GRID_CELL_ICON_TEXT_RENDERER::GetBestSize( wxGrid& grid, wxGridCellAttr&
}
//---- Grid helpers: custom wxGridCellRenderer that renders just an icon ----------------
//
// Note: this renderer is supposed to be used with read only cells
GRID_CELL_ICON_RENDERER::GRID_CELL_ICON_RENDERER(const wxBitmap& icon) : m_icon( icon )
GRID_CELL_ICON_RENDERER::GRID_CELL_ICON_RENDERER( const wxBitmap& icon ) :
m_icon( icon )
{
}
@ -112,7 +108,8 @@ void GRID_CELL_ICON_RENDERER::Draw( wxGrid& aGrid, wxGridCellAttr& aAttr, wxDC&
}
wxSize GRID_CELL_ICON_RENDERER::GetBestSize( wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, int row, int col )
wxSize GRID_CELL_ICON_RENDERER::GetBestSize( wxGrid& grid, wxGridCellAttr& attr, wxDC& dc,
int row, int col )
{
return wxSize( m_icon.GetWidth() + 6, m_icon.GetHeight() + 4 );
}
@ -124,11 +121,6 @@ wxGridCellRenderer* GRID_CELL_ICON_RENDERER::Clone() const
}
//---- Grid helpers: custom wxGridCellEditor ------------------------------------------
//
// Note: this implementation is an adaptation of wxGridCellChoiceEditor
GRID_CELL_ICON_TEXT_POPUP::GRID_CELL_ICON_TEXT_POPUP( const std::vector<BITMAPS>& icons,
const wxArrayString& names ) :
m_icons( icons ),
@ -146,9 +138,10 @@ wxGridCellEditor* GRID_CELL_ICON_TEXT_POPUP::Clone() const
void GRID_CELL_ICON_TEXT_POPUP::Create( wxWindow* aParent, wxWindowID aId,
wxEvtHandler* aEventHandler )
{
m_control = new wxBitmapComboBox(
aParent, aId, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL,
wxCB_READONLY | wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB | wxBORDER_NONE );
m_control = new wxBitmapComboBox( aParent, aId, wxEmptyString, wxDefaultPosition,
wxDefaultSize, 0, nullptr,
wxCB_READONLY | wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB |
wxBORDER_NONE );
for( unsigned i = 0; i < m_names.size(); ++i )
{
@ -163,11 +156,13 @@ void GRID_CELL_ICON_TEXT_POPUP::Create( wxWindow* aParent, wxWindowID aId,
wxGridCellEditor::Create(aParent, aId, aEventHandler);
}
wxString GRID_CELL_ICON_TEXT_POPUP::GetValue() const
{
return Combo()->GetValue();
}
void GRID_CELL_ICON_TEXT_POPUP::SetSize( const wxRect& aRect )
{
wxRect rect( aRect );

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 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
@ -31,6 +31,7 @@
#include <widgets/layer_box_selector.h>
LAYER_SELECTOR::LAYER_SELECTOR()
{
m_layerhotkeys = true;
@ -53,9 +54,10 @@ void LAYER_SELECTOR::DrawColorSwatch( wxBitmap& aLayerbmp, COLOR4D aBackground,
bmpDC.SelectObject( aLayerbmp );
brush.SetStyle( wxBRUSHSTYLE_SOLID );
if( aBackground != COLOR4D::UNSPECIFIED )
{
brush.SetColour( aBackground.WithAlpha(1.0).ToColour() );
brush.SetColour( aBackground.WithAlpha( 1.0 ).ToColour() );
bmpDC.SetBrush( brush );
bmpDC.DrawRectangle( 0, 0, aLayerbmp.GetWidth(), aLayerbmp.GetHeight() );
}
@ -70,19 +72,17 @@ void LAYER_SELECTOR::DrawColorSwatch( wxBitmap& aLayerbmp, COLOR4D aBackground,
}
/* class to display a layer list in a wxBitmapComboBox.
*/
LAYER_BOX_SELECTOR::LAYER_BOX_SELECTOR( wxWindow* parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
int n, const wxString choices[] ) :
wxBitmapComboBox( parent, id, wxEmptyString, pos, size, n, choices, wxCB_READONLY ),
LAYER_SELECTOR()
{
if( choices != NULL )
if( choices != nullptr )
ResyncBitmapOnly();
GetParent()->Connect( wxEVT_CHAR_HOOK, wxKeyEventHandler( LAYER_BOX_SELECTOR::onKeyDown ), NULL, this );
GetParent()->Connect( wxEVT_CHAR_HOOK, wxKeyEventHandler( LAYER_BOX_SELECTOR::onKeyDown ),
nullptr, this );
}
@ -95,24 +95,24 @@ LAYER_BOX_SELECTOR::LAYER_BOX_SELECTOR( wxWindow* parent, wxWindowID id,
if( !choices.IsEmpty() )
ResyncBitmapOnly();
GetParent()->Connect( wxEVT_CHAR_HOOK, wxKeyEventHandler( LAYER_BOX_SELECTOR::onKeyDown ), NULL, this );
GetParent()->Connect( wxEVT_CHAR_HOOK, wxKeyEventHandler( LAYER_BOX_SELECTOR::onKeyDown ),
nullptr, this );
}
LAYER_BOX_SELECTOR::~LAYER_BOX_SELECTOR()
{
GetParent()->Disconnect( wxEVT_CHAR_HOOK, wxKeyEventHandler( LAYER_BOX_SELECTOR::onKeyDown ), NULL, this );
GetParent()->Disconnect( wxEVT_CHAR_HOOK, wxKeyEventHandler( LAYER_BOX_SELECTOR::onKeyDown ),
nullptr, this );
}
// Get Current Item #
int LAYER_BOX_SELECTOR::GetChoice()
{
return GetSelection();
}
// Get Current Layer
LAYER_NUM LAYER_BOX_SELECTOR::GetLayerSelection() const
{
if( GetSelection() < 0 )
@ -122,7 +122,6 @@ LAYER_NUM LAYER_BOX_SELECTOR::GetLayerSelection() const
}
// Set Layer #
int LAYER_BOX_SELECTOR::SetLayerSelection( LAYER_NUM layer )
{
int elements = GetCount();

View File

@ -112,12 +112,11 @@ PAGED_DIALOG::PAGED_DIALOG( wxWindow* aParent, const wxString& aTitle, bool aSho
}
m_treebook->Connect( wxEVT_TREEBOOK_PAGE_CHANGED,
wxBookCtrlEventHandler( PAGED_DIALOG::OnPageChange ), NULL, this );
wxBookCtrlEventHandler( PAGED_DIALOG::OnPageChange ), nullptr, this );
Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( PAGED_DIALOG::OnUpdateUI ), nullptr, this );
}
// Finish initialization after the bookctrl pages have been added.
void PAGED_DIALOG::finishInitialization()
{
for( size_t i = 0; i < m_treebook->GetPageCount(); ++i )
@ -184,7 +183,7 @@ PAGED_DIALOG::~PAGED_DIALOG()
}
m_treebook->Disconnect( wxEVT_TREEBOOK_PAGE_CHANGED,
wxBookCtrlEventHandler( PAGED_DIALOG::OnPageChange ), NULL, this );
wxBookCtrlEventHandler( PAGED_DIALOG::OnPageChange ), nullptr, this );
Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( PAGED_DIALOG::OnUpdateUI ),
nullptr, this );
}
@ -360,7 +359,7 @@ void PAGED_DIALOG::OnPageChange( wxBookCtrlEvent& event )
{
size_t page = event.GetSelection();
// Enable the reset button only if the page is resettable
// Enable the reset button only if the page is re-settable
if( m_resetButton )
{
if( auto panel = dynamic_cast<RESETTABLE_PANEL*>( m_treebook->GetPage( page ) ) )

View File

@ -2,6 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2017-2018 CERN
* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
* This program is free software; you can redistribute it and/or
@ -24,6 +25,7 @@
#include <widgets/text_ctrl_eval.h>
TEXT_CTRL_EVAL::TEXT_CTRL_EVAL( wxWindow* aParent, wxWindowID aId, const wxString& aValue,
const wxPoint& aPos, const wxSize& aSize, long aStyle,
const wxValidator& aValidator, const wxString& aName ) :
@ -31,9 +33,12 @@ TEXT_CTRL_EVAL::TEXT_CTRL_EVAL( wxWindow* aParent, wxWindowID aId, const wxStrin
aName ),
m_eval( EDA_UNITS::UNSCALED )
{
Connect( wxEVT_SET_FOCUS, wxFocusEventHandler( TEXT_CTRL_EVAL::onTextFocusGet ), NULL, this );
Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( TEXT_CTRL_EVAL::onTextFocusLost ), NULL, this );
Connect( wxEVT_TEXT_ENTER, wxCommandEventHandler( TEXT_CTRL_EVAL::onTextEnter ), NULL, this );
Connect( wxEVT_SET_FOCUS, wxFocusEventHandler( TEXT_CTRL_EVAL::onTextFocusGet ), nullptr,
this );
Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( TEXT_CTRL_EVAL::onTextFocusLost ), nullptr,
this );
Connect( wxEVT_TEXT_ENTER, wxCommandEventHandler( TEXT_CTRL_EVAL::onTextEnter ), nullptr,
this );
}

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2014-2015 CERN
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Author: Maciej Suminski <maciej.suminski@cern.ch>
*
* This program is free software; you can redistribute it and/or
@ -33,8 +33,10 @@
#include "widgets/unit_binder.h"
wxDEFINE_EVENT( DELAY_FOCUS, wxCommandEvent );
UNIT_BINDER::UNIT_BINDER( EDA_DRAW_FRAME* aParent, wxStaticText* aLabel, wxWindow* aValueCtrl,
wxStaticText* aUnitLabel, bool allowEval ) :
m_frame( aParent ),
@ -64,17 +66,22 @@ UNIT_BINDER::UNIT_BINDER( EDA_DRAW_FRAME* aParent, wxStaticText* aLabel, wxWindo
if( m_unitLabel )
m_unitLabel->SetLabel( GetAbbreviatedUnitsLabel( m_units, m_dataType ) );
m_valueCtrl->Connect( wxEVT_SET_FOCUS, wxFocusEventHandler( UNIT_BINDER::onSetFocus ), NULL, this );
m_valueCtrl->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( UNIT_BINDER::onKillFocus ), NULL, this );
Connect( DELAY_FOCUS, wxCommandEventHandler( UNIT_BINDER::delayedFocusHandler ), NULL, this );
m_valueCtrl->Connect( wxEVT_SET_FOCUS, wxFocusEventHandler( UNIT_BINDER::onSetFocus ),
nullptr, this );
m_valueCtrl->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( UNIT_BINDER::onKillFocus ),
nullptr, this );
Connect( DELAY_FOCUS, wxCommandEventHandler( UNIT_BINDER::delayedFocusHandler ), nullptr,
this );
m_frame->Connect( UNITS_CHANGED, wxCommandEventHandler( UNIT_BINDER::onUnitsChanged ), nullptr, this );
m_frame->Connect( UNITS_CHANGED, wxCommandEventHandler( UNIT_BINDER::onUnitsChanged ),
nullptr, this );
}
UNIT_BINDER::~UNIT_BINDER()
{
m_frame->Disconnect( UNITS_CHANGED, wxCommandEventHandler( UNIT_BINDER::onUnitsChanged ), nullptr, this );
m_frame->Disconnect( UNITS_CHANGED, wxCommandEventHandler( UNIT_BINDER::onUnitsChanged ),
nullptr, this );
}
@ -208,6 +215,7 @@ bool UNIT_BINDER::Validate( double aMin, double aMax, EDA_UNITS aUnits )
StringFromValue( m_units, val_min_iu, true ) );
textEntry->SelectAll();
// Don't focus directly; we might be inside a KillFocus event handler
wxPostEvent( this, wxCommandEvent( DELAY_FOCUS ) );
@ -222,6 +230,7 @@ bool UNIT_BINDER::Validate( double aMin, double aMax, EDA_UNITS aUnits )
StringFromValue( m_units, val_max_iu, true ) );
textEntry->SelectAll();
// Don't focus directly; we might be inside a KillFocus event handler
wxPostEvent( this, wxCommandEvent( DELAY_FOCUS ) );
@ -306,9 +315,13 @@ long long int UNIT_BINDER::GetValue()
value = textEntry->GetValue();
}
else if( staticText )
{
value = staticText->GetLabel();
}
else
{
return 0;
}
long long int displayValue = ValueFromString( m_units, value, m_dataType );
return m_originTransforms.FromDisplay( displayValue, m_coordType );

View File

@ -26,11 +26,7 @@
#include <kiplatform/ui.h>
#include <widgets/wx_aui_art_providers.h>
/**
* wxAuiDefaultToolBarArt::DrawButton except with dark-mode awareness based on BITMAP_BUTTON
* Unfortunately, wx 3.0 does not provide any hooks that would make it possible to do this in a way
* other than just copy/pasting the upstream implementation and modifying it...
*/
void WX_AUI_TOOLBAR_ART::DrawButton( wxDC& aDc, wxWindow* aWindow, const wxAuiToolBarItem& aItem,
const wxRect& aRect )
{
@ -56,7 +52,8 @@ void WX_AUI_TOOLBAR_ART::DrawButton( wxDC& aDc, wxWindow* aWindow, const wxAuiTo
{
bmpX = aRect.x + ( aRect.width / 2 ) - ( aItem.GetBitmap().GetWidth() / 2 );
bmpY = aRect.y + ( ( aRect.height - textHeight ) / 2 ) - ( aItem.GetBitmap().GetHeight() / 2 );
bmpY = aRect.y + ( ( aRect.height - textHeight ) / 2 ) -
( aItem.GetBitmap().GetHeight() / 2 );
textX = aRect.x + ( aRect.width / 2 ) - ( textWidth / 2 ) + 1;
textY = aRect.y + aRect.height - textHeight - 1;
@ -132,7 +129,7 @@ WX_AUI_DOCK_ART::WX_AUI_DOCK_ART() : wxAuiDefaultDockArt()
m_captionFont = *wxNORMAL_FONT;
// Increase the box the caption rests in size a bit
m_captionSize = wxWindow::FromDIP( 20, NULL );
m_captionSize = wxWindow::FromDIP( 20, nullptr );
#endif
#endif

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
@ -88,7 +88,7 @@ void WX_GRID::SetTable( wxGridTableBase* aTable, bool aTakeOwnership )
delete[] formBuilderColWidths;
Connect( wxEVT_GRID_COL_MOVE, wxGridEventHandler( WX_GRID::onGridColMove ), NULL, this );
Connect( wxEVT_GRID_COL_MOVE, wxGridEventHandler( WX_GRID::onGridColMove ), nullptr, this );
m_weOwnTable = aTakeOwnership;
}
@ -100,7 +100,7 @@ void WX_GRID::DestroyTable( wxGridTableBase* aTable )
// is left open. Normally it's closed in Validate(), but not if the user hit Cancel.
CommitPendingChanges( true /* quiet mode */ );
Disconnect( wxEVT_GRID_COL_MOVE, wxGridEventHandler( WX_GRID::onGridColMove ), NULL, this );
Disconnect( wxEVT_GRID_COL_MOVE, wxGridEventHandler( WX_GRID::onGridColMove ), nullptr, this );
wxGrid::SetTable( nullptr );
delete aTable;
@ -144,8 +144,6 @@ void WX_GRID::ShowHideColumns( const wxString& shownColumns )
}
// An re-implementation of wxGrid::DrawColLabel which left-aligns the first column when
// there are no row labels.
void WX_GRID::DrawColLabel( wxDC& dc, int col )
{
if( GetColWidth( col ) <= 0 || m_colLabelHeight <= 0 )
@ -157,7 +155,7 @@ void WX_GRID::DrawColLabel( wxDC& dc, int col )
static wxGridColumnHeaderRendererDefault rend;
// It is reported that we need to erase the background to avoid display
// artefacts, see #12055.
// artifacts, see #12055.
// wxWidgets renamed this variable between 3.1.2 and 3.1.3 ...
#if wxCHECK_VERSION( 3, 1, 3 )
wxDCBrushChanger setBrush( dc, m_colLabelWin->GetBackgroundColour() );
@ -208,10 +206,10 @@ bool WX_GRID::CommitPendingChanges( bool aQuietMode )
if( changed )
{
if( !aQuietMode && SendEvent(wxEVT_GRID_CELL_CHANGING, newval) == -1 )
if( !aQuietMode && SendEvent( wxEVT_GRID_CELL_CHANGING, newval ) == -1 )
return false;
editor->ApplyEdit(row, col, this);
editor->ApplyEdit( row, col, this );
// for compatibility reasons dating back to wx 2.8 when this event
// was called wxEVT_GRID_CELL_CHANGE and wxEVT_GRID_CELL_CHANGING

View File

@ -125,7 +125,7 @@ public:
}
/// @copydoc wxWindow::Refresh()
virtual void Refresh( bool aEraseBackground = true, const wxRect* aRect = NULL ) override;
virtual void Refresh( bool aEraseBackground = true, const wxRect* aRect = nullptr ) override;
/**
* Force a redraw.

View File

@ -55,7 +55,7 @@ public:
*
* @param aLayout the alternate drawing sheet; if null restore the default drawing sheet
*/
static void SetAltInstance( DS_DATA_MODEL* aLayout = NULL );
static void SetAltInstance( DS_DATA_MODEL* aLayout = nullptr );
int GetFileFormatVersionAtLoad() { return m_fileFormatVersionAtLoad; }
void SetFileFormatVersionAtLoad( int aVersion ) { m_fileFormatVersionAtLoad = aVersion; }

View File

@ -488,7 +488,7 @@ public:
if( m_graphicList.size() )
return m_graphicList[0];
else
return NULL;
return nullptr;
}
DS_DRAW_ITEM_BASE* GetNext()
@ -498,7 +498,7 @@ public:
if( m_graphicList.size() > m_idx )
return m_graphicList[m_idx];
else
return NULL;
return nullptr;
}
void GetAllItems( std::vector<DS_DRAW_ITEM_BASE*>* aList )

View File

@ -2,7 +2,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-2020 Kicad Developers, see change_log.txt for contributors.
* Copyright (C) 2007-2021 Kicad Developers, see change_log.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
@ -127,7 +127,7 @@ public:
* #STRING_LINE_READER or #FILE_LINE_READER. No ownership is taken.
*/
DSNLEXER( const KEYWORD* aKeywordTable, unsigned aKeywordCount,
LINE_READER* aLineReader = NULL );
LINE_READER* aLineReader = nullptr );
virtual ~DSNLEXER();

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2011 Jean-Pierre Charras, <jp.charras@wanadoo.fr>
* 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
@ -252,7 +252,7 @@ public:
virtual bool ReadFootprintFiles( FP_LIB_TABLE* aTable, const wxString* aNickname = nullptr,
PROGRESS_REPORTER* aProgressReporter = nullptr ) = 0;
void DisplayErrors( wxTopLevelWindow* aCaller = NULL );
void DisplayErrors( wxTopLevelWindow* aCaller = nullptr );
FP_LIB_TABLE* GetTable() const
{

View File

@ -2,7 +2,7 @@
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2017 Bernhard Stegmaier <stegmaier@sw-systems.de>
* Copyright (C) 2016-2020 Kicad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2016-2021 Kicad Developers, see AUTHORS.txt for contributors.
*
* Base class for HiDPI aware wxGLCanvas implementations.
*
@ -39,7 +39,7 @@ class HIDPI_GL_CANVAS : public wxGLCanvas
{
public:
// wxGLCanvas constructor
HIDPI_GL_CANVAS( wxWindow *parent, wxWindowID id = wxID_ANY, const int *attribList = NULL,
HIDPI_GL_CANVAS( wxWindow *parent, wxWindowID id = wxID_ANY, const int* attribList = nullptr,
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = 0, const wxString& name = wxGLCanvasName,
const wxPalette& palette = wxNullPalette );

View File

@ -2,7 +2,7 @@
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2014-2017 CERN
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors.
*
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
@ -156,7 +156,7 @@ public:
*/
inline bool IsConstrained() const
{
return m_constraint != NULL;
return m_constraint != nullptr;
}
/**

View File

@ -87,7 +87,7 @@ protected:
struct ANCHOR
{
ANCHOR( VECTOR2I aPos, int aFlags = CORNER | SNAPPABLE, EDA_ITEM* aItem = NULL ) :
ANCHOR( VECTOR2I aPos, int aFlags = CORNER | SNAPPABLE, EDA_ITEM* aItem = nullptr ) :
pos( aPos ),
flags( aFlags ),
item( aItem )

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 CERN
* Copyright (C) 2016-2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2016-2021 KiCad Developers, see AUTHORS.txt for contributors.
*
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
*
@ -69,7 +69,7 @@ public:
m_type( aType ),
m_toolId( aId ),
m_toolName( aName ),
m_toolMgr( NULL ) {};
m_toolMgr( nullptr ) {};
virtual ~TOOL_BASE() {};

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2013-2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2013-2021 KiCad Developers, see AUTHORS.txt for contributors.
*
* @author Dick Hollenbeck
*
@ -205,7 +205,7 @@ public:
public:
uni_iter() // Needed only to build python wrapper, not used outside the wrapper
{
it = NULL;
it = nullptr;
}
uni_iter( const uni_iter& o )
@ -297,7 +297,7 @@ public:
* @param aResult is where to put the unicode character, and may be NULL if no interest.
* @return the count of bytes consumed.
*/
static int uni_forward( const unsigned char* aSequence, unsigned* aResult = NULL );
static int uni_forward( const unsigned char* aSequence, unsigned* aResult = nullptr );
#endif // SWIG
protected:

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 CERN
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors.
*
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
@ -46,7 +46,7 @@ namespace KIGFX
class VIEW_GROUP : public VIEW_ITEM
{
public:
VIEW_GROUP( VIEW* aView = NULL );
VIEW_GROUP( VIEW* aView = nullptr );
virtual ~VIEW_GROUP();
/**

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
@ -25,22 +25,23 @@
#define __APP_PROGRESS_REPORTER
#include <wx/progdlg.h>
#if wxCHECK_VERSION(3, 1, 0)
#if wxCHECK_VERSION( 3, 1, 0 )
#include <wx/appprogress.h>
#endif
/**
* wxProgressDialog with the option to also update the application progress on the taskbar
*/
* wxProgressDialog with the option to also update the application progress on the taskbar
*/
class APP_PROGRESS_DIALOG : public wxProgressDialog
{
public:
APP_PROGRESS_DIALOG( const wxString& aTitle, const wxString& aMessage, int aMaximum = 100,
wxWindow* aParent = NULL, bool aIndeterminateTaskBarStatus = false,
wxWindow* aParent = nullptr, bool aIndeterminateTaskBarStatus = false,
int aStyle = wxPD_APP_MODAL | wxPD_AUTO_HIDE );
virtual bool Update( int aValue, const wxString& aNewMsg = wxEmptyString,
bool* aSkip = NULL ) override;
bool* aSkip = nullptr ) override;
private:

View File

@ -71,7 +71,7 @@ public:
LAYER_BOX_SELECTOR( wxWindow* parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
int n = 0, const wxString choices[] = NULL );
int n = 0, const wxString choices[] = nullptr );
LAYER_BOX_SELECTOR( wxWindow* parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2018 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
@ -65,9 +65,9 @@ wxFont GetInfoFont();
* @param aString the text that is used in sizing the control's pixel width.
* If NULL, then
* the text already within the control is used.
* @return bool - true if the \a aCtrl had its size changed, else false.
* @return true if the \a aCtrl had its size changed, else false.
*/
bool EnsureTextCtrlWidth( wxTextCtrl* aCtrl, const wxString* aString = NULL );
bool EnsureTextCtrlWidth( wxTextCtrl* aCtrl, const wxString* aString = nullptr );
/**
* Select the number (or "?") in a reference for ease of editing.
@ -86,7 +86,8 @@ bool IsInputControlFocused( wxWindow* aFocus = nullptr );
*
* @param aFocus Control that test if editable
*
* @return True if control is input and editable OR control is not a input. False if control is input and not editable.
* @return True if control is input and editable OR control is not a input. False if control is
* input and not editable.
*/
bool IsInputControlEditable( wxWindow* aControl );

View File

@ -35,6 +35,13 @@ public:
virtual ~WX_AUI_TOOLBAR_ART() = default;
/**
* The same as wxAuiDefaultToolBarArt::DrawButton except with dark-mode awareness based on
* BITMAP_BUTTON.
*
* Unfortunately, wx 3.0 does not provide any hooks that would make it possible to do this in
* a way other than just copy/pasting the upstream implementation and modifying it.
*/
void DrawButton( wxDC& aDc, wxWindow* aWindow, const wxAuiToolBarItem& aItem,
const wxRect& aRect ) override;
};

View File

@ -99,6 +99,10 @@ public:
void ShowEditorOnMouseUp() { m_waitForSlowClick = true; }
protected:
/**
* A re-implementation of wxGrid::DrawColLabel which left-aligns the first column when
* there are no row labels.
*/
void DrawColLabel( wxDC& dc, int col ) override;
void onGridColMove( wxGridEvent& aEvent );