如何在SWT中绘制Composite的子元素? [英] How to draw over child elements of a Composite in SWT?

查看:797
本文介绍了如何在SWT中绘制Composite的子元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我理解在绘制一个Composite时,你可以添加一个绘制侦听器,但这会导致在子绘图下绘制。如果我想绘制孩子的顶部怎么办?

I understand to draw on a Composite, you can add a paint listener, but that results in drawing under the children. What if I want to draw over the top of children?

以下绘制一条线,但是在它上面绘制了子线。

The following draws a line, but subc is drawn over it.

Composite c = new Composite(shell, 0);
c.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_BLUE));
c.setBounds(100, 100, 800, 600);

c.addPaintListener(new PaintListener() {
    public void paintControl(PaintEvent e) {
        e.gc.drawLine(0, 0, 500, 1000);
    }
});

final Composite subc = new Composite(c, 0);
subc.setLayout(null);
subc.setBounds(10, 10, 600, 400);


推荐答案

不幸的是,这不是一个已实现的功能,因为你可以请参阅 Bug#114749

Unfortunately this is not an implemented feature, as you can see in Bug#114749.

您必须编写自己的自定义解决方案(例如,计算每个受影响的复合材料的绘图区域,然后在每个复合图上绘制)。

You'd have to code your own custom solution (e.g, calculation the drawing area for each affected composite and then draw on each).

这是一个很老的错误,但如果你认为这是一个必须拥有的话,那就是一个好主意。

Its quite an old bug, but upvoting is always a good idea if you think this is a "must have".

这篇关于如何在SWT中绘制Composite的子元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆