/** Check to see if any Widgets have been resized and call their handlers appropriately. */ public void checkWidgetSize() { for (Map.Entry<ResizableWidget, ResizableWidgetInfo> entry : widgets.entrySet()) { ResizableWidget widget = entry.getKey(); ResizableWidgetInfo info = entry.getValue(); // Call the onResize method only if the widget is attached if (info.updateSizes()) { // Check that the offset width and height are greater than 0. if (info.getOffsetWidth() > 0 && info.getOffsetHeight() > 0 && widget.isAttached()) { // Send the client dimensions, which is the space available for // rendering. widget.onResize(info.getOffsetWidth(), info.getOffsetHeight()); } } } }
/** * Update the current sizes. * * @return true if the sizes changed, false if not. */ public boolean updateSizes() { int offsetWidth = widget.getElement().getOffsetWidth(); int offsetHeight = widget.getElement().getOffsetHeight(); int clientWidth = widget.getElement().getClientWidth(); int clientHeight = widget.getElement().getClientHeight(); if (offsetWidth != curOffsetWidth || offsetHeight != curOffsetHeight || clientWidth != curClientWidth || clientHeight != curClientHeight) { this.curOffsetWidth = offsetWidth; this.curOffsetHeight = offsetHeight; this.curClientWidth = clientWidth; this.curClientHeight = clientHeight; return true; } return false; }
/** * Inform the {@link ResizableWidgetCollection} that the size of a widget has changed and already * been redrawn. This will prevent the widget from being redrawn on the next loop. * * @param widget the widget's size that changed */ public void updateWidgetSize(ResizableWidget widget) { if (!widget.isAttached()) { return; } ResizableWidgetInfo info = widgets.get(widget); if (info != null) { info.updateSizes(); } }