From 080dd34e61b8c70ef8689955f1658455b7c85514 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Fri, 2 Feb 2018 13:24:53 -0500 Subject: [PATCH] Get rid of wx object arrays, use std::vector --- src/AutoRecovery.cpp | 11 +-- src/AutoRecovery.h | 2 - src/Envelope.h | 1 - src/LabelTrack.h | 1 - src/Lyrics.cpp | 43 +++++----- src/Lyrics.h | 12 ++- src/MixerBoard.cpp | 1 - src/ModuleManager.cpp | 3 - src/PluginManager.cpp | 3 - src/PluginManager.h | 1 - src/Project.cpp | 2 - src/Sequence.cpp | 3 +- src/Sequence.h | 1 - src/Snap.cpp | 2 - src/Tags.h | 2 + src/Theme.cpp | 38 ++++----- src/Theme.h | 17 ++-- src/TimeDialog.cpp | 1 - src/Track.h | 1 - src/TrackPanel.h | 13 --- src/commands/CommandManager.h | 1 - src/effects/AutoDuck.cpp | 14 +--- src/effects/BassTreble.cpp | 9 +- src/effects/BassTreble.h | 4 +- src/effects/Distortion.cpp | 9 +- src/effects/Distortion.h | 4 +- src/effects/Effect.h | 1 - src/effects/Equalization.cpp | 137 +++++++++++++++--------------- src/effects/Equalization.h | 36 ++++---- src/effects/Equalization48x.cpp | 2 - src/effects/Phaser.cpp | 9 +- src/effects/Phaser.h | 4 +- src/effects/Wahwah.cpp | 9 +- src/effects/Wahwah.h | 4 +- src/effects/lv2/LV2Effect.cpp | 31 +++---- src/effects/lv2/LV2Effect.h | 8 +- src/effects/nyquist/Nyquist.cpp | 29 +++---- src/effects/nyquist/Nyquist.h | 10 ++- src/export/Export.cpp | 12 +-- src/export/Export.h | 14 ++-- src/export/ExportMultiple.cpp | 15 ++-- src/export/ExportMultiple.h | 5 +- src/import/Import.cpp | 1 - src/prefs/DevicePrefs.h | 1 - src/prefs/QualityPrefs.h | 1 - src/widgets/ExpandingToolBar.cpp | 19 ++--- src/widgets/ExpandingToolBar.h | 8 +- src/widgets/FileHistory.h | 1 - src/widgets/Grid.h | 1 - src/widgets/ImageRoll.cpp | 24 +++--- src/widgets/ImageRoll.h | 9 +- src/widgets/KeyView.cpp | 140 +++++++++++-------------------- src/widgets/KeyView.h | 17 ++-- src/widgets/NumericTextCtrl.cpp | 92 ++++++++++---------- src/widgets/NumericTextCtrl.h | 7 +- src/xml/XMLWriter.h | 1 - 56 files changed, 350 insertions(+), 497 deletions(-) diff --git a/src/AutoRecovery.cpp b/src/AutoRecovery.cpp index 3c6589340..964fb54fe 100644 --- a/src/AutoRecovery.cpp +++ b/src/AutoRecovery.cpp @@ -480,9 +480,6 @@ enum FieldTypes FT_Name // type, name length, name }; -#include -WX_DEFINE_OBJARRAY(IdMapArray); - AutoSaveFile::AutoSaveFile(size_t allocSize) { mAllocSize = allocSize; @@ -762,7 +759,7 @@ bool AutoSaveFile::Decode(const wxString & fileName) XMLFileWriter out{ fileName, _("Error Decoding File") }; IdMap mIds; - IdMapArray mIdStack; + std::vector mIdStack; mIds.clear(); @@ -774,15 +771,15 @@ bool AutoSaveFile::Decode(const wxString & fileName) { case FT_Push: { - mIdStack.Add(mIds); + mIdStack.push_back(mIds); mIds.clear(); } break; case FT_Pop: { - mIds = mIdStack[mIdStack.GetCount() - 1]; - mIdStack.RemoveAt(mIdStack.GetCount() - 1); + mIds = mIdStack.back(); + mIdStack.pop_back(); } break; diff --git a/src/AutoRecovery.h b/src/AutoRecovery.h index 87856ca04..1a6949d0d 100644 --- a/src/AutoRecovery.h +++ b/src/AutoRecovery.h @@ -17,7 +17,6 @@ #include "xml/XMLWriter.h" #include -#include #include #include #include @@ -74,7 +73,6 @@ private: using NameMap = std::unordered_map; using IdMap = std::unordered_map; -WX_DECLARE_OBJARRAY_WITH_DECL(IdMap, IdMapArray, class AUDACITY_DLL_API); // This class's overrides do NOT throw AudacityException. class AUDACITY_DLL_API AutoSaveFile final : public XMLWriter diff --git a/src/Envelope.h b/src/Envelope.h index 41aecbed4..0c0041f6d 100644 --- a/src/Envelope.h +++ b/src/Envelope.h @@ -15,7 +15,6 @@ #include #include -#include #include #include diff --git a/src/LabelTrack.h b/src/LabelTrack.h index cd981a481..8215fef96 100644 --- a/src/LabelTrack.h +++ b/src/LabelTrack.h @@ -20,7 +20,6 @@ #include #include #include -#include #include #include diff --git a/src/Lyrics.cpp b/src/Lyrics.cpp index 1513eff22..bc44395bd 100644 --- a/src/Lyrics.cpp +++ b/src/Lyrics.cpp @@ -20,9 +20,6 @@ #include "Project.h" // for GetActiveProject #include "LabelTrack.h" -#include -WX_DEFINE_OBJARRAY(SyllableArray); - BEGIN_EVENT_TABLE(HighlightTextCtrl, wxTextCtrl) EVT_MOUSE_EVENTS(HighlightTextCtrl::OnMouseEvent) @@ -120,13 +117,13 @@ LyricsPanel::~LyricsPanel() void LyricsPanel::Clear() { - mSyllables.Clear(); + mSyllables.clear(); mText = wxT(""); // Add two dummy syllables at the beginning - mSyllables.Add(Syllable()); + mSyllables.push_back(Syllable()); mSyllables[0].t = -2.0; - mSyllables.Add(Syllable()); + mSyllables.push_back(Syllable()); mSyllables[1].t = -1.0; mHighlightTextCtrl->Clear(); @@ -145,7 +142,7 @@ void LyricsPanel::AddLabels(const LabelTrack *pLT) void LyricsPanel::Add(double t, const wxString &syllable, wxString &highlightText) { - int i = mSyllables.GetCount(); + int i = mSyllables.size(); { Syllable &prevSyllable = mSyllables[i - 1]; @@ -161,7 +158,7 @@ void LyricsPanel::Add(double t, const wxString &syllable, wxString &highlightTex } } - mSyllables.Add(Syllable()); + mSyllables.push_back(Syllable()); Syllable &thisSyllable = mSyllables[i]; thisSyllable.t = t; thisSyllable.text = syllable; @@ -190,12 +187,12 @@ void LyricsPanel::Add(double t, const wxString &syllable, wxString &highlightTex void LyricsPanel::Finish(double finalT) { // Add 3 dummy syllables at the end - int i = mSyllables.GetCount(); - mSyllables.Add(Syllable()); + int i = mSyllables.size(); + mSyllables.push_back(Syllable()); mSyllables[i].t = finalT + 1.0; - mSyllables.Add(Syllable()); + mSyllables.push_back(Syllable()); mSyllables[i+1].t = finalT + 2.0; - mSyllables.Add(Syllable()); + mSyllables.push_back(Syllable()); mSyllables[i+2].t = finalT + 3.0; // Mark measurements as invalid @@ -210,7 +207,7 @@ int LyricsPanel::FindSyllable(long startChar) int i1, i2; i1 = 0; - i2 = mSyllables.GetCount(); + i2 = mSyllables.size(); while (i2 > i1+1) { int pmid = (i1+i2)/2; if (mSyllables[pmid].char0 > startChar) @@ -221,8 +218,8 @@ int LyricsPanel::FindSyllable(long startChar) if (i1 < 2) i1 = 2; - if (i1 > (int)(mSyllables.GetCount()) - 3) - i1 = mSyllables.GetCount() - 3; + if (i1 > (int)(mSyllables.size()) - 3) + i1 = mSyllables.size() - 3; return i1; } @@ -267,9 +264,9 @@ void LyricsPanel::Measure(wxDC *dc) // only for drawn text int x = 2*kIndent; unsigned int i; - for(i=0; i= mSyllables.GetCount()-3)) // Finish() ends with 3 dummies. + (i >= mSyllables.size() - 3)) // Finish() ends with 3 dummies. { dc->GetTextExtent(wxT("DUMMY"), &width, &height); // Get the correct height even if we're at i=0. width = 0; @@ -282,7 +279,7 @@ void LyricsPanel::Measure(wxDC *dc) // only for drawn text // when there's a long pause relative to the previous word, insert // extra space. int extraWidth; - if (i >= I_FIRST_REAL_SYLLABLE && i < mSyllables.GetCount()-2) + if (i >= I_FIRST_REAL_SYLLABLE && i < mSyllables.size() - 2) { double deltaThis = mSyllables[i+1].t - mSyllables[i].t; double deltaPrev = mSyllables[i].t - mSyllables[i-1].t; @@ -318,7 +315,7 @@ int LyricsPanel::FindSyllable(double t) int i1, i2; i1 = 0; - i2 = mSyllables.GetCount(); + i2 = mSyllables.size(); while (i2 > i1+1) { int pmid = (i1+i2)/2; if (mSyllables[pmid].t > t) @@ -329,8 +326,8 @@ int LyricsPanel::FindSyllable(double t) if (i1 < 2) i1 = 2; - if (i1 > (int)(mSyllables.GetCount()) - 3) - i1 = mSyllables.GetCount() - 3; + if (i1 > (int)(mSyllables.size()) - 3) + i1 = mSyllables.size() - 3; return i1; } @@ -348,7 +345,7 @@ void LyricsPanel::GetKaraokePosition(double t, *outX = 0; *outY = 0; - if (t < mSyllables[I_FIRST_REAL_SYLLABLE].t || t > mSyllables[mSyllables.GetCount()-3].t) + if (t < mSyllables[I_FIRST_REAL_SYLLABLE].t || t > mSyllables[mSyllables.size() - 3].t) return; int i0, i1, i2, i3; @@ -557,7 +554,7 @@ void LyricsPanel::HandlePaint_BouncingBall(wxDC &dc) SetDrawnFont(&dc); unsigned int i; wxCoord yTextTop = mKaraokeHeight - mTextHeight - 4; - for(i=0; i x + ctr) diff --git a/src/Lyrics.h b/src/Lyrics.h index f22653c97..2dd3c9009 100644 --- a/src/Lyrics.h +++ b/src/Lyrics.h @@ -14,7 +14,7 @@ #include "Audacity.h" -#include +#include #include #include "widgets/wxPanelWrapper.h" @@ -25,6 +25,12 @@ class LabelTrack; #define LYRICS_DEFAULT_HEIGHT 280 struct Syllable { + Syllable() = default; + Syllable( const Syllable& ) = default; + Syllable& operator= ( const Syllable& ) = default; + Syllable( Syllable && ) = default; + Syllable& operator= ( Syllable&& ) = default; + double t; wxString text; wxString textWithSpace; @@ -35,8 +41,6 @@ struct Syllable { int x; // centerX, used only for kBouncingBallLyrics }; -WX_DECLARE_OBJARRAY(Syllable, SyllableArray); - class LyricsPanel; // Override wxTextCtrl to handle selection events, which the parent ignores if the control is read-only. @@ -136,7 +140,7 @@ private: double mT; int mCurrentSyllable; - SyllableArray mSyllables; + std::vector mSyllables; wxString mText; int mTextHeight; // only for drawn text diff --git a/src/MixerBoard.cpp b/src/MixerBoard.cpp index fd8c6b3ac..3797b063c 100644 --- a/src/MixerBoard.cpp +++ b/src/MixerBoard.cpp @@ -15,7 +15,6 @@ #include #include -#include #include #include // for wxSystemSettings::GetColour and wxSystemSettings::GetMetric diff --git a/src/ModuleManager.cpp b/src/ModuleManager.cpp index 063410e38..56cde196c 100755 --- a/src/ModuleManager.cpp +++ b/src/ModuleManager.cpp @@ -18,7 +18,6 @@ i.e. an alternative to the usual interface, for Audacity. *//*******************************************************************/ -#include #include #include #include @@ -44,8 +43,6 @@ i.e. an alternative to the usual interface, for Audacity. #include "ModuleManager.h" #include "widgets/MultiDialog.h" -#include - #include "Experimental.h" #include "widgets/ErrorDialog.h" diff --git a/src/PluginManager.cpp b/src/PluginManager.cpp index ab3a2bf0f..f4f9c7a1c 100644 --- a/src/PluginManager.cpp +++ b/src/PluginManager.cpp @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -46,8 +45,6 @@ #include "PluginManager.h" -#include - #include "Experimental.h" #ifndef __AUDACITY_OLD_STD__ diff --git a/src/PluginManager.h b/src/PluginManager.h index b6843ebb8..11a813ddf 100644 --- a/src/PluginManager.h +++ b/src/PluginManager.h @@ -12,7 +12,6 @@ #define __AUDACITY_PLUGINMANAGER_H__ #include -#include #include #include diff --git a/src/Project.cpp b/src/Project.cpp index cf071cd3e..828f72803 100644 --- a/src/Project.cpp +++ b/src/Project.cpp @@ -81,8 +81,6 @@ scroll information. It also has some status flags. #include #include -#include // this allows for creation of wxObjArray - #if defined(__WXMAC__) #if !wxCHECK_VERSION(3, 0, 0) #include diff --git a/src/Sequence.cpp b/src/Sequence.cpp index 0326dd922..66c18537b 100644 --- a/src/Sequence.cpp +++ b/src/Sequence.cpp @@ -35,7 +35,6 @@ #include #include -#include #include #include #include @@ -1799,7 +1798,7 @@ void Sequence::Delete(sampleCount start, sampleCount len) Read(scratch.ptr() + prepreLen*sampleSize, mSampleFormat, preBlock, 0, preBufferLen, true); - newBlock.erase(newBlock.end() - 1); + newBlock.pop_back(); Blockify(*mDirManager, mMaxSamples, mSampleFormat, newBlock, prepreBlock.start, scratch.ptr(), sum); } diff --git a/src/Sequence.h b/src/Sequence.h index d2ccb7b8a..4e893ba9e 100644 --- a/src/Sequence.h +++ b/src/Sequence.h @@ -14,7 +14,6 @@ #include "MemoryX.h" #include #include -#include #include "SampleFormat.h" #include "xml/XMLTagHandler.h" diff --git a/src/Snap.cpp b/src/Snap.cpp index bca07038b..68d39bee1 100644 --- a/src/Snap.cpp +++ b/src/Snap.cpp @@ -18,8 +18,6 @@ #include "LabelTrack.h" #include "WaveTrack.h" -#include - inline bool operator < (SnapPoint s1, SnapPoint s2) { return s1.t < s2.t; diff --git a/src/Tags.h b/src/Tags.h index 538bd11ec..ff31f5413 100644 --- a/src/Tags.h +++ b/src/Tags.h @@ -73,6 +73,8 @@ class AUDACITY_DLL_API Tags final : public XMLTagHandler { public: Tags(); // constructor + Tags( const Tags& ) = default; + Tags( Tags && ) = default; virtual ~Tags(); std::shared_ptr Duplicate() const; diff --git a/src/Theme.cpp b/src/Theme.cpp index 27798ceab..6dc219c94 100644 --- a/src/Theme.cpp +++ b/src/Theme.cpp @@ -82,12 +82,6 @@ can't be. #include "ImageManipulation.h" #include "widgets/ErrorDialog.h" -#include - -WX_DEFINE_USER_EXPORTED_OBJARRAY( ArrayOfImages ) -WX_DEFINE_USER_EXPORTED_OBJARRAY( ArrayOfBitmaps ) -WX_DEFINE_USER_EXPORTED_OBJARRAY( ArrayOfColours ) - // JKC: First get the MAC specific images. // As we've disabled USE_AQUA_THEME, we need to name each file we use. // @@ -477,7 +471,7 @@ void ThemeBase::RegisterImage( int &iIndex, char const ** pXpm, const wxString & void ThemeBase::RegisterImage( int &iIndex, const wxImage &Image, const wxString & Name ) { wxASSERT( iIndex == -1 ); // Don't initialise same bitmap twice! - mImages.Add( Image ); + mImages.push_back( Image ); #ifdef __APPLE__ // On Mac, bitmaps with alpha don't work. @@ -487,23 +481,23 @@ void ThemeBase::RegisterImage( int &iIndex, const wxImage &Image, const wxString // the blending ourselves anyway.] wxImage TempImage( Image ); TempImage.ConvertAlphaToMask(); - mBitmaps.Add( wxBitmap( TempImage ) ); + mBitmaps.push_back( wxBitmap( TempImage ) ); #else - mBitmaps.Add( wxBitmap( Image ) ); + mBitmaps.push_back( wxBitmap( Image ) ); #endif mBitmapNames.Add( Name ); mBitmapFlags.Add( mFlow.mFlags ); mFlow.mFlags &= ~resFlagSkip; - iIndex = mBitmaps.GetCount()-1; + iIndex = mBitmaps.size() - 1; } void ThemeBase::RegisterColour( int &iIndex, const wxColour &Clr, const wxString & Name ) { wxASSERT( iIndex == -1 ); // Don't initialise same colour twice! - mColours.Add( Clr ); + mColours.push_back( Clr ); mColourNames.Add( Name ); - iIndex = mColours.GetCount()-1; + iIndex = mColours.size() - 1; } void FlowPacker::Init(int width) @@ -689,7 +683,7 @@ void ThemeBase::CreateImageCache( bool bBinarySave ) #endif // Save the bitmaps - for(i=0;i<(int)mImages.GetCount();i++) + for(i = 0;i < (int)mImages.size();i++) { wxImage &SrcImage = mImages[i]; mFlow.mFlags = mBitmapFlags[i]; @@ -718,7 +712,7 @@ void ThemeBase::CreateImageCache( bool bBinarySave ) mFlow.SetColourGroup(); const int iColSize = 10; - for(i=0;i<(int)mColours.GetCount();i++) + for(i = 0; i < (int)mColours.size(); i++) { mFlow.GetNextPosition( iColSize, iColSize ); wxColour c = mColours[i]; @@ -839,7 +833,7 @@ void ThemeBase::WriteImageMap( ) File.Write( Temp ); File.Write( wxT("\r\n") ); - for(i=0;i<(int)mImages.GetCount();i++) + for(i = 0; i < (int)mImages.size(); i++) { wxImage &SrcImage = mImages[i]; mFlow.mFlags = mBitmapFlags[i]; @@ -857,7 +851,7 @@ void ThemeBase::WriteImageMap( ) // Now save the colours. mFlow.SetColourGroup(); const int iColSize = 10; - for(i=0;i<(int)mColours.GetCount();i++) + for(i = 0; i < (int)mColours.size(); i++) { mFlow.GetNextPosition( iColSize, iColSize ); // No href in html. Uses title not alt. @@ -883,7 +877,7 @@ void ThemeBase::WriteImageDefs( ) if( !File.IsOpened() ) return; teResourceFlags PrevFlags = (teResourceFlags)-1; - for(i=0;i<(int)mImages.GetCount();i++) + for(i = 0; i < (int)mImages.size(); i++) { wxImage &SrcImage = mImages[i]; // No href in html. Uses title not alt. @@ -1029,7 +1023,7 @@ bool ThemeBase::ReadImageCache( teThemeType type, bool bOkIfNotFound) mFlow.Init(ImageCacheWidth); mFlow.mBorderWidth = 1; // Load the bitmaps - for(i=0;i<(int)mImages.GetCount();i++) + for(i = 0; i < (int)mImages.size(); i++) { wxImage &Image = mImages[i]; mFlow.mFlags = mBitmapFlags[i]; @@ -1048,7 +1042,7 @@ bool ThemeBase::ReadImageCache( teThemeType type, bool bOkIfNotFound) mFlow.SetColourGroup(); wxColour TempColour; const int iColSize=10; - for(i=0;i<(int)mColours.GetCount();i++) + for(i = 0; i < (int)mColours.size(); i++) { mFlow.GetNextPosition( iColSize, iColSize ); mFlow.RectMid( x, y ); @@ -1081,7 +1075,7 @@ void ThemeBase::LoadComponents( bool bOkIfNotFound ) int i; int n=0; wxString FileName; - for(i=0;i<(int)mImages.GetCount();i++) + for(i = 0; i < (int)mImages.size(); i++) { if( (mBitmapFlags[i] & resFlagInternal)==0) @@ -1150,7 +1144,7 @@ void ThemeBase::SaveComponents() int i; int n=0; wxString FileName; - for(i=0;i<(int)mImages.GetCount();i++) + for(i = 0; i < (int)mImages.size(); i++) { if( (mBitmapFlags[i] & resFlagInternal)==0) { @@ -1176,7 +1170,7 @@ void ThemeBase::SaveComponents() return; } - for(i=0;i<(int)mImages.GetCount();i++) + for(i = 0; i < (int)mImages.size(); i++) { if( (mBitmapFlags[i] & resFlagInternal)==0) { diff --git a/src/Theme.h b/src/Theme.h index 47939fae2..052549f6c 100644 --- a/src/Theme.h +++ b/src/Theme.h @@ -16,11 +16,11 @@ #include "Audacity.h" +#include #include #include #include #include -#include #include #include @@ -57,14 +57,6 @@ enum teThemeType -WX_DECLARE_USER_EXPORTED_OBJARRAY(wxImage, ArrayOfImages, AUDACITY_DLL_API); -WX_DECLARE_USER_EXPORTED_OBJARRAY(wxBitmap, ArrayOfBitmaps, AUDACITY_DLL_API); -WX_DECLARE_USER_EXPORTED_OBJARRAY(wxColour, ArrayOfColours, AUDACITY_DLL_API); - -//WX_DECLARE_OBJARRAY(wxImage, ArrayOfImages); -//WX_DECLARE_OBJARRAY(wxBitmap, ArrayOfBitmaps); -//WX_DECLARE_OBJARRAY(wxColour, ArrayOfColours); - class AUDACITY_DLL_API FlowPacker { public: @@ -150,12 +142,13 @@ public: wxImage MakeImageWithAlpha( wxBitmap & Bmp ); protected: - ArrayOfImages mImages; - ArrayOfBitmaps mBitmaps; + // wxImage, wxBitmap copy cheaply using reference counting + std::vector mImages; + std::vector mBitmaps; wxArrayString mBitmapNames; wxArrayInt mBitmapFlags; - ArrayOfColours mColours; + std::vector mColours; wxArrayString mColourNames; FlowPacker mFlow; }; diff --git a/src/TimeDialog.cpp b/src/TimeDialog.cpp index bb4c35310..a2c182426 100644 --- a/src/TimeDialog.cpp +++ b/src/TimeDialog.cpp @@ -16,7 +16,6 @@ #include "Audacity.h" #include -#include #include #include #include diff --git a/src/Track.h b/src/Track.h index d04257ebc..e61c17ac7 100644 --- a/src/Track.h +++ b/src/Track.h @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include diff --git a/src/TrackPanel.h b/src/TrackPanel.h index b182fd49c..28cddcd2b 100644 --- a/src/TrackPanel.h +++ b/src/TrackPanel.h @@ -65,19 +65,6 @@ struct TrackPanelDrawingContext; enum class UndoPush : unsigned char; -// JKC Nov 2011: Disabled warning C4251 which is to do with DLL linkage -// and only a worry when there are DLLs using the structures. -// Array classes are private in TrackInfo, so we will not -// access them directly from the DLL. -// TrackClipArray in TrackPanel needs to be handled with care in the derived -// class, but the C4251 warning is no worry in core Audacity. -// wxWidgets doesn't cater to the exact details we need in -// WX_DECLARE_EXPORTED_OBJARRAY to be able to use that for these two arrays. -#ifdef _MSC_VER -#pragma warning( push ) -#pragma warning( disable: 4251 ) -#endif - wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API, EVT_TRACK_PANEL_TIMER, wxCommandEvent); diff --git a/src/commands/CommandManager.h b/src/commands/CommandManager.h index 539e03fd5..a9f197e76 100644 --- a/src/commands/CommandManager.h +++ b/src/commands/CommandManager.h @@ -20,7 +20,6 @@ #include "../MemoryX.h" #include #include -#include #include #include diff --git a/src/effects/AutoDuck.cpp b/src/effects/AutoDuck.cpp index 6c899349d..1860542a9 100644 --- a/src/effects/AutoDuck.cpp +++ b/src/effects/AutoDuck.cpp @@ -24,7 +24,6 @@ #include #include -#include #include #include "../AColor.h" @@ -72,11 +71,6 @@ struct AutoDuckRegion double t1; }; -#include - -WX_DECLARE_OBJARRAY(AutoDuckRegion, AutoDuckRegionArray); -WX_DEFINE_OBJARRAY(AutoDuckRegionArray); - /* * Effect implementation */ @@ -296,7 +290,7 @@ bool EffectAutoDuck::Process() float rmsSum = 0; // to make the progress bar appear more natural, we first look for all // duck regions and apply them all at once afterwards - AutoDuckRegionArray regions; + std::vector regions; bool inDuckRegion = false; { Floats rmsWindow{ kRMSWindowSize, true }; @@ -354,7 +348,7 @@ bool EffectAutoDuck::Process() double duckRegionEnd = mControlTrack->LongSamplesToTime(i - curSamplesPause); - regions.Add(AutoDuckRegion( + regions.push_back(AutoDuckRegion( duckRegionStart - mOuterFadeDownLen, duckRegionEnd + mOuterFadeUpLen)); @@ -381,7 +375,7 @@ bool EffectAutoDuck::Process() { double duckRegionEnd = mControlTrack->LongSamplesToTime(end - curSamplesPause); - regions.Add(AutoDuckRegion( + regions.push_back(AutoDuckRegion( duckRegionStart - mOuterFadeDownLen, duckRegionEnd + mOuterFadeUpLen)); } @@ -399,7 +393,7 @@ bool EffectAutoDuck::Process() { WaveTrack* t = (WaveTrack*)iterTrack; - for (size_t i = 0; i < regions.GetCount(); i++) + for (size_t i = 0; i < regions.size(); i++) { const AutoDuckRegion& region = regions[i]; if (ApplyDuckFade(trackNumber, t, region.t0, region.t1)) diff --git a/src/effects/BassTreble.cpp b/src/effects/BassTreble.cpp index 06392732f..c990d7918 100644 --- a/src/effects/BassTreble.cpp +++ b/src/effects/BassTreble.cpp @@ -46,9 +46,6 @@ Param( Treble, double, wxT("Treble"), 0.0, -30.0, 30.0, 1 ) Param( Gain, double, wxT("Gain"), 0.0, -30.0, 30.0, 1 ); Param( Link, bool, wxT("Link Sliders"), false, false, true, 1 ); -#include -WX_DEFINE_OBJARRAY(EffectBassTrebleStateArray); - // Used to communicate the type of the filter. enum kShelfType { @@ -142,7 +139,7 @@ bool EffectBassTreble::RealtimeInitialize() { SetBlockSize(512); - mSlaves.Clear(); + mSlaves.clear(); return true; } @@ -153,14 +150,14 @@ bool EffectBassTreble::RealtimeAddProcessor(unsigned WXUNUSED(numChannels), floa InstanceInit(slave, sampleRate); - mSlaves.Add(slave); + mSlaves.push_back(slave); return true; } bool EffectBassTreble::RealtimeFinalize() { - mSlaves.Clear(); + mSlaves.clear(); return true; } diff --git a/src/effects/BassTreble.h b/src/effects/BassTreble.h index 0aed2d56c..cf2d743a4 100644 --- a/src/effects/BassTreble.h +++ b/src/effects/BassTreble.h @@ -39,8 +39,6 @@ public: double xn1Treble, xn2Treble, yn1Treble, yn2Treble; }; -WX_DECLARE_OBJARRAY(EffectBassTrebleState, EffectBassTrebleStateArray); - class EffectBassTreble final : public Effect { public: @@ -106,7 +104,7 @@ private: private: EffectBassTrebleState mMaster; - EffectBassTrebleStateArray mSlaves; + std::vector mSlaves; double mBass; double mTreble; diff --git a/src/effects/Distortion.cpp b/src/effects/Distortion.cpp index f1ed3b615..c6252923e 100644 --- a/src/effects/Distortion.cpp +++ b/src/effects/Distortion.cpp @@ -147,9 +147,6 @@ wxString defaultLabel(int index) return theArray.Get()[ index ]; } -#include -WX_DEFINE_OBJARRAY(EffectDistortionStateArray); - // // EffectDistortion // @@ -251,7 +248,7 @@ bool EffectDistortion::RealtimeInitialize() { SetBlockSize(512); - mSlaves.Clear(); + mSlaves.clear(); return true; } @@ -262,14 +259,14 @@ bool EffectDistortion::RealtimeAddProcessor(unsigned WXUNUSED(numChannels), floa InstanceInit(slave, sampleRate); - mSlaves.Add(slave); + mSlaves.push_back(slave); return true; } bool EffectDistortion::RealtimeFinalize() { - mSlaves.Clear(); + mSlaves.clear(); return true; } diff --git a/src/effects/Distortion.h b/src/effects/Distortion.h index 29fda2745..f22004bf2 100644 --- a/src/effects/Distortion.h +++ b/src/effects/Distortion.h @@ -45,8 +45,6 @@ public: double queuetotal; }; -WX_DECLARE_OBJARRAY(EffectDistortionState, EffectDistortionStateArray); - class EffectDistortion final : public Effect { public: @@ -171,7 +169,7 @@ private: private: EffectDistortionState mMaster; - EffectDistortionStateArray mSlaves; + std::vector mSlaves; double mTable[TABLESIZE]; double mThreshold; diff --git a/src/effects/Effect.h b/src/effects/Effect.h index ef52f29d3..991be2985 100644 --- a/src/effects/Effect.h +++ b/src/effects/Effect.h @@ -19,7 +19,6 @@ #include "../MemoryX.h" #include #include -#include #include #include #include diff --git a/src/effects/Equalization.cpp b/src/effects/Equalization.cpp index af78f1966..46b68d051 100644 --- a/src/effects/Equalization.cpp +++ b/src/effects/Equalization.cpp @@ -171,10 +171,6 @@ Param( DrawGrid, bool, wxT(""), true, false, true, Param( dBMin, float, wxT(""), -30.0, -120.0, -10.0, 0 ); Param( dBMax, float, wxT(""), 30.0, 0.0, 60.0, 0 ); -#include -WX_DEFINE_OBJARRAY( EQPointArray ); -WX_DEFINE_OBJARRAY( EQCurveArray ); - ///---------------------------------------------------------------------------- // EffectEqualization //---------------------------------------------------------------------------- @@ -398,7 +394,7 @@ bool EffectEqualization::ValidateUI() j--; } } - Select((int) mCurves.GetCount() - 1); + Select((int) mCurves.size() - 1); } SaveCurves(); @@ -842,7 +838,7 @@ void EffectEqualization::PopulateOrExchange(ShuttleGui & S) S.StartHorizontalLay(wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL, 1); { wxArrayString curves; - for (size_t i = 0, cnt = mCurves.GetCount(); i < cnt; i++) + for (size_t i = 0, cnt = mCurves.size(); i < cnt; i++) { curves.Add(mCurves[ i ].Name); } @@ -1372,18 +1368,18 @@ void EffectEqualization::LoadCurves(const wxString &fileName, bool append) // If requested file doesn't exist... if( !fn.FileExists() && !GetDefaultFileName(fn) ) { - mCurves.Clear(); - mCurves.Add( _("unnamed") ); // we still need a default curve to use + mCurves.clear(); + mCurves.push_back( _("unnamed") ); // we still need a default curve to use return; } EQCurve tempCustom(wxT("temp")); if( append == false ) // Start from scratch - mCurves.Clear(); + mCurves.clear(); else // appending so copy and remove 'unnamed', to replace later { - tempCustom.points = mCurves.Last().points; - mCurves.RemoveAt(mCurves.Count()-1); + tempCustom.points = mCurves.back().points; + mCurves.pop_back(); } // Load the curves @@ -1398,12 +1394,12 @@ void EffectEqualization::LoadCurves(const wxString &fileName, bool append) Effect::MessageBox( msg, wxOK | wxCENTRE, _("Error Loading EQ Curves")); - mCurves.Add( _("unnamed") ); // we always need a default curve to use + mCurves.push_back( _("unnamed") ); // we always need a default curve to use return; } // Move "unnamed" to end, if it exists in current language. - int numCurves = mCurves.GetCount(); + int numCurves = mCurves.size(); int curve; EQCurve tempUnnamed(wxT("tempUnnamed")); for( curve = 0; curve < numCurves-1; curve++ ) @@ -1411,17 +1407,17 @@ void EffectEqualization::LoadCurves(const wxString &fileName, bool append) if( mCurves[curve].Name == _("unnamed") ) { tempUnnamed.points = mCurves[curve].points; - mCurves.RemoveAt(curve); - mCurves.Add( _("unnamed") ); // add 'unnamed' back at the end - mCurves.Last().points = tempUnnamed.points; + mCurves.erase(mCurves.begin() + curve); + mCurves.push_back( _("unnamed") ); // add 'unnamed' back at the end + mCurves.back().points = tempUnnamed.points; } } - if( mCurves.Last().Name != _("unnamed") ) - mCurves.Add( _("unnamed") ); // we always need a default curve to use + if( mCurves.back().Name != _("unnamed") ) + mCurves.push_back( _("unnamed") ); // we always need a default curve to use if( append == true ) { - mCurves.Last().points = tempCustom.points; + mCurves.back().points = tempCustom.points; } return; @@ -1432,7 +1428,7 @@ void EffectEqualization::LoadCurves(const wxString &fileName, bool append) // void EffectEqualization::UpdateDefaultCurves(bool updateAll /* false */) { - if (mCurves.GetCount() == 0) + if (mCurves.size() == 0) return; /* i18n-hint: name of the 'unnamed' custom curve */ @@ -1440,11 +1436,11 @@ void EffectEqualization::UpdateDefaultCurves(bool updateAll /* false */) // Save the "unnamed" curve and remove it so we can add it back as the final curve. EQCurve userUnnamed(wxT("temp")); - userUnnamed = mCurves.Last(); - mCurves.RemoveAt(mCurves.Count()-1); + userUnnamed = mCurves.back(); + mCurves.pop_back(); EQCurveArray userCurves = mCurves; - mCurves.Clear(); + mCurves.clear(); // We only wamt to look for the shipped EQDefaultCurves.xml wxFileName fn = wxFileName(FileNames::ResourcesDir(), wxT("EQDefaultCurves.xml")); wxLogDebug(wxT("Attempting to load EQDefaultCurves.xml from %s"),fn.GetFullPath()); @@ -1459,25 +1455,25 @@ void EffectEqualization::UpdateDefaultCurves(bool updateAll /* false */) } EQCurveArray defaultCurves = mCurves; - mCurves.Clear(); // clear now so that we can sort then add back. + mCurves.clear(); // clear now so that we can sort then add back. // Remove "unnamed" if it exists. - if (defaultCurves.Last().Name == unnamed) { - defaultCurves.RemoveAt(defaultCurves.Count()-1); + if (defaultCurves.back().Name == unnamed) { + defaultCurves.pop_back(); } else { wxLogError(wxT("Error in EQDefaultCurves.xml")); } - int numUserCurves = userCurves.GetCount(); - int numDefaultCurves = defaultCurves.GetCount(); + int numUserCurves = userCurves.size(); + int numDefaultCurves = defaultCurves.size(); EQCurve tempCurve(wxT("test")); if (updateAll) { // Update all factory preset curves. // Sort and add factory defaults first; mCurves = defaultCurves; - mCurves.Sort(SortCurvesByName); + std::sort(mCurves.begin(), mCurves.end()); // then add remaining user curves: for (int curveCount = 0; curveCount < numUserCurves; curveCount++) { bool isCustom = true; @@ -1491,7 +1487,7 @@ void EffectEqualization::UpdateDefaultCurves(bool updateAll /* false */) } // if tempCurve is not in the default set, add it to mCurves. if (isCustom) { - mCurves.Add(tempCurve); + mCurves.push_back(tempCurve); } } } @@ -1503,15 +1499,15 @@ void EffectEqualization::UpdateDefaultCurves(bool updateAll /* false */) for (int userCurveCount = 0; userCurveCount < numUserCurves; userCurveCount++) { if (userCurves[userCurveCount].Name == defaultCurves[defCurveCount].Name) { isUserCurve = true; - mCurves.Add(userCurves[userCurveCount]); + mCurves.push_back(userCurves[userCurveCount]); break; } } if (!isUserCurve) { - mCurves.Add(defaultCurves[defCurveCount]); + mCurves.push_back(defaultCurves[defCurveCount]); } } - mCurves.Sort(SortCurvesByName); + std::sort(mCurves.begin(), mCurves.end()); // now add the rest of the user's curves. for (int userCurveCount = 0; userCurveCount < numUserCurves; userCurveCount++) { bool isDefaultCurve = false; @@ -1523,16 +1519,16 @@ void EffectEqualization::UpdateDefaultCurves(bool updateAll /* false */) } } if (!isDefaultCurve) { - mCurves.Add(tempCurve); + mCurves.push_back(tempCurve); } } } - defaultCurves.Clear(); - userCurves.Clear(); + defaultCurves.clear(); + userCurves.clear(); // Add back old "unnamed" if(userUnnamed.Name == unnamed) { - mCurves.Add( userUnnamed ); // we always need a default curve to use + mCurves.push_back( userUnnamed ); // we always need a default curve to use } SaveCurves(); @@ -1621,11 +1617,11 @@ void EffectEqualization::SaveCurves(const wxString &fileName) void EffectEqualization::setCurve(int currentCurve) { // Set current choice - wxASSERT( currentCurve < (int) mCurves.GetCount() ); + wxASSERT( currentCurve < (int) mCurves.size() ); Select(currentCurve); Envelope *env; - int numPoints = (int) mCurves[currentCurve].points.GetCount(); + int numPoints = (int) mCurves[currentCurve].points.size(); if (mLin) { // linear freq mode env = mLinEnvelope.get(); @@ -1665,7 +1661,8 @@ void EffectEqualization::setCurve(int currentCurve) } // We have at least two points, so ensure they are in frequency order. - mCurves[currentCurve].points.Sort(SortCurvePoints); + std::sort(mCurves[currentCurve].points.begin(), + mCurves[currentCurve].points.end()); if (mCurves[currentCurve].points[0].Freq < 0) { // Corrupt or invalid curve, so bail. @@ -1780,21 +1777,21 @@ void EffectEqualization::setCurve(int currentCurve) void EffectEqualization::setCurve() { - setCurve((int) mCurves.GetCount()-1); + setCurve((int) mCurves.size() - 1); } void EffectEqualization::setCurve(const wxString &curveName) { unsigned i = 0; - for( i = 0; i < mCurves.GetCount(); i++ ) + for( i = 0; i < mCurves.size(); i++ ) if( curveName == mCurves[ i ].Name ) break; - if( i == mCurves.GetCount()) + if( i == mCurves.size()) { Effect::MessageBox( _("Requested curve not found, using 'unnamed'"), wxOK|wxICON_ERROR, _("Curve not found") ); - setCurve((int) mCurves.GetCount()-1); + setCurve((int) mCurves.size() - 1); } else setCurve( i ); @@ -1848,8 +1845,8 @@ void EffectEqualization::EnvelopeUpdated(Envelope *env, bool lin) env->GetPoints( when.get(), value.get(), numPoints ); // Clear the unnamed curve - int curve = mCurves.GetCount()-1; - mCurves[ curve ].points.Clear(); + int curve = mCurves.size() - 1; + mCurves[ curve ].points.clear(); if(lin) { @@ -1860,7 +1857,7 @@ void EffectEqualization::EnvelopeUpdated(Envelope *env, bool lin) double db = value[ point ]; // Add it to the curve - mCurves[ curve ].points.Add( EQPoint( freq, db ) ); + mCurves[ curve ].points.push_back( EQPoint( freq, db ) ); } } else @@ -1876,14 +1873,14 @@ void EffectEqualization::EnvelopeUpdated(Envelope *env, bool lin) double db = value[ point ]; // Add it to the curve - mCurves[ curve ].points.Add( EQPoint( freq, db ) ); + mCurves[ curve ].points.push_back( EQPoint( freq, db ) ); } } // Remember that we've updated the unnamed curve mDirty = true; // set 'unnamed' as the selected curve - Select( (int) mCurves.GetCount()-1 ); + Select( (int) mCurves.size() - 1 ); } // @@ -1957,7 +1954,7 @@ bool EffectEqualization::HandleXMLTag(const wxChar *tag, const wxChar **attrs) do { exists = false; - for(size_t i=0;i0) strValueTemp.Printf(wxT("%s (%d)"),strValue,n); @@ -1971,7 +1968,7 @@ bool EffectEqualization::HandleXMLTag(const wxChar *tag, const wxChar **attrs) } while(exists == true); - mCurves.Add( EQCurve( strValueTemp ) ); + mCurves.push_back( EQCurve( strValueTemp ) ); } } @@ -2014,7 +2011,7 @@ bool EffectEqualization::HandleXMLTag(const wxChar *tag, const wxChar **attrs) } // Create a NEW point - mCurves[ mCurves.GetCount() - 1 ].points.Add( EQPoint( f, d ) ); + mCurves[ mCurves.size() - 1 ].points.push_back( EQPoint( f, d ) ); // Tell caller it was processed return true; @@ -2057,7 +2054,7 @@ void EffectEqualization::WriteXML(XMLWriter &xmlFile) const xmlFile.StartTag( wxT( "equalizationeffect" ) ); // Write all curves - int numCurves = mCurves.GetCount(); + int numCurves = mCurves.size(); int curve; for( curve = 0; curve < numCurves; curve++ ) { @@ -2066,7 +2063,7 @@ void EffectEqualization::WriteXML(XMLWriter &xmlFile) const xmlFile.WriteAttr( wxT( "name" ), mCurves[ curve ].Name ); // Write all points - int numPoints = mCurves[ curve ].points.GetCount(); + int numPoints = mCurves[ curve ].points.size(); int point; for( point = 0; point < numPoints; point++ ) { @@ -2121,7 +2118,7 @@ void EffectEqualization::UpdateCurves() { // Reload the curve names mCurve->Clear(); - for (size_t i = 0, cnt = mCurves.GetCount(); i < cnt; i++) + for (size_t i = 0, cnt = mCurves.size(); i < cnt; i++) { mCurve->Append(mCurves[ i ].Name); } @@ -2396,7 +2393,7 @@ void EffectEqualization::ErrMin(void) } if( error > .0025 * mBandsInUse ) // not within 0.05dB on each slider, on average { - Select( (int) mCurves.GetCount()-1 ); + Select( (int) mCurves.size() - 1 ); EnvelopeUpdated(&testEnvelope, false); } } @@ -3132,10 +3129,10 @@ wxDialogWrapper(parent, wxID_ANY, _("Manage Curves List"), mEffect = effect; mPosition = position; // make a copy of mEffect->mCurves here to muck about with. - mEditCurves.Clear(); - for (unsigned int i = 0; i < mEffect->mCurves.GetCount(); i++) + mEditCurves.clear(); + for (unsigned int i = 0; i < mEffect->mCurves.size(); i++) { - mEditCurves.Add(mEffect->mCurves[i].Name); + mEditCurves.push_back(mEffect->mCurves[i].Name); mEditCurves[i].points = mEffect->mCurves[i].points; } @@ -3195,7 +3192,7 @@ void EditCurvesDialog::PopulateOrExchange(ShuttleGui & S) void EditCurvesDialog::PopulateList(int position) { mList->DeleteAllItems(); - for (unsigned int i = 0; i < mEditCurves.GetCount(); i++) + for (unsigned int i = 0; i < mEditCurves.size(); i++) mList->InsertItem(i, mEditCurves[i].Name); mList->SetColumnWidth(0, wxLIST_AUTOSIZE); int curvesWidth = mList->GetColumnWidth(0); @@ -3292,7 +3289,7 @@ long EditCurvesDialog::GetPreviousItem(long item) // wx doesn't have this void EditCurvesDialog::OnRename(wxCommandEvent & WXUNUSED(event)) { wxString name; - int numCurves = mEditCurves.GetCount(); + int numCurves = mEditCurves.size(); int curve = 0; // Setup list of characters that aren't allowed @@ -3372,13 +3369,13 @@ void EditCurvesDialog::OnRename(wxCommandEvent & WXUNUSED(event)) mList->SetItem(curve, 0, name); else { - mEditCurves.RemoveAt( item ); + mEditCurves.erase( mEditCurves.begin() + item ); numCurves--; } } else if( item == (numCurves-1) ) // renaming 'unnamed' { // Create a NEW entry - mEditCurves.Add( EQCurve( wxT("unnamed") ) ); + mEditCurves.push_back( EQCurve( wxT("unnamed") ) ); // Copy over the points mEditCurves[ numCurves ].points = mEditCurves[ numCurves - 1 ].points; // Give the original unnamed entry the NEW name @@ -3470,12 +3467,12 @@ void EditCurvesDialog::OnDelete(wxCommandEvent & WXUNUSED(event)) } else { - mEditCurves.RemoveAt( item-deleted ); + mEditCurves.erase( mEditCurves.begin() + item - deleted ); deleted++; } item = mList->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); } - PopulateList(mEditCurves.GetCount()-1); // set 'unnamed' as the selected curve + PopulateList(mEditCurves.size() - 1); // set 'unnamed' as the selected curve } #endif } @@ -3512,14 +3509,14 @@ void EditCurvesDialog::OnExport( wxCommandEvent & WXUNUSED(event)) EQCurveArray temp; temp = mEffect->mCurves; // backup the parent's curves EQCurveArray exportCurves; // Copy selected curves to export - exportCurves.Clear(); + exportCurves.clear(); long item = mList->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); int i=0; while(item >= 0) { if(item != mList->GetItemCount()-1) // not 'unnamed' { - exportCurves.Add(mEditCurves[item].Name); + exportCurves.push_back(mEditCurves[item].Name); exportCurves[i].points = mEditCurves[item].points; i++; } @@ -3570,10 +3567,10 @@ void EditCurvesDialog::OnOK(wxCommandEvent & WXUNUSED(event)) wxString backupPlace = wxFileName( FileNames::DataDir(), wxT("EQBackup.xml") ).GetFullPath(); mEffect->SaveCurves(backupPlace); // Load back into the main dialog - mEffect->mCurves.Clear(); - for (unsigned int i = 0; i < mEditCurves.GetCount(); i++) + mEffect->mCurves.clear(); + for (unsigned int i = 0; i < mEditCurves.size(); i++) { - mEffect->mCurves.Add(mEditCurves[i].Name); + mEffect->mCurves.push_back(mEditCurves[i].Name); mEffect->mCurves[i].points = mEditCurves[i].points; } mEffect->SaveCurves(); diff --git a/src/effects/Equalization.h b/src/effects/Equalization.h index 238e72b72..cd83d759d 100644 --- a/src/effects/Equalization.h +++ b/src/effects/Equalization.h @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -57,15 +56,20 @@ class EQPoint { public: EQPoint( const double f, const double d ) { Freq = f; dB = d; } + + bool operator < (const EQPoint &p1) const + { + return Freq < p1.Freq; + } + double Freq; double dB; }; -WX_DECLARE_OBJARRAY( EQPoint, EQPointArray); // // One curve in a list // -// LLL: This "really" isn't needed as the EQPointArray could be +// LLL: This "really" isn't needed as the array of points could be // attached as wxClientData to the wxChoice entries. I // didn't realize this until after the fact and am too // lazy to change it. (But, hollar if you want me to.) @@ -75,10 +79,17 @@ class EQCurve public: EQCurve( const wxString & name = wxEmptyString ) { Name = name; } EQCurve( const wxChar * name ) { Name = name; } + + bool operator < (const EQCurve &that) const + { + return Name.CmpNoCase(that.Name) < 0; + } + wxString Name; - EQPointArray points; + std::vector points; }; -WX_DECLARE_OBJARRAY( EQCurve, EQCurveArray ); + +using EQCurveArray = std::vector; #ifdef EXPERIMENTAL_EQ_SSE_THREADED class EffectEqualization48x; @@ -257,21 +268,6 @@ private: wxSlider *mdBMaxSlider; wxSlider *mSliders[NUMBER_OF_BANDS]; - static int wxCMPFUNC_CONV SortCurvesByName (EQCurve **first, EQCurve **second) - { - return (*first)->Name.CmpNoCase((*second)->Name); - } - - static int wxCMPFUNC_CONV SortCurvePoints (EQPoint **p0, EQPoint **p1) - { - auto diff = (*p0)->Freq - (*p1)->Freq; - if (diff < 0) - return -1; - if (diff > 0) - return 1; - return 0; - } - #ifdef EXPERIMENTAL_EQ_SSE_THREADED wxRadioButton *mMathProcessingType[5]; // default, sse, sse threaded, AVX, AVX threaded (note AVX is not implemented yet wxBoxSizer *szrM; diff --git a/src/effects/Equalization48x.cpp b/src/effects/Equalization48x.cpp index 45beaa11d..a96c2d92b 100644 --- a/src/effects/Equalization48x.cpp +++ b/src/effects/Equalization48x.cpp @@ -34,8 +34,6 @@ #include -#include - #include "Equalization48x.h" #include "../RealFFTf.h" #include "../RealFFTf48x.h" diff --git a/src/effects/Phaser.cpp b/src/effects/Phaser.cpp index de6345c30..0c76b1c12 100644 --- a/src/effects/Phaser.cpp +++ b/src/effects/Phaser.cpp @@ -59,9 +59,6 @@ Param( OutGain, double, wxT("Gain"), -6.0, -30.0, 30.0, 1 ); // How many samples are processed before recomputing the lfo value again #define lfoskipsamples 20 -#include -WX_DEFINE_OBJARRAY(EffectPhaserStateArray); - // // EffectPhaser // @@ -165,7 +162,7 @@ bool EffectPhaser::RealtimeInitialize() { SetBlockSize(512); - mSlaves.Clear(); + mSlaves.clear(); return true; } @@ -176,14 +173,14 @@ bool EffectPhaser::RealtimeAddProcessor(unsigned WXUNUSED(numChannels), float sa InstanceInit(slave, sampleRate); - mSlaves.Add(slave); + mSlaves.push_back(slave); return true; } bool EffectPhaser::RealtimeFinalize() { - mSlaves.Clear(); + mSlaves.clear(); return true; } diff --git a/src/effects/Phaser.h b/src/effects/Phaser.h index 6ae047e30..b7e15ca45 100644 --- a/src/effects/Phaser.h +++ b/src/effects/Phaser.h @@ -44,8 +44,6 @@ public: int laststages; }; -WX_DECLARE_OBJARRAY(EffectPhaserState, EffectPhaserStateArray); - class EffectPhaser final : public Effect { public: @@ -120,7 +118,7 @@ private: private: EffectPhaserState mMaster; - EffectPhaserStateArray mSlaves; + std::vector mSlaves; // parameters int mStages; diff --git a/src/effects/Wahwah.cpp b/src/effects/Wahwah.cpp index 0634b3ada..1deb413be 100644 --- a/src/effects/Wahwah.cpp +++ b/src/effects/Wahwah.cpp @@ -53,9 +53,6 @@ Param( OutGain, double, wxT("Gain"), -6.0, -30.0, 30.0, 1 ); // How many samples are processed before recomputing the lfo value again #define lfoskipsamples 30 -#include -WX_DEFINE_OBJARRAY(EffectWahwahStateArray); - // // EffectWahwah // @@ -157,7 +154,7 @@ bool EffectWahwah::RealtimeInitialize() { SetBlockSize(512); - mSlaves.Clear(); + mSlaves.clear(); return true; } @@ -168,14 +165,14 @@ bool EffectWahwah::RealtimeAddProcessor(unsigned WXUNUSED(numChannels), float sa InstanceInit(slave, sampleRate); - mSlaves.Add(slave); + mSlaves.push_back(slave); return true; } bool EffectWahwah::RealtimeFinalize() { - mSlaves.Clear(); + mSlaves.clear(); return true; } diff --git a/src/effects/Wahwah.h b/src/effects/Wahwah.h index ecd0df82b..168d4999a 100644 --- a/src/effects/Wahwah.h +++ b/src/effects/Wahwah.h @@ -41,8 +41,6 @@ public: double b0, b1, b2, a0, a1, a2; }; -WX_DECLARE_OBJARRAY(EffectWahwahState, EffectWahwahStateArray); - class EffectWahwah final : public Effect { public: @@ -104,7 +102,7 @@ private: private: EffectWahwahState mMaster; - EffectWahwahStateArray mSlaves; + std::vector mSlaves; /* Parameters: mFreq - LFO frequency diff --git a/src/effects/lv2/LV2Effect.cpp b/src/effects/lv2/LV2Effect.cpp index c666984be..95ffdfc2b 100644 --- a/src/effects/lv2/LV2Effect.cpp +++ b/src/effects/lv2/LV2Effect.cpp @@ -19,7 +19,6 @@ #include #include #include -#include #ifdef __WXMAC__ #include @@ -294,10 +293,6 @@ BEGIN_EVENT_TABLE(LV2Effect, wxEvtHandler) EVT_IDLE(LV2Effect::OnIdle) END_EVENT_TABLE() -#include - -WX_DEFINE_OBJARRAY(LV2PortArray); - LV2Effect::LV2Effect(const LilvPlugin *plug) { mPlug = plug; @@ -398,7 +393,7 @@ wxString LV2Effect::GetFamily() bool LV2Effect::IsInteractive() { - return mControls.GetCount() != 0; + return mControls.size() != 0; } bool LV2Effect::IsDefault() @@ -587,9 +582,9 @@ bool LV2Effect::SetHost(EffectHostInterface *host) ctrl.mEnumeration = true; } - mControlsMap[ctrl.mIndex] = mControls.GetCount(); - mGroupMap[ctrl.mGroup].Add(mControls.GetCount()); - mControls.Add(ctrl); + mControlsMap[ctrl.mIndex] = mControls.size(); + mGroupMap[ctrl.mGroup].push_back(mControls.size()); + mControls.push_back(ctrl); } else if (lilv_port_is_a(mPlug, port, gOutput)) { @@ -600,8 +595,8 @@ bool LV2Effect::SetHost(EffectHostInterface *host) } else { - mGroupMap[ctrl.mGroup].Add(mControls.GetCount()); - mControls.Add(ctrl); + mGroupMap[ctrl.mGroup].Add(mControls.size()); + mControls.push_back(ctrl); } } else @@ -955,7 +950,7 @@ bool LV2Effect::ShowInterface(wxWindow *parent, bool forceModal) bool LV2Effect::GetAutomationParameters(EffectAutomationParameters & parms) { - for (size_t p = 0, cnt = mControls.GetCount(); p < cnt; p++) + for (size_t p = 0, cnt = mControls.size(); p < cnt; p++) { if (mControls[p].mInput) { @@ -972,7 +967,7 @@ bool LV2Effect::GetAutomationParameters(EffectAutomationParameters & parms) bool LV2Effect::SetAutomationParameters(EffectAutomationParameters & parms) { // First pass validates values - for (size_t p = 0, cnt = mControls.GetCount(); p < cnt; p++) + for (size_t p = 0, cnt = mControls.size(); p < cnt; p++) { LV2Port & ctrl = mControls[p]; @@ -993,7 +988,7 @@ bool LV2Effect::SetAutomationParameters(EffectAutomationParameters & parms) } // Second pass actually sets the values - for (size_t p = 0, cnt = mControls.GetCount(); p < cnt; p++) + for (size_t p = 0, cnt = mControls.size(); p < cnt; p++) { LV2Port & ctrl = mControls[p]; @@ -1338,7 +1333,7 @@ LilvInstance *LV2Effect::InitInstance(float sampleRate) SetBlockSize(mBlockSize); SetSampleRate(sampleRate); - for (size_t p = 0, cnt = mControls.GetCount(); p < cnt; p++) + for (size_t p = 0, cnt = mControls.size(); p < cnt; p++) { lilv_instance_connect_port(handle, mControls[p].mIndex, @@ -1529,7 +1524,7 @@ bool LV2Effect::BuildPlain() int numCols = 5; // Allocate memory for the user parameter controls - auto ctrlcnt = mControls.GetCount(); + auto ctrlcnt = mControls.size(); mSliders.reinit(ctrlcnt); mFields.reinit(ctrlcnt); @@ -1833,7 +1828,7 @@ bool LV2Effect::TransferDataToWindow() { if (mSuilInstance) { - for (size_t p = 0, cnt = mControls.GetCount(); p < cnt; p++) + for (size_t p = 0, cnt = mControls.size(); p < cnt; p++) { if (mControls[p].mInput) { @@ -2112,7 +2107,7 @@ void LV2Effect::SetPortValue(const char *port_symbol, LV2_URID Int = URID_Map(lilv_node_as_string(gInt)); LV2_URID Long = URID_Map(lilv_node_as_string(gLong)); - for (size_t p = 0, cnt = mControls.GetCount(); p < cnt; p++) + for (size_t p = 0, cnt = mControls.size(); p < cnt; p++) { if (mControls[p].mSymbol.IsSameAs(symbol)) { diff --git a/src/effects/lv2/LV2Effect.h b/src/effects/lv2/LV2Effect.h index 5fafde806..b85b9cd3f 100644 --- a/src/effects/lv2/LV2Effect.h +++ b/src/effects/lv2/LV2Effect.h @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include @@ -62,6 +61,10 @@ public: mHasLo = false; mHasHi = false; } + LV2Port( const LV2Port & ) = default; + LV2Port& operator = ( const LV2Port & ) = default; + LV2Port( LV2Port && ) = default; + LV2Port& operator = ( LV2Port && ) = default; uint32_t mIndex; wxString mSymbol; @@ -92,7 +95,6 @@ public: wxArrayString mScaleLabels; }; -WX_DECLARE_OBJARRAY(LV2Port, LV2PortArray); using LV2GroupMap = std::unordered_map; WX_DEFINE_ARRAY_PTR(LilvInstance *, LV2SlaveArray); @@ -265,7 +267,7 @@ private: double mSampleRate; wxLongToLongHashMap mControlsMap; - LV2PortArray mControls; + std::vector mControls; wxArrayInt mAudioInputs; wxArrayInt mAudioOutputs; diff --git a/src/effects/nyquist/Nyquist.cpp b/src/effects/nyquist/Nyquist.cpp index cd346a9ca..3b9fbf5de 100644 --- a/src/effects/nyquist/Nyquist.cpp +++ b/src/effects/nyquist/Nyquist.cpp @@ -100,9 +100,6 @@ static const wxChar *KEY_Command = wxT("Command"); // /////////////////////////////////////////////////////////////////////////////// -#include -WX_DEFINE_OBJARRAY(NyqControlArray); - BEGIN_EVENT_TABLE(NyquistEffect, wxEvtHandler) EVT_BUTTON(ID_Load, NyquistEffect::OnLoad) EVT_BUTTON(ID_Save, NyquistEffect::OnSave) @@ -267,7 +264,7 @@ bool NyquistEffect::IsInteractive() return true; } - return mControls.GetCount() != 0; + return mControls.size() != 0; } bool NyquistEffect::IsDefault() @@ -292,7 +289,7 @@ bool NyquistEffect::GetAutomationParameters(EffectAutomationParameters & parms) return true; } - for (size_t c = 0, cnt = mControls.GetCount(); c < cnt; c++) + for (size_t c = 0, cnt = mControls.size(); c < cnt; c++) { NyqControl & ctrl = mControls[c]; double d = ctrl.val; @@ -340,7 +337,7 @@ bool NyquistEffect::SetAutomationParameters(EffectAutomationParameters & parms) } // First pass verifies values - for (size_t c = 0, cnt = mControls.GetCount(); c < cnt; c++) + for (size_t c = 0, cnt = mControls.size(); c < cnt; c++) { NyqControl & ctrl = mControls[c]; bool good = false; @@ -379,7 +376,7 @@ bool NyquistEffect::SetAutomationParameters(EffectAutomationParameters & parms) } // Second pass sets the variables - for (size_t c = 0, cnt = mControls.GetCount(); c < cnt; c++) + for (size_t c = 0, cnt = mControls.size(); c < cnt; c++) { NyqControl & ctrl = mControls[c]; @@ -485,7 +482,7 @@ bool NyquistEffect::CheckWhetherSkipEffect() { // If we're a prompt and we have controls, then we've already processed // the audio, so skip further processing. - return (mIsPrompt && mControls.GetCount() > 0); + return (mIsPrompt && mControls.size() > 0); } bool NyquistEffect::Process() @@ -811,7 +808,7 @@ bool NyquistEffect::ShowInterface(wxWindow *parent, bool forceModal) // We're done if the user clicked "Close", we are not the Nyquist Prompt, // or the program currently loaded into the prompt doesn't have a UI. - if (!res || !mIsPrompt || mControls.GetCount() == 0) + if (!res || !mIsPrompt || mControls.size() == 0) { return res; } @@ -1091,7 +1088,7 @@ bool NyquistEffect::ProcessOne() cmd += wxT("(setf *tracenable* NIL)\n"); } - for (unsigned int j = 0; j < mControls.GetCount(); j++) { + for (unsigned int j = 0; j < mControls.size(); j++) { if (mControls[j].type == NYQ_CTRL_REAL || mControls[j].type == NYQ_CTRL_FLOAT_TEXT) { // We use Internat::ToString() rather than "%f" here because we // always have to use the dot as decimal separator when giving @@ -1775,7 +1772,7 @@ void NyquistEffect::Parse(const wxString &line) if( mPresetNames.Index( ctrl.var ) == wxNOT_FOUND ) { - mControls.Add(ctrl); + mControls.push_back(ctrl); } } @@ -1798,7 +1795,7 @@ bool NyquistEffect::ParseProgram(wxInputStream & stream) mCmd = wxT(""); mIsSal = false; - mControls.Clear(); + mControls.clear(); mCategories.Clear(); mIsSpectral = false; mManPage = wxEmptyString; // If not wxEmptyString, must be a page in the Audacity manual. @@ -2047,7 +2044,7 @@ bool NyquistEffect::TransferDataToPromptWindow() bool NyquistEffect::TransferDataToEffectWindow() { - for (size_t i = 0, cnt = mControls.GetCount(); i < cnt; i++) + for (size_t i = 0, cnt = mControls.size(); i < cnt; i++) { NyqControl & ctrl = mControls[i]; @@ -2087,12 +2084,12 @@ bool NyquistEffect::TransferDataFromPromptWindow() bool NyquistEffect::TransferDataFromEffectWindow() { - if (mControls.GetCount() == 0) + if (mControls.size() == 0) { return true; } - for (unsigned int i = 0; i < mControls.GetCount(); i++) + for (unsigned int i = 0; i < mControls.size(); i++) { NyqControl *ctrl = &mControls[i]; @@ -2200,7 +2197,7 @@ void NyquistEffect::BuildEffectWindow(ShuttleGui & S) { S.StartMultiColumn(4); { - for (size_t i = 0; i < mControls.GetCount(); i++) + for (size_t i = 0; i < mControls.size(); i++) { NyqControl & ctrl = mControls[i]; diff --git a/src/effects/nyquist/Nyquist.h b/src/effects/nyquist/Nyquist.h index d916f7ea3..29ef88e2e 100644 --- a/src/effects/nyquist/Nyquist.h +++ b/src/effects/nyquist/Nyquist.h @@ -46,6 +46,12 @@ enum NyqControlType class NyqControl { public: + NyqControl() = default; + NyqControl( const NyqControl& ) = default; + NyqControl &operator = ( const NyqControl & ) = default; + NyqControl( NyqControl && ) = default; + NyqControl &operator = ( NyqControl && ) = default; + int type; wxString var; wxString name; @@ -59,8 +65,6 @@ public: int ticks; }; -WX_DECLARE_USER_EXPORTED_OBJARRAY(NyqControl, NyqControlArray, AUDACITY_DLL_API); - class AUDACITY_DLL_API NyquistEffect final : public Effect { public: @@ -214,7 +218,7 @@ private: wxString mDebugOutput; int mVersion; - NyqControlArray mControls; + std::vector mControls; unsigned mCurNumChannels; WaveTrack *mCurTrack[2]; diff --git a/src/export/Export.cpp b/src/export/Export.cpp index 56157ce54..554ea0f9b 100644 --- a/src/export/Export.cpp +++ b/src/export/Export.cpp @@ -31,7 +31,6 @@ #include "../Audacity.h" #include "Export.h" -#include #include #include #include @@ -74,18 +73,13 @@ //---------------------------------------------------------------------------- // ExportPlugin //---------------------------------------------------------------------------- -#include - -WX_DEFINE_USER_EXPORTED_OBJARRAY(FormatInfoArray); ExportPlugin::ExportPlugin() { - mFormatInfos.Empty(); } ExportPlugin::~ExportPlugin() { - mFormatInfos.Clear(); } bool ExportPlugin::CheckFileName(wxFileName & WXUNUSED(filename), int WXUNUSED(format)) @@ -103,13 +97,13 @@ bool ExportPlugin::CheckFileName(wxFileName & WXUNUSED(filename), int WXUNUSED(f int ExportPlugin::AddFormat() { FormatInfo nf; - mFormatInfos.Add(nf); - return mFormatInfos.Count(); + mFormatInfos.push_back(nf); + return mFormatInfos.size(); } int ExportPlugin::GetFormatCount() { - return mFormatInfos.Count(); + return mFormatInfos.size(); } /** diff --git a/src/export/Export.h b/src/export/Export.h index a55500180..99f5d7f20 100644 --- a/src/export/Export.h +++ b/src/export/Export.h @@ -14,7 +14,6 @@ #include "../MemoryX.h" #include #include -#include #include #include #include "../Tags.h" @@ -39,8 +38,13 @@ enum class ProgressResult : unsigned; class AUDACITY_DLL_API FormatInfo { public: - FormatInfo(){}; - ~FormatInfo(){}; + FormatInfo() {} + FormatInfo( const FormatInfo & ) = default; + FormatInfo &operator = ( const FormatInfo & ) = default; + FormatInfo( FormatInfo && ) = default; + FormatInfo &operator = ( FormatInfo && ) = default; + ~FormatInfo() {} + wxString mFormat; wxString mDescription; // wxString mExtension; @@ -50,8 +54,6 @@ class AUDACITY_DLL_API FormatInfo bool mCanMetaData; }; -WX_DECLARE_USER_EXPORTED_OBJARRAY(FormatInfo, FormatInfoArray, AUDACITY_DLL_API); - //---------------------------------------------------------------------------- // ExportPlugin //---------------------------------------------------------------------------- @@ -141,7 +143,7 @@ protected: const wxString &title, const wxString &message); private: - FormatInfoArray mFormatInfos; + std::vector mFormatInfos; }; using ExportPluginArray = std::vector < movable_ptr< ExportPlugin > > ; diff --git a/src/export/ExportMultiple.cpp b/src/export/ExportMultiple.cpp index 549a29d29..ec2884bb7 100644 --- a/src/export/ExportMultiple.cpp +++ b/src/export/ExportMultiple.cpp @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include @@ -53,8 +52,6 @@ /* define our dynamic array of export settings */ -#include // much hackery -WX_DEFINE_OBJARRAY( ExportKitArray ) enum { FormatID = 10001, @@ -647,8 +644,8 @@ ProgressResult ExportMultiple::ExportMultipleByLabel(bool byName, bool tagsPrompt = mProject->GetShowId3Dialog(); int numFiles = mNumLabels; int l = 0; // counter for files done - ExportKitArray exportSettings; // dynamic array for settings. - exportSettings.Alloc(numFiles); // Allocate some guessed space to use. + std::vector exportSettings; // dynamic array for settings. + exportSettings.reserve(numFiles); // Allocate some guessed space to use. // Account for exporting before first label if( mFirst->GetValue() ) { @@ -739,7 +736,7 @@ ProgressResult ExportMultiple::ExportMultipleByLabel(bool byName, } /* add the settings to the array of settings to be used for export */ - exportSettings.Add(setting); + exportSettings.push_back(setting); l++; // next label, count up one } @@ -777,9 +774,9 @@ ProgressResult ExportMultiple::ExportMultipleByTrack(bool byName, int l = 0; // track counter auto ok = ProgressResult::Success; wxArrayString otherNames; - ExportKitArray exportSettings; // dynamic array we will use to store the + std::vector exportSettings; // dynamic array we will use to store the // settings needed to do the exports with in - exportSettings.Alloc(mNumWaveTracks); // Allocate some guessed space to use. + exportSettings.reserve(mNumWaveTracks); // Allocate some guessed space to use. ExportKit setting; // the current batch of settings setting.destfile.SetPath(mDir->GetValue()); setting.destfile.SetExt(mPlugins[mPluginIndex]->GetExtension(mSubFormatIndex)); @@ -881,7 +878,7 @@ ProgressResult ExportMultiple::ExportMultipleByTrack(bool byName, return ProgressResult::Cancelled; } /* add the settings to the array of settings to be used for export */ - exportSettings.Add(setting); + exportSettings.push_back(setting); l++; // next track, count up one } diff --git a/src/export/ExportMultiple.h b/src/export/ExportMultiple.h index 6d617c030..7cf973daa 100644 --- a/src/export/ExportMultiple.h +++ b/src/export/ExportMultiple.h @@ -13,12 +13,12 @@ #include #include -#include // sadly we are using wx dynamic arrays #include #include #include "Export.h" #include "../Tags.h" // we need to know about the Tags class for metadata +#include "../wxFileNameWrapper.h" class wxButton; class wxCheckBox; @@ -198,7 +198,7 @@ private: { public: Tags filetags; /**< The set of metadata to use for the export */ - wxFileName destfile; /**< The file to export to */ + wxFileNameWrapper destfile; /**< The file to export to */ double t0; /**< Start time for the export */ double t1; /**< End time for the export */ unsigned channels; /**< Number of channels for ExportMultipleByTrack */ @@ -208,7 +208,6 @@ private: * this isn't done anywhere else in Audacity, presumably for a reason?, so * I'm stuck with wxArrays, which are much harder, as well as non-standard. */ - WX_DECLARE_OBJARRAY(ExportKit, ExportKitArray); #endif diff --git a/src/import/Import.cpp b/src/import/Import.cpp index 9ebdb6137..84ae0f125 100644 --- a/src/import/Import.cpp +++ b/src/import/Import.cpp @@ -46,7 +46,6 @@ and ImportLOF.cpp. #include #include #include //for wxBoxSizer -#include #include #include "../ShuttleGui.h" #include "../Project.h" diff --git a/src/prefs/DevicePrefs.h b/src/prefs/DevicePrefs.h index cbabe4bf2..88c87bb30 100644 --- a/src/prefs/DevicePrefs.h +++ b/src/prefs/DevicePrefs.h @@ -17,7 +17,6 @@ #include #include #include -#include #include "PrefsPanel.h" diff --git a/src/prefs/QualityPrefs.h b/src/prefs/QualityPrefs.h index 9fcf445c4..f5b9b1f0f 100644 --- a/src/prefs/QualityPrefs.h +++ b/src/prefs/QualityPrefs.h @@ -16,7 +16,6 @@ #include #include -#include #include #include "PrefsPanel.h" diff --git a/src/widgets/ExpandingToolBar.cpp b/src/widgets/ExpandingToolBar.cpp index d6f6674c9..72f3beb47 100644 --- a/src/widgets/ExpandingToolBar.cpp +++ b/src/widgets/ExpandingToolBar.cpp @@ -76,7 +76,6 @@ ExpandingToolBar. #include #include #include -#include #include #include "ExpandingToolBar.h" @@ -93,13 +92,11 @@ enum { kTimerID }; -WX_DEFINE_OBJARRAY(wxArrayRect); - class ToolBarArrangement { public: ExpandingToolBarArray childArray; - wxArrayRect rectArray; + std::vector rectArray; wxArrayInt rowArray; }; @@ -576,7 +573,7 @@ void ExpandingToolBar::UpdateMoving() int best_dist_sq = 99999; int i; - for(i=0; i<(int)mDropTargets.GetCount(); i++) { + for(i = 0; i < (int)mDropTargets.size(); i++) { int x = (mDropTargets[i].x + (mDropTargets[i].width/2))-cursorPos.x; int y = (mDropTargets[i].y + (mDropTargets[i].height/2))-cursorPos.y; int dist_sq = (x*x) + (y*y); @@ -1193,7 +1190,7 @@ std::unique_ptr ToolBarArea::SaveArrangement() arrangement->rowArray = mRowArray; for(i=0; i<(int)mChildArray.GetCount(); i++) - arrangement->rectArray.Add(mChildArray[i]->GetRect()); + arrangement->rectArray.push_back(mChildArray[i]->GetRect()); return arrangement; } @@ -1215,9 +1212,9 @@ void ToolBarArea::RestoreArrangement(std::unique_ptr&& arran arrangement.reset(); } -wxArrayRect ToolBarArea::GetDropTargets() +std::vector ToolBarArea::GetDropTargets() { - mDropTargets.Clear(); + mDropTargets.clear(); mDropTargetIndices.Clear(); mDropTargetRows.Clear(); @@ -1237,14 +1234,14 @@ wxArrayRect ToolBarArea::GetDropTargets() row = childRow; mDropTargetIndices.Add(i); mDropTargetRows.Add(row); - mDropTargets.Add(wxRect(childRect.x, childRect.y, + mDropTargets.push_back(wxRect(childRect.x, childRect.y, 0, childRect.height)); } // Add a target after this child (always) mDropTargetIndices.Add(i+1); mDropTargetRows.Add(row); - mDropTargets.Add(wxRect(childRect.x+childRect.width, childRect.y, + mDropTargets.push_back(wxRect(childRect.x+childRect.width, childRect.y, 0, childRect.height)); } @@ -1255,7 +1252,7 @@ void ToolBarArea::MoveChild(ExpandingToolBar *toolBar, wxRect dropTarget) { int i, j; - for(i=0; i<(int)mDropTargets.GetCount(); i++) { + for(i = 0; i < (int)mDropTargets.size(); i++) { if (dropTarget == mDropTargets[i]) { int newIndex = mDropTargetIndices[i]; int newRow = mDropTargetRows[i]; diff --git a/src/widgets/ExpandingToolBar.h b/src/widgets/ExpandingToolBar.h index c0546567e..625052e51 100644 --- a/src/widgets/ExpandingToolBar.h +++ b/src/widgets/ExpandingToolBar.h @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include @@ -42,7 +41,6 @@ class ToolBarArrangement; using WindowHash = std::unordered_map; WX_DEFINE_ARRAY(ExpandingToolBar *, ExpandingToolBarArray); -WX_DECLARE_OBJARRAY(wxRect, wxArrayRect); class ExpandingToolBarEvtHandler; @@ -120,7 +118,7 @@ class ExpandingToolBar final : public wxPanelWrapper ImageRollPanel *mTargetPanel; std::unique_ptr mDragImage; wxWindow *mTopLevelParent; - wxArrayRect mDropTargets; + std::vector mDropTargets; wxRect mDropTarget; static int msNoAutoExpandStack; @@ -229,7 +227,7 @@ class ToolBarArea final : public wxPanelWrapper std::unique_ptr SaveArrangement(); void RestoreArrangement(std::unique_ptr&& arrangement); - wxArrayRect GetDropTargets(); + std::vector GetDropTargets(); void MoveChild(ExpandingToolBar *child, wxRect dropTarget); void SetCapturedChild(ExpandingToolBar *child); @@ -252,7 +250,7 @@ class ToolBarArea final : public wxPanelWrapper wxSize mMaxSize; wxSize mActualSize; - wxArrayRect mDropTargets; + std::vector mDropTargets; wxArrayInt mDropTargetIndices; wxArrayInt mDropTargetRows; diff --git a/src/widgets/FileHistory.h b/src/widgets/FileHistory.h index f43c5a32c..a291ce101 100644 --- a/src/widgets/FileHistory.h +++ b/src/widgets/FileHistory.h @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include diff --git a/src/widgets/Grid.h b/src/widgets/Grid.h index 8992ef48e..2c3284a87 100644 --- a/src/widgets/Grid.h +++ b/src/widgets/Grid.h @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include diff --git a/src/widgets/ImageRoll.cpp b/src/widgets/ImageRoll.cpp index 9628cd83f..acdff5d2f 100644 --- a/src/widgets/ImageRoll.cpp +++ b/src/widgets/ImageRoll.cpp @@ -98,14 +98,10 @@ #include "ImageRoll.h" #include -#include #include #include #include -WX_DEFINE_OBJARRAY(BitmapArray); -WX_DEFINE_OBJARRAY(ImageArray); - // static ImageArray ImageRoll::SplitH(const wxImage &src, wxColour magicColor) { @@ -149,7 +145,7 @@ ImageArray ImageRoll::SplitH(const wxImage &src, wxColour magicColor) subImage = src.GetSubImage(subRect); else subImage = wxImage(subRect.width, subRect.height); - result.Add(subImage); + result.push_back(subImage); } else if (!cur && prev) { start = i; @@ -204,7 +200,7 @@ ImageArray ImageRoll::SplitV(const wxImage &src, wxColour magicColor) subImage = src.GetSubImage(subRect); else subImage = wxImage(subRect.width, subRect.height); - result.Add(subImage); + result.push_back(subImage); } else if (!cur && prev) { start = i; @@ -233,13 +229,13 @@ void ImageRoll::Init(RollType type, const wxImage &src, wxColour magicColor) mMaxSize.x = 9999; mMaxSize.y = src.GetHeight(); - for(i=0; i<(int)images.GetCount(); i++) { + for(i = 0; i < (int)images.size(); i++) { if (images[i].Ok()) { - mPieces.Add(wxBitmap(images[i])); + mPieces.push_back(wxBitmap(images[i])); mMinSize.x += mPieces[i].GetWidth(); } else - mPieces.Add(wxBitmap()); + mPieces.push_back(wxBitmap()); } break; @@ -251,18 +247,18 @@ void ImageRoll::Init(RollType type, const wxImage &src, wxColour magicColor) mMaxSize.x = src.GetWidth(); mMaxSize.y = 9999; - for(i=0; i<(int)images.GetCount(); i++) { + for(i = 0; i < (int)images.size(); i++) { if (images[i].Ok()) { - mPieces.Add(wxBitmap(images[i])); + mPieces.push_back(wxBitmap(images[i])); mMinSize.y += mPieces[i].GetHeight(); } else - mPieces.Add(wxBitmap()); + mPieces.push_back(wxBitmap()); } break; case FixedImage: - mPieces.Add(wxBitmap(src)); + mPieces.push_back(wxBitmap(src)); mMinSize.x = src.GetWidth(); mMinSize.y = src.GetHeight(); mMaxSize.x = src.GetWidth(); @@ -317,7 +313,7 @@ void ImageRoll::Draw(wxDC &dc, wxRect rect, wxRasterOperationMode WXUNUSED(logic { int width = rect.width; int height = rect.height; - int num = (int)mPieces.GetCount(); + int num = (int)mPieces.size(); int i, j; switch(mType) { diff --git a/src/widgets/ImageRoll.h b/src/widgets/ImageRoll.h index cc0214e9d..688666546 100644 --- a/src/widgets/ImageRoll.h +++ b/src/widgets/ImageRoll.h @@ -12,10 +12,10 @@ #ifndef __AUDACITY_IMAGE_ROLL__ #define __AUDACITY_IMAGE_ROLL__ +#include #include #include #include -#include #include #include "wxPanelWrapper.h" @@ -23,8 +23,8 @@ #define wxRasterOperationMode int #endif -WX_DECLARE_OBJARRAY(wxBitmap, BitmapArray); -WX_DECLARE_OBJARRAY(wxImage, ImageArray); +// wxImage copies cheaply with reference counting +using ImageArray = std::vector; class ImageRoll { @@ -60,7 +60,8 @@ class ImageRoll void Init(RollType type, const wxImage &src, wxColour magicColor); RollType mType; - BitmapArray mPieces; + // wxBitmap copies cheaply with reference counting + std::vector mPieces; wxSize mMinSize; wxSize mMaxSize; }; diff --git a/src/widgets/KeyView.cpp b/src/widgets/KeyView.cpp index 2370bc8e0..038068102 100644 --- a/src/widgets/KeyView.cpp +++ b/src/widgets/KeyView.cpp @@ -23,7 +23,6 @@ #include "../commands/Keyboard.h" #include "KeyView.h" -#include #include #include "../Internat.h" @@ -34,8 +33,6 @@ #define KV_VSCROLL_WIDTH 16 /* figure this out automatically? */ // Define the KeyNode arrays -WX_DEFINE_OBJARRAY(KeyNodeArray); -WX_DEFINE_OBJARRAY(KeyNodeArrayPtr); // Define the event table BEGIN_EVENT_TABLE(KeyView, wxVListBox) @@ -106,7 +103,7 @@ wxString KeyView::GetLabel(int index) const { // Make sure index is valid - if (index < 0 || index >= (int) mNodes.GetCount()) + if (index < 0 || index >= (int) mNodes.size()) { wxASSERT(false); return wxEmptyString; @@ -122,14 +119,14 @@ wxString KeyView::GetFullLabel(int index) const { // Make sure index is valid - if (index < 0 || index >= (int) mNodes.GetCount()) + if (index < 0 || index >= (int) mNodes.size()) { wxASSERT(false); return wxEmptyString; } // Cache the node and label - KeyNode & node = mNodes[index]; + const KeyNode & node = mNodes[index]; wxString label = node.label; // Prepend the prefix if available @@ -147,7 +144,7 @@ KeyView::GetFullLabel(int index) const int KeyView::GetIndexByName(const wxString & name) const { - int cnt = (int) mNodes.GetCount(); + int cnt = (int) mNodes.size(); // Search the nodes for the key for (int i = 0; i < cnt; i++) @@ -168,7 +165,7 @@ wxString KeyView::GetName(int index) const { // Make sure index is valid - if (index < 0 || index >= (int) mNodes.GetCount()) + if (index < 0 || index >= (int) mNodes.size()) { wxASSERT(false); return wxEmptyString; @@ -183,7 +180,7 @@ KeyView::GetName(int index) const wxString KeyView::GetNameByKey(const wxString & key) const { - int cnt = (int) mNodes.GetCount(); + int cnt = (int) mNodes.size(); // Search the nodes for the key for (int i = 0; i < cnt; i++) @@ -203,7 +200,7 @@ KeyView::GetNameByKey(const wxString & key) const int KeyView::GetIndexByKey(const wxString & key) const { - int cnt = (int) mNodes.GetCount(); + int cnt = (int) mNodes.size(); // Search the nodes for the key for (int i = 0; i < cnt; i++) @@ -224,7 +221,7 @@ wxString KeyView::GetKey(int index) const { // Make sure index is valid - if (index < 0 || index >= (int) mNodes.GetCount()) + if (index < 0 || index >= (int) mNodes.size()) { wxASSERT(false); return wxEmptyString; @@ -240,7 +237,7 @@ bool KeyView::CanSetKey(int index) const { // Make sure index is valid - if (index < 0 || index >= (int) mNodes.GetCount()) + if (index < 0 || index >= (int) mNodes.size()) { wxASSERT(false); return false; @@ -257,7 +254,7 @@ bool KeyView::SetKey(int index, const wxString & key) { // Make sure index is valid - if (index < 0 || index >= (int) mNodes.GetCount()) + if (index < 0 || index >= (int) mNodes.size()) { wxASSERT(false); return false; @@ -399,7 +396,7 @@ KeyView::SetFilter(const wxString & filter) void KeyView::ExpandAll() { - int cnt = (int) mNodes.GetCount(); + int cnt = (int) mNodes.size(); // Set all parent nodes to open for (int i = 0; i < cnt; i++) @@ -421,7 +418,7 @@ KeyView::ExpandAll() void KeyView::CollapseAll() { - int cnt = (int) mNodes.GetCount(); + int cnt = (int) mNodes.size(); // Set all parent nodes to closed for (int i = 0; i < cnt; i++) @@ -449,7 +446,7 @@ KeyView::RecalcExtents() mKeyWidth = 0; // Examine all nodes - int cnt = (int) mNodes.GetCount(); + int cnt = (int) mNodes.size(); for (int i = 0; i < cnt; i++) { KeyNode & node = mNodes[i]; @@ -539,7 +536,7 @@ KeyView::RefreshBindings(const wxArrayString & names, ) { // Start clean - mNodes.Clear(); + mNodes.clear(); // Same as in RecalcExtents() but do it inline mLineHeight = 0; @@ -610,7 +607,7 @@ KeyView::RefreshBindings(const wxArrayString & names, node.isopen = true; // Add it to the tree - mNodes.Add(node); + mNodes.push_back(node); incat = true; // Measure category @@ -650,7 +647,7 @@ KeyView::RefreshBindings(const wxArrayString & names, node.isopen = true; // Add it to the tree - mNodes.Add(node); + mNodes.push_back(node); inpfx = true; } } @@ -684,7 +681,7 @@ KeyView::RefreshBindings(const wxArrayString & names, node.depth = depth; // Add it to the tree - mNodes.Add(node); + mNodes.push_back(node); // Measure key GetTextExtent(node.key, &x, &y); @@ -744,9 +741,9 @@ KeyView::RefreshBindings(const wxArrayString & names, void KeyView::RefreshLines(bool bSort) { - int cnt = (int) mNodes.GetCount(); + int cnt = (int) mNodes.size(); int linecnt = 0; - mLines.Empty(); + mLines.clear(); // Process a filter if one is set if (!mFilter.IsEmpty()) @@ -804,7 +801,7 @@ KeyView::RefreshLines(bool bSort) // whether they match the filter or not. if (mViewType == ViewByTree) { - KeyNodeArrayPtr queue; + std::vector queue; int depth = node.depth; // This node is a category or prefix node, so always mark them @@ -827,7 +824,7 @@ KeyView::RefreshLines(bool bSort) // Examine all previously added nodes to see if this nodes // ancestors need to be added prior to adding this node. bool found = false; - for (int k = (int) mLines.GetCount() - 1; k >= 0; k--) + for (int k = (int) mLines.size() - 1; k >= 0; k--) { // The node indexes match, so we've found the parent of the // child node. @@ -843,7 +840,7 @@ KeyView::RefreshLines(bool bSort) // they will wind up in reverse order. if (!found) { - queue.Add(&mNodes[j]); + queue.push_back(&mNodes[j]); } // Traverse up the tree @@ -853,17 +850,17 @@ KeyView::RefreshLines(bool bSort) // Add any queues nodes to list. This will all be // parent nodes, so mark them as open. - for (int j = (int) queue.GetCount() - 1; j >= 0; j--) + for (int j = (int) queue.size() - 1; j >= 0; j--) { queue[j]->isopen = true; queue[j]->line = linecnt++; - mLines.Add(queue[j]); + mLines.push_back(queue[j]); } } // Finally add the child node node.line = linecnt++; - mLines.Add(&node); + mLines.push_back(&node); } } else @@ -887,7 +884,7 @@ KeyView::RefreshLines(bool bSort) // Add the node node.line = linecnt++; - mLines.Add(&node); + mLines.push_back(&node); // If this node is not open, then skip all of it's decendants if (!node.isopen) @@ -920,7 +917,7 @@ KeyView::RefreshLines(bool bSort) // Add child node to list node.line = linecnt++; - mLines.Add(&node); + mLines.push_back(&node); } } @@ -940,21 +937,21 @@ KeyView::RefreshLines(bool bSort) switch (mViewType) { case ViewByTree: - mLines.Sort(CmpKeyNodeByTree); + std::sort(mLines.begin(), mLines.end(), CmpKeyNodeByTree); break; case ViewByName: - mLines.Sort(CmpKeyNodeByName); + std::sort(mLines.begin(), mLines.end(), CmpKeyNodeByName); break; case ViewByKey: - mLines.Sort(CmpKeyNodeByKey); + std::sort(mLines.begin(), mLines.end(), CmpKeyNodeByKey); break; } } // Now, reassign the line numbers - for (int i = 0; i < (int) mLines.GetCount(); i++) + for (int i = 0; i < (int) mLines.size(); i++) { mLines[i]->line = i; } @@ -980,7 +977,7 @@ KeyView::RefreshLines(bool bSort) #endif // Tell listbox the NEW count and refresh the entire view - SetItemCount(mLines.GetCount()); + SetItemCount(mLines.size()); RefreshAll(); #if wxUSE_ACCESSIBILITY @@ -1025,7 +1022,7 @@ KeyView::SelectNode(int index) int KeyView::LineToIndex(int line) const { - if (line < 0 || line >= (int) mLines.GetCount()) + if (line < 0 || line >= (int) mLines.size()) { return wxNOT_FOUND; } @@ -1039,7 +1036,7 @@ KeyView::LineToIndex(int line) const int KeyView::IndexToLine(int index) const { - if (index < 0 || index >= (int) mNodes.GetCount()) + if (index < 0 || index >= (int) mNodes.size()) { return wxNOT_FOUND; } @@ -1389,7 +1386,7 @@ KeyView::OnKeyDown(wxKeyEvent & event) if (node->isopen) { // But only if there is one - if (line < (int) mLines.GetCount() - 1) + if (line < (int) mLines.size() - 1) { SelectNode(LineToIndex(line + 1)); } @@ -1423,7 +1420,7 @@ KeyView::OnKeyDown(wxKeyEvent & event) // the keycode default: { - int cnt = (int) mLines.GetCount(); + int cnt = (int) mLines.size(); bool found = false; // Search the entire list if none is currently selected @@ -1574,12 +1571,9 @@ KeyView::OnLeftDown(wxMouseEvent & event) // We prefix all "command" nodes with "ffffffff" (highest hex value) // to allow the sort to reorder them as needed. // -int -KeyView::CmpKeyNodeByTree(KeyNode ***n1, KeyNode ***n2) +bool +KeyView::CmpKeyNodeByTree(KeyNode *t1, KeyNode *t2) { - KeyNode *t1 = (**n1); - KeyNode *t2 = (**n2); - unsigned int k1UInt= 0xffffffff; unsigned int k2UInt= 0xffffffff; @@ -1595,15 +1589,11 @@ KeyView::CmpKeyNodeByTree(KeyNode ***n1, KeyNode ***n2) k2UInt = (unsigned int) t2->line; if( k1UInt < k2UInt ) - return -1; + return true; if( k1UInt > k2UInt ) - return +1; + return false; - if( t1->label < t2->label ) - return -1; - if( t1->label > t2->label ) - return 1; - return 0; + return ( t1->label < t2->label ); } // @@ -1611,11 +1601,9 @@ KeyView::CmpKeyNodeByTree(KeyNode ***n1, KeyNode ***n2) // // Nothing special here, just a standard ascending sort. // -int -KeyView::CmpKeyNodeByName(KeyNode ***n1, KeyNode ***n2) +bool +KeyView::CmpKeyNodeByName(KeyNode *t1, KeyNode *t2) { - KeyNode *t1 = (**n1); - KeyNode *t2 = (**n2); wxString k1 = t1->label; wxString k2 = t2->label; @@ -1631,19 +1619,7 @@ KeyView::CmpKeyNodeByName(KeyNode ***n1, KeyNode ***n2) k2 = t2->prefix + wxT(" - ") + k2; } - // See wxWidgets documentation for explanation of comparison results. - // These will produce an ascending order. - if (k1 < k2) - { - return -1; - } - - if (k1 > k2) - { - return 1; - } - - return 0; + return (k1 < k2); } // @@ -1659,11 +1635,9 @@ KeyView::CmpKeyNodeByName(KeyNode ***n1, KeyNode ***n2) // // The assigned entries simply get sorted as normal. // -int -KeyView::CmpKeyNodeByKey(KeyNode ***n1, KeyNode ***n2) +bool +KeyView::CmpKeyNodeByKey(KeyNode *t1, KeyNode *t2) { - KeyNode *t1 = (**n1); - KeyNode *t2 = (**n2); wxString k1 = t1->key; wxString k2 = t2->key; @@ -1695,19 +1669,7 @@ KeyView::CmpKeyNodeByKey(KeyNode ***n1, KeyNode ***n2) k1 += t1->label; k2 += t2->label; - // See wxWidgets documentation for explanation of comparison results. - // These will produce an ascending order. - if (k1 < k2) - { - return -1; - } - - if (k1 > k2) - { - return 1; - } - - return 0; + return (k1 < k2); } #if wxUSE_ACCESSIBILITY @@ -1719,7 +1681,7 @@ bool KeyView::HasChildren(int line) { // Make sure line is valid - if (line < 0 || line >= (int) mLines.GetCount()) + if (line < 0 || line >= (int) mLines.size()) { wxASSERT(false); return false; @@ -1735,7 +1697,7 @@ bool KeyView::IsExpanded(int line) { // Make sure line is valid - if (line < 0 || line >= (int) mLines.GetCount()) + if (line < 0 || line >= (int) mLines.size()) { wxASSERT(false); return false; @@ -1751,7 +1713,7 @@ wxCoord KeyView::GetLineHeight(int line) { // Make sure line is valid - if (line < 0 || line >= (int) mLines.GetCount()) + if (line < 0 || line >= (int) mLines.size()) { wxASSERT(false); return 0; @@ -1769,7 +1731,7 @@ wxString KeyView::GetValue(int line) { // Make sure line is valid - if (line < 0 || line >= (int) mLines.GetCount()) + if (line < 0 || line >= (int) mLines.size()) { wxASSERT(false); return wxEmptyString; diff --git a/src/widgets/KeyView.h b/src/widgets/KeyView.h index 5ba92d390..685984348 100644 --- a/src/widgets/KeyView.h +++ b/src/widgets/KeyView.h @@ -13,7 +13,6 @@ #include #include -#include #include #include @@ -32,6 +31,10 @@ public: isparent = false; isopen = false; } + KeyNode( const KeyNode & ) = default; + KeyNode &operator = ( const KeyNode & ) = default; + KeyNode( KeyNode && ) = default; + KeyNode &operator = ( KeyNode && ) = default; public: wxString name; @@ -49,8 +52,6 @@ public: }; // Declare the KeyNode arrays -WX_DECLARE_OBJARRAY(KeyNode, KeyNodeArray); -WX_DECLARE_OBJARRAY(KeyNode *, KeyNodeArrayPtr); // Types of view currently supported enum ViewByType @@ -131,9 +132,9 @@ private: static wxString CommandTranslated; - static int CmpKeyNodeByTree(KeyNode ***n1, KeyNode ***n2); - static int CmpKeyNodeByName(KeyNode ***n1, KeyNode ***n2); - static int CmpKeyNodeByKey(KeyNode ***n1, KeyNode ***n2); + static bool CmpKeyNodeByTree(KeyNode *n1, KeyNode *n2); + static bool CmpKeyNodeByName(KeyNode *n1, KeyNode *n2); + static bool CmpKeyNodeByKey(KeyNode *n1, KeyNode *n2); #if wxUSE_ACCESSIBILITY friend class KeyViewAx; @@ -146,8 +147,8 @@ private: #endif private: - KeyNodeArray mNodes; - KeyNodeArrayPtr mLines; + std::vector mNodes; + std::vector mLines; ViewByType mViewType; wxString mFilter; diff --git a/src/widgets/NumericTextCtrl.cpp b/src/widgets/NumericTextCtrl.cpp index 7617e0d02..3bbbe74f9 100644 --- a/src/widgets/NumericTextCtrl.cpp +++ b/src/widgets/NumericTextCtrl.cpp @@ -237,6 +237,10 @@ public: zeropad = _zeropad; digits = 0; } + NumericField( const NumericField & ) = default; + NumericField &operator = ( const NumericField & ) = default; + NumericField( NumericField && ) = default; + NumericField &operator = ( NumericField && ) = default; void CreateDigitFormatStr() { if (range > 1) @@ -284,10 +288,6 @@ public: wxRect digitBox; }; -#include -WX_DEFINE_OBJARRAY(NumericFieldArray); -WX_DEFINE_OBJARRAY(DigitInfoArray); - namespace { const std::vector &TimeConverterFormats() { @@ -652,8 +652,8 @@ NumericConverter::NumericConverter(Type type, void NumericConverter::ParseFormatString( const wxString & format) { mPrefix = wxT(""); - mFields.Clear(); - mDigits.Clear(); + mFields.clear(); + mDigits.clear(); mScalingFactor = 1.0; bool inFrac = false; @@ -721,15 +721,15 @@ void NumericConverter::ParseFormatString( const wxString & format) if (inFrac) { int base = fracMult * range; - mFields.Add(NumericField(inFrac, base, range, zeropad)); + mFields.push_back(NumericField(inFrac, base, range, zeropad)); fracMult *= range; numFracFields++; } else { unsigned int j; - for(j=0; j 1) - mFields[mFields.GetCount()-2].label = delimStr; + mFields[mFields.size()-2].label = delimStr; else - mFields[mFields.GetCount()-1].label = delimStr; + mFields[mFields.size()-1].label = delimStr; } else { if (numWholeFields == 0) @@ -768,7 +768,7 @@ void NumericConverter::ParseFormatString( const wxString & format) } } - for(i=0; i 0 && + if (mFields.size() > 0 && mValueString.Mid(mFields[0].pos, 1) == wxChar('-')) { mValue = mInvalidValue; return; } - for(i=0; i= mFields[i].pos) && (mDigits[mFocusedDigit].pos < mFields[i].pos + mFields[i].digits)) @@ -1305,7 +1305,7 @@ void NumericTextCtrl::UpdateAutoFocus() return; mFocusedDigit = 0; - while (mFocusedDigit < ((int)mDigits.GetCount() - 1)) { + while (mFocusedDigit < ((int)mDigits.size() - 1)) { wxChar dgt = mValueString[mDigits[mFocusedDigit].pos]; if (dgt != '0') { break; @@ -1388,7 +1388,7 @@ bool NumericTextCtrl::Layout() mBackgroundBitmap = std::make_unique(1, 1); memDC.SelectObject(*mBackgroundBitmap); - mDigits.Clear(); + mDigits.clear(); mBorderLeft = 1; mBorderTop = 1; @@ -1428,10 +1428,10 @@ bool NumericTextCtrl::Layout() x += strW; pos += mPrefix.Length(); - for(i=0; i= (int)mDigits.GetCount()) - mFocusedDigit = mDigits.GetCount()-1; + if (mFocusedDigit >= (int)mDigits.size()) + mFocusedDigit = mDigits.size() - 1; // Convert numeric keypad entries. if ((keyCode >= WXK_NUMPAD0) && (keyCode <= WXK_NUMPAD9)) @@ -1751,7 +1751,7 @@ void NumericTextCtrl::OnKeyDown(wxKeyEvent &event) ControlsToValue(); Refresh();// Force an update of the control. [Bug 1497] ValueToControls(); - mFocusedDigit = (mFocusedDigit + 1) % (mDigits.GetCount()); + mFocusedDigit = (mFocusedDigit + 1) % (mDigits.size()); Updated(); } @@ -1763,8 +1763,8 @@ void NumericTextCtrl::OnKeyDown(wxKeyEvent &event) else if (!mReadOnly && keyCode == WXK_BACK) { // Moves left, replaces that char with '0', stays there... mFocusedDigit--; - mFocusedDigit += mDigits.GetCount(); - mFocusedDigit %= mDigits.GetCount(); + mFocusedDigit += mDigits.size(); + mFocusedDigit %= mDigits.size(); wxString::reference theDigit = mValueString[mDigits[mFocusedDigit].pos]; if (theDigit != wxChar('-')) theDigit = '0'; @@ -1776,14 +1776,14 @@ void NumericTextCtrl::OnKeyDown(wxKeyEvent &event) else if (keyCode == WXK_LEFT) { mFocusedDigit--; - mFocusedDigit += mDigits.GetCount(); - mFocusedDigit %= mDigits.GetCount(); + mFocusedDigit += mDigits.size(); + mFocusedDigit %= mDigits.size(); Refresh(); } else if (keyCode == WXK_RIGHT) { mFocusedDigit++; - mFocusedDigit %= mDigits.GetCount(); + mFocusedDigit %= mDigits.size(); Refresh(); } @@ -1793,7 +1793,7 @@ void NumericTextCtrl::OnKeyDown(wxKeyEvent &event) } else if (keyCode == WXK_END) { - mFocusedDigit = mDigits.GetCount() - 1; + mFocusedDigit = mDigits.size() - 1; Refresh(); } @@ -1848,7 +1848,7 @@ void NumericTextCtrl::OnKeyDown(wxKeyEvent &event) void NumericTextCtrl::SetFieldFocus(int digit) { #if wxUSE_ACCESSIBILITY - if (mDigits.GetCount() == 0) + if (mDigits.size() == 0) { mFocusedDigit = 0; return; @@ -1959,7 +1959,7 @@ wxAccStatus NumericTextCtrlAx::GetChild(int childId, wxAccessible **child) // Gets the number of children. wxAccStatus NumericTextCtrlAx::GetChildCount(int *childCount) { - *childCount = mCtrl->mDigits.GetCount(); + *childCount = mCtrl->mDigits.size(); return wxACC_OK; } @@ -2051,7 +2051,7 @@ wxAccStatus NumericTextCtrlAx::GetLocation(wxRect & rect, int elementId) wxAccStatus NumericTextCtrlAx::GetName(int childId, wxString *name) { // Slightly messy trick to save us some prefixing. - NumericFieldArray & mFields = mCtrl->mFields; + std::vector & mFields = mCtrl->mFields; wxString value = mCtrl->GetString(); int field = mCtrl->GetFocusedField(); @@ -2076,7 +2076,7 @@ wxAccStatus NumericTextCtrlAx::GetName(int childId, wxString *name) // report the value of the field and the field's label. else if (mLastField != field) { wxString label = mFields[field - 1].label; - int cnt = mFields.GetCount(); + int cnt = mFields.size(); wxString decimal = wxLocale::GetInfo(wxLOCALE_DECIMAL_POINT, wxLOCALE_CAT_NUMBER); // If the NEW field is the last field, then check it to see if diff --git a/src/widgets/NumericTextCtrl.h b/src/widgets/NumericTextCtrl.h index c38cca5fb..0786b481c 100644 --- a/src/widgets/NumericTextCtrl.h +++ b/src/widgets/NumericTextCtrl.h @@ -18,7 +18,6 @@ #include "../MemoryX.h" #include #include -#include #include #include #include @@ -45,10 +44,8 @@ DECLARE_EXPORTED_EVENT_TYPE(AUDACITY_DLL_API, EVT_BANDWIDTHTEXTCTRL_UPDATED, struct BuiltinFormatString; class NumericField; -WX_DECLARE_OBJARRAY(NumericField, NumericFieldArray); class DigitInfo; -WX_DECLARE_OBJARRAY(DigitInfo, DigitInfoArray); class NumericConverter /* not final */ { @@ -119,7 +116,7 @@ protected: wxString mFormatString; - NumericFieldArray mFields; + std::vector mFields; wxString mPrefix; wxString mValueTemplate; wxString mValueMask; @@ -131,7 +128,7 @@ protected: bool mNtscDrop; int mFocusedDigit; - DigitInfoArray mDigits; + std::vector mDigits; const std::vector &mBuiltinFormatStrings; int mNBuiltins; diff --git a/src/xml/XMLWriter.h b/src/xml/XMLWriter.h index 11cb791cb..c73daef1d 100644 --- a/src/xml/XMLWriter.h +++ b/src/xml/XMLWriter.h @@ -11,7 +11,6 @@ #define __AUDACITY_XML_XML_FILE_WRITER__ #include -#include #include #include "../FileException.h"