home *** CD-ROM | disk | FTP | other *** search
/ Datatid 2000 #1 / Datatid-2000-01.iso / Internet / JAVA_NAVIGATOR / JAVANAVIGATOR.EXE / %MAINDIR% / files / JClass / JAVATab.jar / BaseTabbedPanel.class (.txt) next >
Encoding:
Java Class File  |  1999-06-09  |  15.1 KB  |  870 lines

  1. import java.awt.Canvas;
  2. import java.awt.Color;
  3. import java.awt.Component;
  4. import java.awt.Container;
  5. import java.awt.Dimension;
  6. import java.awt.Event;
  7. import java.awt.Font;
  8. import java.awt.FontMetrics;
  9. import java.awt.Graphics;
  10. import java.awt.Image;
  11. import java.awt.Insets;
  12. import java.awt.LayoutManager;
  13. import java.awt.Panel;
  14. import java.awt.Polygon;
  15. import java.awt.Rectangle;
  16. import java.util.Vector;
  17.  
  18. public abstract class BaseTabbedPanel extends Panel {
  19.    public static final int TOP = 0;
  20.    public static final int BOTTOM = 1;
  21.    public static final int ROUNDED = 0;
  22.    public static final int SQUARE = 1;
  23.    private int TF_LEFT;
  24.    private int TF_RIGHT;
  25.    private int TF_TOP;
  26.    private int TF_BOTTOM;
  27.    private int TF_BTN_HEIGHT;
  28.    private Vector vLabels;
  29.    private Vector vEnabled;
  30.    private Vector vPolys;
  31.    protected int curIndex;
  32.    private Font fReg;
  33.    private Font fSel;
  34.    private Font fSReg;
  35.    private Font fSSel;
  36.    private Font fFont;
  37.    private Image imgBG;
  38.    private Component userPanel;
  39.    private int iTabsPosition;
  40.    private int iTabsStyle;
  41.    private int osAdjustment;
  42.    private int firstVisibleTab;
  43.    private DirectionButton dbLeft;
  44.    private DirectionButton dbRight;
  45.    private Polygon nullPoly;
  46.    private int lastWidth;
  47.    Color cLabelColor;
  48.    Color cMOLabelColor;
  49.    Color oldColor;
  50.    private int iMOLabel;
  51.    private int iiMOLabel;
  52.    private boolean bShowTabsOnly;
  53.    int oldx;
  54.    private Insets btpInsets;
  55.  
  56.    public BaseTabbedPanel() {
  57.       this(0, 0);
  58.    }
  59.  
  60.    public BaseTabbedPanel(boolean bTabsOnTop) {
  61.       this(bTabsOnTop ? 0 : 1, bTabsOnTop ? 0 : 1);
  62.    }
  63.  
  64.    public BaseTabbedPanel(int tabsPostion, int tabsStyle) {
  65.       this.TF_TOP = 23;
  66.       this.TF_BTN_HEIGHT = 20;
  67.       this.curIndex = -1;
  68.       this.lastWidth = -1;
  69.       this.cLabelColor = Color.black;
  70.       this.cMOLabelColor = new Color(255, 0, 0);
  71.       this.bShowTabsOnly = false;
  72.       this.vLabels = new Vector();
  73.       this.vEnabled = new Vector();
  74.       this.vPolys = new Vector();
  75.       this.btpInsets = new Insets(0, 0, 0, 0);
  76.       this.setTabsInfo(tabsPostion, tabsStyle);
  77.       this.fReg = new Font("Helvetica", 0, 12);
  78.       this.fSel = new Font("Helvetica", 1, 12);
  79.       if (System.getProperty("os.name").startsWith("S")) {
  80.          this.osAdjustment = -1;
  81.       } else {
  82.          this.osAdjustment = 0;
  83.       }
  84.  
  85.       super.setLayout((LayoutManager)null);
  86.       this.dbLeft = new DirectionButton(0);
  87.       this.dbRight = new DirectionButton(1);
  88.       if (this.imgBG != null) {
  89.          this.dbRight.setBGImage(this.imgBG);
  90.          this.dbLeft.setBGImage(this.imgBG);
  91.       }
  92.  
  93.       this.dbLeft.setShowFocus(false);
  94.       this.dbRight.setShowFocus(false);
  95.       this.dbLeft.shrinkTriangle(1, 1, 0, 1);
  96.       this.dbRight.shrinkTriangle(1, 1, 0, 1);
  97.       super.add(this.dbLeft, -1);
  98.       super.add(this.dbRight, -1);
  99.       this.nullPoly = new Polygon();
  100.       this.nullPoly.addPoint(0, 0);
  101.       this.nullPoly.addPoint(1, 1);
  102.       this.nullPoly.addPoint(0, 0);
  103.    }
  104.  
  105.    public void setLabelColor(Color c) {
  106.       this.cLabelColor = c;
  107.       System.out.println(this.cLabelColor);
  108.       this.dbRight.setForeColor(this.cLabelColor);
  109.       this.dbLeft.setForeColor(this.cLabelColor);
  110.       ((Component)this).invalidate();
  111.    }
  112.  
  113.    public void setBGImage(Image img) {
  114.       this.imgBG = img;
  115.       ((Component)this).invalidate();
  116.    }
  117.  
  118.    public void showTabsOnly(boolean bShowTabsOnly1) {
  119.       this.bShowTabsOnly = bShowTabsOnly1;
  120.       ((Component)this).invalidate();
  121.    }
  122.  
  123.    public void setMOColor(Color c) {
  124.       this.cMOLabelColor = c;
  125.       this.iMOLabel = 999;
  126.       ((Component)this).invalidate();
  127.    }
  128.  
  129.    public void setMOLabelColor(Color c, int index) {
  130.       if (this.oldColor == null) {
  131.          this.oldColor = c;
  132.       }
  133.  
  134.       if (index == 999) {
  135.          this.cMOLabelColor = this.cLabelColor;
  136.       } else {
  137.          this.cMOLabelColor = c;
  138.       }
  139.  
  140.       this.iMOLabel = index;
  141.       ((Component)this).repaint();
  142.       ((Component)this).invalidate();
  143.    }
  144.  
  145.    public void setFont(Font f) {
  146.       if (f != null) {
  147.          this.fFont = f;
  148.       }
  149.  
  150.       ((Component)this).invalidate();
  151.  
  152.       try {
  153.          this.fReg = new Font(this.fFont.getName(), 0, this.fFont.getSize());
  154.          this.fSel = new Font(this.fFont.getName(), 1, this.fFont.getSize());
  155.       } catch (Exception var2) {
  156.          this.fReg = this.fSReg;
  157.          this.fSel = this.fSSel;
  158.       }
  159.    }
  160.  
  161.    public void setTabsPosition(int tabsPosition) {
  162.       if (this.iTabsPosition != tabsPosition) {
  163.          this.setTabsInfo(tabsPosition, this.iTabsStyle);
  164.       }
  165.  
  166.    }
  167.  
  168.    public int getTabsPosition() {
  169.       return this.iTabsPosition;
  170.    }
  171.  
  172.    public Color getMOColor() {
  173.       return this.cMOLabelColor;
  174.    }
  175.  
  176.    public void setTabsStyle(int tabsStyle) {
  177.       if (this.iTabsStyle != tabsStyle) {
  178.          this.setTabsInfo(this.iTabsPosition, tabsStyle);
  179.       }
  180.  
  181.    }
  182.  
  183.    public int getTabsStyle() {
  184.       return this.iTabsStyle;
  185.    }
  186.  
  187.    public void setTabsInfo(int tabsPosition, int tabsStyle) {
  188.       this.iTabsPosition = tabsPosition;
  189.       if (this.iTabsPosition == 0) {
  190.          this.iTabsStyle = 0;
  191.       } else {
  192.          this.iTabsStyle = tabsStyle;
  193.       }
  194.  
  195.       if (this.iTabsStyle == 0) {
  196.          this.TF_BTN_HEIGHT = 20;
  197.       } else {
  198.          this.TF_BTN_HEIGHT = 17;
  199.       }
  200.    }
  201.  
  202.    public void setPanel(Component p) {
  203.       this.removeAll();
  204.       this.userPanel = p;
  205.       if (this.userPanel != null) {
  206.          super.add(this.userPanel, -1);
  207.          this.userPanel.requestFocus();
  208.       }
  209.  
  210.       ((Component)this).repaint();
  211.    }
  212.  
  213.    public int setTabLabelColor(Event evt) {
  214.       int sizeR = this.vPolys.size();
  215.  
  216.       for(int x = 0; x < sizeR; ++x) {
  217.          try {
  218.             Polygon p = (Polygon)this.vPolys.elementAt(x);
  219.             if (p != this.nullPoly && p.inside(evt.x, evt.y)) {
  220.                if (this.iMOLabel != x) {
  221.                   if (this.cMOLabelColor.equals(((Component)this).getForeground())) {
  222.                      this.cMOLabelColor = this.oldColor;
  223.                   }
  224.  
  225.                   this.setMOLabelColor(this.cMOLabelColor, x);
  226.                   this.iiMOLabel = x;
  227.                   this.iMOLabel = x;
  228.                   this.oldx = x;
  229.                }
  230.  
  231.                this.iiMOLabel = this.iMOLabel;
  232.                return this.iiMOLabel;
  233.             }
  234.          } catch (ArrayIndexOutOfBoundsException var5) {
  235.          }
  236.       }
  237.  
  238.       return 999;
  239.    }
  240.  
  241.    public void showPanel(Component p) {
  242.       if (this.userPanel != null) {
  243.          this.userPanel.hide();
  244.       }
  245.  
  246.       this.userPanel = p;
  247.       if (this.userPanel != null) {
  248.          Component[] comps = ((Container)this).getComponents();
  249.          int l = comps.length;
  250.  
  251.          int x;
  252.          for(x = 0; x < l && comps[x] != this.userPanel; ++x) {
  253.          }
  254.  
  255.          if (x == l) {
  256.             super.add(this.userPanel, -1);
  257.          }
  258.  
  259.          this.userPanel.show();
  260.          this.userPanel.requestFocus();
  261.          ((Container)this).validate();
  262.          ((Component)this).repaint();
  263.       }
  264.  
  265.    }
  266.  
  267.    public int addTab(String sLabel, boolean bEnabled) {
  268.       this.vLabels.addElement(sLabel);
  269.       this.vEnabled.addElement(new Boolean(bEnabled));
  270.       int index = this.vLabels.size() - 1;
  271.       if (this.curIndex == -1 && bEnabled) {
  272.          this.showTab(index);
  273.       }
  274.  
  275.       return index;
  276.    }
  277.  
  278.    public synchronized void setTab(String sLabel, boolean bEnabled, int index) {
  279.       if (index >= 0 && index < this.vLabels.size()) {
  280.          if (index != this.curIndex || bEnabled) {
  281.             try {
  282.                this.vLabels.setElementAt(sLabel, index);
  283.                this.vEnabled.setElementAt(new Boolean(bEnabled), index);
  284.                ((Component)this).repaint();
  285.             } catch (ArrayIndexOutOfBoundsException var4) {
  286.             }
  287.          }
  288.       }
  289.    }
  290.  
  291.    public synchronized void setLabel(String sLabel, int index) {
  292.       if (index >= 0 && index < this.vLabels.size()) {
  293.          try {
  294.             this.vLabels.setElementAt(sLabel, index);
  295.             ((Component)this).repaint();
  296.          } catch (ArrayIndexOutOfBoundsException var3) {
  297.          }
  298.       }
  299.    }
  300.  
  301.    public synchronized String getLabel(int index) {
  302.       if (index >= 0 && index < this.vLabels.size()) {
  303.          try {
  304.             return (String)this.vLabels.elementAt(index);
  305.          } catch (ArrayIndexOutOfBoundsException var2) {
  306.             return "";
  307.          }
  308.       } else {
  309.          return "";
  310.       }
  311.    }
  312.  
  313.    public synchronized void setEnabled(boolean bEnabled, int index) {
  314.       if (index >= 0 && index < this.vLabels.size()) {
  315.          if (index != this.curIndex || bEnabled) {
  316.             try {
  317.                this.vEnabled.setElementAt(new Boolean(bEnabled), index);
  318.                ((Component)this).repaint();
  319.             } catch (ArrayIndexOutOfBoundsException var3) {
  320.             }
  321.          }
  322.       }
  323.    }
  324.  
  325.    public void showTab(int index) {
  326.       if (index >= 0 && index < this.vLabels.size() && index != this.curIndex) {
  327.          if (this.tabIsEnabled(index)) {
  328.             this.curIndex = index;
  329.             ((Component)this).invalidate();
  330.             ((Container)this).validate();
  331.             ((Component)this).repaint();
  332.             ((Component)this).postEvent(new Event(this, 1001, (Object)null));
  333.          }
  334.  
  335.       }
  336.    }
  337.  
  338.    public boolean tabIsEnabled(int index) {
  339.       if (index >= 0 && index < this.vLabels.size()) {
  340.          try {
  341.             Boolean bool = (Boolean)this.vEnabled.elementAt(index);
  342.             if (bool) {
  343.                return true;
  344.             }
  345.          } catch (ArrayIndexOutOfBoundsException var3) {
  346.          }
  347.  
  348.          return false;
  349.       } else {
  350.          return false;
  351.       }
  352.    }
  353.  
  354.    public int currentTabIndex() {
  355.       return this.curIndex;
  356.    }
  357.  
  358.    public void enableTab(boolean bEnable, int index) {
  359.       if (index >= 0 && index < this.vEnabled.size() && index != this.curIndex) {
  360.          try {
  361.             this.vEnabled.setElementAt(new Boolean(bEnable), index);
  362.             ((Component)this).repaint();
  363.          } catch (ArrayIndexOutOfBoundsException var3) {
  364.          }
  365.       }
  366.    }
  367.  
  368.    public void removeTab(int index) {
  369.       if (index >= 0 && index < this.vEnabled.size() && index != this.curIndex) {
  370.          try {
  371.             this.vLabels.removeElementAt(index);
  372.             this.vEnabled.removeElementAt(index);
  373.             ((Component)this).repaint();
  374.          } catch (ArrayIndexOutOfBoundsException var2) {
  375.          }
  376.       }
  377.    }
  378.  
  379.    public void removeAllTabs() {
  380.       this.vLabels = new Vector();
  381.       this.vEnabled = new Vector();
  382.       this.vPolys = new Vector();
  383.       this.curIndex = -1;
  384.       this.firstVisibleTab = 0;
  385.       this.lastWidth = -1;
  386.       this.removeAll();
  387.       ((Component)this).repaint();
  388.    }
  389.  
  390.    public void layout() {
  391.       Rectangle r = ((Component)this).bounds();
  392.       int width = r.width - this.TF_LEFT + this.TF_RIGHT;
  393.       if (width >= 0) {
  394.          int height = r.height - this.TF_TOP + this.TF_BOTTOM;
  395.          if (height >= 0) {
  396.             int col = this.TF_LEFT;
  397.             int row = 0;
  398.             if (this.iTabsPosition == 0) {
  399.                row = this.TF_TOP;
  400.             } else {
  401.                row = this.TF_TOP - this.TF_BTN_HEIGHT - 5;
  402.             }
  403.  
  404.             if (this.userPanel != null) {
  405.                this.userPanel.reshape(col + 3, row + 3, width - 6, height - 5);
  406.                this.userPanel.invalidate();
  407.                this.userPanel.validate();
  408.                if (this.userPanel instanceof Canvas || this.userPanel instanceof Panel) {
  409.                   this.userPanel.repaint();
  410.                   return;
  411.                }
  412.  
  413.                ((Component)this).repaint();
  414.             }
  415.  
  416.          }
  417.       }
  418.    }
  419.  
  420.    public synchronized void paint(Graphics g) {
  421.       Rectangle r = ((Component)this).bounds();
  422.       int width = r.width - this.TF_LEFT + this.TF_RIGHT;
  423.       if (width >= 0) {
  424.          int height = r.height - this.TF_TOP + this.TF_BOTTOM;
  425.          if (height >= 0) {
  426.             if (r.width > this.lastWidth) {
  427.                this.firstVisibleTab = 0;
  428.             }
  429.  
  430.             this.lastWidth = r.width;
  431.             int col = this.TF_LEFT;
  432.             Color c = g.getColor();
  433.             g.setColor(((Component)this).getBackground());
  434.             int row;
  435.             if (this.iTabsPosition == 0) {
  436.                row = this.TF_TOP;
  437.             } else {
  438.                row = this.TF_TOP - this.TF_BTN_HEIGHT - 5;
  439.             }
  440.  
  441.             if (this.imgBG != null) {
  442.                for(int x = 0; x < r.height; x += this.imgBG.getHeight(this)) {
  443.                   for(int i = 0; i < r.width; i += this.imgBG.getWidth(this)) {
  444.                      g.drawImage(this.imgBG, i, x, this.imgBG.getWidth(this), this.imgBG.getHeight(this), this);
  445.                   }
  446.                }
  447.             } else {
  448.                g.clearRect(0, 0, r.width, r.height);
  449.             }
  450.  
  451.             if (!this.bShowTabsOnly) {
  452.                if (((Component)this).getBackground().equals(Color.white)) {
  453.                   g.setColor(Color.black);
  454.                } else {
  455.                   g.setColor(Color.white);
  456.                }
  457.  
  458.                if (this.imgBG == null) {
  459.                   g.drawLine(col, row, col + width - 1, row);
  460.                }
  461.  
  462.                g.drawLine(col, row, col, row + height - 1);
  463.                g.setColor(Color.gray);
  464.                if (this.iTabsPosition == 0) {
  465.                   g.drawLine(col + 2, row + height - 2, col + width - 2, row + height - 2);
  466.                } else if (this.imgBG == null) {
  467.                   g.drawLine(col + 2, row + height - 2, col + width - 2, row + height - 2);
  468.                }
  469.  
  470.                g.drawLine(col + width - 2, row + 2, col + width - 2, row + height - 2);
  471.                if (((Component)this).getBackground().equals(Color.black)) {
  472.                   g.setColor(Color.white);
  473.                } else {
  474.                   g.setColor(Color.black);
  475.                }
  476.  
  477.                if (this.imgBG == null) {
  478.                   g.drawLine(col + 1, row + height - 1, col + width - 1, row + height - 1);
  479.                }
  480.  
  481.                g.drawLine(col + width - 1, row + 1, col + width - 1, row + height - 1);
  482.             }
  483.  
  484.             int x2 = this.TF_LEFT + 8;
  485.             int x3 = 0;
  486.             int x4 = this.TF_LEFT;
  487.             int sze = this.vLabels.size();
  488.             this.vPolys.removeAllElements();
  489.             Font f = g.getFont();
  490.             FontMetrics fm = ((Component)this).getFontMetrics(this.fReg);
  491.             FontMetrics fms = ((Component)this).getFontMetrics(this.fSel);
  492.             int labelWidth = 0;
  493.  
  494.             int w;
  495.             for(w = 0; w < this.firstVisibleTab; ++w) {
  496.                this.vPolys.addElement(this.nullPoly);
  497.             }
  498.  
  499.             if (w > 0) {
  500.                x4 += 2;
  501.             }
  502.  
  503.             for(; w < sze; ++w) {
  504.                Polygon p = new Polygon();
  505.  
  506.                try {
  507.                   String sLabel = (String)this.vLabels.elementAt(w);
  508.                   if (w == this.curIndex) {
  509.                      labelWidth = fms.stringWidth(sLabel);
  510.                   } else {
  511.                      labelWidth = fm.stringWidth(sLabel);
  512.                   }
  513.  
  514.                   int y1;
  515.                   int y2;
  516.                   if (this.iTabsPosition == 0) {
  517.                      y1 = this.TF_TOP - this.TF_BTN_HEIGHT;
  518.                      y2 = this.TF_TOP - 1;
  519.                   } else {
  520.                      y1 = r.height + this.TF_BOTTOM + 1;
  521.                      y2 = r.height + this.TF_BOTTOM - this.TF_BTN_HEIGHT - 5;
  522.                   }
  523.  
  524.                   int x1;
  525.                   if (this.iTabsStyle == 0) {
  526.                      x1 = x4 + 2;
  527.                      x2 = x1 + labelWidth + 13;
  528.                   } else {
  529.                      x1 = x2 - 7;
  530.                      x2 = x1 + labelWidth + 28;
  531.                   }
  532.  
  533.                   if (x2 + 36 - this.TF_RIGHT > r.width) {
  534.                      break;
  535.                   }
  536.  
  537.                   if (this.iTabsPosition == 0) {
  538.                      if (w == this.curIndex) {
  539.                         y1 -= 3;
  540.                         x1 -= 2;
  541.                      }
  542.  
  543.                      if (((Component)this).getBackground().equals(Color.white)) {
  544.                         g.setColor(Color.gray);
  545.                      } else {
  546.                         g.setColor(Color.white);
  547.                      }
  548.  
  549.                      if (this.curIndex == w + 1) {
  550.                         g.drawLine(x1 + 2, y1, x2 - 2, y1);
  551.                      } else {
  552.                         g.drawLine(x1 + 2, y1, x2, y1);
  553.                      }
  554.  
  555.                      if (this.curIndex != w - 1) {
  556.                         g.drawLine(x1, y1 + 2, x1, y2);
  557.                         x3 = x1;
  558.                      } else {
  559.                         x3 = x1 + 1;
  560.                      }
  561.  
  562.                      g.drawLine(x1 + 1, y1 + 1, x1 + 1, y1 + 1);
  563.                      if (this.curIndex != w + 1) {
  564.                         g.setColor(Color.gray);
  565.                         g.drawLine(x2, y1, x2, y2);
  566.                         if (((Component)this).getBackground().equals(Color.black)) {
  567.                            g.setColor(Color.white);
  568.                         } else {
  569.                            g.setColor(Color.black);
  570.                         }
  571.  
  572.                         g.drawLine(x2 + 1, y1 + 2, x2 + 1, y2);
  573.                         x4 = x2;
  574.                      } else {
  575.                         x4 = x2 - 1;
  576.                      }
  577.                   } else if (this.iTabsStyle == 1) {
  578.                      g.setColor(Color.gray);
  579.                      g.drawLine(x1 + 9, y1 - 2, x2 - 9, y1 - 2);
  580.                      if (((Component)this).getBackground().equals(Color.black)) {
  581.                         g.setColor(Color.white);
  582.                      } else {
  583.                         g.setColor(Color.black);
  584.                      }
  585.  
  586.                      if (w != 0 && w != this.curIndex) {
  587.                         g.drawLine(col, row, col + width - 1, row);
  588.                         g.drawLine(x1 + 4, y1 - 9, x1 + 9, y1);
  589.                         p.addPoint(x1 + 9, y2);
  590.                         p.addPoint(x1 + 4, y1 - 9);
  591.                      } else {
  592.                         g.drawLine(x1, y2, x1 + 9, y1);
  593.                         p.addPoint(x1, y2);
  594.                      }
  595.  
  596.                      p.addPoint(x1 + 9, y1);
  597.                      p.addPoint(x2 - 9, y1);
  598.                      if (w + 1 == this.curIndex) {
  599.                         p.addPoint(x2 - 5, y1);
  600.                         p.addPoint(x2 - 9, y2);
  601.                      } else {
  602.                         g.drawLine(x2, y2, x2 - 9, y1);
  603.                         p.addPoint(x2, y2);
  604.                      }
  605.  
  606.                      if (w != 1 && w != this.curIndex) {
  607.                         p.addPoint(x1 + 9, y2);
  608.                      } else {
  609.                         p.addPoint(x1, y2);
  610.                      }
  611.                   } else {
  612.                      if (w == this.curIndex) {
  613.                         y1 += 3;
  614.                         x1 -= 2;
  615.                      }
  616.  
  617.                      if (((Component)this).getBackground().equals(Color.white)) {
  618.                         g.setColor(Color.black);
  619.                      } else {
  620.                         g.setColor(Color.white);
  621.                      }
  622.  
  623.                      if (this.curIndex == w + 1) {
  624.                         g.drawLine(x1 + 2, y1, x2 - 2, y1);
  625.                      } else {
  626.                         g.drawLine(x1 + 2, y1, x2, y1);
  627.                      }
  628.  
  629.                      if (this.curIndex != w - 1) {
  630.                         g.drawLine(x1, y1 - 2, x1, y2);
  631.                         x3 = x1;
  632.                      } else {
  633.                         x3 = x1 + 1;
  634.                      }
  635.  
  636.                      g.drawLine(x1 + 1, y1 - 1, x1 + 1, y1 - 1);
  637.                      if (this.curIndex != w + 1) {
  638.                         g.setColor(Color.gray);
  639.                         g.drawLine(x2, y1, x2, y2);
  640.                         if (((Component)this).getBackground().equals(Color.black)) {
  641.                            g.setColor(Color.white);
  642.                         } else {
  643.                            g.setColor(Color.black);
  644.                         }
  645.  
  646.                         g.drawLine(x2 + 1, y1 - 2, x2 + 1, y2);
  647.                         x4 = x2;
  648.                      } else {
  649.                         x4 = x2 - 1;
  650.                      }
  651.                   }
  652.  
  653.                   if (w == this.curIndex) {
  654.                      if (this.iTabsPosition == 0) {
  655.                         ++y2;
  656.                      } else {
  657.                         --y2;
  658.                      }
  659.  
  660.                      g.setColor(((Component)this).getBackground());
  661.                      if (this.imgBG == null) {
  662.                         g.drawLine(x1 + 1, y2, x2, y2);
  663.                         if (this.iTabsPosition == 1) {
  664.                            g.drawLine(x1 + 1, y2 - 1, x2, y2 - 1);
  665.                         }
  666.                      } else {
  667.                         if (((Component)this).getBackground().equals(Color.white)) {
  668.                            g.setColor(Color.black);
  669.                         } else {
  670.                            g.setColor(Color.white);
  671.                         }
  672.  
  673.                         if (this.iTabsPosition == 0) {
  674.                            g.drawLine(col + 1, row, x1 + 1, y2);
  675.                            g.drawLine(x2, y2, col + width - 1, row);
  676.                         } else {
  677.                            g.setColor(Color.black);
  678.                            g.drawLine(col + 1, y2, x1, y2);
  679.                            g.drawLine(x2, y2, col + width - 1, y2);
  680.                            g.setColor(Color.gray);
  681.                            g.drawLine(col + 1, y2 - 1, x1, y2 - 1);
  682.                            g.drawLine(x2, y2 - 1, col + width - 1, y2 - 1);
  683.                         }
  684.                      }
  685.  
  686.                      g.setFont(this.fSel);
  687.                   } else {
  688.                      g.setFont(this.fReg);
  689.                   }
  690.  
  691.                   if (this.iTabsStyle == 0) {
  692.                      p.addPoint(x3, y2);
  693.                      p.addPoint(x4, y2);
  694.                      p.addPoint(x4, y1);
  695.                      p.addPoint(x3, y1);
  696.                      p.addPoint(x3, y2);
  697.                   }
  698.  
  699.                   this.vPolys.addElement(p);
  700.                   if (w == this.iMOLabel) {
  701.                      g.setColor(this.cMOLabelColor);
  702.                   } else {
  703.                      Boolean bool = (Boolean)this.vEnabled.elementAt(w);
  704.                      if (bool) {
  705.                         g.setColor(this.cLabelColor);
  706.                      } else {
  707.                         g.setColor(Color.gray);
  708.                      }
  709.                   }
  710.  
  711.                   if (this.iTabsPosition == 0) {
  712.                      g.drawString(sLabel, x1 + 8, y1 + 15 + this.osAdjustment);
  713.                   } else if (this.iTabsStyle == 0) {
  714.                      g.drawString(sLabel, x1 + 8, y1 - 6 + this.osAdjustment);
  715.                   } else {
  716.                      g.drawString(sLabel, x1 + 14, y1 - 4 + this.osAdjustment);
  717.                   }
  718.                } catch (ArrayIndexOutOfBoundsException var23) {
  719.                }
  720.             }
  721.  
  722.             if (this.firstVisibleTab <= 0 && w >= sze) {
  723.                this.dbLeft.hide();
  724.                this.dbRight.hide();
  725.             } else {
  726.                this.dbLeft.show();
  727.                this.dbRight.show();
  728.                if (this.firstVisibleTab > 0) {
  729.                   this.dbLeft.enable();
  730.                } else {
  731.                   this.dbLeft.disable();
  732.                }
  733.  
  734.                if (w < sze) {
  735.                   this.dbRight.enable();
  736.                } else {
  737.                   this.dbRight.disable();
  738.                }
  739.  
  740.                if (this.iTabsPosition == 0) {
  741.                   this.dbLeft.reshape(r.width - 33 + this.TF_RIGHT, this.TF_TOP - 16, 16, 15);
  742.                   this.dbRight.reshape(r.width - 16 + this.TF_RIGHT, this.TF_TOP - 16, 16, 15);
  743.                } else {
  744.                   this.dbLeft.reshape(r.width - 33 + this.TF_RIGHT, r.height + this.TF_BOTTOM - this.TF_BTN_HEIGHT, 16, 15);
  745.                   this.dbRight.reshape(r.width - 16 + this.TF_RIGHT, r.height + this.TF_BOTTOM - this.TF_BTN_HEIGHT, 16, 15);
  746.                }
  747.             }
  748.  
  749.             while(w < sze) {
  750.                this.vPolys.addElement(this.nullPoly);
  751.                ++w;
  752.             }
  753.  
  754.             g.setFont(f);
  755.             g.setColor(c);
  756.          }
  757.       }
  758.    }
  759.  
  760.    public boolean handleEvent(Event evt) {
  761.       switch (evt.id) {
  762.          case 501:
  763.             int sizeR = this.vPolys.size();
  764.  
  765.             for(int x = 0; x < sizeR; ++x) {
  766.                try {
  767.                   Polygon p = (Polygon)this.vPolys.elementAt(x);
  768.                   if (p != this.nullPoly && p.inside(evt.x, evt.y)) {
  769.                      this.showTab(x);
  770.                      return true;
  771.                   }
  772.                } catch (ArrayIndexOutOfBoundsException var5) {
  773.                }
  774.             }
  775.             break;
  776.          case 1001:
  777.             if (evt.target == this.dbLeft) {
  778.                if (--this.firstVisibleTab < 0) {
  779.                   this.firstVisibleTab = 0;
  780.                } else {
  781.                   ((Component)this).repaint();
  782.                }
  783.  
  784.                return true;
  785.             }
  786.  
  787.             if (evt.target == this.dbRight) {
  788.                int sze = this.vLabels.size();
  789.                if (++this.firstVisibleTab == sze) {
  790.                   --this.firstVisibleTab;
  791.                } else {
  792.                   ((Component)this).repaint();
  793.                }
  794.  
  795.                return true;
  796.             }
  797.       }
  798.  
  799.       return super.handleEvent(evt);
  800.    }
  801.  
  802.    public Component add(Component comp) {
  803.       return comp;
  804.    }
  805.  
  806.    public synchronized Component add(Component comp, int pos) {
  807.       return comp;
  808.    }
  809.  
  810.    public synchronized Component add(String name, Component comp) {
  811.       return comp;
  812.    }
  813.  
  814.    public synchronized void remove(Component comp) {
  815.       if (comp != this.dbLeft && comp != this.dbRight) {
  816.          super.remove(comp);
  817.          if (comp == this.userPanel) {
  818.             this.userPanel = null;
  819.          }
  820.  
  821.       }
  822.    }
  823.  
  824.    public synchronized void removeAll() {
  825.       super.removeAll();
  826.       super.add(this.dbLeft, -1);
  827.       super.add(this.dbRight, -1);
  828.       this.userPanel = null;
  829.    }
  830.  
  831.    public void setLayout(LayoutManager mgr) {
  832.    }
  833.  
  834.    public Insets insets() {
  835.       this.btpInsets = super.insets();
  836.       Insets var10000 = this.btpInsets;
  837.       var10000.left += this.TF_LEFT + 1;
  838.       var10000 = this.btpInsets;
  839.       var10000.right += 2 - this.TF_RIGHT;
  840.       if (this.iTabsPosition == 0) {
  841.          var10000 = this.btpInsets;
  842.          var10000.top += this.TF_TOP + 1;
  843.          var10000 = this.btpInsets;
  844.          var10000.bottom += 2 - this.TF_BOTTOM;
  845.       } else {
  846.          var10000 = this.btpInsets;
  847.          var10000.top += this.TF_TOP - this.TF_BTN_HEIGHT + 1;
  848.          var10000 = this.btpInsets;
  849.          var10000.bottom += this.TF_BTN_HEIGHT + 2 - this.TF_BOTTOM;
  850.       }
  851.  
  852.       return this.btpInsets;
  853.    }
  854.  
  855.    public Dimension preferredSize() {
  856.       Dimension s = ((Component)this).size();
  857.       Dimension m = this.minimumSize();
  858.       return new Dimension(Math.max(s.width, m.width), Math.max(s.height, m.height));
  859.    }
  860.  
  861.    public Dimension minimumSize() {
  862.       if (this.userPanel != null) {
  863.          Dimension s = this.userPanel.minimumSize();
  864.          return new Dimension(s.width + this.btpInsets.left + this.btpInsets.right, s.height + this.btpInsets.top + this.btpInsets.bottom);
  865.       } else {
  866.          return new Dimension(100, 100);
  867.       }
  868.    }
  869. }
  870.