List of usage examples for com.google.gwt.user.client Window getClientHeight
public static int getClientHeight()
From source file:com.lorepo.icplayer.client.module.choice.MyPopupPanel.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 ww w . j a v a 2 s . co m*/ public void center() { boolean initiallyShowing = showing; boolean initiallyAnimated = isAnimationEnabled; if (!initiallyShowing) { setVisible(false); setAnimationEnabled(false); show(); } 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); } } }
From source file:com.lorepo.icplayer.client.module.choice.MyPopupPanel.java
License:Apache License
/** * Positions the popup, called after the offset width and height of the popup * are known.// w ww. j a v a 2 s . c om * * @param relativeObject the ui object to position relative to * @param offsetWidth the drop down's offset width * @param offsetHeight the drop down's offset height */ private void position(final UIObject relativeObject, int offsetWidth, int offsetHeight) { // Calculate left position for the popup. The computation for // the left position is bidi-sensitive. int textBoxOffsetWidth = relativeObject.getOffsetWidth(); // Compute the difference between the popup's width and the // textbox's width int offsetWidthDiff = offsetWidth - textBoxOffsetWidth; int left; if (LocaleInfo.getCurrentLocale().isRTL()) { // RTL case int textBoxAbsoluteLeft = relativeObject.getAbsoluteLeft(); // Right-align the popup. Note that this computation is // valid in the case where offsetWidthDiff is negative. left = textBoxAbsoluteLeft - offsetWidthDiff; // If the suggestion popup is not as wide as the text box, always // align to the right edge of the text box. Otherwise, figure out whether // to right-align or left-align the popup. if (offsetWidthDiff > 0) { // Make sure scrolling is taken into account, since // box.getAbsoluteLeft() takes scrolling into account. int windowRight = Window.getClientWidth() + Window.getScrollLeft(); int windowLeft = Window.getScrollLeft(); // Compute the left value for the right edge of the textbox int textBoxLeftValForRightEdge = textBoxAbsoluteLeft + textBoxOffsetWidth; // Distance from the right edge of the text box to the right edge // of the window int distanceToWindowRight = windowRight - textBoxLeftValForRightEdge; // Distance from the right edge of the text box to the left edge of the // window int distanceFromWindowLeft = textBoxLeftValForRightEdge - windowLeft; // If there is not enough space for the overflow of the popup's // width to the right of the text box and there IS enough space for the // overflow to the right of the text box, then left-align the popup. // However, if there is not enough space on either side, stick with // right-alignment. if (distanceFromWindowLeft < offsetWidth && distanceToWindowRight >= offsetWidthDiff) { // Align with the left edge of the text box. left = textBoxAbsoluteLeft; } } } else { // LTR case // Left-align the popup. left = relativeObject.getAbsoluteLeft(); // If the suggestion popup is not as wide as the text box, always align to // the left edge of the text box. Otherwise, figure out whether to // left-align or right-align the popup. if (offsetWidthDiff > 0) { // Make sure scrolling is taken into account, since // box.getAbsoluteLeft() takes scrolling into account. int windowRight = Window.getClientWidth() + Window.getScrollLeft(); int windowLeft = Window.getScrollLeft(); // Distance from the left edge of the text box to the right edge // of the window int distanceToWindowRight = windowRight - left; // Distance from the left edge of the text box to the left edge of the // window int distanceFromWindowLeft = left - windowLeft; // If there is not enough space for the overflow of the popup's // width to the right of hte text box, and there IS enough space for the // overflow to the left of the text box, then right-align the popup. // However, if there is not enough space on either side, then stick with // left-alignment. if (distanceToWindowRight < offsetWidth && distanceFromWindowLeft >= offsetWidthDiff) { // Align with the right edge of the text box. left -= offsetWidthDiff; } } } // Calculate top position for the popup int top = relativeObject.getAbsoluteTop(); // Make sure scrolling is taken into account, since // box.getAbsoluteTop() takes scrolling into account. int windowTop = Window.getScrollTop(); int windowBottom = Window.getScrollTop() + Window.getClientHeight(); // Distance from the top edge of the window to the top edge of the // text box int distanceFromWindowTop = top - windowTop; // Distance from the bottom edge of the window to the bottom edge of // the text box int distanceToWindowBottom = windowBottom - (top + relativeObject.getOffsetHeight()); // If there is not enough space for the popup's height below the text // box and there IS enough space for the popup's height above the text // box, then then position the popup above the text box. However, if there // is not enough space on either side, then stick with displaying the // popup below the text box. if (distanceToWindowBottom < offsetHeight && distanceFromWindowTop >= offsetHeight) { top -= offsetHeight; } else { // Position above the text box top += relativeObject.getOffsetHeight(); } setPopupPosition(left, top); }
From source file:com.milmaps.client.MobileEntryPoint.java
License:Open Source License
private void setView() { int w = Window.getClientWidth(); int h = Window.getClientHeight(); m_controlsAndMap.setPixelSize(w, h); m_touchPanel.setPixelSize(w, h);/*from w w w.j a va2 s.com*/ m_mapView.resizeMap(w, h); m_mapView.updateView(); }
From source file:com.minesweeper.client.MinesweeperWidget.java
License:Apache License
/** * Timer to clear the UI./* w w w.j a v a 2 s.co m*/ */ // Timer timer = new Timer() { // @Override // public void run() { // status.setInnerText(""); // status.setClassName(STATUS_NONE); // } // }; // // private void setStatus(String message, boolean error) { // status.setInnerText(message); // if (error) { // status.setClassName(STATUS_ERROR); // } else { // if (message.length() == 0) { // status.setClassName(STATUS_NONE); // } else { // status.setClassName(STATUS_SUCCESS); // } // } // // timer.schedule(STATUS_DELAY); // } public MinesweeperWidget() { initWidget(uiBinder.createAndBindUi(this)); final EventBus eventBus = new SimpleEventBus(); requestFactory.initialize(eventBus); // Fill the list fillList(); for (int i = 0; i < buttonPanel.length; i++) { previous[i] = new Button("Previous"); buttonPanel[i] = new HorizontalPanel(); buttonPanel[i].add(previous[i]); next[i] = new Button("Next"); buttonPanel[i].add(next[i]); buttonPanel[i].addStyleName("buttonPanel"); next[i].setEnabled(false); next[i].addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { showNext(((Button) event.getSource()).getTitle()); } }); previous[i].setEnabled(false); previous[i].addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { showPrevious(((Button) event.getSource()).getTitle()); } }); } next[0].setTitle("Logs"); next[1].setTitle("Forms"); previous[0].setTitle("Logs"); previous[1].setTitle("Forms"); FlowPanel p = new FlowPanel(); p.add(listBox); p.setStyleName("buttonPanel"); logsPanel.add(logsTable); logsPanel.add(buttonPanel[0]); tabPanel.add(logsPanel, "Logs"); formsPanel.add(formsTable); formsPanel.add(buttonPanel[1]); tabPanel.add(formsPanel, "Forms"); tabPanel.selectTab(0); tabPanel.setPixelSize(Window.getClientWidth(), Window.getClientHeight()); VerticalPanel mainPanel = new VerticalPanel(); mainPanel.add(p); mainPanel.add(tabPanel); ScrollPanel scroll = new ScrollPanel(mainPanel); scroll.setPixelSize(Window.getClientWidth(), Window.getClientHeight()); // Associate the main panel with the HTML host page RootPanel.get("accGames").add(scroll); // List box with accessible games listBox.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { updateTable(listBox.getValue(listBox.getSelectedIndex())); if (indexOfLogs * MAX_LOG + MAX_LOG > logs.size()) next[0].setEnabled(false); else next[0].setEnabled(true); if (indexOfForms * MAX_LOG + MAX_LOG > forms.size()) next[1].setEnabled(false); else next[1].setEnabled(true); } }); // Setup timer to refresh list automatically. Timer refreshTimer = new Timer() { @Override public void run() { fillList(); } }; refreshTimer.scheduleRepeating(REFRESH_INTERVAL); }
From source file:com.moesol.gwt.maps.client.Driver.java
License:Open Source License
protected void resizeMap() { int h = Window.getClientHeight(); int w = Window.getClientWidth(); m_map.resizeMap(w - 50, h - 50);//from ww w. ja v a2s .c o m updateTileInfo(); }
From source file:com.moesol.gwt.maps.client.MCOP.java
License:Open Source License
private void doMapPanel(RootPanel mapPanel) { DOM.setInnerHTML(mapPanel.getElement(), ""); TouchPanel touchPanel = makeTouchPanel(); AbsolutePanel controlsAndMap = new AbsolutePanel(); m_msg = new Label("msg..."); m_map = new MapView(); loadLayerConfigsFromClient();//from w w w . j a va 2s. c o m int w = Window.getClientWidth() - 20; int h = Window.getClientHeight() - 20; controlsAndMap.setPixelSize(w, h); m_map.setPixelSize(w, h); m_map.updateView(); bindListeners(touchPanel, m_map); Button in = new Button(" + ", new ClickHandler() { @Override public void onClick(ClickEvent event) { goIn(); } }); Button out = new Button(" - ", new ClickHandler() { @Override public void onClick(ClickEvent event) { goOut(); } }); HorizontalPanel bar = new HorizontalPanel(); bar.add(in); bar.add(out); bar.add(m_msg); touchPanel.setWidget(m_map); controlsAndMap.add(touchPanel); controlsAndMap.add(bar); controlsAndMap.setWidgetPosition(bar, 10, 10); mapPanel.add(controlsAndMap); // Layer a tranparent dialog... // DialogBox db = new DialogBox(); // VerticalPanel dbPanel = new VerticalPanel(); // db.setHTML("<a href='' onclick='false'>x</a>"); // db.setPopupPosition(100, 10); // db.setPixelSize(100, 100); // db.show(); }
From source file:com.moesol.mapsample.client.MapSample.java
License:Open Source License
protected void resizeMap() { int h = Window.getClientHeight(); int w = Window.getClientWidth(); m_map.resizeMap(w - 50, h - 50);/*from w w w . java 2s . com*/ updateTileInfo(); }
From source file:com.msco.mil.client.com.sencha.gxt.explorer.client.ExplorerShell.java
License:sencha.com license
public ExplorerShell() { monitorWindowResize = true;/*from ww w . j av a 2 s.com*/ Window.enableScrolling(false); setPixelSize(Window.getClientWidth(), Window.getClientHeight()); setStateful(true); setStateId("explorerLayout"); BorderLayoutStateHandler state = new BorderLayoutStateHandler(this); state.loadState(); }
From source file:com.objetdirect.gwt.umldrawer.client.StartPanel.java
License:Open Source License
/** * Constructor of the {@link StartPanel} *//*from ww w . ja v a 2 s . c om*/ public StartPanel() { super(); this.loadingScreen = new LoadingScreen(); this.loadingScreen.show(); Log.trace("Starting App"); this.setWidth("100%"); this.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); this.setSpacing(20); this.gfxEnginePanel.setSpacing(5); this.geometryStylePanel.setSpacing(5); this.themePanel.setSpacing(5); this.resolutionPanel.setSpacing(5); this.gfxEngineListBox.addItem("Tatami GFX"); this.gfxEngineListBox.addItem("Incubator Canvas GFX"); this.gfxEngineListBox.addItem("GWT Canvas GFX"); this.geometryStyleListBox.addItem("Linear"); this.geometryStyleListBox.addItem("Shape Based"); for (final Theme theme : Theme.values()) { this.themeListBox.addItem(ThemeManager.getThemeName(theme)); } this.isResolutionAutoChkBox.setValue(true); this.widthTxtBox.setEnabled(false); this.heightTxtBox.setEnabled(false); this.isResolutionAutoChkBox.addClickHandler(new ClickHandler() { public void onClick(final ClickEvent event) { StartPanel.this.widthTxtBox.setEnabled(!StartPanel.this.isResolutionAutoChkBox.getValue()); StartPanel.this.heightTxtBox.setEnabled(!StartPanel.this.isResolutionAutoChkBox.getValue()); } }); this.widthTxtBox.setText("" + (Window.getClientWidth() - 50)); this.heightTxtBox.setText("" + (Window.getClientHeight() - 50)); this.widthTxtBox.setWidth("50px"); this.heightTxtBox.setWidth("50px"); for (final QualityLevel qlvl : QualityLevel.values()) { this.qualityListBox.addItem(qlvl.toString()); } this.qualityListBox.setSelectedIndex(1); // High quality this.add(this.logoImg); for (final DiagramType type : DiagramType.values()) { final Button startBtn = new Button("Start new UML " + type.getName() + " diagram..."); this.add(startBtn); startBtn.addClickHandler(new ClickHandler() { @Override public void onClick(final ClickEvent event) { StartPanel.this.setOptions("Drawer", type); } }); } this.add(this.startDemoBtn); this.startDemoBtn.addClickHandler(new ClickHandler() { @Override public void onClick(final ClickEvent event) { StartPanel.this.setOptions("Demo", OBJECT); } }); // this.add(this.startAnimateDemoBtn); // this.startAnimateDemoBtn.addClickHandler(new ClickHandler() { // @Override // public void onClick(final ClickEvent event) { // StartPanel.this.setOptions("AnimatedDemo", HYBRID); // } // }); if (OptionsManager.get("Advanced") == 1) { this.gfxEnginePanel.add(this.gfxEngineLbl); this.gfxEnginePanel.add(this.gfxEngineListBox); this.add(this.gfxEnginePanel); this.geometryStylePanel.add(this.geometryStyleLbl); this.geometryStylePanel.add(this.geometryStyleListBox); this.add(this.geometryStylePanel); } this.themePanel.add(this.themeLbl); this.themePanel.add(this.themeListBox); this.add(this.themePanel); if (OptionsManager.get("Advanced") == 1) { this.resolutionAutoPanel.add(this.isResolutionAutoChkBox); this.add(this.resolutionAutoPanel); this.resolutionPanel.add(this.resolutionLbl); this.resolutionPanel.add(this.widthTxtBox); this.resolutionPanel.add(this.crossLbl); this.resolutionPanel.add(this.heightTxtBox); this.add(this.resolutionPanel); } this.qualityPanel.add(this.qualityLbl); this.qualityPanel.add(this.qualityListBox); this.add(this.qualityPanel); this.loadingScreen.hide(); this.addStyleName("verticalTable"); }
From source file:com.objetdirect.tatami.demo.client.GfxDemo.java
License:Open Source License
/** * Show some properties about a <code>GraphicObjectw</code> * @param object the <code>GraphicObject</code> to show the properties * TODO change the layout of the dialog/*from www. ja v a2 s . c o m*/ */ private void showProperties(GraphicObject object) { final DialogBox dialog = new DialogBox(false); dialog.setText("Properties"); Grid panel = new Grid(5, 4); panel.setCellPadding(5); panel.setCellSpacing(10); panel.setWidget(0, 0, new HTML("<b>Position</b>")); panel.setWidget(0, 1, new Label(object.getX() + "," + object.getY())); panel.setWidget(0, 2, new HTML("<b>Center</b>")); panel.setWidget(0, 3, new Label(object.getCenterX() + "," + object.getCenterY())); panel.setWidget(1, 0, new HTML("<b>Size</b>")); panel.setWidget(1, 1, new Label("? x ? px")); panel.setWidget(2, 0, new HTML("<b>Color of the stroke</b>")); final String color = lastStrokeColor.toHex(); final Label label = new Label(color); label.setTitle(color); DOM.setStyleAttribute(label.getElement(), "color", color); panel.setWidget(2, 1, label); panel.setWidget(2, 2, new HTML("<b>Size of the stroke</b>")); panel.setWidget(2, 3, new Label(lastStrokeSize + "px")); panel.setWidget(3, 0, new HTML("<b>Fill color</b>")); final String fillColor = object.getFillColor().toHex(); final Label labelFill = new Label(fillColor); labelFill.setTitle(fillColor); panel.setWidget(3, 1, labelFill); DOM.setStyleAttribute(labelFill.getElement(), "color", fillColor); Button close = new Button("Close"); close.addClickListener(new ClickListener() { public void onClick(Widget sender) { dialog.hide(); } }); panel.setWidget(4, 0, close); dialog.setPopupPosition(Window.getClientWidth() / 2, Window.getClientHeight() / 2); dialog.addStyleName("GfxDemo-properties"); dialog.setWidget(panel); dialog.show(); System.out.println("bounds " + object.getBounds()); }