Exemple #1
0
 /**
  * 绘制选单
  *
  * @param g
  * @param color1
  * @param color2
  */
 public synchronized void drawChoice(GLEx g) {
   if (!visible) {
     return;
   }
   int x1 = this.getX() - 5;
   int y1 = this.getY();
   int x2 = this.getWidth() + 20;
   int y2 = this.getAllHeight() + 10;
   int w = x2 + 15;
   int h = y2 + 10;
   if (dialogImage == null) {
     dialogImage = createDefaultDialog(w, h);
   }
   g.draw(dialogImage, x1, y1 - 5);
   IFont old = g.getFont();
   try {
     g.setFont(defFont);
     // 选中项
     int i = getDrawContent();
     if (i >= 0 && i < maxSize) {
       LGradation.getInstance(LColor.white, LColor.black, getWidth() + 6, getSpace())
           .drawHeight(g, x1 + 14, y1 + getSpace() * getDrawContent() + 2);
       g.setColor(LColor.darkGray);
       g.drawRect(x1 + 14, y1 + getSpace() * getDrawContent() + 2, getWidth() + 6, getSpace());
       g.resetColor();
     }
     int index = 0;
     // 遍历文字与颜色信息
     for (; ; ) {
       if (index >= maxSize) {
         break;
       }
       int viewIndex = index + view;
       if (viewIndex >= choice.length) {
         break;
       }
       LColor nColor;
       if (colors[viewIndex] != null) {
         nColor = colors[viewIndex];
       } else {
         nColor = LColor.white;
       }
       int i1 = 0;
       for (int j1 = 0; j1 < choice[viewIndex].length; j1++) {
         g.drawString(
             choice[viewIndex][j1],
             posX + i1 + 14,
             posY + index * getSpace() + getHeight() - 14,
             0,
             nColor);
         i1 += mesList[j1] + tab;
       }
       index++;
     }
   } finally {
     g.setFont(old);
     g.resetColor();
   }
 }
Exemple #2
0
 public void draw(final GLEx g, Model model, float mx, float my) {
   int span = existTime * 2;
   switch (model) {
     case OVAL:
       g.drawOval(mx + x - span / 2, my + y - span / 2, span, span);
       break;
     case RECT:
       g.drawRect(mx + x - span / 2, my + y - span / 2, span, span);
       break;
   }
   existTime++;
 }
Exemple #3
0
  public void draw(GLEx g, int x, int y, float mouseX, float mouseY) {
    if (this.max > 0) {

      LFont oldFont = g.getFont();
      int oldColor = g.color();

      g.setFont(this.font);
      int fontSize = font.getSize();

      // 如果没有设置背景,则绘制
      if (bgTexture == null) {
        g.setColor(this.listColor);
        g.fillRect(x, y, getWidth(), getHeight());
        g.setColor(255, 255, 255);
        g.drawRect(x, y, getWidth(), getHeight());
      } else {
        g.draw(bgTexture, x, y, getWidth(), getHeight());
      }

      this.drawNum = ((getHeight() - 10) / fontSize);
      this.loop = 0;
      this.selectList = -1;

      for (int i = this.scrollList; i < this.drawNum + this.scrollList; i++) {
        if (i >= this.num) break;
        this.drawX = (x + 5);
        this.drawY = (y + 5 + this.loop * fontSize);

        if (!this.scrollBarDrag) {
          if ((mouseY > this.drawY)
              && (mouseY <= this.drawY + fontSize)
              && (mouseX > this.drawX)
              && (mouseX < this.drawX + getWidth())) {
            this.selectList = i;
          }
        }

        // 计算是否选中当前行
        if (!this.lengthCheck[i]) {
          this.lengthCheck[i] = true;
          if (this.name[i] != null) {
            while (font.stringWidth(this.name[i]) > getWidth()) {
              this.name[i] = this.name[i].substring(0, this.name[i].length() - 1);
            }
          }
        }

        if ((this.selectList == i) || ((this.useHold) && (this.hold == i))) {
          if ((this.useHold) && (this.hold == i)) {
            g.setColor(255, 255, 0);
            g.fillRect(x + 1, this.drawY, getWidth() - 1, fontSize);
            g.setColor(LColor.black);
            drawString(g, this.name[i], this.drawX, this.drawY);
            this.hold = -1;
          }
          // 选中指定列时
          if (this.selectList == i) {
            if (choiceTexture == null) {
              g.setColor(this.choiceStringBoxColor);
              g.fillRect(x + 1, this.drawY, getWidth() - 2, fontSize + 2);
            } else {
              g.draw(this.choiceTexture, x + 2, this.drawY, getWidth() - 2, fontSize + 2);
            }
            g.setColor(this.choiceStringColor);
            drawString(g, this.name[i], this.drawX, this.drawY);
          }
        } else {
          g.setColor(this.color[i]);
          drawString(g, this.name[i], this.drawX, this.drawY);
        }

        this.loop += 1;
      }

      this.scrollBarX = (x + getWidth() + 1);

      this.scrollBarHeight_max = (getHeight() - this.scrollButtonHeight * 2);

      if ((this.drawNum < this.num) && (this.drawNum > 0)) {
        this.scrollBarHeight = (this.scrollBarHeight_max / this.num / this.drawNum);
        this.scrollBarHeight = (this.scrollBarHeight_max * this.drawNum / this.num);
        if (this.scrollBarHeight < 8) this.scrollBarHeight = 8;

        this.scrollBarY = (y + this.scrollButtonHeight + 1);
        this.scrollBarY +=
            (this.scrollBarHeight_max - this.scrollBarHeight)
                * this.scrollList
                / (this.num - this.drawNum);
      } else {
        this.scrollBarHeight = this.scrollBarHeight_max;
        this.scrollBarY = (y + this.scrollButtonHeight + 1);
      }

      if (this.scrollBarDrag) {
        if (mouseY < this.scrollBarY + this.scrollBarHeight / 3) {
          for (int i = 0; i < 5; i++) {
            if (this.scrollList <= 0) break;
            this.scrollList -= 1;
          }
        }

        if (mouseY > this.scrollBarY + this.scrollBarHeight * 2 / 3) {
          for (int i = 0; i < 5; i++) {
            if (this.scrollList >= this.num - this.drawNum) break;
            this.scrollList += 1;
          }
        }
      }

      if (SysTouch.isDrag()) {
        if ((mouseX > this.scrollBarX)
            && (mouseX <= this.scrollBarX + this.scrollButtonWidth)
            && (mouseY > y + this.scrollButtonHeight)
            && (mouseY < y + getHeight() - this.scrollButtonHeight)) {
          this.scrollBarDrag = true;
        }
      } else {
        this.scrollBarDrag = false;
      }

      if (scrollTexture == null) {
        if (this.scrollBarDrag) {
          g.setColor(0, 255, 255);
        } else {
          g.setColor(255, 255, 255);
        }
        g.fillRect(this.scrollBarX, this.scrollBarY, this.scrollButtonWidth, this.scrollBarHeight);
      } else {
        g.draw(
            this.scrollTexture,
            this.scrollBarX,
            this.scrollBarY,
            this.scrollButtonWidth,
            this.scrollBarHeight);
      }

      this.scrollButtonX = (x + getWidth());
      this.scrollButtonY = y;

      if (scrollFlagATexture == null) {
        if (this.scrollUpButtonON) {
          g.setColor(LColor.gray);
        } else {
          g.setColor(LColor.black);
        }
        g.fillRect(
            this.scrollButtonX + 1,
            this.scrollButtonY + 1,
            this.scrollButtonWidth,
            this.scrollButtonHeight);
        g.setColor(255, 255, 255);
        this.px[0] = (this.scrollButtonX + 1 + this.scrollButtonWidth / 6);
        this.px[1] = (this.scrollButtonX + 1 + this.scrollButtonWidth / 2);
        this.px[2] = (this.scrollButtonX + 1 + this.scrollButtonWidth * 5 / 6);
        this.py[0] = (this.scrollButtonY + 1 + this.scrollButtonHeight * 5 / 6);
        this.py[1] = (this.scrollButtonY + 1 + this.scrollButtonHeight / 6);
        this.py[2] = (this.scrollButtonY + 1 + this.scrollButtonHeight * 5 / 6);
        g.fillPolygon(this.px, this.py, 3);
      } else {
        g.draw(
            this.scrollFlagATexture,
            this.scrollButtonX + 1,
            this.scrollButtonY + 1,
            this.scrollButtonWidth - 1,
            this.scrollButtonHeight - 1);
      }

      this.scrollUpButtonON = false;
      if ((!this.scrollBarDrag)
          && isFocusable()
          && (mouseX > this.scrollButtonX)
          && (mouseX <= this.scrollButtonX + this.scrollButtonWidth)
          && (mouseY > this.scrollButtonY)
          && (mouseY < this.scrollButtonY + this.scrollButtonHeight)) {
        if (this.scrollList > 0) {
          this.scrollList -= 1;
        }
        this.scrollUpButtonON = true;
      }
      this.scrollButtonX = (x + getWidth());
      this.scrollButtonY = (y + getHeight() - this.scrollButtonHeight);
      this.scrollDownButtonON = false;
      if ((!this.scrollBarDrag)
          && isFocusable()
          && (mouseX > this.scrollButtonX)
          && (mouseX <= this.scrollButtonX + this.scrollButtonWidth)
          && (mouseY > this.scrollButtonY)
          && (mouseY < this.scrollButtonY + this.scrollButtonHeight)) {
        if (this.scrollList < this.num - this.drawNum) {
          this.scrollList += 1;
        }
        this.scrollDownButtonON = true;
      }
      if (scrollFlagBTexture == null) {
        if (this.scrollDownButtonON) {
          g.setColor(LColor.gray);
        } else {
          g.setColor(LColor.black);
        }
        g.fillRect(
            this.scrollButtonX + 1,
            this.scrollButtonY - 1,
            this.scrollButtonWidth,
            this.scrollButtonHeight);
        g.setColor(LColor.white);
        this.px[0] = (this.scrollButtonX + 1 + this.scrollButtonWidth / 6);
        this.px[1] = (this.scrollButtonX + 1 + this.scrollButtonWidth / 2);
        this.px[2] = (this.scrollButtonX + 1 + this.scrollButtonWidth * 5 / 6);
        this.py[0] = (this.scrollButtonY - 1 + this.scrollButtonHeight / 6);
        this.py[1] = (this.scrollButtonY - 1 + this.scrollButtonHeight * 5 / 6);
        this.py[2] = (this.scrollButtonY - 1 + this.scrollButtonHeight / 6);
        g.fillPolygon(this.px, this.py, 3);
      } else {
        g.draw(
            this.scrollFlagBTexture,
            this.scrollButtonX + 1,
            this.scrollButtonY + 1,
            this.scrollButtonWidth - 1,
            this.scrollButtonHeight - 1);
      }
      g.setFont(oldFont);
      g.setColor(oldColor);
    }
  }