/** * Set the image shown in this control decoration. Update the rendered * decoration. * * @param image * the image to be shown adjacent to the control. Should never be * <code>null</code>. */ public void setImage(Image image) { previousDecorationRectangle = getDecorationRectangle(control.getShell()); this.image = image; update(); }
/** * Set the image shown in this control decoration. Update the rendered * decoration. * * @param image * the image to be shown adjacent to the control. Should never be * <code>null</code>. */ public void setImage(Image image) { previousDecorationRectangle = getDecorationRectangle(control.getShell()); this.image = image; update(); }
/** * Set the margin width in pixels that should be used between the decorator * and the horizontal edge of the control. The default value of this setting * is <code>0</code>. * * @param marginWidth * the number of pixels that should be reserved between the * horizontal edge of the control and the adjacent edge of the * decoration. */ public void setMarginWidth(int marginWidth) { previousDecorationRectangle = getDecorationRectangle(control.getShell()); this.marginWidth = marginWidth; update(); }
/** * Set the margin width in pixels that should be used between the decorator * and the horizontal edge of the control. The default value of this setting * is <code>0</code>. * * @param marginWidth * the number of pixels that should be reserved between the * horizontal edge of the control and the adjacent edge of the * decoration. */ public void setMarginWidth(int marginWidth) { previousDecorationRectangle = getDecorationRectangle(control.getShell()); this.marginWidth = marginWidth; update(); }
private void notifyMenuDetectListeners(Event event) { if (getDecorationRectangle(null).contains(event.x, event.y)) { MenuDetectEvent clientEvent = new MenuDetectEvent(event); clientEvent.data = this; for (MenuDetectListener l : menuDetectListeners) { l.menuDetected(clientEvent); } } }
private void notifyMenuDetectListeners(Event event) { if (getDecorationRectangle(null).contains(event.x, event.y)) { MenuDetectEvent clientEvent = new MenuDetectEvent(event); clientEvent.data = this; Object[] listeners = menuDetectListeners.getListeners(); for (int i = 0; i < listeners.length; i++) { ((MenuDetectListener) listeners[i]).menuDetected(clientEvent); } } }
/** * Something has changed, requiring redraw. Redraw the decoration and update * the hover text if appropriate. */ protected void update() { if (control == null || control.isDisposed()) { return; } Rectangle rect = getDecorationRectangle(control.getShell()); // If this update is happening due to an image reset, we need to make // sure we clear the area from the old image. // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=212501 if (previousDecorationRectangle != null) { rect = rect.union(previousDecorationRectangle); } // Redraw this rectangle in all children control.getShell() .redraw(rect.x, rect.y, rect.width, rect.height, true); control.getShell().update(); if (hover != null && getDescriptionText() != null) { hover.setText(getDescriptionText(), getDecorationRectangle(control .getParent()), control); } previousDecorationRectangle = null; }
/** * Something has changed, requiring redraw. Redraw the decoration and update * the hover text if appropriate. */ protected void update() { if (control == null || control.isDisposed()) { return; } Rectangle rect = getDecorationRectangle(control.getShell()); // If this update is happening due to an image reset, we need to make // sure we clear the area from the old image. // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=212501 if (previousDecorationRectangle != null) { rect = rect.union(previousDecorationRectangle); } // Redraw this rectangle in all children control.getShell() .redraw(rect.x, rect.y, rect.width, rect.height, true); control.getShell().update(); if (hover != null && getDescriptionText() != null) { hover.setText(getDescriptionText(), getDecorationRectangle(control .getParent()), control); } previousDecorationRectangle = null; }
@Override public void mouseHover(MouseEvent event) { if (showHover) { decorationRectangle = getDecorationRectangle((Control) event.widget); if (decorationRectangle.contains(event.x, event.y)) { showHoverText(getDescriptionText()); Control target = (Control) event.widget; if (moveListeningTarget == null) { printAddListener(target, "MOUSEMOVE"); //$NON-NLS-1$ target.addMouseMoveListener(mouseMoveListener); moveListeningTarget = target; } else if (target != moveListeningTarget) { printRemoveListener(moveListeningTarget, "MOUSEMOVE"); //$NON-NLS-1$ moveListeningTarget .removeMouseMoveListener(mouseMoveListener); printAddListener(target, "MOUSEMOVE"); //$NON-NLS-1$ target.addMouseMoveListener(mouseMoveListener); moveListeningTarget = target; } else { // It is already installed on this control. } } } }
@Override public void mouseHover(MouseEvent event) { if (showHover) { decorationRectangle = getDecorationRectangle((Control) event.widget); if (decorationRectangle.contains(event.x, event.y)) { showHoverText(getDescriptionText()); Control target = (Control) event.widget; if (moveListeningTarget == null) { printAddListener(target, "MOUSEMOVE"); //$NON-NLS-1$ target.addMouseMoveListener(mouseMoveListener); moveListeningTarget = target; } else if (target != moveListeningTarget) { printRemoveListener(moveListeningTarget, "MOUSEMOVE"); //$NON-NLS-1$ moveListeningTarget .removeMouseMoveListener(mouseMoveListener); printAddListener(target, "MOUSEMOVE"); //$NON-NLS-1$ target.addMouseMoveListener(mouseMoveListener); moveListeningTarget = target; } else { // It is already installed on this control. } } } }
hover = new Hover(hoverNear.getShell()); hover.setText(text, getDecorationRectangle(control.getParent()), control); hover.setVisible(true);
hover = new Hover(hoverNear.getShell()); hover.setText(text, getDecorationRectangle(control.getParent()), control); hover.setVisible(true);
private void notifySelectionListeners(Event event) { if (!(event.widget instanceof Control)) { return; } if (getDecorationRectangle((Control) event.widget).contains(event.x, event.y)) { SelectionEvent clientEvent = new SelectionEvent(event); clientEvent.data = this; if (getImage() != null) { clientEvent.height = getImage().getBounds().height; clientEvent.width = getImage().getBounds().width; } switch (event.type) { case SWT.MouseDoubleClick: if (event.button == 1) { for (SelectionListener l : selectionListeners) { l.widgetDefaultSelected(clientEvent); } } break; case SWT.MouseDown: if (event.button == 1) { for (SelectionListener l : selectionListeners) { l.widgetSelected(clientEvent); } } break; } } }
return; if (getDecorationRectangle((Control) event.widget).contains(event.x, event.y)) { SelectionEvent clientEvent = new SelectionEvent(event);
Rectangle rect = getDecorationRectangle(control); if (shouldShowDecoration()) { event.gc.drawImage(getImage(), rect.x, rect.y);
Rectangle rect = getDecorationRectangle(control); if (shouldShowDecoration()) { event.gc.drawImage(getImage(), rect.x, rect.y);