From 7d74db955056a7d1d41f89b54d702b80bdeed229 Mon Sep 17 00:00:00 2001 From: tkellner Date: Wed, 10 Apr 2013 19:10:34 +0000 Subject: Add page number label git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@174 174cde9d-5d70-4d2a-aa98-46368bc2aaf7 --- .../gui/composites/PositioningComposite.java | 29 ++++++++++++++++------ 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'pdf-over-gui/src/main/java') diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java index f4949c52..02cf6d48 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java @@ -40,6 +40,7 @@ import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.ScrollBar; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -66,6 +67,10 @@ public class PositioningComposite extends StateComposite { private Frame frame = null; + private Composite mainArea = null; + + private Label lblPage = null; + int currentPage = 0; int numPages = 0; @@ -96,20 +101,27 @@ public class PositioningComposite extends StateComposite { btnSign.setText("Sign"); FormData fd_btnSign = new FormData(); fd_btnSign.right = new FormAttachment(100); - fd_btnSign.bottom = new FormAttachment(100); + fd_btnSign.top = new FormAttachment(0); btnSign.setLayoutData(fd_btnSign); - Composite mainArea = new Composite(this, SWT.BORDER | SWT.EMBEDDED | SWT.V_SCROLL); + this.lblPage = new Label(bottomBar, SWT.CENTER); + FormData fd_lblPage = new FormData(); + fd_lblPage.left = new FormAttachment(0); + fd_lblPage.right = new FormAttachment(btnSign, 5); + fd_lblPage.bottom = new FormAttachment(100); + this.lblPage.setLayoutData(fd_lblPage); + + this.mainArea = new Composite(this, SWT.BORDER | SWT.EMBEDDED | SWT.V_SCROLL); FormData fd_mainArea = new FormData(); fd_mainArea.left = new FormAttachment(0); fd_mainArea.right = new FormAttachment(100); fd_mainArea.top = new FormAttachment(0); fd_mainArea.bottom = new FormAttachment(bottomBar, -5); - mainArea.setLayoutData(fd_mainArea); - this.scrollbar = mainArea.getVerticalBar(); + this.mainArea.setLayoutData(fd_mainArea); + this.scrollbar = this.mainArea.getVerticalBar(); - this.frame = SWT_AWT.new_Frame(mainArea); - this.addKeyListener(this.keyListener); + this.frame = SWT_AWT.new_Frame(this.mainArea); + this.mainArea.addKeyListener(this.keyListener); this.frame.addMouseWheelListener(this.mouseListener); this.scrollbar.addSelectionListener(this.selectionListener); requestFocus(); @@ -149,8 +161,8 @@ public class PositioningComposite extends StateComposite { */ private void requestFocus() { - this.frame.requestFocus(); - setFocus(); + this.frame.requestFocusInWindow(); + this.mainArea.setFocus(); } /** @@ -260,6 +272,7 @@ public class PositioningComposite extends StateComposite { PositioningComposite.this.scrollbar.setSelection(PositioningComposite.this.currentPage); } }); + this.lblPage.setText(String.format("Page %d of %d", page, this.numPages)); this.viewer.showPage(page); } -- cgit v1.2.3