Example usage for org.eclipse.swt.widgets Composite Composite

List of usage examples for org.eclipse.swt.widgets Composite Composite

Introduction

In this page you can find the example usage for org.eclipse.swt.widgets Composite Composite.

Prototype

public Composite(Composite parent, int style) 

Source Link

Document

Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.

Usage

From source file:PrintKTableExample.java

/**
 * @param parent/* w  w  w . ja  va2 s .c  om*/
 * @param title
 * @param icon
 */
public PrintPreview(Shell parent, String title, Image icon, PDocument doc) {
    super(parent, title, icon);
    createContents();
    document = doc;
    page = 1;
    percent = 100;
    layoutNeccessary = true;

    addToolItem("print", "Drucken ...", IconSource.getImage("print"));
    addToolItem("first", "erste Seite", IconSource.getImage("i2"));
    addToolItem("prev", "vorherige Seite", IconSource.getImage("i3"));
    addToolItem("next", "nachste Seite", IconSource.getImage("i4"));
    addToolItem("last", "letzte Seite", IconSource.getImage("i5"));
    Button close = addButtonRight("&SchlieBen", "");
    // addButtonRight("Seite &einrichten","");
    close.setFocus();

    guiShell.addShellListener(new ShellAdapter() {
        public void shellClosed(ShellEvent arg0) {
            onClose();
        }
    });

    Composite comp = new Composite(guiToolBarArea, SWT.BORDER);
    comp.setLayout(new FillLayout());
    guiPageLabel = new CLabel(comp, SWT.NONE);
    guiPageLabel.setText(guiPageLabel.getText() + "        ");
    guiPageLabel.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
    adjustToToolBar(comp);

    guiZoom = new Combo(guiToolBarArea, SWT.BORDER | SWT.READ_ONLY);
    guiZoom.add("500%");
    guiZoom.add("200%");
    guiZoom.add("100%");
    guiZoom.add("80%");
    guiZoom.add("50%");
    guiZoom.add("20%");
    guiZoom.add("passend");
    adjustToToolBar(guiZoom);
    guiZoom.setToolTipText("VorschaugroBe");
    guiZoom.select(2);
    guiZoom.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent arg0) {
            onCombo(((Combo) arg0.widget).getText());
        }
    });
    guiMainArea.setLayout(new FillLayout());
    guiScrollArea = new ScrolledComposite(guiMainArea, SWT.H_SCROLL | SWT.V_SCROLL);
    guiImageLabel = new Label(guiScrollArea, SWT.NONE);
    guiScrollArea.setContent(guiImageLabel);
    if (guiImageLabel.getImage() != null)
        guiImageLabel.getImage().dispose();
    guiImageLabel.setImage(getPageImage(page));
    guiPageLabel.setText(" Seite " + page + " von " + document.getNumOfPages() + "       ");
    guiImageLabel.setSize(guiImageLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT));

}

From source file:org.eclipse.swt.examples.controlexample.Tab.java

/**
 * Creates the tab folder page./* w ww  .  j  a va2  s  .  com*/
 *
 * @param tabFolder org.eclipse.swt.widgets.TabFolder
 * @return the new page for the tab folder
 */
Composite createTabFolderPage(TabFolder tabFolder) {
    /* Cache the shell and display. */
    shell = tabFolder.getShell();
    display = shell.getDisplay();

    /* Create a two column page. */
    tabFolderPage = new Composite(tabFolder, SWT.NONE);
    tabFolderPage.setLayout(new GridLayout(2, false));

    /* Create the "Example" and "Control" groups. */
    createExampleGroup();
    createControlGroup();

    /* Create the "Listeners" group under the "Control" group. */
    createListenersGroup();

    /* Create and initialize the example and control widgets. */
    createExampleWidgets();
    hookExampleWidgetListeners();
    createControlWidgets();
    setExampleWidgetState();

    return tabFolderPage;
}

From source file:CustomControlExample.java

/**
 * Creates the tab folder page.//w w w. ja va 2 s . c  o  m
 * 
 * @param tabFolder
 *            org.eclipse.swt.widgets.TabFolder
 * @return the new page for the tab folder
 */
Composite createTabFolderPage(TabFolder tabFolder) {
    /*
     * Create a two column page.
     */
    tabFolderPage = new Composite(tabFolder, SWT.NONE);
    tabFolderPage.setLayout(new GridLayout(2, false));

    /* Create the "Example" and "Control" groups. */
    createExampleGroup();
    createControlGroup();

    /* Create the "Listeners" group under the "Control" group. */
    createListenersGroup();

    /* Create and initialize the example and control widgets. */
    createExampleWidgets();
    hookExampleWidgetListeners();
    createControlWidgets();
    setExampleWidgetState();

    return tabFolderPage;
}

From source file:PrintKTableExample.java

protected void createContents() {
    guiMainArea.setLayout(new FillLayout());
    root = new Composite(guiMainArea, SWT.NONE);
    final GridLayout gridLayout = new GridLayout();
    gridLayout.verticalSpacing = 10;//  w w  w . j a  v  a2s  . com
    gridLayout.numColumns = 2;
    root.setLayout(gridLayout);

    {
        final Label l = new Label(root, SWT.NONE);
        l.setText("Papierformat:");
        final GridData gridData_2 = new GridData();
        gridData_2.widthHint = 80;
        l.setLayoutData(gridData_2);
    }
    {
        combFormat = new Combo(root, SWT.BORDER | SWT.READ_ONLY);
        combFormat.setToolTipText(
                "Bestimmt die PapiergroBe. Diese muss mit der Druckereinstellung ubereinstimmen.");
        for (int i = 0; i < formatNames.length; i++) {
            combFormat.add(formatNames[i]);
        }
        combFormat.setText(format);

        final GridData gridData_1 = new GridData(GridData.FILL_HORIZONTAL);
        gridData_1.widthHint = 180;
        combFormat.setLayoutData(gridData_1);
    }
    {
        final Label label = new Label(root, SWT.NONE);
        label.setText("Seitenrander:");
        label.setLayoutData(new GridData(GridData.FILL_BOTH));
    }
    {
        cmbMargin = new Combo(root, SWT.READ_ONLY);
        cmbMargin.setToolTipText("Bestimmt die Breite der Rander.");
        cmbMargin.add("Schmale Rander");
        cmbMargin.add("Normale Rander");
        cmbMargin.add("Breite Rander");
        cmbMargin.select(marginStyle);
        cmbMargin.setLayoutData(new GridData(GridData.FILL_BOTH));
    }
    {
        final Label label = new Label(root, SWT.NONE);
        final GridData gridData = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
        gridData.horizontalSpan = 1;
        label.setLayoutData(gridData);
        label.setText("Ausrichtung:");
    }
    {
        butPortrait = new Button(root, SWT.RADIO);
        butPortrait.setToolTipText(
                "Bestimmt, ob das Papier hochkant oder Breit bedruckt werden soll. \nDiese Einstellung muss mit der des Druckers ubereinstimmen");
        butPortrait.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
        butPortrait.setText("Hochformat");
        butPortrait.setSelection(portrait);
    }
    {
        final Label label = new Label(root, SWT.NONE);
    }
    {
        butLandscape = new Button(root, SWT.RADIO);
        butLandscape.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
        butLandscape.setText("Breitformat");
        butLandscape.setSelection(!portrait);
        butLandscape.setToolTipText(
                "Bestimmt, ob das Papier hochkant oder quer bedruckt werden soll. \nDiese Einstellung muss mit der des Druckers ubereinstimmen");
    }
    {
        final Label label = new Label(root, SWT.NONE);
        label.setText("Skalierung:");
        label.setLayoutData(new GridData(GridData.FILL_BOTH));
    }
    {
        cmbScalierung = new Combo(root, SWT.READ_ONLY);
        cmbScalierung.setItems(scalings);
        cmbScalierung.select(10 - (scaling / 10));
        cmbScalierung.setLayoutData(new GridData(GridData.FILL_BOTH));
        cmbScalierung.setToolTipText(
                "Hiermit konnen Sie dir GroBe des Ausdrucks veringern, so daB mehr auf eine Seite passt.");
    }

}

From source file:PrintKTableExample.java

protected void createShellComposits() {

    // picture area
    guiPictureArea = new Composite(guiShell, SWT.NONE);
    guiPictureGridData = new GridData();
    guiPictureGridData.grabExcessHorizontalSpace = true;
    guiPictureGridData.horizontalAlignment = GridData.FILL;
    guiPictureGridData.heightHint = 0;//from w ww.  j  a v  a  2  s  .co  m
    guiPictureArea.setLayoutData(guiPictureGridData);

    // ToolBar area
    guiToolBarArea = new Composite(guiShell, SWT.NONE);
    guiToolBarGridData = new GridData();
    guiToolBarGridData.grabExcessHorizontalSpace = true;
    guiToolBarGridData.horizontalAlignment = GridData.FILL;
    guiToolBarGridData.heightHint = 0;
    guiToolBarArea.setLayoutData(guiToolBarGridData);

    // main area
    guiMainArea = new Composite(guiShell, SWT.NONE);
    createMainAreaLayout();
    GridData gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = GridData.FILL;
    gd.grabExcessVerticalSpace = true;
    gd.verticalAlignment = GridData.FILL;
    guiMainArea.setLayoutData(gd);

    // button area
    createButtonBar();
}

From source file:PrintKTableExample.java

protected void createButtonBar() {
    // AuBeres Composite
    guiButtonArea = new Composite(guiShell, SWT.NONE);
    GridData gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = GridData.FILL;
    guiButtonArea.setLayoutData(gd);//  ww w.  j a v  a2  s  .  c  o m

    FormLayout butLayout = new FormLayout();
    guiButtonArea.setLayout(butLayout);

    // Trennlinie
    Label sep = new Label(guiButtonArea, SWT.SEPARATOR | SWT.HORIZONTAL);
    FormData fd = new FormData();
    fd.bottom = new FormAttachment(100, -32);
    fd.left = new FormAttachment(0, 0);
    fd.right = new FormAttachment(100, 0);
    sep.setLayoutData(fd);

}

From source file:CustomControlExample.java

/**
 * Creates the "Example" widgets./*from www . j a  v  a2  s  .  c  o m*/
 */
void createExampleWidgets() {
    /*
     * Create the page. This example does not use layouts.
     */
    sashComp = new Composite(sashGroup, SWT.BORDER);

    /* Create the list and text widgets */
    list1 = new List(sashComp, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
    list1.setItems(ListData0);
    list2 = new List(sashComp, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
    list2.setItems(ListData1);
    text = new Text(sashComp, SWT.MULTI | SWT.BORDER);
    text.setText(ControlExample.getResourceString("Multi_line"));

    /* Create the sashes */
    int style = getDefaultStyle();
    if (smoothButton.getSelection())
        style |= SWT.SMOOTH;
    vSash = new Sash(sashComp, SWT.VERTICAL | style);
    hSash = new Sash(sashComp, SWT.HORIZONTAL | style);

    /* Add the listeners */
    hSash.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            Rectangle rect = vSash.getParent().getClientArea();
            event.y = Math.min(Math.max(event.y, SASH_LIMIT), rect.height - SASH_LIMIT);
            if (event.detail != SWT.DRAG) {
                hSash.setBounds(event.x, event.y, event.width, event.height);
                layout();
            }
        }
    });
    vSash.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            Rectangle rect = vSash.getParent().getClientArea();
            event.x = Math.min(Math.max(event.x, SASH_LIMIT), rect.width - SASH_LIMIT);
            if (event.detail != SWT.DRAG) {
                vSash.setBounds(event.x, event.y, event.width, event.height);
                layout();
            }
        }
    });
    sashComp.addControlListener(new ControlAdapter() {
        public void controlResized(ControlEvent event) {
            resized();
        }
    });
}