Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 54517 Details for
Bug 165169
Scrollbar issues on image attachment preview
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch
Clipboard-attachment (text/plain), 6.08 KB, created by
Willian Mitsuda
on 2006-11-25 16:25:41 EST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Willian Mitsuda
Created:
2006-11-25 16:25:41 EST
Size:
6.08 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.mylar.tasks.ui >Index: src/org/eclipse/mylar/internal/tasks/ui/wizards/PreviewAttachmentPage.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.tasks.ui/src/org/eclipse/mylar/internal/tasks/ui/wizards/PreviewAttachmentPage.java,v >retrieving revision 1.2 >diff -u -r1.2 PreviewAttachmentPage.java >--- src/org/eclipse/mylar/internal/tasks/ui/wizards/PreviewAttachmentPage.java 3 Aug 2006 15:57:01 -0000 1.2 >+++ src/org/eclipse/mylar/internal/tasks/ui/wizards/PreviewAttachmentPage.java 25 Nov 2006 21:24:11 -0000 >@@ -15,20 +15,23 @@ > import java.io.IOException; > import java.util.HashMap; > >+import org.eclipse.jface.layout.GridDataFactory; >+import org.eclipse.jface.layout.GridLayoutFactory; > import org.eclipse.jface.wizard.WizardPage; > import org.eclipse.mylar.tasks.core.LocalAttachment; > import org.eclipse.swt.SWT; >-import org.eclipse.swt.graphics.GC; >+import org.eclipse.swt.custom.ScrolledComposite; >+import org.eclipse.swt.events.ControlAdapter; >+import org.eclipse.swt.events.ControlEvent; >+import org.eclipse.swt.events.PaintEvent; >+import org.eclipse.swt.events.PaintListener; > import org.eclipse.swt.graphics.Image; >-import org.eclipse.swt.graphics.Point; > import org.eclipse.swt.graphics.Rectangle; > import org.eclipse.swt.layout.GridData; > import org.eclipse.swt.layout.GridLayout; > import org.eclipse.swt.widgets.Canvas; > import org.eclipse.swt.widgets.Composite; >-import org.eclipse.swt.widgets.Event; > import org.eclipse.swt.widgets.Label; >-import org.eclipse.swt.widgets.Listener; > import org.eclipse.swt.widgets.ScrollBar; > import org.eclipse.swt.widgets.Text; > >@@ -125,73 +128,47 @@ > > private void createImagePreview(Composite composite, LocalAttachment attachment) { > final Image image = new Image(composite.getDisplay(), attachment.getFilePath()); >- final Canvas canvas = new Canvas(composite, SWT.NO_BACKGROUND | SWT.NO_REDRAW_RESIZE | SWT.V_SCROLL >- | SWT.H_SCROLL | SWT.BORDER); >- canvas.setLayoutData(new GridData(GridData.FILL_BOTH)); >- >- // Adapted from snippit 48 >- // http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet48.java?rev=HEAD >- final Point origin = new Point(0, 0); >- 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(); >- canvas.scroll(destX, 0, 0, 0, rect.width, rect.height, false); >- origin.x = -hSelection; >- } >- }); >- 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(); >- canvas.scroll(0, destY, 0, 0, rect.width, rect.height, false); >- origin.y = -vSelection; >- } >- }); >- canvas.addListener(SWT.Resize, new Listener() { >- public void handleEvent(Event e) { >- Rectangle rect = image.getBounds(); >- Rectangle client = canvas.getClientArea(); >- hBar.setMaximum(rect.width); >- vBar.setMaximum(rect.height); >- hBar.setThumb(Math.min(rect.width, client.width)); >- vBar.setThumb(Math.min(rect.height, client.height)); >- int hPage = rect.width - client.width; >- int vPage = rect.height - client.height; >- int hSelection = hBar.getSelection(); >- int vSelection = vBar.getSelection(); >- if (hSelection >= hPage) { >- if (hPage <= 0) >- hSelection = 0; >- origin.x = -hSelection; >- } >- if (vSelection >= vPage) { >- if (vPage <= 0) >- vSelection = 0; >- origin.y = -vSelection; >- } >- canvas.redraw(); >+ final ScrolledComposite scrolledComposite = new ScrolledComposite(composite, SWT.H_SCROLL | SWT.V_SCROLL >+ | SWT.BORDER); >+ scrolledComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); >+ scrolledComposite.setExpandHorizontal(true); >+ scrolledComposite.setExpandVertical(true); >+ >+ Composite canvasComposite = new Composite(scrolledComposite, SWT.NONE); >+ canvasComposite.setLayout(GridLayoutFactory.fillDefaults().create()); >+ Canvas canvas = new Canvas(canvasComposite, SWT.NONE); >+ final Rectangle imgSize = image.getBounds(); >+ canvas.setLayoutData(GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).grab(true, true).hint( >+ imgSize.width, imgSize.height).create()); >+ canvas.addPaintListener(new PaintListener() { >+ >+ public void paintControl(PaintEvent e) { >+ e.gc.drawImage(image, 0, 0); > } >+ > }); >- 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 = canvas.getClientArea(); >- int marginWidth = client.width - rect.width; >- if (marginWidth > 0) { >- gc.fillRectangle(rect.width, 0, marginWidth, client.height); >- } >- int marginHeight = client.height - rect.height; >- if (marginHeight > 0) { >- gc.fillRectangle(0, rect.height, client.width, marginHeight); >- } >+ canvas.setSize(imgSize.width, imgSize.height); >+ scrolledComposite.setMinSize(imgSize.width, imgSize.height); >+ scrolledComposite.setContent(canvasComposite); >+ scrolledComposite.addControlListener(new ControlAdapter() { >+ >+ @Override >+ public void controlResized(ControlEvent e) { >+ Rectangle clientArea = scrolledComposite.getClientArea(); >+ >+ ScrollBar hBar = scrolledComposite.getHorizontalBar(); >+ hBar.setMinimum(1); >+ hBar.setMaximum(clientArea.width - imgSize.width); >+ hBar.setPageIncrement(hBar.getThumb()); >+ hBar.setIncrement(10); >+ >+ ScrollBar vBar = scrolledComposite.getVerticalBar(); >+ vBar.setMinimum(0); >+ vBar.setMaximum(clientArea.height - imgSize.height); >+ vBar.setPageIncrement(vBar.getThumb()); >+ vBar.setIncrement(10); > } >+ > }); > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 165169
: 54517 |
54518
|
54758
|
54759
|
56153
|
56154