Example usage for com.google.gwt.dom.client Element getScrollWidth

List of usage examples for com.google.gwt.dom.client Element getScrollWidth

Introduction

In this page you can find the example usage for com.google.gwt.dom.client Element getScrollWidth.

Prototype

@Override
    public int getScrollWidth() 

Source Link

Usage

From source file:com.bearsoft.gwt.ui.containers.window.WindowPanel.java

@Override
public void maximize() {
    if (!maximized) {
        restoreSnapshot();/*from w w  w.j a  v  a 2  s .c o  m*/
        maximized = true;
        updateDecorCursors();
        snapshotMetrics();
        // editing
        Element movableElement = getMovableTarget().getElement();
        Style targetStyle = getWidget().getElement().getStyle(); // content
        int leftInset = getWidget().getElement().getAbsoluteLeft() - movableElement.getAbsoluteLeft();
        int rightInset = movableElement.getAbsoluteRight() - getWidget().getElement().getAbsoluteRight();
        int hInsets = leftInset + rightInset;
        int topInset = getWidget().getElement().getAbsoluteTop() - movableElement.getAbsoluteTop();
        int bottomInset = movableElement.getAbsoluteBottom() - getWidget().getElement().getAbsoluteBottom();
        int vInsets = topInset + bottomInset;
        Element parentElement = getMovableTarget().getParent().getElement();
        int parentScrollWidth = parentElement.getScrollWidth();
        int parentScrollHeight;
        if (parentElement == Document.get().getBody())// Some browsers
                                                      // return incorrect
                                                      // height for body
                                                      // element
        {
            parentScrollHeight = Document.get().getClientHeight();
        } else {
            parentScrollHeight = parentElement.getScrollHeight();
        }
        targetStyle.setWidth(parentScrollWidth - hInsets, Style.Unit.PX);
        targetStyle.setHeight(parentScrollHeight - vInsets, Style.Unit.PX);
        // editing
        targetStyle = movableElement.getStyle(); // window
        targetStyle.setLeft(0, Style.Unit.PX);
        targetStyle.setTop(0, Style.Unit.PX);
        onResize();
        MaximizeEvent.<WindowUI>fire(this, this);
    }
}

From source file:com.gwtm.ui.client.widgets.FlipSwitch.java

License:Apache License

private int getOffPosition() {
    Element flip = getFilpElement();
    Element parent = flip.getParentElement();
    int flipWidth = flip.getScrollWidth();
    int parentWidth = parent.getClientWidth();
    return parentWidth - flipWidth;
}

From source file:com.haulmont.cuba.web.widgets.client.addons.dragdroplayouts.ui.VLayoutDragDropMouseHandler.java

License:Apache License

private boolean isEventOnScrollBar(NativeEvent event) {
    Element element = Element.as(event.getEventTarget());
    ;/*  w w w  . java 2 s.  c  om*/

    if (WidgetUtil.mayHaveScrollBars(element)) {

        final int nativeScrollbarSize = WidgetUtil.getNativeScrollbarSize();

        int x = WidgetUtil.getTouchOrMouseClientX(event) - element.getAbsoluteLeft();
        int y = WidgetUtil.getTouchOrMouseClientY(event) - element.getAbsoluteTop();

        // Hopefully we have horizontal scroll.
        final int scrollWidth = element.getScrollWidth();
        final int clientWidth = element.getClientWidth();
        if (scrollWidth > clientWidth && clientWidth - nativeScrollbarSize < x) {
            return true;
        }

        // Hopefully we have vertical scroll.
        final int scrollHeight = element.getScrollHeight();
        final int clientHeight = element.getClientHeight();
        if (scrollHeight > clientHeight && clientHeight - nativeScrollbarSize < y) {
            return true;
        }

    }

    return false;
}

From source file:com.novartis.pcs.ontology.webapp.client.view.SVGView.java

License:Apache License

@Override
public void onViewTerm(ViewTermEvent event) {
    final Term term = event.getTerm();
    final Ontology ontology = term.getOntology();

    if (!ontology.isCodelist()) {
        service.loadSVG(term.getReferenceId(), new AsyncCallback<String>() {
            public void onFailure(Throwable caught) {
                GWT.log("Failed to load SVG", caught);
                ErrorView.instance().onUncaughtException(caught);
            }//from  w ww  .j  a va2  s.c  o  m

            public void onSuccess(String svg) {
                Element element = svgContainer.getElement();
                Element panelElement = panel.getElement();
                panelElement.setScrollLeft(0);
                panelElement.setScrollTop(0);
                element.setInnerHTML(svg);

                if (panelElement.getScrollWidth() > element.getClientWidth()
                        || panelElement.getScrollHeight() > element.getClientHeight()) {
                    scrollSVG(term.getReferenceId());
                }
            }
        });
    }
}

From source file:de.swm.commons.mobile.client.widgets.FlipSwitch.java

License:Apache License

/**
 * Returns the absolute off potion// ww  w  .  j a v a  2 s  .c  o m
 * 
 * @return the sreen postion
 */
private int getOffPosition() {
    Element flip = getFilpElement();
    Element parent = flip.getParentElement();
    int flipWidth = flip.getScrollWidth();
    int parentWidth = parent.getClientWidth();
    return parentWidth - flipWidth;
}

From source file:gwtquery.plugins.draggable.client.impl.DraggableHandlerImpl.java

License:Apache License

public int[] calculateContainment(DraggableHandler draggableHandler, Offset containerOffset,
        Element containerElement, boolean overflow) {

    Offset helperMargin = draggableHandler.getMargin();
    UiPlugin.Dimension helperDimension = draggableHandler.getHelperDimension();

    return new int[] {
            containerOffset.left + (int) $(containerElement).cur("borderLeftWidth", true)
                    + (int) $(containerElement).cur("paddingLeft", true) - helperMargin.left,
            containerOffset.top + (int) $(containerElement).cur("borderTopWidth", true)
                    + (int) $(containerElement).cur("paddingTop", true) - helperMargin.top,
            containerOffset.left/*from  w ww.  ja va 2 s  . c  o  m*/
                    + (overflow ? Math.max(containerElement.getScrollWidth(), containerElement.getOffsetWidth())
                            : containerElement.getOffsetWidth())
                    - (int) $(containerElement).cur("borderLeftWidth", true)
                    - (int) $(containerElement).cur("paddingRight", true) - helperDimension.getWidth()
                    - helperMargin.left,
            containerOffset.top
                    + (overflow
                            ? Math.max(containerElement.getScrollHeight(), containerElement.getOffsetHeight())
                            : containerElement.getOffsetHeight())
                    - (int) $(containerElement).cur("borderTopWidth", true)
                    - (int) $(containerElement).cur("paddingBottom", true) - helperDimension.getHeight()
                    - helperMargin.top };
}

From source file:gwtquery.plugins.draggable.client.impl.DraggableHandlerImplIE6.java

License:Apache License

@Override
public int[] calculateContainment(DraggableHandler draggableHandler, Offset containerOffset,
        Element containerElement, boolean overflow) {
    Dimension helperDimension = draggableHandler.getHelperDimension();
    // don't substract margin in ie 6 and 7
    return new int[] {
            containerOffset.left + (int) $(containerElement).cur("borderLeftWidth", true)
                    + (int) $(containerElement).cur("paddingLeft", true),
            containerOffset.top + (int) $(containerElement).cur("borderTopWidth", true)
                    + (int) $(containerElement).cur("paddingTop", true),
            containerOffset.left// w  w w  .  j a va 2s  .c o m
                    + (overflow ? Math.max(containerElement.getScrollWidth(), containerElement.getOffsetWidth())
                            : containerElement.getOffsetWidth())
                    - (int) $(containerElement).cur("borderLeftWidth", true)
                    - (int) $(containerElement).cur("paddingRight", true) - helperDimension.getWidth(),
            containerOffset.top
                    + (overflow
                            ? Math.max(containerElement.getScrollHeight(), containerElement.getOffsetHeight())
                            : containerElement.getOffsetHeight())
                    - (int) $(containerElement).cur("borderTopWidth", true)
                    - (int) $(containerElement).cur("paddingBottom", true) - helperDimension.getHeight() };
}

From source file:jetbrains.jetpad.cell.toDom.CellContainerToDomMapper.java

License:Apache License

private CellContainerPeer createCellContainerPeer() {
    return new CellContainerPeer() {
        @Override//from   ww  w. j ava  2  s.  co  m
        public int getCaretAt(TextCell tv, int x) {
            TextCellMapper textMapper = (TextCellMapper) getMapper(tv);
            if (textMapper == null) {
                throw new IllegalStateException("Can't find a mapper for " + tv);
            }
            return textMapper.getCaretAt(x);
        }

        @Override
        public int getCaretOffset(TextCell tv, int caret) {
            TextCellMapper textMapper = (TextCellMapper) getMapper(tv);
            if (textMapper == null) {
                throw new IllegalStateException("Can't find a mapper for " + tv);
            }
            return textMapper.getCaretOffset(caret);
        }

        @Override
        public Rectangle getBounds(Cell cell) {
            Rectangle result = getBaseBounds(cell);
            if (result == null) {
                result = new Rectangle(Vector.ZERO, Vector.ZERO);
            }
            return result;
        }

        private Rectangle getBaseBounds(Cell cell) {
            Mapper<? extends Cell, ? extends Element> mapper = getMapper(cell);
            if (mapper == null) {
                if (cell instanceof NewLineCell) {
                    return null;
                } else if (cell instanceof IndentCell) {
                    return Cells.indentBounds((IndentCell) cell);
                } else {
                    throw new IllegalStateException("Can't find a mapper for " + cell);
                }
            } else {
                Element target = getElement(cell);
                if (cell instanceof ScrollCell) {
                    return new Rectangle(target.getAbsoluteLeft(), target.getAbsoluteRight(),
                            target.getOffsetWidth(), target.getOffsetHeight());
                } else {
                    return new Rectangle(target.getAbsoluteLeft(), target.getAbsoluteTop(),
                            target.getScrollWidth(), target.getScrollHeight());
                }
            }
        }

        @Override
        public void scrollTo(Rectangle rect, Cell cell) {
            Scrolling.scrollTo(rect, getElement(cell));
        }

        @Override
        public Cell findCell(Cell root, Vector loc) {
            Element e = elementAt(loc.x - myScrollLeft, loc.y - myScrollTop);
            if (e == null)
                return null;
            Cell result = findCellFor(e);
            if (result == null)
                return null;
            if (Composites.isDescendant(root, result)) {
                return result;
            }
            return null;
        }

        private native Element elementAt(int x, int y) /*-{
                                                       return $doc.elementFromPoint(x, y);
                                                       }-*/;

        @Override
        public Rectangle visibleRect() {
            return DomUtil.visiblePart(getTarget());
        }

        @Override
        public void requestFocus() {
            getFocusTarget().focus();
        }

        @Override
        public ReadableProperty<Boolean> focused() {
            return myCellToDomContext.focused;
        }

        @Override
        public EventDispatchThread getEdt() {
            return JsEventDispatchThread.INSTANCE;
        }
    };
}

From source file:jetbrains.jetpad.projectional.domUtil.DomUtil.java

License:Apache License

public static Rectangle visiblePart(Element ctx) {
    return DomUtil.visiblePart(ctx, new Rectangle(0, 0, ctx.getScrollWidth(), ctx.getScrollHeight()));
}

From source file:jetbrains.jetpad.projectional.domUtil.DomUtil.java

License:Apache License

public static Rectangle visiblePart(Element ctx, Rectangle rect) {
    while (true) {
        if (ctx.getOffsetParent() == null) {
            Rectangle visibleArea = new Rectangle(Window.getScrollLeft(), Window.getScrollTop(),
                    Window.getClientWidth(), Window.getClientHeight());
            return visibleArea.intersect(rect);
        } else {// www . ja  v  a  2s .  c o  m
            Rectangle visible;
            if (hasScroller(ctx)) {
                visible = new Rectangle(0, 0, ctx.getClientWidth(), ctx.getClientHeight());
                Vector scroll = new Vector(ctx.getScrollLeft(), ctx.getScrollTop());
                rect = rect.sub(scroll);
            } else {
                visible = new Rectangle(0, 0, ctx.getScrollWidth(), ctx.getScrollHeight());
            }

            Rectangle newRect = visible.intersect(rect);
            Vector offset = new Vector(ctx.getOffsetLeft(), ctx.getOffsetTop());

            ctx = ctx.getOffsetParent();
            rect = newRect.add(offset);
        }
    }
}