List of usage examples for com.google.gwt.user.client Window addWindowScrollHandler
public static HandlerRegistration addWindowScrollHandler(Window.ScrollHandler handler)
From source file:burrito.client.Burrito.java
License:Apache License
public void onModuleLoad() { RootPanel adminPanel = RootPanel.get("burrito-admin"); if (adminPanel != null) { String siteletContainerId = Window.Location.getParameter("container"); if (siteletContainerId != null && !siteletContainerId.isEmpty()) { SiteletAdminPanel siteletAdminPanel = new SiteletAdminPanel(siteletContainerId); adminPanel.add(siteletAdminPanel); } else {/*from www .j a v a 2s.c om*/ CrudPanel crud = new CrudPanel(); adminPanel.add(crud); } Window.addWindowScrollHandler(new ScrollHandler() { @Override public void onWindowScroll(ScrollEvent event) { updateEditFormButtons(); } }); Window.addResizeHandler(new ResizeHandler() { @Override public void onResize(ResizeEvent event) { updateEditFormButtons(); } }); Event.addNativePreviewHandler(new Event.NativePreviewHandler() { @Override public void onPreviewNativeEvent(NativePreviewEvent event) { if (currentCtrlSaveHandler == null) { return; } if (event.getTypeInt() == Event.ONKEYDOWN) { int sCharacterCode = 83; if (event.getNativeEvent().getCtrlKey() && event.getNativeEvent().getKeyCode() == sCharacterCode) { currentCtrlSaveHandler.onCtrlSave(); event.cancel(); } } } }); } }
From source file:cc.alcina.framework.gwt.client.widget.dialog.GlassDialogBox.java
License:Apache License
@Override public void show() { if (!isGlassHidden()) { glass.show(true);//from w w w . j a va 2s.c om } scrollLeft = Window.getScrollLeft(); scrollTop = Window.getScrollTop(); if (this.handlerRegistration == null && !BrowserMod.isMobile()) { this.handlerRegistration = Window.addWindowScrollHandler(scrollHandler); } super.show(); }
From source file:ch.unifr.pai.twice.mousecontrol.client.TouchPadNintendoDS.java
License:Apache License
@Override public void start() { super.start(); if (windowScrollHandler != null) windowScrollHandler.removeHandler(); windowScrollHandler = Window.addWindowScrollHandler(new Window.ScrollHandler() { @Override/*w w w . j av a 2 s . c om*/ public void onWindowScroll(ScrollEvent event) { if (skipEvents > 0) skipEvents--; l.getElement().getStyle().setLeft(RootPanel.getBodyElement().getScrollLeft(), Unit.PX); l.getElement().getStyle().setTop(RootPanel.getBodyElement().getScrollTop(), Unit.PX); } }); Timer t2 = new Timer() { @Override public void run() { skipEvents = eventsAfterReset; Window.scrollTo(1000, 1000); updater.scheduleRepeating(50); } }; t2.schedule(1000); }
From source file:com.arcbees.gquery.appear.client.Appear.java
License:Apache License
private HandlerRegistration addWindowScrollHandler() { return Window.addWindowScrollHandler(new Window.ScrollHandler() { @Override/*from w w w . j a v a 2s.c o m*/ public void onWindowScroll(Window.ScrollEvent event) { ON_SCROLL_FUNCTION.f(); } }); }
From source file:com.axlight.gbrain.client.MainPane.java
License:Apache License
public MainPane() { nodeManager = new NodeManager(); nullCallback = new AsyncCallback<Void>() { public void onFailure(Throwable caught) { GWT.log("Network error!", caught); showAlertDialog("Network error!"); }/* www. ja va 2 s .c o m*/ public void onSuccess(Void ignored) { // nothing } }; ClickHandler borderClickHandler = new ClickHandler() { public void onClick(ClickEvent event) { int left = getWindowScrollLeft(); int top = getWindowScrollTop(); int screenWidth = getWindowScreenWidth(); int screenHeight = getWindowScreenHeight(); int prevCenterPosX = viewX + left + screenWidth / 2; int prevCenterPosY = viewY + top + screenHeight / 2; relocateCenter(prevCenterPosX, prevCenterPosY); } }; borderNorth = new SimplePanel(); borderNorth.addDomHandler(borderClickHandler, ClickEvent.getType()); borderNorth.getElement().getStyle().setBackgroundColor("#445566"); borderEast = new SimplePanel(); borderEast.addDomHandler(borderClickHandler, ClickEvent.getType()); borderEast.getElement().getStyle().setBackgroundColor("#445566"); borderSouth = new SimplePanel(); borderSouth.addDomHandler(borderClickHandler, ClickEvent.getType()); borderSouth.getElement().getStyle().setBackgroundColor("#445566"); borderWest = new SimplePanel(); borderWest.addDomHandler(borderClickHandler, ClickEvent.getType()); borderWest.getElement().getStyle().setBackgroundColor("#445566"); Image image; if (GBrain.isIPhone) { image = new Image("images/create_button.svg"); } else { image = new Image("images/create_button.png"); } PushButton createButton = new PushButton(image, new ClickHandler() { public void onClick(ClickEvent event) { showCreateDialog(); } }); createButton.setPixelSize(BUTTON_SIZE, BUTTON_SIZE); createButton.setTitle("Create a new text"); if (GBrain.isIPhone) { image = new Image("images/delete_button.svg"); } else { image = new Image("images/delete_button.png"); } PushButton deleteButton = new PushButton(image, new ClickHandler() { public void onClick(ClickEvent event) { if (selectNode == null) { showAlertDialog("Nothing is selected."); return; } if (selectNode.getChildren() > 0) { showAlertDialog("You can't delete it with children."); return; } final NeuronNode tmpSelectNode = selectNode; String content = tmpSelectNode.getContent(); final long id = tmpSelectNode.getId(); showConfirmDialog("Are you sure you want to delete\n'" + content + "' ?", new ClickHandler() { public void onClick(ClickEvent event) { gbrainService.deleteNeuron(id, new AsyncCallback<Void>() { public void onFailure(Throwable caught) { GWT.log("Network error!", caught); showAlertDialog("Network error!"); } public void onSuccess(Void ignored) { Long parentId = tmpSelectNode.getParentId(); if (parentId != null) { NeuronNode parentNode = nodeManager.getNode(parentId); if (parentNode != null) { parentNode.decreaseChildren(); } } removeNode(tmpSelectNode); } }); } }); } }); deleteButton.setPixelSize(BUTTON_SIZE, BUTTON_SIZE); deleteButton.setTitle("Delete text"); if (GBrain.isIPhone) { image = new Image("images/noparent_button.svg"); } else { image = new Image("images/noparent_button.png"); } PushButton noparentButton = new PushButton(image, new ClickHandler() { public void onClick(ClickEvent event) { if (selectNode == null) { showAlertDialog("Nothing is selected."); return; } NeuronNode n = selectNode; if (n.getParentId() != null) { replaceParent(n, null); gbrainService.removeParent(n.getId(), nullCallback); } } }); noparentButton.setPixelSize(BUTTON_SIZE, BUTTON_SIZE); noparentButton.setTitle("Remove parent link"); if (GBrain.isIPhone) { image = new Image("images/open_button.svg"); } else { image = new Image("images/open_button.png"); } PushButton openButton = new PushButton(image, new ClickHandler() { public void onClick(ClickEvent event) { if (selectNode == null) { showAlertDialog("Nothing is selected."); return; } refreshChildNeurons(selectNode.getId()); } }); openButton.setPixelSize(BUTTON_SIZE, BUTTON_SIZE); openButton.setTitle("Open children"); if (GBrain.isIPhone) { image = new Image("images/close_button.svg"); } else { image = new Image("images/close_button.png"); } PushButton closeButton = new PushButton(image, new ClickHandler() { public void onClick(ClickEvent event) { if (selectNode == null) { showAlertDialog("Nothing is selected."); return; } removeChildNodes(selectNode); } }); closeButton.setPixelSize(BUTTON_SIZE, BUTTON_SIZE); closeButton.setTitle("Close children"); if (GBrain.isIPhone) { image = new Image("images/arrange_button.svg"); } else { image = new Image("images/arrange_button.png"); } PushButton arrangeButton = new PushButton(image, new ClickHandler() { public void onClick(ClickEvent event) { if (selectNode == null) { showAlertDialog("Nothing is selected."); return; } NeuronNode n = selectNode; nodeManager.arrangeAllChildNodes(n); updatePositionNodeAndChildNodes(n); } }); arrangeButton.setPixelSize(BUTTON_SIZE, BUTTON_SIZE); arrangeButton.setTitle("Arrange children"); if (GBrain.isIPhone) { image = new Image("images/up_button.svg"); } else { image = new Image("images/up_button.png"); } PushButton upButton = new PushButton(image, new ClickHandler() { public void onClick(ClickEvent event) { if (selectNode == null) { showAlertDialog("Nothing is selected."); return; } NeuronNode n = nodeManager.getParentNode(selectNode.getId()); if (n == null) { return; } handleNodeClick(n); slideToPosition(n.getPosX(), n.getPosY()); } }); upButton.setPixelSize(BUTTON_SIZE, BUTTON_SIZE); upButton.setTitle("Jump to parent"); if (GBrain.isIPhone) { image = new Image("images/down_button.svg"); } else { image = new Image("images/down_button.png"); } PushButton downButton = new PushButton(image, new ClickHandler() { public void onClick(ClickEvent event) { if (selectNode == null) { showAlertDialog("Nothing is selected."); return; } NeuronNode n = nodeManager.getFirstChildNode(selectNode.getId()); if (n == null) { return; } handleNodeClick(n); slideToPosition(n.getPosX(), n.getPosY()); } }); downButton.setPixelSize(BUTTON_SIZE, BUTTON_SIZE); downButton.setTitle("Jump to a child"); if (GBrain.isIPhone) { image = new Image("images/prev_button.svg"); } else { image = new Image("images/prev_button.png"); } PushButton prevButton = new PushButton(image, new ClickHandler() { public void onClick(ClickEvent event) { if (selectNode == null) { showAlertDialog("Nothing is selected."); return; } NeuronNode n = nodeManager.getPreviousSiblingNode(selectNode.getId()); if (n == null) { return; } handleNodeClick(n); slideToPosition(n.getPosX(), n.getPosY()); } }); prevButton.setPixelSize(BUTTON_SIZE, BUTTON_SIZE); prevButton.setTitle("Jump to previous sibling"); if (GBrain.isIPhone) { image = new Image("images/next_button.svg"); } else { image = new Image("images/next_button.png"); } PushButton nextButton = new PushButton(image, new ClickHandler() { public void onClick(ClickEvent event) { if (selectNode == null) { showAlertDialog("Nothing is selected."); return; } NeuronNode n = nodeManager.getNextSiblingNode(selectNode.getId()); if (n == null) { return; } handleNodeClick(n); slideToPosition(n.getPosX(), n.getPosY()); } }); nextButton.setPixelSize(BUTTON_SIZE, BUTTON_SIZE); nextButton.setTitle("Jump to next sibling"); if (GBrain.isIPhone) { image = new Image("images/jump_button.svg"); } else { image = new Image("images/jump_button.png"); } PushButton jumpButton = new PushButton(image, new ClickHandler() { public void onClick(ClickEvent event) { if (selectNode == null) { showAlertDialog("Nothing is selected."); return; } jumpToUrl(selectNode); } }); jumpButton.setPixelSize(BUTTON_SIZE, BUTTON_SIZE); jumpButton.setTitle("Jump to URL"); if (GBrain.isIPhone) { image = new Image("images/color_button.svg"); } else { image = new Image("images/color_button.png"); } PushButton colorButton = new PushButton(image, new ClickHandler() { public void onClick(ClickEvent event) { if (selectNode == null) { showAlertDialog("Nothing is selected."); return; } NeuronNode n = selectNode; n.setNextColor(); gbrainService.updateColor(n.getId(), n.getColor(), nullCallback); } }); colorButton.setPixelSize(BUTTON_SIZE, BUTTON_SIZE); colorButton.setTitle("Change color"); buttonPanel = new FlowPanel(); buttonPanel.add(createButton); buttonPanel.add(deleteButton); buttonPanel.add(noparentButton); buttonPanel.add(openButton); buttonPanel.add(closeButton); buttonPanel.add(arrangeButton); buttonPanel.add(upButton); buttonPanel.add(downButton); buttonPanel.add(prevButton); buttonPanel.add(nextButton); buttonPanel.add(jumpButton); buttonPanel.add(colorButton); drawArea = new DrawingArea(0, 0); drawArea.getElement().setId("gbrain-svgpanel"); drawArea.getElement().getStyle().setBackgroundColor("#000000"); this.add(drawArea, 0, 0); this.add(borderNorth, -100, -100); // initially not visible this.add(borderEast, -100, -100); // initially not visible this.add(borderSouth, -100, -100); // initially not visible this.add(borderWest, -100, -100); // initially not visible this.add(buttonPanel, -100, -100); // initially not visible coordinate = new Coordinate(drawArea); drawArea.add(coordinate); supportDragAndDrop(); refreshTopNeurons(); onResize(); Element welcome = Document.get().getElementById("gbrain-welcome"); welcome.getStyle().setLeft(viewWidth / 2 - welcome.getClientWidth() / 2, Unit.PX); welcome.getStyle().setTop(viewHeight / 2 - welcome.getClientHeight() / 2, Unit.PX); Window.addWindowScrollHandler(this); }
From source file:com.google.livingstories.client.ui.AnchoredPanel.java
License:Apache License
@Override public void setWidget(Widget widget) { super.setWidget(widget); Style style = widget.getElement().getStyle(); style.setProperty("position", "relative"); style.setPropertyPx("left", 0); style.setPropertyPx("top", 0); removeHandlers();/*from ww w. j a v a 2s. co m*/ scrollHandler = Window.addWindowScrollHandler(new ScrollHandler() { @Override public void onWindowScroll(ScrollEvent event) { reposition(); } }); resizeHandler = Window.addResizeHandler(new ResizeHandler() { @Override public void onResize(ResizeEvent event) { reposition(); } }); }
From source file:com.google.webcourse.picasaapp.client.PicasaApp.java
License:Apache License
/** * This is the entry point method./*from w w w . j a v a 2 s.c om*/ */ public void onModuleLoad() { LoadAlbumsForm loadAlbumsForm = new LoadAlbumsForm(); CommentSubmitForm commentSubmitForm = new CommentSubmitForm(); thumbnailList = RootPanel.get("thumbnailList"); photoView = new PhotoView(); commentsPanel = new CommentsPanel(); RootPanel.get("loadAlbumsForm").add(loadAlbumsForm); RootPanel.get("photoWrapper").add(photoView); RootPanel.get("comments").add(commentsPanel); RootPanel.get("comments").add(commentSubmitForm); loadAlbumsForm.setLoadAlbumListener(new LoadAlbumsListener() { public void loadAlbums(String username) { loadAlbumsOfUser(username); } }); commentSubmitForm.setCommentSubmitHandler(new CommentSubmitHandler() { public void submitComment(String comment) { commentService.storeComment(currentPhotoUrl, comment, new AsyncCallback<Void>() { public void onFailure(Throwable caught) { // TODO: Show an error message } public void onSuccess(Void result) { loadComments(currentPhotoUrl); } }); } }); // Make sure the thumbnail list has always the correct height, as // height=100% doesn't work properly. Window.addResizeHandler(this); Window.addWindowScrollHandler(new ScrollHandler() { public void onWindowScroll(ScrollEvent event) { onResize(null); } }); onResize(null); }
From source file:com.jwh.gwt.fasttable.sample.client.FastTableSample.java
License:Open Source License
@Override public void onModuleLoad() { //TODO need better switch if (Window.Location.getHref().indexOf("FastTableSample") < 0 && Window.Location.getHref().indexOf("fast-table-sample") < 0) { return;/*from w w w. j a v a 2 s.c om*/ } tablePanel = RootPanel.get("tableContainer"); optionsPanel = RootPanel.get("optionsContainer"); Window.addWindowScrollHandler(new ScrollHandler() { @Override public void onWindowScroll(ScrollEvent event) { if (listenForFinishedBuilding) { builder.logInfo("Scrolled. Done drawing?"); } listenForFinishedBuilding = false; } }); logger.setParent(RootPanel.get("loggerContainer")); buildTable(); buildOptionsPanel(); }
From source file:com.roughindustries.commonwealthcocktails.client.application.ApplicationPresenter.java
License:Apache License
@Override protected void onBind() { step.setValue(25);/*from w ww . j a va 2 s . com*/ current.setValue(25); next.setValue(current.intValue() + step.intValue()); prev.setValue(0); lastScrollPos.setValue(0); lastMaxScrollTop.setValue(0); list.addAll(Collections.nCopies(current.intValue(), new ccCocktail())); final HTML f = new HTML(""); Column<ccCocktail, SafeHtml> text = new Column<ccCocktail, SafeHtml>(new SafeHtmlCell()) { public SafeHtml getValue(ccCocktail cocktail) { SafeHtmlBuilder sb = new SafeHtmlBuilder(); if (cocktail == null || cocktail.getCocktailName() == null) { sb.appendHtmlConstant("Loading ..."); return sb.toSafeHtml(); } else { sb.appendHtmlConstant( "<table border='0' cellpadding='1' cellspacing='1' style='width: 100%;'>"); sb.appendHtmlConstant("<tbody>"); sb.appendHtmlConstant("<tr>"); sb.appendHtmlConstant( "<td><img alt='Cocktail' src='https://s3.amazonaws.com/commonwealthcocktailbucket/noun_320760_cc.png' style='border-width: 0px; border-style: solid; margin: 0px; width: 100px; height: 100px;' /></td>"); sb.appendHtmlConstant( "<td border='0' cellpadding='1' cellspacing='1' style='width: 100%;' table=''>"); sb.appendHtmlConstant( "<table border='0' cellpadding='1' cellspacing='1' style='width: 100%;'>"); sb.appendHtmlConstant("<tbody>"); sb.appendHtmlConstant("<tr>"); sb.appendHtmlConstant("<td><b>" + cocktail.getCocktailName() + "</b></td>"); sb.appendHtmlConstant("</tr>"); sb.appendHtmlConstant("<tr>"); sb.appendHtmlConstant( "<td><b>Origin: </b>" + ((cocktail.getCocktailOrigin() == null) || (cocktail.getCocktailOrigin().length() == 0) ? "" : (cocktail.getCocktailOrigin().substring(0, 150) + "...")) + "</td>"); sb.appendHtmlConstant("</tr>"); sb.appendHtmlConstant("<tr>"); sb.appendHtmlConstant("<td><b>Method: </b>" + ((cocktail.getCocktailMethod() == null) || (cocktail.getCocktailMethod() == null) ? "" : (cocktail.getCocktailMethod().substring(0, 150) + "...")) + "</td>"); sb.appendHtmlConstant("</tr>"); sb.appendHtmlConstant("</tbody>"); sb.appendHtmlConstant("</table>"); sb.appendHtmlConstant("</td>"); sb.appendHtmlConstant("</tr>"); sb.appendHtmlConstant("</tbody>"); sb.appendHtmlConstant("</table>"); return sb.toSafeHtml(); } } }; getView().getCocktailGrid().addColumn(text); data.addAll(list); getView().getCocktailGrid().setRowData(0, data); getView().getCocktailGrid().setVisibleRange(new Range(0, current.intValue())); getView().getCocktailGrid().setHeight(Integer.toString(Window.getClientHeight()) + "px"); getView().getScroll().setHeight(Integer.toString(Window.getClientHeight()) + "px"); getView().getScroll().setWidth(Integer.toString(Window.getClientWidth()) + "px"); if (Window.getClientWidth() <= 768) { getView().getBrand().setMarginLeft((Window.getClientWidth() / 2) - 125); } else { getView().getBrand().setMarginLeft(0); } if (Window.getClientWidth() > (800) && (Window.getClientWidth() <= (800 + NativeVerticalScrollbar.getNativeScrollbarWidth()))) { getView().getHeaderContainer() .setWidth((800 - NativeVerticalScrollbar.getNativeScrollbarWidth()) + "px"); getView().getCocktailGrid().setWidth((800 - NativeVerticalScrollbar.getNativeScrollbarWidth()) + "px"); if (getView().getLeftBuffer().isVisible()) { getView().getLeftBuffer().setVisible(false); getView().getRightBuffer().setVisible(false); } } else if (Window.getClientWidth() <= (800 - NativeVerticalScrollbar.getNativeScrollbarWidth())) { getView().getHeaderContainer().setWidth( Integer.toString(Window.getClientWidth() - NativeVerticalScrollbar.getNativeScrollbarWidth()) + "px"); getView().getCocktailGrid().setWidth( Integer.toString(Window.getClientWidth() - NativeVerticalScrollbar.getNativeScrollbarWidth()) + "px"); if (getView().getLeftBuffer().isVisible()) { getView().getLeftBuffer().setVisible(false); getView().getRightBuffer().setVisible(false); } } else { getView().getHeaderContainer().setWidth("800px"); getView().getCocktailGrid().setWidth("800px"); if (!getView().getLeftBuffer().isVisible()) { getView().getLeftBuffer().setVisible(true); getView().getRightBuffer().setVisible(true); } getView().getLeftBuffer() .setWidth(Integer.toString( (Window.getClientWidth() - 800 - NativeVerticalScrollbar.getNativeScrollbarWidth()) / 2) + "px"); getView().getRightBuffer() .setWidth(Integer.toString( (Window.getClientWidth() - 800 - NativeVerticalScrollbar.getNativeScrollbarWidth()) / 2) + "px"); } getView().getScroll().addScrollHandler(new ScrollHandler() { @Override public void onScroll(ScrollEvent ev) { int oldScrollPos = lastScrollPos.intValue(); lastScrollPos.setValue(getView().getScroll().getVerticalScrollPosition()); // If scrolling up, ignore the event. if (oldScrollPos >= lastScrollPos.intValue()) { return; } // Height of grid contents (including outside the viewable area) // - height of the scroll panel int maxScrollTop = getView().getScroll().getWidget().getOffsetHeight() - getView().getScroll().getOffsetHeight(); if (lastScrollPos.intValue() == maxScrollTop) { if ((data.size() + step.intValue()) <= queryResultsCount.intValue()) { prev.setValue(current); current.setValue(next); next.setValue(next.intValue() + step.intValue()); data.addAll( new ArrayList<ccCocktail>(Collections.nCopies(step.intValue(), new ccCocktail()))); } else { int diff = queryResultsCount.intValue() - data.size(); if (diff > 0) { step.setValue(diff); prev.setValue(current); current.setValue(next); next.setValue(next.intValue() + step.intValue()); data.addAll(new ArrayList<ccCocktail>(Collections.nCopies(diff, new ccCocktail()))); } else { step.setValue(0); } } getView().getCocktailGrid().setRowData(0, data); getView().getCocktailGrid().setVisibleRange(new Range(0, current.intValue())); getView().getCocktailGrid().redraw(); if (step.intValue() != 0) { cocktailService.cocktailServer("", prev.intValue(), step.intValue(), new AsyncCallback<ccCocktail[]>() { public void onFailure(Throwable caught) { } public void onSuccess(ccCocktail[] result) { if (result != null) { for (ccCocktail item : result) { data.set(item.getPageRefID(), item); } getView().getCocktailGrid().setRowData(0, data); getView().getCocktailGrid() .setVisibleRange(new Range(0, current.intValue())); getView().getCocktailGrid().redraw(); } } }); } } } }); Window.addWindowScrollHandler(new Window.ScrollHandler() { @Override public void onWindowScroll(com.google.gwt.user.client.Window.ScrollEvent event) { // Window.alert("Scrolling Window"); } }); cocktailService.getCount("", new AsyncCallback<Integer>() { public void onFailure(Throwable caught) { } public void onSuccess(Integer result) { queryResultsCount.setValue(result.intValue()); cocktailService.cocktailServer("", prev.intValue(), current.intValue(), new AsyncCallback<ccCocktail[]>() { public void onFailure(Throwable caught) { } public void onSuccess(ccCocktail[] result) { ArrayList<ccCocktail> removed = new ArrayList<ccCocktail>(); for (ccCocktail item : result) { if (item != null) { removed.add(item); } } result = removed.toArray(new ccCocktail[0]); if (result != null) { for (ccCocktail item : result) { data.set(item.getPageRefID(), item); } getView().getCocktailGrid().setRowData(0, data); getView().getCocktailGrid().setVisibleRange(new Range(0, current.intValue())); getView().getCocktailGrid().redraw(); } } }); } }); Window.addResizeHandler(new ResizeHandler() { @Override public void onResize(ResizeEvent event) { getView().getCocktailGrid().setHeight(Integer.toString(Window.getClientHeight()) + "px"); getView().getScroll().setHeight(Integer.toString(Window.getClientHeight()) + "px"); getView().getScroll().setWidth(Integer.toString(Window.getClientWidth()) + "px"); if (Window.getClientWidth() <= 768) { getView().getBrand().setMarginLeft((Window.getClientWidth() / 2) - 125); } else { getView().getBrand().setMarginLeft(0); } if (Window.getClientWidth() > (800) && (Window.getClientWidth() <= (800 + NativeVerticalScrollbar.getNativeScrollbarWidth()))) { getView().getHeaderContainer() .setWidth((800 - NativeVerticalScrollbar.getNativeScrollbarWidth()) + "px"); getView().getCocktailGrid() .setWidth((800 - NativeVerticalScrollbar.getNativeScrollbarWidth()) + "px"); if (getView().getLeftBuffer().isVisible()) { getView().getLeftBuffer().setVisible(false); getView().getRightBuffer().setVisible(false); } } else if (Window.getClientWidth() <= (800 + NativeVerticalScrollbar.getNativeScrollbarWidth())) { getView().getHeaderContainer() .setWidth(Integer.toString( Window.getClientWidth() - NativeVerticalScrollbar.getNativeScrollbarWidth()) + "px"); getView().getCocktailGrid() .setWidth(Integer.toString( Window.getClientWidth() - NativeVerticalScrollbar.getNativeScrollbarWidth()) + "px"); if (getView().getLeftBuffer().isVisible()) { getView().getLeftBuffer().setVisible(false); getView().getRightBuffer().setVisible(false); } } else { getView().getHeaderContainer().setWidth("800px"); getView().getCocktailGrid().setWidth("800px"); if (!getView().getLeftBuffer().isVisible()) { getView().getLeftBuffer().setVisible(true); getView().getRightBuffer().setVisible(true); } getView().getLeftBuffer().setWidth(Integer.toString( (Window.getClientWidth() - 800 - NativeVerticalScrollbar.getNativeScrollbarWidth()) / 2) + "px"); getView().getRightBuffer().setWidth(Integer.toString( (Window.getClientWidth() - 800 - NativeVerticalScrollbar.getNativeScrollbarWidth()) / 2) + "px"); } } }); }
From source file:com.smartgwt.mobile.client.widgets.layout.NavigationBar.java
License:Open Source License
@Override protected void onLoad() { super.onLoad(); if (Canvas._getFixNavigationBarPositionDuringKeyboardFocus()) { if (EventHandler.couldShowSoftKeyboard(Document.get().<SuperDocument>cast().getActiveElement())) { _fixPosition();/*from w ww. ja va 2s . c o m*/ } // In a UIWebView, the 'scroll' event is not fired on the window when the Previous/Next // buttons are used to move from <input> to <input>. It is when the app is run in // Mobile Safari, however. if (!Canvas.isUIWebView()) { windowScrollRegistration = Window.addWindowScrollHandler(new Window.ScrollHandler() { @Override public void onWindowScroll(ScrollEvent event) { _updateFixedPosition(); } }); } } windowResizeRegistration = Window.addResizeHandler(new ResizeHandler() { private Timer timer; @Override public void onResize(ResizeEvent event) { // A timeout is used to prevent severe choppiness when the user is resizing // a desktop browser window. if (timer == null) { timer = new Timer() { @Override public void run() { if (timer != this) return; _layOutMembers(); timer = null; } }; timer.schedule(200); } } }); _layOutMembers(); }