using Rulers [message #216294] |
Tue, 16 May 2006 20:06  |
Eclipse User |
|
|
|
Hi there,
I was wondering if there are any sample apps that demonstrate the use of GEF
rulers.
I've hooked them up using the RulerComposite and RulerProvider, however it
seems very limited in what can be customized. Maybe I'm missing something,
but most implementation methods or classes are private.
Ideally I would like to be able to enh or modify rulers to make them
comparable to the rulers in Office products.
At the very least I'd like to be able to prevent guidelines from being added
to the rulers (ie clicking on the ruler should not show a guideline).
Thanks
Damian
|
|
|
|
Re: using Rulers [message #216899 is a reply to message #216294] |
Fri, 26 May 2006 15:57  |
Eclipse User |
|
|
|
Damian wrote:
> Hi there,
>
> I was wondering if there are any sample apps that demonstrate the use of GEF
> rulers.
>
> I've hooked them up using the RulerComposite and RulerProvider, however it
> seems very limited in what can be customized. Maybe I'm missing something,
> but most implementation methods or classes are private.
>
> Ideally I would like to be able to enh or modify rulers to make them
> comparable to the rulers in Office products.
> At the very least I'd like to be able to prevent guidelines from being added
> to the rulers (ie clicking on the ruler should not show a guideline).
I ended up writing my own simpler ruler implementation using just
Draw2D. There's really no way (as I can see) that one can significantly
customize the existing GEF ruler implementation without accessing and
extending internal classes.
Moreover, the GEF implementation of the rulers use GEF. That is, you
end up with three GraphicalViewers -- one for each ruler and the main
viewer for your own GEF canvas. Unless you really need the "edit"
capabilities of GEF for the rulers, you can just as easily draw them
using draw2D. The trickiest part is implementing the scroll bar
listeners. Here's an example:
class ScrollListener implements Listener {
ScrollBar bar;
FigureCanvas canvas; // this is the RULER canvas
Composite c; // this is your center composite
// GEF viewer or otherwise
boolean h = false;
public ScrollListener(FigureCanvas fc,
Composite comp,boolean horizontal){
h = horizontal;
canvas = fc;
c = comp;
bar = h? c.getHorizontalBar() : c.getVerticalBar();
}
public void handleEvent(Event event) {
int s = bar.getSelection();
// account for the trim of the scroll bars
if(!h && c.getHorizontalBar() != null &&
c.getHorizontalBar().isVisible()){
s -= c.getHorizontalBar().getSize().y;
}
// scroll the ruler canvas
if(h)
canvas.scrollToX(s);
else
canvas.scrollToY(s);
}
}
jaaron
|
|
|
Powered by
FUDForum. Page generated in 0.07873 seconds