// event-driven GUI header // define often-used data types typedef unsigned char byte; // ********************************************************************** // base class for all windows and window-elements // ********************************************************************** class Window { public: byte *Store; // storage for background image byte x1, y1, x2, y2; // windows coordinates byte oldx1, oldy1, oldx2, oldy2; // old window coordinates byte oldx, oldy, oldattr; // old cursor position/colours Window *Next; // ptr to window underneath Window ( byte xx1, byte yy1, byte xx2, byte yy2 ); ~Window (); virtual int ProcessKey ( char ); virtual void IdleAction (); }; // ********************************************************************** // main kernel class // ********************************************************************** class Application { public: Window *Head; // ptr to topmost window Application (); ~Application (); void OpenWindow ( Window *p ); void CloseWindow (); void Run (); }; extern Application *anApp; // global variable to access kernel // ********************************************************************** // window with a border // ********************************************************************** class BWindow : public Window { public: BWindow ( byte xx1, byte yy1, byte xx2, byte yy2, byte block ); void directput ( int x, int y, byte cha, byte col ); void Block (); }; // ********************************************************************** // window with a single-line message // ********************************************************************** class MessageWindow : public BWindow { public: MessageWindow ( char *s ); virtual int ProcessKey ( char ); }; // ********************************************************************** // menu item // ********************************************************************** class MenuItem { public: char Data[100]; // actual data for menu MenuItem *Next; // pointer to next item MenuItem ( char *p ) { strcpy (Data, p); Next=NULL; } }; // ********************************************************************** // linked list of menu items // ********************************************************************** class MenuData { public: MenuItem *Head, *Tail; // linked list pointers unsigned int Count; // number of items in list MenuData () // initialize list { Head=NULL; Tail=NULL; Count=0; }; void AddItem ( MenuItem *m ) // add an item to the list { if (Head==NULL) Head=m; else Tail->Next=m; Tail=m; Count++; } ~MenuData (); }; // ********************************************************************** // horizontal menu // ********************************************************************** class HorzMenu : public BWindow { public: MenuData *Menu; // pointer to a list of menu items byte Separator; // distance between menu items byte Position; // current position of selector block HorzMenu ( byte xx1, byte yy1, byte xx2, byte yy2, byte block ); void InitMenu ( MenuData *md ); void Draw ( int Pos, int State ); virtual int ProcessKey ( char ch ); }; // ********************************************************************** // vertical menu // ********************************************************************** class VertMenu : public BWindow { public: MenuData *Menu; // pointer to a list of menu items byte Position; // current position of selector block VertMenu ( byte xx1, byte yy1, byte xx2, byte yy2, byte block ); void InitMenu ( MenuData *md ); void Draw ( int Pos, int State ); virtual int ProcessKey ( char ch ); }; // ********************************************************************** // scrolling status line // ********************************************************************** class StatusLine : public BWindow { public: char Data[100]; // string for status line int waitcount; // delay in-between moves StatusLine ( byte y, char *s ); virtual void IdleAction (); }; // **********************************************************************