0
我找不到解決方案,也無法輕鬆轉換SWT中的Composite。SWT Composite Transform
我想通過組合CTRL + SCROLL實現放大/縮小。我到目前爲止發現的是將PaintListener添加到複合材料中,如下所示:
this.viewingFrame = new Shell(new Display());
this.viewingFrame.setLayout(new GridLayout(2, false));
GridDataFactory.fillDefaults().grab(true, true).applyTo(viewingFrame);
c1 = new Composite(viewingFrame, SWT.NONE);
GridLayoutFactory.swtDefaults().applyTo(c1);
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(c1);
c1.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
Transform trans = new Transform(e.display);
e.gc.setAdvanced(true); // After this line a call to e.gc.getAdvance() returns true
trans.scale(1.5f, 1.5f);
e.gc.setTransform(trans);
trans.dispose();
}
});
// Of course there is more code. I have a KTable displaying a 2D map. I also tried adding the PaintListener to the shell, the composite c1 and the KTable. Same result.
但是,這不起作用。在調試時,我可以看到監聽器被調用,但沒有可見的效果。
我是SWT方面的新手,但我學得很快,所以我願意考慮複雜的解決方案。
感謝您解釋這一點並提出解決方案。這不完全是我想要的,但我認爲我可以讓它滿足我的需求。 – 2014-11-03 21:21:21