From 592c52ae8a2bb64697a1ba58151bd4e46e2c8f27 Mon Sep 17 00:00:00 2001 From: Tobias Kellner Date: Mon, 12 Nov 2012 18:55:00 +0100 Subject: Fix main bar button text positioning --- .../at/asit/pdfover/gui/controls/MainBarButton.java | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 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 95935c89..484f5e28 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 @@ -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); -- cgit v1.2.3