final Composite titleCircle = new Composite(outerCircle, SWT.NO_FOCUS);
titleCircle.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
titleCircle.setBackgroundMode(SWT.INHERIT_FORCE);
titleCircle.setLayout(LayoutUtils.createGridLayout(2, 3, 0, 5, 3, false));
titleCircle.addMouseTrackListener(fMouseTrackListner);
titleCircle.addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
Rectangle clArea = titleCircle.getClientArea();
Image oldBgImage = fTitleBgImage;
fTitleBgImage = new Image(titleCircle.getDisplay(), clArea.width, clArea.height);
GC gc = new GC(fTitleBgImage);
/* Gradient */
drawGradient(gc, clArea);
/* Fix Region Shape */
fixRegion(gc, clArea);
gc.dispose();
titleCircle.setBackgroundImage(fTitleBgImage);
if (oldBgImage != null)
oldBgImage.dispose();
}
private void drawGradient(GC gc, Rectangle clArea) {
gc.setForeground(fNotifierColors.getGradientBegin());
gc.setBackground(fNotifierColors.getGradientEnd());
gc.fillGradientRectangle(clArea.x, clArea.y, clArea.width, clArea.height, true);
}
private void fixRegion(GC gc, Rectangle clArea) {
gc.setForeground(fNotifierColors.getBorder());
/* Fill Top Left */
gc.drawPoint(2, 0);
gc.drawPoint(3, 0);
gc.drawPoint(1, 1);
gc.drawPoint(0, 2);
gc.drawPoint(0, 3);
/* Fill Top Right */
gc.drawPoint(clArea.width - 4, 0);
gc.drawPoint(clArea.width - 3, 0);
gc.drawPoint(clArea.width - 2, 1);
gc.drawPoint(clArea.width - 1, 2);
gc.drawPoint(clArea.width - 1, 3);
}
});
/* Title Label displaying RSSOwl */
fTitleCircleLabel = new CLabel(titleCircle, SWT.NO_FOCUS);
fTitleCircleLabel.setImage(OwlUI.getImage(fResources, "icons/product/24x24.png")); //$NON-NLS-1$
fTitleCircleLabel.setText("RSSOwl"); //$NON-NLS-1$
fTitleCircleLabel.setFont(fBoldTextFont);
fTitleCircleLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true));
fTitleCircleLabel.addMouseTrackListener(fMouseTrackListner);
fTitleCircleLabel.setCursor(fShell.getDisplay().getSystemCursor(SWT.CURSOR_HAND));
fTitleCircleLabel.addMouseListener(new MouseAdapter() {
@Override
public void mouseUp(MouseEvent e) {
doRestore();
}
});
/* CLabel to display a cross to close the popup */
final CLabel closeButton = new CLabel(titleCircle, SWT.NO_FOCUS);
closeButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
closeButton.setImage(fCloseImageNormal);
closeButton.setCursor(fShell.getDisplay().getSystemCursor(SWT.CURSOR_HAND));
closeButton.addMouseTrackListener(fMouseTrackListner);
closeButton.addMouseListener(new MouseAdapter() {
@Override
public void mouseUp(MouseEvent e) {
doClose();
}
@Override
public void mouseDown(MouseEvent e) {
closeButton.setImage(fCloseImagePressed);
}
});
closeButton.addMouseTrackListener(new MouseTrackAdapter() {
@Override
public void mouseEnter(MouseEvent e) {
closeButton.setImage(fCloseImageHot);
}
@Override
public void mouseExit(MouseEvent e) {
closeButton.setImage(fCloseImageNormal);
}
});
/* Outer composite to hold content controlls */
fOuterContentCircle = new Composite(outerCircle, SWT.NONE);
fOuterContentCircle.setLayout(LayoutUtils.createGridLayout(1, 0, 0));
fOuterContentCircle.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
fOuterContentCircle.setBackground(outerCircle.getBackground());
/* Middle composite to show a 1px black line around the content controlls */
Composite middleContentCircle = new Composite(fOuterContentCircle, SWT.NO_FOCUS);
middleContentCircle.setLayout(LayoutUtils.createGridLayout(1, 0, 0));
((GridLayout) middleContentCircle.getLayout()).marginTop = 1;
((GridLayout) middleContentCircle.getLayout()).marginBottom = 1;
middleContentCircle.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
middleContentCircle.setBackground(fNotifierColors.getBorder());
/* Inner composite containing the content controlls */
fInnerContentCircle = new Composite(middleContentCircle, SWT.NO_FOCUS);
fInnerContentCircle.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
fInnerContentCircle.setLayout(LayoutUtils.createGridLayout(4, 0, 5, 0, 0, false));
((GridLayout) fInnerContentCircle.getLayout()).marginLeft = 5;
((GridLayout) fInnerContentCircle.getLayout()).marginRight = 2;
fInnerContentCircle.addMouseTrackListener(fMouseTrackListner);
fInnerContentCircle.setBackground(fShell.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
/* Footer Area containing navigational controls */
final Composite footerCircle = new Composite(outerCircle, SWT.NO_FOCUS);
footerCircle.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
footerCircle.setBackgroundMode(SWT.INHERIT_FORCE);
footerCircle.setLayout(LayoutUtils.createGridLayout(3, 3, 0, 5, 3, false));
footerCircle.addMouseTrackListener(fMouseTrackListner);
footerCircle.addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
Rectangle clArea = footerCircle.getClientArea();
Image oldBgImage = fFooterBgImage;
fFooterBgImage = new Image(footerCircle.getDisplay(), clArea.width, clArea.height);