diff options
author | Matti Tahvonen <matti.tahvonen@itmill.com> | 2008-03-14 07:59:12 +0000 |
---|---|---|
committer | Matti Tahvonen <matti.tahvonen@itmill.com> | 2008-03-14 07:59:12 +0000 |
commit | 52df81b4d4b945cdd4d347f96886406ac3389c84 (patch) | |
tree | 3e2a8c6687c34b845f07bc0736d922701d60df5e /src/com/itmill/toolkit/terminal | |
parent | 34b3d15275aea29c27e11c78eab1a8c8934be0f9 (diff) | |
download | vaadin-framework-52df81b4d4b945cdd4d347f96886406ac3389c84.tar.gz vaadin-framework-52df81b4d4b945cdd4d347f96886406ac3389c84.zip |
TextFields now support width properly
svn changeset:4045/svn branch:trunk
Diffstat (limited to 'src/com/itmill/toolkit/terminal')
-rw-r--r-- | src/com/itmill/toolkit/terminal/gwt/client/ui/IPopupCalendar.java | 8 | ||||
-rw-r--r-- | src/com/itmill/toolkit/terminal/gwt/client/ui/ITextualDate.java | 48 |
2 files changed, 55 insertions, 1 deletions
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IPopupCalendar.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IPopupCalendar.java index 098967b8d9..c398c1b742 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IPopupCalendar.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IPopupCalendar.java @@ -111,4 +111,12 @@ public class IPopupCalendar extends ITextualDate implements Paintable, calendar.setFocus(focus);
}
+ protected int getFieldExtraWidth() {
+ if (fieldExtraWidth < 0) {
+ fieldExtraWidth = super.getFieldExtraWidth();
+ fieldExtraWidth += calendarToggle.getOffsetWidth();
+ }
+ return fieldExtraWidth;
+ }
+
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITextualDate.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITextualDate.java index beff13d1c5..02a401833d 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITextualDate.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITextualDate.java @@ -8,13 +8,14 @@ import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.ui.ChangeListener;
import com.google.gwt.user.client.ui.Widget;
import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;
+import com.itmill.toolkit.terminal.gwt.client.ContainerResizedListener;
import com.itmill.toolkit.terminal.gwt.client.DateLocale;
import com.itmill.toolkit.terminal.gwt.client.Paintable;
import com.itmill.toolkit.terminal.gwt.client.UIDL;
import com.itmill.toolkit.terminal.gwt.client.util.SimpleDateFormat;
public class ITextualDate extends IDateField implements Paintable,
- ChangeListener {
+ ChangeListener, ContainerResizedListener {
private final ITextField text;
@@ -22,6 +23,12 @@ public class ITextualDate extends IDateField implements Paintable, private DateLocale dl;
+ private String width;
+
+ private boolean needLayout;
+
+ protected int fieldExtraWidth = -1;
+
public ITextualDate() {
super();
text = new ITextField();
@@ -237,4 +244,43 @@ public class ITextualDate extends IDateField implements Paintable, return format.trim();
}
+
+ public void setWidth(String newWidth) {
+ if (!"".equals(newWidth) && (width == null || !newWidth.equals(width))) {
+ needLayout = true;
+ width = newWidth;
+ super.setWidth(width);
+ iLayout();
+ if (newWidth.indexOf("%") < 0) {
+ needLayout = false;
+ }
+ } else {
+ if (width != null && !"".equals(width)) {
+ super.setWidth("");
+ needLayout = true;
+ iLayout();
+ needLayout = false;
+ width = null;
+ }
+ }
+ }
+
+ /**
+ * Returns pixels in x-axis reserved for other than textfield content.
+ *
+ * @return extra width in pixels
+ */
+ protected int getFieldExtraWidth() {
+ if (fieldExtraWidth < 0) {
+ text.setWidth("0px");
+ fieldExtraWidth = text.getOffsetWidth();
+ }
+ return fieldExtraWidth;
+ }
+
+ public void iLayout() {
+ if (needLayout) {
+ text.setWidth((getOffsetWidth() - getFieldExtraWidth()) + "px");
+ }
+ }
}
|