void AmControlChangeDataView::GetPreferredSize(float *width, float *height)
{
	*width = 0;
	int32		pref;
	if (AmPrefs().GetFactoryInt32(FactorySignature().String(), ViewName().String(),
							AM_HEIGHT_PREF_STR, &pref) != B_OK)
		pref = AM_MIN_FAC_VIEW_HEIGHT - 1;
	if (pref < AM_MIN_FAC_VIEW_HEIGHT) *height = PREFERRED_HEIGHT;
	else *height = float(pref);
}
// Assumes pt1 and pt2 have been set properly.
void AmControlChangeDataView::DrawEvent(BView* view, const AmPhraseEvent& topPhrase,
										const AmEvent* event, AmRange eventRange, int32 properties)
{
	if ( (event->Type() == event->CONTROLCHANGE_TYPE)
			&& (((AmControlChange*)event)->ControlNumber() == mCc) ) {

		// Set the properties for the note
		if (properties&ARPEVENT_PRIMARY)
			view->SetHighColor(EventColor() );
		else if (properties&ARPEVENT_SHADOW)
			view->SetHighColor( AmPrefs().ShadowColor() );
		else
			view->SetHighColor( AmPrefs().SelectedColor() );

		mPt1.x = mPt2.x = mMtc.TickToPixel(eventRange.start);

		mPt1.y = abs((int)(mPt2.y - (mScale * ((AmControlChange*)event)->ControlValue())));
		if (mPt1.y < 0) mPt1.y = 0;

		// FIX: should do a lineArray thing!  Cool!
		view->StrokeLine(mPt1, mPt2);
	}
}
void AmTrackDataView::DrawTrack(const AmTrack* track,
								BRect clip,
								BView* view,
								int32 properties,
								AmSelectionsI* selections)
{
	AmTime		start = mMtc.PixelToTick(clip.left - 2);
	AmTime		end = mMtc.PixelToTick(clip.right + 2);
	AmNode*		n = track->Phrases().HeadNode();
	while (n && n->Event() && n->StartTime() <= end) {
		if (n->EndTime() >= start) {
			if (n->Event()->Type() == n->Event()->PHRASE_TYPE) {
				AmPhraseEvent*	pe = dynamic_cast<AmPhraseEvent*>( n->Event() );
				if (pe && pe->Phrase() ) {
					mEventColor = pe->Phrase()->Color(AmPhrase::FOREGROUND_C);
					mix_in(mEventColor, AmPrefs().Color(AM_DATA_BG_C), 0.75, mLowEventColor);
					DrawPhrase(clip, view, track->Id(), *pe, pe, start, end, properties, selections);
				}
			}
		}
		n = n->next;
	}
}
void AmControlChangeInfoView::ControlActivated(int32 code)
{
	if (!mCachedControlMenu) return;

	int32		pref;
	if (AmPrefs().GetFactoryInt32(mFactorySignature.String(), mViewName.String(),
							RUN_REPORT_PREF, &pref) != B_OK)
		pref = 0;
	if (pref == 0) {
		mCachedControlMenu->RunReport(0);
		return;
	}
	
	// READ TRACK BLOCK
	#ifdef AM_TRACE_LOCKS
	printf("AmControlChangeInfoView::ControlActivated() read lock\n"); fflush(stdout);
	#endif
	const AmSong*	song = mSongRef.ReadLock();
	const AmTrack*	track = song ? song->Track(mTrackWinProps.OrderedTrackAt(0)) : NULL;
	if (track) mCachedControlMenu->RunReport(track);
	mSongRef.ReadUnlock(song);
	// END READ TRACK BLOCK	
}