/* TUIpeer works in conjunction with an implementation of java.awt.Toolkit to provide a Text User Interface for programs using the Java AWT. Copyright (C) 1997-2000 Stuart D. Gathman This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __TOOLKIT_H #define __TOOLKIT_H #pragma interface #include #include #include #include // a connection to a Java awt toolkit class Component; class Dialog; class Toolkit: private SelectPoll, public Controller { int fd; void *f; // really a FILE *, but we don't want to include stdio.h here Array objs; Array allFrames; class Background *backgrnd; char dumpargs; char argcnt; void logarg(int); void logarg(const char *); void handler(); public: bool trace; bool localtabs; int scalex, scaley; Toolkit(int f); void addComponent(Component *obj,int id); void addFrame(Dialog *w); // add Dialog to task list int findFrame(Component *w); void getfocus(); void removeFrame(Component *w); // remove from task list void nextFrame(); // move focus to next frame in task list void prevFrame(); // move focus to prev frame in task list Dialog *pickList(); // select focus frame from task list Component *componentAt(int i); void delComponent(int); Component *removeComponentAt(int i); void key(int k); void init(int sx,int sy); int run(); void writeShort(int val); void writeUTF(const string &); void readFully(char *buf,int len); void callMethod(int id,int cmd,const char *buf,int len); void callMethod(int id,int cmd,const string &str); void callMethod(int id,int cmd,int x); void callMethod(int id,int cmd,int x,int y); void callMethod(int id,int cmd,int x,int y,int w,int h); void callMethod(int id,int cmd); /** Return bytes known to be readable without blocking. */ int avail(); int readShort(); unsigned readUshort() { return (unsigned short)readShort(); } string readUTF(); int runProg(string cmd); void close(); // close connection ~Toolkit(); }; #endif