Пример #1
0
 void displayStatus(Graphics g) {
   if (statusString != null) {
     g.setColor(0xffffff);
     g.fillRect(0, getHeight() - inputHeight - 2, getWidth(), inputHeight + 2);
     g.setColor(0x000000);
     g.drawLine(0, getHeight() - inputHeight - 2, getWidth(), getHeight() - inputHeight - 2);
     g.drawString(statusString, 0, getHeight() - inputHeight - 2, Graphics.LEFT | Graphics.TOP);
   }
 }
Пример #2
0
 void displayCurrentCommand(Graphics g) {
   g.setColor(0xffffff);
   g.fillRect(0, getHeight() - inputHeight - 2, getWidth(), inputHeight + 2);
   g.setColor(0x000000);
   g.drawLine(0, getHeight() - inputHeight - 2, getWidth(), getHeight() - inputHeight - 2);
   g.drawString(
       "Ctrl" + " + " + currentCharCommand,
       0,
       getHeight() - inputHeight,
       Graphics.LEFT | Graphics.TOP);
 }
Пример #3
0
 void displayCursor(Graphics g) {
   int x = getCursorX();
   int y = getCursorY();
   if (x >= 0 && x <= vectorLines.elementAt(y).toString().length()) {
     if (isSelected(x, y)) {
       g.setColor(0xffffff);
     } else {
       g.setColor(0x000000);
     }
     g.drawLine(caretLeft, (y) * inputHeight, caretLeft, (y + 1) * inputHeight);
   }
 }
Пример #4
0
  void displayScrollBar(Graphics g) {
    int x = getCursorX();
    int y = getCursorY();
    g.setColor(0xffffff);
    g.fillRect(getWidth() - 5, 0, 5, getHeight());
    g.setColor(0x000000);
    g.drawLine(getWidth() - 5, 0, getWidth() - 5, getHeight());

    int hScrollMin = inputHeight;

    int yScroll = (((linesOnScreen - 1) * y) * inputHeight) / getLinesCount();

    g.fillRect(getWidth() - 5, yScroll, 5, hScrollMin);
  }
Пример #5
0
  void displayCharacterMap(Graphics g) {
    if (currentChars != null) {
      g.setColor(0xffffff);
      g.fillRect(0, getHeight() - inputHeight - 2, getWidth(), inputHeight + 2);
      g.setColor(0x000000);
      g.drawLine(0, getHeight() - inputHeight - 2, getWidth(), getHeight() - inputHeight - 2);
      for (int i = 0; i < currentChars.length; i++) {
        char ch = currentChars[i];
        if (isUppercase) {
          ch = String.valueOf(currentChars[i]).toUpperCase().charAt(0);
        }

        // TODO: if i*12 > getWidth() ?

        g.drawChar(ch, i * 12, getHeight() - inputHeight, Graphics.LEFT | Graphics.TOP);
        if (currentChars[currentKeyStep] == currentChars[i]) {
          g.drawRect(
              i * 12 - 2,
              getHeight() - inputHeight - 2,
              inputFont.charWidth(ch) + 4,
              inputHeight + 4);
        }
      }
    }
  }
Пример #6
0
  void displayLines(Graphics g, int yStart) {
    // (1 + 2, depends on font size)

    if (isSelection && (xStartSelection != xEndSelection || yStartSelection != yEndSelection)) {
      for (int y = Math.max(0, yStart);
          y < Math.min(yStart + linesOnScreen + 1 + 2, vectorLines.size());
          y++) {
        String currentLine = vectorLines.elementAt(y).toString();
        int width = 0;

        for (int x = 0; x < currentLine.length(); x++) {
          int previousWidth = (x == 0) ? 0 : inputFont.charWidth(currentLine.charAt(x - 1));
          width += previousWidth;

          if (isSelected(x, y)) {
            g.setColor(0x000000);
            g.fillRect(
                width, y * inputHeight, inputFont.charWidth(currentLine.charAt(x)), inputHeight);

            g.setColor(0xffffff);
            g.drawChar(currentLine.charAt(x), width, y * inputHeight, Graphics.LEFT | Graphics.TOP);
          } else {
            g.setColor(0x000000);
            g.drawChar(currentLine.charAt(x), width, y * inputHeight, Graphics.LEFT | Graphics.TOP);
          }
        }

        if (currentLine.length() == 0) {
          if (isSelected(0, y)) {
            g.setColor(0x000000);
            g.fillRect(0, y * inputHeight, 5, inputHeight);
          }
        }
      }
    } else {
      for (int y = Math.max(0, yStart);
          y < Math.min(yStart + linesOnScreen + 1 + 2, vectorLines.size());
          y++) {
        g.drawString(
            vectorLines.elementAt(y).toString(), 0, y * inputHeight, Graphics.LEFT | Graphics.TOP);
      }
    }
  }
Пример #7
0
 // display
 // not used
 void displayLines(Graphics g) {
   for (int y = 0; y < vectorLines.size(); y++) {
     g.drawString(
         vectorLines.elementAt(y).toString(), 0, y * inputHeight, Graphics.LEFT | Graphics.TOP);
   }
 }
Пример #8
0
  public void paint(Graphics g) {
    g.setFont(inputFont);
    g.setColor(0xffffff);
    g.fillRect(0, 0, getWidth(), getHeight());
    g.setColor(0x000000);

    int x = getCursorX();
    int y = getCursorY();

    translationX = caretLeft - (getWidth() - 5);

    // if(isUp)
    // {
    translationY = y * inputHeight - (getHeight() - 40);
    // }
    // else if(isDown)
    // {
    // 	translationY = y*inputHeight - (getHeight() - 40);
    // }
    // etc

    if (translationX > 0) {
      g.translate(-translationX, 0);
    }

    if (translationY > 0) {
      g.translate(0, -translationY);

      displayLines(g, y - linesOnScreen);
    } else {
      displayLines(g, 0);
    }

    if (caretBlinkOn && goToNextChar) {
      displayCursor(g);
    }

    if (translationX > 0) {
      g.translate(translationX, 0);
    }

    if (translationY > 0) {
      g.translate(0, translationY);
    }

    if (currentState == EditorState.Commands) {
      if (!goToNextChar) {
        displayCharacterMap(g);
      } else {
        displayCurrentCommand(g);
      }
    } else if (currentState == EditorState.Input) {
      if (!goToNextChar) {
        displayCharacterMap(g);
      } else if (isViewStatus) {
        displayStatus(g);
      }
    }

    if (isViewScrollBar) {
      displayScrollBar(g);
    }
  }