コード例 #1
0
ファイル: SkinComposite.java プロジェクト: paulcager/andmore
  /**
   * This method retrieves the key that is placed at the given x,y coordinates, considering the flip
   * status
   *
   * @param x The X coordinate to use at key lookup
   * @param y The Y coordinate to use at key lookup
   * @return The key placed at the given coordinate, or null if none is found
   */
  private IAndroidKey getSkinKey(int x, int y) {
    IAndroidKey keyToReturn = null;
    IAndroidEmulatorInstance instance = UIHelper.getInstanceAssociatedToControl(this);

    Collection<IAndroidKey> keyAreas = skin.getKeyDataCollection(instance.getCurrentLayout());
    if (keyAreas != null) {
      for (IAndroidKey key : keyAreas) {
        if (key.isInsideKey(x, y)) {
          if (key instanceof AndroidPressKey) {
            AndroidPressKey defaultKeyData = (AndroidPressKey) key;

            // if
            // (!defaultKeyData.isFlipSlideValid(instance.isFlipSlideClosed()))
            if (!defaultKeyData.isFlipSlideValid(false)) {
              continue;
            }
          }

          keyToReturn = key;
          break;
        }
      }
    }

    return keyToReturn;
  }
コード例 #2
0
ファイル: SkinComposite.java プロジェクト: paulcager/andmore
  /**
   * Builds an image data that is based on the released image but has the pressed/enter key area
   * painted with data from the pressed/enter image
   *
   * @param key The pressed key
   * @param isEnter Whether the image being retrieved will be used for enter or pressed
   * @return An image data built the way described at method description
   */
  private ImageData getKeyImageData(IAndroidKey key, boolean isEnter) {

    ImageData resultingImage;
    ImageData releasedImage = getImageData(false, false);
    ImageData keyImage = isEnter ? getImageData(false, true) : getImageData(true, false);

    resultingImage = (ImageData) releasedImage.clone();

    Rectangle keyArea = key.getKeyArea();
    int resultingImageSize = resultingImage.width * keyArea.height;
    int[] keyPixelBuffer = new int[resultingImageSize];

    int startY = keyArea.y < 0 ? 0 : keyArea.y;

    keyImage.getPixels(0, startY, resultingImageSize, keyPixelBuffer, 0);

    for (int line = 0; line < keyArea.height; line++) {
      int pos = (line * resultingImage.width) + Math.abs(keyArea.x);
      int startX = Math.abs(keyArea.x);
      startY = (keyArea.y < 0 ? 0 : keyArea.y) + line;
      if (startY < 0) {
        continue;
      }

      int putWidth = keyArea.x < 0 ? keyArea.width - startX : keyArea.width;
      resultingImage.setPixels(startX, startY, putWidth, keyPixelBuffer, pos);
    }

    return resultingImage;
  }
コード例 #3
0
ファイル: SkinComposite.java プロジェクト: paulcager/andmore
  /**
   * This method is called when a mouse selection needs to be canceled. Pressing the right button,
   * releasing the left button or leaving the key area are examples of typical conditions.
   */
  private void cancelMouseSelection() {
    // If the mouse timer is different from null, that means that a key is
    // pressed
    // This check is important so that event messages are not sent by
    // mistake

    if (currentKey != null) {

      ImageData newImageData = getImageData(false, true);
      setSkinImage(newImageData, currentKey, true);
      androidInput.sendClick(currentKey.getKeysym(), false);
    }
  }
コード例 #4
0
ファイル: SkinComposite.java プロジェクト: paulcager/andmore
  /**
   * Performs the skin draw operation.
   *
   * @param gcUsedToDraw The gc object associated with the skin composite that is used to draw the
   *     images
   */
  private void drawSkin(GC gcUsedToDraw, IAndroidKey changedKey) {
    if (currentSkinImage == null) {
      IAndroidEmulatorInstance instance = UIHelper.getInstanceAssociatedToControl(this);
      ImageData initialSkinImage = getImageData(false, false);
      setSkinImage(initialSkinImage, null, false);
      applyLayout(instance.getCurrentLayout());

      if (scrollBarsUsed) {
        synchronizeScrollBars();
      }
    }

    if (displayRectangle != null) {
      int srcXPos, srcYPos, srcWidth, srcHeight;
      int destXPos, destYPos, destWidth, destHeight;
      if (changedKey == null) {
        srcXPos = displayRectangle.x;
        srcYPos = displayRectangle.y;
        srcWidth = displayRectangle.width;
        srcHeight = displayRectangle.height;
        destXPos = 0;
        destYPos = 0;
        destWidth = Math.min(currentSkinImage.getImageData().width, displayRectangle.width);
        destHeight = Math.min(currentSkinImage.getImageData().height, displayRectangle.height);
      } else {
        srcXPos =
            ((int) (changedKey.getKeyArea().x > 0 ? changedKey.getKeyArea().x * zoomFactor : 0));
        srcYPos =
            ((int) (changedKey.getKeyArea().y > 0 ? changedKey.getKeyArea().y * zoomFactor : 0));
        srcWidth = ((int) (changedKey.getKeyArea().width * zoomFactor));
        srcHeight = ((int) (changedKey.getKeyArea().height * zoomFactor));
        destXPos = srcXPos - displayRectangle.x;
        destYPos = srcYPos - displayRectangle.y;
        destWidth = srcWidth;
        destHeight = srcHeight;
      }

      gcUsedToDraw.drawImage(
          currentSkinImage,
          srcXPos,
          srcYPos,
          srcWidth,
          srcHeight,
          destXPos,
          destYPos,
          destWidth,
          destHeight);
    }
  }
コード例 #5
0
ファイル: SkinComposite.java プロジェクト: paulcager/andmore
  private void changeCurrentKey(IAndroidKey newKey) {
    // The following actions are executed only if the key has changed since
    // the last
    // time a mouse move event has happened.
    ImageData newImage;

    if (currentKey != null) {
      // If currentKey is different from null, we know that the mouse
      // cursor has
      // left the area defined by currentKey. That is because from the
      // previous
      // if clause we know that the key has changed, and currentKey
      // attribute
      // state is out-dated until we reach the "currentKey = keyData"
      // statement.
      // In this case, we must draw the RELEASED image version of the key
      // at the
      // key location
      newImage = getImageData(false, false);
      setSkinImage(newImage, currentKey, true);
      setToolTipText(null);
    }

    if (newKey != null) {
      // If keyData is different from null, we know that the mouse cursor
      // has
      // entered the area defined by keyData.
      // In this case, we must draw the ENTER image version of the key at
      // the
      // key location
      newImage = getKeyImageData(newKey, true);
      setSkinImage(newImage, newKey, true);
      setToolTipText(newKey.getToolTip());
    }
    currentKey = newKey;
  }