Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » What components can be inserted in a ToolBar's separator?
What components can be inserted in a ToolBar's separator? [message #467269] Fri, 27 January 2006 13:30 Go to next message
lolo is currently offline loloFriend
Messages: 8
Registered: July 2009
Junior Member
Label, Text or List, when inserted in a ToolBar's separator, are not
visibles.
Re: What components can be inserted in a ToolBar's separator? [message #467271 is a reply to message #467269] Fri, 27 January 2006 13:51 Go to previous messageGo to next message
lolo is currently offline loloFriend
Messages: 8
Registered: July 2009
Junior Member
<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
Re: What components can be inserted in a ToolBar's separator? [message #467296 is a reply to message #467271] Fri, 27 January 2006 22:27 Go to previous messageGo to next message
Jeremy Dowdall is currently offline Jeremy DowdallFriend
Messages: 48
Registered: July 2009
Member
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
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 Go to previous message
lolo is currently offline loloFriend
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
Previous Topic:PLAF conflict with SWT?
Next Topic:Problem with SWT.WRAP (GTK2)
Goto Forum:
  


Current Time: Sat Sep 21 17:47:52 GMT 2019

Powered by FUDForum. Page generated in 0.01345 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top