Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Client Area of a scrolled composite
Client Area of a scrolled composite [message #446866] Fri, 03 December 2004 20:05 Go to next message
Phill Perryman is currently offline Phill PerrymanFriend
Messages: 214
Registered: July 2009
Senior Member
<br><font size=1 face="sans-serif">I am creating a view which contains two columns, the first column has a question in it and the second either a text, button(checkbox) or combo. As the questions can be 1, 2 or 3 lines long I am drawing the components in response to a selection changed event.</font>
<br>
<br><font size=1 face="sans-serif">I have the composite from the view into which I have placed a scrolled composite and into that a composite in which I paint the components.</font>
<br>
<br><font size=1 face="sans-serif">I use the get client area of the scroll are to decide how wide to make my composite, set its size and it appears.</font>
<br>
<br><font size=1 face="sans-serif">The problem I have is when my composite gets too long the scrolled composite turns on the sroll bars (as it should) but these cover up the edge of my composite as the getClientArea returns the size without the scrollbar present. </font>
<br>
<br><font size=1 face="sans-serif">How can I detect the scrollbar has appeared so I can redraw the componets a bit narrower.</font>
<br>
<br><font size=1 face="sans-serif">As a workaround at the moment I have got the sroll bar to always appear so the client area always returns the correct size.</font>
<br>
<br><font size=1 face="sans-serif">My first plug-in so bear with me if this is obvoius</font>
Re: Client Area of a scrolled composite [message #446868 is a reply to message #446866] Fri, 03 December 2004 21:38 Go to previous message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
ScrolledComposite.getClientArea does not include the scrollbars.

Here is a simple example that demonstrates this. Resize the shell and you
will always see the red rectangle, even when the scrollbars are present.

public static void main (String [] args) {
Display display = new Display ();
final Color red = display.getSystemColor(SWT.COLOR_RED);
Shell shell = new Shell (display);
shell.setLayout(new FillLayout());
final ScrolledComposite sc = new ScrolledComposite(shell, SWT.BORDER
| SWT.H_SCROLL | SWT.V_SCROLL);
final Composite c = new Composite(sc, SWT.NONE);
c.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
Rectangle r = sc.getClientArea();
Point origin = sc.getOrigin();
e.gc.setForeground(red);
e.gc.drawRectangle(origin.x+ 3, origin.y + 3,
r.width - 6, r.height - 6);
}
});
c.addControlListener(new ControlAdapter() {
public void controlMoved(ControlEvent e) {
c.redraw();
}
});
sc.addControlListener(new ControlAdapter() {
public void controlResized(ControlEvent e) {
c.redraw();
}
});
sc.setContent(c);
sc.setExpandHorizontal(true);
sc.setExpandVertical(true);
sc.setMinSize(300, 300);
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
<Phill_Perryman@Mitel.COM> wrote in message
news:coqgva$nmn$1@www.eclipse.org...

I am creating a view which contains two columns, the first column has a
question in it and the second either a text, button(checkbox) or combo. As
the questions can be 1, 2 or 3 lines long I am drawing the components in
response to a selection changed event.

I have the composite from the view into which I have placed a scrolled
composite and into that a composite in which I paint the components.

I use the get client area of the scroll are to decide how wide to make my
composite, set its size and it appears.

The problem I have is when my composite gets too long the scrolled composite
turns on the sroll bars (as it should) but these cover up the edge of my
composite as the getClientArea returns the size without the scrollbar
present.

How can I detect the scrollbar has appeared so I can redraw the componets a
bit narrower.

As a workaround at the moment I have got the sroll bar to always appear so
the client area always returns the correct size.

My first plug-in so bear with me if this is obvoius
Previous Topic:Widget layout
Next Topic:Is this the right place for ? about problems using java IDE?
Goto Forum:
  


Current Time: Fri Apr 19 07:18:56 GMT 2024

Powered by FUDForum. Page generated in 0.02258 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top