📄 speedscaleshell.java
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space
// Source File Name: SpeedScaleShell.java
package org.gudy.azureus2.ui.swt.shells;
import java.io.PrintStream;
import java.util.*;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.*;
import org.gudy.azureus2.core3.util.*;
import org.gudy.azureus2.ui.swt.Utils;
// Referenced classes of package org.gudy.azureus2.ui.swt.shells:
// GCStringPrinter
public class SpeedScaleShell
{
private static final boolean MOUSE_ONLY_UP_EXITS = true;
private static final int OPTION_HEIGHT = 15;
private static final int TEXT_HEIGHT = 32;
private static final int SCALER_HEIGHT = 20;
private int HEIGHT;
private static final int WIDTH = 120;
private static final int PADDING_X0 = 10;
private static final int PADDING_X1 = 10;
private static final int WIDTH_NO_PADDING = 100;
private static final int TYPED_TEXT_ALPHA = 80;
private static final long CLOSE_DELAY = 600L;
private int value;
private boolean cancelled;
private int minValue;
private int maxValue;
private int maxTextValue;
private int pageIncrement;
private int bigPageIncrement;
private Shell shell;
private LinkedHashMap mapOptions;
private String sValue;
private Composite composite;
private boolean menuChosen;
protected boolean lastMoveHadMouseDown;
private boolean assumeInitiallyDown;
private TimerEventPerformer cursorBlinkPerformer;
private TimerEvent cursorBlinkEvent;
public static void main(String args[])
{
SpeedScaleShell speedScaleWidget = new SpeedScaleShell() {
public String getStringValue()
{
return (new StringBuilder()).append(getValue()).append("b/s").toString();
}
};
speedScaleWidget.setMaxValue(10000);
speedScaleWidget.setMaxTextValue(15000);
speedScaleWidget.addOption("AutoSpeed", -1);
speedScaleWidget.addOption("Preset: 10b/s", 10);
speedScaleWidget.addOption("Preset: 20b/s", 20);
speedScaleWidget.addOption("Preset: 1b/s", 1);
speedScaleWidget.addOption("Preset: 1000b/s", 1000);
speedScaleWidget.addOption("Preset: A really long preset", 2000);
System.out.println((new StringBuilder()).append("returns ").append(speedScaleWidget.open(1000, Constants.isWindows)).append(" w/").append(speedScaleWidget.getValue()).toString());
}
public SpeedScaleShell()
{
HEIGHT = 52;
mapOptions = new LinkedHashMap();
sValue = "";
cursorBlinkPerformer = null;
cursorBlinkEvent = null;
minValue = 0;
maxValue = -1;
maxTextValue = -1;
pageIncrement = 10;
bigPageIncrement = 100;
cancelled = true;
menuChosen = false;
}
public boolean open(final int startValue, boolean _assumeInitiallyDown)
{
value = startValue;
assumeInitiallyDown = _assumeInitiallyDown;
if (assumeInitiallyDown)
lastMoveHadMouseDown = true;
cancelled = true;
shell = new Shell(Utils.findAnyShell(), 0x20004000);
shell.setLayout(new FillLayout());
final Display display = shell.getDisplay();
composite = new Composite(shell, 0x20000000);
final Point firstMousePos = display.getCursorLocation();
composite.addTraverseListener(new TraverseListener() {
final SpeedScaleShell this$0;
public void keyTraversed(TraverseEvent e)
{
if (e.detail == 2)
{
setCancelled(true);
shell.dispose();
} else
if (e.detail == 64)
setValue(value + 1);
else
if (e.detail == 32)
setValue(value - 1);
else
if (e.detail == 512)
setValue(value + bigPageIncrement);
else
if (e.detail == 256)
setValue(value - bigPageIncrement);
else
if (e.detail == 4)
{
setCancelled(false);
shell.dispose();
}
}
{
this$0 = SpeedScaleShell.this;
super();
}
});
composite.addKeyListener(new KeyListener() {
final SpeedScaleShell this$0;
public void keyReleased(KeyEvent keyevent)
{
}
public void keyPressed(KeyEvent e)
{
if (e.keyCode == 0x1000006 && e.stateMask == 0)
setValue(value + pageIncrement);
else
if (e.keyCode == 0x1000005 && e.stateMask == 0)
setValue(value - pageIncrement);
else
if (e.keyCode == 0x1000007)
setValue(minValue);
else
if (e.keyCode == 0x1000008 && maxValue != -1)
setValue(maxValue);
}
{
this$0 = SpeedScaleShell.this;
super();
}
});
composite.addMouseMoveListener(new MouseMoveListener() {
final SpeedScaleShell this$0;
public void mouseMove(MouseEvent e)
{
lastMoveHadMouseDown = false;
boolean hasButtonDown = (e.stateMask & SWT.BUTTON_MASK) > 0 || assumeInitiallyDown;
if (hasButtonDown)
{
if (e.y > HEIGHT - 20)
{
lastMoveHadMouseDown = true;
setValue(getValueFromMousePos(e.x));
}
composite.redraw();
} else
{
composite.redraw();
}
}
{
this$0 = SpeedScaleShell.this;
super();
}
});
composite.addMouseTrackListener(new MouseTrackListener() {
boolean mouseIsOut;
private boolean exitCancelled;
final SpeedScaleShell this$0;
public void mouseHover(MouseEvent mouseevent)
{
}
public void mouseExit(MouseEvent e)
{
mouseIsOut = true;
SimpleTimer.addEvent("close scaler", SystemTime.getOffsetTime(600L), new TimerEventPerformer() {
final 5 this$1;
public void perform(TimerEvent event)
{
Utils.execSWTThread(new AERunnable() {
final 1 this$2;
public void runSupport()
{
if (!exitCancelled)
shell.dispose();
else
exitCancelled = false;
}
{
this$2 = 1.this;
super();
}
});
}
{
this$1 = 5.this;
super();
}
});
}
public void mouseEnter(MouseEvent e)
{
if (mouseIsOut)
exitCancelled = true;
mouseIsOut = false;
}
{
this$0 = SpeedScaleShell.this;
super();
mouseIsOut = false;
exitCancelled = false;
}
});
composite.addMouseListener(new MouseListener() {
boolean bMouseDown;
final Display val$display;
final Point val$firstMousePos;
final SpeedScaleShell this$0;
public void mouseUp(MouseEvent e)
{
if (assumeInitiallyDown)
assumeInitiallyDown = false;
if (lastMoveHadMouseDown)
{
Point mousePos = display.getCursorLocation();
if (mousePos.equals(firstMousePos))
{
lastMoveHadMouseDown = false;
return;
}
}
bMouseDown = true;
if (bMouseDown)
if (e.y > HEIGHT - 20)
{
setValue(getValueFromMousePos(e.x));
setCancelled(false);
if (lastMoveHadMouseDown)
shell.dispose();
} else
if (e.y > 32)
{
int idx = (e.y - 32) / 15;
Iterator iterator = mapOptions.keySet().iterator();
int newValue;
do
newValue = ((Integer)iterator.next()).intValue();
while (--idx >= 0);
value = newValue;
setCancelled(false);
setMenuChosen(true);
shell.dispose();
}
}
public void mouseDown(MouseEvent e)
{
if (e.count > 1)
{
lastMoveHadMouseDown = true;
return;
}
Point mousePos = display.getCursorLocation();
if (e.y > HEIGHT - 20)
{
bMouseDown = true;
setValue(getValueFromMousePos(e.x));
}
}
public void mouseDoubleClick(MouseEvent mouseevent)
{
}
{
this$0 = SpeedScaleShell.this;
display = display1;
firstMousePos = point;
super();
bMouseDown = false;
}
});
composite.addPaintListener(new PaintListener() {
final int val$startValue;
final Display val$display;
final SpeedScaleShell this$0;
public void paintControl(PaintEvent e)
{
int x = (100 * SpeedScaleShell.this.value) / maxValue;
if (x < 0)
x = 0;
else
if (x > 100)
x = 100;
int startX = (100 * startValue) / maxValue;
if (startX < 0)
startX = 0;
else
if (startX > 100)
startX = 100;
int baseLinePos = getBaselinePos();
try
{
e.gc.setAdvanced(true);
e.gc.setAntialias(1);
}
catch (Exception ex) { }
e.gc.setForeground(display.getSystemColor(18));
e.gc.drawLine(10, baseLinePos - 6, 10, baseLinePos + 6);
e.gc.drawLine(110, baseLinePos - 6, 110, baseLinePos + 6);
e.gc.drawLine(10, baseLinePos, 110, baseLinePos);
e.gc.setForeground(display.getSystemColor(21));
e.gc.setBackground(display.getSystemColor(21));
e.gc.drawLine(10 + startX, baseLinePos - 5, 10 + startX, baseLinePos + 5);
e.gc.fillRoundRectangle((10 + x) - 2, baseLinePos - 5, 5, 10, 10, 10);
e.gc.setForeground(display.getSystemColor(28));
e.gc.setBackground(display.getSystemColor(29));
e.gc.fillRectangle(0, 0, 120, 32);
GCStringPrinter.printString(e.gc, _getStringValue(), new Rectangle(0, 0, 120, HEIGHT), true, false, 0x10000c0);
e.gc.drawLine(0, 31, 120, 31);
int y = 32;
Point mousePos = composite.toControl(display.getCursorLocation());
for (Iterator iter = mapOptions.keySet().iterator(); iter.hasNext();)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -