home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2002 June / INTERNET92.ISO / pc / software / windows / building / visual_dhtml / visualdhtmlwin9x_nt.exe / OCslider.___ (.txt) < prev    next >
Encoding:
Java Class File  |  2001-10-19  |  6.8 KB  |  578 lines

  1. import java.awt.Color;
  2. import java.awt.Component;
  3. import java.awt.Dimension;
  4. import java.awt.Event;
  5. import java.awt.Graphics;
  6. import java.awt.Image;
  7. import java.awt.Panel;
  8.  
  9. class OCslider extends Panel implements Runnable {
  10.    // $FF: renamed from: ds java.awt.Dimension
  11.    private Dimension field_0;
  12.    public static final int SCROLL_LINE_UP = 601;
  13.    public static final int SCROLL_LINE_DOWN = 602;
  14.    public static final int SCROLL_PAGE_UP = 603;
  15.    public static final int SCROLL_PAGE_DOWN = 604;
  16.    public static final int SCROLL_ABSOLUTE = 605;
  17.    public int sbHeight = 0;
  18.    public int sbWidth = 0;
  19.    private int sbValue = 0;
  20.    private int pageIncrement = 0;
  21.    private int sbMax = 0;
  22.    private int sbIncrement = 1;
  23.    private Thread goauto = null;
  24.    private boolean paint_called = false;
  25.    private boolean first_run = true;
  26.    private boolean on_top = false;
  27.    private boolean on_bottom = false;
  28.    private boolean m_down = false;
  29.    private boolean dragging_bubble = false;
  30.    private boolean bad_scroll = true;
  31.    private boolean mouse_in = false;
  32.    private boolean m_off = false;
  33.    private boolean bypass = false;
  34.    private Event the_e = null;
  35.    private int auto_type = 0;
  36.    // $FF: renamed from: mx int
  37.    private int field_1 = 0;
  38.    // $FF: renamed from: my int
  39.    private int field_2 = 0;
  40.    private int drag_move = 0;
  41.    private float hbp = 0.0F;
  42.    private Color button_color;
  43.    private Color arrow_color;
  44.    private Color harrow_color;
  45.    private Color bg_color;
  46.    private Color slider_color;
  47.    private Color outline_color;
  48.    private int slider_height;
  49.    private int last_button;
  50.    private int auto_delay;
  51.    private int auto_rate;
  52.    private int bubble_range;
  53.    private float bubble_pos;
  54.    private float bubble_inc;
  55.    private int position;
  56.    private Image sboff;
  57.    private Graphics g_sboff;
  58.  
  59.    public void reshape(int var1, int var2, int var3, int var4) {
  60.       if (var3 * var4 > 0) {
  61.          this.sbWidth = var3;
  62.          this.sbHeight = var4;
  63.          this.field_0 = new Dimension(var3, var4);
  64.          this.figureBubble(true);
  65.          super.reshape(var1, var2, var3, var4);
  66.       }
  67.    }
  68.  
  69.    public void stop() {
  70.       if (this.goauto != null) {
  71.          this.goauto.stop();
  72.          this.goauto = null;
  73.       }
  74.  
  75.    }
  76.  
  77.    public boolean mouseEnter(Event var1, int var2, int var3) {
  78.       this.mouse_in = true;
  79.       return true;
  80.    }
  81.  
  82.    public boolean mouseMove(Event var1, int var2, int var3) {
  83.       if (!this.m_down && !this.bad_scroll) {
  84.          if (this.cButtons(var3)) {
  85.             return true;
  86.          } else {
  87.             this.undoHButtons();
  88.             return true;
  89.          }
  90.       } else {
  91.          return true;
  92.       }
  93.    }
  94.  
  95.    public int getValue() {
  96.       return this.sbValue;
  97.    }
  98.  
  99.    public boolean mouseExit(Event var1, int var2, int var3) {
  100.       if (this.bad_scroll) {
  101.          return true;
  102.       } else {
  103.          this.mouse_in = false;
  104.          this.m_off = true;
  105.          this.undoHButtons();
  106.          return true;
  107.       }
  108.    }
  109.  
  110.    OCslider(int var1) {
  111.       this.button_color = ACutilb.windowColor;
  112.       this.arrow_color = Color.black;
  113.       this.harrow_color = Color.yellow;
  114.       this.bg_color = Color.white;
  115.       this.slider_color = Color.black;
  116.       this.outline_color = ACutilb.windowColor;
  117.       this.slider_height = 6;
  118.       this.last_button = 0;
  119.       this.auto_delay = 5;
  120.       this.auto_rate = 40;
  121.       this.bubble_range = 0;
  122.       this.bubble_pos = 0.0F;
  123.       this.bubble_inc = 0.0F;
  124.       this.position = 0;
  125.       this.sboff = null;
  126.       this.g_sboff = null;
  127.    }
  128.  
  129.    public void paint(Graphics var1) {
  130.       this.paint_called = true;
  131.       this.paintIt(((Component)this).getGraphics());
  132.    }
  133.  
  134.    public boolean mouseUp(Event var1, int var2, int var3) {
  135.       if (this.bad_scroll) {
  136.          return true;
  137.       } else {
  138.          this.m_down = false;
  139.          this.dragging_bubble = false;
  140.          this.last_button = 0;
  141.          this.stop();
  142.          this.auto_type = 0;
  143.          if (this.m_off) {
  144.             this.drawButton(0, this.sbHeight - this.sbWidth, this.sbWidth - 1, this.sbWidth - 1, 2, this.arrow_color);
  145.             this.drawButton(0, 0, this.sbWidth - 1, this.sbWidth - 1, 1, this.arrow_color);
  146.             this.paintIt(((Component)this).getGraphics());
  147.             this.on_bottom = false;
  148.             this.on_top = false;
  149.             this.m_off = false;
  150.             return true;
  151.          } else if (this.on_bottom) {
  152.             this.drawButton(0, this.sbHeight - this.sbWidth, this.sbWidth - 1, this.sbWidth - 1, 2, this.harrow_color);
  153.             this.paintIt(((Component)this).getGraphics());
  154.             return true;
  155.          } else if (this.on_top) {
  156.             this.drawButton(0, 0, this.sbWidth - 1, this.sbWidth - 1, 1, this.harrow_color);
  157.             this.paintIt(((Component)this).getGraphics());
  158.             return true;
  159.          } else {
  160.             return true;
  161.          }
  162.       }
  163.    }
  164.  
  165.    private synchronized void paintIt(Graphics var1) {
  166.       if (this.paint_called) {
  167.          if (!this.first_run) {
  168.             ((Component)this).setBackground(this.bg_color);
  169.             if (this.field_0.height >= 1 && this.field_0.width >= 1) {
  170.                this.sboff = ((Component)this).createImage(this.field_0.width, this.field_0.height);
  171.                this.g_sboff = this.sboff.getGraphics();
  172.                this.drawBar(var1);
  173.                this.first_run = true;
  174.             }
  175.          } else {
  176.             var1.drawImage(this.sboff, 0, 0, this);
  177.          }
  178.       }
  179.    }
  180.  
  181.    public void setValues(int var1, int var2) {
  182.       this.sbMax = var2;
  183.       this.pageIncrement = var1;
  184.       if (this.sbMax < 1) {
  185.          this.bad_scroll = true;
  186.          this.bubble_pos = (float)this.sbWidth;
  187.       } else {
  188.          this.bad_scroll = false;
  189.       }
  190.  
  191.       this.bubble_pos = 0.0F;
  192.       this.sbValue = 0;
  193.       this.figureBubble(true);
  194.    }
  195.  
  196.    public void resize(Dimension var1) {
  197.       if (var1.width * var1.height > 0) {
  198.          this.sbWidth = var1.width;
  199.          this.sbHeight = var1.height;
  200.          this.field_0 = var1;
  201.          this.figureBubble(true);
  202.          super.resize(var1);
  203.       }
  204.    }
  205.  
  206.    public void resize(int var1, int var2) {
  207.       if (var1 * var2 > 0) {
  208.          this.sbWidth = var1;
  209.          this.sbHeight = var2;
  210.          this.field_0 = new Dimension(var1, var2);
  211.          this.figureBubble(true);
  212.          super.resize(var1, var2);
  213.       }
  214.    }
  215.  
  216.    public void start() {
  217.       if (this.goauto == null) {
  218.          this.goauto = new Thread(this);
  219.          this.goauto.start();
  220.       }
  221.  
  222.    }
  223.  
  224.    public void figureBubble(boolean var1) {
  225.       this.bubble_range = this.sbHeight - this.sbWidth * 3;
  226.       this.bubble_inc = (float)this.bubble_range / (float)this.sbMax;
  227.       this.bubble_pos = (float)this.sbValue * this.bubble_inc + (float)this.sbWidth;
  228.       if (var1) {
  229.          this.first_run = false;
  230.          this.paintIt(((Component)this).getGraphics());
  231.       }
  232.  
  233.    }
  234.  
  235.    private void DrawBubble(boolean var1) {
  236.       if (!this.bad_scroll) {
  237.          this.g_sboff.setColor(this.bg_color);
  238.          this.g_sboff.fillRect(0, (int)this.bubble_pos, this.sbWidth, this.sbWidth);
  239.          this.drawSlider();
  240.          if (!var1) {
  241.             this.bubble_pos = (float)this.sbValue * this.bubble_inc + (float)this.sbWidth;
  242.          } else {
  243.             this.bubble_pos = this.hbp;
  244.             float var2 = (this.bubble_pos - (float)this.sbWidth) / (float)this.bubble_range;
  245.             this.sbValue = (int)(var2 * (float)this.sbMax);
  246.          }
  247.  
  248.          this.drawButton(0, (int)this.bubble_pos, this.sbWidth - 1, this.sbWidth - 1, 0, this.arrow_color);
  249.       }
  250.  
  251.    }
  252.  
  253.    private boolean cButtons(int var1) {
  254.       if (var1 < this.sbWidth && var1 >= 0) {
  255.          if (!this.on_top) {
  256.             this.on_top = true;
  257.             if (!this.m_down) {
  258.                this.drawButton(0, 0, this.sbWidth - 1, this.sbWidth - 1, 1, this.harrow_color);
  259.             } else if (this.last_button != 1) {
  260.                this.drawButton(0, 0, this.sbWidth - 1, this.sbWidth - 1, 3, this.harrow_color);
  261.                this.bypass = true;
  262.                this.auto_type = 2;
  263.                this.start();
  264.             } else {
  265.                this.on_top = false;
  266.             }
  267.  
  268.             this.paintIt(((Component)this).getGraphics());
  269.          }
  270.  
  271.          return true;
  272.       } else if (var1 > this.sbHeight - this.sbWidth && var1 <= this.sbHeight) {
  273.          if (!this.on_bottom) {
  274.             this.on_bottom = true;
  275.             if (!this.m_down) {
  276.                this.drawButton(0, this.sbHeight - this.sbWidth, this.sbWidth - 1, this.sbWidth - 1, 2, this.harrow_color);
  277.             } else if (this.last_button != 2) {
  278.                this.drawButton(0, this.sbHeight - this.sbWidth, this.sbWidth - 1, this.sbWidth - 1, 4, this.harrow_color);
  279.                this.bypass = true;
  280.                this.auto_type = 1;
  281.                this.start();
  282.             } else {
  283.                this.on_bottom = false;
  284.             }
  285.  
  286.             this.paintIt(((Component)this).getGraphics());
  287.          }
  288.  
  289.          return true;
  290.       } else {
  291.          return false;
  292.       }
  293.    }
  294.  
  295.    private void drawButton(int var1, int var2, int var3, int var4, int var5, Color var6) {
  296.       this.g_sboff.setColor(this.button_color);
  297.       if (var5 != 0 && var5 != 1 && var5 != 2) {
  298.          this.g_sboff.fillRect(var1 + 1, var2 + 1, var3 - 1, var4 - 1);
  299.       } else {
  300.          this.g_sboff.fillRect(var1 + 2, var2 + 2, var3 - 2, var4 - 2);
  301.       }
  302.  
  303.       if (var5 == 1 || var5 == 2 || var5 == 3 || var5 == 4) {
  304.          int var7 = 0;
  305.          byte var8 = 6;
  306.          byte var9 = 2;
  307.          int var10 = var3 / 2 - 2;
  308.          if (var3 < 11) {
  309.             var8 = 4;
  310.             var9 = 1;
  311.             var10 = var3 / 2 - 2;
  312.          } else {
  313.             var10 = var3 / 2 - 3;
  314.          }
  315.  
  316.          if (var5 != 2 && var5 != 4) {
  317.             var7 = var4 / 2 + var9;
  318.          } else {
  319.             var7 = this.sbHeight - var4 / 2 - (var9 + 2);
  320.          }
  321.  
  322.          this.g_sboff.setColor(var6);
  323.          if (var5 == 3 || var5 == 4) {
  324.             ++var10;
  325.             ++var7;
  326.          }
  327.  
  328.          for(int var11 = var8; var11 >= 0; var11 -= 2) {
  329.             this.g_sboff.drawLine(var10, var7, var10 + var11, var7);
  330.             ++var10;
  331.             if (var5 != 2 && var5 != 4) {
  332.                --var7;
  333.             } else {
  334.                ++var7;
  335.             }
  336.          }
  337.       }
  338.  
  339.       if (var5 != 0 && var5 != 1 && var5 != 2) {
  340.          this.g_sboff.setColor(Color.gray);
  341.          this.g_sboff.drawRect(var1, var2, var3, var4);
  342.       } else {
  343.          this.g_sboff.setColor(ACutilb.windowColor);
  344.          this.g_sboff.drawRect(var1 + 1, var2 + 1, var3 - 1, var4 - 1);
  345.          this.g_sboff.setColor(Color.gray);
  346.          this.g_sboff.drawLine(var1 + 1, var2 + var4 - 1, var1 + var3 - 1, var2 + var4 - 1);
  347.          this.g_sboff.drawLine(var1 + var3 - 1, var2 + 1, var1 + var3 - 1, var2 + var4 - 1);
  348.          this.g_sboff.setColor(Color.white);
  349.          this.g_sboff.drawRect(var1, var2, var3, var4);
  350.          this.g_sboff.setColor(Color.black);
  351.          this.g_sboff.drawLine(var1, var2 + var4, var1 + var3, var2 + var4);
  352.          this.g_sboff.drawLine(var1 + var3, var2, var1 + var3, var2 + var4);
  353.       }
  354.    }
  355.  
  356.    public Dimension preferredSize() {
  357.       return new Dimension(14, 75);
  358.    }
  359.  
  360.    private void drawBar(Graphics var1) {
  361.       this.g_sboff.setColor(this.bg_color);
  362.       this.g_sboff.fillRect(0, 0, this.field_0.width, this.field_0.height);
  363.       this.drawSlider();
  364.    }
  365.  
  366.    private void drawSlider() {
  367.       byte var1 = 0;
  368.       int var2 = (this.field_0.height - this.slider_height) / 2;
  369.       int var3 = this.field_0.width;
  370.       int var4 = this.slider_height;
  371.       this.g_sboff.setColor(this.slider_color);
  372.       this.g_sboff.fillRect(var1, var2, var3, var4);
  373.    }
  374.  
  375.    private void checkDbutton(Event var1, int var2) {
  376.       if (var2 == 1) {
  377.          this.sbValue += this.sbIncrement;
  378.          if (this.sbValue > this.sbMax) {
  379.             this.sbValue = this.sbMax;
  380.          }
  381.  
  382.          this.DrawBubble(false);
  383.          this.paintIt(((Component)this).getGraphics());
  384.          var1.id = 602;
  385.          ((Component)this).postEvent(var1);
  386.       } else if (var2 == 2) {
  387.          this.sbValue -= this.sbIncrement;
  388.          if (this.sbValue < 0) {
  389.             this.sbValue = 0;
  390.          }
  391.  
  392.          this.DrawBubble(false);
  393.          this.paintIt(((Component)this).getGraphics());
  394.          var1.id = 601;
  395.          ((Component)this).postEvent(var1);
  396.       } else if (var2 == 3) {
  397.          this.sbValue -= this.pageIncrement;
  398.          if (this.sbValue < 0) {
  399.             this.sbValue = 0;
  400.          }
  401.  
  402.          this.DrawBubble(false);
  403.          this.paintIt(((Component)this).getGraphics());
  404.          var1.id = 603;
  405.          ((Component)this).postEvent(var1);
  406.       } else {
  407.          if (var2 == 4) {
  408.             this.sbValue += this.pageIncrement;
  409.             if (this.sbValue > this.sbMax) {
  410.                this.sbValue = this.sbMax;
  411.             }
  412.  
  413.             this.DrawBubble(false);
  414.             this.paintIt(((Component)this).getGraphics());
  415.             var1.id = 604;
  416.             ((Component)this).postEvent(var1);
  417.          }
  418.  
  419.       }
  420.    }
  421.  
  422.    public boolean mouseDown(Event var1, int var2, int var3) {
  423.       this.m_down = true;
  424.       if (this.bad_scroll) {
  425.          return true;
  426.       } else if (this.on_bottom) {
  427.          this.drawButton(0, this.sbHeight - this.sbWidth, this.sbWidth - 1, this.sbWidth - 1, 4, this.harrow_color);
  428.          this.last_button = 1;
  429.          this.auto_type = 1;
  430.          this.checkDbutton(var1, this.auto_type);
  431.          this.the_e = var1;
  432.          this.start();
  433.          return true;
  434.       } else if (this.on_top) {
  435.          this.drawButton(0, 0, this.sbWidth - 1, this.sbWidth - 1, 3, this.harrow_color);
  436.          this.last_button = 2;
  437.          this.auto_type = 2;
  438.          this.checkDbutton(var1, this.auto_type);
  439.          this.the_e = var1;
  440.          this.start();
  441.          return true;
  442.       } else {
  443.          if (var2 >= 0 && var2 <= this.sbWidth) {
  444.             if ((float)var3 >= this.bubble_pos && (float)var3 < this.bubble_pos + (float)this.sbWidth) {
  445.                this.dragging_bubble = true;
  446.                this.drag_move = var3;
  447.                return true;
  448.             }
  449.  
  450.             if ((float)var3 < this.bubble_pos) {
  451.                this.field_2 = var3;
  452.                this.field_1 = var2;
  453.                this.auto_type = 3;
  454.                this.checkDbutton(var1, this.auto_type);
  455.                this.the_e = var1;
  456.                this.start();
  457.             } else {
  458.                this.field_2 = var3;
  459.                this.field_1 = var2;
  460.                this.auto_type = 4;
  461.                this.checkDbutton(var1, this.auto_type);
  462.                this.the_e = var1;
  463.                this.start();
  464.             }
  465.          }
  466.  
  467.          return true;
  468.       }
  469.    }
  470.  
  471.    public void run() {
  472.       while(true) {
  473.          if (!this.bypass) {
  474.             try {
  475.                Thread.sleep((long)(this.auto_delay * 100));
  476.             } catch (InterruptedException var2) {
  477.             }
  478.          } else {
  479.             this.bypass = false;
  480.          }
  481.  
  482.          while(this.m_down) {
  483.             if (this.auto_type != 3 && this.auto_type != 4 || this.field_1 > 0 && this.field_1 < this.sbWidth && this.field_2 <= this.sbHeight - this.sbWidth && this.field_2 >= this.sbWidth && (this.auto_type != 3 || !((float)this.field_2 > this.bubble_pos)) && (this.auto_type != 4 || !((float)this.field_2 < this.bubble_pos + (float)this.sbWidth))) {
  484.                this.checkDbutton(this.the_e, this.auto_type);
  485.  
  486.                try {
  487.                   Thread.sleep((long)this.auto_rate);
  488.                } catch (InterruptedException var1) {
  489.                }
  490.             }
  491.          }
  492.       }
  493.    }
  494.  
  495.    private void undoHButtons() {
  496.       if (this.on_bottom) {
  497.          this.drawButton(0, this.sbHeight - this.sbWidth, this.sbWidth - 1, this.sbWidth - 1, 2, this.arrow_color);
  498.          this.paintIt(((Component)this).getGraphics());
  499.          this.on_bottom = false;
  500.       }
  501.  
  502.       if (this.on_top) {
  503.          this.drawButton(0, 0, this.sbWidth - 1, this.sbWidth - 1, 1, this.arrow_color);
  504.          this.paintIt(((Component)this).getGraphics());
  505.          this.on_top = false;
  506.       }
  507.  
  508.    }
  509.  
  510.    public boolean mouseDrag(Event var1, int var2, int var3) {
  511.       this.field_1 = var2;
  512.       this.field_2 = var3;
  513.       if (this.bad_scroll) {
  514.          return true;
  515.       } else {
  516.          if (this.dragging_bubble) {
  517.             if (this.drag_move != var3) {
  518.                this.hbp = this.bubble_pos + (float)(var3 - this.drag_move);
  519.                if (this.hbp > (float)(this.bubble_range + this.sbWidth)) {
  520.                   this.hbp = (float)(this.bubble_range + this.sbWidth);
  521.                }
  522.  
  523.                if (this.hbp < (float)this.sbWidth) {
  524.                   this.hbp = (float)this.sbWidth;
  525.                }
  526.  
  527.                this.DrawBubble(true);
  528.                this.paintIt(((Component)this).getGraphics());
  529.                var1.id = 605;
  530.                ((Component)this).postEvent(var1);
  531.                this.drag_move = var3;
  532.             }
  533.          } else {
  534.             if (this.auto_type > 2) {
  535.                return true;
  536.             }
  537.  
  538.             if (var2 > 0 && var2 < this.sbWidth && this.cButtons(var3)) {
  539.                this.m_off = false;
  540.                return true;
  541.             }
  542.  
  543.             this.m_off = true;
  544.             this.drawButton(0, this.sbHeight - this.sbWidth, this.sbWidth - 1, this.sbWidth - 1, 2, this.arrow_color);
  545.             this.on_bottom = false;
  546.             this.drawButton(0, 0, this.sbWidth - 1, this.sbWidth - 1, 1, this.arrow_color);
  547.             this.on_top = false;
  548.             this.stop();
  549.             this.auto_type = 0;
  550.             this.paintIt(((Component)this).getGraphics());
  551.          }
  552.  
  553.          return true;
  554.       }
  555.    }
  556.  
  557.    public void setBubblePos(int var1) {
  558.       if (var1 < 1) {
  559.          this.sbValue = 1;
  560.       }
  561.  
  562.       if (var1 > this.sbMax) {
  563.          this.sbValue = this.sbMax;
  564.       }
  565.  
  566.       this.figureBubble(true);
  567.    }
  568.  
  569.    public void setBarStyle(int var1, Color var2, Color var3, Color var4, Color var5, Color var6) {
  570.       this.arrow_color = var2;
  571.       this.slider_height = var1;
  572.       this.harrow_color = var3;
  573.       this.bg_color = var4;
  574.       this.slider_color = var5;
  575.       this.outline_color = var6;
  576.    }
  577. }
  578.