Example usage for com.google.gwt.user.client.ui Widget setWidth

List of usage examples for com.google.gwt.user.client.ui Widget setWidth

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui Widget setWidth.

Prototype

public void setWidth(String width) 

Source Link

Document

Sets the object's width.

Usage

From source file:ar.com.kyol.jet.client.JetTable.java

License:Open Source License

protected void addColumn(Object columnHeading) {
    Widget widget = createCellWidget(columnHeading);
    int cell = this.getHeader().getCellCount(HEADER_ROW_INDEX);

    widget.setWidth("100%");
    widget.addStyleName("JetTable-ColumnLabel");

    this.getHeader().setWidget(HEADER_ROW_INDEX, cell, widget);

    this.getHeader().getCellFormatter().addStyleName(HEADER_ROW_INDEX, cell, "JetTable-ColumnLabelCell");
}

From source file:asquare.gwt.tk.client.ui.behavior.impl.GlassPanelControllerStandard.java

License:Apache License

@Override
public void plugIn(Widget widget) {
    m_widget = widget;// w  w  w. ja  va 2  s .c  o m
    widget.setWidth(calculateWidth());
    widget.setHeight(calculateHeight());
    m_xScroll = canScrollX();
    m_yScroll = canScrollY();
    m_windowResizeRegistration = Window.addResizeHandler(this);
}

From source file:ca.upei.ic.timetable.client.CalendarPanel.java

License:Apache License

protected void reorganizePanel(AbsolutePanel panel) {
    Set<Widget> remaining = new HashSet<Widget>();
    Set<Widget> processing = new HashSet<Widget>();

    // add all widgets to remaining
    for (Widget w : panel) {
        remaining.add(w);//  w  ww . j  av  a2 s .c om
    }

    // loop until no remaining widgets
    while (remaining.size() > 0) {
        // get the first widget
        Widget first = remaining.iterator().next();

        int top = panel.getWidgetTop(first);
        int bottom = panel.getWidgetTop(first) + first.getOffsetHeight();

        remaining.remove(first);
        processing.add(first);

        // find out the overlapping widgets from the first one
        boolean continueProcessing = true;
        while (continueProcessing) {
            // default to terminate the processing
            // this is a hack because no goto statement is supported in
            // Java.
            boolean terminateProcessing = true;
            // iterate all widgets until one overlapping widget is found.
            for (Widget widget : remaining) {
                int widgetTop = panel.getWidgetTop(widget);
                int widgetBottom = panel.getWidgetTop(widget) + widget.getOffsetHeight();
                // found
                if (top < widgetBottom && widgetTop < bottom) {
                    // add to processing set, remove from remaining set
                    processing.add(widget);
                    remaining.remove(widget);
                    // reset top and bottom if necessary
                    if (top > widgetTop)
                        top = widgetTop;
                    if (bottom < widgetBottom)
                        bottom = widgetBottom;
                    // don't terminate processing
                    terminateProcessing = false;
                    break;
                }
            }
            // really want to terminate the process?
            if (terminateProcessing)
                continueProcessing = false;
        }

        // all processing widgets found, try to reposition/resize the
        // widgets
        int count = processing.size();
        int index = 0;
        for (Widget widget : processing) {
            int widgetWidth = (panel.getOffsetWidth() - 2) / count;
            int widgetTop = panel.getWidgetTop(widget);
            int widgetLeft = index * widgetWidth;
            widget.setWidth(Integer.toString(widgetWidth) + "px");
            panel.setWidgetPosition(widget, widgetLeft, widgetTop);
            index++;
        }

        // clear the processing set
        processing.clear();
    }
}

From source file:cc.alcina.framework.gwt.client.util.WidgetUtils.java

License:Apache License

public static void resizeUsingInfo(int containerHeight, int containerWidth, Iterator<Widget> widgets,
        int parentAdjustHeight, int parentAdjustWidth) {
    while (widgets.hasNext()) {
        Widget widget = widgets.next();
        if (widget == null || !widget.isVisible()) {
            continue;
        }//from   w  w  w  .j  a v a 2  s.  c om
        int availableHeight = containerHeight;
        int availableWidth = containerWidth;
        if (widget instanceof HasLayoutInfo) {
            String name = widget.getClass().getName();
            if (debug) {
                GWT.log(CommonUtils.formatJ("%s: ", CommonUtils.simpleClassName(widget.getClass())), null);
            }
            LayoutInfo info = ((HasLayoutInfo) widget).getLayoutInfo();
            info.beforeLayout();
            if (info.to100percentOfAvailableHeight() || info.to100percentOfAvailableWidth()) {
                int usedHeight = 0;
                int usedWidth = 0;
                Widget parent = widget.getParent();
                Iterator<Widget> childIterator = null;
                availableHeight = info.useBestOffsetForParentHeight()
                        ? getBestOffsetHeight(parent.getElement(), true)
                        : containerHeight;
                availableHeight = Math.min(availableHeight, containerHeight);
                availableWidth = info.useBestOffsetForParentWidth()
                        ? getBestOffsetWidth(parent.getElement(), true)
                        : containerWidth;
                availableWidth = Math.min(availableWidth, containerWidth);
                if (parent instanceof HasLayoutInfo) {
                    childIterator = ((HasLayoutInfo) parent).getLayoutInfo().getLayoutWidgets();
                } else if (parent instanceof HasWidgets) {
                    childIterator = ((HasWidgets) parent).iterator();
                }
                boolean ignoreChildrenForHeight = info.to100percentOfAvailableHeight()
                        && (isDirectionalLayoutPanel(parent, true) || info.ignoreSiblingsForHeight());
                boolean ignoreChildrenForWidth = info.to100percentOfAvailableWidth()
                        && (isDirectionalLayoutPanel(parent, false) || info.ignoreSiblingsForWidth());
                if (childIterator != null) {
                    while (childIterator.hasNext()) {
                        Widget cw = childIterator.next();
                        if (cw != widget && WidgetUtils.isVisibleWithOffsetParent(cw.getElement())
                                && cw.isAttached()) {
                            if (!ignoreChildrenForHeight) {
                                usedHeight += getBestOffsetHeight(cw.getElement(), true, false);
                            }
                            if (!ignoreChildrenForWidth) {
                                usedWidth += getBestOffsetWidth(cw.getElement());
                            }
                        }
                    }
                }
                if (info.to100percentOfAvailableHeight()) {
                    availableHeight = availableHeight - usedHeight - parentAdjustHeight
                            - info.getAdjustHeight();
                    if (debug) {
                        GWT.log(CommonUtils.formatJ("%s: %s - comp %s",
                                CommonUtils.simpleClassName(widget.getClass()), availableHeight,
                                containerHeight), null);
                    }
                    if (availableHeight >= 0) {
                        widget.setHeight((availableHeight) + "px");
                    }
                }
                if (info.to100percentOfAvailableWidth()) {
                    availableWidth = availableWidth - usedWidth - parentAdjustWidth - info.getAdjustWidth();
                    if (availableWidth >= 0) {
                        widget.setWidth((availableWidth) + "px");
                    }
                }
            }
            Iterator<Widget> toResize = info.getWidgetsToResize();
            while (toResize.hasNext()) {
                toResize.next().setHeight(containerHeight + "px");
            }
            resizeUsingInfo(availableHeight, availableWidth, info.getLayoutWidgets(),
                    info.getClientAdjustHeight(), info.getClientAdjustWidth());
            info.afterLayout();
        } // haslayoutinfo
        else if (widget instanceof HasWidgets) {
            resizeUsingInfo(availableHeight, availableWidth, ((HasWidgets) widget).iterator(), 0, 0);
        }
    } // while
}

From source file:cc.alcina.framework.gwt.client.widget.dialog.RelativePopupPanel.java

License:Apache License

/**
 * We control size by setting our child widget's size. However, if we don't
 * currently have a child, we record the size the user wanted so that when
 * we do get a child, we can set it correctly. Until size is explicitly
 * cleared, any child put into the popup will be given that size.
 *//*from   www .j  av  a 2 s  .  c o  m*/
void maybeUpdateSize() {
    // For subclasses of RelativePopupPanel, we want the default behavior of
    // setWidth
    // and setHeight to change the dimensions of RelativePopupPanel's child
    // widget.
    // We do this because RelativePopupPanel's child widget is the first
    // widget in
    // the hierarchy which provides structure to the panel. DialogBox is
    // an example of this. We want to set the dimensions on DialogBox's
    // FlexTable, which is RelativePopupPanel's child widget. However, it is
    // not
    // DialogBox's child widget. To make sure that we are actually getting
    // RelativePopupPanel's child widget, we have to use super.getWidget().
    Widget w = super.getWidget();
    if (w != null) {
        if (desiredHeight != null) {
            w.setHeight(desiredHeight);
        }
        if (desiredWidth != null) {
            w.setWidth(desiredWidth);
        }
    }
}

From source file:co.fxl.gui.gwt.GWTDockPanel.java

License:Open Source License

@Override
public void add(Widget widget) {
    // if (!(widget instanceof ScrollPanel))
    // widget.getElement().getStyle().setOverflow(Overflow.HIDDEN);
    DockLayoutConstant location = positions.remove(0);
    container.widget.add(widget, location);
    if (widget instanceof HasHorizontalAlignment) {
        ((HasHorizontalAlignment) widget).setHorizontalAlignment(HorizontalPanel.ALIGN_LEFT);
    }//  w ww .ja  v  a 2s .  co  m
    if (widget instanceof HasVerticalAlignment) {
        ((HasVerticalAlignment) widget).setVerticalAlignment(VerticalPanel.ALIGN_TOP);
    }
    if (location.equals(DockPanel.SOUTH) || location.equals(DockPanel.NORTH)
            || location.equals(DockPanel.CENTER)) {
        container.widget.setCellWidth(widget, "100%");
        widget.setWidth("100%");
    }
    if (location.equals(DockPanel.EAST) || location.equals(DockPanel.WEST)
            || location.equals(DockPanel.CENTER)) {
        container.widget.setCellHeight(widget, height != -1 ? height + "px" : "100%");
        widget.setHeight(height != -1 ? height + "px" : "100%");
    }
}

From source file:co.fxl.gui.gwt.GWTFocusPanel.java

License:Open Source License

@Override
public void add(Widget widget) {
    widget.setWidth("100%");
    container.widget.add(widget);
}

From source file:co.fxl.gui.gwt.GWTGridPanel.java

License:Open Source License

@Override
public void add(Widget widget) {
    if (borderType != null) {
        DOM.setStyleAttribute(container.widget.getCellFormatter().getElement(gridCell.row, gridCell.column),
                borderType, borderConfiguration);
    }//from  w w  w  .  ja  va 2 s .c  o m
    container.widget.setWidget(gridCell.row, gridCell.column, widget);
    CellFormatter formatter = gridCell.formatter();
    formatter.setHeight(gridCell.row, gridCell.column, "100%");
    if (!(widget instanceof HorizontalPanel))
        widget.setWidth("100%");
    // widget.setHeight("100%");
}

From source file:co.fxl.gui.gwt.GWTScrollPane.java

License:Open Source License

@Override
public IContainer viewPort() {
    return new GWTContainer<Widget>(container.parent) {
        public void setComponent(Widget component) {
            super.widget = component;
            component.setWidth("100%");
            container.widget.setWidget(component);
        }//from   www  .  jav  a  2 s  .  co m
    };
}

From source file:co.fxl.gui.gwt.GWTSplitPane.java

License:Open Source License

private void prepare(Widget widget) {
    widget.setWidth("100%");
    widget.setHeight("100%");
}