Package charva.awt

Examples of charva.awt.Point


    public void draw(Toolkit toolkit) {
        /*
         * Get the absolute origin of this component.
         */
        Point origin = getLocationOnScreen();
        toolkit.setCursor(origin);
        int colorpair = getCursesColor();

        int attribute;
        if (!super.isEnabled()) {
            attribute = Toolkit.A_NORMAL;
            toolkit.addString("<", attribute, colorpair);
            toolkit.addString(super.getText(), attribute, colorpair);
            toolkit.addString(">", attribute, colorpair);
        } else {
            attribute = (super.hasFocus()) ? Toolkit.A_BOLD : Toolkit.A_NORMAL;
            toolkit.addString(" ", attribute, colorpair);
            toolkit.addString(super.getText(), attribute, colorpair);
            toolkit.addString(" ", attribute, colorpair);
        }

        if (super.getMnemonic() > 0) {
            int mnemonicPos = super.getText().indexOf(
                    (char) super.getMnemonic());
            if (mnemonicPos != -1) {
                toolkit.setCursor(origin.addOffset(1 + mnemonicPos, 0));
                toolkit.addChar(super.getMnemonic(), attribute
                        | Toolkit.A_UNDERLINE, colorpair);
            }
        }
    }
View Full Code Here


        super.requestFocus();

        /*
         * Get the absolute origin of this component
         */
        Point origin = getLocationOnScreen();
        Toolkit.getDefaultToolkit().setCursor(origin);
    }
View Full Code Here

     */
    public void draw(Toolkit toolkit) {

  /* Get the absolute origin of this component.
   */
  Point origin = getLocationOnScreen();

  /* Blank out the area of this component, but only if this
   * component's color-pair is different than that of the
   * parent container.
   */
  int colorpair = getCursesColor();
  Container parent = getParent();
  if (parent != null && colorpair != parent.getCursesColor())
      toolkit.blankBox(origin, this.getSize(), colorpair);

  // Draw the border if there is one.
  if (_border != null) {
      _border.paintBorder(this, colorpair,
        origin.x, origin.y,
        this.getWidth(), this.getHeight(), toolkit);
  }

  /* Now draw the JPasswordField itself.
   */
  Insets insets = super.getInsets();
  origin.translate(insets.left, insets.top);

  /* If the field is enabled, it is drawn with the UNDERLINE
   * attribute.  If it is disabled, it is drawn without the
   * UNDERLINE attribute.
   */
  int attrib = 0;
  if (super._enabled)
      attrib |= Toolkit.A_UNDERLINE;

  toolkit.setCursor(origin);
  toolkit.addString(_padding, attrib, colorpair);
  toolkit.setCursor(origin);

  // Get the displayable portion of the string
  int end;
  if (super._document.length() > (_offset + _columns))
      end = _offset + _columns;
  else
      end = super._document.length();

  /* If the echo character is set, display echo characters instead
   * of the actual string.
   */
  StringBuffer displaybuf = new StringBuffer();
  if (_echoChar != 0) {
      for (int i=0; i<super._document.length(); i++)
    displaybuf.append(_echoChar);
  }
  else  {
      for (int i=0; i<super._document.length(); i++)
    displaybuf.append(' ');
  }

  toolkit.addString(
    displaybuf.substring(_offset, end).toString(),
    attrib, colorpair);
  toolkit.setCursor(origin.addOffset(super._caretPosition - _offset, 0));
    }
View Full Code Here

    }

    public void draw(Toolkit toolkit) {
  /* Get the absolute origin of this component.
   */
  Point origin = getLocationOnScreen();

  int colorpair = getCursesColor();

  toolkit.setCursor(origin);

  int attribute = 0;
  if ( ! (getParent() instanceof JMenuBar)) {
      // This menu is in a JPopupMenu.
      super.draw(toolkit);
  }
  else {
      attribute = (super.hasFocus()) ? Toolkit.A_BOLD : Toolkit.A_REVERSE;
      toolkit.addString(" ", attribute, colorpair);
      toolkit.addString(super.getText(), attribute, colorpair);
      toolkit.addString(" ", attribute, colorpair);

      if (super.getMnemonic() > 0) {
    int mnemonicPos = super.getText().indexOf((char) super.getMnemonic());
    if (mnemonicPos != -1) {
        toolkit.setCursor(origin.addOffset(mnemonicPos + 1, 0));
        toolkit.addChar(super.getMnemonic(), attribute | Toolkit.A_UNDERLINE, colorpair);
    }
      }
  }
    }
View Full Code Here

  }

  if (_popup == null)
      _popup = new JPopupMenu(_menuItems);

  Point p;
  if ( ! this.isTopLevelMenu()) {

      /* If this menu is a submenu (i.e. it is not a direct
       * child of the menubar), check if there is enough
       * space on the right hand side of the parent menu.
       * If there is not enough space, position it on the
       * left of the parent menu.
       */
      JMenu parentmenu = (JMenu) getParentMenu();
      JPopupMenu parentpopup = parentmenu.getPopupMenu();
      p = parentpopup.getLocation();

      int verticalOffset = parentpopup.getComponentIndex(this);
      _popup.setInvoker(parentpopup);
      int parentwidth = parentpopup.getSize().width;
      Toolkit term = Toolkit.getDefaultToolkit();
      if (p.x + parentwidth + _popup.getWidth() <
        term.getScreenColumns()) {

    _popup.setLocation(
          p.addOffset(parentwidth - 1, verticalOffset));
      }
      else {
    _popup.setLocation(
      p.addOffset(-_popup.getWidth() + 1, verticalOffset));
      }
  }
  else {
      JMenuBar parentMenuBar = (JMenuBar) getParent();
      p = parentMenuBar.getPopupMenuLocation(this);
View Full Code Here

  if (_bold)
      attrib |= Toolkit.A_BOLD;

  /* Get the absolute origin of this component.
   */
  Point origin = getLocationOnScreen();
  Insets insets = super.getInsets();
  origin.translate(insets.left, insets.top);

  int colorpair = getCursesColor();

  toolkit.setCursor(origin);
  toolkit.addString(_padding, attrib, colorpair);
  toolkit.setCursor(origin);

  // Get the displayable portion of the string
  int end;
  if (super.getText().length() > (_offset + _columns))
      end = _offset + _columns;
  else
      end = super.getText().length();

  toolkit.addString(
    super.getText().substring(_offset, end).toString(),
    attrib, colorpair);
  toolkit.setCursor(origin.addOffset(super._caretPosition - _offset, 0));
    }
View Full Code Here

      int x = e_.getX();

      /* Get the absolute origin of this component.
       */
      Point origin = getLocationOnScreen();
      Insets insets = super.getInsets();
      origin.translate(insets.left, insets.top);

      int new_caret = _offset + (x - origin.x);
      super._caretPosition =
        (new_caret < super._document.length()) ?
        new_caret : super._document.length();
View Full Code Here

   */
  super.requestFocus();

  /* Get the absolute origin of this component.
   */
  Point origin = getLocationOnScreen();
  Insets insets = super.getInsets();
  origin.translate(insets.left, insets.top);
  Toolkit.getDefaultToolkit().setCursor(
    origin.addOffset(super._caretPosition - _offset, 0));
    }
View Full Code Here

            _headerViewport = new JViewport();
            _headerViewport.setView(header);
            add(_headerViewport);
            _headerViewport.setParent(this);

            _childViewport.setLocation(new Point(0, 1));
            _childViewport.setViewPosition(new Point(0, -1));
        }
    }
View Full Code Here

        /*
         * "limit" gives the row and column of the view component that must
         * appear just inside the JViewport after scrolling.
         */
        Point limit = e_.getLimit();

        /*
         * Determine the value of "limit" relative to the top left corner of
         * the JScrollPane.
         */
        Point viewportLocation = getViewport().getLocation();
        limit.translate(viewportLocation.x, viewportLocation.y);
        limit.translate(scrollable.getLocation());

        /*
         * Get the bounding rectangle of the child viewport, relative to the
         * top left corner of the JScrollPane.
         */
        Rectangle viewport = _childViewport.getBounds();
        //Dimension viewportExtent = _childViewport.getExtentSize();

        Point viewPosition = _childViewport.getViewPosition();
        Point headerPosition = null;
        if (_headerViewport != null)
                headerPosition = _headerViewport.getViewPosition();

        /*
         * If the limit is inside the viewport, the component doesn't need to
         * be scrolled. First do the left/right scrolling.
         */
        if (limit.x > viewport.getRight()) {
            if ((direction == ScrollEvent.LEFT
                    || direction == ScrollEvent.UP_LEFT || direction == ScrollEvent.DOWN_LEFT)) {

                viewPosition.x -= (limit.x - viewport.getRight());
                if (_headerViewport != null)
                        headerPosition.x -= (limit.x - viewport.getRight());
            } else if (direction == ScrollEvent.RIGHT
                    || direction == ScrollEvent.UP_RIGHT
                    || direction == ScrollEvent.DOWN_RIGHT) {

                viewPosition.x += (viewport.getLeft() - limit.x);
                if (_headerViewport != null)
                        headerPosition.x += (viewport.getLeft() - limit.x);
            }
        } else if (limit.x < viewport.getLeft()) {
            if (direction == ScrollEvent.RIGHT
                    || direction == ScrollEvent.UP_RIGHT
                    || direction == ScrollEvent.DOWN_RIGHT) {

                viewPosition.x += (viewport.getLeft() - limit.x);
                if (_headerViewport != null)
                        headerPosition.x += (viewport.getLeft() - limit.x);
            } else if (direction == ScrollEvent.LEFT
                    || direction == ScrollEvent.UP_LEFT
                    || direction == ScrollEvent.DOWN_LEFT) {
                viewPosition.x -= (limit.x - viewport.getRight());
                if (_headerViewport != null)
                        headerPosition.x -= (limit.x - viewport.getRight());
            }
        }

        // Now do the up/down scrolling
        if (limit.y < viewport.getTop()
                && (direction == ScrollEvent.DOWN
                        || direction == ScrollEvent.DOWN_LEFT || direction == ScrollEvent.DOWN_RIGHT)) {

            viewPosition.y += (viewport.getTop() - limit.y);
        } else if (limit.y > viewport.getBottom()
                && (direction == ScrollEvent.UP
                        || direction == ScrollEvent.UP_LEFT || direction == ScrollEvent.UP_RIGHT)) {

            viewPosition.y -= (limit.y - viewport.getBottom());
        }

        _childViewport.setViewPosition(viewPosition);
        if (_headerViewport != null)
                _headerViewport.setViewPosition(headerPosition);

        draw(Toolkit.getDefaultToolkit());

        /*
         * Ensure the cursor is within the viewport (if the component contained
         * within the viewport is offset a long way to the left, the cursor
         * position can get scrambled).
         */
        Toolkit toolkit = Toolkit.getDefaultToolkit();
        Point cursor = toolkit.getCursor();
        Point viewportOrigin = _childViewport.getLocationOnScreen();
        if (cursor.x < viewportOrigin.x || cursor.y < viewportOrigin.y) {
            if (cursor.x < viewportOrigin.x) cursor.x = viewportOrigin.x;
            if (cursor.y < viewportOrigin.y) cursor.y = viewportOrigin.y;
            toolkit.setCursor(cursor);
        }
View Full Code Here

TOP

Related Classes of charva.awt.Point

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.