List of usage examples for com.google.gwt.user.client Window getClientWidth
public static int getClientWidth()
From source file:com.gwtcx.extgwt.client.desktop.view.contact.AbstractContactTabbedFormView.java
License:Open Source License
protected void resize() { int width = Window.getClientWidth(); int height = Window.getClientHeight(); VerticalLayoutContainer layout = null; Log.debug("resize() - width: " + width + " height: " + height); getPanel().setSize(width + "px", height + "px"); getForm().setSize(width + "px", height + "px"); getTabPanel().setWidth(width + "px"); if (getTabTemplate() == null) { Log.error("You must call setTabTemplate() in the constructor of your derived class"); return;//from w w w. j av a 2 s . co m } for (int row = 0; row < getNumberOfTabs(); row++) { layout = entityTabs[row].getLayoutContainer(); if (layout != null && layout instanceof com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer) { layout.setSize(width + "px", height + "px"); Log.debug("layout.setSize()"); } } getPanel().onResize(); }
From source file:com.gwtm.ui.client.widgets.OverlayPanel.java
License:Apache License
private void doPosition(Style s) { if (isCentered) { setBottom(null);//from www . j a v a 2 s . c o m setRight(null); setTop("50%"); setLeft("50%"); int height = getWidget().getOffsetHeight(); int width = getWidget().getOffsetWidth(); int centralPointW = Window.getClientWidth() / 2; int centralPointH = Window.getClientHeight() / 2; int newLeft = centralPointW - (width / 2); int newTop = centralPointH - (height / 2); getWidget().getElement().getStyle().setLeft(newLeft, Unit.PX); getWidget().getElement().getStyle().setTop(newTop, Unit.PX); // XLog.info("height: " + height + ", getOffsetHeight(): " + // getOffsetHeight()); // int top_ = height >= getOffsetHeight() ? 0 : (height / 2); // int left_ = width >= getOffsetWidth() ? 0 : (width / 2); // // s.setProperty("marginTop", "-" + top_ + "px"); // s.setProperty("marginLeft", "-" + left_ + "px"); } else { if (top == null) { s.clearProperty("top"); } else { s.setProperty("top", top); } if (right == null) { s.clearProperty("right"); } else { s.setProperty("right", right); } if (bottom == null) { s.clearProperty("bottom"); } else { s.setProperty("bottom", bottom); } if (left == null) { s.clearProperty("left"); } else { s.setProperty("left", left); } } }
From source file:com.gwtmobile.ui.client.page.Page.java
License:Apache License
private static void setPageResolution() { int clientWidth = Window.getClientWidth(); if (Utils.isDesktop()) { Document.get().getDocumentElement().setClassName("HVGA"); } else if (clientWidth < 320) { Document.get().getDocumentElement().setClassName("QVGA"); } else if (clientWidth < 480) { Document.get().getDocumentElement().setClassName("HVGA"); } else if (clientWidth < 560) { Document.get().getDocumentElement().setClassName("WVGA"); } else {// w w w.java 2s . c om Document.get().getDocumentElement().setClassName("WXGA"); } }
From source file:com.gwtmodel.table.view.util.ModalDialog.java
License:Apache License
public void show(final WSize w, final SolidPos sPos) { // TODO: showRelativeTo seems not working properly // if (w.getW() != null) { // dBox.showRelativeTo(w.getW()); // } else/* w w w.j ava 2 s.c o m*/ dBox.setPopupPositionAndShow(new PopupPanel.PositionCallback() { @Override public void setPosition(int offsetWidth, int offsetHeight) { assert w != null : LogT.getT().cannotBeNull(); int maxwi = Window.getClientWidth(); int maxhei = Window.getClientHeight(); int t = w.getTop() + w.getHeight(); int l = w.getLeft(); int left = MaxI.min(maxwi - offsetWidth, l); int top = MaxI.min(maxhei - offsetHeight, t); if (sPos.getStartl() != -1) top = sPos.getStartl(); if (sPos.getStartcol() != -1) left = sPos.getStartcol(); if (sPos.getMaxstartl() != -1 && top > sPos.getMaxstartl()) top = sPos.getMaxstartl(); if (sPos.getMaxstartcol() != -1 && left > sPos.getMaxstartcol()) left = sPos.getMaxstartcol(); if (top < 0) top = 0; dBox.setPopupPosition(left, top); } }); }
From source file:com.gwtplatform.mvp.client.view.CenterPopupPositioner.java
License:Apache License
/** * By default this method centers the popup horizontally. * You can override this method to change the horizontal position of the popup. * @param popupWidth//w w w . ja v a2 s . c o m * @return the left position of the popup */ protected int getLeft(int popupWidth) { return ((Window.getClientWidth() - popupWidth) / 2) + Window.getScrollLeft(); }
From source file:com.gwtplatform.mvp.client.view.RelativeToWidgetPopupPositioner.java
License:Apache License
private boolean canFitOnLeftEdge(int popupWidth) { int windowRight = Window.getClientWidth() + Window.getScrollLeft(); return windowRight - popupWidth > widget.getAbsoluteLeft(); }
From source file:com.haulmont.cuba.web.toolkit.ui.client.jqueryfileupload.CubaFileUploadProgressWindow.java
License:Apache License
private boolean cursorInsideBrowserContentArea(Event event) { if (event.getClientX() < 0 || event.getClientY() < 0) { // Outside to the left or above return false; }//from w w w. j a v a 2 s . c o m if (event.getClientX() > Window.getClientWidth() || event.getClientY() > Window.getClientHeight()) { // Outside to the right or below return false; } return true; }
From source file:com.haulmont.cuba.web.toolkit.ui.client.Tools.java
License:Apache License
public static void showPopup(VOverlay overlay, int left, int top) { overlay.setAutoHideEnabled(true);//ww w . j a v a2 s. c om overlay.setVisible(false); overlay.show(); Widget widget = overlay.getWidget(); if (widget instanceof VVerticalLayout) { resetItemSelection(widget); VVerticalLayout verticalLayout = (VVerticalLayout) widget; if (verticalLayout.getStyleName().contains(CUBA_CONTEXT_MENU_CONTAINER)) { int widgetCount = verticalLayout.getWidgetCount(); if (widgetCount > 1) { Widget verticalSlot = verticalLayout.getWidget(0); Widget buttonWidget = ((Slot) verticalSlot).getWidget(); buttonWidget.addStyleName(SELECTED_ITEM_STYLE); if (buttonWidget instanceof FocusWidget) { ((FocusWidget) buttonWidget).setFocus(true); } } } } // mac FF gets bad width due GWT popups overflow hacks, // re-determine width int offsetWidth = overlay.getOffsetWidth(); int offsetHeight = overlay.getOffsetHeight(); if (offsetWidth + left > Window.getClientWidth()) { left = left - offsetWidth; if (left < 0) { left = 0; } } if (offsetHeight + top > Window.getClientHeight()) { top = top - offsetHeight; if (top < 0) { top = 0; } } overlay.setPopupPosition(left, top); overlay.setVisible(true); }
From source file:com.haulmont.cuba.web.widgets.client.addons.popupbutton.VPopupButton.java
License:Apache License
void showPopup() { Scheduler.get().scheduleDeferred(new ScheduledCommand() { public void execute() { if (position.equals("auto")) { int extra = 20; int left = getPopupPositionWidget().getAbsoluteLeft(); if (direction.isHorizontalCenter()) { left -= (popup.getOffsetWidth() - getPopupPositionWidget().getOffsetWidth()) / 2; } else if (direction.isLeft()) { left -= popup.getOffsetWidth() - getPopupPositionWidget().getOffsetWidth(); }/* w w w . java 2 s . c o m*/ int top = getPopupPositionWidget().getAbsoluteTop() + getPopupPositionWidget().getOffsetHeight(); int browserWindowWidth = Window.getClientWidth() + Window.getScrollLeft(); int browserWindowHeight = Window.getClientHeight() + Window.getScrollTop(); if (left + popup.getOffsetWidth() > browserWindowWidth - extra) { left = getPopupPositionWidget().getAbsoluteLeft() - (popup.getOffsetWidth() - getPopupPositionWidget().getOffsetWidth()); } if (top + popup.getOffsetHeight() > browserWindowHeight - extra) { top = getPopupPositionWidget().getAbsoluteTop() - popup.getOffsetHeight() - 2; } left = left + xOffset; if (left < 0) { left = 0; } popup.setPopupPosition(left, top + yOffset); popup.setVisible(true); } else if (position.equals("fixed")) { int extra = 20; int left = getPopupPositionWidget().getAbsoluteLeft(); int top = getPopupPositionWidget().getAbsoluteTop() + getPopupPositionWidget().getOffsetHeight() - Window.getScrollTop(); int browserWindowWidth = Window.getClientWidth() + Window.getScrollLeft(); int clientHeight = Window.getClientHeight(); if (left + popup.getOffsetWidth() > browserWindowWidth - extra) { left = getPopupPositionWidget().getAbsoluteLeft() - (popup.getOffsetWidth() - getPopupPositionWidget().getOffsetWidth()); } if (top + popup.getOffsetHeight() > clientHeight - extra) { top = (getPopupPositionWidget().getAbsoluteTop() - Window.getScrollTop()) - popup.getOffsetHeight() - 2; } left = left + xOffset; if (left < 0) { left = 0; } popup.setPopupPosition(left, top + yOffset); popup.addStyleName("fixed"); popup.setVisible(true); } } }); }
From source file:com.hydro4ge.mycircle.client.MyCircle.java
License:Apache License
public void onModuleLoad() { MyDrawing d = new MyDrawing(Window.getClientWidth(), Window.getClientHeight()); RootPanel.get().add(d); }