summaryrefslogtreecommitdiff
path: root/trunk/pdf-over-gui/src/main/java/at
diff options
context:
space:
mode:
authortkellner <tkellner@3a0b52a2-8410-0410-bc02-ff6273a87459>2012-10-31 16:36:38 +0000
committertkellner <tkellner@3a0b52a2-8410-0410-bc02-ff6273a87459>2012-10-31 16:36:38 +0000
commitc9020e95969af213252555ebfcb77c202e25072a (patch)
treea965cc1ff17f9098c25491b257dde6c03d8eb244 /trunk/pdf-over-gui/src/main/java/at
parent48e00df6935e61ed32767626084490a920dc0188 (diff)
downloadpdf-over-c9020e95969af213252555ebfcb77c202e25072a.tar.gz
pdf-over-c9020e95969af213252555ebfcb77c202e25072a.tar.bz2
pdf-over-c9020e95969af213252555ebfcb77c202e25072a.zip
Add scrollbar to pdf preview
git-svn-id: https://svn.iaik.tugraz.at/svn/egiz/prj/current/12PDF-OVER-4.0@12700 3a0b52a2-8410-0410-bc02-ff6273a87459
Diffstat (limited to 'trunk/pdf-over-gui/src/main/java/at')
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java30
1 files changed, 27 insertions, 3 deletions
diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java
index 7d461772..9528dd1e 100644
--- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java
+++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java
@@ -31,7 +31,12 @@ import org.eclipse.swt.awt.SWT_AWT;
import org.eclipse.swt.events.KeyAdapter;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.ScrollBar;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -57,12 +62,14 @@ public class PositioningComposite extends StateComposite {
private Frame frame = null;
- int currentPage;
+ int currentPage = 0;
- int numPages;
+ int numPages = 0;
private SignaturePosition position = null;
+ ScrollBar scrollbar = null;
+
/**
* Set the PDF Document to display
* @param document document to display
@@ -84,6 +91,7 @@ public class PositioningComposite extends StateComposite {
else
this.viewer.setDocument(this.pdf);
this.numPages = this.pdf.getNumPages();
+ this.scrollbar.setValues(1, 1, this.numPages + 1, 1, 1, 1);
showPage(this.numPages);
}
@@ -94,11 +102,14 @@ public class PositioningComposite extends StateComposite {
* @param state
*/
public PositioningComposite(Composite parent, int style, State state) {
- super(parent, style | SWT.EMBEDDED, state);
+ super(parent, style | SWT.EMBEDDED | SWT.V_SCROLL, state);
//this.setLayout(null);
+ this.setBounds(0, 0, 10, 10);
+ this.scrollbar = this.getVerticalBar();
this.frame = SWT_AWT.new_Frame(this);
this.addKeyListener(this.keyListener);
this.frame.addMouseWheelListener(this.mouseListener);
+ this.scrollbar.addSelectionListener(this.selectionListener);
}
private KeyListener keyListener = new KeyAdapter() {
@@ -158,8 +169,21 @@ public class PositioningComposite extends StateComposite {
}
};
+ private SelectionListener selectionListener = new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ PositioningComposite.this.showPage(PositioningComposite.this.scrollbar.getSelection());
+ }
+ };
+
void showPage(int page) {
this.currentPage = page;
+ Display.getDefault().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ PositioningComposite.this.scrollbar.setSelection(PositioningComposite.this.currentPage);
+ }
+ });
this.viewer.showPage(page);
}