summaryrefslogtreecommitdiff
path: root/trunk/pdf-over-gui
diff options
context:
space:
mode:
authorTobias Kellner <tobias.kellner@iaik.tugraz.at>2012-11-12 18:55:00 +0100
committerTobias Kellner <tobias.kellner@iaik.tugraz.at>2012-11-12 18:55:00 +0100
commit592c52ae8a2bb64697a1ba58151bd4e46e2c8f27 (patch)
tree19816ffb001947adb5e53a9214f6ad17bc0e6a5e /trunk/pdf-over-gui
parentb4e411cf2527adb3e5c6a7e21ca01e37f40199b0 (diff)
downloadpdf-over-592c52ae8a2bb64697a1ba58151bd4e46e2c8f27.tar.gz
pdf-over-592c52ae8a2bb64697a1ba58151bd4e46e2c8f27.tar.bz2
pdf-over-592c52ae8a2bb64697a1ba58151bd4e46e2c8f27.zip
Fix main bar button text positioning
Diffstat (limited to 'trunk/pdf-over-gui')
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarButton.java18
1 files 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);