Java Code Examples for com.codename1.ui.TextArea#getHeight()

The following examples show how to use com.codename1.ui.TextArea#getHeight() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InPlaceEditView.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
TextAreaData(TextArea ta) {

            absoluteX = ta.getAbsoluteX();
            absoluteY = ta.getAbsoluteY();
            scrollX = ta.getScrollX();
            scrollY = ta.getScrollY();
            Style s = ta.getStyle();
            paddingTop = s.getPaddingTop();
            paddingLeft = s.getPaddingLeft(ta.isRTL());
            paddingRight = s.getPaddingRight(ta.isRTL());
            paddingBottom = s.getPaddingBottom();
            isTextField = (ta instanceof TextField);
            verticalAlignment = ta.getVerticalAlignment();
            height = ta.getHeight();
            width = ta.getWidth();
            fontHeight = s.getFont().getHeight();
            textArea = ta;
            isRTL = ta.isRTL();
            nextDown = textArea.getComponentForm().getNextComponent(textArea);
            isSingleLineTextArea = textArea.isSingleLineTextArea();
            hint = ta.getHint();
            nativeHintBool = textArea.getUIManager().isThemeConstant("nativeHintBool", false);
            nativeFont = s.getFont().getNativeFont();
            fgColor = s.getFgColor();
            maxSize = ta.getMaxSize();
        }
 
Example 2
Source File: InPlaceEditView.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
public static void reLayoutEdit(boolean force) {

        if (mIsEditing && !isActiveTextEditorHidden() && sInstance != null && sInstance.mEditText != null) {
            final TextArea txt = sInstance.mEditText.mTextArea;
            if (!force && lastTextAreaX == txt.getAbsoluteX() + txt.getScrollX() &&
                    lastTextAreaY == txt.getAbsoluteY() + txt.getScrollY() &&
                    lastTextAreaWidth == txt.getWidth() &&
                    lastTextAreaHeight == txt.getHeight()) {
                return;
            }
            Display.getInstance().callSerially(new Runnable() {
                public void run() {
                    if (mIsEditing && !isActiveTextEditorHidden() && sInstance != null && sInstance.mEditText != null) {

                        if (txt != null) {

                            if (sInstance.mEditText.mTextArea != txt) {
                                //has changed in between, skip or would change location back to old field
                                return;
                            }

                            final int txty = lastTextAreaY = txt.getAbsoluteY() + txt.getScrollY();
                            final int txtx = lastTextAreaX = txt.getAbsoluteX() + txt.getScrollX();
                            final int w = lastTextAreaWidth = txt.getWidth();
                            final int h = lastTextAreaHeight = txt.getHeight();


                            sInstance.impl.getActivity().runOnUiThread(new Runnable() {
                                public void run() {
                                    if (mIsEditing && !isActiveTextEditorHidden() && sInstance != null && sInstance.mEditText != null) {

                                        if (sInstance.mEditText.mTextArea != txt) {
                                            //has changed in between, skip or would change location back to old field
                                            return;
                                        }

                                        sInstance.mEditLayoutParams.setMargins(txtx, txty, 0, 0);
                                        sInstance.mEditLayoutParams.width = w;
                                        sInstance.mEditLayoutParams.height = h;
                                        if (!txt.isSingleLineTextArea() && txt.getDoneListener() != null) {
                                            sInstance.mEditText.getLayoutParams().width = w;
                                            sInstance.mEditText.getLayoutParams().height = h;
                                            sInstance.mEditText.setMaxWidth(w);
                                            sInstance.mEditText.setMaxHeight(h);
                                            sInstance.setHorizontalScrollBarEnabled(false);
                                            sInstance.mEditText.setHorizontallyScrolling(false);
                                        }



                                        sInstance.mEditText.requestLayout();
                                        sInstance.invalidate();
                                        if (sInstance.getVisibility() != VISIBLE) {
                                            sInstance.setVisibility(VISIBLE);
                                        }
                                        sInstance.bringToFront();
                                    }
                                }
                            });
                        }
                    }
                }
            });
        }
    }
 
Example 3
Source File: DefaultLookAndFeel.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
/**
   * {@inheritDoc}
   */
   public void drawTextFieldCursor(Graphics g, TextArea ta) {
       Style style = ta.getStyle();
       Font f = style.getFont();


      int cursorY;
      if(ta.isSingleLineTextArea()) {
          switch(ta.getVerticalAlignment()) {
              case Component.BOTTOM:
                  cursorY = ta.getY() + ta.getHeight() -  f.getHeight();
                  break;
              case Component.CENTER:
                  cursorY = ta.getY() + ta.getHeight() / 2 -  f.getHeight() / 2;
                  break;
              default:
                  cursorY = ta.getY() + style.getPaddingTop();
                  break;
          }
       } else {
          cursorY = ta.getY() + style.getPaddingTop() + ta.getCursorY() * (ta.getRowsGap() + f.getHeight());
       }
  	int cursorX = getTextFieldCursorX(ta);

      int align = reverseAlignForBidi(ta);
int x=0;
      if (align==Component.RIGHT) {
          String inputMode = ta.getInputMode();
          int inputModeWidth = f.stringWidth(inputMode);

  		int baseX=ta.getX()+style.getPaddingLeftNoRTL()+inputModeWidth;
  		if (cursorX<baseX) {
  			x=baseX-cursorX;
  		}
      }

      int oldColor = g.getColor();
      if(getTextFieldCursorColor() == 0) {
          g.setColor(style.getFgColor());
       } else {
          g.setColor(getTextFieldCursorColor());
       }
      g.drawLine(cursorX + x, cursorY, cursorX + x, cursorY + f.getHeight());
      g.setColor(oldColor);
  }