📄 lightboxshell.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: LightBoxShell.java
package org.gudy.azureus2.ui.swt.components.shell;
import com.aelitis.azureus.ui.swt.UIFunctionsManagerSWT;
import com.aelitis.azureus.ui.swt.UIFunctionsSWT;
import com.aelitis.azureus.ui.swt.imageloader.ImageLoader;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.widgets.*;
import org.gudy.azureus2.core3.util.AERunnable;
import org.gudy.azureus2.core3.util.Constants;
import org.gudy.azureus2.ui.swt.Utils;
import org.gudy.azureus2.ui.swt.mainwindow.Colors;
import org.gudy.azureus2.ui.swt.mainwindow.IMainWindow;
// Referenced classes of package org.gudy.azureus2.ui.swt.components.shell:
// StyledShell
public class LightBoxShell
{
private Shell lbShell;
private Shell parentShell;
private int insetTop;
private int insetBottom;
private int insetLeft;
private int insetRight;
private boolean closeOnESC;
private boolean isAlreadyOpened;
private Display display;
private UIFunctionsSWT uiFunctions;
private boolean isBusy;
private Image spinnerImages[];
private Rectangle spinnerBounds;
private boolean busyAlready;
private Canvas spinnerCanvas;
private Rectangle shellBounds;
private boolean parentActivatedOnce;
public static final int RESIZE_VERTICAL = 2;
public static final int RESIZE_HORIZONTAL = 4;
private int styleMask;
private int alphaLevel;
public LightBoxShell()
{
this(false);
}
public LightBoxShell(boolean closeOnESC)
{
lbShell = null;
parentShell = null;
insetTop = 0;
insetBottom = 0;
insetLeft = 0;
insetRight = 0;
this.closeOnESC = false;
isAlreadyOpened = false;
isBusy = false;
spinnerImages = null;
spinnerBounds = null;
busyAlready = false;
spinnerCanvas = null;
shellBounds = null;
parentActivatedOnce = false;
styleMask = 6;
alphaLevel = 178;
this.closeOnESC = closeOnESC;
parentShell = getUIFunctions().getMainShell();
if (null == parentShell)
{
return;
} else
{
IMainWindow mainWindow = getUIFunctions().getMainWindow();
Rectangle r = mainWindow.getMetrics(3);
setInsets(0, r.height, 0, 0);
createControls();
return;
}
}
public LightBoxShell(Shell parentShell, boolean closeOnESC)
{
lbShell = null;
this.parentShell = null;
insetTop = 0;
insetBottom = 0;
insetLeft = 0;
insetRight = 0;
this.closeOnESC = false;
isAlreadyOpened = false;
isBusy = false;
spinnerImages = null;
spinnerBounds = null;
busyAlready = false;
spinnerCanvas = null;
shellBounds = null;
parentActivatedOnce = false;
styleMask = 6;
alphaLevel = 178;
this.parentShell = parentShell;
this.closeOnESC = closeOnESC;
createControls();
}
public void setInsets(int top, int bottom, int left, int right)
{
insetTop = top;
insetBottom = bottom;
insetLeft = left;
insetRight = right;
if (null != lbShell && !lbShell.isDisposed() && isAlreadyOpened())
lbShell.setBounds(getBounds(true));
}
private void createControls()
{
if (null == parentShell)
return;
lbShell = new Shell(parentShell, 8);
if (Constants.isOSX)
getUIFunctions().createMainMenu(lbShell);
display = parentShell.getDisplay();
if (closeOnESC)
lbShell.addListener(31, new Listener() {
final LightBoxShell this$0;
public void handleEvent(Event e)
{
if (e.detail == 2)
{
e.doit = false;
close();
}
}
{
this$0 = LightBoxShell.this;
super();
}
});
if (Constants.isOSX)
lbShell.addShellListener(new ShellAdapter() {
final LightBoxShell this$0;
public void shellActivated(ShellEvent e)
{
if (null != parentShell && !parentShell.isDisposed())
if (!parentActivatedOnce)
{
parentActivatedOnce = true;
parentShell.forceActive();
} else
{
parentActivatedOnce = false;
}
}
{
this$0 = LightBoxShell.this;
super();
}
});
lbShell.addDisposeListener(new DisposeListener() {
final LightBoxShell this$0;
public void widgetDisposed(DisposeEvent e)
{
if (null != spinnerImages)
spinnerImages = null;
}
{
this$0 = LightBoxShell.this;
super();
}
});
final ControlListener moveAndResizeListener = new ControlListener() {
final LightBoxShell this$0;
public void controlMoved(ControlEvent e)
{
shellBounds = null;
getBounds();
lbShell.setLocation(shellBounds.x, shellBounds.y);
}
public void controlResized(ControlEvent e)
{
if ((styleMask & 4) != 0 && (styleMask & 2) != 0)
{
shellBounds = null;
getBounds();
lbShell.setSize(shellBounds.width, shellBounds.height);
} else
if ((styleMask & 4) != 0)
{
shellBounds = null;
getBounds();
lbShell.setSize(shellBounds.width, lbShell.getSize().y);
} else
if ((styleMask & 2) != 0)
{
shellBounds = null;
getBounds();
lbShell.setSize(lbShell.getSize().x, shellBounds.height);
}
}
{
this$0 = LightBoxShell.this;
super();
}
};
parentShell.addControlListener(moveAndResizeListener);
lbShell.addDisposeListener(new DisposeListener() {
final ControlListener val$moveAndResizeListener;
final LightBoxShell this$0;
public void widgetDisposed(DisposeEvent e)
{
parentShell.removeControlListener(moveAndResizeListener);
}
{
this$0 = LightBoxShell.this;
moveAndResizeListener = controllistener;
super();
}
});
}
private UIFunctionsSWT getUIFunctions()
{
if (null == uiFunctions)
{
uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
if (null == uiFunctions)
throw new NullPointerException("An initialized instance of UIFunctionsSWT is required to create a LightBoxShell");
}
return uiFunctions;
}
public void open()
{
if (null != lbShell && !lbShell.isDisposed())
{
lbShell.setBounds(getBounds());
isAlreadyOpened = true;
lbShell.setBackground(Colors.black);
try
{
lbShell.setAlpha(alphaLevel);
}
catch (Throwable t) { }
lbShell.open();
}
}
public void close()
{
Utils.execSWTThread(new AERunnable() {
final LightBoxShell this$0;
public void runSupport()
{
if (null != lbShell && !lbShell.isDisposed())
lbShell.dispose();
}
{
this$0 = LightBoxShell.this;
super();
}
});
}
public Rectangle getBounds()
{
return getBounds(false);
}
private Rectangle getBounds(boolean recalculate)
{
if (!recalculate && null != shellBounds)
{
return new Rectangle(shellBounds.x, shellBounds.y, shellBounds.width, shellBounds.height);
} else
{
shellBounds = parentShell.getClientArea();
Point parentLocation = parentShell.toDisplay(insetLeft, insetTop);
shellBounds.x = parentLocation.x;
shellBounds.y = parentLocation.y;
shellBounds.width -= insetRight + insetLeft;
shellBounds.height -= insetTop + insetBottom;
return new Rectangle(shellBounds.x, shellBounds.y, shellBounds.width, shellBounds.height);
}
}
public StyledShell createPopUpShell(int borderWidth, boolean closeLightboxOnExit)
{
return createPopUpShell(borderWidth, closeLightboxOnExit, true);
}
public StyledShell createPopUpShell(int borderWidth, boolean closeLightboxOnExit, boolean useCustomTrim)
{
StyledShell newShell = new StyledShell(lbShell, borderWidth, useCustomTrim);
if (closeLightboxOnExit)
newShell.addListener(12, new Listener() {
final LightBoxShell this$0;
public void handleEvent(Event event)
{
close();
}
{
this$0 = LightBoxShell.this;
super();
}
});
return newShell;
}
public void open(StyledShell shellToOpen)
{
if (null != shellToOpen && null != lbShell)
{
if (!isAlreadyOpened)
open();
if (!shellToOpen.isAlreadyOpened())
shellToOpen.open();
}
}
public void setCursor(Cursor cursor)
{
if (null != lbShell && !lbShell.isDisposed())
lbShell.setCursor(cursor);
}
public void setData(String key, Object value)
{
if (null != lbShell && !lbShell.isDisposed())
lbShell.setData(key, value);
}
public Display getDisplay()
{
return display;
}
public boolean isAlreadyOpened()
{
return isAlreadyOpened;
}
public void addDisposeListener(DisposeListener listener)
{
lbShell.addDisposeListener(listener);
}
public void showBusy(boolean value, long delayInMilli)
{
if (value == isBusy)
return;
isBusy = value;
if (isBusy && !busyAlready)
showSpinner(Math.max(0L, delayInMilli));
}
private void showSpinner(long delayInMilli)
{
if (null == spinnerImages)
{
ImageLoader imageLoader = ImageLoader.getInstance();
spinnerImages = imageLoader.getImages("spinner_big");
if (spinnerImages.length == 0)
return;
int w = 0;
int h = 0;
for (int i = 0; i < spinnerImages.length; i++)
{
Image image = spinnerImages[i];
Rectangle bounds = image.getBounds();
w = Math.max(w, bounds.width);
h = Math.max(w, bounds.height);
}
spinnerBounds = new Rectangle(0, 0, w, h);
lbShell.addDisposeListener(new DisposeListener() {
final LightBoxShell this$0;
public void widgetDisposed(DisposeEvent e)
{
ImageLoader imageLoader = ImageLoader.getInstance();
imageLoader.releaseImage("spinner_big");
}
{
this$0 = LightBoxShell.this;
super();
}
});
}
Utils.centerRelativeTo(spinnerBounds, getBounds());
Point to_lbShell = lbShell.toControl(spinnerBounds.x, spinnerBounds.y);
spinnerBounds.x = to_lbShell.x;
spinnerBounds.y = to_lbShell.y;
final int imageDataIndex[] = new int[1];
if (null == spinnerCanvas)
{
spinnerCanvas = new Canvas(lbShell, 0);
spinnerCanvas.addPaintListener(new PaintListener() {
final int val$imageDataIndex[];
final LightBoxShell this$0;
public void paintControl(PaintEvent e)
{
e.gc.drawImage(spinnerImages[imageDataIndex[0]], 0, 0);
}
{
this$0 = LightBoxShell.this;
imageDataIndex = ai;
super();
}
});
}
spinnerCanvas.setBackground(lbShell.getBackground());
spinnerCanvas.setBounds(spinnerBounds);
Utils.execSWTThreadLater(100, new AERunnable() {
final int val$imageDataIndex[];
final LightBoxShell this$0;
public void runSupport()
{
if (!isBusy || spinnerImages == null)
{
busyAlready = false;
return;
}
busyAlready = true;
if (null != spinnerCanvas && !spinnerCanvas.isDisposed())
{
spinnerCanvas.redraw();
spinnerCanvas.update();
}
if (imageDataIndex[0] == spinnerImages.length - 1)
imageDataIndex[0] = 0;
else
imageDataIndex[0]++;
Utils.execSWTThreadLater(100, this);
}
{
this$0 = LightBoxShell.this;
imageDataIndex = ai;
super();
}
});
}
public int getStyleMask()
{
return styleMask;
}
public void setStyleMask(int styleMask)
{
this.styleMask = styleMask;
}
public int getAlphaLevel()
{
return alphaLevel;
}
public void setAlphaLevel(final int alphaLevel)
{
this.alphaLevel = alphaLevel;
Utils.execSWTThread(new AERunnable() {
final int val$alphaLevel;
final LightBoxShell this$0;
public void runSupport()
{
if (lbShell.isDisposed())
return;
try
{
lbShell.setAlpha(alphaLevel);
}
catch (Throwable t) { }
}
{
this$0 = LightBoxShell.this;
alphaLevel = i;
super();
}
});
}
public void moveAbove(Control control)
{
lbShell.moveAbove(control);
}
public Shell getShell()
{
return lbShell;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -