/** * rewrite of "Document" concept, from scratch. * This is really just a prototype, so I may go back to using the * old "Document" class. But I need a place to hold the new concepts, * so here it is. * * This is the top-level class for actually holding user-input data. * The GUI interacts with this class, via the TextInterface construct. * We also need to implement DocInterface here. * * Possibly we need to merge TextInterface more with DocInterface. * We need to add something about changing existing text area margins, * blah blah blah, so we can then test multiple TFrames in the same * TPage * * We may be trimming down TextInterface a bit, too. * (to get rid of the TextMode support, possibly) Then again, * COULD just stub that stuff out. * */ class JDoc implements DocInterface { TCursor tcursor; TFrameManager tframes; GUIInterface GUI; public JDoc(){ DocInit(); } void DocInit(){ tcursor=new TCursor(); /* after loading a doc, this should be set better */ /* ALso, after setting margins or something...?*/ tframes=new TFrameManager(); } /******************************************************** * Here are the routines required by DocInteface * ********************************************************/ public void addString(String newtext) throws java.io.IOException{ do something at cursor relate this to methods used below in addChar() delChar() } // These should do something with TPage public void setLeftMargin(int ptdist) throws java.io.IOException; public void setRightMargin(int ptdist) throws java.io.IOException; public void setTopMargin(int ptdist) throws java.io.IOException; public void setBottomMargin(int ptdist) throws java.io.IOException; /**************************************************** * And now, the TextInterface stuff * ****************************************************/ public void setCursorByPoint(int pagenum, Point p){ GUI.hideCursor(); if(tcursor.pageid != pagenum){ pages.hidecursor(tcursor.pageid); tcursor.pageid=pagenum; } pages.getPageAt(pagenum).setCursor(tcursor,p); debug("JDoc.setCursorByPoint not done"); showCursor(); } public void setCursor(int pagenum, int row, int column){ GUI.hideCursor(); if(tcursor.pageid != pagenum){ pages.hidecursor(tcursor.pageid); tcursor.pageid=pagenum; } pages.getPageAt(pagenum).setCursor(tcursor,row,column); debug("JDoc.setCursor not done"); showCursor(); } /* This is tough to figure out where it should be run from * I suppose it should be coordinated here. But * there's also a lot of lowerlevel coordination needed, * at frame level,and possibly page level */ public void adjCursor(int coladj, int rowadj){ GUI.hideCursor(); debug("JDoc.adjCursor not done"); showCursor(); } public boolean addChar(char newchar){ GUI.hideCursor(); debug("JDoc.addChar not done"); showCursor(); } /*--------------------------------------------------------------*/ /* addString() already implemented above, in DocInteface section*/ /*--------------------------------------------------------------*/ public boolean delChar(); public boolean delCharLeft(); public boolean delWord(); public void repaintRegion(int pagenum, Point startpoint, Point endpoint){ pages.getPageAt(pagenum).repaintRegion(GUI,pagenum, startpoint,endpoint); } public void repaintPage(int pagenum){ pages.getPageAt(pagenum).repaintPage(GUI,pagenum); } /****************************************************************/ * Below here, are convenience functions. Any public function * * should go ABOVE HERE * ****************************************************************/ void debug(String msg){ System.out.println(msg); } /* A convinience function to abstract showing the cursor * to the user in the right place. * We assume that TCursor has been updated appropriately * BEFORE calling us here. */ void showCursor(){ GUI.showCursor(tcursor.pageid, tcursor.pagexpos, tcursor.pageypos); } }