📄 infolistcanvas.java
字号:
package inline.ui;
import inline.ui.*;
import inline.sys.*;
import java.util.*;
import javax.microedition.lcdui.*;
import inline.ui.le.*;
import inline.sys.*;
public class InfoListCanvas extends ListFormCanvas
{
private String text;
public InfoListCanvas(HostCanvas pprevious, String caption, String ttext)
{
super(pprevious, caption, Base.getText(0x0501),"");
text = ttext;
fillList(text);
}
private void fillList(String text)
{
Vector vct = new Vector();
int dw = list.getWidth();
if (dw == 0) return;
Font fn = list.getFont();
char[] ca = new char[text.length()];
text.getChars(0, text.length(), ca, 0);
int ls = 0; // line start position
int ps = 0; // ps - previous space position
for(int i=0;i<ca.length;i++)
{
if (ca[i] == ' ' || ca[i] == '/' || ca[i] == '\n')
{
int te = fn.charsWidth(ca, ls, i-ls);
if (te > dw)
{
String txx = new String(ca, ls, ps-ls).trim();
vct.addElement(new StringElement(txx));
ls = ps;
}
ps = i;
}
if (ca[i] == '\n')
{
String txx = new String(ca, ls, i-ls).trim();
vct.addElement(new StringElement(txx));
ps = i;
ls = i;
}
}
if (ls<ca.length)
{
String txx = new String(ca, ls, ca.length-ls).trim();
if (txx.length()>0) vct.addElement(new StringElement(txx));
}
list.setLines(vct);
}
protected void sizeChanged(int w, int h)
{
super.sizeChanged(w,h);
fillList(text);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -