wxWidgets 3.3 compatibility: explicit wxString conversion

This commit is contained in:
Jon Evans 2024-03-20 21:52:19 -04:00
parent e7b6573717
commit f00f47df13
18 changed files with 45 additions and 43 deletions

View File

@ -952,7 +952,7 @@ void DIALOG_ERC::deleteAllMarkers( bool aIncludeExclusions )
void DIALOG_ERC::OnSaveReport( wxCommandEvent& aEvent )
{
wxFileName fn( wxS( "ERC." ) + FILEEXT::ReportFileExtension );
wxFileName fn( wxS( "ERC." ) + wxString( FILEEXT::ReportFileExtension ) );
wxFileDialog dlg( this, _( "Save Report File" ), Prj().GetProjectPath(), fn.GetFullName(),
FILEEXT::ReportFileWildcard() + wxS( "|" ) + FILEEXT::JsonFileWildcard(),
@ -990,4 +990,4 @@ void DIALOG_ERC::OnSaveReport( wxCommandEvent& aEvent )
DisplayError( this, wxString::Format( _( "Failed to create file '%s'." ),
fn.GetFullPath() ) );
}
}
}

View File

@ -422,7 +422,10 @@ bool DIALOG_SIM_COMMAND::TransferDataFromWindow()
}
if( !ref.IsEmpty() )
ref = wxS( "," ) + m_circuitModel->GetItemName( std::string( ref.ToUTF8() ) );
{
ref = wxS( "," )
+ wxString( m_circuitModel->GetItemName( std::string( ref.ToUTF8() ) ) );
}
m_simCommand.Printf( ".noise v(%s%s) %s %s %s %s %s %s",
output,

View File

@ -68,7 +68,7 @@ LIB_SYMBOL* SchGetLibSymbol( const LIB_ID& aLibId, SYMBOL_LIB_TABLE* aLibTable,
wxCHECK_MSG( aCacheLib->IsCache(), nullptr, wxS( "Invalid cache library." ) );
wxString cacheName = aLibId.GetLibNickname().wx_str();
cacheName += "_" + aLibId.GetLibItemName();
cacheName << "_" << aLibId.GetLibItemName();
symbol = aCacheLib->FindSymbol( cacheName );
}
}

View File

@ -569,7 +569,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSheets()
getSheetNumber( rootSheetID ) )
.ToStdString();
ReplaceIllegalFileNameChars( &filename );
filename += wxT( "." ) + FILEEXT::KiCadSchematicFileExtension;
filename += wxT( "." ) + wxString( FILEEXT::KiCadSchematicFileExtension );
wxFileName fn( m_schematic->Prj().GetProjectPath() + filename );
m_rootSheet->GetScreen()->SetFileName( fn.GetFullPath() );
@ -2493,7 +2493,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSheetAndChildSheets( LAYER_ID
std::string filename = wxString::Format( "%s_%02d", loadedFilename, sheetNum ).ToStdString();
ReplaceIllegalFileNameChars( &filename );
filename += wxT( "." ) + FILEEXT::KiCadSchematicFileExtension;
filename += wxT( "." ) + wxString( FILEEXT::KiCadSchematicFileExtension );
filenameField.SetText( filename );

View File

@ -1874,7 +1874,7 @@ void SCH_IO_EAGLE::loadInstance( wxXmlNode* aInstanceNode )
for( const auto& a : epart->variant )
{
SCH_FIELD* field = symbol->AddField( *symbol->GetField( VALUE_FIELD ) );
field->SetName( wxT( "VARIANT_" ) + a.first );
field->SetName( wxT( "VARIANT_" ) + wxString( a.first ) );
field->SetText( a.second );
field->SetVisible( false );
}

View File

@ -2055,7 +2055,7 @@ int SCH_SCREENS::ChangeSymbolLibNickname( const wxString& aFrom, const wxString&
{
SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
if( symbol->GetLibId().GetLibNickname() != aFrom )
if( wxString( symbol->GetLibId().GetLibNickname() ) != aFrom )
continue;
LIB_ID id = symbol->GetLibId();

View File

@ -1802,7 +1802,7 @@ void SCH_SYMBOL::Show( int nestLevel, std::ostream& os ) const
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str()
<< " ref=\"" << TO_UTF8( GetField( REFERENCE_FIELD )->GetName() )
<< '"' << " chipName=\""
<< GetLibId().Format() << '"' << m_pos
<< wxString( GetLibId().Format() ) << '"' << m_pos
<< " layer=\"" << m_layer
<< '"' << ">\n";

View File

@ -45,22 +45,6 @@ enum class PAD_SHAPE : int
// (thick segments, circles, arcs, polygons).
};
static inline std::string PAD_SHAPE_T_asString( PAD_SHAPE a )
{
switch( a )
{
case PAD_SHAPE::CIRCLE: return "PAD_SHAPE::CIRCLE";
case PAD_SHAPE::RECTANGLE: return "PAD_SHAPE::RECT";
case PAD_SHAPE::OVAL: return "PAD_SHAPE::OVAL";
case PAD_SHAPE::TRAPEZOID: return "PAD_SHAPE::TRAPEZOID";
case PAD_SHAPE::ROUNDRECT: return "PAD_SHAPE::ROUNDRECT";
case PAD_SHAPE::CHAMFERED_RECT: return "PAD_SHAPE::CHAMFERED_RECT";
case PAD_SHAPE::CUSTOM: return "PAD_SHAPE::CUSTOM";
}
return ""; // Just to quiet GCC.
};
/**
* The set of pad drill shapes, used with PAD::{Set,Get}DrillShape()

View File

@ -152,7 +152,7 @@ void IMPORT_PROJ_HELPER::ImportIndividualFile( KICAD_T aFT, int aImportedFileTyp
ss << aImportedFileType << '\n' << TO_UTF8( appImportFile );
for( const auto& [key, value] : m_properties )
ss << '\n' << key << '\n' << value;
ss << '\n' << key << '\n' << wxString( value );
std::string packet = ss.str();
frame->Kiway().ExpressMail( frame_type, MAIL_IMPORT_FILE, packet, m_frame );
@ -216,4 +216,4 @@ void IMPORT_PROJ_HELPER::ImportFiles( int aImportedSchFileType, int aImportedPcb
ImportIndividualFile( SCHEMATIC_T, aImportedSchFileType );
ImportIndividualFile( PCB_T, aImportedPcbFileType );
}
}

View File

@ -267,7 +267,7 @@ void PANEL_PACKAGES_VIEW::setPackageDetails( const PACKAGE_VIEW_DATA& aPackageDa
for( const std::pair<const std::string, wxString>& entry : contact.contact )
{
details << wxT( "<li>" );
details << entry.first + wxT( ": " ) + format_entry( entry );
details << entry.first << wxT( ": " ) + format_entry( entry );
details << wxT( "</li>" );
}
@ -286,7 +286,7 @@ void PANEL_PACKAGES_VIEW::setPackageDetails( const PACKAGE_VIEW_DATA& aPackageDa
for( const std::pair<const std::string, wxString>& entry : package.resources )
{
details << wxT( "<li>" );
details << entry.first + wxT( ": " );
details << entry.first << wxT( ": " );
details << format_entry( entry ) + wxT( "</li>" );
}

View File

@ -114,6 +114,10 @@ public:
bool operator==( const std::string& rhs ) const { return m_s == rhs; }
bool operator==( const char* s ) const { return m_s == s; }
bool operator!=( const UTF8& rhs ) const { return !( operator==( rhs ) ); }
bool operator<( const UTF8& rhs ) const { return m_s < rhs.m_s; }
bool operator>( const UTF8& rhs ) const { return m_s > rhs.m_s; }
std::string::size_type find_first_of( const std::string& str,
std::string::size_type pos = 0 ) const
{
@ -305,4 +309,6 @@ protected:
};
std::ostream& operator<<( std::ostream& aStream, const UTF8& aRhs );
#endif // UTF8_H_

View File

@ -239,3 +239,10 @@ UTF8& UTF8::operator+=( unsigned w_ch )
return *this;
}
std::ostream& operator<<( std::ostream& aStream, const UTF8& aRhs )
{
aStream << static_cast<const std::string&>( aRhs );
return aStream;
}

View File

@ -298,7 +298,7 @@ void FOOTPRINT_CHOOSER_FRAME::Update3DView( bool aMarkDirty,
wxString footprintName;
if( fpID.IsValid() )
footprintName = fpID.Format();
footprintName << fpID.Format();
wxString title = _( "3D Viewer" ) + wxT( " \u2014 " ) + footprintName;
PCB_BASE_FRAME::Update3DView( aMarkDirty, aRefresh, &title );

View File

@ -53,6 +53,7 @@
#include <memory>
#include <macros.h>
#include <magic_enum.hpp>
#include "kiface_base.h"
#include "pcbnew_settings.h"
@ -552,8 +553,8 @@ void PAD::BuildEffectiveShapes( PCB_LAYER_ID aLayer ) const
break;
default:
wxFAIL_MSG( wxT( "PAD::buildEffectiveShapes: Unsupported pad shape: " )
+ PAD_SHAPE_T_asString( effectiveShape ) );
wxFAIL_MSG( wxT( "PAD::buildEffectiveShapes: Unsupported pad shape: PAD_SHAPE::" )
+ wxString( magic_enum::enum_name( effectiveShape ) ) );
break;
}
@ -1719,7 +1720,7 @@ void PAD::TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer,
default:
wxFAIL_MSG( wxT( "PAD::TransformShapeToPolygon no implementation for " )
+ PAD_SHAPE_T_asString( GetShape() ) );
+ wxString( magic_enum::enum_name( GetShape() ) ) );
break;
}
}

View File

@ -286,7 +286,7 @@ ABOARD6::ABOARD6( ALTIUM_BINARY_PARSER& aReader )
for( size_t i = 1; i < std::numeric_limits<size_t>::max(); i++ )
{
const wxString layeri = wxT( "LAYER" ) + std::to_string( i );
const wxString layeri = wxT( "LAYER" ) + wxString( std::to_string( i ) );
const wxString layername = layeri + wxT( "NAME" );
auto layernameit = props.find( layername );
@ -334,7 +334,7 @@ ACLASS6::ACLASS6( ALTIUM_BINARY_PARSER& aReader )
for( size_t i = 0; i < std::numeric_limits<size_t>::max(); i++ )
{
auto mit = properties.find( wxT( "M" ) + std::to_string( i ) );
auto mit = properties.find( wxT( "M" ) + wxString( std::to_string( i ) ) );
if( mit == properties.end() )
break; // it doesn't seem like we know beforehand how many components are in the netclass
@ -417,8 +417,9 @@ ADIMENSION6::ADIMENSION6( ALTIUM_BINARY_PARSER& aReader )
for( int i = 0; i < refcount; i++ )
{
const std::string refi = "REFERENCE" + std::to_string( i ) + "POINT";
referencePoint.emplace_back( ALTIUM_PROPS_UTILS::ReadKicadUnit( props, refi + wxT( "X" ), wxT( "0mil" ) ),
-ALTIUM_PROPS_UTILS::ReadKicadUnit( props, refi + wxT( "Y" ), wxT( "0mil" ) ) );
const wxString ref( refi );
referencePoint.emplace_back( ALTIUM_PROPS_UTILS::ReadKicadUnit( props, ref + wxT( "X" ), wxT( "0mil" ) ),
-ALTIUM_PROPS_UTILS::ReadKicadUnit( props, ref + wxT( "Y" ), wxT( "0mil" ) ) );
}
for( size_t i = 1; i < std::numeric_limits<size_t>::max(); i++ )

View File

@ -230,7 +230,7 @@ void GPCB_FPL_CACHE::Load()
}
wxString fullName;
wxString fileSpec = wxT( "*." ) + FILEEXT::GedaPcbFootprintLibFileExtension;
wxString fileSpec = wxT( "*." ) + wxString( FILEEXT::GedaPcbFootprintLibFileExtension );
// wxFileName construction is egregiously slow. Construct it once and just swap out
// the filename thereafter.
@ -301,7 +301,7 @@ bool GPCB_FPL_CACHE::IsModified()
long long GPCB_FPL_CACHE::GetTimestamp( const wxString& aLibPath )
{
wxString fileSpec = wxT( "*." ) + FILEEXT::GedaPcbFootprintLibFileExtension;
wxString fileSpec = wxT( "*." ) + wxString( FILEEXT::GedaPcbFootprintLibFileExtension );
return TimestampDir( aLibPath, fileSpec );
}

View File

@ -172,7 +172,7 @@ void FP_CACHE::Load()
}
wxString fullName;
wxString fileSpec = wxT( "*." ) + FILEEXT::KiCadFootprintFileExtension;
wxString fileSpec = wxT( "*." ) + wxString( FILEEXT::KiCadFootprintFileExtension );
// wxFileName construction is egregiously slow. Construct it once and just swap out
// the filename thereafter.
@ -268,7 +268,7 @@ bool FP_CACHE::IsModified()
long long FP_CACHE::GetTimestamp( const wxString& aLibPath )
{
wxString fileSpec = wxT( "*." ) + FILEEXT::KiCadFootprintFileExtension;
wxString fileSpec = wxT( "*." ) + wxString( FILEEXT::KiCadFootprintFileExtension );
return TimestampDir( aLibPath, fileSpec );
}

View File

@ -379,10 +379,10 @@ int BOARD_EDITOR_CONTROL::ImportSpecctraSession( const TOOL_EVENT& aEvent )
wxString ext;
wxFileName::SplitPath( fullFileName, &path, &name, &ext );
name += wxT( "." ) + FILEEXT::SpecctraSessionFileExtension;
name += wxT( "." ) + wxString( FILEEXT::SpecctraSessionFileExtension );
fullFileName = wxFileSelector( _( "Specctra Session File" ), path, name,
wxT( "." ) + FILEEXT::SpecctraSessionFileExtension,
wxT( "." ) + wxString( FILEEXT::SpecctraSessionFileExtension ),
FILEEXT::SpecctraSessionFileWildcard(), wxFD_OPEN | wxFD_CHANGE_DIR,
frame() );