use of org.eclipse.swt.custom.ScrolledComposite in project eclipse.platform.swt by eclipse.
the class ClipboardExample method open.
public void open(Display display) {
clipboard = new Clipboard(display);
shell = new Shell(display);
shell.setText("SWT Clipboard");
shell.setLayout(new FillLayout());
ScrolledComposite sc = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL);
Composite parent = new Composite(sc, SWT.NONE);
sc.setContent(parent);
parent.setLayout(new GridLayout(2, true));
Group copyGroup = new Group(parent, SWT.NONE);
copyGroup.setText("Copy From:");
GridData data = new GridData(GridData.FILL_BOTH);
copyGroup.setLayoutData(data);
copyGroup.setLayout(new GridLayout(3, false));
Group pasteGroup = new Group(parent, SWT.NONE);
pasteGroup.setText("Paste To:");
data = new GridData(GridData.FILL_BOTH);
pasteGroup.setLayoutData(data);
pasteGroup.setLayout(new GridLayout(3, false));
Group controlGroup = new Group(parent, SWT.NONE);
controlGroup.setText("Control API:");
data = new GridData(GridData.FILL_HORIZONTAL);
data.horizontalSpan = 2;
controlGroup.setLayoutData(data);
controlGroup.setLayout(new GridLayout(5, false));
Group typesGroup = new Group(parent, SWT.NONE);
typesGroup.setText("Available Types");
data = new GridData(GridData.FILL_HORIZONTAL);
data.horizontalSpan = 2;
typesGroup.setLayoutData(data);
typesGroup.setLayout(new GridLayout(2, false));
status = new Label(parent, SWT.NONE);
data = new GridData(GridData.FILL_HORIZONTAL);
data.horizontalSpan = 2;
status.setLayoutData(data);
createTextTransfer(copyGroup, pasteGroup);
createRTFTransfer(copyGroup, pasteGroup);
createHTMLTransfer(copyGroup, pasteGroup);
createFileTransfer(copyGroup, pasteGroup);
createImageTransfer(copyGroup, pasteGroup);
createMyTransfer(copyGroup, pasteGroup);
createControlTransfer(controlGroup);
createAvailableTypes(typesGroup);
sc.setMinSize(parent.computeSize(SWT.DEFAULT, SWT.DEFAULT));
sc.setExpandHorizontal(true);
sc.setExpandVertical(true);
Point size = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT);
Rectangle monitorArea = shell.getMonitor().getClientArea();
shell.setSize(Math.min(size.x, monitorArea.width - 20), Math.min(size.y, monitorArea.height - 20));
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
clipboard.dispose();
}
use of org.eclipse.swt.custom.ScrolledComposite in project eclipse.platform.swt by eclipse.
the class Test_org_eclipse_swt_widgets_ScrolledComposite method test_setContent.
@Test
public void test_setContent() {
scrolledComposite = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL);
Point point = new Point(5, 5);
Composite parent = new Composite(scrolledComposite, SWT.NONE);
scrolledComposite.setContent(null);
scrolledComposite.setOrigin(point);
assertEquals(0, scrolledComposite.getOrigin().x);
assertEquals(0, scrolledComposite.getOrigin().y);
scrolledComposite.setContent(parent);
scrolledComposite.setOrigin(point);
assertEquals(5, scrolledComposite.getOrigin().x);
assertEquals(5, scrolledComposite.getOrigin().y);
}
use of org.eclipse.swt.custom.ScrolledComposite in project eclipse.platform.swt by eclipse.
the class Test_org_eclipse_swt_widgets_ScrolledComposite method test_getOrigin.
@Test
public void test_getOrigin() {
scrolledComposite = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL);
Composite parent = new Composite(scrolledComposite, SWT.NONE);
scrolledComposite.setContent(parent);
Point point = new Point(5, 0);
scrolledComposite.setOrigin(point);
assertEquals(5, scrolledComposite.getOrigin().x);
assertEquals(0, scrolledComposite.getOrigin().y);
point.x = 0;
point.y = 5;
scrolledComposite.setOrigin(point);
assertEquals(0, scrolledComposite.getOrigin().x);
assertEquals(5, scrolledComposite.getOrigin().y);
point.x = 1;
point.y = -5;
scrolledComposite.setOrigin(point);
assertEquals(1, scrolledComposite.getOrigin().x);
assertEquals(0, scrolledComposite.getOrigin().y);
point.x = -2;
point.y = 3;
scrolledComposite.setOrigin(point);
assertEquals(0, scrolledComposite.getOrigin().x);
assertEquals(3, scrolledComposite.getOrigin().y);
scrolledComposite.setOrigin(0, 10);
assertEquals(0, scrolledComposite.getOrigin().x);
assertEquals(10, scrolledComposite.getOrigin().y);
scrolledComposite.setOrigin(10, 0);
assertEquals(10, scrolledComposite.getOrigin().x);
assertEquals(0, scrolledComposite.getOrigin().y);
scrolledComposite.setOrigin(-5, 5);
assertEquals(0, scrolledComposite.getOrigin().x);
assertEquals(5, scrolledComposite.getOrigin().y);
scrolledComposite.setOrigin(5, -5);
assertEquals(5, scrolledComposite.getOrigin().x);
assertEquals(0, scrolledComposite.getOrigin().y);
}
use of org.eclipse.swt.custom.ScrolledComposite in project eclipse.platform.swt by eclipse.
the class DNDExample method open.
public void open(Display display) {
Shell shell = new Shell(display);
shell.setText("Drag and Drop Example");
shell.setLayout(new FillLayout());
itemImage = new Image(display, DNDExample.class.getResourceAsStream("openFolder.gif"));
ScrolledComposite sc = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL);
Composite parent = new Composite(sc, SWT.NONE);
sc.setContent(parent);
parent.setLayout(new FormLayout());
Label dragLabel = new Label(parent, SWT.LEFT);
dragLabel.setText("Drag Source:");
Group dragWidgetGroup = new Group(parent, SWT.NONE);
dragWidgetGroup.setText("Widget");
createDragWidget(dragWidgetGroup);
Composite cLeft = new Composite(parent, SWT.NONE);
cLeft.setLayout(new GridLayout(2, false));
Group dragOperationsGroup = new Group(cLeft, SWT.NONE);
dragOperationsGroup.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, false, 1, 1));
dragOperationsGroup.setText("Allowed Operation(s):");
createDragOperations(dragOperationsGroup);
Group dragTypesGroup = new Group(cLeft, SWT.NONE);
dragTypesGroup.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1));
dragTypesGroup.setText("Transfer Type(s):");
createDragTypes(dragTypesGroup);
dragConsole = new Text(cLeft, SWT.READ_ONLY | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI);
dragConsole.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
Menu menu = new Menu(shell, SWT.POP_UP);
MenuItem item = new MenuItem(menu, SWT.PUSH);
item.setText("Clear");
item.addSelectionListener(widgetSelectedAdapter(e -> dragConsole.setText("")));
item = new MenuItem(menu, SWT.CHECK);
item.setText("Show Event detail");
item.addSelectionListener(widgetSelectedAdapter(e -> {
MenuItem eItem = (MenuItem) e.widget;
dragEventDetail = eItem.getSelection();
}));
dragConsole.setMenu(menu);
Label dropLabel = new Label(parent, SWT.LEFT);
dropLabel.setText("Drop Target:");
Group dropWidgetGroup = new Group(parent, SWT.NONE);
dropWidgetGroup.setText("Widget");
createDropWidget(dropWidgetGroup);
Composite cRight = new Composite(parent, SWT.NONE);
cRight.setLayout(new GridLayout(2, false));
Group dropOperationsGroup = new Group(cRight, SWT.NONE);
dropOperationsGroup.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, false, 1, 2));
dropOperationsGroup.setText("Allowed Operation(s):");
createDropOperations(dropOperationsGroup);
Group dropTypesGroup = new Group(cRight, SWT.NONE);
dropTypesGroup.setText("Transfer Type(s):");
createDropTypes(dropTypesGroup);
Group feedbackTypesGroup = new Group(cRight, SWT.NONE);
feedbackTypesGroup.setText("Feedback Type(s):");
createFeedbackTypes(feedbackTypesGroup);
dropConsole = new Text(cRight, SWT.READ_ONLY | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI);
dropConsole.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
menu = new Menu(shell, SWT.POP_UP);
item = new MenuItem(menu, SWT.PUSH);
item.setText("Clear");
item.addSelectionListener(widgetSelectedAdapter(e -> dropConsole.setText("")));
item = new MenuItem(menu, SWT.CHECK);
item.setText("Show Event detail");
item.addSelectionListener(widgetSelectedAdapter(e -> {
MenuItem eItem = (MenuItem) e.widget;
dropEventDetail = eItem.getSelection();
}));
dropConsole.setMenu(menu);
if (dragEnabled)
createDragSource();
if (dropEnabled)
createDropTarget();
int height = 200;
FormData data = new FormData();
data.top = new FormAttachment(0, 10);
data.left = new FormAttachment(0, 10);
dragLabel.setLayoutData(data);
data = new FormData();
data.top = new FormAttachment(dragLabel, 10);
data.left = new FormAttachment(0, 10);
data.right = new FormAttachment(50, -10);
data.height = height;
dragWidgetGroup.setLayoutData(data);
data = new FormData();
data.top = new FormAttachment(dragWidgetGroup, 10);
data.left = new FormAttachment(0, 10);
data.right = new FormAttachment(50, -10);
data.bottom = new FormAttachment(100, -10);
cLeft.setLayoutData(data);
data = new FormData();
data.top = new FormAttachment(0, 10);
data.left = new FormAttachment(cLeft, 10);
dropLabel.setLayoutData(data);
data = new FormData();
data.top = new FormAttachment(dropLabel, 10);
data.left = new FormAttachment(cLeft, 10);
data.right = new FormAttachment(100, -10);
data.height = height;
dropWidgetGroup.setLayoutData(data);
data = new FormData();
data.top = new FormAttachment(dropWidgetGroup, 10);
data.left = new FormAttachment(cLeft, 10);
data.right = new FormAttachment(100, -10);
data.bottom = new FormAttachment(100, -10);
cRight.setLayoutData(data);
sc.setMinSize(parent.computeSize(SWT.DEFAULT, SWT.DEFAULT));
sc.setExpandHorizontal(true);
sc.setExpandVertical(true);
Point size = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT);
Rectangle monitorArea = shell.getMonitor().getClientArea();
shell.setSize(Math.min(size.x, monitorArea.width - 20), Math.min(size.y, monitorArea.height - 20));
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
itemImage.dispose();
}
use of org.eclipse.swt.custom.ScrolledComposite in project eclipse.platform.text by eclipse.
the class FindReplaceDialog method createContents.
@Override
protected Control createContents(Composite parent) {
Composite panel = new Composite(parent, SWT.NULL);
GridLayout layout = new GridLayout();
layout.numColumns = 1;
layout.makeColumnsEqualWidth = true;
panel.setLayout(layout);
setGridData(panel, SWT.FILL, true, SWT.FILL, true);
ScrolledComposite scrolled = new ScrolledComposite(panel, SWT.V_SCROLL);
setGridData(scrolled, SWT.FILL, true, SWT.FILL, true);
Composite mainArea = new Composite(scrolled, SWT.NONE);
setGridData(mainArea, SWT.FILL, true, SWT.FILL, true);
mainArea.setLayout(new GridLayout(1, true));
Composite inputPanel = createInputPanel(mainArea);
setGridData(inputPanel, SWT.FILL, true, SWT.TOP, false);
Composite configPanel = createConfigPanel(mainArea);
setGridData(configPanel, SWT.FILL, true, SWT.TOP, true);
scrolled.setContent(mainArea);
scrolled.setExpandHorizontal(true);
scrolled.setExpandVertical(true);
scrolled.addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
scrolled.setMinHeight(mainArea.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
}
});
Composite buttonPanelB = createButtonSection(panel);
setGridData(buttonPanelB, SWT.RIGHT, true, SWT.BOTTOM, false);
Composite statusBar = createStatusAndCloseButton(panel);
setGridData(statusBar, SWT.FILL, true, SWT.BOTTOM, false);
panel.addTraverseListener(new TraverseListener() {
@Override
public void keyTraversed(TraverseEvent e) {
if (e.detail == SWT.TRAVERSE_RETURN) {
if (!Util.isMac()) {
Control controlWithFocus = getShell().getDisplay().getFocusControl();
if (controlWithFocus != null && (controlWithFocus.getStyle() & SWT.PUSH) == SWT.PUSH)
return;
}
Event event = new Event();
event.type = SWT.Selection;
event.stateMask = e.stateMask;
fFindNextButton.notifyListeners(SWT.Selection, event);
e.doit = false;
} else if (e.detail == SWT.TRAVERSE_MNEMONIC) {
Character mnemonic = Character.valueOf(Character.toLowerCase(e.character));
if (fMnemonicButtonMap.containsKey(mnemonic)) {
Button button = fMnemonicButtonMap.get(mnemonic);
if ((fFindField.isFocusControl() || fReplaceField.isFocusControl() || (button.getStyle() & SWT.PUSH) != 0) && button.isEnabled()) {
Event event = new Event();
event.type = SWT.Selection;
event.stateMask = e.stateMask;
if ((button.getStyle() & SWT.RADIO) != 0) {
Composite buttonParent = button.getParent();
if (buttonParent != null) {
Control[] children = buttonParent.getChildren();
for (int i = 0; i < children.length; i++) ((Button) children[i]).setSelection(false);
}
button.setSelection(true);
} else {
button.setSelection(!button.getSelection());
}
button.notifyListeners(SWT.Selection, event);
e.detail = SWT.TRAVERSE_NONE;
e.doit = true;
}
}
}
}
});
updateButtonState();
applyDialogFont(panel);
return panel;
}
Aggregations