|
Re: Add border to sourceviewer [message #522440 is a reply to message #521862] |
Mon, 22 March 2010 12:14   |
Eclipse User |
|
|
|
Hi Upkar,
According to SourceViewer's doc, the space to the left of the text viewer is
its annotation presentation area, and the space to its right is its overview
ruler. Are you providing implementations of either of these? If so then
this expains why these spaces are there, the viewer is composed of the
combination of the text editor along with these strips on each side.
In SourceViewer.createControl() I see the following:
protected void createControl(Composite parent, int styles) {
if (fVerticalRuler != null || fOverviewRuler != null) {
styles= (styles & ~SWT.BORDER);
fComposite= new Canvas(parent, SWT.NONE);
fComposite.setLayout(createLayout());
parent= fComposite;
}
super.createControl(parent, styles);
... <snip> ...
The super.createControl() invocation is what ultimately creates the viewer's
text editor, so if you provide an implementation for either the annotation
area or the overview ruler then SWT.BORDER is removed from the styles used
to create it. And since the only time to provide a style bit like
SWT.BORDER is when a control is initially created, I don't think there's a
way to do what you want, unless I'm making a wrong assumption somewhere here
(eg.- you aren't actually providing an implementation for the annotation
area or overview ruler)?
Grant
"Upkar Lidder" <ulidder@gmail.com> wrote in message
news:hnucse$rvl$1@build.eclipse.org...
> Hello,
>
> I am trying to create a custom sourceViewer widget that I can reuse in my
code. I need to add spell checking facility to it. To show the spell errors,
I want to use the sourceViewer. Everything works great. The problem I am
having is with the UI. I am unable to add SWT.BORDER to the sourceViewer. I
read in another thread that "if a vertical ruler is required then the
SourceViewer should be added to a Composite whose style bit is set to
SWT.BORDER". This works, but the widget does not look elegant. The border is
seems out of place ...
>
> http://i39.tinypic.com/ev6khs.jpg
>
>
>
> Is there a way to remove that extra space between the border and the
sourceViewer? I am using the following layout for the composite that
contains the sourceViewer.
>
> Composite composite = new Composite(parent, SWT.BORDER);
> composite.setLayout(new GridLayout());
> composite.setLayoutData(new GridData(GridData.FILL_BOTH));
>
> SourceViewerWithSpellCheck sourceViewer = new
SourceViewerWithSpellCheck(composite, style);
>
>
> I also tried
>
> sourceViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
> sourceViewer.getTextWidget().setLayoutData(new
GridData(GridData.FILL_BOTH));
>
> But, nothing changed.
> Thanks.
> Upkar.
>
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.03481 seconds