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); }
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; } } } }
public void __setStatus(String resource, int priority, byte index, String statusText) { if (StatusInfo.STATUS_OFFLINE == index) { resource = StringUtils.notNull(resource); if (resource.equals(currentResource)) { currentResource = null; } removeSubContact(resource); if (0 == subContacts.size()) { setOfflineStatus(); } } else { SubContact c = getSubContact(resource); c.priority = (byte) Math.min(127, Math.max(priority, -127)); c.status = index; c.statusText = statusText; } }
private void setCurrItem(int cItem) { currItem = Math.max(0, Math.min(cItem, getSize() - 1)); }
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); } }
public final void setTopByOffset(int offset) { offset = Math.max(0, Math.min(offset, getFullSize() - getContentHeight())); int top = getItemByOffset(offset); setTop(top, offset - getOffset(top)); }