Java Code Examples for com.google.gwt.user.client.Window#getScrollLeft()

The following examples show how to use com.google.gwt.user.client.Window#getScrollLeft() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: unitime   File: InfoPanelImpl.java    License: Apache License 2.0 6 votes vote down vote up
public void onBrowserEvent(Event event) {
	if (iHint.getText().isEmpty()) return;
	iX = 10 + event.getClientX() + getElement().getOwnerDocument().getScrollLeft();
	iY = 10 + event.getClientY() + getElement().getOwnerDocument().getScrollTop();
	
	switch (DOM.eventGetType(event)) {
	case Event.ONMOUSEMOVE:
		if (iInfoPanel.isShowing()) {
			int maxX = Window.getScrollLeft() + Window.getClientWidth() - iInfoPanel.getOffsetWidth() - 10;
			iInfoPanel.setPopupPosition(Math.min(iX, maxX), iY);
		} else if (iInfo.getRowCount() > 0) {
			iShowInfo.cancel();
			iShowInfo.schedule(1000);
		}
		break;
	case Event.ONMOUSEOUT:
		iShowInfo.cancel();
		if (iInfoPanel.isShowing())
			iHideInfo.schedule(1000);
		break;
	}
}
 
Example 2
@Override
protected void onAttach(MappingContext ctx) {
  super.onAttach(ctx);
  getSource().setCellContainerPeer(createCellContainerPeer());

  disablePopup(getTarget());
  getTarget().setTabIndex(0);
  getTarget().addClassName(CSS.rootContainer());

  getTarget().appendChild(myLineHighlight1);
  getTarget().appendChild(myLineHighlight2);
  getTarget().appendChild(myContent);

  refreshLineHighlight();

  myScrollLeft = Window.getScrollLeft();
  myScrollTop = Window.getScrollTop();

  myWindowReg = Window.addWindowScrollHandler(new Window.ScrollHandler() {
    @Override
    public void onWindowScroll(Window.ScrollEvent event) {
      myScrollLeft = event.getScrollLeft();
      myScrollTop = event.getScrollTop();
    }
  });
}
 
Example 3
public static Rectangle visiblePart(Element ctx, Rectangle rect) {
  while (true) {
    if (ctx.getOffsetParent() == null) {
      Rectangle visibleArea = new Rectangle(Window.getScrollLeft(), Window.getScrollTop(), Window.getClientWidth(), Window.getClientHeight());
      return visibleArea.intersect(rect);
    } else {
      Rectangle visible;
      if (hasScroller(ctx)) {
        visible = new Rectangle(0, 0, ctx.getClientWidth(), ctx.getClientHeight());
        Vector scroll = new Vector(ctx.getScrollLeft(), ctx.getScrollTop());
        rect = rect.sub(scroll);
      } else {
        visible = new Rectangle(0, 0, ctx.getScrollWidth(), ctx.getScrollHeight());
      }

      Rectangle newRect = visible.intersect(rect);
      Vector offset = new Vector(ctx.getOffsetLeft(), ctx.getOffsetTop());

      ctx = ctx.getOffsetParent();
      rect = newRect.add(offset);
    }
  }
}
 
Example 4
Source Project: unitime   File: RoomEdit.java    License: Apache License 2.0 6 votes vote down vote up
public void show() {
	UniTimePageLabel.getInstance().setPageName(iRoom.getUniqueId() == null ? MESSAGES.pageAddRoom() : MESSAGES.pageEditRoom());
	setVisible(true);
	iLastScrollLeft = Window.getScrollLeft();
	iLastScrollTop = Window.getScrollTop();
	onShow();
	Window.scrollTo(0, 0);
	
	if (iMap != null) {
		if (iMap.isEnabled() || iRoom.hasCoordinates()) {
			iMap.setVisible(true);
			iMap.onShow();
		} else {
			iMap.setVisible(false);
		}
	}
}
 
Example 5
Source Project: unitime   File: FilterBox.java    License: Apache License 2.0 6 votes vote down vote up
private void position(final UIObject relativeObject, int offsetWidth, int offsetHeight) {
	int textBoxOffsetWidth = relativeObject.getOffsetWidth();
	int offsetWidthDiff = offsetWidth - textBoxOffsetWidth;
	int left = relativeObject.getAbsoluteLeft();
	if (offsetWidthDiff > 0) {
		int windowRight = Window.getClientWidth() + Window.getScrollLeft();
		int windowLeft = Window.getScrollLeft();
		int distanceToWindowRight = windowRight - left;
		int distanceFromWindowLeft = left - windowLeft;
		if (distanceToWindowRight < offsetWidth && distanceFromWindowLeft >= offsetWidthDiff) {
			left -= offsetWidthDiff;
		}
	}
	int top = relativeObject.getAbsoluteTop();
	int windowTop = Window.getScrollTop();
	int windowBottom = Window.getScrollTop() + Window.getClientHeight();
	int distanceFromWindowTop = top - windowTop;
	int distanceToWindowBottom = windowBottom - (top + relativeObject.getOffsetHeight());
	if (distanceToWindowBottom < offsetHeight && distanceFromWindowTop >= offsetHeight) {
		top -= offsetHeight;
	} else {
		top += relativeObject.getOffsetHeight();
	}
	setPopupPosition(left, top);
}
 
Example 6
Source Project: cuba   File: CubaSuggestionFieldWidget.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void setPosition(int offsetWidth, int offsetHeight) {
    // CAUTION: offsetWidth and offsetHeight are ignored because we measure width/height after show

    offsetHeight = getOffsetHeight();

    if (popupOuterPadding == -1) {
        popupOuterPadding = WidgetUtil.measureHorizontalPaddingAndBorder(getElement(), 2);
    }

    int top;
    int left;

    if (offsetHeight + getPopupTop() > Window.getClientHeight() + Window.getScrollTop()) {
        top = getPopupTop() - offsetHeight - textField.getOffsetHeight();
        if (top < 0) {
            top = 0;
        }
    } else {
        top = getPopupTop();
        int topMargin = (top - topPosition);
        top -= topMargin;
    }

    Widget popup = getWidget();
    Element containerFirstChild = popup.getElement().getFirstChild().cast();
    final int textFieldWidth = textField.getOffsetWidth();

    offsetWidth = containerFirstChild.getOffsetWidth();
    if (offsetWidth + getPopupLeft() > Window.getClientWidth() + Window.getScrollLeft()) {
        left = textField.getAbsoluteLeft() + textFieldWidth + Window.getScrollLeft() - offsetWidth;
        if (left < 0) {
            left = 0;
        }
    } else {
        left = getPopupLeft();
    }

    setPopupPosition(left, top);
}
 
Example 7
Source Project: cuba   File: CubaTreeTableWidget.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void showContextMenu(Event event) {
    if (_delegate.contextMenuEnabled && enabled && (_delegate.customContextMenu != null || actionKeys != null)) {
        // Show context menu if there are registered action handlers
        int left = WidgetUtil.getTouchOrMouseClientX(event)
                + Window.getScrollLeft();
        int top = WidgetUtil.getTouchOrMouseClientY(event)
                + Window.getScrollTop();

        selectRowForContextMenuActions(event);

        showContextMenu(left, top);
    }
}
 
Example 8
private Rectangle getVisiblePart() {
  if (DomUtil.hasScrollers(myContext.rootElement)) {
    return DomUtil.visiblePart(myContext.rootElement);
  } else {
    return new Rectangle(Window.getScrollLeft(), Window.getScrollTop(), Window.getClientWidth(), Window.getClientHeight());
  }
}
 
Example 9
Source Project: unitime   File: EventAdd.java    License: Apache License 2.0 5 votes vote down vote up
public void show() {
	UniTimePageLabel.getInstance().setPageName(iEvent.getId() == null ? MESSAGES.pageAddEvent() : MESSAGES.pageEditEvent());
	setVisible(true);
	iLastScrollLeft = Window.getScrollLeft();
	iLastScrollTop = Window.getScrollTop();
	onShow();
	Window.scrollTo(0, 0);
	if (iForm.getRowFormatter().isVisible(iSessionRow)) {
		iSession.setFilter(this);
		iForm.setWidget(iSessionRow, 1, iSession);
	}
	iFileUpload.check();
}
 
Example 10
Source Project: unitime   File: RoomDetail.java    License: Apache License 2.0 5 votes vote down vote up
public void show() {
	UniTimePageLabel.getInstance().setPageName(MESSAGES.pageRoomDetail());
	setVisible(true);
	iLastScrollLeft = Window.getScrollLeft();
	iLastScrollTop = Window.getScrollTop();
	onShow();
	Window.scrollTo(0, 0);
}
 
Example 11
Source Project: unitime   File: RoomFeatureEdit.java    License: Apache License 2.0 5 votes vote down vote up
public void show() {
	UniTimePageLabel.getInstance().setPageName(iFeature.getId() == null ? MESSAGES.pageAddRoomFeature() : MESSAGES.pageEditRoomFeature());
	setVisible(true);
	iLastScrollLeft = Window.getScrollLeft();
	iLastScrollTop = Window.getScrollTop();
	onShow();
	Window.scrollTo(0, 0);
}
 
Example 12
Source Project: unitime   File: UniTimeMenuBar.java    License: Apache License 2.0 5 votes vote down vote up
private void move(boolean show) {
	iLastClientWidth = Window.getClientWidth();
	iLastScrollLeft = Window.getScrollLeft();
	iLastScrollTop = Window.getScrollTop();
	iMenu.getElement().getStyle().setWidth(iLastClientWidth - 2, Unit.PX);
	iMenu.getElement().getStyle().setLeft(iLastScrollLeft, Unit.PX);
	iMenu.getElement().getStyle().setTop(iLastScrollTop, Unit.PX);
	iMenu.setVisible(true);
}
 
Example 13
Source Project: unitime   File: SolutionReportsPage.java    License: Apache License 2.0 5 votes vote down vote up
public static void __search() {
	final int left = Window.getScrollLeft();
	final int top = Window.getScrollTop();
	SolutionReportsPage page = (SolutionReportsPage)RootPanel.get("UniTimeGWT:Body").getWidget(0);
	page.init(new AsyncCallback<Boolean>() {
		@Override
		public void onFailure(Throwable caught) {
		}
		@Override
		public void onSuccess(Boolean result) {
			if (result)
				Window.scrollTo(left, top);
		}
	});
}
 
Example 14
Source Project: unitime   File: SolutionChangesPage.java    License: Apache License 2.0 5 votes vote down vote up
public static void __search() {
	final int left = Window.getScrollLeft();
	final int top = Window.getScrollTop();
	SolutionChangesPage page = (SolutionChangesPage)RootPanel.get("UniTimeGWT:Body").getWidget(0);
	page.search(new AsyncCallback<Boolean>() {
		@Override
		public void onFailure(Throwable caught) {
		}
		@Override
		public void onSuccess(Boolean result) {
			if (result)
				Window.scrollTo(left, top);
		}
	});
}
 
Example 15
Source Project: swellrt   File: OffsetPosition.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Create a offset position base on the event's client X, Y. The return offset
 * position is relative to the Document body coordinate.
 *
 * @param event
 */
public OffsetPosition(Event event) {
  // convert the event's client coordinate system, which is client area base, to the
  // body position coordinate system.

  this.left = event.getClientX() + Window.getScrollLeft() - Document.get().getBodyOffsetLeft();
  this.top = event.getClientY() + Window.getScrollTop() - Document.get().getBodyOffsetTop();

  this.offsetParent = null;
}
 
Example 16
Source Project: unitime   File: AssignedClassesPage.java    License: Apache License 2.0 5 votes vote down vote up
public static void __search() {
	final int left = Window.getScrollLeft();
	final int top = Window.getScrollTop();
	AssignedClassesPage page = (AssignedClassesPage)RootPanel.get("UniTimeGWT:Body").getWidget(0);
	page.search(new AsyncCallback<Boolean>() {
		@Override
		public void onFailure(Throwable caught) {
		}
		@Override
		public void onSuccess(Boolean result) {
			if (result)
				Window.scrollTo(left, top);
		}
	});
}
 
Example 17
Source Project: unitime   File: AssignmentHistoryPage.java    License: Apache License 2.0 5 votes vote down vote up
public static void __search() {
	final int left = Window.getScrollLeft();
	final int top = Window.getScrollTop();
	AssignmentHistoryPage page = (AssignmentHistoryPage)RootPanel.get("UniTimeGWT:Body").getWidget(0);
	page.search(new AsyncCallback<Boolean>() {
		@Override
		public void onFailure(Throwable caught) {
		}
		@Override
		public void onSuccess(Boolean result) {
			if (result)
				Window.scrollTo(left, top);
		}
	});
}
 
Example 18
Source Project: unitime   File: UniTimeMenuBar.java    License: Apache License 2.0 4 votes vote down vote up
private boolean needsMove() {
	return iLastClientWidth != Window.getClientWidth() ||
		iLastScrollLeft != Window.getScrollLeft() || iLastScrollTop != Window.getScrollTop();
}
 
Example 19
Source Project: unitime   File: TimeGrid.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void onBrowserEvent(Event event) {
	if (Event.ONMOUSEMOVE == DOM.eventGetType(event) && !iSelection.isActive() && iMoving != null) {
		iMoving.onBrowserEvent(event);
		if (iMoving.iCursor != null)
			getElement().getStyle().setCursor(iMoving.iCursor);
		return;
	}

	double x = event.getClientX() - getAbsoluteLeft() + Window.getScrollLeft();
	double y = event.getClientY() - getAbsoluteTop() + Window.getScrollTop();

	int slot = 3 * Math.min(Math.max(0, (int)Math.round(4 * (y - 1 + iStart * iCellHeight) / iCellHeight)), 96);
	int day = Math.min(Math.max(0, (int)Math.floor((x - 2) / iCellWidth)), iDays.length - 1);
	int weeks = (isSingleRoom() ? iSelectedWeeks.size() : iRoomResources.size());
	int week = Math.min(Math.max(0, (int)Math.floor(weeks * (x - 2 - iCellWidth * day) / (iCellWidth - 6))), weeks - 1);
	if (iRTL) {
		day = iDays.length - day - 1;
		week = weeks - week - 1;
	}
	int dayOfWeek = iDays[day];
	int h = slot / 12;
	int m = 5 * (slot % 12);
	String time = (CONSTANTS.useAmPm() ? (h == 0 ? "12": h <= 12 ? h : h-12) : h) + ":" + (m < 10 ? "0" : "") + m + (CONSTANTS.useAmPm() ? (h <= 11 ? "a" : "p") : "");
	
	int dayInv = (iDayOfWeeks == null ? (7 + dayOfWeek - iPropertiesProvider.getFirstDayOfWeek()) % 7 : dayOfWeek);
	String text = (iDayOfWeeks == null ? CONSTANTS.longDays()[dayOfWeek] : iDayOfWeeks.get(dayOfWeek)) + " " + (isSingleRoom() ? iSelectedWeeks.get(week) : iSelectedWeeks.get(0)).getDayNames().get(dayInv) +
			" " + time + (isSingleRoom() ? "" : " " + iRoomResources.get(week).getName());
	ResourceInterface room = (isSingleRoom() ? iRoomResources.get(0) : iRoomResources.get(week));
	iPopup.setPopupPosition(event.getClientX() + Window.getScrollLeft(), event.getClientY() + Window.getScrollTop());
	
	getElement().getStyle().setCursor(Cursor.CROSSHAIR);
	
	switch (DOM.eventGetType(event)) {
	case Event.ONMOUSEDOWN:
		iSelection.setStart(dayOfWeek, slot, week);
		iSelection.setEnd(dayOfWeek, slot, week);
		iSelection.setVisible(true);
		iSelection.setActive(true);
		break;
	case Event.ONMOUSEMOVE:
		iSelection.setEnd(dayOfWeek, slot, week);
		if (!iPopup.isShowing()) iPopup.show();
		if (!room.getId().equals(iLastRoomId)) {
			RoomHint.showHint(iPopup.getElement(), room.getId(), "", (room.hasDistance() ? String.valueOf(Math.round(room.getDistance())) : ""), false);
			iLastRoomId = room.getId();
		}
		break;
	case Event.ONMOUSEUP:
		onMouseUp();
		break;
	case Event.ONMOUSEOVER:
		if (!iPopup.isShowing() && (iSelection.isActive() || iMoving == null)) iPopup.show();
		if (iSelection.isActive() && !iSelection.isVisible()) {
			iSelection.setVisible(true);					
		}
		if (!room.getId().equals(iLastRoomId)) {
			RoomHint.showHint(iPopup.getElement(), room.getId(), "", (room.hasDistance() ? String.valueOf(Math.round(room.getDistance())) : ""), false);
			iLastRoomId = room.getId();
		}
		break;
	case Event.ONMOUSEOUT:
		Element child = DOM.eventGetToElement(event);
		if (child != null && !getElement().isOrHasChild(child)) {
			if (iPopup.isShowing()) {
				iPopup.hide();
				RoomHint.hideHint(); iLastRoomId = null;
			}
			iSelection.setVisible(false);
		}
		/*
		if (iSelection.isActive() && !DOM.isOrHasChild(TimeGrid.this.getElement(), DOM.eventGetToElement(event))) {
			iSelection.setActive(false);
		}
		*/
		break;
	}
	
	iHint.setText((iSelection.isVisible() && iSelection.isActive() ? iSelection.toString() : text));
	
	event.preventDefault();
	event.stopPropagation();
}
 
Example 20
Source Project: gwt-traction   File: Geometry.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * This takes into account scrolling and will be in absolute
 * coordinates where the top left corner of the page is 0,0 but
 * the viewport may be scrolled to something else.
 */
public static final Rect getViewportBounds() {
    return new Rect(Window.getScrollLeft(), Window.getScrollTop(), Window.getClientWidth(), Window.getClientHeight());
}