private void scheduleReflow(final boolean flushCache) { if (delayedReflow) { if (reflowPending) { updateSizeWhilePending(); return; } reflowPending = true; getDisplay().asyncExec(() -> { reflowPending = false; if (!isDisposed()) reflow(flushCache); }); } else reflow(flushCache); }
/** * Creates a scrolled composite * * @param parent the parent to add to * @param columns the number of columns for the composite * @param hspan the horizontal span to take up in the parent * @param marginwidth the width of the margins * @param marginheight the height of the margins * @return a new scrolled composite */ public static SharedScrolledComposite createScrolledComposite(Composite parent, int columns, int hspan, int marginwidth, int marginheight) { SharedScrolledComposite comp = new SharedScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL) {}; GridLayout layout = new GridLayout(columns, false); layout.marginHeight = marginheight; layout.marginWidth = marginwidth; comp.setLayout(layout); GridData gd = new GridData(GridData.FILL_BOTH); gd.horizontalSpan = hspan; comp.setLayoutData(gd); comp.setExpandHorizontal(true); comp.setExpandVertical(true); return comp; }
/** * Creates the new instance. * * @param parent * the parent composite * @param style * the style to use */ public SharedScrolledComposite(Composite parent, int style) { super(parent, style); addListener(SWT.Resize, e -> { if (!ignoreResizes) { scheduleReflow(false); } }); initializeScrollBars(); }
@Override public void run() { reflowPending = false; if (!isDisposed()) reflow(flushCache); } });
Composite c = (Composite) getContent(); Rectangle clientArea = getClientArea(); if (c == null) return; if (clientArea.width == getSize().x) { ScrollBar bar = getVerticalBar(); if (bar != null) { clientArea.width -= bar.getSize().x; setMinSize(newSize); FormUtil.updatePageIncrement(this); ScrollBar vbar = getVerticalBar(); if (vbar != null) { if (getClientArea().height - 5 < V_SCROLL_INCREMENT) getVerticalBar().setIncrement(getClientArea().height - 5); else getVerticalBar().setIncrement(V_SCROLL_INCREMENT); layout(flushCache); ignoreLayouts = true;
private void scheduleReflow(final boolean flushCache) { if (delayedReflow) { if (reflowPending) { updateSizeWhilePending(); return; } reflowPending = true; getDisplay().asyncExec(new Runnable() { @Override public void run() { reflowPending = false; if (!isDisposed()) reflow(flushCache); } }); } else reflow(flushCache); }
/** * Overrides 'super' to pass the proper colors and font */ @Override public void setContent(Control content) { super.setContent(content); if (content != null) { content.setForeground(getForeground()); content.setBackground(getBackground()); content.setFont(getFont()); } }
private void updateSizeWhilePending() { Control c = getContent(); Rectangle area = getClientArea(); setMinSize(area.width, c.getSize().y); }
/** * Sets the font of the form. This font will be used to render the title * text. It will not affect the body. */ @Override public void setFont(Font font) { super.setFont(font); if (getContent() != null) getContent().setFont(font); }
/** * Creates the new instance. * * @param parent * the parent composite * @param style * the style to use */ public SharedScrolledComposite(Composite parent, int style) { super(parent, style); addListener(SWT.Resize, new Listener() { @Override public void handleEvent(Event e) { if (!ignoreResizes) { scheduleReflow(false); } } }); initializeScrollBars(); }
private void reflow() { Composite parent = section.getParent(); while (parent != null) { if (parent instanceof SharedScrolledComposite) { ((SharedScrolledComposite) parent).reflow(true); return; } parent = parent.getParent(); } }
Composite c = (Composite) getContent(); Rectangle clientArea = getClientArea(); if (c == null) return; if (clientArea.width == getSize().x) { ScrollBar bar = getVerticalBar(); if (bar != null) { clientArea.width -= bar.getSize().x; setMinSize(new Point(controlWidth, controlHeight)); FormUtil.updatePageIncrement(this); ScrollBar vbar = getVerticalBar(); if (vbar != null) { if (getClientArea().height - 5 < V_SCROLL_INCREMENT) getVerticalBar().setIncrement(getClientArea().height - 5); else getVerticalBar().setIncrement(V_SCROLL_INCREMENT); layout(flushCache); ignoreLayouts = true;
/** * Overrides 'super' to pass the proper colors and font */ @Override public void setContent(Control content) { super.setContent(content); if (content != null) { content.setForeground(getForeground()); content.setBackground(getBackground()); content.setFont(getFont()); } }
private void updateSizeWhilePending() { Control c = getContent(); Rectangle area = getClientArea(); setMinSize(area.width, c.getSize().y); }
/** * Sets the foreground of the control and its content. * * @param fg * the new foreground color */ @Override public void setForeground(Color fg) { super.setForeground(fg); if (getContent() != null) getContent().setForeground(fg); }
void reflow() { Composite c = this; while (c != null) { c.setRedraw(false); c = c.getParent(); if (c instanceof SharedScrolledComposite || c instanceof Shell) { break; } } c = this; while (c != null) { c.requestLayout(); c = c.getParent(); if (c instanceof SharedScrolledComposite) { ((SharedScrolledComposite) c).reflow(true); break; } } c = this; while (c != null) { c.setRedraw(true); c = c.getParent(); if (c instanceof SharedScrolledComposite || c instanceof Shell) { break; } } } }
/** * Creates a scrolled composite * * @param parent the parent to add to * @param style the style bits for the composite * @param columns the number of columns for the composite * @param hspan the horizontal span to take up in the parent * @param marginwidth the width of the margins * @param marginheight the height of the margins * @return a new scrolled composite */ public static SharedScrolledComposite createScrolledComposite(Composite parent, int style, int columns, int hspan, int marginwidth, int marginheight) { SharedScrolledComposite comp = new SharedScrolledComposite(parent, style) {}; GridLayout layout = new GridLayout(columns, false); layout.marginHeight = marginheight; layout.marginWidth = marginwidth; comp.setLayout(layout); GridData gd = new GridData(GridData.FILL_BOTH); gd.horizontalSpan = hspan; comp.setLayoutData(gd); comp.setExpandHorizontal(true); comp.setExpandVertical(true); return comp; }
/** * Sets the background of the control and its content. * * @param bg * the new background color */ @Override public void setBackground(Color bg) { super.setBackground(bg); if (getContent() != null) getContent().setBackground(bg); }
c = c.getParent(); if (c instanceof SharedScrolledComposite) { ((SharedScrolledComposite) c).reflow(true); break;
/** * Creates a scrolled composite * * @param parent the parent to add to * @param columns the number of columns for the composite * @param hspan the horizontal span to take up in the parent * @param marginwidth the width of the margins * @param marginheight the height of the margins * @return a new scrolled composite */ public static SharedScrolledComposite createScrolledComposite(Composite parent, int columns, int hspan, int marginwidth, int marginheight) { SharedScrolledComposite comp = new SharedScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL) {}; GridLayout layout = new GridLayout(columns, false); layout.marginHeight = marginheight; layout.marginWidth = marginwidth; comp.setLayout(layout); GridData gd = new GridData(GridData.FILL_BOTH); gd.horizontalSpan = hspan; comp.setLayoutData(gd); comp.setExpandHorizontal(true); comp.setExpandVertical(true); return comp; }