use of org.rstudio.core.client.Rectangle in project rstudio by rstudio.
the class DomUtilsStandardImpl method getCursorBounds.
public Rectangle getCursorBounds(Document doc) {
Selection sel = Selection.get(NativeWindow.get(doc));
Range selRng = sel.getRangeAt(0);
if (selRng == null)
return null;
sel.removeAllRanges();
SpanElement span = doc.createSpanElement();
Range rng = selRng.cloneRange();
rng.collapse(true);
rng.insertNode(span);
int x = span.getAbsoluteLeft();
int y = span.getAbsoluteTop();
int w = 0;
int h = span.getOffsetHeight();
Rectangle result = new Rectangle(x, y, w, h);
ElementEx parent = (ElementEx) span.getParentElement();
parent.removeChild(span);
parent.normalize();
sel.setRange(selRng);
return result;
}
use of org.rstudio.core.client.Rectangle in project rstudio by rstudio.
the class MiniPopupPanel method positionNearRange.
public void positionNearRange(DocDisplay display, Range range) {
Rectangle bounds = display.getRangeBounds(range);
Point center = bounds.center();
int pageX = center.getX() - (getOffsetWidth() / 2);
// prefer displaying popup below associated text, but place above text
// if it won't fit below
int pageY = bounds.getBottom() + 10;
if (pageY + getOffsetHeight() > display.getBounds().getBottom()) {
pageY = bounds.getTop() - 10 - getOffsetHeight();
}
// avoid leaking off left side of page
pageX = Math.max(20, pageX);
pageY = Math.max(20, pageY);
setPopupPosition(pageX, pageY);
}
use of org.rstudio.core.client.Rectangle in project rstudio by rstudio.
the class CompletionList method getSelectionRect.
/**
* Gets the rectangle of the selected row in absolute (document-relative)
* coordinates, or null if nothing is selected.
*/
public Rectangle getSelectionRect() {
int index = getSelectedIndex();
if (index < 0)
return null;
com.google.gwt.dom.client.Element el = DomUtils.getTableCell(grid_.getElement(), index, 0);
return new Rectangle(el.getAbsoluteLeft(), el.getAbsoluteTop(), el.getOffsetWidth(), el.getOffsetHeight());
}
use of org.rstudio.core.client.Rectangle in project rstudio by rstudio.
the class PlotsPanePreviewer method getPreviewClientRect.
public Rectangle getPreviewClientRect() {
WindowEx win = imageFrame_.getElement().<IFrameElementEx>cast().getContentWindow();
Document doc = win.getDocument();
NodeList<Element> images = doc.getElementsByTagName("img");
if (images.getLength() > 0) {
ElementEx img = images.getItem(0).cast();
return new Rectangle(img.getClientLeft(), img.getClientTop(), img.getClientWidth(), img.getClientHeight());
} else {
return new Rectangle(0, 0, 0, 0);
}
}
use of org.rstudio.core.client.Rectangle in project rstudio by rstudio.
the class AceEditor method getPositionBounds.
@Override
public Rectangle getPositionBounds(Position position) {
Renderer renderer = widget_.getEditor().getRenderer();
ScreenCoordinates start = renderer.textToScreenCoordinates(position.getRow(), position.getColumn());
return new Rectangle(start.getPageX(), start.getPageY(), (int) Math.round(renderer.getCharacterWidth()), (int) (renderer.getLineHeight() * 0.8));
}
Aggregations