#ifndef FOXCONSOLE
   #include "FoxInclude:foxconsole.h"
#endif

#include <stdio.h>
#include <utility/tagitem.h>
#include <intuition/intuition.h>

// Screens
#define GS_PUBLIC				1
#define GS_AUTOSCROLL		2
#define GS_DISPLAY_ID		4
#define GS_OVERSCAN			8
#define GS_PENS				16
#define GS_INTERLACE			32

// Windows
#define GW_DRAG				1
#ifdef OLD_LISTS
#define LIST_UPDATE_OFF		0
#define LINE_SCROLL			2
#define PAGE_SCROLL			4
#define LIST_UPDATE_ON		8
#endif
#define GW_CONSOLE			16
#define GW_DEPTH				32
#define GW_CLOSE				64
#define GW_BORDERLESS		128
#define GW_SIZE				256
#define GW_DROP				512

#define ASCENDING				1
#define DESCENDING			2
#define NUM_ASCENDING		4
#define NUM_DESCENDING		8
#define IGNORE_CASE			16

#define GUI_MODAL_END	2
#define GUI_END			1
#define GUI_CONTINUE		0

// For all controls (but not windows)
#define S_AUTO_SIZE		128

// Edit boxes
#define TEXT_EDIT			0
#define INT_EDIT			1
#define FLOAT_EDIT		2
#define NO_EDIT			4
#define EB_CLEAR			8

// Drop-down list boxes
#define DD_CLEAR			EB_CLEAR

// Edit boxes and output boxes
#define THREED				64
//      S_AUTO_SIZE		128

// Output boxes
#define NO_BORDER			1
#define JUSTIFY_LEFT		2
#define JUSTIFY_CENTRE	4
#define JUSTIFY_RIGHT	8

// List Boxes
#define LB_CLIPPED		1     // Set if ListBoxClipOn() has been called with no matching ListBoxClipOff()
#define SYS_LB_VSCROLL	2
#define LB_DBLCLICK		4
#define LB_DRAG			8
#define LB_DRAGIMAGE		16
#define LB_DROP			32
#define SYS_LB_HSCROLL	64
//      S_AUTO_SIZE		128

// Tick boxes/Radio buttons
#define BG_CLEAR				1
#define BG_CAPTION_LEFT		16
#define BG_CAPTION_RIGHT	32
#define BG_SELECTED			64
//      S_AUTO_SIZE			128

// Buttons
#define BN_STD				0		/* Standard button    */
#define BN_CLEAR			1
#define BN_AR				2		/* Auto repeat button */
#define BN_CANCEL			4		// A Cancel button can be activated by pressing the escape key.
#define BN_OKAY			8		// An Okay button can be activated by pressing the return key.
#define SYS_BN_ROUNDED	64
//      S_AUTO_SIZE		128
#define SYS_BN_HIDDEN	256

// Images
#define BM_STUPID			0 // Opposite of BM_SMART
#define BM_OVERLAY		1
#define BM_SCALE			2
#define BM_CLIP			4
#define BM_SMART			8

// Frames
#define FM_CLEAR			BN_CLEAR
#define FM_LBUT			2
#define FM_RBUT			4
#define FM_DRAG			8
#define FM_DRAGIMAGE		16
#define FM_DROP			32
//      S_AUTO_SIZE		128

// Tab controls
#define TC_CLEAR			FM_CLEAR

// Timers
#define TM_SECOND			1
#define TM_MINUTE			2

// Misc.
#define FAST_MALLOCS		1
#define GM_YES				1
#define GM_OKAY			1
#define GM_NO				2
#define GM_CANCEL			4

// Progress bars
#define PB_RAISED						0
#define PB_INSET						1
#define PB_CAPTION_CENTRE			2
#define PB_CAPTION_TOP_LEFT		4
#define PB_CAPTION_BOTTOM_LEFT	8
#define PB_CAPTION_TOP_RIGHT		0
#define PB_CAPTION_BOTTOM_RIGHT	16
#define PB_FILL_LR					0
#define PB_FILL_BT					32
//      S_AUTO_SIZE					128


#define WinPrint(w,str)         ConPrint((w)->Con,str)
#define WinTab(w,x,y)           ConTab((w)->Con,x,y)
#define WinPrintTab(w,x,y,str)  ConPrintTab((w)->Con,x,y,str)
#define WinPrintHi(w,str)       ConPrintHi((w)->Con,str,(w)->HighCol)
#define WinPrintCol(w,str,col)  ConPrintHi((w)->Con,str,col)
#define WinShowCursor(w)        ConShowCursor((w)->Con)
#define WinHideCursor(w)        ConHideCursor((w)->Con)
#define WinClear(w)             ConClear((w)->Con)
#define WinHome(w)              ConHome((w)->Con)
#define WinBlankToEOL(w)        ConBlankToEOL((w)->Con)
#define WinWrapOn(w)            ConWrapOn((w)->Con)
#define WinWrapOff(w)           ConWrapOff((w)->Con)
#define SetDDListBoxText(l,c)   SetEditBoxText(l,c)
#define GetDDListBoxText(l)     GetEditBoxText(l)
#define GetEditBoxID(p)         (p)->id
#define GetDDListBoxID(l)       (l)->id
#define GetOutputBoxID(o)       (o)->id

#define GuiFree(p)              GuiFreeMem(p,__LINE__,__FILE__)

#ifdef FOXGUI
   #define EXT
#else
   #define EXT extern
#endif

#define NUM_WB_PENS 12

typedef struct GuiScrStruct
   {
	char   *ObjectType; // Do not move this item!  It must be first to match other controls.
   struct Screen    *scr;
   struct ExtNewScreen *nsc;
	struct TagItem *Screen_Tags;
	char   *PubName;
	UWORD  Pens[NUM_WB_PENS + 1];
	int    (*LastWinFn)(struct GuiScrStruct *);
	BYTE   LastWinSig;
	struct GuiScrStruct *NextScr;
   } GuiScreen;

struct ListElement
   {
   int						Itemnum;
   char						*string;
   struct ListElement	*Next;
   struct EditBoxStruct	*Child;
   };

typedef struct GWS
   {
	char              *ObjectType; // Do not move this item!  It must be first to match other controls.
   GuiScreen			*ParentGuiScr;
	/*	Normally, we could get to the screen structure via the GuiScreen structure (i.e.
		win->ParentGuiScr->scr) but in the case of a window opened on another applications public screen,
		the ParentGuiScr will be NULL so we need another handle directly onto the Screen structure, hence
		ParentScreen below. */
	/* Actually we don't need it at all because we can get it from the Window structure
		(gw->Win->WScreen) but never mind! */
	struct Screen		*ParentScreen;
   struct Console		*Con;
   struct Window		*Win;
   struct NewWindow	NewWin;
   unsigned long		ConReadSig, WindowSig;
   int					HighCol;
	int					(*DropFn)(struct GWS*, int x, int y, void*);
	int					(*MenuFn)(struct GWS*, struct MenuItem*);
	int					(*CloseFn)(struct GWS*); // fn to call if the close gadget (if present) is clicked.
	BOOL					Enabled, Sleep, OldStatus, SysStatus;
   struct GWS			*next, *previous;
	struct Menu			*FirstMenu;
	struct Requester	Request;

#ifdef OLD_LISTS
	struct Gadget		*ScrollGad, *ScrollUpGad, *ScrollDownGad;
	struct PropInfo	*ScrollGadInfo;
	struct Image		*ScrollGadImage;
	struct Border		*uparrow, *downarrow, *suparrow, *sdownarrow;
#endif
   } GuiWindow;

typedef struct TabStopStruct
	{
	int tab;
	struct TabStopStruct *Next;
	} TabStop;

typedef struct IntuiText ListBoxItem;

typedef struct
	{
	int left, top, width, height;
	} OriginalSize;

typedef struct
	{
	short points[20];
	struct Border DarkBorder, LightBorder;
	struct PB *ScrollUp, *ScrollDown;
	struct Gadget ScrollGad;
	struct PropInfo ScrollGadInfo;
	struct Image ScrollGadImage;
	} Scroller;

typedef struct ListBoxStruct
	{
	char *ObjectType; // Do not move this item!  It must be first to match other controls.
	void *Parent;
	struct GWS *Win;
	struct Border DarkBorder, LightBorder, UpArrow, DownArrow;
	short points[20], hidden;
	int FrontPen, flags;
	int Left, Top, Width, Height, xOffset;
	int LBorder, TBorder;
	int NoItems, NoTitles;
	int MaxIntuiLen, LongestIntuiLen, TopShown;
	ListBoxItem *FirstTitle, *FirstItem, *HiItem;
	int HiNum;
	struct TextAttr *Font;
	Scroller *LR, *UD;
	OriginalSize *os;
	TabStop *FirstTabStop;
	BOOL modified; // Has the list box been modified since it was last refreshed?
	BOOL Enabled;
	struct ListBoxStruct *NextListBox;
	int (*Selfn) (struct ListBoxStruct*);
	int (*Eventfn) (struct ListBoxStruct*, short, int, void**);
	unsigned short *DragPointer;
	short PointerWidth, PointerHeight, PointerXOffset, PointerYOffset;
	void *DragData;
	} ListBox;

typedef struct GBMstruct
	{
	unsigned short width, height, depth;
	short  flags;
	struct BitMap *bm;
	struct BMIstruct *bmi; // Only used when the bitmap is on a control.  Otherwise NULL.
	struct GBMstruct *obm; // Points to the original bitmap when on a resizable control.  Otherwise NULL.
	struct GBMstruct *next;
	} GuiBitMap;

typedef struct BMIstruct
	{
	GuiWindow *win;
	unsigned short left, top;
	GuiBitMap *bm;
	} BitMapInstance;

typedef struct FrameStruct
	{
	// The first five items must not be moved.  They match the first five items in the PushButton struct.
	char               *ObjectType;
	struct Gadget      button;
	GuiBitMap          *bitmap;
	OriginalSize       *os;
	short              flags; // Need to keep a copy of the flags because not everything can be handled directly by the gadget.
	// Okay to move anything below this point.
	void               *Parent;
	struct IntuiText   text;
	char               *t;
	struct Border      light, dark;
	short              points[12], *cbCopy, hidden;
	int                (*Callfn) (struct FrameStruct*, short, short, short, void**);
	BOOL               Active;
	void               *ParentControl;
	unsigned short     *DragPointer;
	short              PointerWidth, PointerHeight, PointerXOffset, PointerYOffset;
	void               *DragData;
	struct FrameStruct *next;
	} Frame;

typedef struct PB
   {
	// The first five items must not be moved.  They match the first five items in the Frame struct.
	char             *ObjectType;
   struct Gadget    button;
	GuiBitMap        *bitmap;
	OriginalSize     *os;
	short            flags;
	// Okay to move anything below this point.
	void             *Parent;
   struct IntuiText text1, text2, text3;
	char             *t1, t2[2], *t3;
	struct TextAttr  *ULfont;
   struct Border    light, dark;
   struct Border    slight, sdark;
	short            points[28], *cbCopy, hidden;
   int              (*Callfn) (struct PB*);
	int              (*Filefn) (char*, char*);
   char             Key1, Key2;
   BOOL             Active, OldStatus, SysStatus;
	void             *ParentControl; // Pointer to control if the button is part of another control (eg list box or tab control)
   struct PB        *Next;
   } PushButton;

typedef struct TabStruct
	{
	Frame *frame;
	PushButton *pb;
	struct TabStruct *next;
	} Tab;

typedef struct TCStruct
	{
	char *ObjectType; // Do not move this item!  It must be first to match other controls.
	void *Parent;
	Tab *FirstTab, *SelectedTab;
	struct Border CustomFrameBorder; // The same for every tab except the points
	short FramePoints[4];
	struct TCStruct *next;
	} TabControl;

struct GuiList
   {
   int						TotalElems, Width, Height;
   BOOL						Update, ListBox;
   char						*Title1, *Title2, *Title3;
   struct ListElement	*First, *Last;
   int						TopShown, HighNum;
   };

struct DDListBoxStruct
   {
	GuiWindow				*win;
	ListBox				*nlb;
   int						MaxHeight, TotalElems;
   struct ListElement	*first;
   int						PopupWidth, PopupX, PopupY;
   struct EditBoxStruct	*Parent;
   };

typedef struct EditBoxStruct
   {
	char                 *ObjectType; // Do not move this item!  It must be first to match other controls.
   int                  len, Bcol, Tcol, x, y, type, dp, id;
	OriginalSize         *os;
   char                 *buffer;
   void						*Parent;
   BOOL                 (*valifn)(struct EditBoxStruct*);
   short                points[26], hidden;
   BOOL                 enabled, OldStatus, SysStatus;
   struct Border        lborder, dborder, arrow, bb1, bb2;
   struct EditBoxStruct *next, *previous;
   struct EditBoxStruct *NextAssociated, *PreviousAssociated;
   struct DDListBoxStruct *list;
	struct IntuiText		*PreText, *PostText;
	struct Gadget			editbox;
	struct StringInfo    strinfo;
	int						pixlen;
	char						*undobuffer;
	long						flags;
   } EditBox;

typedef struct EditBoxStruct DDListBox;

typedef struct OutputBoxStruct
   {
	char                    *ObjectType; // Do not move this item!  It must be first to match other controls.
	void							*Parent;
   GuiWindow					*win;
	int							len, Bcol, Tcol, dp, id, flags;
	OriginalSize				*os;
   short							points[20], hidden;
   struct Border				lborder, dborder;
	struct IntuiText			IText, *PreText, *PostText;
	char							*text;
	struct TextAttr			*font;
   struct OutputBoxStruct	*next, *previous;
   } OutputBox;

struct MutexList
	{
	struct RBStruct *Mutex;
	struct MutexList *Next;
	};

typedef struct RBStruct
	{
	char *ObjectType; // Do not move this item!  It must be first to match other controls.
	void *Parent;
	short BevelPoints[20], hidden;
	struct Border BLight, BDark, sBDark, sBLight;
	struct Gadget RBGad;
	int flags;
	OriginalSize *os;
	BOOL Active;
   int (*Callfn) (struct RBStruct *);
	struct MutexList *MList;
	struct RBStruct *Next;
	} RadioButton;

typedef struct TickBoxStruct
	{
	char *ObjectType; // Do not move this item!  It must be first to match other controls.
	void *Parent;
	short BevelPoints[20], TickPoints[12], hidden;
	struct Border BLight, BDark, sTick, nsTick;
	struct Gadget TickBoxGad;
	int flags;
	OriginalSize *os;
	BOOL Active, Ticked;
   int (*Callfn) (struct TickBoxStruct *);
	struct TickBoxStruct *Next;
	} TickBox;

typedef struct TimerStruct
	{
	char *ObjectType; // Do not move this item!  It must be first to match other controls.
	long lasttrigger, timesecs, starttimesecs, pausetimesecs;
	BOOL running, paused;
	short flags;
	int (*Callfn) (struct TimerStruct *, long);
	struct TimerStruct *NextTimer;
	} Timer;

typedef struct PIStruct
	{
	char *ObjectType; // Do not move this item!  It must be first to match other controls.
	void *Parent;
	GuiWindow *win;
	struct Border light, dark;
	short flags, fillcol, BevelPoints[20], hidden;
	OriginalSize *os;
	int iprogress, max;
	struct IntuiText progress;
	struct PIStruct *Next;
	} ProgressBar;

/******************
	Progress Bars
******************/

void FOXLIB DestroyProgressBar(ProgressBar *pb, BOOL refresh);
ProgressBar* FOXLIB MakeProgressBar(void *Parent, int left, int top, int width,
		int height, short fillcol, int tcol, short flags);
void FOXLIB SetProgress(ProgressBar *pb, int progress);
void FOXLIB SetProgressMax(ProgressBar *pb, int progressmax);


/***********
	Frames
***********/

void FOXLIB DestroyAllFrames(BOOL refresh);
void FOXLIB DestroyFrame(Frame *Fptr, BOOL refresh);
void FOXLIB DestroyWinFrames(GuiWindow *w, BOOL refresh);
Frame* FOXLIB MakeFrame(void *Parent, char *name, int left, int top, int width, int height, int tcol,
		int bcol, struct Border *cb, int (*callfn) (Frame*, short, short, short, void**), short flags, ...);


/************
	BitMaps
************/

GuiBitMap* FOXLIB LoadBitMap(char *fname);
BitMapInstance* FOXLIB ShowBitMap(GuiBitMap *bm, GuiWindow *w, unsigned short x, unsigned short y, short flags);
BOOL FOXLIB HideBitMap(BitMapInstance *bmi);
BOOL FOXLIB FreeGuiBitMap(GuiBitMap *bm);
GuiBitMap* FOXLIB ScaleBitMap(GuiBitMap *source, unsigned short destwidth, unsigned short destheight);
BOOL FOXLIB RedrawBitMap(BitMapInstance *bmi);
BOOL FOXLIB AttachBitMapToControl(GuiBitMap *bm, void *control, short left, short top, short width,
		short height, int flags);
BOOL FOXLIB ScreenColoursFromILBM(GuiScreen *sc, char *fname);


/***************
	List Boxes
***************/

void FOXLIB SortListBox(ListBox *p, int flags, int startnum, BOOL refresh);
void FOXLIB ClearListBoxTabStops(ListBox *nlb, BOOL refresh);
BOOL FOXLIB SetListBoxTabStops(ListBox *nlb, BOOL refresh, short num, ...);
void FOXLIB SetListBoxTopNum(ListBox *lb, int num, BOOL refresh);
void FOXLIB SetListBoxHiNum(ListBox *lb, int num, BOOL refresh);
int FOXLIB NoTitles(ListBox *lb);
int FOXLIB NoLines(ListBox *lb);
int FOXLIB TopNum(ListBox *lb);
int FOXLIB HiNum(ListBox *lb);
ListBoxItem* FOXLIB HiElem(ListBox *lb);
char* FOXLIB HiText(ListBox *lb);
BOOL FOXLIB AddListBoxTitle(ListBox *nlb, char *title, int frontpen, BOOL refresh);
ListBoxItem* FOXLIB AddListBoxItem(ListBox *nlb, char *item, BOOL refresh);
void FOXLIB ListBoxRefresh(ListBox *lb);
void FOXLIB ClearListBoxTitles(ListBox *lb, BOOL refresh);
void FOXLIB ClearListBoxItems(ListBox *lb, BOOL refresh);
BOOL FOXLIB DisableListBox(ListBox *lb);
void FOXLIB DisableAllListBoxes(void);
void FOXLIB DisableWinListBoxes(GuiWindow *w);
BOOL FOXLIB EnableListBox(ListBox *lb);
void FOXLIB EnableAllListBoxes(void);
void FOXLIB EnableWinListBoxes(GuiWindow *w);
BOOL FOXLIB DestroyListBox(ListBox *nlb, BOOL refresh);
void FOXLIB DestroyAllListBoxes(BOOL refresh);
void FOXLIB DestroyWinListBoxes(GuiWindow *w, BOOL refresh);
ListBox* FOXLIB MakeListBox(void *Parent, int left, int top, int width,
		int height, int lborder, int tborder, int frontpen, struct TextAttr *font,
		int (*selfn) (ListBox*), int flags, ...);

/*************************
	Drop Down List Boxes
*************************/

void FOXLIB StoreDDListBoxStatus(void);
void FOXLIB RestoreDDListBoxStatus(BOOL redraw);
void FOXLIB ClearDDListBox(DDListBox *l);
BOOL FOXLIB RemoveFromDDListBox(DDListBox *list, char *str);
BOOL FOXLIB AddToDDListBox(DDListBox *list, char *str);
void FOXLIB SortDDListBox(DDListBox *p, int flags);
BOOL FOXLIB SetDDListBoxPopup(DDListBox *l, int x, int y, int width, int height);
BOOL FOXLIB AssociateDDListBox(DDListBox *l, DDListBox *m);
DDListBox* FOXLIB MakeSubDDListBox(DDListBox *lb, char *string, int left, int top, int width, int height, int id,
		BOOL (*callfn)(DDListBox*));
void FOXLIB EnableDDListBox(DDListBox *p, BOOL redraw);
void FOXLIB DisableDDListBox(DDListBox *p, BOOL redraw);
void FOXLIB EnableAllDDListBoxes(BOOL redraw);
void FOXLIB DisableAllDDListBoxes(BOOL redraw);
void FOXLIB EnableWinDDListBoxes(GuiWindow *c, BOOL redraw);
void FOXLIB DisableWinDDListBoxes(GuiWindow *c, BOOL redraw);
void FOXLIB DestroyDDListBox(DDListBox *p, BOOL refresh);
void FOXLIB DestroyAllDDListBoxes(BOOL refresh);
void FOXLIB DestroyWinDDListBoxes(GuiWindow *c, BOOL refresh);
DDListBox* FOXLIB MakeDDListBox(void *Parent, int x, int y, int len, int buflen,
	int MaxHeight, int BorderCol, int Bcol, int Tcol, int id, char *prestr,
	char *poststr, short (*callfn) (DDListBox*), long flags);

/***************
	Edit Boxes
***************/

void FOXLIB StoreEditBoxStatus(void);
void FOXLIB RestoreEditBoxStatus(BOOL redraw);
void FOXLIB RefreshEditBox(EditBox *p);
BOOL FOXLIB SetEditBoxFocus(EditBox *p);
BOOL FOXLIB SetEditBoxCols(EditBox *p, int BorderCol, int Bcol, int Tcol);
char* FOXLIB GetEditBoxText(EditBox *p);
int FOXLIB GetEditBoxInt(EditBox *p);
float FOXLIB GetEditBoxFloat(EditBox *p);
BOOL FOXLIB SetEditBoxText(EditBox *p, char *text);
BOOL FOXLIB SetEditBoxInt(EditBox *p, int num);
BOOL FOXLIB SetEditBoxFloat(EditBox *p, float num);
BOOL FOXLIB SetEditBoxDP(EditBox *p, int num);
void FOXLIB EnableEditBox(EditBox *p, BOOL redraw);
void FOXLIB DisableEditBox(EditBox *p, BOOL redraw);
void FOXLIB EnableAllEditBoxes(BOOL redraw);
void FOXLIB DisableAllEditBoxes(BOOL redraw);
void FOXLIB EnableWinEditBoxes(GuiWindow *c, BOOL redraw);
void FOXLIB DisableWinEditBoxes(GuiWindow *c, BOOL redraw);
void FOXLIB DestroyEditBox(EditBox *p, BOOL refresh);
void FOXLIB DestroyAllEditBoxes(BOOL refresh);
void FOXLIB DestroyWinEditBoxes(GuiWindow *c, BOOL refresh);
EditBox* FOXLIB MakeEditBox(void *Parent, int x, int y, int len, int buflen, int BorderCol, int Bcol,
		int Tcol, int id, char *prestr, char *poststr, BOOL (*callfn) (EditBox*), long flags);


/*******************
		Menus
*******************/

BOOL FOXLIB DisableWinMenus(GuiWindow *win);
BOOL FOXLIB EnableWinMenus(GuiWindow *win);
BOOL FOXLIB DisableMenu(GuiWindow *win, struct Menu *menu);
BOOL FOXLIB EnableMenu(GuiWindow *win, struct Menu *menu);
BOOL FOXLIB DisableMenuItem(GuiWindow *win, struct MenuItem *item);
BOOL FOXLIB EnableMenuItem(GuiWindow *win, struct MenuItem *item);
void FOXLIB SetWinMenuFn(GuiWindow *win, int (*fn) (GuiWindow*, struct MenuItem *));
void FOXLIB ClearMenus(GuiWindow *win);
void FOXLIB ShareMenus(GuiWindow *dest, GuiWindow *source);
struct Menu* FOXLIB AddMenu(GuiWindow *win, char *name, int leftedge, int enabled);
struct MenuItem* FOXLIB AddMenuItem(GuiWindow *win, struct Menu *menu,
	char *name, char *selname, unsigned short flags, int key, int enabled,
	int checkit, int checked, int menutoggle);
struct MenuItem* FOXLIB AddSubMenuItem(GuiWindow *win,
	struct MenuItem *menuitem, char *name, char *selname, unsigned short flags,
	int key, int enabled, int checkit, int checked, int menutoggle);
BOOL FOXLIB RemoveMenuItem(GuiWindow *win, struct MenuItem *item);

/*******************
		Windows
*******************/

BOOL FOXLIB SleepPointer(GuiWindow *win);
void FOXLIB WakePointer(GuiWindow *win);
void FOXLIB CloseGuiWindow(GuiWindow *w);
GuiWindow* FOXLIB OpenGuiWindow(void *Scr, int Left, int Top, int Width, int Height, int minwidth,
		int minheight, int Dpen, int Bpen, int hicol, char *Title, int flags, int (*CloseFn)(GuiWindow *),
		...);
void FOXLIB CloseAllWindows(void);
void FOXLIB CloseScrWindows(GuiScreen *sc);
BOOL FOXLIB ShowFileRequester(GuiWindow *Wnd, char *path, char *pattern, char
   *title, BOOL Save, int (*callfn) (char*, char*), int Col_GW1, int
   Col_GW2, int Col_GW3, int Col_OB1, int Col_OB2, int Col_EB1, int
   Col_EB2, int Col_EB3, int Col_B1);

#ifdef OLD_LISTS
void SetListTitles(ListWindow *l, char *t1, char *t2, char *t3);
void CloseListWindow(ListWindow *l);
ListWindow *OpenListWindow(GuiScreen *Scr, int left, int top, int width,
	int height, int dpen, int bpen, int hicol, char *title, int flags,
	char *t1, char *t2, char *t3, void (*selfn) (int));
int ListNoTitles(ListWindow *win);
void ClearList(ListWindow *l);
BOOL DeleteListItem(ListWindow *listptr, int num);
BOOL ReplaceListItem(ListWindow *listptr, int num, char *str);
void SetListUpdate(ListWindow *listptr, int update);
BOOL AddToList(ListWindow *listptr, char *str);
void unhighlight(ListWindow *win);
void highlight(ListWindow *win, int itemnum);
char *GetListWindowText(ListWindow *l, int num);
void DisplayList(ListWindow *l, int start, int hinum);
BOOL DisableListWindow(ListWindow *w);
BOOL EnableListWindow(ListWindow *w);
#endif

void FOXLIB SetFName(char *fname);
void FOXLIB SetPath(char *path);
void FOXLIB UpdateFList(void);

/*******************
		Misc.
*******************/

short FOXLIB InitGui(short flags, FILE *DebugFile);
void FOXLIB GuiLoop(void);
void FOXLIB EndGui(void);
short FOXLIB LibVersion(void);
BOOL FOXLIB SetGuiPensFromPubScreen(char *pub_screen_name);
void FOXLIB SetGuiPens(short hipen, short lopen);
BOOL FOXLIB ShowMessage(GuiScreen *scr, char *a, char *b, char *c, int col);
BOOL FOXLIB DestroyMessage(void);
void FOXLIB SetPeriod(int time);
void FOXLIB SetDelay(int time);
void* FOXLIB GuiMalloc(unsigned NoOfBytes, unsigned long flags);
BOOL FOXLIB WasGuiMallocd(void *p);
void FOXLIB GuiFreeMem(void *p, int line, char *fname);
void FOXLIB StoreEveryStatus(void);
void FOXLIB RestoreEveryStatus(BOOL redraw);
void FOXLIB EnableEverything(int redraw);
void FOXLIB DisableEverything(int redraw);
void FOXLIB DrawLines(GuiWindow *win, short *points, int count, int col);
short FOXLIB GuiMessage(void *Scr, char *text, char *title, int detail, int block, int Btext, int high, int flags);
void FOXLIB Hide(void *Control);
void FOXLIB Show(void *Control);
void FOXLIB DisableControl(void *Control, BOOL refresh);
void FOXLIB EnableControl(void *Control, BOOL refresh);
void FOXLIB Destroy(void *Control, BOOL refresh);
GuiWindow* FOXLIB GetWindow(void *Control);
BOOL FOXLIB RegisterGadget(struct Gadget *gad, GuiWindow *gadwin, int (*gadfn)(struct Gadget*, struct IntuiMessage *));
BOOL FOXLIB UnRegisterGadget(struct Gadget *gad);
struct Window* FOXLIB IntuiWindow(GuiWindow *gw);
void FOXLIB CheckMessages(void);

/*******************
		Screens
*******************/

BOOL FOXLIB CloseGuiScreen(GuiScreen *scr);
void FOXLIB CloseAllGuiScreens(void);
GuiScreen* FOXLIB OpenGuiScreen(int Depth, int DPen, int BPen, struct TextAttr *Font, char *Title,
		int (*LastWinFn)(GuiScreen *), int flags, ...);

/*******************
		Buttons
*******************/

void FOXLIB StoreButtonStatus(void);
void FOXLIB RestoreButtonStatus(void);
void FOXLIB DisableButton(PushButton *Bptr);
void FOXLIB DisableAllButtons(void);
void FOXLIB DisableWinButtons(GuiWindow *w);
void FOXLIB EnableButton(PushButton *Bptr);
void FOXLIB EnableAllButtons(void);
void FOXLIB EnableWinButtons(GuiWindow *w);
void FOXLIB DestroyButton(PushButton *b, BOOL refresh);
void FOXLIB DestroyAllButtons(BOOL refresh);
void FOXLIB DestroyWinButtons(GuiWindow *w, BOOL refresh);
PushButton* FOXLIB MakeButton(void *Parent, char *name, int left, int top, int
   width, int height, int tcol, int bcol, int key, struct Border *cb, int
   (*callfn) (PushButton*), short flags);

/*******************
	Output Boxes
*******************/

void FOXLIB SetOutputBoxDP(OutputBox *p, int dp);
void FOXLIB SetOutputBoxInt(OutputBox *p, int num);
void FOXLIB SetOutputBoxFloat(OutputBox *p, float num);
void FOXLIB SetOutputBoxText(OutputBox *p, char *text);
void FOXLIB DestroyOutputBox(OutputBox *p, BOOL refresh);
void FOXLIB DestroyAllOutputBoxes(BOOL refresh);
void FOXLIB DestroyWinOutputBoxes(GuiWindow *c, BOOL refresh);
void FOXLIB SetOutputBoxCols(OutputBox *ob, int Bcol, int Tcol, BOOL refresh);
OutputBox* FOXLIB MakeOutputBox(void *Parent, int x, int y, int width, int len, int Bcol, int Tcol, int id,
		char *prestr, char *poststr, struct TextAttr *font, long flags);

/********************
	Boolean Gadgets
********************/

RadioButton* FOXLIB ActiveRadioButton(RadioButton *rb);
void FOXLIB DestroyRadioButton(RadioButton *rb, BOOL refresh);
RadioButton* FOXLIB MakeRadioButton(void *Parent, RadioButton *MutEx, int left, int top, int width,
		int height, int fillcol, char *caption, struct TextAttr *font, int captioncol,
		int (*callfn) (RadioButton*), int flags);
BOOL FOXLIB TickBoxValue(TickBox *tb);
void FOXLIB DestroyAllRadioButtons(BOOL refresh);
void FOXLIB DestroyAllTickBoxes(BOOL refresh);
void FOXLIB DestroyTickBox(TickBox *tb, BOOL refresh);
void FOXLIB DestroyWinRadioButtons(GuiWindow *gw, BOOL refresh);
void FOXLIB DestroyWinTickBoxes(GuiWindow *gw, BOOL refresh);
void FOXLIB DisableRadioButton(RadioButton *rb);
void FOXLIB DisableTickBox(TickBox *tb);
void FOXLIB EnableRadioButton(RadioButton *rb);
void FOXLIB EnableTickBox(TickBox *tb);
TickBox* FOXLIB MakeTickBox(void *Parent, int left, int top, int width, int height, int tickcol, int fillcol,
		char *caption, struct TextAttr *font, int captioncol, int (*callfn) (TickBox*), int flags);

/***********
	Timers
***********/

BOOL FOXLIB DestroyTimer(Timer *t);
void FOXLIB DestroyAllTimers(void);
Timer* FOXLIB MakeTimer(short flags, int (*CallFn) (Timer *, long));
void FOXLIB StartTimer(Timer *t);
void FOXLIB StopTimer(Timer *t);
void FOXLIB PauseTimer(Timer *t);
void FOXLIB UnpauseTimer(Timer *t);
void FOXLIB AddTime(Timer *t, long secs);
void FOXLIB SetTime(Timer *t, long secs);

/*****************
   Tab Controls
*****************/

TabControl* FOXLIB MakeTabControl(void *Parent, int left, int top, int width, int height, int tcol, int fcol,
		int tabheight, short flags, int numtabs, ...);
void FOXLIB DestroyTabControl(TabControl *tc, BOOL refresh);
void FOXLIB DestroyWinTabControls(GuiWindow *w, BOOL refresh);
void FOXLIB DestroyAllTabControls(BOOL refresh);
Frame* FOXLIB TabControlFrame(TabControl *tc, int frameno);
void FOXLIB EnableTabControl(TabControl *tc);
void FOXLIB DisableTabControl(TabControl *tc);
