/* SampleList.h */

#ifndef Included_SampleList_h
#define Included_SampleList_h

/* SampleList module depends on */
/* MiscInfo.h */
/* Audit */
/* Debug */
/* Definitions */
/* Screen */
/* EventLoop */
/* Memory */
/* StringList */
/* Array */
/* SampleObject */
/* Alert */
/* DataMunging */
/* PcodeSystem */
/* SampleConsts */
/* FixedPoint */
/* MainWindowStuff */
/* BufferedFileInput */
/* BufferedFileOutput */
/* Files */
/* Scrap */

#include "Screen.h"
#include "EventLoop.h"
#include "SampleConsts.h"
#include "FixedPoint.h"
#include "MainWindowStuff.h"

struct SampleListRec;
typedef struct SampleListRec SampleListRec;

/* forward declarations */
struct MainWindowRec;
struct CodeCenterRec;
struct SampleObjectRec;
struct BufferedInputRec;
struct BufferedOutputRec;
struct FileType;

/* create a new sample list */
SampleListRec*			NewSampleList(struct MainWindowRec* MainWindow,
											struct CodeCenterRec* CodeCenter, WinType* ScreenID,
											OrdType XLoc, OrdType YLoc, OrdType Width, OrdType Height);

/* delete the sample list and all of the samples it contains */
void								DisposeSampleList(SampleListRec* SampList);

/* change the location of the sample list in the window */
void								SetSampleListLocation(SampleListRec* SampList,
											OrdType XLoc, OrdType YLoc, OrdType Width, OrdType Height);

/* redraw the list */
void								SampleListRedraw(SampleListRec* SampList);

/* see if the specified coordinates falls inside the sample list rectangle */
MyBoolean						SampleListHitTest(SampleListRec* SampList,
											OrdType XLoc, OrdType YLoc);

/* handle a mouse down event for the sample list */
void								SampleListDoMouseDown(SampleListRec* SampList, OrdType XLoc,
											OrdType YLoc, ModifierFlags Modifiers);

/* called when the window becomes active */
void								SampleListBecomeActive(SampleListRec* SampList);

/* called when the window becomes inactive */
void								SampleListBecomeInactive(SampleListRec* SampList);

/* called when a selection is made in another list, so that this list */
/* is deselected */
void								SampleListDeselect(SampleListRec* SampList);

/* check to see if there is a selection in this list */
MyBoolean						SampleListIsThereSelection(SampleListRec* SampList);

/* check to see if any of the samples contained in this list need to be saved */
MyBoolean						DoesSampleListNeedToBeSaved(SampleListRec* SampList);

/* open an edit window for the selected sample */
void								SampleListOpenSelection(SampleListRec* SampList);

/* create a new sample and open a window for it */
void								SampleListNewSample(SampleListRec* SampList);

/* delete the selected sample */
void								SampleListDeleteSelection(SampleListRec* SampList);

/* delete the explicitly specified sample */
void								SampleListDeleteSample(SampleListRec* SampList,
											struct SampleObjectRec* TheSample);

/* the name of a sample has changed, so the name in the scrolling */
/* list must also be changed */
void								SampleListSampleNameChanged(SampleListRec* SampList,
											struct SampleObjectRec* TheSample);

/* look for a specified sample.  returns NIL if not found.  the name is NOT null */
/* terminated */
struct SampleObjectRec*	SampleListLookupNamedSample(SampleListRec* SampList, char* Name);

/* obtain large fixedpoint data for samples.  returns the error code defined */
/* in SampleConsts.  the name is NOT null terminated */
SampleErrors				SampleListGetSampleLeftFixed(SampleListRec* SampList,
											char* Name, largefixedsigned** DataOut);
SampleErrors				SampleListGetSampleRightFixed(SampleListRec* SampList,
											char* Name, largefixedsigned** DataOut);
SampleErrors				SampleListGetSampleMonoFixed(SampleListRec* SampList,
											char* Name, largefixedsigned** DataOut);

/* use the provided data to open a new sample with the specified attributes. */
/* this is used when opening an algorithmic sample as a data sample. */
/* RawData MUST be valid. */
struct SampleObjectRec*	SampleListCopyRawSampleAndOpen(SampleListRec* SampList,
											char* RawData, NumBitsType NumBits, NumChannelsType NumChannels,
											long Origin, long LoopStart1, long LoopStart2, long LoopStart3,
											long LoopEnd1, long LoopEnd2, long LoopEnd3, long SamplingRate,
											double NaturalFrequency);

/* the document's name has changed, so the windows have to be updated */
void								SampleListGlobalNameChange(SampleListRec* SampleList,
											char* NewFilename);

/* read sample objects from a file.  returns True if fully successful. */
FileLoadingErrors		SampleListReadData(SampleListRec* SampleList,
											struct BufferedInputRec* Input);

/* write sample objects to a file.  returns True if fully successful. */
FileLoadingErrors		SampleListWriteData(SampleListRec* SampleList,
											struct BufferedOutputRec* Output);

/* after a file has been saved, this is called to mark all objects as not modified. */
void								SampleListMarkAllObjectsSaved(SampleListRec* SampleList);

/* copy the selected object in the list to the clipboard.  return False if failed. */
MyBoolean						SampleListCopyObject(SampleListRec* SampleList);

/* try to paste the clipboard in as a sample object.  returns False if it failed */
/* or the clipboard did not contain a sample object. */
MyBoolean						SampleListPasteObject(SampleListRec* SampleList);

/* paste a sample object in from the file */
MyBoolean						SampleListPasteFromFile(SampleListRec* SampleList,
											struct FileType* File);

/* find out how many samples there are in this list */
long								SampleListHowMany(SampleListRec* SampleList);

/* get an indexed sample from the list */
struct SampleObjectRec*	SampleListGetIndexedSample(SampleListRec* SampleList, long Index);

#endif
