.i-button {
cursor: pointer;
font-size: 13px;
+ white-space: nowrap;
}
.i-button img {
}
.i-errorindicator {
- width: 10px;
+ width: 12px;
height: 16px;
- padding-right:13px;
- display: inline;
+ float: left;
background: transparent url(icons/16/error.png) no-repeat top right;
}
*+html .i-errorindicator {
margin-left:-3px;
}
-
.i-caption .i-icon {
padding-right: 2px;
vertical-align: middle;
}
.i-orderedlayout-vspacing {
- margin-top: 8px;
+ padding-top: 8px;
}
.i-orderedlayout-hspacing {
padding-left: 8px;
.i-filterselect {
height: 23px;
- background: transparent url(select/img/bg-left-filter.png) no-repeat;
- margin-right: 1px;
white-space: nowrap;
text-align: left /* Force default alignment */
}
.i-filterselect-input {
- width: 99%;
+ background: transparent url(select/img/bg-left-filter.png) no-repeat;
border: none;
- background: transparent;
height: 20px;
margin: 0;
padding: 3px 0 0 4px;
.i-filterselect-button {
float: right;
- margin: -23px -1px 0 0;
+ margin-left: -23px;
width: 25px;
height: 23px;
cursor: pointer;
private int sessionExpirationInterval;
private ArrayList<Widget> relativeSizeChanges = new ArrayList<Widget>();;
+ private ArrayList<Widget> captionSizeChanges = new ArrayList<Widget>();;
public ApplicationConnection(WidgetSet widgetSet,
ApplicationConfiguration cnf) {
Vector<Widget> updatedWidgets = new Vector<Widget>();
relativeSizeChanges.clear();
+ captionSizeChanges.clear();
for (int i = 0; i < changes.size(); i++) {
try {
Set<Widget> sizeUpdatedWidgets = new HashSet<Widget>();
updatedWidgets.addAll(relativeSizeChanges);
+ sizeUpdatedWidgets.addAll(captionSizeChanges);
for (Widget widget : updatedWidgets) {
Size oldSize = componentOffsetSizes.get(widget);
public void setWindowName(String newName) {
windowName = newName;
}
+
+ public void captionSizeUpdated(Widget component) {
+ captionSizeChanges.add(component);
+ }
}
public int getWidth() {
int width = 0;
+
if (icon != null) {
width += icon.getOffsetWidth();
}
- if (captionText != null) {
- width += captionText.getOffsetWidth();
- }
- if (requiredFieldIndicator != null) {
- width += requiredFieldIndicator.getOffsetWidth();
- }
- if (errorIndicatorElement != null) {
- width += errorIndicatorElement.getOffsetWidth();
+
+ if (maxWidth >= 0) {
+ if (captionText != null) {
+ width += captionText.getOffsetWidth();
+ }
+ if (requiredFieldIndicator != null) {
+ width += requiredFieldIndicator.getOffsetWidth();
+ }
+ if (errorIndicatorElement != null) {
+ width += errorIndicatorElement.getOffsetWidth();
+ }
+
+ } else {
+ if (captionText != null) {
+ width += captionText.getScrollWidth();
+ }
+ if (requiredFieldIndicator != null) {
+ width += requiredFieldIndicator.getScrollWidth();
+ }
+ if (errorIndicatorElement != null) {
+ width += errorIndicatorElement.getScrollWidth();
+ }
+
}
return width;
Map<Container, Set<Paintable>> childWidgets = new HashMap<Container, Set<Paintable>>();
for (Widget widget : widgets) {
+// ApplicationConnection.getConsole().log(
+// "Widget " + Util.getSimpleName(widget) + " size updated");
Widget parent = widget.getParent();
while (parent != null && !(parent instanceof Container)) {
parent = parent.getParent();
return padding;
}
+ public static int measureHorizontalBorder(Element element) {
+ int borders;
+ if (BrowserInfo.get().isIE6()) {
+ String originalWidth = DOM.getStyleAttribute(element, "width");
+ int originalOffsetWidth = element.getOffsetWidth();
+ DOM.setStyleAttribute(element, "width", originalOffsetWidth + "px");
+ borders = element.getOffsetWidth()
+ - element.getPropertyInt("clientWidth");
+
+ DOM.setStyleAttribute(element, "width", originalWidth);
+ } else {
+ borders = element.getOffsetWidth()
+ - element.getPropertyInt("clientWidth");
+ }
+ assert borders >= 0;
+
+ return borders;
+ }
+
+ public static int measureVerticalBorder(Element element) {
+ int borders = element.getOffsetHeight()
+ - element.getPropertyInt("clientHeight");
+ assert borders >= 0;
+ return borders;
+ }
+
+ public static int measureMarginLeft(Element element) {
+ return element.getAbsoluteLeft()
+ - element.getParentElement().getAbsoluteLeft();
+ }
+
public static void setWidthExcludingPadding(Element element,
int requestedWidth, int paddingGuess) {
\r
/* Fetch alignments and expand ratio from UIDL */\r
updateAlignmentsAndExpandRatios(uidl, uidlWidgets);\r
+ // w.mark("Alignments and expand ratios updated");\r
\r
/* Fetch widget sizes from rendered components */\r
for (ChildComponentContainer childComponentContainer : widgetToComponentContainer\r
*/\r
childComponentContainer.updateWidgetSize();\r
}\r
+ // w.mark("Widget sizes updated");\r
\r
recalculateLayout();\r
+ // w.mark("Layout size calculated (" + activeLayoutSize +\r
+ // ") offsetSize: "\r
+ // + getOffsetWidth() + "," + getOffsetHeight());\r
\r
/* Render relative size components */\r
for (int i = 0; i < relativeSizeComponents.size(); i++) {\r
// childComponentContainer.updateWidgetSize();\r
}\r
\r
+ // w.mark("Rendering of " + (relativeSizeComponents.size())\r
+ // + " relative size components done");\r
+\r
/* Fetch widget sizes for relative size components */\r
for (ChildComponentContainer childComponentContainer : widgetToComponentContainer\r
.values()) {\r
childComponentContainer.updateWidgetSize();\r
}\r
\r
- // w.mark("Rendering of " + (relativeSizeComponents.size())\r
- // + " relative size components done");\r
+ // w.mark("Widget sizes updated");\r
+\r
+ /* Update component spacing */\r
+ updateContainerMargins();\r
\r
/* Recalculate component sizes and alignments */\r
recalculateComponentSizesAndAlignments();\r
return;\r
}\r
\r
- updateContainerMargins();\r
-\r
/*\r
* Update the height of relative height components in a horizontal\r
* layout or the width for relative width components in a vertical\r
int widgetWidth = s.getWidth()\r
+ childComponentContainer.getCaptionWidthAfterComponent();\r
\r
- if (isDynamicWidth()) {\r
- /*\r
- * For a dynamic width layout the max of caption/widget defines\r
- * the required size\r
- */\r
+ /*\r
+ * If the component does not have a specified size in the main\r
+ * direction the caption may determine the space used by the\r
+ * component\r
+ */\r
+ if (!childComponentContainer.widgetHasSizeSpecified(orientation)) {\r
int captionWidth = childComponentContainer.getCaptionWidth();\r
if (captionWidth > widgetWidth) {\r
widgetWidth = captionWidth;\r
}\r
}\r
-\r
+ \r
int widgetHeight = s.getHeight()\r
+ childComponentContainer.getCaptionHeightAboveComponent();\r
\r
width = childComponentContainer.getWidgetSize().getWidth()\r
+ childComponentContainer\r
.getCaptionWidthAfterComponent();\r
- int captionWidth = childComponentContainer\r
- .getCaptionWidth();\r
- if (captionWidth > width) {\r
- width = captionWidth;\r
+\r
+ /*\r
+ * If the component does not have a specified size in the\r
+ * main direction the caption may determine the space used\r
+ * by the component\r
+ */\r
+ if (!childComponentContainer\r
+ .widgetHasSizeSpecified(orientation)) {\r
+ int captionWidth = childComponentContainer\r
+ .getCaptionWidth();\r
+ if (captionWidth > width) {\r
+ width = captionWidth;\r
+ }\r
}\r
} else {\r
width = 0;\r
\r
}\r
\r
+ /**\r
+ * Updates the spacing between components. Needs to be done only when\r
+ * components are added/removed.\r
+ */\r
private void updateContainerMargins() {\r
ChildComponentContainer firstChildComponent = getFirstChildComponentContainer();\r
\r
}\r
}\r
\r
+ public void updateCaption(Paintable component, UIDL uidl) {\r
+ ChildComponentContainer componentContainer = getComponentContainer((Widget) component);\r
+ componentContainer.updateCaption(uidl, client);\r
+ if (!isRendering) {\r
+ /*\r
+ * This was a component-only update and the possible size change\r
+ * must be propagated to the layout\r
+ */\r
+ client.captionSizeUpdated((Widget) component);\r
+ }\r
+ }\r
+\r
}\r
private int borderPaddingVertical = -1;
+ private int captionPaddingHorizontal = -1;
+
+ private int captionMarginLeft = -1;
+
public IPanel() {
super();
DOM.appendChild(getElement(), captionNode);
}
layout.updateFromUIDL(layoutUidl, client);
-
- if (BrowserInfo.get().isIE7()) {
- // IE is not able to make the offsetWidth for contentNode correct for some reason...
+ if (BrowserInfo.get().isIE()) {
+ // IE is not able to make the offsetWidth for contentNode correct
+ // for some reason...
iLayout(false);
}
// We may have actions attached to this panel
}
public void iLayout(boolean runGeckoFix) {
- renderInformation.updateSize(getElement());
-
if (BrowserInfo.get().isIE6() && width != null && !width.equals("")) {
/*
* IE6 requires overflow-hidden elements to have a width specified
int parentWidthExcludingPadding = getElement().getOffsetWidth()
- parentPadding;
- int captionMarginLeft = captionNode.getAbsoluteLeft()
- - getElement().getAbsoluteLeft();
Util.setWidthExcludingPadding(captionNode,
- parentWidthExcludingPadding - captionMarginLeft, 26);
+ parentWidthExcludingPadding - getCaptionMarginLeft(), 26);
int contentMarginLeft = contentNode.getAbsoluteLeft()
- getElement().getAbsoluteLeft();
}
- if (BrowserInfo.get().isIE7() && (width == null || width.equals(""))) {
- //FIXME This won't work if the panel's content gets narrower later on...
- int captionMarginLeft = captionNode.getAbsoluteLeft()
- - getElement().getAbsoluteLeft();
- int captionWidth = captionNode.getOffsetWidth() + captionMarginLeft;
- int contentWidth = contentNode.getOffsetWidth();
+ if (BrowserInfo.get().isIE() && (width == null || width.equals(""))) {
+ int captionWidth = captionText.getOffsetWidth()
+ + getCaptionMarginLeft() + getCaptionPaddingHorizontal();
int layoutWidth = ((Widget) layout).getOffsetWidth()
+ getContainerBorderWidth();
- int width = contentWidth;
+ int width = layoutWidth;
if (captionWidth > width) {
width = captionWidth;
}
- if (layoutWidth > width) {
- width = layoutWidth;
- }
super.setWidth(width + "px");
}
}
}
+ private int getCaptionMarginLeft() {
+ if (captionMarginLeft < 0) {
+ detectContainerBorders();
+ }
+ return captionMarginLeft;
+ }
+
+ private int getCaptionPaddingHorizontal() {
+ if (captionPaddingHorizontal < 0) {
+ detectContainerBorders();
+ }
+ return captionPaddingHorizontal;
+ }
+
private int getContainerBorderHeight() {
if (borderPaddingVertical < 0) {
detectContainerBorders();
private void detectContainerBorders() {
DOM.setStyleAttribute(contentNode, "overflow", "hidden");
- borderPaddingHorizontal = contentNode.getOffsetWidth()
- - contentNode.getPropertyInt("clientWidth");
- assert borderPaddingHorizontal >= 0;
- borderPaddingVertical = contentNode.getOffsetHeight()
- - contentNode.getPropertyInt("clientHeight");
- assert borderPaddingVertical >= 0;
+
+ borderPaddingHorizontal = Util.measureHorizontalBorder(contentNode);
+ borderPaddingVertical = Util.measureVerticalBorder(contentNode);
DOM.setStyleAttribute(contentNode, "overflow", "auto");
+
+ captionPaddingHorizontal = Util.measureHorizontalPadding(captionNode,
+ 26);
+
+ captionMarginLeft = Util.measureMarginLeft(captionNode);
+
}
public boolean hasChildComponent(Widget component) {
*/
return true;
}
+ iLayout(false);
return !renderInformation.updateSize(getElement());
}
import com.google.gwt.user.client.ui.Widget;\r
import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;\r
import com.itmill.toolkit.terminal.gwt.client.Container;\r
-import com.itmill.toolkit.terminal.gwt.client.Paintable;\r
import com.itmill.toolkit.terminal.gwt.client.UIDL;\r
import com.itmill.toolkit.terminal.gwt.client.ui.MarginInfo;\r
\r
throw new UnsupportedOperationException();\r
}\r
\r
- public void updateCaption(Paintable component, UIDL uidl) {\r
- ChildComponentContainer componentContainer = getComponentContainer((Widget) component);\r
- componentContainer.updateCaption(uidl, client);\r
- }\r
-\r
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {\r
this.client = client;\r
\r
spacingFromCSS.vSpacing = measurement.getOffsetHeight() - 1;\r
spacingFromCSS.hSpacing = measurement.getOffsetWidth() - 1;\r
\r
- ApplicationConnection.getConsole().log("Margins: " + marginsFromCSS);\r
- ApplicationConnection.getConsole().log("Spacing: " + spacingFromCSS);\r
+ // ApplicationConnection.getConsole().log("Margins: " + marginsFromCSS);\r
+ // ApplicationConnection.getConsole().log("Spacing: " + spacingFromCSS);\r
\r
root.removeChild(measurement);\r
\r
* Size of the widget inside the container DIV\r
*/\r
private Size widgetSize = new Size(0, 0);\r
+ /**\r
+ * Size of the caption\r
+ */\r
+ private Size captionSize = new Size(0, 0);\r
\r
/**\r
* Padding added to the container when it is larger than the component.\r
return 0;\r
}\r
\r
- return caption.getWidth();\r
+ return captionSize.getWidth();\r
}\r
\r
public int getCaptionHeight() {\r
return 0;\r
}\r
\r
- return caption.getHeight();\r
+ return captionSize.getHeight();\r
}\r
\r
public int getCaptionWidthAfterComponent() {\r
return 0;\r
}\r
\r
- return caption.getWidth();\r
+ return getCaptionWidth();\r
}\r
\r
public int getCaptionHeightAboveComponent() {\r
return 0;\r
}\r
\r
- return caption.getHeight();\r
+ return getCaptionHeight();\r
}\r
\r
public int calculateVerticalAlignmentTopOffset(int emptySpace) {\r
.getHeight());\r
} else {\r
emptySpace -= widgetSize.getHeight();\r
- emptySpace -= caption.getHeight();\r
+ emptySpace -= getCaptionHeight();\r
}\r
} else {\r
/*\r
*/\r
captionSpace = 0;\r
widgetSpace -= widgetSize.getWidth();\r
- widgetSpace -= caption.getWidth();\r
+ widgetSpace -= getCaptionWidth();\r
} else {\r
/*\r
* The caption is above the component. Caption and widget needs\r
* separate alignment offsets.\r
*/\r
widgetSpace -= widgetSize.getWidth();\r
- captionSpace -= caption.getWidth();\r
+ captionSpace -= getCaptionWidth();\r
}\r
} else {\r
/*\r
\r
}\r
\r
+ int w = 0;\r
+ int h = 0;\r
+\r
+ if (caption != null) {\r
+ w = caption.getWidth();\r
+ h = caption.getHeight();\r
+ }\r
+\r
+ captionSize.setWidth(w);\r
+ captionSize.setHeight(h);\r
}\r
\r
private void setCaption(ICaption newCaption) {\r
return widget;\r
}\r
\r
+ /**\r
+ * Return true if the size of the widget has been specified in the selected\r
+ * orientation.\r
+ * \r
+ * @return\r
+ */\r
+ public boolean widgetHasSizeSpecified(int orientation) {\r
+ String size;\r
+ if (orientation == CellBasedLayout.ORIENTATION_HORIZONTAL) {\r
+ size = widget.getElement().getStyle().getProperty("width");\r
+ } else {\r
+ size = widget.getElement().getStyle().getProperty("height");\r
+ }\r
+ return (size != null && !size.equals(""));\r
+ }\r
+\r
public boolean isComponentRelativeSized(int orientation) {\r
if (relativeSize == null) {\r
return false;\r
// Also update caption max width\r
if (caption != null) {\r
caption.setMaxWidth(width);\r
+\r
+ captionSize.setWidth(caption.getWidth());\r
}\r
\r
}\r