home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / intrvews / xgrab.lha / xgrab / ui / gframe.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-04-24  |  5.2 KB  |  270 lines

  1. /**
  2.    GRAB Graph Layout and Browser System
  3.  
  4.    Copyright (c) 1989, Tera Computer Company
  5.  **/
  6.  
  7. /** 
  8.    Implementation of the frame around everything, the top-level
  9.    interactor, the big cheese.
  10.  
  11.    Most of the routines in here just invoke routines of components of the
  12.    frame.  The frame is mostly worried about putting it all together, and
  13.    about changing the cursor to its proper value.
  14.  **/
  15.  
  16. #include "gframe.h"
  17. #include "graph.h"
  18. #include "winview.h"
  19. #include "fonthandler.h"
  20. #include "gview.h"
  21. #include "bview.h"
  22. #include "tview.h"
  23. #include "dview.h"
  24. #include "mypanner.h"
  25. #include <InterViews/banner.h>
  26. #include <InterViews/border.h>
  27. #include <InterViews/box.h>
  28. #include <InterViews/button.h>
  29. #include <InterViews/cursor.h>
  30. #include <InterViews/frame.h>
  31. #include <InterViews/glue.h>
  32. #include <InterViews/graphic.h>
  33. #include <InterViews/scroller.h>
  34. #include <InterViews/sensor.h>
  35. #include <InterViews/tray.h>
  36. #include <InterViews/viewport.h>
  37. #include "stringedit.h"
  38. #include <string.h>
  39. #include "cursor.line"
  40. #include "cursor.text"
  41. #include "cursor.button"    
  42.  
  43. Cursor* mainCursor;    
  44. Cursor* lineCursor;
  45. Cursor* nodeCursor;
  46. Cursor* browseCursor;
  47. Cursor* textCursor;
  48. Cursor* waitCursor;
  49. Cursor* buttonCursor;
  50.   /* I suspect buttonCursor isn't used and could be eliminated */
  51.  
  52. void GraphFrame::InitCursors ()
  53. {
  54.     mainCursor = arrow;
  55.     nodeCursor = crosshairs;
  56.     lineCursor = new Cursor(15, 1, lineCursorData, lineCursorData, 
  57.     black, white);
  58.     browseCursor = mainCursor;
  59.     waitCursor = hourglass;
  60.     textCursor = new Cursor(1, 15, textCursorData, textCursorData, 
  61.     black, white);
  62.     buttonCursor = new Cursor(1, 15, buttonCursorData, buttonCursorData, 
  63.     black, white);
  64. }
  65.  
  66. static const sideSize = 150;    /* size of the panner et al. */
  67.  
  68. GraphFrame::GraphFrame (GView* g, TextView* t) 
  69.   /* initialize everything, set the proper variables, and put it all together */
  70. {
  71.     gwin = new GrabWindow (g, t);
  72.     panner = new MyPanner(gwin->gview, sideSize);
  73.     dview = new DrawView(sideSize);
  74.     sidewin = new VBox(dview, new VGlue(10, 0, 0), panner);
  75.     fhandler = new FontHandler();
  76.     gwin->gview->SetFHandler(fhandler);
  77.     Init();
  78.     MakeFrame();
  79. }
  80.  
  81. void GraphFrame::Init () 
  82.   /* set variables; let the buttons and the graph know who the frame is */
  83. {
  84.     SetClassName("GraphFrame");
  85.     delete input;
  86.     input = updownEvents;
  87.     input->Reference();
  88.     Propagate(false);
  89.     InitCursors();
  90.     currentCursor = mainC;
  91.     SetCurs(currentCursor);
  92.     gwin->bview->SetFrame(this);
  93.     gwin->gview->SetFrame(this);
  94. }
  95.  
  96. void GraphFrame::ChangeStatusLine (char* s, boolean now) 
  97. {
  98.     gwin->tview->ChangeStatusLine (s, now);
  99.  
  100.     if (now)
  101.       /**
  102.      cheap trick:  if we set the cursor, the new status line
  103.      is printed
  104.        **/
  105.     {
  106.     SetCurs(currentCursor);
  107.     }
  108. }
  109.  
  110. void GraphFrame::ChangeGraphName (char* s) 
  111. {
  112.     gwin->tview->ChangeGraphName (s);
  113. }
  114.  
  115. void GraphFrame::ChangeFileName (char* s) 
  116. {
  117.     gwin->tview->ChangeFileName (s);
  118. }
  119.  
  120. void GraphFrame::ChangeToggles (char b[numopts])
  121. {
  122.     gwin->bview->NewOptionsMenu (b);
  123. }
  124.  
  125. void GraphFrame::ChangeZGrad (float zg)
  126. {
  127.     panner->ChangeZGrad (zg);
  128. }
  129.  
  130. void GraphFrame::InitFonts()
  131. {
  132.     fhandler->newScreen();
  133. }
  134.  
  135. void GraphFrame::SmallestFont(int* x, int* y)
  136. {
  137.     fhandler->SmallestFont(x, y);
  138. }
  139.  
  140. void GraphFrame::SetFont(int x, int y)
  141. {
  142.     fhandler->set_font(x, y);
  143. }
  144.  
  145. boolean GraphFrame::TextFits()
  146. {
  147.     return (fhandler->text_flag);
  148. }
  149.  
  150. void GraphFrame::ForceEL()
  151. {
  152.     fhandler->force_elabel();
  153. }
  154.  
  155. void GraphFrame::NoForceEL()
  156. {
  157.     fhandler->noforce_elabel();
  158. }
  159.  
  160. void GraphFrame::ForceNL()
  161. {
  162.     fhandler->force_nlabel();
  163. }
  164.  
  165. void GraphFrame::NoForceNL()
  166. {
  167.     fhandler->noforce_nlabel();
  168. }
  169.  
  170. void GraphFrame::MakeFrame() 
  171. {
  172.     noframe = new HBox(sidewin, new VBorder, gwin);
  173.     Insert(
  174.     new BorderFrame(
  175.         new VBox(
  176.         new Banner("Xgrab2.3", "\0", "04/24/89"),
  177.         new HBorder,
  178.         noframe,
  179.         new HBorder
  180.         )
  181.     )
  182.     );
  183. }
  184.  
  185. void GraphFrame::SetCurs(Curs c) 
  186.   /* node and line cursors only show up in the graph area */
  187. {
  188.     currentCursor = c;
  189.  
  190.     switch (c)
  191.     {
  192.     case nodeC:
  193.             gwin->gview->SetCursor(nodeCursor);
  194.         break;
  195.     case lineC:
  196.             gwin->gview->SetCursor(lineCursor);
  197.         break;
  198.     case waitC:
  199.             SetCursor(waitCursor);
  200.         gwin->gview->SetCursor(waitCursor);
  201.         break;
  202.     case browseC:
  203.             SetCursor(browseCursor);
  204.         gwin->gview->SetCursor(browseCursor);
  205.         break;
  206.     case textC:
  207.             SetCursor(textCursor);
  208.         gwin->gview->SetCursor(textCursor);
  209.         break;
  210.     case buttonC:
  211.             SetCursor(buttonCursor);
  212.         gwin->gview->SetCursor(buttonCursor);
  213.         break;
  214.     case mainC:
  215.             SetCursor(mainCursor);
  216.         gwin->gview->SetCursor(mainCursor);
  217.         break;
  218.     }
  219. }
  220.  
  221. NShape GraphFrame::CurShape() 
  222. {
  223.     return dview->CurShape();
  224. }
  225.  
  226. BType GraphFrame::CurBrush() 
  227. {
  228.     return dview->CurBrush();
  229. }
  230.  
  231. CType GraphFrame::CurColor() 
  232. {
  233.     return dview->CurColor();
  234. }
  235.  
  236. boolean GraphFrame::ShapeSet() 
  237. {
  238.     return dview->ShapeSet();
  239. }
  240.  
  241. boolean GraphFrame::BrushSet() 
  242. {
  243.     return dview->BrushSet();
  244. }
  245.  
  246. boolean GraphFrame::ColorSet() 
  247. {
  248.     return dview->ColorSet();
  249. }
  250.  
  251. void GraphFrame::UnsetCurs() 
  252. {
  253.     SetCurs(mainC);
  254. }
  255.  
  256. void GraphFrame::drawside()
  257. {
  258.     dview->DrawDep();
  259. }
  260.  
  261. void GraphFrame::SetPS(char* fs)
  262. {
  263.     fhandler->SetPS(fs);
  264. }
  265.  
  266. int GraphFrame::WidthPS(char* s)
  267. {
  268.     return fhandler->WidthPS(s);
  269. }
  270.