Search in sources :

Example 1 with XElement

use of com.sencha.gxt.core.client.dom.XElement in project activityinfo by bedatadriven.

the class LogicalTabPanel method autoSizeTabs.

private void autoSizeTabs() {
    int count = getModelCount();
    if (count == 0)
        return;
    int aw = appearance.getBar(getElement()).getClientWidth();
    if (aw == 0) {
        aw = getElement().getStyleSize().getWidth();
    }
    int each = (int) Math.max(Math.min(Math.floor((aw - 4) / count) - tabMargin, tabWidth), minTabWidth);
    for (int i = 0; i < count; i++) {
        XElement el = findItem(i).cast();
        appearance.setItemWidth(el, each);
    }
}
Also used : XElement(com.sencha.gxt.core.client.dom.XElement) Point(com.sencha.gxt.core.client.util.Point)

Example 2 with XElement

use of com.sencha.gxt.core.client.dom.XElement in project activityinfo by bedatadriven.

the class LogicalTabPanel method update.

/**
 * Updates the appearance of the specified tab item. Must be invoked after changing the tab item configuration.
 *
 * @param model the widget for the tab to update
 * @param config the new or updated tab item configuration
 */
public void update(M model, TabItemConfig config) {
    XElement item = findItem(getModelIndex(model));
    if (item != null) {
        configMap.put(model, config);
        appearance.updateItem(item, config);
    }
}
Also used : XElement(com.sencha.gxt.core.client.dom.XElement)

Example 3 with XElement

use of com.sencha.gxt.core.client.dom.XElement in project activityinfo by bedatadriven.

the class LogicalTabPanel method scrollToTab.

/**
 * Scrolls to a particular tab if tab scrolling is enabled.
 *
 * @param item the item to scroll to
 * @param animate true to animate the scroll
 */
public void scrollToTab(M item, boolean animate) {
    if (item == null)
        return;
    int pos = getScrollPos();
    int area = getScrollArea();
    XElement itemEl = findItem(getModelIndex(item)).cast();
    int left = itemEl.getOffsetsTo(getStripWrap()).getX() + pos;
    int right = left + itemEl.getOffsetWidth();
    if (left < pos) {
        scrollTo(left, animate);
    } else if (right > (pos + area)) {
        scrollTo(right - area, animate);
    }
}
Also used : XElement(com.sencha.gxt.core.client.dom.XElement) Point(com.sencha.gxt.core.client.util.Point)

Example 4 with XElement

use of com.sencha.gxt.core.client.dom.XElement in project activityinfo by bedatadriven.

the class LogicalTabPanel method onClick.

protected void onClick(Event event) {
    XElement target = event.getEventTarget().cast();
    Element item = findItem(target);
    if (item != null) {
        event.stopPropagation();
        M w = getModel(itemIndex(item));
        boolean close = appearance.isClose(target);
        if (close) {
            close(w);
        } else if (w != getActiveModel()) {
            setActiveModel(w);
            focusTab(w, true);
        } else if (w == getActiveModel()) {
            focusTab(w, true);
        }
    }
    if (appearance.getScrollLeft(getElement()) != null && target.isOrHasChild(appearance.getScrollLeft(getElement()))) {
        event.stopPropagation();
        onScrollLeft();
    }
    if (appearance.getScrollRight(getElement()) != null && target.isOrHasChild(appearance.getScrollRight(getElement()))) {
        event.stopPropagation();
        onScrollRight();
    }
}
Also used : XElement(com.sencha.gxt.core.client.dom.XElement) XElement(com.sencha.gxt.core.client.dom.XElement) Element(com.google.gwt.dom.client.Element) FxElement(com.sencha.gxt.fx.client.FxElement) XDOM(com.sencha.gxt.core.client.dom.XDOM)

Example 5 with XElement

use of com.sencha.gxt.core.client.dom.XElement in project activityinfo by bedatadriven.

the class LogicalTabPanel method autoScrollTabs.

private void autoScrollTabs() {
    int count = getModelCount();
    int tw = appearance.getBar(getElement()).getClientWidth();
    if (tw == 0) {
        tw = getElement().getStyleSize().getWidth();
    }
    XElement stripWrap = appearance.getStripWrap(getElement());
    XElement edge = appearance.getStripEdge(getElement());
    XElement scrollLeft = appearance.getScrollLeft(getElement());
    XElement scrollRight = appearance.getScrollRight(getElement());
    int cw = stripWrap.getOffsetWidth();
    int pos = getScrollPos();
    int l = edge.<XElement>cast().getOffsetsTo(stripWrap).getX() + pos;
    if (!getTabScroll() || count < 1 || cw < 20) {
        return;
    }
    if (l <= tw) {
        stripWrap.<XElement>cast().setWidth(tw);
        if (scrolling) {
            stripWrap.setScrollLeft(0);
            scrolling = false;
            scrollLeft.setVisible(false);
            scrollRight.setVisible(false);
            // add a class that CSS can hook into to add/remove padding as necessary when scrollers change visibility
            scrollLeft.addClassName("x-tabScrollerLeftHidden");
            appearance.onScrolling(getElement(), false);
        }
    } else {
        if (!scrolling) {
            appearance.onScrolling(getElement(), true);
        }
        if (!scrolling) {
            if (scrollLeft == null) {
                appearance.createScrollers(getElement());
                // need to re-initialize scrollers as they will still be null
                scrollLeft = appearance.getScrollLeft(getElement());
                scrollRight = appearance.getScrollRight(getElement());
            } else {
                scrollLeft.setVisible(true);
                scrollRight.setVisible(true);
                scrollLeft.removeClassName("x-tabScrollerLeftHidden");
            }
        }
        // account for scrollers before setting width
        tw -= scrollLeft.getComputedWidth() + scrollRight.getComputedWidth();
        stripWrap.<XElement>cast().setWidth(tw > 20 ? tw : 20);
        scrolling = true;
        if (pos > (l - tw)) {
            stripWrap.setScrollLeft(l - tw);
        } else {
            scrollToTab(getActiveModel(), false);
        }
        appearance.updateScrollButtons(getElement());
    }
}
Also used : XElement(com.sencha.gxt.core.client.dom.XElement) Point(com.sencha.gxt.core.client.util.Point)

Aggregations

XElement (com.sencha.gxt.core.client.dom.XElement)8 Point (com.sencha.gxt.core.client.util.Point)5 Element (com.google.gwt.dom.client.Element)3 FxElement (com.sencha.gxt.fx.client.FxElement)3 TabItemConfig (com.sencha.gxt.widget.core.client.TabItemConfig)2 XDOM (com.sencha.gxt.core.client.dom.XDOM)1 AfterAnimateEvent (com.sencha.gxt.fx.client.animation.AfterAnimateEvent)1 AfterAnimateHandler (com.sencha.gxt.fx.client.animation.AfterAnimateEvent.AfterAnimateHandler)1 Fx (com.sencha.gxt.fx.client.animation.Fx)1