}
});
Rectangle printArea = new Rectangle(BORDER_X, 0, WIDTH - (BORDER_X * 2),
5000);
spText = new GCStringPrinter(gc, text, printArea, true, false, SWT.WRAP);
spText.setUrlColor(Colors.blues[Colors.FADED_DARKEST]);
spText.calculateMetrics();
gc.setFont(fontCount);
String sCount = MessageText.getString("OpenTorrentWindow.xOfTotal",
new String[] {
"" + historyPosition + 1,
"" + getWarningCount()
});
spCount = new GCStringPrinter(gc, sCount, printArea, true, false, SWT.WRAP);
spCount.calculateMetrics();
gc.setFont(fontTitle);
spTitle = new GCStringPrinter(gc, title, printArea, true, false, SWT.WRAP);
spTitle.calculateMetrics();
gc.dispose();
sizeText = spText.getCalculatedSize();
sizeTitle = spTitle.getCalculatedSize();
sizeCount = spCount.getCalculatedSize();
FormData fd;
Button btnDismiss = new Button(shell, SWT.PUSH);
Messages.setLanguageText(btnDismiss, "Button.dismiss");
final int btnHeight = btnDismiss.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
Button btnPrev = new Button(shell, SWT.PUSH);
btnPrev.setText("<");
Button btnNext = new Button(shell, SWT.PUSH);
btnNext.setText(">");
fd = new FormData();
fd.bottom = new FormAttachment(100, -BORDER_Y1);
fd.right = new FormAttachment(100, -BORDER_X);
btnNext.setLayoutData(fd);
fd = new FormData();
fd.bottom = new FormAttachment(100, -BORDER_Y1);
fd.right = new FormAttachment(btnNext, -BORDER_X);
btnPrev.setLayoutData(fd);
fd = new FormData();
fd.bottom = new FormAttachment(100, -BORDER_Y1);
fd.right = new FormAttachment(btnPrev, -BORDER_X);
btnDismiss.setLayoutData(fd);
height = BORDER_Y0 + sizeTitle.y + GAP_Y + sizeText.y + GAP_Y_TITLE_COUNT
+ sizeCount.y + GAP_BUTTON_Y + btnHeight + BORDER_Y1;
Rectangle area = shell.computeTrim(ptBottomRight.x - WIDTH, ptBottomRight.y
- height, WIDTH, height);
shell.setBounds(area);
shell.setLocation(ptBottomRight.x - area.width, ptBottomRight.y
- area.height - 2);
rectX = new Rectangle(area.width - BORDER_X - boundsClose.width, BORDER_Y0,
boundsClose.width, boundsClose.height);
shell.addMouseMoveListener(new MouseMoveListener() {
int lastCursor = SWT.CURSOR_ARROW;
public void mouseMove(MouseEvent e) {
if (shell == null || shell.isDisposed()) {
return;
}
URLInfo hitUrl = spText.getHitUrl(e.x, e.y);
int cursor = (rectX.contains(e.x, e.y)) || hitUrl != null
? SWT.CURSOR_HAND : SWT.CURSOR_ARROW;
if (cursor != lastCursor) {
lastCursor = cursor;
shell.setCursor(e.display.getSystemCursor(cursor));
}
}
});
shell.addMouseListener(new MouseListener() {
public void mouseUp(MouseEvent e) {
if (shell == null || shell.isDisposed()) {
return;
}
if (rectX.contains(e.x, e.y)) {
shell.dispose();
}
URLInfo hitUrl = spText.getHitUrl(e.x, e.y);
if (hitUrl != null) {
if (hitUrl.url.equals("details")) {
MessageBoxShell mb = new MessageBoxShell(Constants.APP_NAME,
logAlert.details, new String[] {
MessageText.getString("Button.ok")
}, 0);
mb.setUseTextBox(true);
mb.setParent(Utils.findAnyShell());
mb.open(null);
} else {
Utils.launch(hitUrl.url);
}
}
}
public void mouseDown(MouseEvent e) {
}
public void mouseDoubleClick(MouseEvent e) {
}
});
shell.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
e.gc.drawImage(imgClose, WIDTH - BORDER_X - boundsClose.width,
BORDER_Y0);
Rectangle printArea;
printArea = new Rectangle(BORDER_X, BORDER_Y0 + sizeTitle.y + GAP_Y_TITLE_COUNT,
WIDTH, 100);
String sCount = MessageText.getString("OpenTorrentWindow.xOfTotal",
new String[] {
"" + (historyPosition + 1),
"" + getWarningCount()
});
e.gc.setAlpha(180);
Font lastFont = e.gc.getFont();
e.gc.setFont(fontCount);
spCount = new GCStringPrinter(e.gc, sCount, printArea, true, false,
SWT.WRAP | SWT.TOP);
spCount.printString();
e.gc.setAlpha(255);
sizeCount = spCount.getCalculatedSize();