Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-swt-dev] trivial work about setting layout data -- need improvements

Hi Carolyn :

Thank you.

On 3/5/10, Carolyn MacLeod <Carolyn_MacLeod@xxxxxxxxxx> wrote:
> One other possibility is to use the LayoutExample to do some of the work
> for you.
> Here's how to get all of the SWT examples:
> http://www.eclipse.org/swt/examples.php
> Then run the LayoutExample, choose the layout type you think you want to
> use, add the controls that you want in your layout, and lay them out the
> way you want by changing various layout data values in the table.
> Then click the Generate Code button. Copy/paste the generated code into
> your code.
> It's really primitive, but it could be helpful.
>
> Alternatively, you can try out one of the available GUI builders:
> http://www.eclipse.org/swt/faq.php#guibuilder
>
> Hope this helps,
> Carolyn
>
>
>
> From:
> zhong nanhai <higerinbeijing@xxxxxxxxx>
> To:
> "Eclipse Platform SWT component developers list."
> <platform-swt-dev@xxxxxxxxxxx>
> Date:
> 05/03/2010 12:52 AM
> Subject:
> Re: [platform-swt-dev] trivial work about setting layout data -- need
> improvements
> Sent by:
> platform-swt-dev-bounces@xxxxxxxxxxx
>
>
>
> Hi Shwan:
>
> Yes, that's what I need, although this necessary functionality exists
> in JFace other than SWT.
>
> Then thank you very much.
>
> higer
>
> On 3/5/10, Shawn Minto <shawn.minto@xxxxxxxxxxx> wrote:
>> Hi higer,
>>
>> If you use JFace, there is a GridDataFactory class that makes it
>> really easy to set this information.  It provides you will utility
>> methods to create and set all of the fields on GridData that you can
>> chain together and apply to a control i.e.
>>
>> Button btn1 = new Button(shell, SWT.PUSH);
>> GridDataFactory.swtDefaults().grab(true,true).applyTo(btn1);
>>
>> This sounds similar to what you are looking for.  There is still some
>> duplication, but it is shorter and easier to setup the layout data
>> than setting the fields directly.
>>
>> Shawn
>>
>> On Thu, Mar 4, 2010 at 7:22 PM, zhong nanhai <higerinbeijing@xxxxxxxxx>
>> wrote:
>>> Hi, guys:
>>>
>>> As is known to everyone, we often use layout and layout data to show
>>> our controls in a composite panel when using SWT, but don't you find
>>> it's very trivial and boring to set the layout data?
>>>
>>> Everytime we layout a control we have to create a new ***Data(e.g.
>>> GridData) and set its prapameters in a proper way, and when we create
>>> another control which have the same layout requirements, we then
>>> always create a complete new ***Data and set it step by step, it's
>>> boring and it sucks! The following is a simple example:
>>>
>>> .................
>>> Button btn1 = new Button(shell, SWT.PUSH);
>>> GridData data = new GridData();
>>> data.grabExcessHorizontalSpace = true;
>>> data.grabExcessVerticalSpace = true;
>>> data.***=**
>>> data.***=**
>>> btn1.setLayoutData(data);
>>> Button btn2 = new Button(shell, SWT.PUSH);
>>> /* Then all the following steps are complete the same*/
>>> data = new GridData();
>>> data.grabExcessHorizontalSpace = true;
>>> data.grabExcessVerticalSpace = true;
>>> data.***=**
>>> data.***=**
>>> btn2.setLayoutData(data);
>>> ................
>>>
>>>
>>> So, I think SWT should provide a new way to do this work, for example,
>>> SWT can provide a clone method to a layout data object , and when we
>>> set another control, we just need to clone an old layout data object
>>> and set some parameters if necessary, then this work could become
>>> every easy. The above code may look like this:
>>>
>>> ...............
>>> Button btn1 = new Button(shell, SWT.PUSH);
>>> GridData data = new GridData();
>>> data.grabExcessHorizontalSpace = true;
>>> data.grabExcessVerticalSpace = true;
>>> data.***=**
>>> data.***=**
>>> btn1.setLayoutData(data);
>>> Button btn2 = new Button(shell, SWT.PUSH);
>>> /* more simple way to create a layout data*/
>>> data = data.clone();
>>> data.grabExcessHorizontalSpace = false; // just need to modify the
>>> necessary parameters
>>> btn2.setLayoutData(data);
>>>
>>> .................
>>>
>>> So, what a wonderful job!
>>>
>>> I do not know why such a method doesn't exist in SWT and I want to do
>>> some improvements , then I need you guys' good advices and directions
>>> about this idea.
>>>
>>> Many thanks!
>>>
>>>
>>> Best wishes to everyone,
>>> higer
>>> _______________________________________________
>>> platform-swt-dev mailing list
>>> platform-swt-dev@xxxxxxxxxxx
>>> https://dev.eclipse.org/mailman/listinfo/platform-swt-dev
>>>
>>
>>
>>
>> --
>> Shawn Minto
>> shawn.minto@xxxxxxxxxxx
>> Tasktop Technologies, Inc.
>> http://www.tasktop.com
>> _______________________________________________
>> platform-swt-dev mailing list
>> platform-swt-dev@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/platform-swt-dev
>>
> _______________________________________________
> platform-swt-dev mailing list
> platform-swt-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/platform-swt-dev
>
>
>


Back to the top