summaryrefslogtreecommitdiff
path: root/pdf-over-gui/src/main/java/at/asit/pdfover/gui
diff options
context:
space:
mode:
authortkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7>2013-04-10 19:21:20 +0000
committertkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7>2013-04-10 19:21:20 +0000
commitfce62342b9c5611b37e95afe3bfde3133bcb8c37 (patch)
tree2ffdf604140f787c9f40a0de7ae28acf533c9f87 /pdf-over-gui/src/main/java/at/asit/pdfover/gui
parentd278894566013fa4dabed5b317ad6e1f20fb161f (diff)
downloadmocca-fce62342b9c5611b37e95afe3bfde3133bcb8c37.tar.gz
mocca-fce62342b9c5611b37e95afe3bfde3133bcb8c37.tar.bz2
mocca-fce62342b9c5611b37e95afe3bfde3133bcb8c37.zip
Fix main bar button text positioning
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@277 174cde9d-5d70-4d2a-aa98-46368bc2aaf7
Diffstat (limited to 'pdf-over-gui/src/main/java/at/asit/pdfover/gui')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarButton.java18
1 files changed, 4 insertions, 14 deletions
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 95935c89..484f5e28 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
@@ -306,12 +306,6 @@ public abstract class MainBarButton extends Canvas {
// e.gc.fillGradientRectangle(0, 1, width, height / 4, true);
if (this.image == null) {
- int textlen = 0;
-
- if (this.getText() != null) {
- textlen = this.getText().length();
- }
-
Color current = e.gc.getForeground();
if(this.getActive() && this.isEnabled()) {
@@ -326,17 +320,13 @@ public abstract class MainBarButton extends Canvas {
this.getTextsize(),
e.gc.getFont().getFontData()[0].getStyle());
+ String text = this.getText();
e.gc.setFont(font);
-
- int texty = (height - e.gc.getFontMetrics().getHeight()) / 2;
-
- int textx = (width - e.gc.getFontMetrics().getAverageCharWidth()
- * textlen) / 2;
-
+ size = e.gc.stringExtent(text);
+ int texty = (height - size.y) / 2;
+ int textx = (width - size.x) / 2;
textx = this.changeTextPosition(textx);
-
e.gc.drawText(this.getText(), textx, texty, true);
-
font.dispose();
e.gc.setForeground(current);