home *** CD-ROM | disk | FTP | other *** search
Wrap
import java.awt.Color; import java.awt.Component; import java.awt.Dimension; import java.awt.Event; import java.awt.Graphics; import java.awt.Image; import java.awt.Panel; class stsb extends Panel implements Runnable { public static final int SCROLL_LINE_UP = 601; public static final int SCROLL_LINE_DOWN = 602; public static final int SCROLL_PAGE_UP = 603; public static final int SCROLL_PAGE_DOWN = 604; public static final int SCROLL_ABSOLUTE = 605; public static final int MOUSE_ENTER = 611; public static final int MOUSE_EXIT = 612; public static final int MOUSE_DOWN = 613; public static final int MOUSE_UP = 614; public int sbHeight = 0; public int sbWidth = 0; private int sbValue = 0; private int pageIncrement = 0; private int sbMax = 0; private int sbIncrement = 1; private Thread goauto = null; private boolean paint_called = false; public boolean first_run = true; private boolean initialized = false; private boolean bubble_hl = false; private boolean on_top = false; private boolean on_bottom = false; private boolean m_down = false; private boolean dragging_bubble = false; private boolean bad_scroll = true; private boolean mouse_in = false; private boolean m_off = false; private boolean bypass = false; private boolean indent_bubble = false; private Event the_e = null; private int auto_type = 0; // $FF: renamed from: mx int private int field_0 = 0; // $FF: renamed from: my int private int field_1 = 0; private float scrollpos; private float lineinc; private int drag_move = 0; private float hbp = 0.0F; private boolean flat = false; private Color button_color; private Color arrow_color; private Color harrow_color; private Color bg_color; private Color slider_color; private Color outline_color; private Color middle_arrow_color; private Color unactive_color; private Color middle_arrowhl_color; private int slider_inset; private int last_button; private int auto_delay; private int auto_rate; private int bubble_range; private float bubble_pos; private float oldbubble_pos; private float bubble_inc; private int position; Image sboff; private Graphics g_sboff; private Image slider; private Graphics g_slider; private Image[] topb; private Image[] botb; private Image[] bubble; private boolean top_graphic; private boolean bottom_graphic; private boolean bubble_graphic; private Image barbg; 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) { this.button_color = var2; this.arrow_color = var3; this.harrow_color = var4; this.bg_color = var5; this.slider_color = var6; this.outline_color = var7; this.middle_arrow_color = var8; this.unactive_color = var10; this.middle_arrowhl_color = var9; this.slider_inset = var1; this.flat = var11; this.indent_bubble = var12; } public void stop() { if (this.goauto != null) { this.goauto.stop(); this.goauto = null; } } public boolean mouseEnter(Event var1, int var2, int var3) { ((Component)this).postEvent(new Event(this, 611, (Object)null)); this.mouse_in = true; return true; } public void setBarBgImage(Image var1) { this.barbg = var1; } private void initButtons() { if (!this.top_graphic || !this.bottom_graphic || !this.bubble_graphic) { int var1 = 0; do { if (!this.top_graphic) { this.topb[var1] = ((Component)this).createImage(this.sbWidth, this.sbWidth); } if (!this.bottom_graphic) { this.botb[var1] = ((Component)this).createImage(this.sbWidth, this.sbWidth); } if (var1 < 3 && !this.bubble_graphic) { this.bubble[var1] = ((Component)this).createImage(this.sbWidth, this.sbWidth); } ++var1; } while(var1 < 4); if (!this.top_graphic) { if (this.barbg != null) { int var2 = 0; do { Graphics var3 = this.topb[var2].getGraphics(); var3.drawImage(this.barbg, 0, 0, this); ++var2; } while(var2 < 4); } Graphics var4 = this.topb[0].getGraphics(); this.initDrawButtons(0, 0, this.sbWidth, this.sbWidth, 1, this.arrow_color, var4); var4 = this.topb[1].getGraphics(); this.initDrawButtons(0, 0, this.sbWidth, this.sbWidth, 1, this.harrow_color, var4); var4 = this.topb[2].getGraphics(); this.initDrawButtons(0, 0, this.sbWidth, this.sbWidth, 3, this.harrow_color, var4); var4 = this.topb[3].getGraphics(); this.initDrawButtons(0, 0, this.sbWidth, this.sbWidth, 1, this.unactive_color, var4); } if (!this.bottom_graphic) { if (this.barbg != null) { int var17 = 0; do { Graphics var8 = this.botb[var17].getGraphics(); var8.drawImage(this.barbg, 0, -(this.sbHeight - this.sbWidth), this); ++var17; } while(var17 < 4); } Graphics var9 = this.botb[0].getGraphics(); this.initDrawButtons(0, 0, this.sbWidth, this.sbWidth, 2, this.arrow_color, var9); var9 = this.botb[1].getGraphics(); this.initDrawButtons(0, 0, this.sbWidth, this.sbWidth, 2, this.harrow_color, var9); var9 = this.botb[2].getGraphics(); this.initDrawButtons(0, 0, this.sbWidth, this.sbWidth, 4, this.harrow_color, var9); var9 = this.botb[3].getGraphics(); this.initDrawButtons(0, 0, this.sbWidth, this.sbWidth, 2, this.unactive_color, var9); } if (!this.bubble_graphic) { if (this.barbg != null) { int var18 = 0; do { Graphics var13 = this.bubble[var18].getGraphics(); var13.drawImage(this.barbg, 0, -this.sbWidth, this); ++var18; } while(var18 < 3); } Graphics var14 = this.bubble[0].getGraphics(); this.initDrawButtons(0, 0, this.sbWidth, this.sbWidth, 5, this.middle_arrow_color, var14); var14 = this.bubble[1].getGraphics(); this.initDrawButtons(0, 0, this.sbWidth, this.sbWidth, 5, this.middle_arrowhl_color, var14); var14 = this.bubble[2].getGraphics(); if (this.indent_bubble) { this.initDrawButtons(0, 0, this.sbWidth, this.sbWidth, 6, this.middle_arrowhl_color, var14); return; } this.initDrawButtons(0, 0, this.sbWidth, this.sbWidth, 5, this.middle_arrowhl_color, var14); } } } public void start() { if (this.goauto == null) { this.goauto = new Thread(this); this.goauto.start(); } } public void figureBubble() { if (this.initialized) { this.bubble_range = this.sbHeight - this.sbWidth * 3; this.bubble_inc = (float)this.bubble_range / (float)this.sbMax; this.bubble_pos = (float)this.sbValue * this.bubble_inc + (float)this.sbWidth; this.oldbubble_pos = this.bubble_pos; } } private void DrawBubble() { if (!this.bad_scroll) { this.drawSlider(); this.bubble_pos = this.hbp; float var1 = (this.bubble_pos - (float)this.sbWidth) / (float)this.bubble_range; this.sbValue = (int)(var1 * (float)this.sbMax); this.drawButton(2, 2); } } public Dimension preferredSize() { return new Dimension(14, 75); } private void undoHButtons() { if (this.on_bottom) { this.drawButton(1, 0); this.paintIt(); this.on_bottom = false; } if (this.on_top) { this.drawButton(0, 0); this.paintIt(); this.on_top = false; } if (this.bubble_hl) { this.drawButton(2, 0); this.paintIt(); this.bubble_hl = false; } } public void reshape(int var1, int var2, int var3, int var4) { if (var3 * var4 > 0) { this.sbWidth = var3; this.sbHeight = var4; this.redo(); super.reshape(var1, var2, var3, var4); } } public void setValue(int var1) { this.scrollpos = (float)var1; this.sbValue = (int)(Math.abs(this.scrollpos) / this.lineinc); if (this.sbValue < 0) { this.sbValue = 0; } if (this.sbValue > this.sbMax) { this.sbValue = this.sbMax; } this.syncGraphics(0); } public int getValue() { return this.sbValue; } public boolean mouseExit(Event var1, int var2, int var3) { ((Component)this).postEvent(new Event(this, 612, (Object)null)); if (this.bad_scroll) { return true; } else { this.mouse_in = false; this.m_off = true; this.syncGraphics(9); return true; } } public void redo() { this.paint_called = false; this.first_run = true; this.figureBubble(); this.paintIt(); } stsb() { this.button_color = Color.lightGray; this.arrow_color = Color.black; this.harrow_color = Color.yellow; this.bg_color = Color.white; this.slider_color = Color.black; this.outline_color = Color.lightGray; this.middle_arrow_color = Color.lightGray; this.unactive_color = Color.lightGray; this.middle_arrowhl_color = Color.lightGray; this.slider_inset = 0; this.last_button = 0; this.auto_delay = 5; this.auto_rate = 40; this.bubble_range = 0; this.bubble_pos = 0.0F; this.oldbubble_pos = 0.0F; this.bubble_inc = 0.0F; this.position = 0; this.sboff = null; this.g_sboff = null; this.topb = new Image[4]; this.botb = new Image[4]; this.bubble = new Image[3]; this.top_graphic = false; this.bottom_graphic = false; this.bubble_graphic = false; } public void paint(Graphics var1) { this.paint_called = true; this.paintIt(); } public boolean mouseUp(Event var1, int var2, int var3) { if (this.bad_scroll) { ((Component)this).postEvent(new Event(this, 614, (Object)null)); return true; } else { this.m_down = false; if (this.dragging_bubble) { this.dragging_bubble = false; if (var2 >= 0 && var2 <= this.sbWidth && (float)var3 >= this.bubble_pos && (float)var3 < this.bubble_pos + (float)this.sbWidth) { this.drawButton(2, 1); this.paintIt(); } } this.last_button = 0; this.stop(); this.auto_type = 0; if (this.m_off) { this.syncGraphics(8); ((Component)this).postEvent(new Event(this, 614, (Object)null)); return true; } else if (this.on_bottom) { this.syncGraphics(10); ((Component)this).postEvent(new Event(this, 614, (Object)null)); return true; } else if (this.on_top) { this.syncGraphics(11); ((Component)this).postEvent(new Event(this, 614, (Object)null)); return true; } else { ((Component)this).postEvent(new Event(this, 614, (Object)null)); return true; } } } private synchronized void syncGraphics(int var1) { if (var1 == 0) { if (!this.bad_scroll) { this.drawSlider(); this.drawButton(2, 0); this.drawButton(0, 0); this.drawButton(1, 0); } else { this.drawSlider(); this.drawButton(0, 3); this.drawButton(1, 3); } this.paintIt(); } else if (var1 == 3) { this.drawButton(1, 2); } else if (var1 == 4) { this.drawButton(0, 2); } else if (var1 == 5) { this.drawSlider(); this.bubble_pos = (float)this.sbValue * this.bubble_inc + (float)this.sbWidth; this.drawButton(2, 0); this.paintIt(); } else if (var1 == 6) { this.DrawBubble(); this.paintIt(); } else if (var1 == 7) { this.drawButton(1, 0); this.on_bottom = false; this.drawButton(0, 0); this.on_top = false; this.stop(); this.auto_type = 0; this.paintIt(); } else if (var1 == 8) { this.drawButton(1, 0); this.drawButton(0, 0); this.paintIt(); this.on_bottom = false; this.on_top = false; this.m_off = false; } else if (var1 == 9) { this.undoHButtons(); } else if (var1 == 10) { this.drawButton(1, 1); this.paintIt(); } else if (var1 == 11) { this.drawButton(0, 1); this.paintIt(); } else { if (var1 == 12) { this.initDrawScrollBar(); } } } private synchronized void paintIt() { if (this.paint_called && this.sbWidth != 0 && this.sbHeight != 0) { ((Component)this).getGraphics(); if (this.first_run) { ((Component)this).setBackground(this.bg_color); if (this.sbWidth * this.sbHeight > 0) { this.sboff = ((Component)this).createImage(this.sbWidth, this.sbHeight); this.g_sboff = this.sboff.getGraphics(); this.syncGraphics(12); this.first_run = false; } } else { ((Component)this).getGraphics().drawImage(this.sboff, 0, 0, this); } } } public void setValues(int var1, int var2, int var3, int var4) { this.scrollpos = (float)var4; this.lineinc = (float)var1; this.sbIncrement = var1; this.pageIncrement = var2; this.sbMax = var3 - var2; this.sbValue = var4; this.bubble_pos = 0.0F; if (this.sbMax < 1) { this.bad_scroll = true; this.bubble_pos = (float)this.sbWidth; } else { this.bad_scroll = false; } this.initialized = true; this.figureBubble(); this.paintIt(); this.syncGraphics(0); } public void resize(int var1, int var2) { if (var1 * var2 > 0) { this.sbWidth = var1; this.sbHeight = var2; this.redo(); super.resize(var1, var2); } } public void resize(Dimension var1) { if (var1.width * var1.height > 0) { this.sbWidth = var1.width; this.sbHeight = var1.height; this.redo(); super.resize(var1); } } private void initDrawScrollBar() { this.g_sboff.setColor(this.bg_color); this.g_sboff.fillRect(0, 0, this.sbWidth, this.sbHeight); int var1 = this.sbHeight - this.sbWidth * 2; this.slider = ((Component)this).createImage(this.sbWidth, var1); this.g_slider = this.slider.getGraphics(); if (this.barbg != null) { this.g_slider.drawImage(this.barbg, 0, -this.sbWidth, this); } if (this.slider_color != null) { this.g_slider.setColor(this.slider_color); this.g_slider.fillRect(this.slider_inset, 0, this.sbWidth - (this.slider_inset * 2 + 1), var1); } if (this.outline_color != null) { this.g_slider.setColor(this.outline_color); this.g_slider.drawLine(this.slider_inset, 0, this.slider_inset, var1); this.g_slider.drawLine(this.sbWidth - (this.slider_inset + 1), 0, this.sbWidth - (this.slider_inset + 1), var1); } this.drawSlider(); this.initButtons(); if (!this.bad_scroll) { this.drawButton(0, 0); this.drawButton(1, 0); this.drawButton(2, 0); } else { this.drawButton(0, 3); this.drawButton(1, 3); } ((Component)this).getGraphics().drawImage(this.sboff, 0, 0, this); } private void initDrawButtons(int var1, int var2, int var3, int var4, int var5, Color var6, Graphics var7) { if (this.button_color != null) { var7.setColor(this.button_color); var7.fillRect(var1, var2, var3 + 1, var4 + 1); } if (this.flat && this.outline_color != null) { var7.setColor(this.outline_color); var7.drawRect(var1, var2, var3 - 1, var4 - 1); } if (var5 > 0 && var6 != null) { var7.setColor(var6); int var8 = 0; int var9 = 0; int var10 = 0; if (var3 < 10) { var8 = 2; } else if (var3 < 14) { var8 = 4; } else if (var3 < 17) { var8 = 6; } else { var8 = 8; } int var11 = var8 + 1; int var12 = var8 / 2 + 1; int var13 = (int)((float)var3 / 2.0F - (float)var11 / 2.0F); int var14 = (int)((float)var4 / 2.0F - (float)var12 / 2.0F); if (var5 == 1 || var5 == 3) { var14 = var4 - var14 - 1; } if (var5 == 5 || var5 == 6) { var8 -= 2; var11 = var8 + 1; var13 = (int)((float)var3 / 2.0F - (float)var11 / 2.0F); var14 = var4 / 2 + 1; var9 = var13; var10 = var14 - 3; } if (var5 == 3 || var5 == 4) { ++var13; ++var14; } if (var5 == 6) { ++var14; ++var10; } if (var5 != 5 && var5 != 6) { for(int var19 = var8; var19 >= 0; var19 -= 2) { var7.drawLine(var13, var14, var13 + var19, var14); ++var13; if (var5 != 2 && var5 != 4) { --var14; } else { ++var14; } } } else { int var15 = 0; do { for(int var16 = var8; var16 >= 0; var16 -= 2) { var7.drawLine(var13, var14, var13 + var16, var14); ++var13; if (var15 == 0) { ++var14; } else { --var14; } } var13 = var9; var14 = var10; ++var15; } while(var15 < 2); } } if (!this.flat) { if (var5 == 0 || var5 == 1 || var5 == 2 || var5 == 5) { var7.setColor(Color.lightGray); var7.drawRect(0, 0, var3 - 1, var4 - 1); var7.setColor(Color.black); var7.drawLine(0, var4 - 1, var3 - 1, var4 - 1); var7.drawLine(var3 - 1, 0, var3 - 1, var4 - 1); var7.setColor(Color.white); var7.drawRect(1, 1, var3 - 3, var4 - 3); var7.setColor(Color.gray); var7.drawLine(1, var4 - 2, var3 - 2, var4 - 2); var7.drawLine(var3 - 2, 1, var3 - 2, var4 - 2); return; } if (var5 == 6) { var7.setColor(Color.white); var7.drawRect(0, 0, var3 - 1, var4 - 1); var7.setColor(Color.black); var7.drawLine(0, var4 - 1, var3 - 1, var4 - 1); var7.drawLine(var3 - 1, 0, var3 - 1, var4 - 1); return; } var7.setColor(Color.gray); var7.drawRect(var1, var2, var3 - 1, var4 - 1); } } private void drawButton(int var1, int var2) { if (var1 == 0) { if (this.topb[var2] != null) { this.g_sboff.drawImage(this.topb[var2], 0, 0, this); return; } } else if (var1 == 1) { if (this.botb[var2] != null) { this.g_sboff.drawImage(this.botb[var2], 0, this.sbHeight - this.sbWidth, this); return; } } else if (var1 == 2 && this.bubble[var2] != null) { this.g_sboff.drawImage(this.bubble[var2], 0, (int)this.bubble_pos, this); } } private void checkDbutton(Event var1, int var2) { if (var2 == 1) { this.sbValue += this.sbIncrement; if (this.sbValue > this.sbMax) { this.sbValue = this.sbMax; } this.syncGraphics(5); var1.id = 602; ((Component)this).postEvent(var1); } else if (var2 == 2) { this.sbValue -= this.sbIncrement; if (this.sbValue < 0) { this.sbValue = 0; } this.syncGraphics(5); var1.id = 601; ((Component)this).postEvent(var1); } else if (var2 == 3) { this.sbValue -= this.pageIncrement; if (this.sbValue < 0) { this.sbValue = 0; } this.syncGraphics(5); var1.id = 603; ((Component)this).postEvent(var1); } else { if (var2 == 4) { this.sbValue += this.pageIncrement; if (this.sbValue > this.sbMax) { this.sbValue = this.sbMax; } this.syncGraphics(5); var1.id = 604; ((Component)this).postEvent(var1); } } } private void drawSlider() { if (this.slider != null) { this.g_sboff.drawImage(this.slider, 0, this.sbWidth, this); } } public boolean mouseDown(Event var1, int var2, int var3) { ((Component)this).postEvent(new Event(this, 613, (Object)null)); this.m_down = true; if (this.bad_scroll) { return true; } else if (this.on_bottom) { this.syncGraphics(3); this.last_button = 1; this.auto_type = 1; this.checkDbutton(var1, this.auto_type); this.the_e = var1; this.start(); return true; } else if (this.on_top) { this.syncGraphics(4); this.last_button = 2; this.auto_type = 2; this.checkDbutton(var1, this.auto_type); this.the_e = var1; this.start(); return true; } else { if (var2 >= 0 && var2 <= this.sbWidth) { if ((float)var3 >= this.bubble_pos && (float)var3 < this.bubble_pos + (float)this.sbWidth) { this.drawButton(2, 2); this.paintIt(); this.dragging_bubble = true; this.drag_move = var3; return true; } if ((float)var3 < this.bubble_pos) { this.field_1 = var3; this.field_0 = var2; this.auto_type = 3; this.checkDbutton(var1, this.auto_type); this.the_e = var1; this.start(); } else { this.field_1 = var3; this.field_0 = var2; this.auto_type = 4; this.checkDbutton(var1, this.auto_type); this.the_e = var1; this.start(); } } return true; } } public void setBarButtonImages(Image[] var1, Image[] var2, Image[] var3) { if (var1 != null) { this.topb = var1; this.top_graphic = true; } if (var2 != null) { this.botb = var2; this.bottom_graphic = true; } if (this.bubble != null) { this.bubble = var3; this.bubble_graphic = true; } } private boolean cButtons(int var1) { if (var1 < this.sbWidth && var1 >= 0) { if (!this.on_top) { this.undoHButtons(); this.on_top = true; if (!this.m_down) { this.drawButton(0, 1); } else if (this.last_button != 1) { this.drawButton(0, 1); this.bypass = true; this.auto_type = 2; this.start(); } else { this.on_top = false; } this.paintIt(); } return true; } else if (var1 > this.sbHeight - this.sbWidth && var1 <= this.sbHeight) { if (!this.on_bottom) { this.undoHButtons(); this.on_bottom = true; if (!this.m_down) { this.drawButton(1, 1); } else if (this.last_button != 2) { this.drawButton(1, 1); this.bypass = true; this.auto_type = 1; this.start(); } else { this.on_bottom = false; } this.paintIt(); } return true; } else if ((float)var1 >= this.bubble_pos && (float)var1 < this.bubble_pos + (float)this.sbWidth) { if (!this.bubble_hl) { this.undoHButtons(); this.drawButton(2, 1); this.paintIt(); this.bubble_hl = true; } return true; } else { return false; } } public void run() { while(true) { if (!this.bypass) { try { Thread.sleep((long)(this.auto_delay * 100)); } catch (InterruptedException var2) { } } else { this.bypass = false; } while(this.m_down) { if (this.auto_type != 3 && this.auto_type != 4 || this.field_0 > 0 && this.field_0 < this.sbWidth && this.field_1 <= this.sbHeight - this.sbWidth && this.field_1 >= this.sbWidth && (this.auto_type != 3 || !((float)this.field_1 > this.bubble_pos)) && (this.auto_type != 4 || !((float)this.field_1 < this.bubble_pos + (float)this.sbWidth))) { this.checkDbutton(this.the_e, this.auto_type); try { Thread.sleep((long)this.auto_rate); } catch (InterruptedException var1) { } } } } } public boolean mouseDrag(Event var1, int var2, int var3) { this.field_0 = var2; this.field_1 = var3; if (this.bad_scroll) { return true; } else { if (this.dragging_bubble) { if (this.drag_move != var3) { this.hbp = this.bubble_pos + (float)(var3 - this.drag_move); if (this.hbp > (float)(this.bubble_range + this.sbWidth)) { this.hbp = (float)(this.bubble_range + this.sbWidth); } if (this.hbp < (float)this.sbWidth) { this.hbp = (float)this.sbWidth; } this.syncGraphics(6); var1.id = 605; ((Component)this).postEvent(var1); this.drag_move = var3; } } else { if (this.auto_type > 2) { return true; } if (var2 > 0 && var2 < this.sbWidth && this.cButtons(var3)) { this.m_off = false; return true; } this.m_off = true; this.syncGraphics(7); } return true; } } public boolean mouseMove(Event var1, int var2, int var3) { if (!this.m_down && !this.bad_scroll) { if (this.cButtons(var3)) { return true; } else { this.syncGraphics(9); return true; } } else { return true; } } }