[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.platform.swt] Re: Toolbars with a gradient background?
|
Hi Jakob,
See
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet218.java?view=co
for an example of setting a gradient background image. The example shows a
StyledText, but changing it to a ToolBar works the same.
Grant
"Jakob Lyng Petersen" <jlp@xxxxxxxxxxx> wrote in message
news:ftd19g$pot$1@xxxxxxxxxxxxxxxxxxxx
> Hi,
>
> I would like to create a toolbar with a gradient background. ToolItems
> added to the toolbar, should be drawn "on top" of the gradient.
> Having played around with this, it seems that I'm only able to have the
> gradient drawn on top of the ToolItems.
>
> Basically, what I'm doing is something like this:
> ToolBar tb = new ToolBar(parent, SWT.HORIZONTAL);
> tb.addPaintListener(new PaintListener() {
> public void paintControl(final PaintEvent e) {
> e.gc.setForeground(e.display.getSystemColor(SWT.COLOR_RED));
> e.gc.setBackground(e.display.getSystemColor(SWT.COLOR_YELLOW));
> e.gc.fillGradientRectangle(0, 0, tb.width, tb.height, true);
> }
> });
>
> ToolItem ti1 = new ToolItem(tb, SWT.PUSH);
> ti1.setText("Button 1");
>
> Now, the result of the above is that the I can see the gradient, but not
> the tool item. If I just draw a line in the paint listener, I can see
> that the line is drawn on top of the tool item.
> Is there a way to have the tool items "above" the gradient "background"?
>
> Thanks,
>
> Jakob Lyng Petersen.