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

  1. import java.awt.Color;
  2. import java.awt.Graphics;
  3. import java.awt.Image;
  4. import java.awt.Panel;
  5.  
  6. class stsbimg {
  7.    private boolean bubble_hl = false;
  8.    private boolean on_top = false;
  9.    private boolean on_bottom = false;
  10.    private boolean m_down = false;
  11.    private boolean dragging_bubble = false;
  12.    private boolean bad_scroll = true;
  13.    private boolean mouse_in = false;
  14.    private boolean m_off = false;
  15.    private boolean bypass = false;
  16.    private boolean indent_bubble = false;
  17.    private float hbp = 0.0F;
  18.    private boolean flat = false;
  19.    private Color button_color;
  20.    private Color arrow_color;
  21.    private Color harrow_color;
  22.    private Color bg_color;
  23.    private Color slider_color;
  24.    private Color outline_color;
  25.    private Color middle_arrow_color;
  26.    private Color unactive_color;
  27.    private Color middle_arrowhl_color;
  28.    private int slider_inset;
  29.    private int last_button;
  30.    private int auto_delay;
  31.    private int auto_rate;
  32.    private int bubble_range;
  33.    private float bubble_pos;
  34.    private float oldbubble_pos;
  35.    private float bubble_inc;
  36.    private int position;
  37.    Image sboff;
  38.    private Graphics g_sboff;
  39.    private Image slider;
  40.    private Graphics g_slider;
  41.    private Image[] topb;
  42.    private Image[] botb;
  43.    private Image[] bubble;
  44.    private boolean top_graphic;
  45.    private boolean bottom_graphic;
  46.    private boolean bubble_graphic;
  47.    private Image barbg;
  48.    Panel gcomp;
  49.    int sbWidth;
  50.    int sbHeight;
  51.  
  52.    public void setBarBgImage(Image var1) {
  53.       this.barbg = var1;
  54.    }
  55.  
  56.    stsbimg(Panel var1, int var2, int var3) {
  57.       this.button_color = Color.lightGray;
  58.       this.arrow_color = Color.black;
  59.       this.harrow_color = Color.yellow;
  60.       this.bg_color = Color.white;
  61.       this.slider_color = Color.black;
  62.       this.outline_color = Color.lightGray;
  63.       this.middle_arrow_color = Color.lightGray;
  64.       this.unactive_color = Color.lightGray;
  65.       this.middle_arrowhl_color = Color.lightGray;
  66.       this.slider_inset = 0;
  67.       this.last_button = 0;
  68.       this.auto_delay = 5;
  69.       this.auto_rate = 40;
  70.       this.bubble_range = 0;
  71.       this.bubble_pos = 0.0F;
  72.       this.oldbubble_pos = 0.0F;
  73.       this.bubble_inc = 0.0F;
  74.       this.position = 0;
  75.       this.sboff = null;
  76.       this.g_sboff = null;
  77.       this.topb = new Image[4];
  78.       this.botb = new Image[4];
  79.       this.bubble = new Image[3];
  80.       this.top_graphic = false;
  81.       this.bottom_graphic = false;
  82.       this.bubble_graphic = false;
  83.       this.gcomp = var1;
  84.       this.sbWidth = var2;
  85.       this.sbHeight = var3;
  86.    }
  87.  
  88.    private void initButtons() {
  89.       if (!this.top_graphic || !this.bottom_graphic || !this.bubble_graphic) {
  90.          int var1 = 0;
  91.  
  92.          do {
  93.             if (!this.top_graphic) {
  94.                this.topb[var1] = this.gcomp.createImage(this.sbWidth, this.sbWidth);
  95.             }
  96.  
  97.             if (!this.bottom_graphic) {
  98.                this.botb[var1] = this.gcomp.createImage(this.sbWidth, this.sbWidth);
  99.             }
  100.  
  101.             if (var1 < 3 && !this.bubble_graphic) {
  102.                this.bubble[var1] = this.gcomp.createImage(this.sbWidth, this.sbWidth);
  103.             }
  104.  
  105.             ++var1;
  106.          } while(var1 < 4);
  107.  
  108.          if (!this.top_graphic) {
  109.             if (this.barbg != null) {
  110.                int var20 = 0;
  111.  
  112.                do {
  113.                   Graphics var4 = this.topb[var20].getGraphics();
  114.                   var4.drawImage(this.barbg, 0, 0, this.gcomp);
  115.                   ++var20;
  116.                } while(var20 < 4);
  117.             } else if (this.bg_color != null) {
  118.                int var2 = 0;
  119.  
  120.                do {
  121.                   Graphics var3 = this.topb[var2].getGraphics();
  122.                   var3.setColor(this.bg_color);
  123.                   var3.fillRect(0, 0, this.sbWidth, this.sbWidth);
  124.                   ++var2;
  125.                } while(var2 < 4);
  126.             }
  127.  
  128.             Graphics var5 = this.topb[0].getGraphics();
  129.             this.initDrawButtons(0, 0, this.sbWidth, this.sbWidth, 1, this.arrow_color, var5);
  130.             var5 = this.topb[1].getGraphics();
  131.             this.initDrawButtons(0, 0, this.sbWidth, this.sbWidth, 1, this.harrow_color, var5);
  132.             var5 = this.topb[2].getGraphics();
  133.             this.initDrawButtons(0, 0, this.sbWidth, this.sbWidth, 3, this.harrow_color, var5);
  134.             var5 = this.topb[3].getGraphics();
  135.             this.initDrawButtons(0, 0, this.sbWidth, this.sbWidth, 1, this.unactive_color, var5);
  136.          }
  137.  
  138.          if (!this.bottom_graphic) {
  139.             if (this.barbg != null) {
  140.                int var22 = 0;
  141.  
  142.                do {
  143.                   Graphics var10 = this.botb[var22].getGraphics();
  144.                   var10.drawImage(this.barbg, 0, -(this.sbHeight - this.sbWidth), this.gcomp);
  145.                   ++var22;
  146.                } while(var22 < 4);
  147.             } else if (this.bg_color != null) {
  148.                int var21 = 0;
  149.  
  150.                do {
  151.                   Graphics var9 = this.botb[var21].getGraphics();
  152.                   var9.setColor(this.bg_color);
  153.                   var9.fillRect(0, 0, this.sbWidth, this.sbWidth);
  154.                   ++var21;
  155.                } while(var21 < 4);
  156.             }
  157.  
  158.             Graphics var11 = this.botb[0].getGraphics();
  159.             this.initDrawButtons(0, 0, this.sbWidth, this.sbWidth, 2, this.arrow_color, var11);
  160.             var11 = this.botb[1].getGraphics();
  161.             this.initDrawButtons(0, 0, this.sbWidth, this.sbWidth, 2, this.harrow_color, var11);
  162.             var11 = this.botb[2].getGraphics();
  163.             this.initDrawButtons(0, 0, this.sbWidth, this.sbWidth, 4, this.harrow_color, var11);
  164.             var11 = this.botb[3].getGraphics();
  165.             this.initDrawButtons(0, 0, this.sbWidth, this.sbWidth, 2, this.unactive_color, var11);
  166.          }
  167.  
  168.          if (!this.bubble_graphic) {
  169.             if (this.barbg != null) {
  170.                int var24 = 0;
  171.  
  172.                do {
  173.                   Graphics var16 = this.bubble[var24].getGraphics();
  174.                   var16.drawImage(this.barbg, 0, -this.sbWidth, this.gcomp);
  175.                   ++var24;
  176.                } while(var24 < 3);
  177.             } else if (this.bg_color != null) {
  178.                int var23 = 0;
  179.  
  180.                do {
  181.                   Graphics var15 = this.bubble[var23].getGraphics();
  182.                   var15.setColor(this.bg_color);
  183.                   var15.fillRect(0, 0, this.sbWidth, this.sbWidth);
  184.                   ++var23;
  185.                } while(var23 < 3);
  186.             }
  187.  
  188.             Graphics var17 = this.bubble[0].getGraphics();
  189.             this.initDrawButtons(0, 0, this.sbWidth, this.sbWidth, 5, this.middle_arrow_color, var17);
  190.             var17 = this.bubble[1].getGraphics();
  191.             this.initDrawButtons(0, 0, this.sbWidth, this.sbWidth, 5, this.middle_arrowhl_color, var17);
  192.             var17 = this.bubble[2].getGraphics();
  193.             if (this.indent_bubble) {
  194.                this.initDrawButtons(0, 0, this.sbWidth, this.sbWidth, 6, this.middle_arrowhl_color, var17);
  195.                return;
  196.             }
  197.  
  198.             this.initDrawButtons(0, 0, this.sbWidth, this.sbWidth, 5, this.middle_arrowhl_color, var17);
  199.          }
  200.  
  201.       }
  202.    }
  203.  
  204.    public Image getSBImage() {
  205.       if (this.sbWidth >= 1 && this.sbHeight >= 1) {
  206.          this.sboff = this.gcomp.createImage(this.sbWidth, this.sbHeight);
  207.          this.g_sboff = this.sboff.getGraphics();
  208.          this.initDrawScrollBar();
  209.          return this.sboff;
  210.       } else {
  211.          return null;
  212.       }
  213.    }
  214.  
  215.    private void initDrawScrollBar() {
  216.       this.g_sboff.setColor(this.bg_color);
  217.       this.g_sboff.fillRect(0, 0, this.sbWidth, this.sbHeight);
  218.       int var1 = this.sbHeight - this.sbWidth * 2;
  219.       this.slider = this.gcomp.createImage(this.sbWidth, var1);
  220.       this.g_slider = this.slider.getGraphics();
  221.       this.g_slider.setColor(this.bg_color);
  222.       this.g_slider.fillRect(0, 0, this.sbWidth, var1);
  223.       if (this.barbg != null) {
  224.          this.g_slider.drawImage(this.barbg, 0, -this.sbWidth, this.gcomp);
  225.       }
  226.  
  227.       if (this.slider_color != null) {
  228.          this.g_slider.setColor(this.slider_color);
  229.          this.g_slider.fillRect(this.slider_inset, 0, this.sbWidth - (this.slider_inset * 2 + 1), var1);
  230.       }
  231.  
  232.       if (this.outline_color != null) {
  233.          this.g_slider.setColor(this.outline_color);
  234.          this.g_slider.drawLine(this.slider_inset, 0, this.slider_inset, var1);
  235.          this.g_slider.drawLine(this.sbWidth - (this.slider_inset + 1), 0, this.sbWidth - (this.slider_inset + 1), var1);
  236.       }
  237.  
  238.       this.drawSlider();
  239.       this.initButtons();
  240.       this.drawButton(0, 0);
  241.       this.drawButton(1, 0);
  242.       this.drawButton(2, 0);
  243.    }
  244.  
  245.    private void initDrawButtons(int var1, int var2, int var3, int var4, int var5, Color var6, Graphics var7) {
  246.       if (this.button_color != null) {
  247.          var7.setColor(this.button_color);
  248.          var7.fillRect(var1, var2, var3 + 1, var4 + 1);
  249.       }
  250.  
  251.       if (this.flat && this.outline_color != null) {
  252.          var7.setColor(this.outline_color);
  253.          var7.drawRect(var1, var2, var3 - 1, var4 - 1);
  254.       }
  255.  
  256.       if (var5 > 0 && var6 != null) {
  257.          var7.setColor(var6);
  258.          int var8 = 0;
  259.          int var9 = 0;
  260.          int var10 = 0;
  261.          if (var3 < 10) {
  262.             var8 = 2;
  263.          } else if (var3 < 14) {
  264.             var8 = 4;
  265.          } else if (var3 < 17) {
  266.             var8 = 6;
  267.          } else {
  268.             var8 = 8;
  269.          }
  270.  
  271.          int var11 = var8 + 1;
  272.          int var12 = var8 / 2 + 1;
  273.          int var13 = (int)((float)var3 / 2.0F - (float)var11 / 2.0F);
  274.          int var14 = (int)((float)var4 / 2.0F - (float)var12 / 2.0F);
  275.          if (var5 == 1 || var5 == 3) {
  276.             var14 = var4 - var14 - 1;
  277.          }
  278.  
  279.          if (var5 == 5 || var5 == 6) {
  280.             var8 -= 2;
  281.             var11 = var8 + 1;
  282.             var13 = (int)((float)var3 / 2.0F - (float)var11 / 2.0F);
  283.             var14 = var4 / 2 + 1;
  284.             var9 = var13;
  285.             var10 = var14 - 3;
  286.          }
  287.  
  288.          if (var5 == 3 || var5 == 4) {
  289.             ++var13;
  290.             ++var14;
  291.          }
  292.  
  293.          if (var5 == 6) {
  294.             ++var14;
  295.             ++var10;
  296.          }
  297.  
  298.          if (var5 != 5 && var5 != 6) {
  299.             for(int var19 = var8; var19 >= 0; var19 -= 2) {
  300.                var7.drawLine(var13, var14, var13 + var19, var14);
  301.                ++var13;
  302.                if (var5 != 2 && var5 != 4) {
  303.                   --var14;
  304.                } else {
  305.                   ++var14;
  306.                }
  307.             }
  308.          } else {
  309.             int var15 = 0;
  310.  
  311.             do {
  312.                for(int var16 = var8; var16 >= 0; var16 -= 2) {
  313.                   var7.drawLine(var13, var14, var13 + var16, var14);
  314.                   ++var13;
  315.                   if (var15 == 0) {
  316.                      ++var14;
  317.                   } else {
  318.                      --var14;
  319.                   }
  320.                }
  321.  
  322.                var13 = var9;
  323.                var14 = var10;
  324.                ++var15;
  325.             } while(var15 < 2);
  326.          }
  327.       }
  328.  
  329.       if (!this.flat) {
  330.          if (var5 == 0 || var5 == 1 || var5 == 2 || var5 == 5) {
  331.             var7.setColor(Color.lightGray);
  332.             var7.drawRect(0, 0, var3 - 1, var4 - 1);
  333.             var7.setColor(Color.black);
  334.             var7.drawLine(0, var4 - 1, var3 - 1, var4 - 1);
  335.             var7.drawLine(var3 - 1, 0, var3 - 1, var4 - 1);
  336.             var7.setColor(Color.white);
  337.             var7.drawRect(1, 1, var3 - 3, var4 - 3);
  338.             var7.setColor(Color.gray);
  339.             var7.drawLine(1, var4 - 2, var3 - 2, var4 - 2);
  340.             var7.drawLine(var3 - 2, 1, var3 - 2, var4 - 2);
  341.             return;
  342.          }
  343.  
  344.          if (var5 == 6) {
  345.             var7.setColor(Color.white);
  346.             var7.drawRect(0, 0, var3 - 1, var4 - 1);
  347.             var7.setColor(Color.black);
  348.             var7.drawLine(0, var4 - 1, var3 - 1, var4 - 1);
  349.             var7.drawLine(var3 - 1, 0, var3 - 1, var4 - 1);
  350.             return;
  351.          }
  352.  
  353.          var7.setColor(Color.gray);
  354.          var7.drawRect(var1, var2, var3 - 1, var4 - 1);
  355.       }
  356.  
  357.    }
  358.  
  359.    private void drawButton(int var1, int var2) {
  360.       if (var1 == 0) {
  361.          if (this.topb[var2] != null) {
  362.             this.g_sboff.drawImage(this.topb[var2], 0, 0, this.gcomp);
  363.             return;
  364.          }
  365.       } else if (var1 == 1) {
  366.          if (this.botb[var2] != null) {
  367.             this.g_sboff.drawImage(this.botb[var2], 0, this.sbHeight - this.sbWidth, this.gcomp);
  368.             return;
  369.          }
  370.       } else if (var1 == 2 && this.bubble[var2] != null) {
  371.          this.g_sboff.drawImage(this.bubble[var2], 0, this.sbWidth, this.gcomp);
  372.       }
  373.  
  374.    }
  375.  
  376.    private void drawSlider() {
  377.       if (this.slider != null) {
  378.          this.g_sboff.drawImage(this.slider, 0, this.sbWidth, this.gcomp);
  379.       }
  380.  
  381.    }
  382.  
  383.    public void setBarButtonImages(Image[] var1, Image[] var2, Image[] var3) {
  384.       if (var1 != null) {
  385.          this.topb = var1;
  386.          this.top_graphic = true;
  387.       }
  388.  
  389.       if (var2 != null) {
  390.          this.botb = var2;
  391.          this.bottom_graphic = true;
  392.       }
  393.  
  394.       if (this.bubble != null) {
  395.          this.bubble = var3;
  396.          this.bubble_graphic = true;
  397.       }
  398.  
  399.    }
  400.  
  401.    public void setBarStyle(int var1, Color var2, Color var3, Color var4, Color var5, Color var6, Color var7, Color var8, Color var9, Color var10, boolean var11, boolean var12) {
  402.       this.button_color = var2;
  403.       this.arrow_color = var3;
  404.       this.harrow_color = var4;
  405.       this.bg_color = var5;
  406.       this.slider_color = var6;
  407.       this.outline_color = var7;
  408.       this.middle_arrow_color = var8;
  409.       this.unactive_color = var10;
  410.       this.middle_arrowhl_color = var9;
  411.       this.slider_inset = var1;
  412.       this.flat = var11;
  413.       this.indent_bubble = var12;
  414.    }
  415. }
  416.