Esempio n. 1
0
 private void moveCursor(int step) {
   int top = getTopOffset();
   int visible = getContentHeight();
   // #sijapp cond.if modules_TOUCH is "true"#
   if (touchUsed) {
     touchUsed = false;
     int curr = getCurrItem();
     int current = getOffset(curr);
     if ((current + getItemHeight(curr) < top) || (top + visible < current)) {
       int offset = (step < 0) ? (top + visible - 1) : (top + 1);
       setCurrentItemIndex(getItemByOffset(offset));
       return;
     }
   }
   // #sijapp cond.end#
   int next = getCurrItem() + step;
   if (VirtualList.MP_SELECTABLE_ONLY == getMovingPolicy()) {
     while (!isItemSelectable(next)) {
       next += step;
       if ((next < 0) || (getSize() <= next)) {
         break;
       }
     }
   }
   next = Math.max(-1, Math.min(next, getSize()));
   if (0 < step) {
     if (getSize() == next) {
       int end = getFullSize() - visible;
       if (top < end) {
         setTopByOffset(Math.min(end, top + visible / 3));
         return;
       }
     } else {
       int nextOffset = getOffset(next);
       if (top + visible < nextOffset) {
         setTopByOffset(top + visible / 3);
         return;
       }
     }
   } else {
     if (-1 == next) {
       if (0 < top) {
         setTopByOffset(Math.max(0, top - visible / 3));
         return;
       }
     } else {
       if (getOffset(next) + getItemHeight(next) < top) {
         setTopByOffset(top - visible / 3);
         return;
       }
     }
   }
   if ((next < 0) || (getSize() <= next)) {
     return;
   }
   setCurrentItemIndex(next);
 }
Esempio n. 2
0
 // #sijapp cond.if modules_TOUCH is "true"#
 protected void stylusXMoved(TouchState state) {
   if (getWidth() / 2 < Math.abs(state.fromX - state.x)) {
     boolean isTrue = state.fromX < state.x;
     int currentModel = 0;
     if (Options.getBoolean(Options.OPTION_CL_HIDE_OFFLINE)) currentModel = 1;
     if (((RosterContent) content).getModel() == getUpdater().getChatModel()) currentModel = 2;
     currentModel = (currentModel + 3 + (isTrue ? -1 : +1)) % 3;
     switch (currentModel) {
       case 0:
         Options.setBoolean(Options.OPTION_CL_HIDE_OFFLINE, false);
         updateOfflineStatus();
         Options.safeSave();
         break;
       case 1:
         Options.setBoolean(Options.OPTION_CL_HIDE_OFFLINE, true);
         updateOfflineStatus();
         Options.safeSave();
         break;
       case 2:
         ((RosterContent) content).setModel(getUpdater().getChatModel());
         break;
     }
     updateTitle();
     Jimm.getJimm().getCL().activate();
   }
 }
Esempio n. 3
0
  private void setOptimalTopItem() {
    int size = getSize();
    if (0 == size) {
      setTopByOffset(0);
      return;
    }
    int current = Math.max(0, getCurrItem());
    int top = get_Top();
    int topOffset = get_TopOffset();
    if (current <= top) {
      top = current;
      final int contentHeight = getContentHeight();
      int maxTopHeight = getOffset(size) - contentHeight;
      top = Math.min(top, getItemByOffset(maxTopHeight));
      setTop(top, Math.max(0, getItemHeight(top) - contentHeight));

    } else {
      top = Math.min(top, size - 1);
      int height;
      int offset = getContentHeight();
      for (int item = current; top <= item; --item) {
        height = getItemHeight(item);
        offset -= height;
        if (offset <= 0) {
          offset = -offset;
          if (item == current) {
            offset = 0;
          }
          if (item < top) {
          } else if ((item == top) && (offset < topOffset)) {
          } else {
            setTop(item, offset);
          }
          return;
        }
      }
    }
  }
Esempio n. 4
0
 private int getBottomVisibleItem() {
   int size = getSize();
   int cur = size;
   int offset = getContentHeight() + get_TopOffset();
   for (int i = get_Top(); i < size; ++i) {
     int height = getItemHeight(i);
     if (offset < height) {
       cur = i;
       break;
     }
     offset -= height;
   }
   cur = (size == cur) ? size - 1 : Math.max(get_Top(), cur - 1);
   return cur;
 }
Esempio n. 5
0
  private void drawBack(GraphicsEx g, int top, int width, int height) {
    // Fill background
    g.setThemeColor(CanvasEx.THEME_BACKGROUND);
    g.fillRect(0, top, width, height);

    g.setClip(0, top, width, height);
    if (null != Scheme.backImage) {
      int offset = 0;
      if (0 < getSize()) {
        offset =
            Math.max(0, Scheme.backImage.getHeight() - height) * getTopOffset() / getFullSize();
      }
      g.drawImage(Scheme.backImage, 0, top - offset, Graphics.LEFT | Graphics.TOP);
    }
  }
Esempio n. 6
0
 private void setCurrItem(int cItem) {
   currItem = Math.max(0, Math.min(cItem, getSize() - 1));
 }
Esempio n. 7
0
  private void drawItems(GraphicsEx g, int top_y, int itemWidth, int height) {
    int size = getSize();
    int bottom = height + top_y;

    if (0 == size) {
      drawEmptyItems(g, top_y);
      return;
    }

    boolean showCursor = false;
    int currentY = 0;
    int currentIndex = isCurrentItemSelectable() ? getCurrItem() : -1;
    // #sijapp cond.if modules_TOUCH is "true"#
    if (touchUsed && !touchPressed) currentIndex = -1;
    // #sijapp cond.end#

    { // background
      int offset = topOffset;
      int y = top_y;
      for (int i = topItem; i < size; ++i) {
        int itemHeight = getItemHeight(i);
        int realHeight = Math.min(itemHeight - offset, bottom - y + 1);
        g.setClip(0, y, itemWidth, realHeight + 1);
        g.setStrokeStyle(Graphics.SOLID);
        if (i == currentIndex) {
          currentY = y - offset;
          if (g.notEqualsColor(CanvasEx.THEME_BACKGROUND, CanvasEx.THEME_SELECTION_BACK)) {
            g.setThemeColor(CanvasEx.THEME_SELECTION_BACK);
            g.fillRect(0, currentY, itemWidth - 1, itemHeight);
          }
          drawItemBack(g, i, 2, y - offset, itemWidth - 4, itemHeight, offset, realHeight);
          showCursor = true;
        } else {
          drawItemBack(g, i, 2, y - offset, itemWidth - 4, itemHeight, offset, realHeight);
        }
        y += itemHeight - offset;
        if (y >= bottom) break;
        offset = 0;
      }
      if (0 < MyScrollBar.showScroll) {
        g.setClip(0, top_y, itemWidth, bottom - top_y);
        MyScrollBar.paint(g, this, CanvasEx.THEME_SCROLL_BACK);
      }
    }

    { // Draw items
      g.setColor(0);
      int offset = topOffset;
      int y = top_y;
      for (int i = topItem; i < size; ++i) {
        int itemHeight = getItemHeight(i);
        int realHeight = Math.min(itemHeight, bottom - y + 1);
        g.setClip(0, y, itemWidth, realHeight + 1);
        g.setStrokeStyle(Graphics.SOLID);
        drawItemData(g, i, 2, y - offset, itemWidth - 4, itemHeight, offset, realHeight);
        y += itemHeight - offset;
        if (y >= bottom) break;
        offset = 0;
      }
    }
    if (showCursor) {
      int itemHeight = getItemHeight(currentIndex);
      g.setClip(0, currentY, itemWidth, itemHeight + 1);
      g.setThemeColor(CanvasEx.THEME_SELECTION_RECT);
      g.setStrokeStyle(Graphics.SOLID);
      g.drawSimpleRect(0, currentY, itemWidth - 1, itemHeight);
    }
  }
Esempio n. 8
0
 public final void setTopByOffset(int offset) {
   offset = Math.max(0, Math.min(offset, getFullSize() - getContentHeight()));
   int top = getItemByOffset(offset);
   setTop(top, offset - getOffset(top));
 }