summaryrefslogtreecommitdiff
path: root/trunk/pdf-over-gui/src/main/java/at
diff options
context:
space:
mode:
authortkellner <tkellner@3a0b52a2-8410-0410-bc02-ff6273a87459>2012-08-24 17:06:16 +0000
committertkellner <tkellner@3a0b52a2-8410-0410-bc02-ff6273a87459>2012-08-24 17:06:16 +0000
commit9ebf57b69c7caefd80db2184a90cabe5ba56893c (patch)
tree6a0b2686cb3256103111a1ef4cd2da3496eaea7f /trunk/pdf-over-gui/src/main/java/at
parent10de5d4e81aec570993762979a6c0017752c2f21 (diff)
downloadpdf-over-9ebf57b69c7caefd80db2184a90cabe5ba56893c.tar.gz
pdf-over-9ebf57b69c7caefd80db2184a90cabe5ba56893c.tar.bz2
pdf-over-9ebf57b69c7caefd80db2184a90cabe5ba56893c.zip
Test dragging of signature canvas
git-svn-id: https://svn.iaik.tugraz.at/svn/egiz/prj/current/12PDF-OVER-4.0@12413 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.java55
1 files changed, 42 insertions, 13 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 0b50f0bb..f1f89d79 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
@@ -20,16 +20,18 @@ import java.io.File;
import java.io.IOException;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DragDetectEvent;
+import org.eclipse.swt.events.DragDetectListener;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseMoveListener;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.icepdf.core.exceptions.PDFException;
@@ -53,10 +55,15 @@ public class PositioningComposite extends StateComposite {
PDFViewerComposite viewer = null;
- private Canvas signature = null;
+ Canvas signature = null;
private SignaturePosition position = null;
+ boolean doDrag = false;
+
+ Point origMousePos = null;
+ Rectangle origSigPos = null;
+
/**
* Gets the position of the signature
* @return the SignaturePosition
@@ -93,10 +100,8 @@ public class PositioningComposite extends StateComposite {
void resizeViewer()
{
Rectangle clientArea = this.getClientArea();
- log.debug("Resizing to 0,0," + clientArea.width + "," + clientArea.height);
+ log.debug("Resizing to " + clientArea.width + "x" + clientArea.height);
this.viewer.setBounds(0, 0, clientArea.width, clientArea.height);
-
- this.signature.setBounds(clientArea.width - 250, clientArea.height -200, 150, 40);
}
/**
@@ -111,27 +116,52 @@ public class PositioningComposite extends StateComposite {
this.addListener(SWT.Resize, new Listener() {
@Override
- public void handleEvent(Event arg0) {
+ public void handleEvent(Event e) {
if (PositioningComposite.this.viewer != null)
resizeViewer();
}
});
this.signature = new Canvas(this, SWT.NO_BACKGROUND);
+ this.signature.setBounds(200, 200, 150, 40);
this.signature.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
- PositioningComposite.this.viewer.redraw();
+// PositioningComposite.this.viewer.redraw();
Rectangle r = ((Canvas) e.widget).getBounds();
- e.gc.setForeground(e.display.getSystemColor(SWT.COLOR_RED));
-// e.gc.setB
+ e.gc.setForeground(e.display.getSystemColor(SWT.COLOR_BLUE));
e.gc.drawFocus(5, 5, r.width - 10, r.height - 10);
e.gc.drawText("Position Signature", 10, 10);
}
});
+ this.signature.addDragDetectListener(new DragDetectListener() {
+ @Override
+ public void dragDetected(DragDetectEvent e) {
+ PositioningComposite.this.doDrag = true;
+ origMousePos = Display.getCurrent().getCursorLocation();
+ origSigPos = ((Canvas) e.widget).getBounds();
+ }
+ });
+ this.signature.addMouseMoveListener(new MouseMoveListener() {
+ @Override
+ public void mouseMove(MouseEvent e) {
+ if (PositioningComposite.this.doDrag)
+ {
+ Point newMousePos = Display.getCurrent().getCursorLocation();
+ int x = origSigPos.x + (newMousePos.x - origMousePos.x);
+ int y = origSigPos.y + (newMousePos.y - origMousePos.y);
+ PositioningComposite.this.signature.setBounds(x, y, origSigPos.width, origSigPos.height);
+ }
+ }
+ });
this.signature.addMouseListener(new MouseAdapter() {
@Override
- public void mouseDown(MouseEvent e) {
+ public void mouseUp(MouseEvent e) {
+ if (PositioningComposite.this.doDrag)
+ {
+ PositioningComposite.this.doDrag = false;
+ return;
+ }
// TODO: FIX to get real position
PositioningComposite.this.setPosition(new SignaturePosition()); // Setting auto position for testing
PositioningComposite.this.state.updateStateMachine();
@@ -149,7 +179,6 @@ public class PositioningComposite extends StateComposite {
*/
@Override
public void doLayout() {
-
this.layout(true, true);
}
}