You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[GTK] Control.setBackgroundImage is ignored on ToolBar #3538
On GTK a background image set on a ToolBar is never painted; the bar shows the GTK theme's toolbar colour. The same image on a Composite or Label paints fine.
Snippet
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
public class ToolBarBackgroundImage {
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("ToolBar background image");
shell.setLayout(new GridLayout(1, false));
Image image = new Image(display, 10, 40);
GC gc = new GC(image);
gc.setBackground(display.getSystemColor(SWT.COLOR_MAGENTA));
gc.fillRectangle(0, 0, 10, 40);
gc.dispose();
new Label(shell, SWT.NONE).setText("ToolBar: image is not painted");
ToolBar bar = new ToolBar(shell, SWT.FLAT);
bar.setLayoutData(new GridData(200, 40));
new ToolItem(bar, SWT.PUSH).setText("Item");
bar.setBackgroundImage(image);
new Label(shell, SWT.NONE).setText("Composite: image is painted");
Composite composite = new Composite(shell, SWT.NONE);
composite.setLayoutData(new GridData(200, 40));
composite.setBackgroundImage(image);
shell.setSize(400, 250);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
image.dispose();
display.dispose();
}
}
Expected on GTK: the composite is magenta, the tool bar is not.
Activity