📄 minimizedwindow.java
字号:
/*
* Created on 8 juil. 2003
* Copyright (C) 2003, 2004, 2005, 2006 Aelitis, All Rights Reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* AELITIS, SAS au capital de 46,603.30 euros
* 8 Allee Lenotre, La Grille Royale, 78600 Le Mesnil le Roi, France.
*
*/
package org.gudy.azureus2.ui.swt;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.*;
import org.gudy.azureus2.core3.download.DownloadManager;
import org.gudy.azureus2.core3.internat.MessageText;
import org.gudy.azureus2.core3.util.AEMonitor;
import org.gudy.azureus2.core3.util.AERunnable;
import org.gudy.azureus2.core3.util.Constants;
import org.gudy.azureus2.core3.util.DisplayFormatters;
import org.gudy.azureus2.ui.swt.mainwindow.Colors;
import org.gudy.azureus2.ui.swt.components.shell.ShellManager;
import org.eclipse.swt.widgets.ProgressBar;
import java.util.Iterator;
import java.util.Vector;
/**
* DownloadBar + manager
*
* @author Olivier
*
*/
public class MinimizedWindow {
Shell splash;
Label lDrag;
MinimizedWindow stucked;
private Rectangle screen;
private static final Vector downloadBars = new Vector();
private static final AEMonitor downloadBars_mon = new AEMonitor("DLBars");
private static final ShellManager shellManager = new ShellManager();
private int xPressed, yPressed;
private boolean moving;
private int hSize;
private Label splashFile;
private Label splashDown;
private Label splashUp;
private Label splashTime;
public ProgressBar pb1;
public GC gc;
private DownloadManager manager;
public MinimizedWindow(DownloadManager _manager, Shell main) {
manager = _manager;
this.stucked = null;
// The splash Screen setup
splash = org.gudy.azureus2.ui.swt.components.shell.ShellFactory.createShell(SWT.ON_TOP);
shellManager.addWindow(splash);
main.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent event) {
close();
}
});
this.screen = main.getDisplay().getClientArea();
lDrag = new Label(splash, SWT.NULL);
if(! Constants.isOSX) {
lDrag.setImage(ImageRepository.getImage("dragger")); //$NON-NLS-1$
}
lDrag.pack();
int hSizeImage = lDrag.getSize().y;
int xSize = lDrag.getSize().x + 3;
lDrag.setLocation(0, 0);
MouseListener mListener = new MouseAdapter() {
public void mouseDown(MouseEvent e) {
xPressed = e.x;
yPressed = e.y;
moving = true;
//System.out.println("Position : " + xPressed + " , " + yPressed);
}
public void mouseUp(MouseEvent e) {
moving = false;
}
};
MouseMoveListener mMoveListener = new MouseMoveListener() {
public void mouseMove(MouseEvent e) {
if (moving) {
int dX = xPressed - e.x;
int dY = yPressed - e.y;
//System.out.println("dX,dY : " + dX + " , " + dY);
Point currentLoc = splash.getLocation();
currentLoc.x -= dX;
currentLoc.y -= dY;
setSnapLocation(currentLoc);
//System.out.println("Position : " + xPressed + " , " + yPressed);
}
}
};
splash.setBackground(Colors.blues[Colors.BLUES_LIGHTEST]);
splash.setForeground(Colors.blues[Colors.BLUES_DARKEST]);
splash.addMouseListener(mListener);
splash.addMouseMoveListener(mMoveListener);
lDrag.addMouseListener(mListener);
lDrag.addMouseMoveListener(mMoveListener);
Label l1 = new Label(splash, SWT.NONE);
l1.setBackground(Colors.blues[Colors.BLUES_LIGHTEST]);
l1.setForeground(Colors.blues[Colors.BLUES_DARKEST]);
Messages.setLanguageText(l1, "MinimizedWindow.name"); //$NON-NLS-1$
l1.addMouseListener(mListener);
l1.addMouseMoveListener(mMoveListener);
l1.pack();
l1.setLocation(xSize, 0);
xSize += l1.getSize().x + 3;
int hSizeText = l1.getSize().y;
hSize = hSizeText > hSizeImage ? hSizeText : hSizeImage;
splashFile = new Label(splash, SWT.NONE);
splashFile.setBackground(Colors.blues[Colors.BLUES_LIGHTEST]);
splashFile.setText(""); //$NON-NLS-1$
splashFile.addMouseListener(mListener);
splashFile.addMouseMoveListener(mMoveListener);
splashFile.setSize(200, hSize);
splashFile.setLocation(xSize, 0);
xSize += 200 + 3;
pb1 = new ProgressBar(splash ,SWT.SMOOTH);
pb1.setBackground(Colors.blues[Colors.BLUES_LIGHTEST]);
pb1.setForeground(Colors.blues[Colors.BLUES_MIDLIGHT]);
pb1.setMinimum(0);
pb1.setMaximum(1000);
pb1.addMouseListener(mListener);
pb1.addMouseMoveListener(mMoveListener);
pb1.setSize(100, hSize);
pb1.setLocation(xSize, 0);
xSize += 100 + 5;
Listener pb_listener = new Listener() {
public void handleEvent(Event event) {
int perc = manager.getStats().getCompleted();
Color old = event.gc.getForeground();
event.gc.setForeground(Colors.black);
/*
FontData[] fd = splashFile.getFont().getFontData();
int y_offset = ( pb1.getSize().y - fd[0].getHeight() )/2;
if ( y_offset < 0 ){
y_offset = 0;
}
*/
int char_width = event.gc.getFontMetrics().getAverageCharWidth();
String percent = DisplayFormatters.formatPercentFromThousands(perc);
event.gc.drawText(percent, ( pb1.getSize().x - percent.length() * char_width )/2, -1, true);
event.gc.setForeground(old);
}
};
pb1.addListener(SWT.Paint,pb_listener);
Label l3 = new Label(splash, SWT.NONE);
l3.setBackground(Colors.blues[Colors.BLUES_LIGHTEST]);
l3.setForeground(Colors.blues[Colors.BLUES_DARKEST]);
l3.setText(MessageText.getString("ConfigView.download.abbreviated"));
l3.addMouseListener(mListener);
l3.addMouseMoveListener(mMoveListener);
l3.pack();
l3.setLocation(xSize, 0);
xSize += l3.getSize().x + 3;
splashDown = new Label(splash, SWT.NONE);
splashDown.setBackground(Colors.blues[Colors.BLUES_LIGHTEST]);
splashDown.setText(""); //$NON-NLS-1$
splashDown.addMouseListener(mListener);
splashDown.addMouseMoveListener(mMoveListener);
splashDown.setSize(65, hSize);
splashDown.setLocation(xSize, 0);
xSize += 65 + 3;
Label l4 = new Label(splash, SWT.NONE);
l4.setBackground(Colors.blues[Colors.BLUES_LIGHTEST]);
l4.setForeground(Colors.blues[Colors.BLUES_DARKEST]);
l4.setText(MessageText.getString("ConfigView.upload.abbreviated"));
l4.addMouseListener(mListener);
l4.addMouseMoveListener(mMoveListener);
l4.pack();
l4.setLocation(xSize, 0);
xSize += l4.getSize().x + 3;
splashUp = new Label(splash, SWT.NONE);
splashUp.setBackground(Colors.blues[Colors.BLUES_LIGHTEST]);
splashUp.setText(""); //$NON-NLS-1$
splashUp.addMouseListener(mListener);
splashUp.addMouseMoveListener(mMoveListener);
splashUp.setSize(65, hSize);
splashUp.setLocation(xSize, 0);
xSize += 65 + 3;
Label l5 = new Label(splash, SWT.NONE);
l5.setBackground(Colors.blues[Colors.BLUES_LIGHTEST]);
l5.setForeground(Colors.blues[Colors.BLUES_DARKEST]);
l5.setText(MessageText.getString("MyTorrentsView.eta") + ":");
l5.addMouseListener(mListener);
l5.addMouseMoveListener(mMoveListener);
l5.pack();
l5.setLocation(xSize, 0);
xSize += l5.getSize().x + 3;
splashTime = new Label(splash, SWT.NONE);
splashTime.setBackground(Colors.blues[Colors.BLUES_LIGHTEST]);
splashTime.setText(""); //$NON-NLS-1$
splashTime.addMouseListener(mListener);
splashTime.addMouseMoveListener(mMoveListener);
splashTime.setSize(65, hSize);
splashTime.setLocation(xSize, 0);
xSize += 65 + 3;
splash.addListener(SWT.Deiconify, new Listener() {
public void handleEvent(Event e) {
splash.setVisible(true);
//splash.setMaximized(true);
splash.setActive();
}
});
splash.setSize(xSize + 3, hSize + 2);
Menu menu = new Menu(splash,SWT.POP_UP);
MenuItem itemClose = new MenuItem(menu,SWT.NULL);
itemClose.setText(MessageText.getString("wizard.close"));
itemClose.addListener(SWT.Selection,new Listener() {
public void handleEvent(Event e) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -