/* 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 __textdraw_h #define __textdraw_h #pragma interface #include #include #include class DrawingContext { protected: Rect cliprect; short translatex, translatey; // translation public: DrawingContext(const Rect &r); Rect clipRect() const; virtual class IndirectContext create(); void clipRect(const Rect &r); void translate(int dx, int dy) { translatex += dx; translatey += dy; } virtual void writeAttr(int x,int y,int n,const CHTYPE *a) = 0; virtual void copyArea(const Rect &,int dx,int dy) = 0; virtual void fillRect(const Rect &,CHTYPE attr) = 0; virtual CHTYPE get(int x,int y) const; string asString() const; void writeStr(int x,int y,const string &s,CHTYPE attr); void writeStr(int x,int y,int n,const string &s,CHTYPE attr); enum LDtype { LD_SINGLE, LD_DOUBLE }; void drawRect(int x,int y,int w,int h,CHTYPE a,LDtype type); virtual ~DrawingContext() { } }; class IndirectContext: public DrawingContext { DrawingContext *dc; public: IndirectContext(DrawingContext *); class IndirectContext create(); void setClip(const Rect &); CHTYPE get(int x,int y) const; void writeAttr(int x,int y,int n,const CHTYPE *a); void copyArea(const Rect &,int dx,int dy); void fillRect(const Rect &,CHTYPE attr); }; class TextImage: public DrawingContext { CHTYPE *data; unsigned *d; short imgwidth, imgheight; public: CHTYPE *rowdata(int i) { return data + d[i]; } const CHTYPE *rowdata(int i) const { return data + d[i]; } TextImage(int width, int height); void writeAttr(int x,int y,int n,const CHTYPE *a); void copyArea(const Rect &,int dx,int dy); void fillRect(const Rect &,CHTYPE attr); void resize(int width, int height); CHTYPE get(int x,int y) const; ~TextImage(); }; #endif