Ejemplo n.º 1
0
 GWTFontMetrics getFontMetrics(Font font) {
   GWTFontMetrics metrics = fontMetrics.get(font);
   if (metrics == null) {
     measureElement.getStyle().setFontSize(font.size, Unit.PX);
     measureElement.getStyle().setFontWeight(Style.FontWeight.NORMAL);
     measureElement.getStyle().setFontStyle(Style.FontStyle.NORMAL);
     measureElement.getStyle().setProperty("fontFamily", font.name);
     measureElement.setInnerText(HEIGHT_TEXT);
     switch (font.style) {
       case BOLD:
         measureElement.getStyle().setFontWeight(Style.FontWeight.BOLD);
         break;
       case ITALIC:
         measureElement.getStyle().setFontStyle(Style.FontStyle.ITALIC);
         break;
       case BOLD_ITALIC:
         measureElement.getStyle().setFontWeight(Style.FontWeight.BOLD);
         measureElement.getStyle().setFontStyle(Style.FontStyle.ITALIC);
         break;
       default:
         break;
     }
     float height = measureElement.getOffsetHeight();
     measureElement.setInnerText(EMWIDTH_TEXT);
     float emwidth = measureElement.getOffsetWidth();
     metrics = new GWTFontMetrics(font, height, emwidth);
     fontMetrics.put(font, metrics);
   }
   return metrics;
 }
Ejemplo n.º 2
0
  public VSlider() {
    super();

    base = DOM.createDiv();
    handle = DOM.createDiv();
    smaller = DOM.createDiv();
    bigger = DOM.createDiv();

    setStyleName(CLASSNAME);

    getElement().appendChild(bigger);
    getElement().appendChild(smaller);
    getElement().appendChild(base);
    base.appendChild(handle);

    // Hide initially
    smaller.getStyle().setDisplay(Display.NONE);
    bigger.getStyle().setDisplay(Display.NONE);

    sinkEvents(
        Event.MOUSEEVENTS
            | Event.ONMOUSEWHEEL
            | Event.KEYEVENTS
            | Event.FOCUSEVENTS
            | Event.TOUCHEVENTS);

    feedbackPopup.setWidget(feedback);
  }
Ejemplo n.º 3
0
  /**
   * Tunes splitter. Makes it wider and adds double border to seem rich.
   *
   * @param el element to tune
   */
  private void tuneSplitter(Element el) {
    /** Add Z-Index to move the splitter on the top and make content visible */
    el.getParentElement().getStyle().setProperty("zIndex", "1000");
    el.getParentElement().getStyle().setProperty("overflow", "visible");

    /** Tune splitter catch panel */
    el.getStyle().setProperty("boxSizing", "border-box");
    el.getStyle().setProperty("width", "5px");
    el.getStyle().setProperty("overflow", "hidden");
    el.getStyle().setProperty("marginLeft", "-3px");
    el.getStyle().setProperty("backgroundColor", "transparent");

    /** Add small border */
    DivElement smallBorder = Document.get().createDivElement();
    smallBorder.getStyle().setProperty("position", "absolute");
    smallBorder.getStyle().setProperty("width", "1px");
    smallBorder.getStyle().setProperty("height", "100%");
    smallBorder.getStyle().setProperty("left", "3px");
    smallBorder.getStyle().setProperty("top", "0px");
    smallBorder.getStyle().setProperty("backgroundColor", Style.getSplitterSmallBorderColor());
    el.appendChild(smallBorder);

    /** Add large border */
    DivElement largeBorder = Document.get().createDivElement();
    largeBorder.getStyle().setProperty("position", "absolute");
    largeBorder.getStyle().setProperty("width", "2px");
    largeBorder.getStyle().setProperty("height", "100%");
    largeBorder.getStyle().setProperty("left", "1px");
    largeBorder.getStyle().setProperty("top", "0px");
    largeBorder.getStyle().setProperty("opacity", "0.4");
    largeBorder.getStyle().setProperty("backgroundColor", Style.getSplitterLargeBorderColor());
    el.appendChild(largeBorder);
  }
Ejemplo n.º 4
0
 protected void recalcMargins() {
   List<Widget> north = new ArrayList<>();
   List<Widget> south = new ArrayList<>();
   Widget center = getCenter();
   for (Widget w : getChildren()) {
     Direction d = getResolvedDirection(getWidgetDirection(w));
     if (d == Direction.WEST) {
       // west = w;
     } else if (d == Direction.EAST) {
       // east = w;
     } else if (d == Direction.NORTH) {
       north.add(w);
     } else if (d == Direction.SOUTH) {
       south.add(w);
     }
   }
   if (center != null) {
     Element centerContainer = getWidgetContainerElement(center);
     centerContainer.getStyle().setMarginLeft(hgap, Style.Unit.PX);
     centerContainer.getStyle().setMarginRight(hgap, Style.Unit.PX);
     centerContainer.getStyle().setMarginTop(vgap, Style.Unit.PX);
     centerContainer.getStyle().setMarginBottom(vgap, Style.Unit.PX);
   }
   /*
    * if (!north.isEmpty()) { for (Widget w : north) { Element
    * northContainer = getWidgetContainerElement(w);
    * northContainer.getStyle().setMarginLeft(hgap, Style.Unit.PX);
    * northContainer.getStyle().setMarginRight(hgap, Style.Unit.PX); } } if
    * (!south.isEmpty()) { for (Widget w : south) { Element southContainer
    * = getWidgetContainerElement(w);
    * southContainer.getStyle().setMarginLeft(hgap, Style.Unit.PX);
    * southContainer.getStyle().setMarginRight(hgap, Style.Unit.PX); } }
    */
 }
Ejemplo n.º 5
0
  public static void setFlex(Element el, double flex) {
    /* iOS < 7 && Android < 4.4*/
    el.getStyle().setProperty("WebkitBoxFlex", Double.toString(flex));

    el.getStyle().setProperty("MozFlex", Double.toString(flex));
    el.getStyle().setProperty("WebkitFlex", Double.toString(flex));
    el.getStyle().setProperty("flex", Double.toString(flex));
  }
Ejemplo n.º 6
0
 public static void hideElement(Element element) {
   if (!Display.NONE
       .toString()
       .toLowerCase()
       .equals(element.getStyle().getDisplay().toLowerCase())) {
     element.getStyle().setDisplay(Display.NONE);
   }
 }
Ejemplo n.º 7
0
  void buildHandle() {
    final String handleAttribute = isVertical() ? "marginTop" : "marginLeft";
    final String oppositeHandleAttribute = isVertical() ? "marginLeft" : "marginTop";

    handle.getStyle().setProperty(handleAttribute, "0");

    // clear unnecessary opposite handle attribute
    handle.getStyle().clearProperty(oppositeHandleAttribute);
  }
Ejemplo n.º 8
0
 public void setCreating(boolean creating) {
   if (creating) {
     editTitle.getStyle().setDisplay(Display.NONE);
     createTitle.getStyle().clearDisplay();
   } else {
     editTitle.getStyle().clearDisplay();
     createTitle.getStyle().setDisplay(Display.NONE);
   }
 }
Ejemplo n.º 9
0
 public void setHeight(int h) {
   if (h == -1) {
     getElement().getStyle().setProperty("height", "");
     eventContent.getStyle().setProperty("height", "");
   } else {
     getElement().getStyle().setHeight(h, Unit.PX);
     // FIXME measure the border height (2px) from the DOM
     eventContent.getStyle().setHeight(h - 2, Unit.PX);
   }
 }
 private void updateResetButtonVisibility() {
   if (textField.getValue().isEmpty()
       || textField.isReadOnly()
       || !textField.isEnabled()
       || textField.getStyleName().contains("v-textfield-prompt")) {
     resetButtonElement.getStyle().setDisplay(Display.NONE);
   } else {
     resetButtonElement.getStyle().clearDisplay();
   }
 }
Ejemplo n.º 11
0
 private void setHeight() {
   // Calculate decoration size
   base.getStyle().setHeight(0, Unit.PX);
   base.getStyle().setOverflow(Overflow.HIDDEN);
   int h = getElement().getOffsetHeight();
   if (h < MIN_SIZE) {
     h = MIN_SIZE;
   }
   base.getStyle().setHeight(h, Unit.PX);
   base.getStyle().clearOverflow();
 }
Ejemplo n.º 12
0
  /**
   * When enabled, the background will be blocked with a semi-transparent pane the next time it is
   * shown. If the PopupPanel is already visible, the glass will not be displayed until it is hidden
   * and shown again.
   *
   * @param enabled true to enable, false to disable
   */
  public void setGlassEnabled(boolean enabled) {
    this.isGlassEnabled = enabled;
    if (enabled && glass == null) {
      glass = Document.get().createDivElement();
      glass.setClassName(glassStyleName);

      glass.getStyle().setPosition(Position.ABSOLUTE);
      glass.getStyle().setLeft(0, Unit.PX);
      glass.getStyle().setTop(0, Unit.PX);
    }
  }
Ejemplo n.º 13
0
  @Override
  public void setEditTitle(boolean edit) {

    if (edit) {
      editTitle.getStyle().clearDisplay();
      createTitle.getStyle().setDisplay(Display.NONE);
    } else {
      editTitle.getStyle().setDisplay(Display.NONE);
      createTitle.getStyle().clearDisplay();
    }
  }
Ejemplo n.º 14
0
  public void setSubmenu(Menu menu) {

    subMenu = menu;

    if (subMenu != null) {
      accessoryElement.getStyle().setDisplay(Style.Display.BLOCK);
      subMenu.setParentMenu(getMenu());
    } else {
      accessoryElement.getStyle().setDisplay(Style.Display.NONE);
    }
  }
Ejemplo n.º 15
0
 public static void setOrientation(Element el, Orientation value) {
   // iOS6 & Android < 4.4
   switch (value) {
     case HORIZONTAL:
       el.getStyle().setProperty("WebkitBoxOrient", "horizontal");
       break;
     case VERTICAL:
       el.getStyle().setProperty("WebkitBoxOrient", "vertical");
       break;
     default:
       throw new RuntimeException();
   }
   setFlexProperty(el, Orientation.getCssProperty(), value.getCssValue());
 }
Ejemplo n.º 16
0
 protected static void hideBlackMask(Element mainPageElem) {
   if (mainPageElem == null) {
     return;
   }
   Element menuElem = mainPageElem.getParentElement();
   if (menuElem == null) {
     return;
   }
   for (int it = 0; it < menuElem.getChildCount(); it++) {
     Element menuChildElem = menuElem.getChild(it).cast();
     String color = menuChildElem.getStyle().getBackgroundColor();
     if ("black".equalsIgnoreCase(color)) {
       menuChildElem.getStyle().setBackgroundColor("transparent");
     }
   }
 }
Ejemplo n.º 17
0
  /**
   * This method constructs the application user interface by instantiating controls and hooking up
   * event handler.
   */
  public void init() {
    // Inject global styles.
    GWT.<GlobalResources>create(GlobalResources.class).css().ensureInjected();

    // Create the UI defined in Mail.ui.xml.
    DockLayoutPanel outer = binder.createAndBindUi(this);

    // Get rid of scrollbars, and clear out the window's built-in margin,
    // because we want to take advantage of the entire client area.
    Window.enableScrolling(false);
    Window.setMargin("0px");

    // Special-case stuff to make topPanel overhang a bit.
    Element topElem = outer.getWidgetContainerElement(topPanel);
    topElem.getStyle().setZIndex(2);
    topElem.getStyle().setOverflow(Overflow.VISIBLE);

    // Listen for item selection, displaying the currently-selected item in
    // the detail area.
    //    mailList.setListener(new MailList.Listener() {
    //      public void onItemSelected(MailItem item) {
    //        mailDetail.setItem(item);
    //      }
    //    });

    // Add the outer panel to the RootLayoutPanel, so that it will be
    // displayed.

    // MenuMain PRINCIPAL
    RootLayoutPanel.get().add(outer);
  }
Ejemplo n.º 18
0
  /**
   * Automatically tries to create a proxy image from given element.
   *
   * @param element
   * @param alignImageToEvent if true, proxy image is aligned to start event, else next to mouse
   *     cursor
   * @deprecated As of 7.2, call or override {@link #createDragImage(Element,boolean)} instead
   */
  @Deprecated
  public void createDragImage(
      com.google.gwt.user.client.Element element, boolean alignImageToEvent) {
    Element cloneNode = (Element) element.cloneNode(true);

    // Set size explicitly for cloned node to avoid stretching #14617.
    cloneNode.getStyle().setWidth(element.getOffsetWidth(), Unit.PX);
    cloneNode.getStyle().setHeight(element.getOffsetHeight(), Unit.PX);

    syncContent(element, cloneNode);
    if (BrowserInfo.get().isIE()) {
      if (cloneNode.getTagName().toLowerCase().equals("tr")) {
        TableElement table = Document.get().createTableElement();
        TableSectionElement tbody = Document.get().createTBodyElement();
        table.appendChild(tbody);
        tbody.appendChild(cloneNode);
        cloneNode = table.cast();
      }
    }
    if (alignImageToEvent) {
      int absoluteTop = element.getAbsoluteTop();
      int absoluteLeft = element.getAbsoluteLeft();
      int clientX = WidgetUtil.getTouchOrMouseClientX(startEvent);
      int clientY = WidgetUtil.getTouchOrMouseClientY(startEvent);
      int offsetX = absoluteLeft - clientX;
      int offsetY = absoluteTop - clientY;
      setDragImage(cloneNode, offsetX, offsetY);
    } else {
      setDragImage(cloneNode);
    }
  }
Ejemplo n.º 19
0
 private void setOpacity(Element e, String val) {
   if (val == null || val.trim().length() == 0) {
     val = "1";
   }
   e.getStyle().setProperty("zoom", "1");
   e.getStyle().setProperty("filter", "alpha(opacity=" + (int) (Double.valueOf(val) * 100) + ")");
 }
Ejemplo n.º 20
0
  public TabBar(Callback callback) {
    this.callback = callback;

    Element div = DOM.createDiv();

    setElement(div);

    setStylePrimaryName("RibbonTab");

    clear = DOM.createDiv();
    clear.getStyle().setProperty("clear", "both");
    div.appendChild(clear);

    addDomHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            Element tgt = event.getNativeEvent().getEventTarget().cast();
            if (tgt.getParentElement() != getElement()) return;

            int index = DOM.getChildIndex(getElement(), tgt);
            if (index >= getTabCount()) return;

            selectTab(index);
          }
        },
        ClickEvent.getType());
  }
Ejemplo n.º 21
0
 public void doSlideToTop(int durationMilli) {
   this.initMarginTop =
       Integer.parseInt(
           element.getStyle().getMarginTop().replace(Unit.PX.getType(), "").replace(" ", ""));
   cancel();
   currentOp = IabakoAnimation.SLIDE_TO_TOP_FROM_CENTER;
   run(durationMilli);
 }
Ejemplo n.º 22
0
 /**
  * Sets a DOM element's opacity
  *
  * @param e
  * @param percent
  */
 public static void setOpacity(final Element e, final int percent) {
   final Style s = e.getStyle();
   final double d = ((double) percent / (double) 100);
   s.setProperty("opacity", String.valueOf(d));
   s.setProperty("MozOpacity", String.valueOf(d));
   s.setProperty("KhtmlOpacity", String.valueOf(d));
   s.setProperty("filter", "alpha(opacity=" + percent + ")");
 }
Ejemplo n.º 23
0
 @Override
 public double getOpacity(Element e) {
   Style s = e.getStyle();
   String o = s.getProperty("filter");
   if (o != null) {
     return !o.matches(".*opacity=.*") ? 1 : Double.valueOf(o.replaceAll("[^\\d]", "")) / 100;
   }
   return super.getOpacity(e);
 }
Ejemplo n.º 24
0
 private void show(boolean applyToParent, UIObject... objs) {
   for (UIObject obj : objs) {
     Element ele = obj.getElement();
     if (applyToParent) {
       ele = ele.getParentElement();
     }
     ele.getStyle().clearDisplay();
   }
 }
Ejemplo n.º 25
0
 private void processStyle(Element e, String value) {
   String[] styles = value.split("\\s*;\\s*");
   for (String style : styles) {
     Matcher m = STYLE_PATTERN.matcher(style);
     if (m.matches()) {
       e.getStyle().setProperty(m.group(1), m.group(2));
     }
   }
 }
Ejemplo n.º 26
0
 public void slideFromMarginTop(int durationMilli, int marginTop) {
   this.initMarginTop = marginTop;
   this.maxMarginTop =
       Integer.parseInt(
           element.getStyle().getMarginTop().replace(Unit.PX.getType(), "").replace(" ", ""));
   cancel();
   currentOp = IabakoAnimation.SLIDE_DOWN;
   run(durationMilli);
 }
Ejemplo n.º 27
0
 public void slideFromTopToCenter(int durationMilli) {
   this.initMarginTop =
       Integer.parseInt(
           element.getStyle().getMarginTop().replace(Unit.PX.getType(), "").replace(" ", ""));
   this.maxMarginTop = Window.getClientHeight() / 2 - element.getOffsetHeight() / 2;
   cancel();
   currentOp = IabakoAnimation.SLIDE_DOWN;
   run(durationMilli);
 }
Ejemplo n.º 28
0
  public void setIcon(String iconClass) {

    setCheckable(false);

    if (this.iconClass != null) {
      markerElement.removeClassName(this.iconClass);
    }

    if (iconClass != null) {

      this.iconClass = iconClass;
      markerElement.getStyle().setDisplay(Style.Display.BLOCK);
      markerElement.addClassName(iconClass);

    } else {
      markerElement.getStyle().setDisplay(Style.Display.NONE);
    }
  }
Ejemplo n.º 29
0
 private void hide(boolean applyToParent, UIObject... objs) {
   for (UIObject obj : objs) {
     Element ele = obj.getElement();
     if (applyToParent) {
       ele = ele.getParentElement();
     }
     ele.getStyle().setDisplay(Display.NONE);
   }
 }
Ejemplo n.º 30
0
  public S screenCenter() {
    int width = this.outerWidth();
    int height = this.outerHeight();

    int left = (Window.getClientWidth() - width) >> 1;
    int top = (Window.getClientHeight() - height) >> 1;

    int computedLeft =
        Math.max(Window.getScrollLeft() + left, 0) - Document.get().getBodyOffsetLeft();
    int computedTop = Math.max(Window.getScrollTop() + top, 0) - Document.get().getBodyOffsetTop();

    Element element = this.getElement();
    element.getStyle().setPropertyPx("left", computedLeft);
    element.getStyle().setPropertyPx("top", computedTop);
    element.getStyle().setPosition(Position.ABSOLUTE);

    return (S) this;
  }