Package com.alkacon.geranium.client.util

Examples of com.alkacon.geranium.client.util.PositionBean


     */
    public PositionBean getAreaPosition(boolean relative) {

        // returning the relative position
        if (relative) {
            return new PositionBean(m_currentSelection);
        }

        // returning the absolute position
        PositionBean abs = new PositionBean(m_currentSelection);
        abs.setTop(m_currentSelection.getTop() + getElement().getAbsoluteTop());
        abs.setLeft(m_currentSelection.getLeft() + getElement().getAbsoluteLeft());
        return abs;
    }
View Full Code Here


        if (pos == null) {
            return;
        }
        m_state = State.SELECTED;
        showSelect(true);
        m_currentSelection = new PositionBean();
        m_firstX = pos.getLeft();
        m_firstY = pos.getTop();
        if (!relative) {
            m_firstX -= getElement().getAbsoluteLeft();
            m_firstY -= getElement().getAbsoluteTop();
View Full Code Here

            case EMPTY:
                DOM.setCapture(getElement());
                m_state = State.SELECTING;
                m_firstX = event.getRelativeX(getElement());
                m_firstY = event.getRelativeY(getElement());
                m_currentSelection = new PositionBean();
                setSelectPosition(m_firstX, m_firstY, 0, 0);
                showSelect(true);

                break;
            case SELECTED:
View Full Code Here

     * Positions the given pop-up relative to the reference element.<p>
     */
    void positionPopup() {

        if (m_referenceElement != null) {
            PositionBean referencePosition = PositionBean.getInnerDimensions(m_referenceElement);
            int currentTop = m_popup.getAbsoluteTop();
            int windowHeight = Window.getClientHeight();
            int scrollTop = Window.getScrollTop();
            int contentHeight = m_popup.getOffsetHeight();
            int top = referencePosition.getTop();
            if (((windowHeight + scrollTop) < (top + referencePosition.getHeight() + contentHeight + 20))
                && ((contentHeight + 40) < top)) {
                top = top - contentHeight - 5;
                if ((currentTop < top) && ((top - currentTop) < 200)) {
                    // keep the current position
                    top = currentTop;
                }
            } else {
                top = top + referencePosition.getHeight() + 5;
                if ((currentTop > top) && ((currentTop - top) < 200)) {
                    // keep the current position
                    top = currentTop;
                }
            }
View Full Code Here

     * Resets the in line editing toolbar position.<p>
     */
    private void resetToolbarContainerPosition() {

        if (m_toolbarContainer != null) {
            PositionBean position = PositionBean.generatePositionInfo(m_contentElement);
            m_toolbarContainer.getStyle().setTop(position.getTop() - 5, Unit.PX);
            m_toolbarContainer.getStyle().setLeft(position.getLeft(), Unit.PX);
        }
    }
View Full Code Here

     * Resets the in line editing toolbar position.<p>
     */
    private void resetToolbarContainerPosition() {

        if (m_toolbarContainer != null) {
            PositionBean position = PositionBean.generatePositionInfo(m_contentElement);
            m_toolbarContainer.getStyle().setTop(position.getTop() - 5, Unit.PX);
            m_toolbarContainer.getStyle().setLeft(position.getLeft(), Unit.PX);
        }
    }
View Full Code Here

            minLeft = spaceAssurance;
        }
        // get the max right position
        int maxRight = minLeft + space;
        // get the middle button position
        PositionBean buttonPosition = PositionBean.generatePositionInfo(button.getElement());
        int buttonMiddle = (buttonPosition.getLeft() - Window.getScrollLeft()) + (buttonPosition.getWidth() / 2);
        // get the content width
        int contentWidth = popup.getOffsetWidth();

        // the optimum left position is in the middle of the button minus the half content width
        // assume that the optimum fits into the space
        int contentLeft = buttonMiddle - (contentWidth / 2);

        if (minLeft > contentLeft) {
            // if the optimum left position of the popup is outside the min left position:
            // move the popup to the right (take the min left position as left)
            contentLeft = minLeft;
        } else if ((contentLeft + contentWidth) > maxRight) {
            // if the left position plus the content width is outside the max right position:
            // move the popup to the left (take the max right position minus the content width)
            contentLeft = maxRight - contentWidth;
        }

        // limit the right position if the popup is right outside the window
        if ((contentLeft + contentWidth + spaceAssurance) > windowWidth) {
            contentLeft = windowWidth - contentWidth - spaceAssurance;
        }

        // limit the left position if the popup is left outside the window
        if (contentLeft < spaceAssurance) {
            contentLeft = spaceAssurance;
        }

        int arrowSpace = 10;
        int arrowWidth = I_LayoutBundle.INSTANCE.gwtImages().menuArrowTopImage().getWidth();
        int arrowHeight = I_LayoutBundle.INSTANCE.gwtImages().menuArrowTopImage().getHeight();

        // the optimum position for the arrow is in the middle of the button
        int arrowLeft = buttonMiddle - contentLeft - (arrowWidth / 2);
        if ((arrowLeft + arrowWidth + arrowSpace) > contentWidth) {
            // limit the arrow position if the maximum is reached (content width 'minus x')
            arrowLeft = contentWidth - arrowWidth - arrowSpace;
        } else if ((arrowLeft - arrowSpace) < 0) {
            // limit the arrow position if the minimum is reached ('plus x')
            arrowLeft = arrowWidth + arrowSpace;
        }

        int arrowTop = -(arrowHeight - 2);
        String arrowClass = I_LayoutBundle.INSTANCE.dialogCss().menuArrowTop();

        int contentTop = (((buttonPosition.getTop() + buttonPosition.getHeight()) - Window.getScrollTop()) + arrowHeight) - 2;
        if (!isToolbarMode) {
            contentTop = (buttonPosition.getTop() + buttonPosition.getHeight() + arrowHeight) - 2;
            int contentHeight = popup.getOffsetHeight();
            int windowHeight = Window.getClientHeight();

            if (((contentHeight + spaceAssurance) < windowHeight)
                && ((buttonPosition.getTop() - Window.getScrollTop()) > contentHeight)
                && (((contentHeight + spaceAssurance + contentTop) - Window.getScrollTop()) > windowHeight)) {
                // content fits into the window height,
                // there is enough space above the button
                // and there is to little space below the button
                // so show above
                contentTop = ((buttonPosition.getTop() - arrowHeight) + 2) - contentHeight;
                arrowTop = contentHeight - 1;
                arrowClass = I_LayoutBundle.INSTANCE.dialogCss().menuArrowBottom();
            }
        } else {
            contentLeft = contentLeft - Window.getScrollLeft();
View Full Code Here

TOP

Related Classes of com.alkacon.geranium.client.util.PositionBean

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.