本文整理汇总了Java中org.eclipse.swt.widgets.Composite.getClientArea方法的典型用法代码示例。如果您正苦于以下问题:Java Composite.getClientArea方法的具体用法?Java Composite.getClientArea怎么用?Java Composite.getClientArea使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.swt.widgets.Composite
的用法示例。
在下文中一共展示了Composite.getClientArea方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: layout
import org.eclipse.swt.widgets.Composite; //导入方法依赖的package包/类
public void layout(Composite editor, boolean force) {
Rectangle bounds = editor.getClientArea();
Point buttonOpenSize = buttonOpenCtrl.computeSize(SWT.DEFAULT, SWT.DEFAULT, force);
Point buttonNullSize = buttonNullCtrl.computeSize(SWT.DEFAULT, SWT.DEFAULT, force);
if (labelCtrl != null) {
labelCtrl.setBounds(0, 0, bounds.width - (buttonOpenSize.x + buttonNullSize.x), bounds.height);
}
buttonOpenCtrl.setBounds(bounds.width - (buttonOpenSize.x + buttonNullSize.x), 0, buttonOpenSize.x, bounds.height);
buttonNullCtrl.setBounds(bounds.width - buttonNullSize.x, 0, buttonNullSize.x, bounds.height);
}
示例2: copyToClipBoard
import org.eclipse.swt.widgets.Composite; //导入方法依赖的package包/类
void copyToClipBoard() {
Composite item = viewer;
Point p = viewer.computeSize(SWT.DEFAULT, SWT.DEFAULT);
Rectangle size = item.getClientArea();
System.out.println(p + " " + size);
// compositeViewer.setBackground(Constants.HIGHLIGHT_COLOR);
GC gc = new GC(item);
// Rectangle clipping2 = gc.getClipping();
// Image img = new Image(Display.getDefault(), size.width, size.height);
// gc.copyArea(img, 0, 0);
// ImageData imageData = img.getImageData();
RGB[] rgb = new RGB[256];
// build grey scale palette: 256 different grey values are generated.
for (int i = 0; i < 256; i++) {
rgb[i] = new RGB(i, i, i);
}
// Construct a new indexed palette given an array of RGB values.
PaletteData palette = new PaletteData(rgb);
Image img2 = new Image(Display.getDefault(), new ImageData(size.width, size.height, 8, palette));
// gc.setClipping(0, 0, p.x, p.y);
gc.copyArea(img2, 0, 0);
Shell popup = new Shell(Display.getDefault());
popup.setText("Image");
popup.setBounds(50, 50, 200, 200);
Canvas canvas = new Canvas(popup, SWT.NONE);
canvas.setBounds(img2.getBounds());
canvas.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
e.gc.drawImage(img2, 0, 0);
}
});
popup.open();
Clipboard clipboard = new Clipboard(Display.getDefault());
clipboard.setContents(new Object[]{img2.getImageData()}, new Transfer[]{ ImageTransfer.getInstance()});
img2.dispose();
gc.dispose();
}