List of usage examples for com.google.gwt.user.client Window getClientHeight
public static int getClientHeight()
From source file:fr.fg.client.map.impl.BaseMap.java
License:Open Source License
public void onWindowResized(int width, int height) { this.bounds = new Dimension(Window.getClientWidth(), Window.getClientHeight()); updateView();/* w w w. j a va2 s. com*/ }
From source file:fr.fg.client.openjwt.ui.JSDialog.java
License:Open Source License
/** * Dplace le dialogue une position donne sur l'cran. * * @param x L'abscisse du coin suprieur gauche du dialogue par rapport au * coin suprieur de la page, en pixels.// w w w . ja v a 2 s. c o m * @param y L'ordonne du coin suprieur gauche du dialogue par rapport au * coin suprieur de la page, en pixels. * @param withinPage Indique si la fentre doit rester dans les * limites de la page. Vaut false par dfaut. */ public void setLocation(int x, int y, boolean withinPage) { if (withinPage) { int clientWidth = Window.getClientWidth(); int clientHeight = Window.getClientHeight(); int width = getPixelWidth(); int height = getPixelHeight(); // Vrifie que le dialogue ne sort pas de la page if (x + width >= clientWidth) x = clientWidth - width - 1; if (x < 0) x = 0; if (y + height >= clientHeight) y = clientHeight - height - 1; if (y < 0) y = 0; } this.dialogX = x; this.dialogY = y; getElement().getStyle().setProperty("left", x + "px"); getElement().getStyle().setProperty("top", y + "px"); }
From source file:fr.fg.client.openjwt.ui.JSDialog.java
License:Open Source License
/** * Centre le dialogue l'cran.//from w w w.ja v a 2 s .com */ public void centerOnScreen() { // Dimensions de l'cran int clientWidth = Window.getClientWidth(); int clientHeight = Window.getClientHeight(); if (!isAttached()) { boolean visible = isVisible(); super.setVisible(true); RootPanel.get().add(this, 0, 0); // Centre le dialogue setLocation((clientWidth - getPixelWidth()) / 2, (clientHeight - getPixelHeight()) / 2, true); RootPanel.get().remove(this); super.setVisible(visible); } else { // Centre le dialogue setLocation((clientWidth - getPixelWidth()) / 2, (clientHeight - getPixelHeight()) / 2, true); } }
From source file:fr.putnami.pwt.core.widget.client.Affix.java
License:Open Source License
public void reset() { Element e = this.getElement(); StyleUtils.addStyle(e, Affixed.TOP); this.clearElementStyle(); this.clientHeigth = Window.getClientHeight(); this.pinnedOffset = e.getAbsoluteTop(); this.offsetWidth = e.getClientWidth(); StyleUtils.addStyle(e, this.affixed); this.resetPosistion(); }
From source file:fr.putnami.pwt.core.widget.client.base.SimpleDropdown.java
License:Open Source License
@Override public void open() { StyleUtils.addStyle(this, SimpleDropdown.STYLE_OPEN); Element menuElt = this.menuContainer.getElement(); int topMenu = menuElt.getAbsoluteTop() - Window.getScrollTop(); int menuHeight = menuElt.getOffsetHeight(); int anchorHeight = this.anchor.getOffsetHeight(); int clientHeight = Window.getClientHeight(); if (topMenu + menuHeight > clientHeight && topMenu >= anchorHeight + menuHeight) { StyleUtils.addStyle(this, SimpleDropdown.STYLE_OPEN_UP); }/* w ww. ja v a2s .co m*/ int leftMenu = menuElt.getAbsoluteLeft() - Window.getScrollLeft(); int menuWidth = menuElt.getOffsetWidth(); int anchorWidth = this.anchor.getOffsetWidth(); int clientWidth = Window.getClientWidth(); if (leftMenu + menuWidth > clientWidth && leftMenu >= anchorWidth + menuWidth) { StyleUtils.addStyle(this, SimpleDropdown.STYLE_OPEN_LEFT); } this.open = true; this.updateHandlers(); }
From source file:geogebra.web.gui.advanced.client.ui.widget.ListPopupPanel.java
License:Apache License
/** Adjusts drop down list sizes to make it take optimal area on the screen. */ protected void adjustSize() { ScrollPanel table = getScrollPanel(); int visibleRows = getVisibleRows(); int delta = getElement().getOffsetWidth() - getElement().getClientWidth(); getScrollPanel().setWidth((getComboBox().getOffsetWidth() - delta) + "px"); if (visibleRows <= 0) { table.setHeight(""); int spaceAbove = getComboBox().getAbsoluteTop(); int spaceUnder = Window.getClientHeight() - getComboBox().getAbsoluteTop() - getComboBox().getOffsetHeight(); DOM.setStyleAttribute(table.getElement(), "maxHeight", Math.min(Window.getClientHeight() * 0.3, Math.max(spaceAbove, spaceUnder)) + "px"); } else if (getComboBox().getModel().getCount() > visibleRows) { int index = getStartItemIndex(); int count = getItemCount(); if (index + visibleRows > count) { index = count - visibleRows + 1; if (index < 0) index = 0;//from w w w .j a va2s . com } int listHeight = 0; int scrollPosition = 0; for (int i = 0; i < index + visibleRows && i < count; i++) { int height = getList().getWidget(i).getOffsetHeight(); if (i < index) scrollPosition += height; else listHeight += height; } table.setSize(table.getOffsetWidth() + "px", listHeight + "px"); table.setScrollPosition(scrollPosition); DOM.setStyleAttribute(table.getElement(), "maxHeight", ""); } else { table.setHeight(""); DOM.setStyleAttribute(table.getElement(), "maxHeight", ""); } resetPosition(); }
From source file:geogebra.web.gui.advanced.client.ui.widget.ListPopupPanel.java
License:Apache License
/** Chooses and sets a mostly appropriate position of the drop down list */ protected void resetPosition() { if (getDropDownPosition() == DropDownPosition.ABOVE || getDropDownPosition() == DropDownPosition.AUTO && Window.getClientHeight() - getComboBox().getAbsoluteTop() - getComboBox().getOffsetHeight() < getComboBox().getAbsoluteTop()) { setPopupPosition(getComboBox().getAbsoluteLeft(), getComboBox().getAbsoluteTop() - getOffsetHeight()); } else if (getDropDownPosition() == DropDownPosition.UNDER || getDropDownPosition() == DropDownPosition.AUTO) { setPopupPosition(getComboBox().getAbsoluteLeft(), getComboBox().getAbsoluteTop() + getComboBox().getOffsetHeight()); }/* w w w. j a va 2s . c o m*/ }
From source file:geogebra.web.gui.advanced.client.ui.widget.ListPopupPanel.java
License:Apache License
/** * This method checks whether the limit of displayed items reached.<p/> * It takes into account different aspects including setting of the widget, geometrical size of the * drop down list and selected value that must be displayed.<p/> * This method optimally chooses a number of items to display. * * @param previouslyRenderedRows is a number of rows previously loaded in the list * (items count before filling the list). * @return a result of check./*from w w w.jav a 2s . c o m*/ */ protected boolean isRenderingLimitReached(int previouslyRenderedRows) { ListDataModel model = getComboBox().getModel(); int previousHeight = 0; if (previouslyRenderedRows > 0) { Widget last = getItem(previouslyRenderedRows - 1); Widget first = getItem(0); previousHeight = last.getOffsetHeight() + last.getAbsoluteTop() - first.getAbsoluteTop(); } return model.getCount() <= 0 // no data // OR a selected value has already been displayed || getItemCount() > getComboBox().getSelectedIndex() // AND one of the following conditions is true: && (getItemCount() >= model.getCount() //no items any more // OR no limit but there are too many items || isLazyRenderingEnabled() && getVisibleRows() <= 0 && getList().getOffsetHeight() - previousHeight >= Window.getClientHeight() * 0.6 // OR visible rows number is limited and there was a new page rendered excepting the first page // since two pages may be displayed if the list is rendered first time || isLazyRenderingEnabled() && getVisibleRows() > 0 && getItemCount() - previouslyRenderedRows > 0 && (getItemCount() - previouslyRenderedRows) % getVisibleRows() == 0 && (getItemCount() - previouslyRenderedRows) / getVisibleRows() != 1); }
From source file:geogebra.web.gui.advanced.client.ui.widget.LockingPanel.java
License:Apache License
/** * Shows the panel.//from w ww . ja v a 2s .co m */ public void lock() { setStyleName("advanced-LockingPanel"); setPopupPosition(0, 0); setWidth("100%"); setHeight("100%"); setPixelSize(Window.getClientWidth(), Window.getClientHeight()); show(); }
From source file:geogebra.web.gui.util.PopupPanel.java
License:Apache License
/** * Centers the popup in the browser window and shows it. If the popup was * already showing, then the popup is centered. *//*from w w w . j a v a 2s .c om*/ public void center() { boolean initiallyShowing = showing; boolean initiallyAnimated = isAnimationEnabled; if (!initiallyShowing) { setVisible(false); setAnimationEnabled(false); show(); } // If left/top are set from a previous center() call, and our content // has changed, we may get a bogus getOffsetWidth because our new content // is wrapping (giving a lower offset width) then it would without the // previous left. Setting left/top back to 0 avoids this. Element elem = getElement(); elem.getStyle().setPropertyPx("left", 0); elem.getStyle().setPropertyPx("top", 0); int left = (Window.getClientWidth() - getOffsetWidth()) >> 1; int top = (Window.getClientHeight() - getOffsetHeight()) >> 1; setPopupPosition(Math.max(Window.getScrollLeft() + left, 0), Math.max(Window.getScrollTop() + top, 0)); if (!initiallyShowing) { setAnimationEnabled(initiallyAnimated); // Run the animation. The popup is already visible, so we can skip the // call to setState. if (initiallyAnimated) { impl.setClip(getElement(), "rect(0px, 0px, 0px, 0px)"); setVisible(true); resizeAnimation.run(ANIMATION_DURATION); } else { setVisible(true); } } }