/* WaveTableWindow.h */

#ifndef Included_WaveTableWindow_h
#define Included_WaveTableWindow_h

/* WaveTableWindow module depends on */
/* MiscInfo.h */
/* Audit */
/* Debug */
/* Definitions */
/* MainWindowStuff */
/* CodeCenter */
/* WaveTableList */
/* Screen */
/* Menus */
/* EventLoop */
/* TextEdit */
/* IconButton */
/* Scroll */
/* SimpleButton */
/* SampleView */
/* WindowDispatcher */
/* WaveTableObject */
/* Memory */
/* Numbers */
/* SampleConsts */
/* Array */
/* DataMunging */
/* EditImages */
/* GrowIcon */
/* Main */
/* StringDialog */
/* FindDialog */
/* GlobalWindowMenuList */
/* WaveTableStorage */
/* WaveTableStorageDisplay */
/* SoundOutput */
/* Alert */
/* NumberDialog */
/* WaveTableSizeDialog */
/* CompilerRoot */
/* PcodeObject */
/* PcodeStack */
/* PcodeSystem */
/* FunctionCode */
/* FixedPoint */

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

struct WaveTableWindowRec;
typedef struct WaveTableWindowRec WaveTableWindowRec;

/* forward declarations */
struct MainWindowRec;
struct WaveTableObjectRec;
struct CodeCenterRec;
struct WaveTableListRec;
struct WaveTableStorageRec;

/* create a new wave table window. */
WaveTableWindowRec*	NewWaveTableWindow(struct MainWindowRec* MainWindow,
											struct WaveTableObjectRec* WaveTableObject,
											struct CodeCenterRec* CodeCenter,
											struct WaveTableListRec* WaveTableList,
											struct WaveTableStorageRec* WaveData,
											OrdType WinX, OrdType WinY, OrdType WinWidth, OrdType WinHeight);

/* write back modified data and dispose of the wave table window */
void								DisposeWaveTableWindow(WaveTableWindowRec* Window);

/* return True if the data has been modified since the last time the file was saved */
MyBoolean						HasWaveTableWindowBeenModified(WaveTableWindowRec* Window);

/* bring the window to the top and give it the focus */
void								WaveTableWindowBringToTop(WaveTableWindowRec* Window);

/* event handling routines */
void								WaveTableWindowDoIdle(WaveTableWindowRec* Window,
											MyBoolean CheckCursorFlag, OrdType XLoc, OrdType YLoc,
											ModifierFlags Modifiers);
void								WaveTableWindowBecomeActive(WaveTableWindowRec* Window);
void								WaveTableWindowBecomeInactive(WaveTableWindowRec* Window);
void								WaveTableWindowJustResized(WaveTableWindowRec* Window);
void								WaveTableWindowDoMouseDown(OrdType XLoc, OrdType YLoc,
											ModifierFlags Modifiers, WaveTableWindowRec* Window);
void								WaveTableWindowDoKeyDown(unsigned char KeyCode,
											ModifierFlags Modifiers, WaveTableWindowRec* Window);
void								WaveTableWindowClose(WaveTableWindowRec* Window);
void								WaveTableWindowUpdator(WaveTableWindowRec* Window);
void								WaveTableWindowMenuSetup(WaveTableWindowRec* Window);
void								WaveTableWindowDoMenuCommand(WaveTableWindowRec* Window,
											MenuItemType* MenuItem);

/* get a copy of the wave table's name */
char*								WaveTableWindowGetNameCopy(WaveTableWindowRec* Window);

/* get a copy of the wave table's formula */
char*								WaveTableWindowGetFormulaCopy(WaveTableWindowRec* Window);

/* get the number of bits used for the wave table */
NumBitsType					WaveTableWindowGetNumBits(WaveTableWindowRec* Window);

/* get the number of periods in the wave table */
long								WaveTableWindowGetNumTables(WaveTableWindowRec* Window);

/* get the number of frames in each period of the wave table */
long								WaveTableWindowGetNumFramesPerTable(WaveTableWindowRec* Window);

/* get the pitch at which the wave table should be tested */
double							WaveTableWindowGetPitch(WaveTableWindowRec* Window);

/* get the duration (seconds) for the increasing table index phase of the test */
double							WaveTableWindowGetAscendingDuration(WaveTableWindowRec* Window);

/* get the duration (seconds) for the decreasing table index phase of the test */
double							WaveTableWindowGetDescendingDuration(WaveTableWindowRec* Window);

/* get the sampling rate to use for the test */
long								WaveTableWindowGetTestSamplingRate(WaveTableWindowRec* Window);

/* reset the scroll bar indices and redraw it */
void								WaveTableWindowUpdateScrollBar(WaveTableWindowRec* Window);

/* redraw the wave table waveform box */
void								WaveTableWindowRedrawTable(WaveTableWindowRec* Window);

/* the name of the file has changed, so change the title bar.  the string is a */
/* non-null-terminated, and the caller is responsible for disposing of it */
void								WaveTableWindowGlobalNameChange(WaveTableWindowRec* Window,
											char* NewFilename);

/* reset the title bar name even if the document name hasn't changed */
void								WaveTableWindowResetTitlebar(WaveTableWindowRec* Window);

/* set the number of periods to that stored in the edit box, and interpolate */
/* the periods. */
void								WaveTableWindowSetNewNumTables(WaveTableWindowRec* Window);

/* set the number of periods edit box to be the same as the data */
void								WaveTableWindowUpdateTableCountEdit(WaveTableWindowRec* Window);

/* set the number of frames edit box to be the same as the data */
void								WaveTableWindowUpdateFrameCountEdit(WaveTableWindowRec* Window);

/* set all edit boxes to be the same as the underlying data */
void								WaveTableWindowUpdateAllParameters(WaveTableWindowRec* Window);

/* give a dialog box asking for a new number of frames, and then interpolate all */
/* of the wave periods. */
void								WaveTableWindowSetNewNumFrames(WaveTableWindowRec* Window);

/* evaluate the wave formula and update the wave data */
void								WaveTableWindowEvaluateFunction(WaveTableWindowRec* Window);

/* get a copy of the wave data array */
largefixedsigned*		WaveTableWindowGetWaveArray(WaveTableWindowRec* Window);

/* force the wave data to be written back to the object.  this does not write back */
/* any other data. */
MyBoolean						WaveTableWindowForceWaveTableUpdate(WaveTableWindowRec* Window);

/* force all data to be written back to the object.  this includes calling */
/* WaveTableWindowForceWaveTableUpdate() */
MyBoolean						WaveTableWindowWritebackModifiedData(WaveTableWindowRec* Window);

#endif
