home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / Share / Java / JDesignerPro / Jdp3_0.exe / data1.cab / Program_Files / JDPMain.jar / JDPScrollPanel.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-03-03  |  3.0 KB  |  185 lines

  1. import java.awt.Component;
  2. import java.awt.Container;
  3. import java.awt.Dimension;
  4. import java.awt.Event;
  5. import java.awt.Insets;
  6. import java.awt.Panel;
  7. import java.awt.Scrollbar;
  8.  
  9. public class JDPScrollPanel extends Panel {
  10.    static boolean activated;
  11.    JDPRowLayout thisLayout;
  12.    Scrollbar scrollEast;
  13.    Scrollbar scrollSouth;
  14.    int xOffset;
  15.    int yOffset;
  16.    Insets thisInsets;
  17.    boolean dropEvent;
  18.  
  19.    public JDPScrollPanel() {
  20.       activated = JDPUser.classactivated;
  21.       if (!activated) {
  22.          System.out.println("Software Violation - this class may only be used in conjunction with JDesignerPro.");
  23.       } else {
  24.          this.thisInsets = new Insets(3, 5, 0, 0);
  25.          this.thisLayout = new JDPRowLayout(3, 1);
  26.          ((Container)this).setLayout(this.thisLayout);
  27.          this.scrollEast = new Scrollbar(1, 0, 100, 0, 100);
  28.          ((Container)this).add("scrollEast", this.scrollEast);
  29.          this.scrollSouth = new Scrollbar(0, 0, 100, 0, 100);
  30.          ((Container)this).add("scrollSouth", this.scrollSouth);
  31.       }
  32.    }
  33.  
  34.    public JDPScrollPanel(boolean var1) {
  35.       activated = JDPUser.classactivated;
  36.       if (!activated) {
  37.          System.out.println("Software Violation - this class may only be used in conjunction with JDesignerPro.");
  38.       } else {
  39.          this.thisLayout = new JDPRowLayout(3, 1, var1);
  40.          this.thisInsets = new Insets(3, 5, 0, 0);
  41.          ((Container)this).setLayout(this.thisLayout);
  42.          this.scrollEast = new Scrollbar(1, 0, 100, 0, 100);
  43.          ((Container)this).add("scrollEast", this.scrollEast);
  44.          this.scrollSouth = new Scrollbar(0, 0, 100, 0, 100);
  45.          ((Container)this).add("scrollSouth", this.scrollSouth);
  46.       }
  47.    }
  48.  
  49.    public Component getLeftComp(int var1) {
  50.       return var1 >= this.thisLayout.leftc.length ? null : this.thisLayout.leftc[var1];
  51.    }
  52.  
  53.    public Component getRightComp(int var1) {
  54.       return var1 >= this.thisLayout.rightc.length ? null : this.thisLayout.rightc[var1];
  55.    }
  56.  
  57.    public Insets insets() {
  58.       return this.thisInsets;
  59.    }
  60.  
  61.    public boolean handleEvent(Event var1) {
  62.       Dimension var2 = ((Component)this).size();
  63.       if (var1.target.equals(this.scrollEast)) {
  64.          switch (var1.id) {
  65.             case 601:
  66.                this.dropEvent = true;
  67.                this.yOffset -= 20;
  68.                break;
  69.             case 602:
  70.                this.dropEvent = true;
  71.                this.yOffset += 20;
  72.                break;
  73.             case 603:
  74.                this.dropEvent = true;
  75.                this.yOffset -= var2.height;
  76.                break;
  77.             case 604:
  78.                this.dropEvent = true;
  79.                this.yOffset += var2.height;
  80.                break;
  81.             case 605:
  82.                if (this.dropEvent) {
  83.                   this.dropEvent = false;
  84.                   return true;
  85.                }
  86.  
  87.                this.yOffset = this.scrollEast.getValue();
  88.                break;
  89.             default:
  90.                this.dropEvent = false;
  91.          }
  92.  
  93.          this.reDrawPanel();
  94.          var1.target = this;
  95.          super.handleEvent(var1);
  96.          return false;
  97.       } else if (var1.target.equals(this.scrollSouth)) {
  98.          switch (var1.id) {
  99.             case 601:
  100.                this.dropEvent = true;
  101.                this.xOffset -= 20;
  102.                break;
  103.             case 602:
  104.                this.dropEvent = true;
  105.                this.xOffset += 20;
  106.                break;
  107.             case 603:
  108.                this.dropEvent = true;
  109.                this.xOffset -= var2.width;
  110.                break;
  111.             case 604:
  112.                this.dropEvent = true;
  113.                this.xOffset += var2.width;
  114.                break;
  115.             case 605:
  116.                if (this.dropEvent) {
  117.                   this.dropEvent = false;
  118.                   return true;
  119.                }
  120.  
  121.                this.xOffset = this.scrollSouth.getValue();
  122.                break;
  123.             default:
  124.                this.dropEvent = false;
  125.          }
  126.  
  127.          this.reDrawPanel();
  128.          var1.target = this;
  129.          super.handleEvent(var1);
  130.          return false;
  131.       } else {
  132.          this.dropEvent = false;
  133.          return false;
  134.       }
  135.    }
  136.  
  137.    public int getLineCount() {
  138.       int var1 = 0;
  139.  
  140.       for(int var2 = 0; var2 < this.thisLayout.leftc.length; ++var2) {
  141.          if (this.thisLayout.leftc[var2] != null || this.thisLayout.rightc[var2] != null) {
  142.             var1 = var2 + 1;
  143.          }
  144.       }
  145.  
  146.       return var1;
  147.    }
  148.  
  149.    public void reDrawPanel() {
  150.       Dimension var1 = ((Component)this).size();
  151.       Dimension var2 = ((Container)this).preferredSize();
  152.       if (this.xOffset < 0) {
  153.          this.xOffset = 0;
  154.       }
  155.  
  156.       if (this.xOffset > var2.width - var1.width) {
  157.          this.xOffset = var2.width - var1.width;
  158.       }
  159.  
  160.       if (this.yOffset < 0) {
  161.          this.yOffset = 0;
  162.       }
  163.  
  164.       if (this.yOffset > var2.height - var1.height) {
  165.          this.yOffset = var2.height - var1.height;
  166.       }
  167.  
  168.       int var3 = 0;
  169.       int var4 = 0;
  170.       if (System.getProperty("java.vendor").startsWith("Netscape") && System.getProperty("java.version").compareTo("1.1.5") < 0 || System.getProperty("java.vendor").startsWith("Microsoft") && System.getProperty("java.version").compareTo("1.1.4") < 0) {
  171.          var3 = var1.width;
  172.          var4 = var1.height;
  173.       }
  174.  
  175.       if (var2.width - 10 >= var1.width) {
  176.          this.scrollEast.setValues(this.yOffset, var1.height, 0, var2.height - var4);
  177.       } else {
  178.          this.scrollEast.setValues(this.yOffset, var1.height, 0, var2.height + 5 - var4);
  179.       }
  180.  
  181.       this.scrollSouth.setValues(this.xOffset, var1.width, 0, var2.width - var3);
  182.       ((Container)this).layout();
  183.    }
  184. }
  185.