⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 virtuallist.java.svn-base

📁 类似QQ的功能
💻 SVN-BASE
📖 第 1 页 / 共 5 页
字号:
		catch (Exception e) {}		return KEY_CODE_UNKNOWN;	}	protected void keyPressed(int keyCode)	{		doKeyreaction(keyCode, KEY_PRESSED);	}		private CommandListener commandListener;	public void setCommandListener(CommandListener l)	{		commandListener = l;		if (isActive()) virtualCanvas.setCommandListener(commandListener);	}		protected boolean executeCommand(Command command)	{		if ((commandListener != null) && (command != null))		{			commandListener.commandAction(command, null);			return true;		}		return false;	}	protected void keyRepeated(int keyCode)	{		doKeyreaction(keyCode, KEY_REPEATED);	}	protected void keyReleased(int keyCode)	{		doKeyreaction(keyCode, KEY_RELEASED);	}	//#sijapp cond.if target is "MIDP2"#	private static long lastPointerTime = 0;	private static int lastPointerYCrd = -1;	private static int lastPointerXCrd = -1;	private static int lastPointerTopItem = -1;	protected void pointerDragged(int x, int y)	{		if (lastPointerTopItem == -1) return;		int height = getHeightInternal() - getCapHeight();		int itemCount = getSize();		int visCount = getVisCount();		if (itemCount == visCount) return;		storelastItemIndexes();		topItem = lastPointerTopItem + (itemCount) * (y - lastPointerYCrd) / height;		if (topItem < 0) topItem = 0;		if (topItem > (itemCount - visCount)) topItem = itemCount - visCount;		repaintIfLastIndexesChanged();	}	protected boolean pointerPressedOnUtem(int index, int x, int y, int mode)	{		return false;	}	protected void pointerPressed(int x, int y)	{		// is pointing on scroller		if (x >= (getWidthInternal() - 3 * scrollerWidth))		{			if ((srcollerY1 <= y) && (y < srcollerY2))			{				lastPointerYCrd = y;				lastPointerTopItem = topItem;				return;			}		}		lastPointerTopItem = -1;				int mode = DMS_CLICK;		long time = System.currentTimeMillis();				if (((time - lastPointerTime) < 500) && 				(Math.abs(x - lastPointerXCrd) < 10) && 				(Math.abs(y - lastPointerYCrd) < 10)) mode = DMS_DBLCLICK;				if (bDIimage == null) bDIimage = Image.createImage(getWidthInternal(), getHeightInternal());		paintAllOnGraphics(bDIimage.getGraphics(), mode, x, y);				lastPointerXCrd = x;		lastPointerYCrd = y;		lastPointerTime = time;	}		protected void pointerReleased(int x, int y)	{			}	//#sijapp cond.end#		static public void setBottomText(String text)	{		if ((bottomText != null) && bottomText.equals(text)) return;		bottomText = text;		if ((virtualCanvas != null) && virtualCanvas.isShown()) virtualCanvas.repaint();	}	//! Set caption text for list	public void setCaption(String capt)	{		if ((caption != null) && (caption.equals(capt))) return;		caption = capt;//#sijapp cond.if target="MIDP2" | target="MOTOROLA" | target="SIEMENS2" | target="RIM"#		if (!fullScreen) invalidate(0, 0, getWidth(), getCapHeight());//#sijapp cond.else#		invalidate(0, 0, getWidth(), getCapHeight());//#sijapp cond.end#	}	public String getCaption()	{		return caption;	}	public void setTopItem(int index)	{		storelastItemIndexes();		currItem = topItem = index;		checkTopItem();		repaintIfLastIndexesChanged();	}	// public void setCurrentItem(int index)	public void setCurrentItem(int index)	{		storelastItemIndexes();		currItem = index;		checkTopItem();		repaintIfLastIndexesChanged();	}	// public int getCurrIndex()	public int getCurrIndex()	{		return currItem;	}	// Return height of caption in pixels	protected final int getCapHeight()	{		//#sijapp cond.if target is "MIDP2" | target is "MOTOROLA" | target is "SIEMENS2" | target="RIM"#		if (fullScreen) return curFrameWidth;		//#sijapp cond.end#		int capHeight = 0;		if (caption != null) capHeight = capAndMenuFont.getHeight() + 2;		if (capImages != null)		{			int imgHeight = capImagesHeight + 2;			if (imgHeight > capHeight) capHeight = imgHeight;		}		return capHeight + 1;	}		protected void afterDrawCaption(Graphics g, int height) {}	// private int drawCaption(Graphics g)	protected int drawCaption(Graphics g, int mode, int curX, int curY)	{		if (caption == null) return 0;				if (mode != DMS_DRAW) return getCapHeight();				int width = getWidthInternal();				//#sijapp cond.if target is "MIDP2" | target is "MOTOROLA" | target is "SIEMENS2"#		if (fullScreen)		{			if (mode == DMS_DRAW)			{				g.setColor(bkgrndColor);				g.fillRect(0, 0, width, curFrameWidth);			}			return curFrameWidth;		}		//#sijapp cond.end#				g.setFont(capAndMenuFont);		int height = getCapHeight();		drawRect(g, capBkCOlor, transformColorLight(capBkCOlor, -64), 0, 0, width, height, 255);		g.setColor(transformColorLight(capBkCOlor, -128));		g.drawLine(0, height - 1, width, height - 1);		int x = 2+(capOffset*width-2)/100;		if (capImages != null)		{			for (int i = 0; i < capImages.length; i++)			{				Image img = capImages[i];				if (img == null) continue;				g.drawImage(img, x, (height - img.getHeight()) / 2, Graphics.TOP | Graphics.LEFT);				x += img.getWidth() + 1;			}		}		if (mpbEnable) {			int progressW = (width - x - 4);			int progressPx = (progressW - 2)  / 100 * mpbPercent;			if (progressPx > 0) {				g.setColor(0xffffff); g.fillRect(x, 2, progressW, height - 4);				g.setColor(0x00aa00); g.fillRect(x+1, 3, progressPx, height - 6);			}			if (mpbPercent > 99) {				mpbEnable = false;				mpbPercent = 0;			}		} else {			g.setColor(capTxtColor);			g.drawString(caption, x, (height - capAndMenuFont.getHeight()) / 2, Graphics.TOP | Graphics.LEFT);		}				//#sijapp cond.if modules_DEBUGLOG is "true"#		int ram=(int)((Runtime.getRuntime().freeMemory()*32)/Runtime.getRuntime().totalMemory());		g.setColor(0xffffff);  g.fillRect(width-54, 0, 34, 3);		g.setColor(0x00ff00);  g.fillRect(width-53, 1, ram, 2);		//#sijapp cond.end #		afterDrawCaption(g, height);				return height;	}	protected boolean isItemSelected(int index)	{		return ((currItem == index) && (cursorMode != CURSOR_MODE_DISABLED));	}	private static int srcollerY1 = -1;	private static int srcollerY2 = -1;	// Draw scroller is items doesn't fit in VL area 	private void drawScroller(Graphics g, int topY, int visCount, int menuBarHeight)	{		int width = getWidthInternal() - scrollerWidth;		int height = getHeightInternal()-menuBarHeight;		int itemCount = getSize();		boolean haveToShowScroller = ((itemCount > visCount) && (itemCount > 0));		int color = transformColorLight(bkgrndColor, -16);		if (color == 0) color = 0x808080;		g.setStrokeStyle(Graphics.SOLID);		g.setColor(color);		g.fillRect(width + 1, topY, scrollerWidth - 1, height - topY);		g.setColor(transformColorLight(color, -64));		g.drawLine(width, topY, width, height);		if (haveToShowScroller)		{			int sliderSize = (height - topY) * visCount / itemCount;			if (sliderSize < 7) sliderSize = 7;			srcollerY1 = topItem * (height - sliderSize - topY) / (itemCount - visCount) + topY;			srcollerY2 = srcollerY1 + sliderSize;			color = capBkCOlor;			g.setColor(color);			g.fillRect(width+1, srcollerY1+1, scrollerWidth-2, srcollerY2-srcollerY1-2);			g.setColor(mergeColors(color, 0, 70));			g.drawRect(width, srcollerY1, scrollerWidth - 1, srcollerY2 - srcollerY1 - 1);			g.setColor(transformColorLight(color, 96));			g.drawLine(width+1, srcollerY1+1, width+1, srcollerY2-3);			g.drawLine(width+1, srcollerY1+1, width+scrollerWidth-2, srcollerY1+1);		}	}//#sijapp cond.if target!="DEFAULT"#		private static int[] menuBarBackground;	private static int menuBarBackgroundColor1 = -1;	private static int menuBarBackgroundColor2 = -1;	private static int[] getMenuBarBackground(int width, int height, int color1, int color2)	{		if (color1 == menuBarBackgroundColor1 && color2 == menuBarBackgroundColor2 && menuBarBackground != null)			return menuBarBackground;		menuBarBackground = new int[height*width];				int r1 = ((color1 & 0xFF0000) >> 16);		int g1 = ((color1 & 0x00FF00) >> 8);		int b1 = (color1 & 0x0000FF);		int r2 = ((color2 & 0xFF0000) >> 16);		int g2 = ((color2 & 0x00FF00) >> 8);		int b2 = (color2 & 0x0000FF);				int width2 = width/2;		int width3 = width/3;		int idx = 0;		int r = 0;		int g = 0;		int b = 0;		int dist = 0;		int diff = 0;		int new_r = 0;		int new_g = 0;		int new_b = 0;		int color = 0;		for (int y = 0; y < height; y++)		{			r = y * (r2 - r1) / (height-1) + r1;			g = y * (g2 - g1) / (height-1) + g1;			b = y * (b2 - b1) / (height-1) + b1;						for (int x = 0; x < width; x++)			{				dist = x-width2;								if (dist < 0) dist = -dist;				dist = width3-dist;				if (dist < 0) dist = 0;				diff = 96*dist/width3;								new_r = r+diff;				new_g = g+diff;				new_b = b+diff;								if (new_r < 0) new_r = 0;				if (new_r > 255) new_r = 255;				if (new_g < 0) new_g = 0;				if (new_g > 255) new_g = 255;				if (new_b < 0) new_b = 0;				if (new_b > 255) new_b = 255;								color = (new_r << 16) | (new_g << 8) | (new_b);				menuBarBackground[idx++] = color;			}		}				menuBarBackgroundColor1 = color1;		menuBarBackgroundColor2 = color2;		return menuBarBackground;	}//#sijapp cond.end#		private static int[] alphaBuffer = null;	private static int lastRectHeight;	private static int lastRectColor1;	private static int lastRectColor2;			static public void drawRect(Graphics gr, int color1, int color2, int x1, int y1, int x2, int y2, int alpha)	{		int r1 = ((color1 & 0xFF0000) >> 16);		int g1 = ((color1 & 0x00FF00) >> 8);		int b1 = (color1 & 0x0000FF);		int r2 = ((color2 & 0xFF0000) >> 16);		int g2 = ((color2 & 0x00FF00) >> 8);		int b2 = (color2 & 0x0000FF);				if (alpha == 255)		{			int count = (y2-y1)/3;			if (count < 0) count = -count;			if (count < 8) count = 8;						y2++;			x2++;			int crd1 = 0;			int crd2 = 0;			for (int i = 0; i < count; i++)			{				crd1 = i * (y2 - y1) / count + y1;				crd2 = (i + 1) * (y2 - y1) / count + y1;				if (crd1 == crd2) continue;				gr.setColor(i * (r2 - r1) / (count-1) + r1, i * (g2 - g1) / (count-1) + g1, i * (b2 - b1) / (count-1) + b1);				gr.fillRect(x1, crd1, x2-x1, crd2-crd1);			}		}//#sijapp cond.if target!="DEFAULT"#				else		{			int alphaValue = alpha << 24;			int width = x2-x1;			int height = y2-y1;			if (width <= 0 || height <= 1) return; 						int spaceRequired = 32*height;			if (alphaBuffer == null || alphaBuffer.length < spaceRequired)			{				alphaBuffer = null;				alphaBuffer = new int[spaceRequired];			}						if (lastRectHeight != height || lastRectColor1 != color1 || lastRectColor2 != color2)			{				int idx = 0;				int crd1 = 0;				int crd2 = 0;				int r = 0;				int g = 0;				int b = 0;								int color = 0;				for (int y = 0; y < height; y++)				{					crd1 = y * (y2 - y1) / height;					crd2 = (y + 1) * (y2 - y1) / height;					if (crd1 == crd2) continue;										r = y * (r2 - r1) / (height-1) + r1;					g = y * (g2 - g1) / (height-1) + g1;					b = y * (b2 - b1) / (height-1) + b1;										color = (r << 16) | (g << 8) | (b) | (alphaValue);										for (int x = 0; x < 32; x++) alphaBuffer[idx++] = color;				}				lastRectHeight = height;				lastRectColor1 = color1;				lastRectColor2 = color2;			}						int totalWidth = width;			for (int x = x1; x < x2; x += 32)			{				gr.drawRGB(alphaBuffer, 0, 32, x, y1, (totalWidth > 32) ? 32 : totalWidth, height, true);				totalWidth -= 32;			}		}//#sijapp cond.end#			}		/**	 * @return Returns height of normal font (in pixels)	 */	public int getFontHeight()	{		return fontHeight;	}		protected void getCurXVals(int[] values)	{		values[0] = curFrameWidth+1;		values[1] = getWidthInternal() - scrollerWidth - curFrameWidth;	}	protected final boolean drawItems	(		Graphics g, 		int topY, 		int menuBarHeight, 		int mode, 		int mouseX, 		int mouseY, 		int clipY1, 		int clipY2	)	{		int height = getDrawHeight();		int size = getSize();		int i, y;		int itemWidth = getWidthInternal() - scrollerWidth;		int bottomY = topY+height;				if ((mode == DMS_DRAW) && (!crdIntersect(topY, bottomY, clipY1, clipY2))) return false;		// Draw items		paintedItem.clear();		y = topY;		int itemHeight = 0;		int x1 = 0;		int x2 = 0;		int y1 = 0;		int y2 = 0;		for (i = topItem; i < size; i++)		{			itemHeight = getItemHeight(i);			if (g != null) g.setStrokeStyle(Graphics.SOLID);						x1 = borderWidth;			x2 = itemWidth-2;			y1 = y;			y2 = y + itemHeight;			if ((mode == DMS_DRAW || mode == DMS_CUSTOM)/* && */)			{				if (crdIntersect(y1, y2, clipY1, clipY2))

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -