/** * @param constrainee * @param container */ private void constrainRectangleToContainer( Rectangle constrainee, Rectangle container ) { Point originalSize = Geometry.getSize( constrainee ); Point containerSize = Geometry.getSize( container ); Point oversize = Geometry.subtract( originalSize, containerSize ); if ( oversize.x > 0 ) { constrainee.width = originalSize.x - oversize.x; } if ( oversize.y > 0 ) { constrainee.height = originalSize.y - oversize.y; } // Detect if the dialog was positioned outside the container Geometry.moveInside( constrainee, container ); }
protected Point computePopupLocation() { if (popup == null || popup.isDisposed()) return null; LinkedPosition position = renameLinkedMode.getCurrentLinkedPosition(); if (position == null) return null; ISourceViewer viewer = editor.getInternalSourceViewer(); ITextViewerExtension5 viewer5 = (ITextViewerExtension5) viewer; int widgetOffset = viewer5.modelOffset2WidgetOffset(position.offset); StyledText textWidget = viewer.getTextWidget(); Point pos = textWidget.getLocationAtOffset(widgetOffset); Point pSize = getExtent(); pSize.y += HAH + 1; pos.x -= HAO; pos.y += textWidget.getLineHeight(widgetOffset); Point dPos = textWidget.toDisplay(pos); Rectangle displayBounds = textWidget.getDisplay().getClientArea(); Rectangle dPopupRect = Geometry.createRectangle(dPos, pSize); Geometry.moveInside(dPopupRect, displayBounds); return new Point(dPopupRect.x, dPopupRect.y); }
/** * Determines the graphical area covered by the given text region. * * @param region the region whose graphical extend must be computed * @return the graphical extend of the given region */ private Rectangle computeArea(IRegion region) { int start= 0; int end= 0; IRegion widgetRegion= modelRange2WidgetRange(region); if (widgetRegion != null) { start= widgetRegion.getOffset(); end= widgetRegion.getOffset() + widgetRegion.getLength(); } StyledText styledText= fTextViewer.getTextWidget(); Rectangle bounds; if (end > 0 && start < end) bounds= styledText.getTextBounds(start, end - 1); else { Point loc= styledText.getLocationAtOffset(start); bounds= new Rectangle(loc.x, loc.y, 0, styledText.getLineHeight(start)); } Rectangle clientArea= styledText.getClientArea(); Geometry.moveInside(bounds, clientArea); return bounds; }
Rectangle displayBounds= textWidget.getDisplay().getClientArea(); Rectangle dPopupRect= Geometry.createRectangle(dPos, pSize); Geometry.moveInside(dPopupRect, displayBounds); return new Point(dPopupRect.x, dPopupRect.y); Rectangle displayBounds= textWidget.getDisplay().getClientArea(); Rectangle dPopupRect= Geometry.createRectangle(dPos, pSize); Geometry.moveInside(dPopupRect, displayBounds); return new Point(dPopupRect.x, dPopupRect.y);
/** * Determines the graphical area covered by the given text region. * * @param region the region whose graphical extend must be computed * @return the graphical extend of the given region */ private Rectangle computeArea(IRegion region) { int start= 0; int end= 0; IRegion widgetRegion= modelRange2WidgetRange(region); if (widgetRegion != null) { start= widgetRegion.getOffset(); end= widgetRegion.getOffset() + widgetRegion.getLength(); } StyledText styledText= fTextViewer.getTextWidget(); Rectangle bounds; if (end > 0 && start < end) bounds= styledText.getTextBounds(start, end - 1); else { Point loc= styledText.getLocationAtOffset(start); bounds= new Rectangle(loc.x, loc.y, 0, styledText.getLineHeight(start)); } Rectangle clientArea= styledText.getClientArea(); Geometry.moveInside(bounds, clientArea); return bounds; }
Rectangle displayBounds= textWidget.getDisplay().getClientArea(); Rectangle dPopupRect= Geometry.createRectangle(dPos, pSize); Geometry.moveInside(dPopupRect, displayBounds); return new Point(dPopupRect.x, dPopupRect.y); Rectangle displayBounds= textWidget.getDisplay().getClientArea(); Rectangle dPopupRect= Geometry.createRectangle(dPos, pSize); Geometry.moveInside(dPopupRect, displayBounds); return new Point(dPopupRect.x, dPopupRect.y);
Rectangle displayBounds= textWidget.getDisplay().getClientArea(); Rectangle dPopupRect= Geometry.createRectangle(dPos, pSize); Geometry.moveInside(dPopupRect, displayBounds); return new Point(dPopupRect.x, dPopupRect.y); Rectangle displayBounds= textWidget.getDisplay().getClientArea(); Rectangle dPopupRect= Geometry.createRectangle(dPos, pSize); Geometry.moveInside(dPopupRect, displayBounds); return new Point(dPopupRect.x, dPopupRect.y);
Monitor monitor= getClosestMonitor(display, caret); Rectangle bounds= monitor.getClientArea(); Geometry.moveInside(caret, bounds);
Monitor monitor= getClosestMonitor(display, caret); Rectangle bounds= monitor.getClientArea(); Geometry.moveInside(caret, bounds);
Geometry.moveInside(bb,cr);
Monitor monitor= getClosestMonitor(display, caret); Rectangle bounds= monitor.getClientArea(); Geometry.moveInside(caret, bounds);
Monitor monitor= getClosestMonitor(display, caret); Rectangle bounds= monitor.getClientArea(); Geometry.moveInside(caret, bounds);
Rectangle displayBounds = closestMonitor.getClientArea(); if (!modelBounds.intersects(displayBounds)) { Geometry.moveInside(modelBounds, displayBounds);