Aligning button text to the left, yet expand button? [message #528245] |
Mon, 19 April 2010 19:37 |
Herb Miller Messages: 139 Registered: January 2010 |
Senior Member |
|
|
I have an application that uses 2 columns of buttons in an Eclipse view. In the createPartControl method, the layout for the parent Composite is left at the default value which turns out to be a horizontal FillLayout. A ScrolledComposite with vertical RowLayout is added to the parent, and a Composite with a 2-column GridLayout is added to the ScrolledComposite. The GridLayout is set to make the columns of equal width.
parent: Composite w/ FillLayout(horizontal)
scroll: ScrolledComposite w/ RowLayout(vertical)
child: Composite w/ GridLayout(2,true)
The buttons are added to the child composite. The problem is that the columns of buttons do not display as equal width. The buttons with less text are shorter, and the buttons with more text are longer.
The only way I was able to get them to be the same width was to use a GridData on each button, and to set the widthHint of the GridData to the same large value on every button. Now the buttons are the same width.
However, the buttons have images and the images and the button text move to the center of the button, and now the images do not line up. Maybe I can show this below:
What I have:
____________________
| Image 1 LargeText1 |
|____________________|
____________________
| Image 2 Text2 |
|____________________|
What I want:
____________________
| Image 1 LargeText1 |
|____________________|
____________________
| Image 2 Text2 |
|____________________|
Notice that in the second case (What I want), the buttons are the same size, but the images and the beginning of the text line up vertically.
Is there any way to achieve the 2nd case?
Thanks.
|
|
|
|
|
Re: Aligning button text to the left, yet expand button? [message #528454 is a reply to message #528395] |
Tue, 20 April 2010 15:12 |
Herb Miller Messages: 139 Registered: January 2010 |
Senior Member |
|
|
Yes, you are correct. Because of the GridLayout, I do get 2 columns of buttons. That part works well. But the buttons in each column vary their size based on the text.
I would like all of the buttons to be the same size, even if the text value for each button is of different lengths. I set the makeColumnsEqualWidth for the GridLayout to true. But for some reason, the buttons are not the same width. They stll vary their width based on the text.
I was able to get the buttons to be the same width by using a GridData on each button and setting the widthHint.
Using the widthHint did make all of the buttons the same width, but it centered the image attached to the button and it centered the text. I would like to keep the images and text on the left edge of the button.
My diagram (pitiful as it was) was trying to show just 1 column of the buttons, and how the text and images on the button did not line up.
If you need more, please let me know. The code is quite large. If I can pare it down to a small snippet, I will post it.
I am using Galileo on Linux.
Thanks.
|
|
|
Powered by
FUDForum. Page generated in 0.03599 seconds