if (top == null) { top = new Composite(parent, SWT.NONE); top.setLayout(new TrimBarLayout(true)); top.addDisposeListener(e -> top = null); if (bottom == null) { bottom = new Composite(parent, SWT.NONE); bottom.setLayout(new TrimBarLayout(true)); bottom.addDisposeListener(e -> bottom = null); if (left == null) { left = new Composite(parent, SWT.NONE); left.setLayout(new TrimBarLayout(false)); left.addDisposeListener(e -> left = null); if (right == null) { right = new Composite(parent, SWT.NONE); right.setLayout(new TrimBarLayout(false)); right.addDisposeListener(e -> right = null);
protected void layout(Composite composite, boolean flushCache) { Rectangle bounds = composite.getBounds(); // offset the rectangle to allow for the margins bounds.x = marginLeft; bounds.y = marginTop; bounds.width -= (marginLeft + marginRight); bounds.height -= (marginTop + marginBottom); // If we were called directly we need to fill the caches if (lines.size() == 0) { if (horizontal) computeSize(composite, bounds.width, SWT.DEFAULT, true); else computeSize(composite, SWT.DEFAULT, bounds.height, true); } if (lines.size() == 0) return; for (TrimLine curLine : lines) { tileLine(curLine, bounds); if (horizontal) bounds.y += curLine.minor + wrapSpacing; else bounds.x += curLine.minor + wrapSpacing; } }
private Point computeSize(Control ctrl) { Point ctrlSize = ctrl.computeSize(SWT.DEFAULT, SWT.DEFAULT); // Hack! the StatusLine doesn't compute a useable size if (isStatusLine(ctrl)) { ctrlSize.x = 375; ctrlSize.y = 26; } return ctrlSize; }
.getData(AbstractPartRenderer.OWNING_ME); for (MTrimElement te : bar.getChildren()) { hideManagedTB(te); while (i < (kids.length - 2) && isGlue(kids[i + 1])) { segment.addControl(kids[i + 1]); segment.addControl(kids[i + 2]);
private MUIElement getInsertionElement(MUIElement dragElement, DnDInfo info) { Composite trimComp = (Composite) trimBar.getWidget(); // If we're over the trim bar itself drop at the end // May need to take margins into account if (info.curCtrl == trimComp) return null; TrimBarLayout tbl = (TrimBarLayout) trimComp.getLayout(); Point trimPos = trimComp.getDisplay().map(null, trimComp, info.cursorPos); Control trimCtrl = tbl.ctrlFromPoint(trimPos); if (trimCtrl == null) return null; if (trimCtrl == dragElement.getWidget()) return dragElement; // Are we closer to the 'end' of the trim control ? // If so insert before the next control (if any) MUIElement trimElement = (MUIElement) trimCtrl.getData(AbstractPartRenderer.OWNING_ME); if (isAfter(trimCtrl, info)) { MElementContainer<MUIElement> trimParent = trimElement.getParent(); int trimIndex = trimParent.getChildren().indexOf(trimElement); if (trimIndex == trimParent.getChildren().size() - 1) return null; return trimParent.getChildren().get(trimIndex + 1); } return trimElement; }
while (i < (kids.length - 2) && isGlue(kids[i + 1])) { segment.addControl(kids[i + 1]); segment.addControl(kids[i + 2]);
private MUIElement getInsertionElement(MUIElement dragElement, DnDInfo info) { Composite trimComp = (Composite) trimBar.getWidget(); // If we're over the trim bar itself drop at the end // May need to take margins into account if (info.curCtrl == trimComp) { return null; } TrimBarLayout tbl = (TrimBarLayout) trimComp.getLayout(); Point trimPos = trimComp.getDisplay().map(null, trimComp, info.cursorPos); Control trimCtrl = tbl.ctrlFromPoint(trimComp, trimPos); if (trimCtrl == null || dragElement.getWidget() == null) { return null; } if (trimCtrl == dragElement.getWidget()) { return dragElement; } // Are we closer to the 'end' of the trim control ? // If so insert before the next control (if any) MUIElement trimElement = (MUIElement) trimCtrl.getData(AbstractPartRenderer.OWNING_ME); if (isAfter(trimCtrl, info) && trimElement != null) { MElementContainer<MUIElement> trimParent = trimElement.getParent(); int trimIndex = trimParent.getChildren().indexOf(trimElement); if (trimIndex == trimParent.getChildren().size() - 1) { return null; } return trimParent.getChildren().get(trimIndex + 1); } return trimElement; }
@Override protected void layout(Composite composite, boolean flushCache) { if (flushCache) { // Clear the current cache lines.clear(); } Rectangle bounds = composite.getBounds(); // offset the rectangle to allow for the margins bounds.x = marginLeft; bounds.y = marginTop; bounds.width -= (marginLeft + marginRight); bounds.height -= (marginTop + marginBottom); // If we were called directly we need to fill the caches if (lines.isEmpty()) { if (horizontal) computeSize(composite, bounds.width, SWT.DEFAULT, true); else computeSize(composite, SWT.DEFAULT, bounds.height, true); } if (lines.isEmpty()) return; for (TrimLine curLine : lines) { tileLine(curLine, bounds); if (horizontal) bounds.y += curLine.minor + wrapSpacing; else bounds.x += curLine.minor + wrapSpacing; } }
if (top == null) { top = new Composite(parent, SWT.NONE); top.setLayout(new TrimBarLayout(true)); top.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { if (bottom == null) { bottom = new Composite(parent, SWT.NONE); bottom.setLayout(new TrimBarLayout(true)); bottom.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { if (left == null) { left = new Composite(parent, SWT.NONE); left.setLayout(new TrimBarLayout(false)); left.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { if (right == null) { right = new Composite(parent, SWT.NONE); right.setLayout(new TrimBarLayout(false)); right.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) {
private Point computeSize(Control ctrl) { Point ctrlSize = ctrl.computeSize(SWT.DEFAULT, SWT.DEFAULT); // Hack! the StatusLine doesn't compute a useable size if (isStatusLine(ctrl)) { ctrlSize.x = 375; ctrlSize.y = 26; } return ctrlSize; }
} else { trimComposite = new Composite(parentComp, SWT.NONE); trimComposite.setLayout(new TrimBarLayout(true));
} else { trimComposite = new Composite(parentComp, SWT.NONE); trimComposite.setLayout(new TrimBarLayout(true));