#ifndef COMPONENT_H #define COMPONENT_H /* TUIpeer works in conjunction with an implementation of java.awt.Toolkit to provide a Text User Interface for programs using the Java AWT. Component is the base class for the various TUI component implementations. 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. */ /* * $Log: component.h,v $ * Revision 1.2 2000/12/18 01:58:57 stuart * Removed dependencies on libg++. * Changed all references to String to string. * Changed libg++ String idioms to string idioms. * Copied Obstack from libg++ and hacked it to throw an exception on error. * Hacked Set.cc to throw an exception on error. * Added Str.cc to relace the split function from libg++. * * Revision 1.1.1.1 2000/12/16 20:45:18 stuart * Released TUIPeer sources * */ #pragma interface #include "remotepeer.h" #include // a Java toolkit Component Peer class DrawingContext; class IndirectContext; /** Features we need to remember to emulate a Java Graphics context. */ struct TextContext { string fontname; short textStyle; short textSize; // not used for TUI short fgColor; short bgColor; enum fontStyles { PLAIN, BOLD, ITALIC }; TextContext(); void operator=(const TextContext &); unsigned short textAttr; // computed from fgColor,bgColor,textStyle,font IndirectContext *dc; void setDC(IndirectContext *); unsigned short getAttr(short color) const; unsigned short drawAttr(int x,int y) const; unsigned short getAttr() const; ~TextContext(); }; class Component: virtual public Controller, public TextContext, protected RemotePeer { friend class Toolkit; class MenuContainer *popup; protected: short posx, posy, width, height; short cursor; bool enabled, visible; bool localtabs; class ContainerComponent *parent; void setDC(); int descale(short val,int scale); public: Component(); virtual ~Component(); void remoteMethod(int cmd); class ContainerComponent *getParent() const { return parent; } void setParent(ContainerComponent *c); class Rect bounds() const; bool inside(int x,int y) const; class Point location() const; void invalidate(); // redraw component virtual void repaint(const Rect &); // redraw area of component soon virtual void reshape(int x,int y,int w,int h); void setSize(int w,int h); virtual void paint(DrawingContext *dc); virtual void show(bool visible); virtual void nextFocus(); virtual void prevFocus(); bool isVisible() const; bool isEnabled() const; virtual class MenuContainer *asMenu() { return 0; } virtual class MenuItemComponent *asMenuItem() { return 0; } virtual IndirectContext *getDC(); // create drawing context virtual void setCursor(int x,int y); // set text cursor virtual void setCursor(int type); // set cursor type void getfocus(); void losefocus(); virtual Component *getTab() { return this; } virtual bool focusForward(); virtual bool focusBackward(); void key(int); Point absLocation() const; }; #endif