Package jcurses.util

Examples of jcurses.util.Rectangle


    // Ideally we shouldn't have to calculate this when laying out every widget, only when
    // some widget has changed, c.f. java.awt.LayoutManager2.invalidateLayout()
    updateAllSeparators();

    // Fit the current widget into the appropriate cell
    Rectangle rect = (mFather.getChildsRectangle() == null) ? mFather.getSize() : mFather.getChildsRectangle();
    BorderLayoutConstraint cstr = (BorderLayoutConstraint)constraint;

    Rectangle prefSize = widget.getPreferredSize();
    int prefWidth = prefSize.getWidth();
    int prefHeight = prefSize.getHeight();
    int maxWidth = rect.getWidth()// Cell width
    int maxHeight = rect.getHeight();// Cell height
    int x = 0;                       // Cell x offset
    int y = 0;                       // Cell y offset
    switch (cstr.mPosition) {
    case NORTH:
      x = 0; y = 0;
      maxHeight = mYSep[0];
      break;
    case SOUTH:
      x = 0; y = mYSep[1];
      maxHeight -= mYSep[1];
      break;
    case CENTER:
      x = mXSep[0]; y = mYSep[0];
      maxWidth = mXSep[1] - mXSep[0];
      maxHeight = mYSep[1] - mYSep[0];
      break;
    case WEST:
      x = 0; y = mYSep[0];
      maxWidth = mXSep[0];
      maxHeight = mYSep[1] - mYSep[0];
      break;
    case EAST:
      x = mXSep[1]; y = mYSep[0];
      maxWidth -= mXSep[1];
      maxHeight = mYSep[1] - mYSep[0];
      break;
    default:
      throw new IllegalStateException("Unknown position for widget: " + cstr.mPosition);
    }

    if (prefWidth <= 0) {
      prefWidth = maxWidth;
    }
    if (prefHeight <= 0) {
      prefHeight = maxHeight;
    }

    /*
    Protocol.debug("Widget prelayout for cell " + cstr.mPosition + " is offset(" + x + "," + y + ")" +
                       " maxsize(" + maxWidth + "," + maxHeight + ")");
    */

    int width = 0;
    int height = 0;
    if (prefWidth < maxWidth) {
      widget.setX(getAlignedCoordinate(prefWidth, maxWidth, x, cstr.mHorizontalConstraint));
      width = prefWidth;
    } else {
      widget.setX(x);
      width = maxWidth;
    }

    if (prefHeight < maxHeight) {
      widget.setY(getAlignedCoordinate(prefHeight, maxHeight, y, cstr.mVerticalConstraint));
      height = prefHeight;
    } else {
      widget.setY(y);
      height = maxHeight;
    }
    /*
    Protocol.debug("Widget layout for cell " + cstr.mPosition + " is offset(" + widget.getX() + "," + widget.getY() + ")" +
                       " maxsize(" + width + "," + height + ")");
    */
    widget.setSize(new Rectangle(width, height));
  }
View Full Code Here


   *        |
   *        mXSep[1]
   */
  private void updateAllSeparators() {
    // Get Rectangle to lay out into -- this is the total area available.
    Rectangle rect = (mFather.getChildsRectangle() == null) ? mFather.getSize() : mFather.getChildsRectangle();
    updateSeparatorsDimension(mXSep, mSlots[WEST], mSlots[CENTER], mSlots[EAST], rect.getWidth(), true);
    updateSeparatorsDimension(mYSep, mSlots[NORTH], mSlots[CENTER], mSlots[SOUTH], rect.getHeight(), false);
  }
View Full Code Here

  public void layout(Widget widget, Object constraint) {
    if (! (constraint instanceof GridLayoutConstraint)) {
     throw new RuntimeException("unknown constraint: "+constraint.getClass().getName());
    }
   
    Rectangle rect = (_father.getChildsRectangle() == null)?_father.getSize():_father.getChildsRectangle();
    _grid = new Grid(rect, _width, _height);
    _defLayout.layout(widget, ((GridLayoutConstraint)constraint).getDefaultLayoutConstraint(_grid));
 
  }
View Full Code Here

    this.verticalConstraint=verticalConstraint;
  }
 
  DefaultLayoutConstraint getDefaultLayoutConstraint(Grid grid) {
   
    Rectangle rect = grid.getRectangle(x,y,width,height);
    return new DefaultLayoutConstraint(rect.getX(), rect.getY(), rect.getWidth(), rect.getHeight(),
                       horizontalConstraint, verticalConstraint);
   
  }
View Full Code Here

    }
   
  }
 
  Rectangle getRectangle(int x, int y, int width, int height) {
    return new Rectangle(getWidth(_widths, 0,x), getWidth(_heights, 0,y), getWidth(_widths, x,x+width),
               getWidth(_heights, y, y+height));
   
  }
View Full Code Here

  public boolean hasVerticalScrollbar() {
    return true;
  }

  public Rectangle getBorderRectangle() {
    Rectangle r = list.getRectangle();
   
    // account for normal (unwanted) margin
    r.setY(-1);
    r.setHeight(r.getHeight() + 2);
   
    r.setX(r.getX() + r.getWidth() - 1);
    r.setWidth(1);
    return r;
  }
View Full Code Here

    this.completionStatus = completionStatus;
  }
 
  @Override
  protected Rectangle getPreferredSize() {
    return new Rectangle(1, 100);
  }
View Full Code Here

    BorderLayoutManager manager = new BorderLayoutManager();
    getRootPanel().setLayoutManager(manager);

    list = new List(35, false) {
      {
        setSize(new Rectangle(10, 10));
      }

      protected boolean handleInput(InputChar inputChar) {
        boolean result = super.handleInput(inputChar);
View Full Code Here

    BorderLayoutManager manager = new BorderLayoutManager();
    getRootPanel().setLayoutManager(manager);

    list = new List(35, false) {
      {
        setSize(new Rectangle(10, 10));
      }

      protected boolean handleInput(InputChar inputChar) {
        boolean result = super.handleInput(inputChar);
View Full Code Here

   
    return true;
  }

  public Rectangle getBorderRectangle() {
    Rectangle r = less.list.getRectangle();
   
    // account for normal (unwanted) margin
    r.setY(-1);
    r.setHeight(r.getHeight() + 2);
   
    r.setX(r.getX() + r.getWidth() - 1);
    r.setWidth(1);
    return r;
  }
View Full Code Here

TOP

Related Classes of jcurses.util.Rectangle

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.