📄 emview.java
字号:
// Decompiled by DJ v2.9.9.60 Copyright 2000 Atanas Neshkov Date: 2005-4-3 23:27:55
// Home Page : http://members.fortunecity.com/neshkov/dj.html - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name: EMView.java
package NBMaJiang;
import com.nokia.mid.ui.FullCanvas;
import java.util.Vector;
import javax.microedition.lcdui.*;
// Referenced classes of package NBMaJiang:
// Action, ActionListener
public class EMView extends FullCanvas
{
public EMView(String title)
{
infos = new Vector();
width = getWidth();
height = getHeight();
smallFont = Font.getFont(0, 0, 8);
try
{
bgImg = Image.createImage("/NBMaJiang/images/bgImage.png");
arrowbackImg = Image.createImage("/NBMaJiang/images/arrowBack.png");
}
catch(Exception e) { }
okAction = new Action("\u8FD4\u56DE", 6, 1);
curIndex = 0;
needRollBar = false;
lineH = smallFont.getHeight() + 5;
maxLine = (height - 35) / lineH;
this.title = title;
}
public void setActionListener(ActionListener actListener)
{
actionListener = actListener;
}
public void setTitle(String value)
{
title = value;
}
protected void paint(Graphics g)
{
g.drawImage(bgImg, 0, 0, 0x10 | 4);
int tX = 5;
g.setFont(smallFont);
if(infos.size() > maxLine)
needRollBar = true;
int endIndex = infos.size() <= curIndex + maxLine ? infos.size() : curIndex + maxLine;
g.setColor(0);
if(!title.equals(""))
g.drawString(title, width / 2, 8, 0x10 | 1);
for(int i = curIndex; i < endIndex; i++)
{
int tY = ((i + 1) - curIndex) * lineH + 5;
g.drawString((String)infos.elementAt(i), tX, tY, 0x10 | 4);
}
g.setClip(width - 27, height - 38, 18, 30);
g.drawImage(arrowbackImg, width - 27, height - 38, 0x10 | 4);
if(needRollBar)
drawRollBar(g);
}
private void drawRollBar(Graphics g)
{
int numRec = infos.size() / maxLine + 1;
g.setColor(0);
g.drawRoundRect(width - 10, 20, 6, height - 40, 5, 5);
int curRec = infos.size() % (curIndex + 1);
g.setColor(0x922633);
int recH = (height - 40) / (infos.size() + 1);
g.fillRoundRect(width - 10, 20 + curIndex * recH, 6, recH, 5, 5);
}
public void clear()
{
infos.removeAllElements();
}
public void addInfos(String info)
{
infos.addElement(info);
}
protected void keyPressed(int keyCode)
{
if(keyCode == -7)
{
if(actionListener != null && okAction != null)
actionListener.action(okAction, this);
return;
}
if(!needRollBar)
return;
int action = getGameAction(keyCode);
switch(action)
{
default:
break;
case 1: // '\001'
curIndex--;
if(curIndex < 0)
curIndex = 0;
break;
case 6: // '\006'
curIndex++;
if(curIndex > infos.size())
curIndex = infos.size();
break;
}
repaint();
}
private Font smallFont;
private int width;
private int height;
private ActionListener actionListener;
private Vector infos;
private Action okAction;
private int curIndex;
private String title;
private boolean needRollBar;
private int lineH;
private int maxLine;
private Image bgImg;
private Image arrowbackImg;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -