From 76aa0ba756cd7eef6021036e8973675177d23364 Mon Sep 17 00:00:00 2001 From: "maciej." Date: Sat, 18 Jan 2014 03:07:05 -0600 Subject: [PATCH] Fix compile errors when wx3.x is built with --enable-stl --- common/edaappl.cpp | 7 +--- common/gr_basic.cpp | 4 +-- .../page_layout/class_worksheet_dataitem.cpp | 2 +- common/string.cpp | 36 ++++++++++--------- eeschema/class_library.cpp | 20 +++++------ eeschema/class_library.h | 14 ++++---- eeschema/dialogs/dialog_erc.cpp | 5 +-- eeschema/dialogs/dialog_erc.h | 2 -- eeschema/erc.cpp | 10 +++--- eeschema/erc.h | 2 ++ include/class_worksheet_dataitem.h | 31 ++++++++-------- include/colors.h | 2 +- include/kicad_string.h | 6 ++-- pcbnew/class_pcb_layer_widget.cpp | 2 +- pcbnew/exporters/gen_modules_placefile.cpp | 4 +-- pcbnew/specctra.cpp | 2 +- pcbnew/specctra.h | 2 +- pcbnew/specctra_import.cpp | 4 +-- 18 files changed, 75 insertions(+), 80 deletions(-) diff --git a/common/edaappl.cpp b/common/edaappl.cpp index a8fa09ae83..9a097454b6 100644 --- a/common/edaappl.cpp +++ b/common/edaappl.cpp @@ -57,11 +57,6 @@ static const wxChar* CommonConfigPath = wxT( "kicad_common" ); -#ifdef __UNIX__ -# define TMP_FILE "/tmp/kicad.tmp" -#endif - - // some key strings used to store parameters in config static const wxChar backgroundColorKey[] = wxT( "BackgroundColor" ); static const wxChar showPageLimitsKey[] = wxT( "ShowPageLimits" ); @@ -90,7 +85,7 @@ struct LANGUAGE_DESCR BITMAP_DEF m_Lang_Icon; /// Labels used in menus - const wxChar* m_Lang_Label; + wxString m_Lang_Label; /// Set to true if the m_Lang_Label must not be translated bool m_DoNotTranslate; diff --git a/common/gr_basic.cpp b/common/gr_basic.cpp index e8d4b4449f..22a58b338a 100644 --- a/common/gr_basic.cpp +++ b/common/gr_basic.cpp @@ -1451,12 +1451,12 @@ EDA_COLOR_T ColorMix( EDA_COLOR_T aColor1, EDA_COLOR_T aColor2 ) } -EDA_COLOR_T ColorByName( const wxChar *aName ) +EDA_COLOR_T ColorByName( const wxString& aName ) { // look for a match in the palette itself for( EDA_COLOR_T trying = BLACK; trying < NBCOLORS; trying = NextColor(trying) ) { - if( 0 == wxStricmp( aName, g_ColorRefs[trying].m_Name ) ) + if( 0 == aName.CmpNoCase( g_ColorRefs[trying].m_Name ) ) return trying; } diff --git a/common/page_layout/class_worksheet_dataitem.cpp b/common/page_layout/class_worksheet_dataitem.cpp index 819fc1a5ff..66683d191a 100644 --- a/common/page_layout/class_worksheet_dataitem.cpp +++ b/common/page_layout/class_worksheet_dataitem.cpp @@ -430,7 +430,7 @@ const wxPoint WORKSHEET_DATAITEM_POLYPOLYGON::GetCornerPositionUi( unsigned aIdx return wxPoint( int(pos.x), int(pos.y) ); } -WORKSHEET_DATAITEM_TEXT::WORKSHEET_DATAITEM_TEXT( const wxChar* aTextBase ) : +WORKSHEET_DATAITEM_TEXT::WORKSHEET_DATAITEM_TEXT( const wxString& aTextBase ) : WORKSHEET_DATAITEM( WS_TEXT ) { m_TextBase = aTextBase; diff --git a/common/string.cpp b/common/string.cpp index 7d3a74f0c4..f801a8748c 100644 --- a/common/string.cpp +++ b/common/string.cpp @@ -211,31 +211,33 @@ wxString DateAndTime() } -int StrNumCmp( const wxChar* aString1, const wxChar* aString2, int aLength, bool aIgnoreCase ) +int StrNumCmp( const wxString& aString1, const wxString& aString2, int aLength, bool aIgnoreCase ) { int i; int nb1 = 0, nb2 = 0; - if( ( aString1 == NULL ) || ( aString2 == NULL ) ) + wxString::const_iterator str1 = aString1.begin(), str2 = aString2.begin(); + + if( ( str1 == aString1.end() ) || ( str2 == aString2.end() ) ) return 0; for( i = 0; i < aLength; i++ ) { - if( isdigit( *aString1 ) && isdigit( *aString2 ) ) /* digit found */ + if( isdigit( *str1 ) && isdigit( *str2 ) ) /* digit found */ { nb1 = 0; nb2 = 0; - while( isdigit( *aString1 ) ) + while( isdigit( *str1 ) ) { - nb1 = nb1 * 10 + *aString1 - '0'; - aString1++; + nb1 = nb1 * 10 + (int) *str1 - '0'; + str1++; } - while( isdigit( *aString2 ) ) + while( isdigit( *str2 ) ) { - nb2 = nb2 * 10 + *aString2 - '0'; - aString2++; + nb2 = nb2 * 10 + (int) *str2 - '0'; + str2++; } if( nb1 < nb2 ) @@ -247,29 +249,29 @@ int StrNumCmp( const wxChar* aString1, const wxChar* aString2, int aLength, bool if( aIgnoreCase ) { - if( toupper( *aString1 ) < toupper( *aString2 ) ) + if( toupper( *str1 ) < toupper( *str2 ) ) return -1; - if( toupper( *aString1 ) > toupper( *aString2 ) ) + if( toupper( *str1 ) > toupper( *str2 ) ) return 1; - if( ( *aString1 == 0 ) && ( *aString2 == 0 ) ) + if( ( *str1 == 0 ) && ( *str2 == 0 ) ) return 0; } else { - if( *aString1 < *aString2 ) + if( *str1 < *str2 ) return -1; - if( *aString1 > *aString2 ) + if( *str1 > *str2 ) return 1; - if( ( *aString1 == 0 ) && ( *aString2 == 0 ) ) + if( ( str1 == aString1.end() ) && ( str2 == aString2.end() ) ) return 0; } - aString1++; - aString2++; + str1++; + str2++; } return 0; diff --git a/eeschema/class_library.cpp b/eeschema/class_library.cpp index 6a57b1c232..284142bc43 100644 --- a/eeschema/class_library.cpp +++ b/eeschema/class_library.cpp @@ -44,18 +44,18 @@ #include #include -static const wxChar* duplicate_name_msg = +static const wxString duplicate_name_msg = _( "Library <%s> has duplicate entry name <%s>.\n\ This may cause some unexpected behavior when loading components into a schematic." ); -bool operator==( const CMP_LIBRARY& aLibrary, const wxChar* aName ) +bool operator==( const CMP_LIBRARY& aLibrary, const wxString& aName ) { return aLibrary.GetName().CmpNoCase( aName ) == 0; } -bool operator!=( const CMP_LIBRARY& aLibrary, const wxChar* aName ) +bool operator!=( const CMP_LIBRARY& aLibrary, const wxString& aName ) { return !( aLibrary == aName ); } @@ -224,10 +224,10 @@ bool CMP_LIBRARY::Conflicts( LIB_COMPONENT* aComponent ) } -LIB_ALIAS* CMP_LIBRARY::FindEntry( const wxChar* aName ) +LIB_ALIAS* CMP_LIBRARY::FindEntry( const wxString& aName ) { - LIB_ALIAS_MAP::iterator it = aliases.find( wxString( aName ) ); + LIB_ALIAS_MAP::iterator it = aliases.find( aName ); if( it != aliases.end() ) return (*it).second; @@ -245,7 +245,7 @@ LIB_ALIAS* CMP_LIBRARY::GetFirstEntry() } -LIB_COMPONENT* CMP_LIBRARY::FindComponent( const wxChar* aName ) +LIB_COMPONENT* CMP_LIBRARY::FindComponent( const wxString& aName ) { LIB_COMPONENT* component = NULL; LIB_ALIAS* entry = FindEntry( aName ); @@ -392,12 +392,12 @@ LIB_COMPONENT* CMP_LIBRARY::ReplaceComponent( LIB_COMPONENT* aOldComponent, } -LIB_ALIAS* CMP_LIBRARY::GetNextEntry( const wxChar* aName ) +LIB_ALIAS* CMP_LIBRARY::GetNextEntry( const wxString& aName ) { if( aliases.empty() ) return NULL; - LIB_ALIAS_MAP::iterator it = aliases.find( wxString( aName ) ); + LIB_ALIAS_MAP::iterator it = aliases.find( aName ); it++; @@ -408,12 +408,12 @@ LIB_ALIAS* CMP_LIBRARY::GetNextEntry( const wxChar* aName ) } -LIB_ALIAS* CMP_LIBRARY::GetPreviousEntry( const wxChar* aName ) +LIB_ALIAS* CMP_LIBRARY::GetPreviousEntry( const wxString& aName ) { if( aliases.empty() ) return NULL; - LIB_ALIAS_MAP::iterator it = aliases.find( wxString( aName ) ); + LIB_ALIAS_MAP::iterator it = aliases.find( aName ); if( it == aliases.begin() ) it = aliases.end(); diff --git a/eeschema/class_library.h b/eeschema/class_library.h index 64610c326f..9c17b3cd8a 100644 --- a/eeschema/class_library.h +++ b/eeschema/class_library.h @@ -240,7 +240,7 @@ public: * @param aName - Name of entry, case insensitive. * @return Entry if found. NULL if not found. */ - LIB_ALIAS* FindEntry( const wxChar* aName ); + LIB_ALIAS* FindEntry( const wxString& aName ); /** * Find component by \a aName. @@ -251,7 +251,7 @@ public: * @param aName - Name of component, case insensitive. * @return Component if found. NULL if not found. */ - LIB_COMPONENT* FindComponent( const wxChar* aName ); + LIB_COMPONENT* FindComponent( const wxString& aName ); /** * Find alias by \a nName. @@ -262,7 +262,7 @@ public: * @param aName - Name of alias, case insensitive. * @return Alias if found. NULL if not found. */ - LIB_ALIAS* FindAlias( const wxChar* aName ) + LIB_ALIAS* FindAlias( const wxString& aName ) { return (LIB_ALIAS*) FindEntry( aName ); } @@ -331,7 +331,7 @@ public: * @param aName - Name of current entry. * @return Next entry if entry name is found. Otherwise NULL. */ - LIB_ALIAS* GetNextEntry( const wxChar* aName ); + LIB_ALIAS* GetNextEntry( const wxString& aName ); /** @@ -343,7 +343,7 @@ public: * @param aName - Name of current entry. * @return Previous entry if entry name is found, otherwise NULL. */ - LIB_ALIAS* GetPreviousEntry( const wxChar* aName ); + LIB_ALIAS* GetPreviousEntry( const wxString& aName ); /** * Return the file name without path or extension. @@ -525,7 +525,7 @@ public: /** * Case insensitive library name comparison. */ -extern bool operator==( const CMP_LIBRARY& aLibrary, const wxChar* aName ); -extern bool operator!=( const CMP_LIBRARY& aLibrary, const wxChar* aName ); +extern bool operator==( const CMP_LIBRARY& aLibrary, const wxString& aName ); +extern bool operator!=( const CMP_LIBRARY& aLibrary, const wxString& aName ); #endif // CLASS_LIBRARY_H diff --git a/eeschema/dialogs/dialog_erc.cpp b/eeschema/dialogs/dialog_erc.cpp index 91268209b5..03a6630236 100644 --- a/eeschema/dialogs/dialog_erc.cpp +++ b/eeschema/dialogs/dialog_erc.cpp @@ -290,10 +290,7 @@ void DIALOG_ERC::ReBuildMatrixPanel() wxPoint txtpos; txtpos.x = x + (bitmap_size.x / 2); txtpos.y = y - text_height; - text = new wxStaticText( m_matrixPanel, - -1, - CommentERC_V[ii], - txtpos ); + text = new wxStaticText( m_matrixPanel, -1, CommentERC_V[ii], txtpos ); } int event_id = ID_MATRIX_0 + ii + ( jj * PIN_NMAX ); diff --git a/eeschema/dialogs/dialog_erc.h b/eeschema/dialogs/dialog_erc.h index 61ad84b033..294efe7131 100644 --- a/eeschema/dialogs/dialog_erc.h +++ b/eeschema/dialogs/dialog_erc.h @@ -17,8 +17,6 @@ extern int DiagErc[PIN_NMAX][PIN_NMAX]; extern bool DiagErcTableInit; // go to true after DiagErc init extern int DefaultDiagErc[PIN_NMAX][PIN_NMAX]; -extern const wxChar* CommentERC_H[]; -extern const wxChar* CommentERC_V[]; /* Control identifiers */ #define ID_MATRIX_0 1800 diff --git a/eeschema/erc.cpp b/eeschema/erc.cpp index c52688f2db..379b48f620 100644 --- a/eeschema/erc.cpp +++ b/eeschema/erc.cpp @@ -82,7 +82,7 @@ */ // Messages for matrix rows: -const wxChar* CommentERC_H[] = +const wxString CommentERC_H[] = { _( "Input Pin.........." ), _( "Output Pin........." ), @@ -94,12 +94,11 @@ const wxChar* CommentERC_H[] = _( "Power Output Pin..." ), _( "Open Collector....." ), _( "Open Emitter......." ), - _( "No Connection......" ), - NULL + _( "No Connection......" ) }; // Messages for matrix columns -const wxChar* CommentERC_V[] = +const wxString CommentERC_V[] = { _( "Input Pin" ), _( "Output Pin" ), @@ -111,8 +110,7 @@ const wxChar* CommentERC_V[] = _( "Power Output Pin" ), _( "Open Collector" ), _( "Open Emitter" ), - _( "No Connection" ), - NULL + _( "No Connection" ) }; diff --git a/eeschema/erc.h b/eeschema/erc.h index 22eb00257d..5072ed7dbc 100644 --- a/eeschema/erc.h +++ b/eeschema/erc.h @@ -45,6 +45,8 @@ enum errortype UNC // Error: unconnected pin }; +extern const wxString CommentERC_H[]; +extern const wxString CommentERC_V[]; /// DRC error codes: #define ERCE_UNSPECIFIED 0 diff --git a/include/class_worksheet_dataitem.h b/include/class_worksheet_dataitem.h index 5be7fea9ad..fd10c7de84 100644 --- a/include/class_worksheet_dataitem.h +++ b/include/class_worksheet_dataitem.h @@ -267,6 +267,7 @@ public: } }; + class WORKSHEET_DATAITEM_POLYPOLYGON : public WORKSHEET_DATAITEM { public: @@ -355,26 +356,27 @@ public: bool IsInsidePage( int ii ) const; }; + class WORKSHEET_DATAITEM_TEXT : public WORKSHEET_DATAITEM { public: - wxString m_TextBase; // The basic text, with format symbols - wxString m_FullText; // The expanded text, shown on screen - double m_Orient; // Orientation in degrees - enum EDA_TEXT_HJUSTIFY_T m_Hjustify; - enum EDA_TEXT_VJUSTIFY_T m_Vjustify; - DSIZE m_TextSize; - DSIZE m_BoundingBoxSize; // When not null, this is the max - // size of the full text. - // the text size will be modified - // to keep the full text insite this - // bound. - DSIZE m_ConstrainedTextSize;// Actual text size, if constrained by - // the m_BoundingBoxSize constraint + wxString m_TextBase; // The basic text, with format symbols + wxString m_FullText; // The expanded text, shown on screen + double m_Orient; // Orientation in degrees + EDA_TEXT_HJUSTIFY_T m_Hjustify; + EDA_TEXT_VJUSTIFY_T m_Vjustify; + DSIZE m_TextSize; + DSIZE m_BoundingBoxSize; // When not null, this is the max + // size of the full text. + // the text size will be modified + // to keep the full text insite this + // bound. + DSIZE m_ConstrainedTextSize; // Actual text size, if constrained by + // the m_BoundingBoxSize constraint public: - WORKSHEET_DATAITEM_TEXT( const wxChar* aTextBase ); + WORKSHEET_DATAITEM_TEXT( const wxString& aTextBase ); /** * @return false (no end point) @@ -467,6 +469,7 @@ public: } }; + class BITMAP_BASE; class WORKSHEET_DATAITEM_BITMAP : public WORKSHEET_DATAITEM { diff --git a/include/colors.h b/include/colors.h index 4cca37efa9..a1bd0c8fdf 100644 --- a/include/colors.h +++ b/include/colors.h @@ -134,7 +134,7 @@ inline void ColorApplyHighlightFlag( EDA_COLOR_T *aColor ) } /// Find a color by name -EDA_COLOR_T ColorByName( const wxChar *aName ); +EDA_COLOR_T ColorByName( const wxString& aName ); /// Find the nearest color match EDA_COLOR_T ColorFindNearest( const wxColour &aColor ); diff --git a/include/kicad_string.h b/include/kicad_string.h index 314e803a8f..ab64b6c4aa 100644 --- a/include/kicad_string.h +++ b/include/kicad_string.h @@ -99,8 +99,8 @@ wxString DateAndTime(); * except that strings containing numbers are compared by their integer value not * by their ASCII code. * - * @param aString1 A wxChar pointer to the reference string. - * @param aString2 A wxChar pointer to the comparison string. + * @param aString1 A wxString reference to the reference string. + * @param aString2 A wxString reference to the comparison string. * @param aLength The number of characters to compare. Set to -1 to compare * the entire string. * @param aIgnoreCase Use true to make the comparison case insensitive. @@ -108,7 +108,7 @@ wxString DateAndTime(); * \a aString1 is equal to \a aString2, or 1 if \a aString1 is greater * than \a aString2. */ -int StrNumCmp( const wxChar* aString1, const wxChar* aString2, int aLength = INT_MAX, +int StrNumCmp( const wxString& aString1, const wxString& aString2, int aLength = INT_MAX, bool aIgnoreCase = false ); /** diff --git a/pcbnew/class_pcb_layer_widget.cpp b/pcbnew/class_pcb_layer_widget.cpp index 00dcd3fad4..6dc983babf 100644 --- a/pcbnew/class_pcb_layer_widget.cpp +++ b/pcbnew/class_pcb_layer_widget.cpp @@ -280,7 +280,7 @@ void PCB_LAYER_WIDGET::ReFill() { if( enabledLayers & GetLayerMask( layer ) ) { - const wxChar *dsc; + wxString dsc; switch( layer ) { case LAYER_N_FRONT: diff --git a/pcbnew/exporters/gen_modules_placefile.cpp b/pcbnew/exporters/gen_modules_placefile.cpp index c5d1fc7073..609b6adebf 100644 --- a/pcbnew/exporters/gen_modules_placefile.cpp +++ b/pcbnew/exporters/gen_modules_placefile.cpp @@ -55,8 +55,8 @@ class LIST_MOD // An helper class used to build a list of useful footprints { public: MODULE* m_Module; // Link to the actual footprint - const wxChar* m_Reference; // Its schematic reference - const wxChar* m_Value; // Its schematic value + wxString m_Reference; // Its schematic reference + wxString m_Value; // Its schematic value LAYER_NUM m_Layer; // its side (LAYER_N_BACK, or LAYER_N_FRONT) }; diff --git a/pcbnew/specctra.cpp b/pcbnew/specctra.cpp index 080c37269a..b1018a58a8 100644 --- a/pcbnew/specctra.cpp +++ b/pcbnew/specctra.cpp @@ -108,7 +108,7 @@ int SPECCTRA_DB::findLayerName( const std::string& aLayerName ) const } -void SPECCTRA_DB::ThrowIOError( const wxChar* fmt, ... ) throw( IO_ERROR ) +void SPECCTRA_DB::ThrowIOError( const wxString& fmt, ... ) throw( IO_ERROR ) { wxString errText; va_list args; diff --git a/pcbnew/specctra.h b/pcbnew/specctra.h index 2a53c33211..35572563fa 100644 --- a/pcbnew/specctra.h +++ b/pcbnew/specctra.h @@ -3910,7 +3910,7 @@ public: */ void LoadSESSION( const wxString& filename ) throw( IO_ERROR ); - void ThrowIOError( const wxChar* fmt, ... ) throw( IO_ERROR ); + void ThrowIOError( const wxString& fmt, ... ) throw( IO_ERROR ); /** * Function ExportPCB diff --git a/pcbnew/specctra_import.cpp b/pcbnew/specctra_import.cpp index da0310e811..9b541d1ed8 100644 --- a/pcbnew/specctra_import.cpp +++ b/pcbnew/specctra_import.cpp @@ -198,7 +198,7 @@ TRACK* SPECCTRA_DB::makeTRACK( PATH* aPath, int aPointIndex, int aNetcode ) thro { wxString layerName = FROM_UTF8( aPath->layer_id.c_str() ); ThrowIOError( _("Session file uses invalid layer id \"%s\""), - GetChars(layerName) ); + GetChars( layerName ) ); } TRACK* track = new TRACK( sessionBoard ); @@ -247,7 +247,7 @@ SEGVIA* SPECCTRA_DB::makeVIA( PADSTACK* aPadstack, const POINT& aPoint, int aNet if( shapeCount == 0 ) { - ThrowIOError( _( "Session via padstack has no shapes") ); + ThrowIOError( _( "Session via padstack has no shapes" ) ); } else if( shapeCount == 1 ) {