#include "ScrollingPane.h"

#if GS_MAC_CFM
	#include <UTextTraits.h>
	#include <ToolUtils.h> // for LoWord and HiWord
	#include <Fonts.h>
	#include <Sound.h>
#endif

#include <LView.h>
#include <LStdControl.h>
#include <UDrawingState.h>
#include <GSString.h>
#include <MiniCadCallbacks.h>



CMCListView::CMCListView(LStream *inStream) :
	LView(inStream),
	kBorder(20)
{
	fSizeIsSet = false;
}


CMCListView* CMCListView::CreateMCListViewStream(LStream *inStream)
{
	return new CMCListView(inStream);
}



void CMCListView::ListenToMessage(MessageT inMessage, void *ioParam)
{
	switch(inMessage) {
		case 'Zoom': {
			long selection = *(long*)ioParam;
			
			switch (selection) {
				case 1: {
					SysBeep(10);
					break;
				}
				case 2: {
					SysBeep(10);
					SysBeep(10);
					break;
				}
				default: {
					SysBeep(10);
					SysBeep(10);
					SysBeep(10);
					break;
				}
				
			}
			
			// force recalculation of pane size
			fSizeIsSet = false;

			
			// we want to refresh the superview so the scroll bars will be drawn correctly
			LView* v = GetSuperView();
			if (v)
				v->Refresh();
			
			
			break;
		}
	}
}




void CMCListView::SpendTime(const EventRecord& /*theEvent*/)
{


}



///////////////////
// LView function allowing us to draw our content

void CMCListView::DrawSelf()
{
	TextTraitsRecord labelText;
	UTextTraits::LoadSystemTraits(labelText);
	StClipRgnState saveClip;
	
	labelText.size = 48;
	labelText.fontNumber = applFont;
	
	UTextTraits::SetPortTextTraits(&labelText);
	
	
	Rect myFrame;
	CalcLocalFrameRect(myFrame);
	
	PStr255 tdStr;
	
	SPoint32 imageLocation;
	Point textPoint;
	
	imageLocation.h = 10;
	imageLocation.v = 150;
	
	ImageToLocalPoint(imageLocation, textPoint);
	
	saveClip.ClipToIntersection(myFrame);
	
	tdStr << "WOAH!";

	::MoveTo(textPoint.h, textPoint.v);
	::DrawString(tdStr);
	
	
	// set image size
	if (!fSizeIsSet) {
		ResizeImageTo(1000, 1000, true);
		fSizeIsSet = true;
	}
	
}



