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

  1. /**
  2.    GRAB Graph Layout and Browser System
  3.  
  4.    Copyright (c) 1987, 1988, 1989 Stanford University
  5.    Copyright (c) 1989, Tera Computer Company
  6.  **/
  7.  
  8.   /**
  9.      Exactly like the panners in the InterViews source, except
  10.      they use myadjusters instead of adjusters
  11.    **/
  12.  
  13. #include "myadjuster.h"
  14. #include "mypanner.h"
  15. #include <InterViews/adjuster.h>
  16. #include <InterViews/border.h>
  17. #include <InterViews/box.h>
  18. #include <InterViews/glue.h>
  19. #include <InterViews/painter.h>
  20. #include <InterViews/panner.h>
  21. #include <InterViews/pattern.h>
  22. #include <InterViews/perspective.h>
  23. #include <InterViews/rubrect.h>
  24. #include <InterViews/sensor.h>
  25. #include <InterViews/shape.h>
  26. #include <math.h>
  27.  
  28. MyPanner::MyPanner (Interactor* i, int size) 
  29. {
  30.     Init(i, size);
  31. }
  32.  
  33. MyPanner::MyPanner (const char* name, Interactor* i, int size) 
  34. {
  35.     SetInstance(name);
  36.     Init(i, size);
  37. }
  38.  
  39. MyPanner::MyPanner (Interactor* i, int size, Painter* p) 
  40. {
  41.     output = p;
  42.     output->Reference();
  43.     Init(i, size);
  44. }
  45.  
  46. /* 0.3 second delay for auto-repeat */
  47. static int DELAY = 3;
  48.  
  49. void MyPanner::Init (Interactor* i, int n) 
  50. {
  51.     SetClassName("MyPanner");
  52.     size = n;
  53.     enlarger = new MyEnlarger(i);
  54.     reducer = new MyReducer(i);
  55.     adjusters = new HBox(new HGlue, 
  56.              new VBox(new UpMover(i, DELAY), 
  57.                   new HBox(new LeftMover(i, DELAY), new HGlue,
  58.                            new RightMover(i, DELAY)),
  59.                       new DownMover(i, DELAY)),
  60.              new HGlue,
  61.              new VBox(new VGlue(2), enlarger, 
  62.                   new VGlue(4), reducer, new VGlue(2)),
  63.              new HGlue);
  64.     slider = new Slider(i);
  65.     Insert(new VBox(adjusters, new HBorder, slider));
  66. }
  67.  
  68. void MyPanner::Reconfig () 
  69. {
  70.     MonoScene::Reconfig();
  71.     Shape a = *adjusters->GetShape();
  72.  
  73.     if (a.vstretch != 0 || a.vshrink != a.height / 3) 
  74.     {
  75.         if (size != 0) 
  76.     {
  77.             a.width = size;
  78.         a.hshrink = a.hstretch = 0;
  79.         }
  80.  
  81.         a.vstretch = 0;
  82.         a.vshrink = a.height/3;
  83.         adjusters->Reshape(a);
  84.     }
  85.  
  86.     Shape* s = slider->GetShape();
  87.  
  88.     if (s->width != a.width) 
  89.     {
  90.         slider->Reshape(a);
  91.     }
  92. }
  93.  
  94. void MyPanner::ChangeZGrad (float zg) 
  95. {
  96.     enlarger->ChangeZGrad( 1.0 / zg);
  97.     reducer->ChangeZGrad(zg);
  98. }
  99.