home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / Share / Java / JDesignerPro / Jdp3_0.exe / data1.cab / Program_Files / JDPSplitPanel.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-04-09  |  3.7 KB  |  226 lines

  1. import java.awt.Color;
  2. import java.awt.Component;
  3. import java.awt.Container;
  4. import java.awt.Event;
  5. import java.awt.Insets;
  6. import java.awt.Panel;
  7.  
  8. public class JDPSplitPanel extends Panel {
  9.    JDPUser user;
  10.    static boolean activated;
  11.    JDPSplitLayout thisLayout;
  12.    Insets thisInsets;
  13.    Panel dragXPanel;
  14.    Panel dragYPanel;
  15.    int saveXpos;
  16.    int saveYpos;
  17.    Color saveColor;
  18.    boolean draggingXPanel;
  19.    boolean draggingYPanel;
  20.    public static final int PANEL_RESIZED = 10011;
  21.  
  22.    public void setLeftPercentage(float var1) {
  23.       this.thisLayout.setLeftPercentage(var1);
  24.       ((Container)this).layout();
  25.       ((Component)this).paintAll(((Component)this).getGraphics());
  26.    }
  27.  
  28.    public float getLeftPercentage() {
  29.       return this.thisLayout.getLeftPercentage();
  30.    }
  31.  
  32.    public void setTopPercentage(float var1) {
  33.       this.thisLayout.setTopPercentage(var1);
  34.       ((Container)this).layout();
  35.       ((Component)this).paintAll(((Component)this).getGraphics());
  36.    }
  37.  
  38.    public float getTopPercentage() {
  39.       return this.thisLayout.getTopPercentage();
  40.    }
  41.  
  42.    public JDPSplitPanel(JDPUser var1) {
  43.       this.createPanel(var1, 1, 1);
  44.    }
  45.  
  46.    public JDPSplitPanel(JDPUser var1, int var2, int var3) {
  47.       this.createPanel(var1, var2, var3);
  48.    }
  49.  
  50.    public Component getBottomLeftComp() {
  51.       return this.thisLayout.lowerLeft;
  52.    }
  53.  
  54.    public Component getBottomRightComp() {
  55.       return this.thisLayout.lowerRight;
  56.    }
  57.  
  58.    public Component getTopLeftComp() {
  59.       return this.thisLayout.upperLeft;
  60.    }
  61.  
  62.    public Component getTopRightComp() {
  63.       return this.thisLayout.upperRight;
  64.    }
  65.  
  66.    public Insets insets() {
  67.       return this.thisInsets;
  68.    }
  69.  
  70.    public boolean handleEvent(Event var1) {
  71.       switch (var1.id) {
  72.          case 501:
  73.             if (var1.target.equals(this.thisLayout.dragXPanel)) {
  74.                ((Component)this).requestFocus();
  75.                this.saveXpos = var1.x;
  76.                if (this.saveColor == null) {
  77.                   this.saveColor = this.dragXPanel.getBackground();
  78.                }
  79.  
  80.                this.thisLayout.dragXPanel.setBackground(JDPUtils.darker(((Component)this).getBackground()));
  81.                this.thisLayout.dragXPanel.repaint();
  82.                this.thisLayout.showXdragPanel(var1.x);
  83.                this.draggingXPanel = true;
  84.                if (this.user.jdpMainWindow != null) {
  85.                   this.user.jdpMainWindow.setCursor(10);
  86.                }
  87.  
  88.                return true;
  89.             } else {
  90.                if (var1.target.equals(this.thisLayout.dragYPanel)) {
  91.                   ((Component)this).requestFocus();
  92.                   this.saveYpos = var1.y;
  93.                   if (this.saveColor == null) {
  94.                      this.saveColor = this.thisLayout.dragYPanel.getBackground();
  95.                   }
  96.  
  97.                   this.thisLayout.dragYPanel.setBackground(JDPUtils.darker(((Component)this).getBackground()));
  98.                   this.thisLayout.dragYPanel.repaint();
  99.                   this.thisLayout.showYdragPanel(var1.y);
  100.                   this.draggingYPanel = true;
  101.                   if (this.user.jdpMainWindow != null) {
  102.                      this.user.jdpMainWindow.setCursor(8);
  103.                   }
  104.  
  105.                   return true;
  106.                }
  107.  
  108.                return false;
  109.             }
  110.          case 502:
  111.             if (this.draggingXPanel) {
  112.                this.thisLayout.dragXPanel.setBackground(this.saveColor);
  113.                this.thisLayout.dragXPanel.repaint();
  114.                this.saveColor = null;
  115.                this.draggingXPanel = false;
  116.                if (this.user.jdpMainWindow != null) {
  117.                   this.user.jdpMainWindow.setCursor(0);
  118.                }
  119.  
  120.                this.thisLayout.moveXdivider(var1.x);
  121.                ((Container)this).layout();
  122.                ((Component)this).paintAll(((Component)this).getGraphics());
  123.                Event var3 = new Event(this, 10011, (Object)null);
  124.                ((Component)this).getParent().postEvent(var3);
  125.                return true;
  126.             } else {
  127.                if (this.draggingYPanel) {
  128.                   this.thisLayout.dragYPanel.setBackground(this.saveColor);
  129.                   this.thisLayout.dragYPanel.repaint();
  130.                   this.saveColor = null;
  131.                   this.draggingYPanel = false;
  132.                   if (this.user.jdpMainWindow != null) {
  133.                      this.user.jdpMainWindow.setCursor(0);
  134.                   }
  135.  
  136.                   this.thisLayout.moveYdivider(var1.y);
  137.                   ((Container)this).layout();
  138.                   ((Component)this).paintAll(((Component)this).getGraphics());
  139.                   Event var2 = new Event(this, 10011, (Object)null);
  140.                   ((Component)this).getParent().postEvent(var2);
  141.                   return true;
  142.                }
  143.  
  144.                return false;
  145.             }
  146.          case 503:
  147.          case 504:
  148.             if (var1.target.equals(this.thisLayout.dragXPanel)) {
  149.                if (this.user.jdpMainWindow != null) {
  150.                   this.user.jdpMainWindow.setCursor(10);
  151.                }
  152.  
  153.                return true;
  154.             } else {
  155.                if (var1.target.equals(this.thisLayout.dragYPanel)) {
  156.                   if (this.user.jdpMainWindow != null) {
  157.                      this.user.jdpMainWindow.setCursor(8);
  158.                   }
  159.  
  160.                   return true;
  161.                }
  162.  
  163.                return false;
  164.             }
  165.          case 505:
  166.             if (var1.target.equals(this.thisLayout.dragXPanel) && !this.draggingXPanel) {
  167.                if (this.user.jdpMainWindow != null) {
  168.                   this.user.jdpMainWindow.setCursor(0);
  169.                }
  170.  
  171.                return true;
  172.             } else {
  173.                if (var1.target.equals(this.thisLayout.dragYPanel) && !this.draggingYPanel) {
  174.                   if (this.user.jdpMainWindow != null) {
  175.                      this.user.jdpMainWindow.setCursor(0);
  176.                   }
  177.  
  178.                   return true;
  179.                }
  180.  
  181.                return false;
  182.             }
  183.          case 506:
  184.             if (this.draggingXPanel) {
  185.                this.thisLayout.showXdragPanel(var1.x);
  186.                return true;
  187.             } else {
  188.                if (this.draggingYPanel) {
  189.                   this.thisLayout.showYdragPanel(var1.y);
  190.                   return true;
  191.                }
  192.  
  193.                return false;
  194.             }
  195.          default:
  196.             if (this.draggingXPanel) {
  197.                this.thisLayout.showXdragPanel(var1.x);
  198.             }
  199.  
  200.             if (this.draggingYPanel) {
  201.                this.thisLayout.showYdragPanel(var1.y);
  202.             }
  203.  
  204.             return false;
  205.       }
  206.    }
  207.  
  208.    void createPanel(JDPUser var1, int var2, int var3) {
  209.       this.user = var1;
  210.       activated = JDPUser.classactivated;
  211.       if (!activated) {
  212.          System.out.println("Software Violation - this class may only be used in conjunction with JDesignerPro.");
  213.       } else {
  214.          this.thisInsets = new Insets(0, 0, 0, 0);
  215.          this.dragXPanel = new Panel();
  216.          this.dragYPanel = new Panel();
  217.          this.thisLayout = new JDPSplitLayout(var2, var3);
  218.          this.thisLayout.dragXPanel = this.dragXPanel;
  219.          this.thisLayout.dragYPanel = this.dragYPanel;
  220.          ((Container)this).setLayout(this.thisLayout);
  221.          ((Container)this).add(this.dragXPanel);
  222.          ((Container)this).add(this.dragYPanel);
  223.       }
  224.    }
  225. }
  226.