diff options
author | Veronika Irvine <veronika> | 2006-02-07 21:38:29 +0000 |
---|---|---|
committer | Veronika Irvine <veronika> | 2006-02-07 21:38:29 +0000 |
commit | c436d3b4e5daaddf64e5d60f86aa79a8285bb509 (patch) | |
tree | 78a4164ff6269f1acd03cc3738d24cc18ce7f920 | |
parent | 8893f517660270ca90d80d35c2c7eb9e8f50245a (diff) | |
download | eclipse.platform.swt-c436d3b4e5daaddf64e5d60f86aa79a8285bb509.tar.gz eclipse.platform.swt-c436d3b4e5daaddf64e5d60f86aa79a8285bb509.tar.xz eclipse.platform.swt-c436d3b4e5daaddf64e5d60f86aa79a8285bb509.zip |
*** empty log message ***
-rw-r--r-- | examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet48.java | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet48.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet48.java index cc1c53cb6d..036b88bac9 100644 --- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet48.java +++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet48.java @@ -18,15 +18,15 @@ package org.eclipse.swt.snippets; */ import org.eclipse.swt.*; import org.eclipse.swt.graphics.*; +import org.eclipse.swt.layout.*; import org.eclipse.swt.widgets.*; public class Snippet48 { public static void main (String [] args) { Display display = new Display (); - final Shell shell = new Shell (display, - SWT.SHELL_TRIM | SWT.NO_BACKGROUND | - SWT.NO_REDRAW_RESIZE | SWT.V_SCROLL | SWT.H_SCROLL); + Shell shell = new Shell (display); + shell.setLayout(new FillLayout()); Image originalImage = null; FileDialog dialog = new FileDialog (shell, SWT.OPEN); dialog.setText ("Open an image file or cancel"); @@ -46,30 +46,32 @@ public static void main (String [] args) { } final Image image = originalImage; final Point origin = new Point (0, 0); - final ScrollBar hBar = shell.getHorizontalBar (); + final Canvas canvas = new Canvas (shell, SWT.NO_BACKGROUND | + SWT.NO_REDRAW_RESIZE | SWT.V_SCROLL | SWT.H_SCROLL); + final ScrollBar hBar = canvas.getHorizontalBar (); hBar.addListener (SWT.Selection, new Listener () { public void handleEvent (Event e) { int hSelection = hBar.getSelection (); int destX = -hSelection - origin.x; Rectangle rect = image.getBounds (); - shell.scroll (destX, 0, 0, 0, rect.width, rect.height, false); + canvas.scroll (destX, 0, 0, 0, rect.width, rect.height, false); origin.x = -hSelection; } }); - final ScrollBar vBar = shell.getVerticalBar (); + final ScrollBar vBar = canvas.getVerticalBar (); vBar.addListener (SWT.Selection, new Listener () { public void handleEvent (Event e) { int vSelection = vBar.getSelection (); int destY = -vSelection - origin.y; Rectangle rect = image.getBounds (); - shell.scroll (0, destY, 0, 0, rect.width, rect.height, false); + canvas.scroll (0, destY, 0, 0, rect.width, rect.height, false); origin.y = -vSelection; } }); - shell.addListener (SWT.Resize, new Listener () { + canvas.addListener (SWT.Resize, new Listener () { public void handleEvent (Event e) { Rectangle rect = image.getBounds (); - Rectangle client = shell.getClientArea (); + Rectangle client = canvas.getClientArea (); hBar.setMaximum (rect.width); vBar.setMaximum (rect.height); hBar.setThumb (Math.min (rect.width, client.width)); @@ -86,15 +88,15 @@ public static void main (String [] args) { if (vPage <= 0) vSelection = 0; origin.y = -vSelection; } - shell.redraw (); + canvas.redraw (); } }); - shell.addListener (SWT.Paint, new Listener () { + canvas.addListener (SWT.Paint, new Listener () { public void handleEvent (Event e) { GC gc = e.gc; gc.drawImage (image, origin.x, origin.y); Rectangle rect = image.getBounds (); - Rectangle client = shell.getClientArea (); + Rectangle client = canvas.getClientArea (); int marginWidth = client.width - rect.width; if (marginWidth > 0) { gc.fillRectangle (rect.width, 0, marginWidth, client.height); |