Home » Eclipse Projects » GEF » Draw2d and modifying default Canvas scrolling
Draw2d and modifying default Canvas scrolling [message #186732] |
Wed, 06 July 2005 17:54  |
Eclipse User |
|
|
|
I am creating a Table and utilizing a Canvas, not a ScrollPane, to
handle scrolling. This scrolls all content, header and all. What would
be the correct way to modify the scrolling behavior to allow for my
header to stay in place when scrolling occurs? I still don't have my
head around the whole process and if someone could point me in the right
direction I'd appreciate it.
Thanks,
Brad
|
|
| | | | |
Re: Draw2d and modifying default Canvas scrolling [message #187003 is a reply to message #186928] |
Thu, 07 July 2005 21:54   |
Eclipse User |
|
|
|
ok, if you use border to draw the column header , if user want to resize the
column with mouse, how to implement.
I think aother way to implement this table:
you can use layout manager like borderlayout. and fit the column header
to the top(fit the row header to the left),and center fit the viewport.
my idea<S> .
"Brad Reynolds" <bradleyjames@gmail.com> wrote in message
news:dajh88$otq$2@news.eclipse.org...
> Can you elaborate on what I might run into for mouse events? Is it just
> that it's because my header is in the border or is it that mouse events
> overall are difficult to handle in draw2d?
>
> gao wrote:
>> If you use the border draw the header, It is difficulty to catch the
>> mouse event.
>>
>> I think you should create two composite. the example see the logic ruler.
>>
>> "Randy Hudson" <none@us.ibm.com> wrote in message
>> news:dai2h9$2q1$1@news.eclipse.org...
>>
>>>Use a FigureCanvas with a viewport. The Viewport's border does not
>>>scroll. You could use the border. Or, you could create a viewport which
>>>support more than a single child. But this would be tricky because of
>>>coordinate systems. An easy way might be to create a viewport which
>>>wrappers a default viewport. The wrapper would override layout and place
>>>a header figure and the real viewport.
>>>
>>>"Brad Reynolds" <bradleyjames@gmail.com> wrote in message
>>>news:dahjtr$mc0$1@news.eclipse.org...
>>>
>>>>I am creating a Table and utilizing a Canvas, not a ScrollPane, to
>>>>handle scrolling. This scrolls all content, header and all. What would
>>>>be the correct way to modify the scrolling behavior to allow for my
>>>>header to stay in place when scrolling occurs? I still don't have my
>>>>head around the whole process and if someone could point me in the right
>>>>direction I'd appreciate it.
>>>>
>>>>Thanks,
>>>>Brad
>>>
>>>
>>
|
|
|
Re: Draw2d and modifying default Canvas scrolling [message #187084 is a reply to message #187003] |
Fri, 08 July 2005 08:42   |
Eclipse User |
|
|
|
The reason I asked about mouse events is that I haven't done anything in
draw2d before attempting this so I haven't yet dealt with mouse
events. If I can't receive them when setting something as the border
it's news to me so thank you for that information.
I'll give border layout a shot but my question is how will this behave
when scrolling? This has been my biggest hangup so far with trying to
implement this using draw2d. It seems like whenever scrolling it's
wanting to scroll all figures on the Canvas and not just certain
children. I'm wanting to stick with the native scroll bars so that I
get the native bitblitting and well. I currently have it implemented
with multiple canvases and when scrolling I sync up the 2 canvases.
It's working so far with a header and body. I still need to attempt to
implement a third canvas for the locked columns. I might take a look at
the GEF table to see how this was implemented.
gao wrote:
> ok, if you use border to draw the column header , if user want to resize the
> column with mouse, how to implement.
>
>
> I think aother way to implement this table:
> you can use layout manager like borderlayout. and fit the column header
> to the top(fit the row header to the left),and center fit the viewport.
>
> my idea<S> .
>
>
> "Brad Reynolds" <bradleyjames@gmail.com> wrote in message
> news:dajh88$otq$2@news.eclipse.org...
>
>>Can you elaborate on what I might run into for mouse events? Is it just
>>that it's because my header is in the border or is it that mouse events
>>overall are difficult to handle in draw2d?
>>
>>gao wrote:
>>
>>>If you use the border draw the header, It is difficulty to catch the
>>>mouse event.
>>>
>>>I think you should create two composite. the example see the logic ruler.
>>>
>>>"Randy Hudson" <none@us.ibm.com> wrote in message
>>>news:dai2h9$2q1$1@news.eclipse.org...
>>>
>>>
>>>>Use a FigureCanvas with a viewport. The Viewport's border does not
>>>>scroll. You could use the border. Or, you could create a viewport which
>>>>support more than a single child. But this would be tricky because of
>>>>coordinate systems. An easy way might be to create a viewport which
>>>>wrappers a default viewport. The wrapper would override layout and place
>>>>a header figure and the real viewport.
>>>>
>>>>"Brad Reynolds" <bradleyjames@gmail.com> wrote in message
>>>>news:dahjtr$mc0$1@news.eclipse.org...
>>>>
>>>>
>>>>>I am creating a Table and utilizing a Canvas, not a ScrollPane, to
>>>>>handle scrolling. This scrolls all content, header and all. What would
>>>>>be the correct way to modify the scrolling behavior to allow for my
>>>>>header to stay in place when scrolling occurs? I still don't have my
>>>>>head around the whole process and if someone could point me in the right
>>>>>direction I'd appreciate it.
>>>>>
>>>>>Thanks,
>>>>>Brad
>>>>
>>>>
>
|
|
| | | | | | | | |
Re: Draw2d and modifying default Canvas scrolling [message #187410 is a reply to message #187350] |
Tue, 12 July 2005 10:07   |
Eclipse User |
|
|
|
This is a multi-part message in MIME format.
--------------030402080809090601080504
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Attached is a quick test with a Viewport as the body. It just has a
header and body for testing purposes. It's a little jumpy. Is there a
better way of going about constraining the header and body to the
appropriate locations?
Randy Hudson wrote:
> Stop dragging but with the button still pressed.
> "Brad Reynolds" <bradleyjames@gmail.com> wrote in message
> news:dauqqk$a1i$1@news.eclipse.org...
>
>>It was 10.3. What do you mean when you say "pause the mouse"?
>>
>>Randy Hudson wrote:
>>
>>>>wasn't ideal and was hoping to avoid it if possible. The other
>>>>interesting thing I saw was that on OS X with 2 canvases the second
>>>>header wouldn't update until mouse up of the scrollbar on the body
>>>>canvas. This was something I wanted to dig into to see if I had an error
>>>>in my code or if it was maybe a SWT thing. I haven't gotten back to that
>>>>so I can't confirm it.
>>>
>>>
>>>Which version of Mac OSX? We have a general problem that
>>>ascynExec(runnable) does not get run while the mouse button is down.
>>>But, if you pause the mouse it usually runs. Scrollbar dragging could be
>>>worse than just mouse dragging on the canvas.
>>>
>
>
--------------030402080809090601080504
Content-Type: text/plain;
name="ViewportsTest.java"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="ViewportsTest.java"
package com.cerner.client.components.custom.table;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.FigureCanvas;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.RangeModel;
import org.eclipse.draw2d.ToolbarLayout;
import org.eclipse.draw2d.Viewport;
import org.eclipse.draw2d.XYLayout;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class ViewportsTest {
public void run() {
Display display = new Display();
Shell shell = new Shell(display);
GridLayout layout = new GridLayout();
shell.setLayout(layout);
GridData data = new GridData(GridData.FILL_BOTH);
final FigureCanvas canvas = new FigureCanvas(shell);
canvas.setLayoutData(data);
// Create a figure that changes the preferred size to create scrollbars
// properly on the Canvas.
final Contents contents = new Contents();
contents.setLayoutManager(new XYLayout());
canvas.setContents(contents);
final IFigure header = new Figure();
header.setLayoutManager(new ToolbarLayout());
header.add(new Label("header")); //$NON-NLS-1$
contents.addHeader(header);
final Viewport body = new Viewport();
IFigure bodyContents = new Figure();
bodyContents.setLayoutManager(new ToolbarLayout());
body.setContents(bodyContents);
// Add items to the body.
for (int i = 0; i < 1000; i++) {
bodyContents.add(new Label("body " + i)); //$NON-NLS-1$
}
contents.addBody(body);
// Set initial constraints for header and body, values are hard coded for testing purposes.
contents.setConstraint(header, new Rectangle(0, 0, -1, -1));
contents.setConstraint(body, new Rectangle(0, 50, -1, 500));
// Add a change listener for the vertical scrolling of the main
// viewport.
final Viewport mainvp = canvas.getViewport();
mainvp.getVerticalRangeModel().addPropertyChangeListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
RangeModel rangeModel = (RangeModel) event.getSource();
// Anchor the header to the top of the viewport.
Point location = mainvp.getViewLocation();
contents.setConstraint(header, new Rectangle(location.x, location.y, -1, -1));
// Position body below the header.
contents.setConstraint(body, new Rectangle(location.x, location.y + 50, -1, 500));
body.setVerticalLocation(rangeModel.getValue());
}
});
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
public static void main(String[] args) {
new ViewportsTest().run();
}
/**
* Returns a preferred size that is a body's perferred size.
*/
private class Contents extends Figure {
private IFigure body;
private IFigure header;
public void addHeader(IFigure header) {
super.add(header);
this.header = header;
}
public void addBody(IFigure body) {
super.add(body);
this.body = body;
}
public Dimension getPreferredSize(int wHint, int hHint) {
return body.getPreferredSize(wHint, hHint);
}
}
}
--------------030402080809090601080504--
|
|
| | | |
Re: Draw2d and modifying default Canvas scrolling [message #187516 is a reply to message #187410] |
Tue, 12 July 2005 17:33  |
Eclipse User |
|
|
|
Originally posted by: none.us.ibm.com
The problem you are seeing is related to FigureCanvas and the way it calls
scroll(int, int, int....)
The contents are being copied on top of the header.
"Brad Reynolds" <bradleyjames@gmail.com> wrote in message
news:db0iqg$c5n$1@news.eclipse.org...
> Attached is a quick test with a Viewport as the body. It just has a
> header and body for testing purposes. It's a little jumpy. Is there a
> better way of going about constraining the header and body to the
> appropriate locations?
>
>
> Randy Hudson wrote:
>> Stop dragging but with the button still pressed.
>> "Brad Reynolds" <bradleyjames@gmail.com> wrote in message
>> news:dauqqk$a1i$1@news.eclipse.org...
>>
>>>It was 10.3. What do you mean when you say "pause the mouse"?
>>>
>>>Randy Hudson wrote:
>>>
>>>>>wasn't ideal and was hoping to avoid it if possible. The other
>>>>>interesting thing I saw was that on OS X with 2 canvases the second
>>>>>header wouldn't update until mouse up of the scrollbar on the body
>>>>>canvas. This was something I wanted to dig into to see if I had an
>>>>>error
>>>>>in my code or if it was maybe a SWT thing. I haven't gotten back to
>>>>>that
>>>>>so I can't confirm it.
>>>>
>>>>
>>>>Which version of Mac OSX? We have a general problem that
>>>>ascynExec(runnable) does not get run while the mouse button is down.
>>>>But, if you pause the mouse it usually runs. Scrollbar dragging could be
>>>>worse than just mouse dragging on the canvas.
>>>>
>>
>>
>
>
------------------------------------------------------------ --------------------
> package com.cerner.client.components.custom.table;
>
> import java.beans.PropertyChangeEvent;
> import java.beans.PropertyChangeListener;
>
> import org.eclipse.draw2d.Figure;
> import org.eclipse.draw2d.FigureCanvas;
> import org.eclipse.draw2d.IFigure;
> import org.eclipse.draw2d.Label;
> import org.eclipse.draw2d.RangeModel;
> import org.eclipse.draw2d.ToolbarLayout;
> import org.eclipse.draw2d.Viewport;
> import org.eclipse.draw2d.XYLayout;
> import org.eclipse.draw2d.geometry.Dimension;
> import org.eclipse.draw2d.geometry.Point;
> import org.eclipse.draw2d.geometry.Rectangle;
> import org.eclipse.swt.layout.GridData;
> import org.eclipse.swt.layout.GridLayout;
> import org.eclipse.swt.widgets.Display;
> import org.eclipse.swt.widgets.Shell;
>
> public class ViewportsTest {
> public void run() {
> Display display = new Display();
> Shell shell = new Shell(display);
> GridLayout layout = new GridLayout();
> shell.setLayout(layout);
>
> GridData data = new GridData(GridData.FILL_BOTH);
> final FigureCanvas canvas = new FigureCanvas(shell);
> canvas.setLayoutData(data);
>
> // Create a figure that changes the preferred size to create scrollbars
> // properly on the Canvas.
> final Contents contents = new Contents();
> contents.setLayoutManager(new XYLayout());
> canvas.setContents(contents);
>
> final IFigure header = new Figure();
> header.setLayoutManager(new ToolbarLayout());
> header.add(new Label("header")); //$NON-NLS-1$
> contents.addHeader(header);
>
> final Viewport body = new Viewport();
> IFigure bodyContents = new Figure();
> bodyContents.setLayoutManager(new ToolbarLayout());
> body.setContents(bodyContents);
>
> // Add items to the body.
> for (int i = 0; i < 1000; i++) {
> bodyContents.add(new Label("body " + i)); //$NON-NLS-1$
> }
>
> contents.addBody(body);
>
> // Set initial constraints for header and body, values are hard coded for
> testing purposes.
> contents.setConstraint(header, new Rectangle(0, 0, -1, -1));
> contents.setConstraint(body, new Rectangle(0, 50, -1, 500));
>
> // Add a change listener for the vertical scrolling of the main
> // viewport.
> final Viewport mainvp = canvas.getViewport();
> mainvp.getVerticalRangeModel().addPropertyChangeListener(new
> PropertyChangeListener() {
> public void propertyChange(PropertyChangeEvent event) {
> RangeModel rangeModel = (RangeModel) event.getSource();
>
> // Anchor the header to the top of the viewport.
> Point location = mainvp.getViewLocation();
> contents.setConstraint(header, new Rectangle(location.x,
> location.y, -1, -1));
>
> // Position body below the header.
> contents.setConstraint(body, new Rectangle(location.x, location.y +
> 50, -1, 500));
> body.setVerticalLocation(rangeModel.getValue());
> }
> });
>
> shell.open();
> while (!shell.isDisposed()) {
> if (!display.readAndDispatch())
> display.sleep();
> }
> display.dispose();
> }
>
> public static void main(String[] args) {
> new ViewportsTest().run();
> }
>
> /**
> * Returns a preferred size that is a body's perferred size.
> */
> private class Contents extends Figure {
> private IFigure body;
> private IFigure header;
>
> public void addHeader(IFigure header) {
> super.add(header);
>
> this.header = header;
> }
>
> public void addBody(IFigure body) {
> super.add(body);
>
> this.body = body;
> }
>
> public Dimension getPreferredSize(int wHint, int hHint) {
> return body.getPreferredSize(wHint, hHint);
> }
> }
> }
>
|
|
|
Goto Forum:
Current Time: Thu Aug 28 01:05:36 EDT 2025
Powered by FUDForum. Page generated in 0.07239 seconds
|