|
|
|
Re: What components can be inserted in a ToolBar's separator? [message #467355 is a reply to message #467296] |
Mon, 30 January 2006 09:02 |
lolo Messages: 8 Registered: July 2009 |
Junior Member |
|
|
I have proven your code, but it does not work for me. I have noticed, that
if I do not set the width of the separator, the label is visible. Here you
have an snippet:
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
public class ToolBarSeparator {
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
ToolBar bar = new ToolBar(shell, SWT.BORDER);
for (int i = 0; i < 4; i++) {
ToolItem item = new ToolItem(bar, 0);
item.setText("Item " + i);
}
Image image = new Image(display, 10, 23);
Color color = display.getSystemColor(SWT.COLOR_RED);
GC gc = new GC(image);
gc.setBackground(color);
gc.fillRectangle(image.getBounds());
gc.dispose();
ToolItem sep = new ToolItem(bar, SWT.SEPARATOR);
int start = bar.getItemCount();
Label c = new Label(bar, SWT.READ_ONLY);
c.setText("Label");
c.pack();
sep.setWidth(c.getSize().x);//comment this line, to view the label
sep.setControl(c);
for (int i = start; i < start + 4; i++) {
ToolItem item = new ToolItem(bar, 0);
item.setText("Item " + i);
item.setImage(image);
}
bar.pack();
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
image.dispose();
}
}
Jeremy Dowdall wrote:
> are you setting the size of the separator? I've been using labels in
> ToolItems on GTK for some time without a problem - if you have a snippet
> I'd be happy to take a closer look.
>
>
> ToolItem item = new ToolItem(tb, SWT.SEPARATOR);
> CLabel lbl = new CLabel(tb, SWT.CENTER);
> lbl.setText("000 of 000");
> item.setControl(lbl);
> item.setWidth(lbl.computeSize(SWT.DEFAULT, SWT.DEFAULT).x);
>
> (add a listener to resize the item when its content changes)
>
>
> Manuel Nogales wrote:
>> <publicado y enviado>
>>
>> Manuel Nogales wrote:
>>
>>
>>>Label, Text or List, when inserted in a ToolBar's separator, are not
>>>visibles.
>>
>> This only occurs in linux, not in windows
|
|
|
Powered by
FUDForum. Page generated in 0.03601 seconds