List of usage examples for org.eclipse.swt.widgets Composite getChildren
public Control[] getChildren()
From source file:org.eclipse.swt.examples.launcher.SplitLayout.java
private Point computeHSplitSize(Composite composite, int wHint, int hHint, boolean flushCache) { Point size = new Point(marginLeft + marginRight, marginTop + marginBottom); Control[] children = composite.getChildren(); for (Control child : children) { Point childSize = child.computeSize(wHint, hHint, flushCache); size.x = Math.max(size.x, childSize.x); size.y += childSize.y + spacing; }//from w w w . j av a2 s. com return size; }
From source file:org.eclipse.swt.examples.launcher.SplitLayout.java
private Point computeVSplitSize(Composite composite, int wHint, int hHint, boolean flushCache) { Point size = new Point(marginLeft + marginRight, marginTop + marginBottom); Control[] children = composite.getChildren(); for (Control child : children) { Point childSize = child.computeSize(wHint, hHint, flushCache); size.x += childSize.x + spacing; size.y = Math.max(size.y, childSize.y); }/* www . j av a 2 s .c o m*/ return size; }
From source file:org.eclipse.swt.examples.launcher.SplitLayout.java
/** * @see Layout#layout(Composite, boolean) *///from w ww . ja v a2 s . c o m @Override protected void layout(Composite composite, boolean flushCache) { Rectangle clientArea = composite.getClientArea(); computeSize(composite, clientArea.width, clientArea.height, false); Control[] children = composite.getChildren(); clientArea.x += marginLeft; clientArea.y += marginTop; clientArea.width -= marginRight + marginLeft; clientArea.height -= marginBottom + marginTop; Point position = new Point(clientArea.x, clientArea.y); for (Control child : children) { final Rectangle bounds; if (splitDirection == splitHorizontally) { int height = clientArea.height / children.length; bounds = new Rectangle(position.x, position.y, clientArea.width, height); position.y += height + spacing; } else { int width = clientArea.width / children.length; bounds = new Rectangle(position.x, position.y, width, clientArea.height); position.x += width + spacing; } bounds.width = Math.max(bounds.width, 0); bounds.height = Math.max(bounds.height, 0); child.setBounds(bounds); } }
From source file:YetAnotherBorderLayout.java
protected void getControls(Composite composite) { // Iterate through all the controls, setting // the member data according to the BorderData. // Note that we overwrite any previously set data. // Note also that we default to CENTER Control[] children = composite.getChildren(); for (int i = 0, n = children.length; i < n; i++) { Control child = children[i]; BorderData borderData = (BorderData) child.getLayoutData(); if (borderData == BorderData.NORTH) north = child;/*from w w w .ja va 2s . c om*/ else if (borderData == BorderData.SOUTH) south = child; else if (borderData == BorderData.EAST) east = child; else if (borderData == BorderData.WEST) west = child; else center = child; } }
From source file:org.eclipse.swt.examples.controlexample.Tab.java
/** * Creates the "Control" group. The "Control" group * is typically the right hand column in the tab. *///from w ww . ja va2s. c o m void createControlGroup() { /* * Create the "Control" group. This is the group on the * right half of each example tab. It consists of the * "Style" group, the "Other" group and the "Size" group. */ controlGroup = new Group(tabFolderPage, SWT.NONE); controlGroup.setLayout(new GridLayout(2, true)); controlGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); controlGroup.setText(ControlExample.getResourceString("Parameters")); /* Create individual groups inside the "Control" group */ createStyleGroup(); createOtherGroup(); createSetGetGroup(); createSizeGroup(); createColorAndFontGroup(); if (rtlSupport()) { createOrientationGroup(); createDirectionGroup(); } createBackgroundModeGroup(); /* * For each Button child in the style group, add a selection * listener that will recreate the example controls. If the * style group button is a RADIO button, ensure that the radio * button is selected before recreating the example controls. * When the user selects a RADIO button, the current RADIO * button in the group is deselected and the new RADIO button * is selected automatically. The listeners are notified for * both these operations but typically only do work when a RADIO * button is selected. */ SelectionListener selectionListener = widgetSelectedAdapter(event -> { if ((event.widget.getStyle() & SWT.RADIO) != 0) { if (!((Button) event.widget).getSelection()) return; } if (!handleTextDirection(event.widget)) { recreateExampleWidgets(); if (rtlSupport()) { /* Reflect the base direction falls back to the default (i.e. orientation). */ ltrDirectionButton.setSelection(false); rtlDirectionButton.setSelection(false); autoDirectionButton.setSelection(false); defaultDirectionButton.setSelection(true); } } }); Control[] children = styleGroup.getChildren(); for (Control child : children) { if (child instanceof Button) { Button button = (Button) child; button.addSelectionListener(selectionListener); } else { if (child instanceof Composite) { /* Look down one more level of children in the style group. */ Composite composite = (Composite) child; Control[] grandchildren = composite.getChildren(); for (Control grandchild : grandchildren) { if (grandchild instanceof Button) { Button button = (Button) grandchild; button.addSelectionListener(selectionListener); } } } } } if (rtlSupport()) { rtlButton.addSelectionListener(selectionListener); ltrButton.addSelectionListener(selectionListener); defaultOrietationButton.addSelectionListener(selectionListener); rtlDirectionButton.addSelectionListener(selectionListener); ltrDirectionButton.addSelectionListener(selectionListener); autoDirectionButton.addSelectionListener(selectionListener); defaultDirectionButton.addSelectionListener(selectionListener); } }