Skip to main content



      Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Get the size of a view
Get the size of a view [message #446387] Wed, 24 November 2004 05:27 Go to next message
Eclipse UserFriend
Hi!

In a view i want to display a content, which might be larger than the
visible area of the view. I use a ScrolledComposite which has the method
setMinSize() where you can set the minimal Size at which Scrollbars
should be shown. The only way i see is to giveMinSize the dimension of
the view.

Is there some way to get the current dimension of a view?

Thanks in advance.

Kai

(I am using Eclipse 3.1 on W2k)
Re: Get the size of a view [message #446403 is a reply to message #446387] Wed, 24 November 2004 10:40 Go to previous messageGo to next message
Eclipse UserFriend
You should give setMinSize the preferred size of the contents of the
ScrolledComposite not the parent of teh ScrolledComposite. The View is the
parent.

See the example from the class javadoc for ScrolledComposite:

// set the minimum width and height of the scrolled content - method 2
final ScrolledComposite sc2 = new ScrolledComposite(shell, SWT.H_SCROLL |
SWT.V_SCROLL | SWT.BORDER);
sc2.setExpandHorizontal(true);
sc2.setExpandVertical(true);
final Composite c2 = new Composite(sc2, SWT.NONE);
sc2.setContent(c2);
c2.setBackground(blue);
layout = new GridLayout();
layout.numColumns = 4;
c2.setLayout(layout);
Button b2 = new Button (c2, SWT.PUSH);
b2.setText("first button");
sc2.setMinSize(c2.computeSize(SWT.DEFAULT, SWT.DEFAULT));


"Kai" <junkworld@gmx.de> wrote in message
news:co1nm7$3jr$1@www.eclipse.org...
> Hi!
>
> In a view i want to display a content, which might be larger than the
> visible area of the view. I use a ScrolledComposite which has the method
> setMinSize() where you can set the minimal Size at which Scrollbars should
> be shown. The only way i see is to giveMinSize the dimension of the view.
>
> Is there some way to get the current dimension of a view?
>
> Thanks in advance.
>
> Kai
>
> (I am using Eclipse 3.1 on W2k)
Re: Get the size of a view [message #446405 is a reply to message #446403] Wed, 24 November 2004 11:39 Go to previous messageGo to next message
Eclipse UserFriend
Thanks for your reply Veronika, but seems it doesn`t work correct in my
case. I am developing an eclipse plugin, my content is created
dymnamicly and after that, i want to decide if scrollbars are needed.
The composite which represents the content, includes other composites.

When i try to use something like

sc2.setMinSize(c2.computeSize(SWT.DEFAULT, SWT.DEFAULT));

the whole content is displayed, but now scrollbars are shown. I could
see my the content which is to large for the visible area, when resize
the view.

Is it possible that a view has a different behavior in this case then a
normal window?

If i use getClientArea() on a composite in my view, i get the visible
area of the view. I tried to use setSize on my ScrolledComposite and
then use setMinSize(), but i doesen't seems to work, too.

Any idea?





Veronika Irvine wrote:
> You should give setMinSize the preferred size of the contents of the
> ScrolledComposite not the parent of teh ScrolledComposite. The View is the
> parent.
>
> See the example from the class javadoc for ScrolledComposite:
>
> // set the minimum width and height of the scrolled content - method 2
> final ScrolledComposite sc2 = new ScrolledComposite(shell, SWT.H_SCROLL |
> SWT.V_SCROLL | SWT.BORDER);
> sc2.setExpandHorizontal(true);
> sc2.setExpandVertical(true);
> final Composite c2 = new Composite(sc2, SWT.NONE);
> sc2.setContent(c2);
> c2.setBackground(blue);
> layout = new GridLayout();
> layout.numColumns = 4;
> c2.setLayout(layout);
> Button b2 = new Button (c2, SWT.PUSH);
> b2.setText("first button");
> sc2.setMinSize(c2.computeSize(SWT.DEFAULT, SWT.DEFAULT));
>
>
> "Kai" <junkworld@gmx.de> wrote in message
> news:co1nm7$3jr$1@www.eclipse.org...
>
>>Hi!
>>
>>In a view i want to display a content, which might be larger than the
>>visible area of the view. I use a ScrolledComposite which has the method
>>setMinSize() where you can set the minimal Size at which Scrollbars should
>>be shown. The only way i see is to giveMinSize the dimension of the view.
>>
>>Is there some way to get the current dimension of a view?
>>
>>Thanks in advance.
>>
>>Kai
>>
>>(I am using Eclipse 3.1 on W2k)
>
>
>
Re: Get the size of a view [message #446414 is a reply to message #446405] Wed, 24 November 2004 13:02 Go to previous messageGo to next message
Eclipse UserFriend
Views work the same as any other SWT Composite. Please give a code example
showing your problem.

"Kai" <junkworld@gmx.de> wrote in message
news:co2dff$jv2$1@www.eclipse.org...
> Thanks for your reply Veronika, but seems it doesn`t work correct in my
> case. I am developing an eclipse plugin, my content is created dymnamicly
> and after that, i want to decide if scrollbars are needed. The composite
> which represents the content, includes other composites.
>
> When i try to use something like
>
> sc2.setMinSize(c2.computeSize(SWT.DEFAULT, SWT.DEFAULT));
>
> the whole content is displayed, but now scrollbars are shown. I could see
> my the content which is to large for the visible area, when resize the
> view.
>
> Is it possible that a view has a different behavior in this case then a
> normal window?
>
> If i use getClientArea() on a composite in my view, i get the visible area
> of the view. I tried to use setSize on my ScrolledComposite and then use
> setMinSize(), but i doesen't seems to work, too.
>
> Any idea?
>
>
>
>
>
> Veronika Irvine wrote:
>> You should give setMinSize the preferred size of the contents of the
>> ScrolledComposite not the parent of teh ScrolledComposite. The View is
>> the parent.
>>
>> See the example from the class javadoc for ScrolledComposite:
>>
>> // set the minimum width and height of the scrolled content - method 2
>> final ScrolledComposite sc2 = new ScrolledComposite(shell, SWT.H_SCROLL |
>> SWT.V_SCROLL | SWT.BORDER);
>> sc2.setExpandHorizontal(true);
>> sc2.setExpandVertical(true);
>> final Composite c2 = new Composite(sc2, SWT.NONE);
>> sc2.setContent(c2);
>> c2.setBackground(blue);
>> layout = new GridLayout();
>> layout.numColumns = 4;
>> c2.setLayout(layout);
>> Button b2 = new Button (c2, SWT.PUSH);
>> b2.setText("first button");
>> sc2.setMinSize(c2.computeSize(SWT.DEFAULT, SWT.DEFAULT));
>>
>>
>> "Kai" <junkworld@gmx.de> wrote in message
>> news:co1nm7$3jr$1@www.eclipse.org...
>>
>>>Hi!
>>>
>>>In a view i want to display a content, which might be larger than the
>>>visible area of the view. I use a ScrolledComposite which has the method
>>>setMinSize() where you can set the minimal Size at which Scrollbars
>>>should be shown. The only way i see is to giveMinSize the dimension of
>>>the view.
>>>
>>>Is there some way to get the current dimension of a view?
>>>
>>>Thanks in advance.
>>>
>>>Kai
>>>
>>>(I am using Eclipse 3.1 on W2k)
>>
>>
Re: Get the size of a view [message #446421 is a reply to message #446414] Wed, 24 November 2004 13:29 Go to previous messageGo to next message
Eclipse UserFriend
viewComposite = new ScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL );
viewComposite.setExpandHorizontal(true);
viewComposite.setExpandVertical(true);

commandComposite = new Composite (viewComposite,SWT.NONE);
commandComposite.setLayout(new GridLayout(1, false));
commandComposite.setLayoutData(new GridData());

viewComposite.setContent(commandComposite);

//dynamic add composites to commandComposite
//...

viewComposite.setMinSize(commandComposite.computeSize(SWT.DE FAULT,
SWT.DEFAULT));

// i tried this, but it seems to have no effect
//viewComposite.setSize(viewComposite.getClientArea().width, viewComposite.getClientArea().height);


commandComposite.layout(true);
viewComposite.layout(true);
parent.layout(true);


Veronika Irvine wrote:

> Views work the same as any other SWT Composite. Please give a code example
> showing your problem.
>
> "Kai" <junkworld@gmx.de> wrote in message
> news:co2dff$jv2$1@www.eclipse.org...
>
>>Thanks for your reply Veronika, but seems it doesn`t work correct in my
>>case. I am developing an eclipse plugin, my content is created dymnamicly
>>and after that, i want to decide if scrollbars are needed. The composite
>>which represents the content, includes other composites.
>>
>>When i try to use something like
>>
>>sc2.setMinSize(c2.computeSize(SWT.DEFAULT, SWT.DEFAULT));
>>
>>the whole content is displayed, but now scrollbars are shown. I could see
>>my the content which is to large for the visible area, when resize the
>>view.
>>
>>Is it possible that a view has a different behavior in this case then a
>>normal window?
>>
>>If i use getClientArea() on a composite in my view, i get the visible area
>>of the view. I tried to use setSize on my ScrolledComposite and then use
>>setMinSize(), but i doesen't seems to work, too.
>>
>>Any idea?
>>
>>
>>
>>
>>
>>Veronika Irvine wrote:
>>
>>>You should give setMinSize the preferred size of the contents of the
>>>ScrolledComposite not the parent of teh ScrolledComposite. The View is
>>>the parent.
>>>
>>>See the example from the class javadoc for ScrolledComposite:
>>>
>>>// set the minimum width and height of the scrolled content - method 2
>>>final ScrolledComposite sc2 = new ScrolledComposite(shell, SWT.H_SCROLL |
>>>SWT.V_SCROLL | SWT.BORDER);
>>>sc2.setExpandHorizontal(true);
>>>sc2.setExpandVertical(true);
>>>final Composite c2 = new Composite(sc2, SWT.NONE);
>>>sc2.setContent(c2);
>>>c2.setBackground(blue);
>>>layout = new GridLayout();
>>>layout.numColumns = 4;
>>>c2.setLayout(layout);
>>>Button b2 = new Button (c2, SWT.PUSH);
>>>b2.setText("first button");
>>>sc2.setMinSize(c2.computeSize(SWT.DEFAULT, SWT.DEFAULT));
>>>
>>>
>>>"Kai" <junkworld@gmx.de> wrote in message
>>>news:co1nm7$3jr$1@www.eclipse.org...
>>>
>>>
>>>>Hi!
>>>>
>>>>In a view i want to display a content, which might be larger than the
>>>>visible area of the view. I use a ScrolledComposite which has the method
>>>>setMinSize() where you can set the minimal Size at which Scrollbars
>>>>should be shown. The only way i see is to giveMinSize the dimension of
>>>>the view.
>>>>
>>>>Is there some way to get the current dimension of a view?
>>>>
>>>>Thanks in advance.
>>>>
>>>>Kai
>>>>
>>>>(I am using Eclipse 3.1 on W2k)
>>>
>>>
>
Re: Get the size of a view [message #446463 is a reply to message #446421] Thu, 25 November 2004 07:17 Go to previous message
Eclipse UserFriend
OK i figured it out, in my code was missing:

viewComposite.setLayoutData(new GridData(GridData.FILL_VERTICAL));

which seems to be necessary.




Kai Fischer wrote:
>
>
> viewComposite = new ScrolledComposite(parent, SWT.V_SCROLL |
> SWT.H_SCROLL );
> viewComposite.setExpandHorizontal(true);
> viewComposite.setExpandVertical(true);
>
> commandComposite = new Composite (viewComposite,SWT.NONE);
> commandComposite.setLayout(new GridLayout(1, false));
> commandComposite.setLayoutData(new GridData());
>
> viewComposite.setContent(commandComposite);
>
> //dynamic add composites to commandComposite
> //...
>
> viewComposite.setMinSize(commandComposite.computeSize(SWT.DE FAULT,
> SWT.DEFAULT));
>
> // i tried this, but it seems to have no effect
> //viewComposite.setSize(viewComposite.getClientArea().width, viewComposite.getClientArea().height);
>
>
>
> commandComposite.layout(true);
> viewComposite.layout(true);
> parent.layout(true);
>
>
> Veronika Irvine wrote:
>
>> Views work the same as any other SWT Composite. Please give a code
>> example showing your problem.
>>
>> "Kai" <junkworld@gmx.de> wrote in message
>> news:co2dff$jv2$1@www.eclipse.org...
>>
>>> Thanks for your reply Veronika, but seems it doesn`t work correct in
>>> my case. I am developing an eclipse plugin, my content is created
>>> dymnamicly and after that, i want to decide if scrollbars are needed.
>>> The composite which represents the content, includes other composites.
>>>
>>> When i try to use something like
>>>
>>> sc2.setMinSize(c2.computeSize(SWT.DEFAULT, SWT.DEFAULT));
>>>
>>> the whole content is displayed, but now scrollbars are shown. I could
>>> see my the content which is to large for the visible area, when
>>> resize the view.
>>>
>>> Is it possible that a view has a different behavior in this case then
>>> a normal window?
>>>
>>> If i use getClientArea() on a composite in my view, i get the visible
>>> area of the view. I tried to use setSize on my ScrolledComposite and
>>> then use setMinSize(), but i doesen't seems to work, too.
>>>
>>> Any idea?
>>>
>>>
>>>
>>>
>>>
>>> Veronika Irvine wrote:
>>>
>>>> You should give setMinSize the preferred size of the contents of the
>>>> ScrolledComposite not the parent of teh ScrolledComposite. The View
>>>> is the parent.
>>>>
>>>> See the example from the class javadoc for ScrolledComposite:
>>>>
>>>> // set the minimum width and height of the scrolled content - method 2
>>>> final ScrolledComposite sc2 = new ScrolledComposite(shell,
>>>> SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
>>>> sc2.setExpandHorizontal(true);
>>>> sc2.setExpandVertical(true);
>>>> final Composite c2 = new Composite(sc2, SWT.NONE);
>>>> sc2.setContent(c2);
>>>> c2.setBackground(blue);
>>>> layout = new GridLayout();
>>>> layout.numColumns = 4;
>>>> c2.setLayout(layout);
>>>> Button b2 = new Button (c2, SWT.PUSH);
>>>> b2.setText("first button");
>>>> sc2.setMinSize(c2.computeSize(SWT.DEFAULT, SWT.DEFAULT));
>>>>
>>>>
>>>> "Kai" <junkworld@gmx.de> wrote in message
>>>> news:co1nm7$3jr$1@www.eclipse.org...
>>>>
>>>>
>>>>> Hi!
>>>>>
>>>>> In a view i want to display a content, which might be larger than
>>>>> the visible area of the view. I use a ScrolledComposite which has
>>>>> the method setMinSize() where you can set the minimal Size at which
>>>>> Scrollbars should be shown. The only way i see is to giveMinSize
>>>>> the dimension of the view.
>>>>>
>>>>> Is there some way to get the current dimension of a view?
>>>>>
>>>>> Thanks in advance.
>>>>>
>>>>> Kai
>>>>>
>>>>> (I am using Eclipse 3.1 on W2k)
>>>>
>>>>
>>>>
>>
Previous Topic:GCC & MinGW How to compile a user library
Next Topic:how to remove a Combo from a Group
Goto Forum:
  


Current Time: Wed Jul 23 08:42:10 EDT 2025

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

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

Back to the top