/** * Sets the form's busy state. Busy form will display 'busy' animation in * the area of the title image. * * @param busy * the form's busy state * @since 3.2 */ public void setBusy(boolean busy) { head.setBusy(busy); }
/** * Adds support for dragging items out of the form title area via a user * drag-and-drop operation. * * @param operations * a bitwise OR of the supported drag and drop operation types ( * <code>DROP_COPY</code>,<code>DROP_LINK</code>, and * <code>DROP_MOVE</code>) * @param transferTypes * the transfer types that are supported by the drag operation * @param listener * the callback that will be invoked to set the drag data and to * cleanup after the drag and drop operation finishes * @see org.eclipse.swt.dnd.DND * @since 3.3 */ public void addTitleDragSupport(int operations, Transfer[] transferTypes, DragSourceListener listener) { head.addDragSupport(operations, transferTypes, listener); }
/** * Adds support for dropping items into the form title area via a user * drag-and-drop operation. * * @param operations * a bitwise OR of the supported drag and drop operation types ( * <code>DROP_COPY</code>,<code>DROP_LINK</code>, and * <code>DROP_MOVE</code>) * @param transferTypes * the transfer types that are supported by the drop operation * @param listener * the callback that will be invoked after the drag and drop * operation finishes * @see org.eclipse.swt.dnd.DND * @since 3.3 */ public void addTitleDropSupport(int operations, Transfer[] transferTypes, DropTargetListener listener) { head.addDropSupport(operations, transferTypes, listener); }
private void onPaint(GC gc) { if (!isSeparatorVisible() && getBackgroundImage() == null) return; Rectangle carea = getClientArea(); if (carea.width == 0 || carea.height == 0) { return; Image buffer = new Image(getDisplay(), carea.width, carea.height); buffer.setBackground(getBackground()); GC igc = new GC(buffer); igc.setBackground(getBackground()); igc.fillRectangle(0, 0, carea.width, carea.height); if (getBackgroundImage() != null) { if (gradientInfo != null) drawBackground(igc, carea.x, carea.y, carea.width, carea.height); else { Image bgImage = getBackgroundImage(); Rectangle ibounds = bgImage.getBounds(); drawBackground(igc, carea.x, carea.y, ibounds.width, ibounds.height); if (isSeparatorVisible()) { if (hasColor(IFormColors.H_BOTTOM_KEYLINE1)) igc.setForeground(getColor(IFormColors.H_BOTTOM_KEYLINE1)); else igc.setForeground(getBackground()); igc.drawLine(carea.x, carea.height - 2, carea.x + carea.width - 1, carea.height - 2); if (hasColor(IFormColors.H_BOTTOM_KEYLINE2))
setBackgroundMode(SWT.INHERIT_DEFAULT); addListener(SWT.Paint, e -> onPaint(e.gc)); addListener(SWT.Dispose, e -> { if (gradientImage != null) { FormImages.getInstance().markFinished(gradientImage, getDisplay()); gradientImage = null; addListener(SWT.Resize, e -> { if (gradientInfo != null || (backgroundImage != null && !isBackgroundImageTiled())) updateGradientImage(); }); addMouseMoveListener(e -> updateTitleRegionHoverState(e)); addMouseTrackListener(new MouseTrackListener() { @Override public void mouseEnter(MouseEvent e) {
private void updateGradientImage() { Rectangle rect = getBounds(); if (gradientImage != null) { FormImages.getInstance().markFinished(gradientImage, getDisplay()); gradientImage = null; } if (gradientInfo != null) { gradientImage = FormImages.getInstance().getGradient(gradientInfo.gradientColors, gradientInfo.percents, gradientInfo.vertical ? rect.height : rect.width, gradientInfo.vertical, getColor(COLOR_BASE_BG), getDisplay()); } else if (backgroundImage != null && !isBackgroundImageTiled()) { gradientImage = new Image(getDisplay(), Math.max(rect.width, 1), Math.max(rect.height, 1)); gradientImage.setBackground(getBackground()); GC gc = new GC(gradientImage); gc.drawImage(backgroundImage, 0, 0); gc.dispose(); } setBackgroundImage(gradientImage); }
public void setTextBackground(Color[] gradientColors, int[] percents, boolean vertical) { if (gradientColors != null) { gradientInfo = new GradientInfo(); gradientInfo.gradientColors = gradientColors; gradientInfo.percents = percents; gradientInfo.vertical = vertical; setBackground(null); updateGradientImage(); } else { // reset gradientInfo = null; if (gradientImage != null) { FormImages.getInstance().markFinished(gradientImage, getDisplay()); gradientImage = null; setBackgroundImage(null); } } }
try { FormHeading heading = (FormHeading) form.getHead(); heading.setBusy(true); heading.setBusy(false); titleLabel.setForeground(heading.getForeground()); titleLabel.setFont(heading.getFont()); titleLabel.addFocusListener(new FocusAdapter() { public void focusLost(FocusEvent e) { Image emptyImage = new Image(heading.getDisplay(), size.x, size.y); UIUtils.hookDisposal(titleLabel, emptyImage); busyLabel.setImage(emptyImage);
setBackgroundMode(SWT.INHERIT_DEFAULT); addListener(SWT.Paint, new Listener() { @Override public void handleEvent(Event e) { addListener(SWT.Dispose, new Listener() { @Override public void handleEvent(Event e) { addListener(SWT.Resize, new Listener() { @Override public void handleEvent(Event e) { addMouseMoveListener(new MouseMoveListener() { @Override public void mouseMove(MouseEvent e) { addMouseTrackListener(new MouseTrackListener() { @Override public void mouseEnter(MouseEvent e) {
/** * Returns the tool bar manager that is used to manage tool items in the * form's title area. * * @return form tool bar manager */ public IToolBarManager getToolBarManager() { if (toolBarManager == null) { toolBarManager = new ToolBarManager(SWT.FLAT); ToolBar toolbar = toolBarManager.createControl(this); toolbar.setBackground(getBackground()); toolbar.setForeground(getForeground()); toolbar.setCursor(FormsResources.getHandCursor()); addDisposeListener(new DisposeListener() { @Override public void widgetDisposed(DisposeEvent e) { if (toolBarManager != null) { toolBarManager.dispose(); toolBarManager = null; } } }); } return toolBarManager; }
/** * Creates the form content control as a child of the provided parent. * * @param parent * the parent widget */ public Form(Composite parent, int style) { super(parent, SWT.NO_BACKGROUND | style); super.setLayout(new FormLayout()); head = new FormHeading(this, SWT.NULL); head.setMenu(parent.getMenu()); body = new Composite(this, SWT.NULL); body.setMenu(parent.getMenu()); }
@Override public void handleEvent(Event e) { if (gradientImage != null) { FormImages.getInstance().markFinished(gradientImage, getDisplay()); gradientImage = null; } } });
/** * Adds a message hyperlink listener. If at least one listener is present, * messages will be rendered as hyperlinks. * * @param listener * @see #removeMessageHyperlinkListener(IHyperlinkListener) * @since 3.3 */ public void addMessageHyperlinkListener(IHyperlinkListener listener) { head.addMessageHyperlinkListener(listener); }
private void onPaint(GC gc) { if (!isSeparatorVisible() && getBackgroundImage() == null) return; Rectangle carea = getClientArea(); if (carea.width == 0 || carea.height == 0) { return; Image buffer = new Image(getDisplay(), carea.width, carea.height); buffer.setBackground(getBackground()); GC igc = new GC(buffer); igc.setBackground(getBackground()); igc.fillRectangle(0, 0, carea.width, carea.height); if (getBackgroundImage() != null) { if (gradientInfo != null) drawBackground(igc, carea.x, carea.y, carea.width, carea.height); else { Image bgImage = getBackgroundImage(); Rectangle ibounds = bgImage.getBounds(); drawBackground(igc, carea.x, carea.y, ibounds.width, ibounds.height); if (isSeparatorVisible()) { if (hasColor(IFormColors.H_BOTTOM_KEYLINE1)) igc.setForeground(getColor(IFormColors.H_BOTTOM_KEYLINE1)); else igc.setForeground(getBackground()); igc.drawLine(carea.x, carea.height - 2, carea.x + carea.width - 1, carea.height - 2); if (hasColor(IFormColors.H_BOTTOM_KEYLINE2))
private void updateGradientImage() { Rectangle rect = getBounds(); Image oldGradientImage = gradientImage; gradientImage = null; if (gradientInfo != null) { gradientImage = FormImages.getInstance().getGradient(gradientInfo.gradientColors, gradientInfo.percents, gradientInfo.vertical ? rect.height : rect.width, gradientInfo.vertical, getColor(COLOR_BASE_BG), getDisplay()); } else if (backgroundImage != null && !isBackgroundImageTiled()) { gradientImage = new Image(getDisplay(), Math.max(rect.width, 1), Math.max(rect.height, 1)); gradientImage.setBackground(getBackground()); GC gc = new GC(gradientImage); gc.drawImage(backgroundImage, 0, 0); gc.dispose(); } if (oldGradientImage != null) { FormImages.getInstance().markFinished(oldGradientImage, getDisplay()); } setBackgroundImage(gradientImage); }
public void setTextBackground(Color[] gradientColors, int[] percents, boolean vertical) { if (gradientColors != null) { gradientInfo = new GradientInfo(); gradientInfo.gradientColors = gradientColors; gradientInfo.percents = percents; gradientInfo.vertical = vertical; setBackground(null); updateGradientImage(); } else { // reset gradientInfo = null; if (gradientImage != null) { FormImages.getInstance().markFinished(gradientImage, getDisplay()); gradientImage = null; setBackgroundImage(null); } } }
/** * Returns the tool bar manager that is used to manage tool items in the * form's title area. * * @return form tool bar manager */ public IToolBarManager getToolBarManager() { if (toolBarManager == null) { toolBarManager = new ToolBarManager(SWT.FLAT); ToolBar toolbar = toolBarManager.createControl(this); toolbar.setBackground(getBackground()); toolbar.setForeground(getForeground()); toolbar.setCursor(FormsResources.getHandCursor()); addDisposeListener(e -> { if (toolBarManager != null) { toolBarManager.dispose(); toolBarManager.removeAll(); toolBarManager = null; } }); } return toolBarManager; }
/** * Creates the form content control as a child of the provided parent. * * @param parent * the parent widget */ public Form(Composite parent, int style) { super(parent, SWT.NO_BACKGROUND | style); super.setLayout(new FormLayout()); head = new FormHeading(this, SWT.NULL); head.setMenu(parent.getMenu()); body = new LayoutComposite(this, SWT.NULL); body.setMenu(parent.getMenu()); }
private void updateForeground() { Color theFg; switch (messageType) { case IMessageProvider.ERROR: theFg = getDisplay().getSystemColor(SWT.COLOR_RED); break; case IMessageProvider.WARNING: theFg = getDisplay().getSystemColor(SWT.COLOR_DARK_YELLOW); break; default: theFg = fg; } getMessageControl().setForeground(theFg); } }
/** * Adds a message hyperlink listener. If at least one listener is present, * messages will be rendered as hyperlinks. * * @param listener * @see #removeMessageHyperlinkListener(IHyperlinkListener) * @since 3.3 */ public void addMessageHyperlinkListener(IHyperlinkListener listener) { head.addMessageHyperlinkListener(listener); }