diff options
author | tkellner <tkellner@3a0b52a2-8410-0410-bc02-ff6273a87459> | 2012-10-01 08:30:41 +0000 |
---|---|---|
committer | tkellner <tkellner@3a0b52a2-8410-0410-bc02-ff6273a87459> | 2012-10-01 08:30:41 +0000 |
commit | 5ef8c7dd57907a9905760dbe2084e71b5750f610 (patch) | |
tree | 2099bf0c93df9b20df7a0bf4414158017cbfaf21 /trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarButton.java | |
parent | 5d98e826b1f6ee5e1f96e59445ced9cd750172b2 (diff) | |
download | pdf-over-5ef8c7dd57907a9905760dbe2084e71b5750f610.tar.gz pdf-over-5ef8c7dd57907a9905760dbe2084e71b5750f610.tar.bz2 pdf-over-5ef8c7dd57907a9905760dbe2084e71b5750f610.zip |
Minor GUI changes to MainBar Buttons
git-svn-id: https://svn.iaik.tugraz.at/svn/egiz/prj/current/12PDF-OVER-4.0@12537 3a0b52a2-8410-0410-bc02-ff6273a87459
Diffstat (limited to 'trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarButton.java')
-rw-r--r-- | trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarButton.java | 46 |
1 files changed, 43 insertions, 3 deletions
diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarButton.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarButton.java index 509780fb..37e4f85b 100644 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarButton.java +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarButton.java @@ -27,6 +27,7 @@ import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Cursor; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.graphics.Region; import org.eclipse.swt.widgets.Canvas; import org.eclipse.swt.widgets.Composite; @@ -49,12 +50,12 @@ public abstract class MainBarButton extends Canvas { @Override public void paintControl(PaintEvent e) { - MainBarButton.this.paintButton(e); + MainBarButton.this.paintControl(e); } }); final Cursor hand = new Cursor(this.getDisplay(), SWT.CURSOR_HAND); - + this.addListener(SWT.Resize, new Listener() { @Override @@ -120,6 +121,7 @@ public abstract class MainBarButton extends Canvas { * the active state */ public void setActive(boolean active) { + this.active = active; if (this.active) { this.setBackground(this.activeBackground); @@ -158,15 +160,52 @@ public abstract class MainBarButton extends Canvas { private static final Logger log = LoggerFactory .getLogger(MainBarButton.class); + protected void paintBackground(PaintEvent e) { + + Point size = this.getSize(); + int height = size.y - 2; + + int width = size.x; + + int factor = 4; + + // TOP + e.gc.fillGradientRectangle(0, 0, width, factor, true); + + // BOTTOM + e.gc.fillGradientRectangle(0, height, width, -1 * (factor), + true); + + // LEFT + //e.gc.fillGradientRectangle(0, 0, factor, height, false); + + // RIGTH + //e.gc.fillGradientRectangle(width, 0, -1 * (width / factor), height, + // false); + + } + + private void paintControl(PaintEvent e) { + this.paintBackground(e); + this.paintButton(e); + this.paintBorderAndText(e); + } + + protected void paintButton(PaintEvent e) { + // could be overwritten by subclasses + } + /** * @param e */ - protected void paintButton(PaintEvent e) { + protected void paintBorderAndText(PaintEvent e) { Point size = this.getSize(); int height = size.y - 2; int width = size.x; + // e.gc.fillGradientRectangle(0, 1, width, height / 4, true); + if (this.image == null) { int textlen = 0; @@ -184,6 +223,7 @@ public abstract class MainBarButton extends Canvas { .scaledTo(height, height)); e.gc.drawImage(tmp, imgx, 0); } + } /** |