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

📄 win.java

📁 game for basketball. Midlet,support MIDP2.0
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
					}
				}
				return 1;
			}
			case 0x0106 :
				case 0x0105 :
				{
					repaintWin();
					if(0x0105 == msg)
					{
						x = param1;
						y = param2;
					}
					else
					{
						wid = param1;
						hgt = param2;
					}
					repaintWin();
					return 1;
				}
				case 0x0204 :
				{
					if(scrolling != 0)
					{
						if(scrolling < 9 && scrolling > 0)
							scrolling = 9;
						scrolly += scrolling;
						if(scrolly < 0 && scrolling < 0)
						{
							scrolly = 0;
							scrolling = 0;
						}
						if(scrolly + hgt > scrollhgt)
						{
							scrolly = scrollhgt - hgt;
							scrolling = 0;
						}
						if(!win.autoScroll)
						{
							scrolling = 0;
						}
						repaintWin();
					}
					return 0;
				}
				case 0x0202 :
				{
					if(1 != scrolling)
						scrolling = 0;
					if(!ready || !CurState)
						return 0;
				}
				case 0x0206 :
				{
					if(!ready || 0 ==(style & 0x0100))
						return 0;
					CurState = false;
					if(null != parent)
						parent.message(0x0109, ID, CurState ? 1 : 0);
					return 1;
				}
				case 0x0201 :
				{
					if(scrollhgt > hgt)
					{
						if(param1 == Canvas.UP || param2 == Canvas.KEY_NUM2)
						{
							scrolling = -foreFont.getHeight();
							message(0x0204, 0, 0);
							return 1;
						}
						else if(param1 == Canvas.DOWN || param2 == Canvas.KEY_NUM8)
						{
							scrolling = foreFont.getHeight();
							message(0x0204, 0, 0);
							return 1;
						}
					}
					if(!ready || 0 ==(style & 0x0100)||
						(param1 != Canvas.FIRE && param2 != Canvas.KEY_NUM5))
						return 0;
					CurState = true;
					return 1;
				}
		}
		return 0;
	}
	static public win setFocus(win win)
	{
		if(win == focusWin)
			return focusWin;
		if(null != focusWin)
		{
			oldFocusList.removeElement(focusWin);
			oldFocusList.push(focusWin);
			focusWin.message(0x0103, 0, 0);
		}
		win old = focusWin;
		focusWin = win;
		focusWin.message(0x0102, 0, 0);
		return old;
	}
	static public win getFocus()
	{
		return focusWin;
	}
	static public void releaseFocus(win win)
	{
		if(win != focusWin)
			return;
		focusWin.message(0x0103, 0, 0);
		if(oldFocusList.empty())
			focusWin = null;
		else
		{
			focusWin =(win)oldFocusList.pop();
			focusWin.message(0x0102, 0, 0);
		}
		return;
	}
	static public int sendMessage(win win, int msg, int param1, int param2)
	{
		try
		{
			if(null == win)
			{
				if(null != focusWin)
					win = focusWin;
			}
			if(null != win)
			{
				return win.message(msg, param1, param2);
			}
		}
		catch(RuntimeException e)
		{
		}
		return 0;
	}
	static public void setFontFileAndStats(String _name, int w, int h, int k, byte sizes[],
	String _bold, int wb, int hb, int kb, byte sizesb[])
	{
		fontFile = _name;
		fontFileB = _bold;
		fontWidth = w;
		fontWidthB = wb;
		fontHeight = h;
		fontHeightB = hb;
		fontKern = k;
		fontKernB = kb;
		fontSizes = sizes;
		fontSizesB = sizesb;
		return;
	}
	static public bhFont getColoredFont(int fore, boolean bold)
	{
		if((bold && null == fontFileB)||
			(!bold && null == fontFile))
			return null;
		Vector list;
		if(bold)
			list = fontListB;
		else
			list = fontList;
		for(Enumeration e = list.elements(); e.hasMoreElements();)
		{
			bhFont test =(bhFont)e.nextElement();
			if(test.isColor(fore))
				return test;
		}
		bhFont nFont;
		if(bold)
			nFont = new bhFont(fontFileB, fontWidthB, fontHeightB, fontKernB, fontSizesB, fore);
		else
			nFont = new bhFont(fontFile, fontWidth, fontHeight, fontKern, fontSizes, fore);
		list.addElement((Object)nFont);
		return nFont;
	}
	static public void deleteFonts()
	{
		while(!fontList.isEmpty())
		{
			bhFont fnt =(bhFont)fontList.firstElement();
			fontList.removeElement(fnt);
		}
		while(!fontListB.isEmpty())
		{
			bhFont fnt =(bhFont)fontListB.firstElement();
			fontListB.removeElement(fnt);
		}
		return;
	}
	private static ByteArrayInputStream in;
	private static DataInputStream fin;
	public DataInputStream OpenResourceFile(String name, String resource)
	{
		in = null;
		fin = null;
		in = new ByteArrayInputStream(Basketball.m_pRsgBuf);
		fin = new DataInputStream(in);
		if(fin == null)
			return null;
		try
		{
			fin.skipBytes(32);
			long Version = fin.readInt();
			if(0x10000000 != Version)
				return null;
			String res_name;
			long pos, cpos;
			cpos = 32 + 4;
			do
			{
				res_name = fin.readUTF();
				pos = fin.readInt();
				cpos +=(4 + 2 + res_name.length());
				if(0 == resource.compareTo(res_name))
				{
					fin.skipBytes((int)(pos - cpos));
					return fin;
				}
			} while(0 != res_name.length());
			fin.close();
			in.close();
			fin = null;
			in = null;
		}
		catch(java.io.IOException e)
		{
			return null;
		}
		return null;
	}
	private int strCount;
	private int strIDs[];
	private String strings[];
	win(String name, String resource)
	{
		loadStringTable(name, resource);
		parent = null;
		return;
	}
	public static void Touch()
	{
	}
	private void loadStringTable(String name, String resource)
	{
		long Version;
		DataInputStream In;
		if(null !=(In = OpenResourceFile(name, resource)))
		{
			try
			{
				strCount = In.readInt();
				Basketball.myCanvas.maxProgress = strCount;
				if(strCount < 1000)
				{
					strings = new String[strCount];
					strIDs = new int[strCount];
					for(int i = 0; i < strCount; i++)
					{
						strIDs[i]= In.readInt();
						strings[i]= In.readUTF();
						Basketball.myCanvas.incrementProgress();
						if(null == strings[i])
						{
							strCount = i;
							break;
						}
					}
				}
				else
					strCount = 0;
			}
			catch(java.io.IOException e)
			{
				strCount = 0;
				strIDs = null;
				strings = null;
				return;
			}
		}
		else
		{
			strCount = 0;
			strIDs = null;
			strings = null;
		}
		try {
				In.close();
			In = null;
			System.gc();
		}
		catch(Exception ex){
				ex.printStackTrace();
		}
		Basketball.myCanvas.progress = 0;
		return;
	}
	public String getString(int ID)
	{
		int CurMin = 0;
		int Probe;
		int ElemCnt = strCount;
		int i;
		while(ElemCnt > 0)
		{
			i = ElemCnt >> 1;
			Probe = CurMin + i;
			if(ID == strIDs[Probe])
				return strings[Probe];
			else if(ID < strIDs[Probe])
				ElemCnt = i;
			else
			{
				CurMin = Probe + 1;
				ElemCnt = ElemCnt - i - 1;
			}
		}
		return null;
	}
	private void changeCurrentControl(win newWin)
	{
		if(null != curControl)
			curControl.message(0x0103, 0, 0);
		curControl = newWin;
		if(null != curControl)
			curControl.message(0x0102, 0, 0);
		return;
	}
	private void arrowFocus(int deltaX, int deltaY)
	{
		if(null == curControl)
		{
			for(Enumeration e = childWinList.elements(); e.hasMoreElements();)
			{
				win cur =(win)e.nextElement();
				if(0 ==(cur.style &(0x8000 | 0x4000 | 0x1000)))
				{
					changeCurrentControl(cur);
					return;
				}
			}
			return;
		}
		else
		{
			int sx = curControl.x + deltaX * curControl.wid;
			int sy = curControl.y + deltaY * curControl.hgt;
			int MinDist = 0;
			int CurDist = 10000;
			if(0 != deltaX)
				MinDist = curControl.wid;
			else if(0 != deltaY)
				MinDist = curControl.hgt;
			int passes = 0;
			win hTmp, hClosest = null;
			do
			{
				Enumeration e = childWinList.elements();
				hTmp =(win)e.nextElement();
				while(hTmp != curControl)
					hTmp =(win)e.nextElement();
				do
				{
					if(!e.hasMoreElements())
						e = childWinList.elements();
					hTmp =(win)e.nextElement();
					if(hTmp == curControl)
						break;
					if(null != hTmp)
					{
						if(0 ==(hTmp.style &(0x8000 | 0x4000 | 0x1000)))
						{
							int dist = 0;
							boolean dirOK = false;
							if(0 != deltaX)
							{
								dist = hTmp.x - sx;
								if((dist < 0 && deltaX < 0)||
									(dist > 0 && deltaX > 0))
								{
									dirOK = true;
								}
								dist = Math.abs(dist);
								if(passes < 2)
									dist += Math.abs(hTmp.y - sy);
							}
							if(0 != deltaY)
							{
								int tmp = hTmp.y - sy;
								if((tmp < 0 && deltaY < 0)||
									(tmp > 0 && deltaY > 0))
								{
									dirOK = true;
								}
								dist += Math.abs(tmp);
								if(passes < 2)
									dist += Math.abs(hTmp.x - sx);
							}
							if((dist < MinDist)||
								(dirOK && dist < CurDist))
							{
								hClosest = hTmp;
								if(MinDist > dist)
									MinDist = dist;
								CurDist = dist;
							}
						}
					}
				} while(null != hTmp);
				if(null == hClosest)
				{
					if(0 == passes)
					{
						if(deltaX > 0)
							sx = 0;
						else if(0 == deltaX)
							sx = Basketball.myCanvas.getWidth()/ 2;
						else
							sx = Basketball.myCanvas.getWidth();
						if(deltaY > 0)
							sy = 0;
						else if(0 == deltaY)
							sx = Basketball.myCanvas.getHeight()/ 2;
						else
							sy = Basketball.myCanvas.getHeight();
						passes++;
					}
					else if(1 == passes)
					{
						MinDist = 10000;
						passes++;
					}
					else
						break;
				}
			} while(null == hClosest);
			if(null != hClosest)
			{
				changeCurrentControl(hClosest);
			}
		}
	}
	public void startDialog()
	{
		if(null == childWinList)
			return;
		scrollable = null;
		curControl = null;
		for(Enumeration e = childWinList.elements(); e.hasMoreElements();)
		{
			win cur =(win)e.nextElement();
			cur.message(0x0107, 0, 0);
			if(null == curControl && 0 ==(cur.style &(0x8000 | 0x4000 | 0x1000)))
				curControl = cur;
			if(0x0004 ==(0x0004 & cur.style))
				scrollable = cur;
		}
		if(null == curControl)
			curControl = scrollable;
		message(0x0107, 0, 0);
		setFocus(this);
		ready = true;
		repaintWin();
		return;
	}
	public void endDialog()
	{
		ready = false;
		if(null != curControl)
		{
			curControl.message(0x0103, 0, 0);
			curControl = null;
		}
		message(0x0108, 0, 0);

⌨️ 快捷键说明

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