/* TrackView.h */

#ifndef Included_TrackView_h
#define Included_TrackView_h

/* TrackView module depends on */
/* MiscInfo.h */
/* Audit */
/* Debug */
/* Definitions */
/* Screen */
/* TrackObject */
/* Memory */
/* FrameObject */
/* Frequency */
/* EditImages */
/* NoteObject */
/* StaffCalibration */
/* TrackDisplayScheduling */
/* Array */
/* EditCommandParameters */
/* Numbers */
/* TieTrackPixel */
/* EventLoop */
/* Scrap */
/* Files */
/* BufferedFileInput */
/* BufferedFileOutput */
/* DataMunging */
/* MainWindowStuff */
/* LoadSaveNoteVectors */
/* Alert */

#include "NoteObject.h"
#include "Screen.h"
#include "EventLoop.h"

struct TrackViewRec;
typedef struct TrackViewRec TrackViewRec;

/* forward declarations */
struct TrackObjectRec;

/* create a new track view object */
TrackViewRec*						NewTrackView(struct TrackObjectRec* TrackObj, WinType* Window,
													OrdType X, OrdType Y, OrdType Width, OrdType Height);

/* dispose of the track view object */
void										DisposeTrackView(TrackViewRec* View);

/* get the left edge of the track view area */
OrdType									GetTrackViewXLoc(TrackViewRec* View);

/* get the top edge of the track view area */
OrdType									GetTrackViewYLoc(TrackViewRec* View);

/* get the width of the track view area */
OrdType									GetTrackViewWidth(TrackViewRec* View);

/* get the height of the track view area */
OrdType									GetTrackViewHeight(TrackViewRec* View);

/* change the location of the track view area */
void										SetTrackViewPosition(TrackViewRec* View, OrdType X, OrdType Y,
													OrdType Width, OrdType Height);

/* redraw the track view staff bars.  it assumes clipping rectangle has been */
/* properly set up.  XStart is in window coordinates, not track view area coordinates. */
void										TrackViewRedrawStaff(TrackViewRec* View, OrdType XStart,
													OrdType Width);

/* redraw the whole track view, but don't mess with the clipping region.  XStart is */
/* is in window coordinates, not local coordinates */
void										TrackViewRedrawDontSetClip(TrackViewRec* View, OrdType XStart,
													OrdType Width);

/* redraw the entire track view, including properly setting the clipping region. */
void										TrackViewRedrawAll(TrackViewRec* View);

/* get the number of vertical degrees of freedom, for setting the vertical scroll bar */
long										TrackViewGetVerticalDegreesOfFreedom(TrackViewRec* View);

/* get the vertical offset for setting vertical scroll bar.  0 is top of score area. */
long										TrackViewGetVerticalOffset(TrackViewRec* View);

/* change the vertical offset and redraw the track view area */
void										TrackViewSetNewVerticalOffset(TrackViewRec* View, long Offset);

/* hit test to see if the coordinates are within the track view area */
MyBoolean								TrackViewHitTest(TrackViewRec* View, OrdType X, OrdType Y);

/* update the cursor and optionally draw the vertical (pitch) positioning bar */
void										TrackViewUpdateMouseCursor(TrackViewRec* View,
													OrdType X, OrdType Y, MyBoolean DrawFunnyBarThing);

/* the track data has been modified, so set some flags */
void										TrackViewTrackObjectModified(TrackViewRec* View,
													struct TrackObjectRec* TrackObj, long Index);

/* another track has been deleted, so remove it from the background list */
void										TrackViewObjectTrackDying(TrackViewRec* View,
													struct TrackObjectRec* TrackObj);

/* insert a note at the specified mouse coordinate with the attributes */
void										TrackViewAddNote(TrackViewRec* View,
													OrdType X, OrdType Y, unsigned long NoteAttributes);

/* add a command at the specified mouse coordinates. */
void										TrackViewAddCommand(TrackViewRec* View,
													OrdType X, OrdType Y, NoteCommands CommandOpcode);

/* erase the vertical (pitch) positioning bar */
void										TrackViewUndrawCursorBar(TrackViewRec* View);

/* draw the vertical (pitch) positioning bar.  this assumes that it has been */
/* previously undrawn (i.e. it doesn't erase any existing bars) */
void										TrackViewDrawCursorBar(TrackViewRec* View);

/* get the horizontal offset from the start of the track, in pixels */
long										TrackViewGetHorizontalOffset(TrackViewRec* View);

/* get the horizontal extent of the track (in pixels) for setting the scroll bar */
long										TrackViewGetHorizontalDegreesOfFreedom(TrackViewRec* View);

/* change the horizontal position of the track display and redraw */
void										TrackViewSetNewHorizontalOffset(TrackViewRec* View, long Offset);

/* try to select a single note, if there is one, at the specified mouse location */
void										TrackViewTrySingleNoteSelection(TrackViewRec* View,
													OrdType X, OrdType Y);

/* is the current selection a single note? */
MyBoolean								TrackViewIsASingleNoteSelected(TrackViewRec* View);

/* is the current selection a single command? */
MyBoolean								TrackViewIsASingleCommandSelected(TrackViewRec* View);

/* is a range of frames selected? */
MyBoolean								TrackViewIsARangeSelected(TrackViewRec* View);

/* is nothing selected, and thus there is an insertion point? */
MyBoolean								TrackViewIsThereInsertionPoint(TrackViewRec* View);

/* get the frame index of the insertion point.  it is an error if there is no */
/* valid insertion point */
long										TrackViewGetInsertionPointIndex(TrackViewRec* View);

/* get the beginning of a selection range.  it is an error if a range is not selected */
long										TrackViewGetRangeStart(TrackViewRec* View);

/* get the frame after the end of a selection range.  it is an error if there is */
/* no selected range. */
long										TrackViewGetRangeEndPlusOne(TrackViewRec* View);

/* get the frame number of a single note or command selection */
long										TrackViewGetSingleNoteSelectionFrameNumber(TrackViewRec* View);

/* delete the selected single note or command.  it is an error if no single note */
/* or command is selected */
void										TrackViewDeleteSingleNoteOrCommand(TrackViewRec* View);

/* add a track to the greyed-out background display */
MyBoolean								TrackViewAddBackgroundTrack(TrackViewRec* View,
													struct TrackObjectRec* TrackObj);

/* remove a track from the greyed-out background display */
void										TrackViewRemoveBackgroundTrack(TrackViewRec* View,
													struct TrackObjectRec* TrackObj);

/* present a dialog box for editing the selected object's attributes.  it is an */
/* error if there is no single note or command selected. */
void										TrackViewEditSingleSelectionAttributes(TrackViewRec* View);

/* set a tie from the currently selected note to the note at the specified position. */
/* it is an error if there is no single note selected. */
void										TrackViewSetTieOnNote(TrackViewRec* View, OrdType X, OrdType Y);

/* select a range of frames. */
void										TrackViewSetRangeSelection(TrackViewRec* View, long StartFrame,
													long EndFramePlusOne);

/* set an insertion point at the specified frame index */
void										TrackViewSetInsertionPoint(TrackViewRec* View, long FrameIndex);

/* do a mouse down, which may select things.  ExtendSelection is true for shift-key */
/* type selection extending */
void										TrackViewDoMouseDown(TrackViewRec* View, OrdType XLoc,
													OrdType YLoc, MyBoolean ExtendSelection,
													void (*ScrollCallback)(void* Refcon), void* Refcon);

/* set the range selection to the entire track */
void										TrackViewSelectAll(TrackViewRec* View);

/* delete the selected range.  it is an error if there is no selected range. it */
/* returns False if it fails.  undo information is automatically maintained */
MyBoolean								TrackViewDeleteRangeSelection(TrackViewRec* View);

/* attempt to paste notes into the track.  returns False if it fails.  undo */
/* information is automatically maintained. */
MyBoolean								TrackViewAttemptPaste(TrackViewRec* View);

/* copy the selected range to the clipboard.  it is an error if there is no selected */
/* range.  it returns True if successful. */
MyBoolean								TrackViewCopyRangeSelection(TrackViewRec* View);

/* cut the range selection (copy to clipboard, then delete).  returns True if */
/* successful.  it is an error if there is no range selected.  automatically */
/* updates undo information. */
MyBoolean								TrackViewCutRangeSelection(TrackViewRec* View);

/* show the selection or insertion point by scrolling the view area */
void										TrackViewShowSelection(TrackViewRec* View);

/* find out if we can undo the last operation */
MyBoolean								TrackViewCanWeUndo(TrackViewRec* View);

/* dispose of all undo information. */
void										TrackViewFlushUndoInfo(TrackViewRec* View);

/* save the undo information for the track.  returns False if it fails. */
MyBoolean								TrackViewBuildFullUndoBackingStore(TrackViewRec* View);

/* undo the last operation.  if it fails, well... */
void										TrackViewUndo(TrackViewRec* View);

/* transpose the selection by adding AddHalfSteps to the pitch of each selected note */
/* AddHalfSteps can be negative.  it is an error if there is no single note selection */
/* or no range selection */
void										TrackViewTransposeSelection(TrackViewRec* View, long AddHalfSteps);

/* scroll to the specified measure.  invalid measure numbers may be specified. */
void										TrackViewShowMeasure(TrackViewRec* View, long MeasureNumber);

#endif
