本文整理匯總了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();
}