Example usage for com.google.gwt.event.logical.shared ResizeEvent fire

List of usage examples for com.google.gwt.event.logical.shared ResizeEvent fire

Introduction

In this page you can find the example usage for com.google.gwt.event.logical.shared ResizeEvent fire.

Prototype

public static <S extends HasResizeHandlers & HasHandlers> void fire(S source, int width, int height) 

Source Link

Document

Fires a resize event on all registered handlers in the handler source.

Usage

From source file:be.progs.routeshare.client.RouteShareMenu.java

License:Open Source License

private void buildGui() {
    contentPanel.setVisible(open);// ww w  .  j av a 2s.c om
    if (open) {
        int width = contentPanel.getOffsetWidth();
        setWidth(width + "px");
    } else {
        setWidth("100px");
    }
    ResizeEvent.fire(this, getOffsetWidth(), getOffsetHeight());
}

From source file:com.alkacon.acacia.client.widgets.TinyMCEWidget.java

License:Open Source License

/**
 * Fires the resize event.<p>
 */
private void fireResizeEvent() {

    ResizeEvent.fire(this, getOffsetWidth(), getOffsetHeight());
}

From source file:com.philbeaudoin.quebec.client.widget.FullCanvas.java

License:Apache License

@Override
public void onResize() {
    int width = getParent().getOffsetWidth();
    int height = getParent().getOffsetHeight();
    int top = 0;/*from w  w  w  . ja  v  a2s.  co m*/
    int left = 0;
    double aspectRatio = (double) width / (double) height;
    if (targetAspectRatio > aspectRatio) {
        // Constrain canvas width.
        top = height;
        height = (int) (width / targetAspectRatio);
        top = (top - height) / 2;
    } else {
        // Constrain canvas height.
        left = width;
        width = (int) (height * targetAspectRatio);
        left = (left - width) / 2;
    }
    canvas.getElement().getStyle().setPropertyPx("top", top);
    canvas.getElement().getStyle().setPropertyPx("left", left);
    canvas.setPixelSize(width, height);
    canvas.setCoordinateSpaceWidth(width);
    canvas.setCoordinateSpaceHeight(height);

    ResizeEvent.fire(this, width, height);
}

From source file:com.sencha.gxt.widget.core.client.Component.java

License:sencha.com license

/**
 * Sets the component's size. Unlike GWT widget's, when setting sizes, the component's actual size will match exactly
 * the size specified independent of borders and padding.
 *
 * @param width new width, in pixels/*from www . ja  va  2s  . c  o m*/
 * @param height height, in pixels
 */
@Override
public void setPixelSize(int width, int height) {
    int w, h;
    if (width == -1) {
        w = width;
        this.width = null;
    } else if (width != Integer.MIN_VALUE) {
        w = width;
        this.width = width + "px";
    } else {
        w = Util.parseInt(this.width, -1);
    }

    if (height == -1) {
        this.height = null;
        h = height;
    } else if (height != Integer.MIN_VALUE) {
        h = height;
        this.height = height + "px";
    } else {
        h = Util.parseInt(this.height, -1);
    }

    if (!isAttached()) {
        return;
    }

    Size size = new Size(w, h);
    if (cacheSizes && lastSize != null && lastSize.equals(size)) {
        return;
    }

    List<FastMap<Object>> list = makeVisible();

    lastSize = size;

    Size ads = adjustSize(size);

    int aw = ads.getWidth();
    int ah = ads.getHeight();

    if (width != -1 && height != -1 && width != Integer.MIN_VALUE && height != Integer.MIN_VALUE
            && !deferHeight) {
        getElement().setSize(aw, ah, adjustSize);
    } else if (width != -1 && width != Integer.MIN_VALUE) {
        getElement().setWidth(aw, adjustSize);
        if (height != Integer.MIN_VALUE) {
            getElement().getStyle().clearHeight();
        }
    } else if (height != -1 && !deferHeight) {
        getElement().setHeight(ah, adjustSize);
        if (width != Integer.MIN_VALUE) {
            getElement().getStyle().clearWidth();
        }
    }

    restoreVisible(list);

    onResize(aw, ah);

    Scheduler.get().scheduleFinally(new ScheduledCommand() {

        @Override
        public void execute() {
            sync(true);
        }
    });

    ResizeEvent.fire(this, aw, ah);
}

From source file:com.sencha.gxt.widget.core.client.Component.java

License:sencha.com license

/**
 * Sets the width and height of the widget. This method fires the <i>Resize</i> event.
 *
 * @param width the new width to set/*from w  w  w  .  ja  v a 2 s  . c  o  m*/
 * @param height the new height to set
 */
@Override
public void setSize(String width, String height) {
    if (width != null && !Style.UNDEFINED.equals(width)) {
        width = XElement.addUnits(width, "px");
    }

    if (height != null && !Style.UNDEFINED.equals(height)) {
        height = XElement.addUnits(height, "px");
    }

    if ((height == null && width != null && width.endsWith("px"))
            || (width == null && height != null && height.endsWith("px"))
            || (width != null && height != null && width.endsWith("px") && height.endsWith("px"))) {
        int w, h;
        if (width == null) {
            w = -1;
        } else if (Style.UNDEFINED.equals(width)) {
            w = Integer.MIN_VALUE;
        } else {
            w = Util.parseInt(width, -1);
        }
        if (height == null) {
            h = -1;
        } else if (Style.UNDEFINED.equals(height)) {
            h = Integer.MIN_VALUE;
        } else {
            h = Util.parseInt(height, -1);
        }
        setPixelSize(w, h);
        return;
    }

    if (width == null) {
        this.width = null;
    } else if (width.equals(Style.UNDEFINED)) {
        width = this.width;
    } else {
        this.width = width;
    }

    if (height == null) {
        this.height = null;
    } else if (height.equals(Style.UNDEFINED)) {
        height = this.height;
    } else {
        this.height = height;
    }

    if (!isAttached()) {
        return;
    }

    if (width != null) {
        getElement().setWidth(width);
    } else {
        getElement().getStyle().clearWidth();
    }

    if (height != null) {
        if (!deferHeight) {
            getElement().setHeight(height);
        }
    } else {
        getElement().getStyle().clearHeight();
    }

    int w = -1;
    int h = -1;

    List<FastMap<Object>> list = makeVisible();

    if (width == null) {
        w = -1;
    } else if (width.indexOf("px") != -1) {
        w = Util.parseInt(width, -1);
    } else {
        w = getOffsetWidth();
    }
    if (height == null) {
        h = -1;
    } else if (height.indexOf("px") != -1) {
        h = Util.parseInt(height, -1);
    } else {
        h = getOffsetHeight();
    }

    Size size = new Size(w, h);
    if (cacheSizes && lastSize != null && lastSize.equals(size)) {
        return;
    }

    lastSize = size;

    onResize(w, h);

    sync(true);

    restoreVisible(list);

    ResizeEvent.fire(this, w, h);
}

From source file:com.sencha.gxt.widget.core.client.grid.ColumnHeader.java

License:sencha.com license

protected void checkHeaderSizeChange() {
    int width = getOffsetWidth();
    int height = getOffsetHeight();
    if (width != oldWidth || height != oldHeight) {
        ResizeEvent.fire(this, width, height);
        oldWidth = width;//w w  w  .  ja v a  2  s  .com
        oldHeight = height;
    }
}

From source file:com.vaadin.client.ui.VUI.java

License:Apache License

/**
 * Send new dimensions to the server.//from w ww.  java 2s. c om
 * <p>
 * For internal use only. May be removed or replaced in the future.
 */
public void sendClientResized() {
    Profiler.enter("VUI.sendClientResized");
    Element parentElement = getElement().getParentElement();
    int viewHeight = parentElement.getClientHeight();
    int viewWidth = parentElement.getClientWidth();

    ResizeEvent.fire(this, viewWidth, viewHeight);
    Profiler.leave("VUI.sendClientResized");
}

From source file:org.drools.guvnor.client.asseteditor.drools.modeldriven.ui.DynamicTextArea.java

License:Apache License

private void assertTextAreaDimensions() {
    String text = getText();/*ww  w  .j  ava2 s  .co  m*/
    int oldLines = getVisibleLines();
    int oldCharacters = getCharacterWidth();
    setNumberOfLines(text);
    setMaxLineWidth(text);

    //Fire a resize event, if applicable
    boolean resizeContainer = false;
    if (oldLines != getVisibleLines()) {
        resizeContainer = true;
    }
    if (oldCharacters != getCharacterWidth()) {
        resizeContainer = true;
    }
    if (resizeContainer) {
        ResizeEvent.fire(this, getVisibleLines(), getCharacterWidth());
    }
}

From source file:org.drools.guvnor.client.decisiontable.widget.VerticalDecisionTableHeaderWidget.java

License:Apache License

private void fireResizeEvent() {
    Scheduler.get().scheduleDeferred(new ScheduledCommand() {
        public void execute() {
            ResizeEvent.fire(VerticalDecisionTableHeaderWidget.this, getBody().getOffsetWidth(),
                    getBody().getOffsetHeight());
        }/*from   ww  w  .j  a  v a  2s.  c  o m*/
    });

}

From source file:org.drools.workbench.screens.guided.dtable.client.widget.table.VerticalDecisionTableHeaderWidget.java

License:Apache License

private void fireResizeEvent() {
    Scheduler.get().scheduleDeferred(new ScheduledCommand() {
        public void execute() {
            ResizeEvent.fire(VerticalDecisionTableHeaderWidget.this, widget.getOffsetWidth(),
                    widget.getOffsetHeight());
        }/*w w w .  j a  v  a 2s  .  c o  m*/
    });

}