Array of subclassed Component

Hi - Just getting started on using the Juce framework…

Having trouble with Array::add() because I read classes subclassed from Component shouldn’t have a copy constructor…

So we have:

[code]class CTrackComponent : public Component
CTrackComponent ();

//[UserMethods]     -- You can add your own custom methods in this section.


//[UserVariables] – You can add your own custom variables in this section.



// (prevent copy constructor and operator= being generated..)
CTrackComponent (const CTrackComponent&);
const CTrackComponent& operator= (const CTrackComponent&);


If I now have:

[code]class PsplayerAudioProcessorEditor : public AudioProcessorEditor,
public Timer
PsplayerAudioProcessorEditor (PsplayerAudioProcessor* ownerFilter);


void timerCallback();
void resized();

// This is just a standard Juce paint method...
void paint (Graphics& g);

Label infoLabel;

ScopedPointer<CTrackComponent> pTrack;

ScopedPointer<CTrackComponent> pTrack2;

Array<CTrackComponent> TrackArry;

AudioPlayHead::CurrentPositionInfo lastDisplayedPosition;

PsplayerAudioProcessor* getProcessor() const
    return static_cast <PsplayerAudioProcessor*> (getAudioProcessor());

void displayPositionInfo (const AudioPlayHead::CurrentPositionInfo& pos);



[code]PsplayerAudioProcessorEditor::PsplayerAudioProcessorEditor (PsplayerAudioProcessor* ownerFilter)
: AudioProcessorEditor (ownerFilter),
infoLabel (String::empty)
// This is where our plugin’s editor size is set.
setSize (960, 610);

File szBackgroundImagePath("/Users/railrogut/juce projects/xxxxx/resources/MainBackground.png");

backgroundImage = ImageFileFormat::loadFrom(szBackgroundImagePath);

// add a label that will display the current timecode and status..

addAndMakeVisible (&infoLabel);
infoLabel.setColour (Label::textColourId, Colours::blue);

pTrack = 0;

pTrack2 = 0;

pTrack = new CTrackComponent();
pTrack2 = new CTrackComponent();

if (pTrack)
    pTrack->setTopLeftPosition(5, 84);

if (pTrack2)
    pTrack2->setTopLeftPosition(82, 84);

pTrack->setSize(75, 521);

pTrack2->setSize(75, 521);

// TrackArry.add(*pTrack);



the above works… but now if I try and make my CTrackComponent an Array and uncomment:

// TrackArry.add(*pTrack);

(or use the Array add() method on a Constructor derived object) I get a problem because the add() method attempts to call a copy constructor for CTrackComponent and gives a compile error “Calling a private constructor of class CTrackComponent”.

I know I read in the docs somewhere that if you subclass Component you shouldn’t have a copy constructor as it’ll cause problems…

So the question is (finally)… what’s the suggested methodology to create an Array of Components (or their derivatives)?




Thank you sir!

For some reason at 5am this morning I missed that.

Just tested - and works perfect!