Search in sources :

Example 76 with ScrolledComposite

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();
}
Also used : Group(org.eclipse.swt.widgets.Group) Shell(org.eclipse.swt.widgets.Shell) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) Rectangle(org.eclipse.swt.graphics.Rectangle) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Clipboard(org.eclipse.swt.dnd.Clipboard) FillLayout(org.eclipse.swt.layout.FillLayout) Point(org.eclipse.swt.graphics.Point)

Example 77 with ScrolledComposite

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);
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Point(org.eclipse.swt.graphics.Point) Test(org.junit.Test)

Example 78 with ScrolledComposite

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);
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Point(org.eclipse.swt.graphics.Point) Test(org.junit.Test)

Example 79 with ScrolledComposite

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();
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) StyledText(org.eclipse.swt.custom.StyledText) URL(java.net.URL) DND(org.eclipse.swt.dnd.DND) TableColumn(org.eclipse.swt.widgets.TableColumn) FontMetrics(org.eclipse.swt.graphics.FontMetrics) Point(org.eclipse.swt.graphics.Point) SWTError(org.eclipse.swt.SWTError) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) URLTransfer(org.eclipse.swt.dnd.URLTransfer) Composite(org.eclipse.swt.widgets.Composite) TreeColumn(org.eclipse.swt.widgets.TreeColumn) DropTarget(org.eclipse.swt.dnd.DropTarget) Text(org.eclipse.swt.widgets.Text) Button(org.eclipse.swt.widgets.Button) Display(org.eclipse.swt.widgets.Display) Transfer(org.eclipse.swt.dnd.Transfer) MenuItem(org.eclipse.swt.widgets.MenuItem) Tree(org.eclipse.swt.widgets.Tree) SWT(org.eclipse.swt.SWT) HTMLTransfer(org.eclipse.swt.dnd.HTMLTransfer) List(org.eclipse.swt.widgets.List) DragSourceEvent(org.eclipse.swt.dnd.DragSourceEvent) Label(org.eclipse.swt.widgets.Label) RTFTransfer(org.eclipse.swt.dnd.RTFTransfer) DragSourceListener(org.eclipse.swt.dnd.DragSourceListener) Image(org.eclipse.swt.graphics.Image) Rectangle(org.eclipse.swt.graphics.Rectangle) Table(org.eclipse.swt.widgets.Table) SelectionListener.widgetSelectedAdapter(org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter) TextTransfer(org.eclipse.swt.dnd.TextTransfer) Canvas(org.eclipse.swt.widgets.Canvas) GridData(org.eclipse.swt.layout.GridData) FillLayout(org.eclipse.swt.layout.FillLayout) FileTransfer(org.eclipse.swt.dnd.FileTransfer) DragSource(org.eclipse.swt.dnd.DragSource) TableItem(org.eclipse.swt.widgets.TableItem) Combo(org.eclipse.swt.widgets.Combo) Shell(org.eclipse.swt.widgets.Shell) MalformedURLException(java.net.MalformedURLException) DropTargetListener(org.eclipse.swt.dnd.DropTargetListener) FormLayout(org.eclipse.swt.layout.FormLayout) FileDialog(org.eclipse.swt.widgets.FileDialog) FormData(org.eclipse.swt.layout.FormData) FormAttachment(org.eclipse.swt.layout.FormAttachment) Group(org.eclipse.swt.widgets.Group) TreeItem(org.eclipse.swt.widgets.TreeItem) File(java.io.File) RowLayout(org.eclipse.swt.layout.RowLayout) Menu(org.eclipse.swt.widgets.Menu) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Control(org.eclipse.swt.widgets.Control) GridLayout(org.eclipse.swt.layout.GridLayout) FormData(org.eclipse.swt.layout.FormData) Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Label(org.eclipse.swt.widgets.Label) Rectangle(org.eclipse.swt.graphics.Rectangle) StyledText(org.eclipse.swt.custom.StyledText) Text(org.eclipse.swt.widgets.Text) MenuItem(org.eclipse.swt.widgets.MenuItem) FillLayout(org.eclipse.swt.layout.FillLayout) Point(org.eclipse.swt.graphics.Point) Image(org.eclipse.swt.graphics.Image) Point(org.eclipse.swt.graphics.Point) Shell(org.eclipse.swt.widgets.Shell) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Menu(org.eclipse.swt.widgets.Menu) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 80 with ScrolledComposite

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;
}
Also used : TraverseEvent(org.eclipse.swt.events.TraverseEvent) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ControlAdapter(org.eclipse.swt.events.ControlAdapter) TraverseListener(org.eclipse.swt.events.TraverseListener) Point(org.eclipse.swt.graphics.Point) GridLayout(org.eclipse.swt.layout.GridLayout) Control(org.eclipse.swt.widgets.Control) Button(org.eclipse.swt.widgets.Button) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) TraverseEvent(org.eclipse.swt.events.TraverseEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Event(org.eclipse.swt.widgets.Event) ControlEvent(org.eclipse.swt.events.ControlEvent) ShellEvent(org.eclipse.swt.events.ShellEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ControlEvent(org.eclipse.swt.events.ControlEvent)

Aggregations

ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)89 Composite (org.eclipse.swt.widgets.Composite)67 GridData (org.eclipse.swt.layout.GridData)55 GridLayout (org.eclipse.swt.layout.GridLayout)51 Label (org.eclipse.swt.widgets.Label)39 Point (org.eclipse.swt.graphics.Point)27 Button (org.eclipse.swt.widgets.Button)21 Text (org.eclipse.swt.widgets.Text)20 FillLayout (org.eclipse.swt.layout.FillLayout)19 SelectionEvent (org.eclipse.swt.events.SelectionEvent)18 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)14 Control (org.eclipse.swt.widgets.Control)13 Group (org.eclipse.swt.widgets.Group)13 ControlEvent (org.eclipse.swt.events.ControlEvent)10 Rectangle (org.eclipse.swt.graphics.Rectangle)9 HistoryComposite (com.cubrid.cubridmanager.ui.monitoring.editor.internal.HistoryComposite)8 ArrayList (java.util.ArrayList)7 Combo (org.eclipse.swt.widgets.Combo)7 Image (org.eclipse.swt.graphics.Image)6 FormAttachment (org.eclipse.swt.layout.FormAttachment)6