/* 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. */ #pragma implementation #include #include "wincomp.h" #include "rmtcomp.h" RemoteComponent::RemoteComponent() { } RemoteComponent::~RemoteComponent() { } void Component::remoteMethod(int cmd) { enum GraphicIDs { // from TUIGraphics.java DRAWFONT = 150, DRAWCOLOR = 151, CLIPRECT = 152, TRANSLATE = 153, COPYAREA = 154, FILLRECT = 155, DRAWRECT = 156, CLEARRECT = 157, DRAWROUNDRECT = 158, FILLROUNDRECT = 159, DRAWSTRING = 160, DRAWLINE = 161 }; switch (cmd) { case DISABLE: enabled = false; return; case ENABLE: enabled = true; return; case HIDE: show(false); return; case SHOW: show(true); return; case NEXTFOCUS: nextFocus(); return; case REQUESTFOCUS: if (parent) parent->setfocus(this); return; case SETBACKGROUND: bgColor = readShort(); textAttr = getAttr(); invalidate(); return; case SETFOREGROUND: fgColor = readShort(); textAttr = getAttr(); invalidate(); return; case SETFONT: fontname = readUTF(); textSize = readShort(); textStyle = readShort(); textAttr = getAttr(); invalidate(); return; case SETCURSOR: setCursor(readShort()); return; case REPAINT: { int x,y,w,h; x = readShort(); y = readShort(); w = readShort(); h = readShort(); repaint(Rect(Point(y,x),w,h)); return; } case RESHAPE: { int x,y,w,h; x = readShort(); y = readShort(); w = readShort(); h = readShort(); reshape(x,y,w,h); return; } case DRAWSTRING: { String str(readUTF()); int x = readShort(); int y = readShort(); if (dc) dc->writeStr(x,y,str,textAttr); return; } case FILLRECT: { int x,y,w,h; x = readShort(); y = readShort(); w = readShort(); h = readShort(); if (dc) dc->fillRect(Rect(Point(y,x),w,h),' '|getAttr(fgColor)); return; } case DRAWRECT: { int x,y,w,h; x = readShort(); y = readShort(); w = readShort(); h = readShort(); if (dc) dc->drawRect(x,y,w,h,textAttr,dc->LD_SINGLE); return; } case CLEARRECT: { int x,y,w,h; x = readShort(); y = readShort(); w = readShort(); h = readShort(); if (dc) dc->fillRect(Rect(Point(y,x),w,h),' '|getAttr(bgColor)); return; } case CLIPRECT: { int x,y,w,h; x = readShort(); y = readShort(); w = readShort(); h = readShort(); if (dc) dc->clipRect(Rect(Point(y,x),w,h)); return; } case TRANSLATE: { short x,y; x = readShort(); y = readShort(); if (dc) dc->translate(x,y); return; } case DRAWCOLOR: { fgColor = readShort(); textAttr = getAttr(); return; } case DRAWLINE: { short x1,y1,x2,y2; x1 = readShort(); y1 = readShort(); x2 = readShort(); y2 = readShort(); if (dc) { if (y1 == y2) // draw horizontal line dc->fillRect(Rect(y1,x1,y2,x2),ACS_HLINE | textAttr); if (x1 == x2) dc->fillRect(Rect(y1,x1,y2,x2),ACS_VLINE | textAttr); } return; } } fflush(stderr); abort(); } void RemoteContainer::remoteMethod(int cmd) { Component *obj; switch (cmd) { case NEWFRAME: obj = new RemoteFrame; // NOTE: TUIKit is not prepared for gotfocus event at this point break; case NEWWINDOW: obj = new RemoteWindow; break; case NEWDIALOG: obj = new RemoteDialog; break; case NEWMENUBAR: add(obj = new RemoteMenuBar); break; case NEWMENU: add(obj = new RemoteMenu); break; case NEWMENUITEM: add(obj = new RemoteMenuItem); break; case NEWLABEL: add(obj = new RemoteLabel); break; case NEWBUTTON: add(obj = new RemoteButton); break; case NEWTEXTFIELD: add(obj = new RemoteTextField); break; case NEWTEXTAREA: add(obj = new RemoteTextArea); break; case NEWPANEL: add(obj = new RemoteContainer); break; case NEWCHECKBOX: add(obj = new RemoteCheckBox); break; case NEWCHOICE: add(obj = new RemoteChoice); break; case NEWLIST: add(obj = new RemoteList); break; case ADDCOMPONENT: { int id = readShort(); Component *c = toolkit->componentAt(id); if (c) add(c); return; } case BEEP: Window::beep(); return; case SYNC: Ksync(); return; case NEWCANVAS: case NEWSCROLLBAR: case NEWSCROLLPANE: case NEWPOPUPMENU: case NEWCHECKMENUITEM: default: Component::remoteMethod(cmd); return; } toolkit->addComponent(obj,readShort()); }