Example #1
0
 private Location center(final View workspace, final View view) {
   final Size rootSize = workspace.getSize();
   final Location location = new Location(rootSize.getWidth() / 2, rootSize.getHeight() / 2);
   final Size dialogSize = view.getRequiredSize(new Size(rootSize));
   location.subtract(dialogSize.getWidth() / 2, dialogSize.getHeight() / 2);
   return location;
 }
Example #2
0
 int cursorAtLine(final Location atLocation) {
   LOG.debug("pointer at " + atLocation);
   final int y = atLocation.getY();
   int lineIndex = displayFromLine + (y / target.getText().getLineHeight());
   lineIndex = Math.max(lineIndex, 0);
   return lineIndex;
 }
Example #3
0
  int cursorAtCharacter(final Location atLocation, final int lineOffset) {
    final String text = getText(lineOffset);
    if (text == null) {
      for (int i = lineOffset; i >= 0; i--) {
        final String text2 = getText(i);
        if (text2 != null) {
          final int at = text2.length();
          LOG.debug("character at " + at + " line " + lineOffset);
          return at;
        }
      }
    }

    /*
     * slightly offsetting mouse helps the user position the cursor between
     * characters near the pointer rather than always after the pointer
     */
    final int x = atLocation.getX() - 3;

    int at = 0;
    final int endAt = text.length();

    int width = 0;

    while (at < endAt && x > width) {
      width += target.getText().charWidth(text.charAt(at));
      at++;
    }

    LOG.debug("character at " + at + " line " + lineOffset);
    return at;
  }
Example #4
0
 public ViewAreaType viewAreaType(final Location location) {
   if (onOverlay(location)) {
     location.subtract(overlayView.getLocation());
     return overlayView.viewAreaType(location);
   } else {
     return rootView.viewAreaType(location);
   }
 }
Example #5
0
 public View pickupView(final Location location) {
   if (onOverlay(location)) {
     location.subtract(overlayView.getLocation());
     return overlayView.pickupView(location);
   } else {
     return rootView.pickupView(location);
   }
 }
Example #6
0
 public void mouseMoved(final Location location) {
   if (onOverlay(location)) {
     location.subtract(overlayView.getLocation());
     overlayView.mouseMoved(location);
   } else {
     rootView.mouseMoved(location);
   }
 }
Example #7
0
 public View identifyView(final Location location, final boolean includeOverlay) {
   if (includeOverlay && onOverlay(location)) {
     location.subtract(overlayView.getLocation());
     return overlayView.identify(location);
   } else {
     return rootView.identify(location);
   }
 }
Example #8
0
 public View dragFrom(final Location location) {
   if (onOverlay(location)) {
     location.subtract(overlayView.getLocation());
     return overlayView.dragFrom(location);
   } else {
     return rootView.dragFrom(location);
   }
 }
Example #9
0
 @Override
 public void showInOverlay(final Content content, final Location location) {
   View view;
   view = Toolkit.getViewFactory().createView(new ViewRequirement(content, ViewRequirement.OPEN));
   view =
       new LineBorder(
           2,
           Toolkit.getColor(ColorsAndFonts.COLOR_SECONDARY2),
           new BackgroundBorder(Toolkit.getColor(ColorsAndFonts.COLOR_SECONDARY3), view));
   final Size size = view.getRequiredSize(Size.createMax());
   location.subtract(size.getWidth() / 2, size.getHeight() / 2);
   view.setLocation(location);
   setOverlayView(view);
 }
Example #10
0
 @Override
 public void showDebugFrame(final DebuggableWithTitle[] info, final Location at) {
   final InfoDebugFrame f = new InfoDebugFrame();
   f.setInfo(info);
   f.show(at.getX(), at.getY());
 }