List of usage examples for com.google.gwt.user.client.ui ScrollPanel setScrollPosition
@Deprecated public void setScrollPosition(int position)
From source file:asquare.gwt.tk.uitest.isvisible.client.Demo.java
License:Apache License
public void onModuleLoad() { RootPanel outer = RootPanel.get();/*from w w w . ja v a 2 s.c o m*/ TextBox rowInput = new TextBox(); TextBox colInput = new TextBox(); Grid input = new Grid(2, 2); input.setText(0, 0, "Row: "); input.setWidget(0, 1, rowInput); input.setText(1, 0, "Col: "); input.setWidget(1, 1, colInput); outer.add(input); final int ROWS = 20; final int COLS = 20; Grid grid = new Grid(ROWS, COLS); grid.setCellPadding(0); grid.setCellSpacing(0); for (int row = 0; row < ROWS; row++) { for (int col = 0; col < COLS; col++) { grid.setWidget(row, col, new Label("(" + row + "," + col + ")")); } } ScrollPanel scrollInner = new ScrollPanel(); scrollInner.setAlwaysShowScrollBars(true); scrollInner.setPixelSize(400, 400); scrollInner.setWidget(grid); ScrollPanel scrollOuter = new ScrollPanel(); scrollOuter.add(scrollInner); scrollOuter.setAlwaysShowScrollBars(true); scrollOuter.setPixelSize(600, 200); outer.add(scrollOuter); scrollInner.setScrollPosition(100); scrollInner.setHorizontalScrollPosition(100); }
From source file:edu.caltech.ipac.firefly.ui.GwtUtil.java
/** * Cause the ScrollPanel to set it scroll bars so the widget it is showing is centered * * @param sp the scrollPanel/*from w w w .j av a 2 s . c o m*/ */ public static void centerScrollPanel(ScrollPanel sp) { Element el = sp.getElement(); int sw = DOM.getElementPropertyInt(el, "scrollWidth"); int sh = DOM.getElementPropertyInt(el, "scrollHeight"); int w = sp.getOffsetWidth(); int h = sp.getOffsetHeight(); sp.setScrollPosition((sh - h) / 2); sp.setHorizontalScrollPosition((sw - w) / 2); }
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 ww w . j a va 2 s.co m } 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(); }