public void dragOver( DropTargetEvent e ) { styledText.setFocus(); Point location = xParent.getDisplay().map( null, styledText, e.x, e.y ); location.x = Math.max( 0, location.x ); location.y = Math.max( 0, location.y ); try { int offset = styledText.getOffsetAtLocation( new Point( location.x, location.y ) ); styledText.setCaretOffset( offset ); } catch ( IllegalArgumentException ex ) { int maxOffset = styledText.getCharCount(); Point maxLocation = styledText.getLocationAtOffset( maxOffset ); if ( location.y >= maxLocation.y ) { if ( location.x >= maxLocation.x ) { styledText.setCaretOffset( maxOffset ); } else { int offset = styledText.getOffsetAtLocation( new Point( location.x, maxLocation.y ) ); styledText.setCaretOffset( offset ); } } else { styledText.setCaretOffset( maxOffset ); } } }
Point p = expressionEditor.getLocationAtOffset( offset ); int h = expressionEditor.getLineHeight( offset ); Point l = GUIResource.calculateControlPosition( expressionEditor );
private boolean isLocationSelected(Point point) { // FIXME: https://bugs.eclipse.org/bugs/show_bug.cgi?id=260922 if (isBlockSelectionModeEnabled()) return false; int offset = st.getOffsetAtPoint(point); Point p= st.getLocationAtOffset(offset); if (p.x > point.x) offset--; return offset >= fSelection.x && offset < fSelection.y; }
private boolean isLocationSelected(Point point) { // FIXME: https://bugs.eclipse.org/bugs/show_bug.cgi?id=260922 if (isBlockSelectionModeEnabled()) return false; int offset= st.getOffsetAtLocation(point); Point p= st.getLocationAtOffset(offset); if (p.x > point.x) offset--; return offset >= fSelection.x && offset < fSelection.y; }
void refreshCaret(StyledText text, int oldOffset, int newOffset) { if (oldOffset != newOffset) { if (oldOffset != -1) { Point oldPos = text.getLocationAtOffset(oldOffset); int oldHeight = text.getLineHeight(oldOffset); text.redraw (oldPos.x, oldPos.y, CARET_WIDTH, oldHeight, false); } if (newOffset != -1) { Point newPos = text.getLocationAtOffset(newOffset); int newHeight = text.getLineHeight(newOffset); text.redraw (newPos.x, newPos.y, CARET_WIDTH, newHeight, false); } } }
void refreshCaret(StyledText text, int oldOffset, int newOffset) { if (oldOffset != newOffset) { if (oldOffset != -1) { Point oldPos = text.getLocationAtOffset(oldOffset); int oldHeight = text.getLineHeight(oldOffset); text.redraw (oldPos.x, oldPos.y, CARET_WIDTH, oldHeight, false); } if (newOffset != -1) { Point newPos = text.getLocationAtOffset(newOffset); int newHeight = text.getLineHeight(newOffset); text.redraw (newPos.x, newPos.y, CARET_WIDTH, newHeight, false); } } }
void refreshCaret(StyledText text, int oldOffset, int newOffset) { if (oldOffset != newOffset) { if (oldOffset != -1) { Point oldPos = text.getLocationAtOffset(oldOffset); int oldHeight = text.getLineHeight(oldOffset); text.redraw (oldPos.x, oldPos.y, CARET_WIDTH, oldHeight, false); } if (newOffset != -1) { Point newPos = text.getLocationAtOffset(newOffset); int newHeight = text.getLineHeight(newOffset); text.redraw (newPos.x, newPos.y, CARET_WIDTH, newHeight, false); } } }
@Override public Point getLocationAtOffset(int offset) { if (fContentAssistSubjectControl != null) return fContentAssistSubjectControl.getLocationAtOffset(offset); return fViewer.getTextWidget().getLocationAtOffset(offset); }
@Override public Point getLocationAtOffset(int offset) { if (fContentAssistSubjectControl != null) return fContentAssistSubjectControl.getLocationAtOffset(offset); return fViewer.getTextWidget().getLocationAtOffset(offset); }
void updateCaret() { oldCaretLoc = boxText.getLocationAtOffset(boxText.getCaretOffset()); turnOnBox(oldCaretLoc.x > 0 ? oldCaretLoc.x-1:oldCaretLoc.x, oldCaretLoc.y); }
protected Point getAboveLocation(Shell shell, int offset) { StyledText text= fViewer.getTextWidget(); Point location= text.getLocationAtOffset(offset); location= text.toDisplay(location); Rectangle shellBounds= shell.getBounds(); Rectangle displayBounds= shell.getDisplay().getClientArea(); location.y=location.y - shellBounds.height; shiftHorizontalLocation(location, shellBounds, displayBounds); shiftVerticalLocation(location, shellBounds, displayBounds); return location; }
protected Point getAboveLocation(Shell shell, int offset) { StyledText text= fViewer.getTextWidget(); Point location= text.getLocationAtOffset(offset); location= text.toDisplay(location); Rectangle shellBounds= shell.getBounds(); Rectangle displayBounds= shell.getDisplay().getClientArea(); location.y=location.y - shellBounds.height; shiftHorizontalLocation(location, shellBounds, displayBounds); shiftVerticalLocation(location, shellBounds, displayBounds); return location; }
@Override public void handleEvent (Event event) { if (currentOffset != -1) { StyledText text = (StyledText) getControl(); Point position = text.getLocationAtOffset(currentOffset); int height = text.getLineHeight(currentOffset); event.gc.setBackground(event.display.getSystemColor (SWT.COLOR_BLACK)); event.gc.fillRectangle(position.x, position.y, CARET_WIDTH, height); } } };
@Override public void handleEvent (Event event) { if (currentOffset != -1) { StyledText text = (StyledText) getControl(); Point position = text.getLocationAtOffset(currentOffset); int height = text.getLineHeight(currentOffset); event.gc.setBackground(event.display.getSystemColor (SWT.COLOR_BLACK)); event.gc.fillRectangle(position.x, position.y, CARET_WIDTH, height); } } };
@Override public void handleEvent (Event event) { if (currentOffset != -1) { StyledText text = (StyledText) getControl(); Point position = text.getLocationAtOffset(currentOffset); int height = text.getLineHeight(currentOffset); event.gc.setBackground(event.display.getSystemColor (SWT.COLOR_BLACK)); event.gc.fillRectangle(position.x, position.y, CARET_WIDTH, height); } } };
@Override public void handleEvent (Event event) { if (currentOffset != -1) { StyledText text = (StyledText) getControl(); Point position = text.getLocationAtOffset(currentOffset); int height = text.getLineHeight(currentOffset); event.gc.setBackground(event.display.getSystemColor (SWT.COLOR_BLACK)); event.gc.fillRectangle(position.x, position.y, CARET_WIDTH, height); } } };
protected Point getBelowLocation(Shell shell, int offset) { StyledText text= fViewer.getTextWidget(); Point location= text.getLocationAtOffset(offset); if (location.x < 0) location.x= 0; if (location.y < 0) location.y= 0; location= text.toDisplay(location); Rectangle shellBounds= shell.getBounds(); Rectangle displayBounds= shell.getDisplay().getClientArea(); location.y= location.y + text.getLineHeight(offset); shiftHorizontalLocation(location, shellBounds, displayBounds); shiftVerticalLocation(location, shellBounds, displayBounds); return location; }
public void handleEvent (Event event) { if (currentOffset != -1) { StyledText text = (StyledText) getControl(); Point position = text.getLocationAtOffset(currentOffset); int height = text.getLineHeight(currentOffset); event.gc.setBackground(event.display.getSystemColor (SWT.COLOR_BLACK)); event.gc.fillRectangle(position.x, position.y, CARET_WIDTH, height); } } };
@Override public void run() { if (fSourceViewer == null) return; StyledText text= fSourceViewer.getTextWidget(); if (text == null || text.isDisposed()) return; Point location= text.getLocationAtOffset(text.getCaretOffset()); location.x= 0; if (fVerticalRuler instanceof IVerticalRulerExtension) ((IVerticalRulerExtension) fVerticalRuler).setLocationOfLastMouseButtonActivity(location.x, location.y); location= text.toDisplay(location); fRulerContextMenu.setLocation(location.x, location.y); fRulerContextMenu.setVisible(true); } }
protected void carretMoved() { Point newLoc = boxText.getLocationAtOffset(boxText.getCaretOffset()); if (boxes != null && (oldCaretLoc == null || !oldCaretLoc.equals(newLoc))) { oldCaretLoc = newLoc; boolean build = false; if (!setCaretOffset && builder!=null && builder.getCaretOffset() > -1 && builder.getCaretOffset() != boxText.getCaretOffset()) { buildBoxes(); build = true; } if (turnOnBox(oldCaretLoc.x > 0? oldCaretLoc.x -1 : oldCaretLoc.x, oldCaretLoc.y) || build) drawBackgroundBoxes(); } }