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 ...

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.

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.
>
>

Thanks for your response. I see your logic and will try and look through the swt code in future myself .
I am using the overview ruler to display the spelling mistakes in the text. I however don't need the annotation ruler on the left. I found a method to turn off the annotation ruler.
sourceViewer.showAnnotations(false);

The widget now looks like ...

It now looks more like the other widgets on the dialog. That is exactly what I want.