]> source.dussan.org Git - vaadin-framework.git/commitdiff
PopupDateField without size calculations (#8313)
authorLeif Åstrand <leif@vaadin.com>
Mon, 20 Feb 2012 14:04:06 +0000 (16:04 +0200)
committerLeif Åstrand <leif@vaadin.com>
Mon, 20 Feb 2012 14:04:06 +0000 (16:04 +0200)
WebContent/VAADIN/themes/reindeer/datefield/datefield.css
src/com/vaadin/terminal/gwt/client/ui/VPopupCalendar.java
src/com/vaadin/terminal/gwt/client/ui/VPopupCalendarPaintable.java
src/com/vaadin/terminal/gwt/client/ui/VTextualDate.java

index 1dbc59257a0646c7f15804ca6e26b3f50c0565e4..574a4973bf8d719a33e050b02474e30159615086 100644 (file)
@@ -45,6 +45,7 @@ span.v-datefield-calendarpanel-month {
 }
 .v-datefield-popupcalendar {
        min-width: 0;
+       padding-right: 24px;
 }
 .v-datefield-year .v-datefield-calendarpanel {
        width: 100px;
@@ -224,16 +225,25 @@ td.v-datefield-calendarpanel-nextyear {
 .v-op .v-datefield-popup {
        background: rgba(255,255,255,.95);
 }
-.v-datefield-year .v-datefield-textfield {
+.v-datefield-textfield {
+       width: 100%;
+       box-sizing: border-box;
+       -moz-box-sizing: border-box;
+}
+.v-datefield.v-undefined-width > .v-datefield-textfield {
+       box-sizing: content-box;
+       -moz-box-sizing: content-box;
+}
+.v-datefield-year.v-undefined-width > .v-datefield-textfield {
        width: 4em;
 }
-.v-datefield-month .v-datefield-textfield {
+.v-datefield-month.v-undefined-width > .v-datefield-textfield {
        width: 5em;
 }
-.v-datefield-day .v-datefield-textfield {
+.v-datefield-day.v-undefined-width > .v-datefield-textfield {
        width: 5.5em;
 }
-.v-datefield-full .v-datefield-textfield {
+.v-datefield-full.v-undefined-width  >.v-datefield-textfield {
        width: 12em;
 }
 .v-datefield-popupcalendar input.v-datefield-textfield {
@@ -256,6 +266,7 @@ td.v-datefield-calendarpanel-nextyear {
 }
 .v-datefield-popupcalendar .v-datefield-button {
        width: 24px;
+       margin-right: -24px;
        height: 23px;
        background: transparent;
        border: none;
index 1c0b937e05c257b83445ac7a86288c4942b973b5..cbd3a7af8f5736ff17027941bdae1569e285c619 100644 (file)
@@ -274,20 +274,6 @@ public class VPopupCalendar extends VTextualDate implements Field,
         calendar.setFocus(focus);
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.vaadin.terminal.gwt.client.ui.VTextualDate#getFieldExtraWidth()
-     */
-    @Override
-    protected int getFieldExtraWidth() {
-        if (fieldExtraWidth < 0) {
-            fieldExtraWidth = super.getFieldExtraWidth();
-            fieldExtraWidth += calendarToggle.getOffsetWidth();
-        }
-        return fieldExtraWidth;
-    }
-
     /*
      * (non-Javadoc)
      * 
index 042d7307389e7e133143e64bcdf8e38191b7bfa6..5beb912ff0577423618de2cf72b42938375bdd58 100644 (file)
@@ -114,15 +114,6 @@ public class VPopupCalendarPaintable extends VTextualDatePaintable {
                             + "-button-readonly");
         }
 
-        if (lastReadOnlyState != getWidgetForPaintable().readonly
-                || lastEnabledState != getWidgetForPaintable().isEnabled()) {
-            // Enabled or readonly state changed. Differences in theming might
-            // affect the width (for instance if the popup button is hidden) so
-            // we have to recalculate the width (IF the width of the field is
-            // fixed)
-            getWidgetForPaintable().updateWidth();
-        }
-
         getWidgetForPaintable().calendarToggle.setEnabled(true);
     }
 
index bb808321b9e99d65a214c05c47efcf2fc1606ca0..a19be371cf3438c3b70ec3465652b3428dde4a6e 100644 (file)
@@ -14,7 +14,6 @@ import com.google.gwt.event.dom.client.FocusEvent;
 import com.google.gwt.event.dom.client.FocusHandler;
 import com.google.gwt.user.client.Element;
 import com.google.gwt.user.client.ui.TextBox;
-import com.vaadin.terminal.gwt.client.ContainerResizedListener;
 import com.vaadin.terminal.gwt.client.EventId;
 import com.vaadin.terminal.gwt.client.Focusable;
 import com.vaadin.terminal.gwt.client.LocaleNotLoadedException;
@@ -22,7 +21,7 @@ import com.vaadin.terminal.gwt.client.LocaleService;
 import com.vaadin.terminal.gwt.client.VConsole;
 
 public class VTextualDate extends VDateField implements Field, ChangeHandler,
-        ContainerResizedListener, Focusable, SubPartAware {
+        Focusable, SubPartAware {
 
     private static final String PARSE_ERROR_CLASSNAME = CLASSNAME
             + "-parseerror";
@@ -31,12 +30,6 @@ public class VTextualDate extends VDateField implements Field, ChangeHandler,
 
     protected String formatStr;
 
-    private String width;
-
-    private boolean needLayout;
-
-    protected int fieldExtraWidth = -1;
-
     protected boolean lenient;
 
     private static final String CLASSNAME_PROMPT = "prompt";
@@ -295,72 +288,6 @@ public class VTextualDate extends VDateField implements Field, ChangeHandler,
         return format.trim();
     }
 
-    @Override
-    public void setWidth(String newWidth) {
-        if (!"".equals(newWidth)
-                && (isUndefinedWidth() || !newWidth.equals(width))) {
-            needLayout = true;
-            width = newWidth;
-            super.setWidth(width);
-            iLayout();
-            if (newWidth.indexOf("%") < 0) {
-                needLayout = false;
-            }
-        } else {
-            if ("".equals(newWidth) && !isUndefinedWidth()) {
-                super.setWidth("");
-                iLayout(true);
-                width = null;
-            }
-        }
-    }
-
-    protected boolean isUndefinedWidth() {
-        return width == null || "".equals(width);
-    }
-
-    /**
-     * Returns pixels in x-axis reserved for other than textfield content.
-     * 
-     * @return extra width in pixels
-     */
-    protected int getFieldExtraWidth() {
-        if (fieldExtraWidth < 0) {
-            text.setWidth("0");
-            fieldExtraWidth = text.getOffsetWidth();
-        }
-        return fieldExtraWidth;
-    }
-
-    /**
-     * Force an recalculation of the width of the component IF the width has
-     * been defined. Does nothing if width is undefined as the width will be
-     * automatically adjusted by the browser.
-     */
-    public void updateWidth() {
-        if (isUndefinedWidth()) {
-            return;
-        }
-        needLayout = true;
-        fieldExtraWidth = -1;
-        iLayout(true);
-    }
-
-    public void iLayout() {
-        iLayout(false);
-    }
-
-    public void iLayout(boolean force) {
-        if (needLayout || force) {
-            int textFieldWidth = getOffsetWidth() - getFieldExtraWidth();
-            if (textFieldWidth < 0) {
-                // Field can never be smaller than 0 (causes exception in IE)
-                textFieldWidth = 0;
-            }
-            text.setWidth(textFieldWidth + "px");
-        }
-    }
-
     public void focus() {
         text.setFocus(true);
     }