private void ensureVisible(IFocusSelectable segment) { if (mouseFocus) { mouseFocus = false; return; } if (segment == null) return; Rectangle bounds = segment.getBounds(); ScrolledComposite scomp = FormUtil.getScrolledComposite(this); if (scomp == null) return; Point origin = FormUtil.getControlLocation(scomp, this); origin.x += bounds.x; origin.y += bounds.y; FormUtil.ensureVisible(scomp, origin, new Point(bounds.width, bounds.height)); }
public static Text createText(Composite parent, String label, FormToolkit factory) { return createText(parent, label, factory, 1); }
public static boolean mnemonicMatch(String text, char key) { char mnemonic = findMnemonic(text); if (mnemonic == '\0') return false; return Character.toUpperCase(key) == Character.toUpperCase(mnemonic); }
public static void ensureVisible(Control c) { ScrolledComposite scomp = getScrolledComposite(c); if (scomp != null) { Object data = scomp.getData(FOCUS_SCROLLING); if (data == null || !data.equals(Boolean.FALSE)) FormUtil.ensureVisible(scomp, c); } }
public static void ensureVisible(ScrolledComposite scomp, Control control) { // if the control is a FormText we do not need to scroll since it will // ensure visibility of its segments as necessary if (control instanceof FormText) return; Point controlSize = control.getSize(); Point controlOrigin = getControlLocation(scomp, control); ensureVisible(scomp, controlOrigin, controlSize); }
return; ScrolledComposite scomp = FormUtil.getScrolledComposite(c); if (scomp != null) { if (c instanceof Combo) case SWT.ARROW_DOWN: if (scomp.getData("novarrows") == null) //$NON-NLS-1$ FormUtil.scrollVertical(scomp, false); break; case SWT.ARROW_UP: if (scomp.getData("novarrows") == null) //$NON-NLS-1$ FormUtil.scrollVertical(scomp, true); break; case SWT.ARROW_LEFT: FormUtil.scrollHorizontal(scomp, true); break; case SWT.ARROW_RIGHT: FormUtil.scrollHorizontal(scomp, false); break; case SWT.PAGE_UP: FormUtil.scrollPage(scomp, true); break; case SWT.PAGE_DOWN: FormUtil.scrollPage(scomp, false); break;
/** * A utility method that ensures that the control is visible in the scrolled * composite. The prerequisite for this method is that the control has a * class that extends ScrolledComposite somewhere in the parent chain. If * the control is partially or fully clipped, the composite is scrolled to * set by setting the origin to the control origin. * * @param c * the control to make visible * @param verticalOnly * if <code>true</code>, the scrolled composite will be * scrolled only vertically if needed. Otherwise, the scrolled * composite origin will be set to the control origin. * @since 3.1 */ public static void setControlVisible(Control c, boolean verticalOnly) { ScrolledComposite scomp = FormUtil.getScrolledComposite(c); if (scomp == null) return; Point location = FormUtil.getControlLocation(scomp, c); scomp.setOrigin(location); }
/** * A helper method that ensures the provided control is visible when * ScrolledComposite is somewhere in the parent chain. If scroll bars are * visible and the control is clipped, the client of the scrolled composite * will be scrolled to reveal the control. * * @param c * the control to reveal */ public static void ensureVisible(Control c) { FormUtil.ensureVisible(c); }
if (tcsize.x > 0 && FormUtil.isWrapControl(textClient)) { size = textLabelCache.computeSize(SWT.DEFAULT, SWT.DEFAULT); if (innertHint != SWT.DEFAULT && innertHint < size.x + IGAP + tcsize.x) { if (textLabel instanceof Label) { GC gc = new GC(textLabel); size = FormUtil.computeWrapSize(gc, ((Label)textLabel).getText(), Math.round(innertHint*(size.x/(float)(size.x+tcsize.x)))); gc.dispose(); } else Point csize = clientCache.computeSize(FormUtil.getWidthHint( cwHint, client), SWT.DEFAULT); if (getDescriptionControl() != null) {
public static void setFocusScrollingEnabled(Control c, boolean enabled) { ScrolledComposite scomp = null; if (c instanceof ScrolledComposite) scomp = (ScrolledComposite)c; else scomp = getScrolledComposite(c); if (scomp!=null) scomp.setData(FormUtil.FOCUS_SCROLLING, enabled?null:Boolean.FALSE); }
public static void ensureVisible(ScrolledComposite scomp, Control control, MouseEvent e) { Point controlOrigin = getControlLocation(scomp, control); int rX = controlOrigin.x + e.x; int rY = controlOrigin.y + e.y;
public static void paintWrapText(GC gc, String text, Rectangle bounds) { paintWrapText(gc, text, bounds, false); }
return computeWrapSize(gc, text, maxWidth); return new Point(maxWidth, height);
if (tcsize.x > 0 && FormUtil.isWrapControl(textClient)) { size = textLabelCache.computeSize(SWT.DEFAULT, SWT.DEFAULT); if (twidth < size.x + IGAP + tcsize.x) { if (textLabel instanceof Label) { GC gc = new GC(textLabel); size = FormUtil.computeWrapSize(gc, ((Label)textLabel).getText(), Math.round(twidth*(size.x/(float)(size.x+tcsize.x)))); gc.dispose(); } else
private void startSelection(MouseEvent e) { inSelection = true; selData = new SelectionData(e); redraw(); Form form = FormUtil.getForm(this); if (form != null) form.setSelectionText(this); }
private Image getSelectedImage(Hashtable<String, Object> objectTable, SelectionData selData) { String key = SEL_IMAGE_PREFIX + getObjectId(); Image image = getImage(key, objectTable); if (image==null) { image = FormUtil.createAlphaMashImage(selData.display, getImage(objectTable)); if (image!=null) objectTable.put(key, image); } return image; } /*
@Override public void keyTraversed(TraverseEvent e) { if (e.detail == SWT.TRAVERSE_MNEMONIC) { // steal the mnemonic if (!isVisible() || !isEnabled()) return; if (FormUtil.mnemonicMatch(getText(), e.character)) { e.doit = false; if (!isFixedStyle()) { programmaticToggleState(); } setFocus(); } } } });
return; ScrolledComposite scomp = FormUtil.getScrolledComposite(c); if (scomp != null) { if (c instanceof Combo) case SWT.ARROW_DOWN: if (scomp.getData("novarrows") == null) //$NON-NLS-1$ FormUtil.scrollVertical(scomp, false); break; case SWT.ARROW_UP: if (scomp.getData("novarrows") == null) //$NON-NLS-1$ FormUtil.scrollVertical(scomp, true); break; case SWT.ARROW_LEFT: FormUtil.scrollHorizontal(scomp, true); break; case SWT.ARROW_RIGHT: FormUtil.scrollHorizontal(scomp, false); break; case SWT.PAGE_UP: FormUtil.scrollPage(scomp, true); break; case SWT.PAGE_DOWN: FormUtil.scrollPage(scomp, false); break;
public static void ensureVisible(Control c) { ScrolledComposite scomp = getScrolledComposite(c); if (scomp != null) { Object data = scomp.getData(FOCUS_SCROLLING); if (data == null || !data.equals(Boolean.FALSE)) FormUtil.ensureVisible(scomp, c); } }
public static void ensureVisible(ScrolledComposite scomp, Control control) { // if the control is a FormText we do not need to scroll since it will // ensure visibility of its segments as necessary if (control instanceof FormText) return; Point controlSize = control.getSize(); Point controlOrigin = getControlLocation(scomp, control); ensureVisible(scomp, controlOrigin, controlSize); }