How to change the alignment image/text in a ToolItem? [message #1068112] |
Fri, 12 July 2013 09:11 |
Francis Delsinnes Messages: 49 Registered: November 2011 |
Member |
|
|
I don't understand why the following code does not work:
shell.setSize(240, 100);
ToolBar toolbar = new ToolBar(shell, SWT.FLAT);
toolbar.setSize(shell.getSize().x, 40);
toolbar.setLocation(0, 0);
//...
Image imageBtn2 = new Image(display, "btn2.bmp");
ToolItem btn2 = new ToolItem(toolbar, SWT.PUSH);
btn2.setImage(imageBtn2);
btn2.setText("Stop");
//...
With this code, I got a ToolItem with an Icon (btn2) and the label "Stop" on one line. (alignement: horizontal, left to right)
But I would like a ToolItem with an Icon on the top and the label to the center bottom... (alignement: vertical, top down) like that:
Today, I've two alternative solutions:
1. Make a Composite with an image and a label
2. Create an image with my icon and my text
But with the solution
#1, I cannot highlight my "button" (only the border of my composite by CSS theme)
#2, the font of my text and the text himself are fixed in the new image
|
|
|
|
|
Re: How to change the alignment image/text in a ToolItem? [message #1069101 is a reply to message #1068112] |
Mon, 15 July 2013 06:59 |
Ivan Furnadjiev Messages: 2426 Registered: July 2009 Location: Sofia, Bulgaria |
Senior Member |
|
|
Hi Francis,
the desired by you behavior is controlled in SWT by SWT.RIGHT style flag
on the ToolBar:
-> SWT.RIGHT set - icon and text on the same line
-> SWT.RIGHT not set - icon on top, text below the icon, both centered
each other
In RAP, the SWT.RIGHT style flag is not supported. You can vote for this
enhancement.
237737: [ToolBar] SWT.RIGHT not supported
https://bugs.eclipse.org/bugs/show_bug.cgi?id=237737
Best,
Ivan
On 7/12/2013 12:11 PM, Francis Delsinnes wrote:
> I don't understand why the following code does not work:
>
>
> shell.setSize(240, 100);
> ToolBar toolbar = new ToolBar(shell, SWT.FLAT);
> toolbar.setSize(shell.getSize().x, 40);
> toolbar.setLocation(0, 0);
>
> //...
>
> Image imageBtn2 = new Image(display, "btn2.bmp");
> ToolItem btn2 = new ToolItem(toolbar, SWT.PUSH);
> btn2.setImage(imageBtn2);
> btn2.setText("Stop");
>
> //...
>
>
> With this code, I got a ToolItem with an Icon (btn2) and the label
> "Stop" on one line. (alignement: horizontal, left to right)
>
>
> But I would like a ToolItem with an Icon on the top and the label to
> the center bottom... (alignement: vertical, top down) like that:
>
>
> Today, I've two alternative solutions:
> 1. Make a Composite with an image and a label
> 2. Create an image with my icon and my text
>
> But with the solution #1, I cannot highlight my "button" (only the
> border of my composite by CSS theme)
> #2, the font of my text and the text himself are fixed in the new image
--
Ivan Furnadjiev
Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/
Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
|
|
|
|
Powered by
FUDForum. Page generated in 0.02834 seconds