From e60e1df5284c93b25cf6f6a477b924850dffb9d5 Mon Sep 17 00:00:00 2001 From: tkellner Date: Wed, 10 Apr 2013 18:59:29 +0000 Subject: UI Improvements git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@69 174cde9d-5d70-4d2a-aa98-46368bc2aaf7 --- .../asit/pdfover/gui/controls/MainBarButton.java | 83 ++++++++++++++++++++-- .../pdfover/gui/controls/MainBarEndButton.java | 6 +- .../pdfover/gui/controls/MainBarMiddleButton.java | 2 +- .../gui/controls/MainBarRectangleButton.java | 2 +- .../pdfover/gui/controls/MainBarStartButton.java | 2 +- 5 files changed, 84 insertions(+), 11 deletions(-) (limited to 'pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls') diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarButton.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarButton.java index 45a8d230..d67ecfc3 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarButton.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarButton.java @@ -21,6 +21,7 @@ import org.eclipse.swt.events.PaintEvent; import org.eclipse.swt.events.PaintListener; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Cursor; +import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Region; @@ -65,7 +66,9 @@ public abstract class MainBarButton extends Canvas { this.inactiveBackground = new Color(getDisplay(), 0x4B, 0x95, 0x00); this.activeBackground = new Color(getDisplay(), 0x98, 0xF2, 0x3D); - + this.textColor = this.getForeground(); + this.borderColor = new Color(getDisplay(), 0x76, 0xC4, 0xC8); + this.textsize = 12; } private Color inactiveBackground = null; @@ -86,6 +89,53 @@ public abstract class MainBarButton extends Canvas { this.activeBackground = activeBackground; } + /** + * the text size + */ + protected int textsize = 12; + + /** + * @return the textsize + */ + public int getTextsize() { + return this.textsize; + } + + /** + * @param textsize the textsize to set + */ + public void setTextsize(int textsize) { + this.textsize = textsize; + } + + /** + * the used text color + */ + protected Color textColor = null; + + /** + * @param textColor the textColor to set + */ + public void setTextColor(Color textColor) { + this.textColor = textColor; + } + + /** + * @return the borderColor + */ + public Color getBorderColor() { + return this.borderColor; + } + + /** + * @param borderColor the borderColor to set + */ + public void setBorderColor(Color borderColor) { + this.borderColor = borderColor; + } + + private Color borderColor = null; + private Color activeBackground = null; private String text = ""; //$NON-NLS-1$ @@ -165,6 +215,7 @@ public abstract class MainBarButton extends Canvas { */ protected void paintBackground(PaintEvent e) { + /* Point size = this.getSize(); int height = size.y - 2; @@ -176,9 +227,8 @@ public abstract class MainBarButton extends Canvas { e.gc.fillGradientRectangle(0, 0, width, factor, true); // BOTTOM - e.gc.fillGradientRectangle(0, height, width, -1 * (factor), - true); - + e.gc.fillGradientRectangle(0, height, width, -1 * (factor), true); + */ // LEFT //e.gc.fillGradientRectangle(0, 0, factor, height, false); @@ -194,7 +244,15 @@ public abstract class MainBarButton extends Canvas { */ void paintControl(PaintEvent e) { this.paintBackground(e); + + Color current = e.gc.getForeground(); + + e.gc.setForeground(getBorderColor()); + this.paintButton(e); + + e.gc.setForeground(current); + this.paintText(e); } @@ -224,11 +282,26 @@ public abstract class MainBarButton extends Canvas { if (this.getText() != null) { textlen = this.getText().length(); } - + + Color current = e.gc.getForeground(); + + e.gc.setForeground(this.textColor); + + String font_name = e.gc.getFont().getFontData()[0].getName(); + + Font font = new Font(this.getDisplay(), font_name, this.getTextsize(), e.gc.getFont().getFontData()[0].getStyle() ); + + e.gc.setFont(font); + int texty = (height - e.gc.getFontMetrics().getHeight()) / 2; int textx = (width - e.gc.getFontMetrics().getAverageCharWidth() * textlen) / 2; + e.gc.drawText(this.getText(), textx, texty); + + font.dispose(); + + e.gc.setForeground(current); } else { int imgx = (width - height) / 2; Image tmp = new Image(getDisplay(), this.image.getImageData() diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarEndButton.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarEndButton.java index 923df73e..1b749883 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarEndButton.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarEndButton.java @@ -52,13 +52,13 @@ public class MainBarEndButton extends MainBarButton { @Override protected void paintButton(PaintEvent e) { Point size = this.getSize(); - int height = size.y - 2; + int height = size.y - 3; int split = 10; - int width = size.x; + int width = size.x - 1; e.gc.drawLine(0, 0, width, 0); - e.gc.drawLine(width, 0, width+split, (height) / 2); + e.gc.drawLine(width, 0, width, height); e.gc.drawLine(width, height, 0, height); e.gc.drawLine(0, height, 0+split, (height) / 2); e.gc.drawLine(0+split, (height) / 2, 0, 0); diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarMiddleButton.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarMiddleButton.java index 5e64826f..e6d469b6 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarMiddleButton.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarMiddleButton.java @@ -50,7 +50,7 @@ public class MainBarMiddleButton extends MainBarButton { Point size = this.getSize(); - int height = size.y - 2; + int height = size.y - 3; int split = 10; int width = size.x - split; diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarRectangleButton.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarRectangleButton.java index aff1fa7e..6f8b8340 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarRectangleButton.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarRectangleButton.java @@ -52,7 +52,7 @@ public class MainBarRectangleButton extends MainBarButton { Point size = this.getSize(); - int height = size.y - 2; + int height = size.y - 3; int width = size.x; diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarStartButton.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarStartButton.java index 8cdafefa..cbdfc05d 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarStartButton.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarStartButton.java @@ -50,7 +50,7 @@ public class MainBarStartButton extends MainBarButton { Point size = this.getSize(); - int height = size.y - 2; + int height = size.y - 3; int split = 10; int width = size.x - split; -- cgit v1.2.3