Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Get the size of a view
| |
Re: Get the size of a view [message #446405 is a reply to message #446403] |
Wed, 24 November 2004 16:39 |
Kai Fischer Messages: 11 Registered: July 2009 |
Junior Member |
|
|
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 18:02 |
Veronika Irvine Messages: 1272 Registered: July 2009 |
Senior Member |
|
|
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 18:29 |
Kai Fischer Messages: 11 Registered: July 2009 |
Junior Member |
|
|
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 12:17 |
Kai Fischer Messages: 11 Registered: July 2009 |
Junior Member |
|
|
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)
>>>>
>>>>
>>>>
>>
|
|
|
Goto Forum:
Current Time: Sat Apr 20 02:46:03 GMT 2024
Powered by FUDForum. Page generated in 0.03854 seconds
|