?? htmlselect.java
字號:
package org.gggeye.easymf.ui;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.List;
import org.gggeye.easymf.midlet.MIDletManager;
public class HtmlSelect extends View {
private SelectOptionGUI sgui;
int listType;
int selectIndex;
SelectOption[] selectOption;
String name;
String iValue;
/**
* label
*
* @param text
* @param values
* @param maxSize
*/
public HtmlSelect(String _name, String _value, String _iName,
String _iValue, int _listType) {
super(0xCEF, 0x0, null);
this.name = _name;
this.value = _value;
this.name = _iName;
this.iValue = _iValue;
listType = _listType;
this.hasFocus = true;
}
public void doClick(int keyCode) {
// if (keyCode == 8) {
openGUIFor();
// }
}
private void openGUIFor() {
sgui = new SelectOptionGUI(this.listType);
MIDletManager.show(sgui);
}
/**
* 發現實現多選是沒有意義的。
*
* @author fox
*
*/
class SelectOptionGUI extends List implements
javax.microedition.lcdui.CommandListener {
Command ok = new Command("確定", Command.OK, Command.OK);
Command cancel = new Command("取消", Command.CANCEL, Command.CANCEL);
public SelectOptionGUI(int listType) {
super("列表選擇", listType == 0 ? List.EXCLUSIVE : List.IMPLICIT);
this.addCommand(ok);
this.addCommand(cancel);
this.setCommandListener(this);
if (selectOption != null) {
for (int j = 0; j < selectOption.length; j++) {
append(selectOption[j].name, null);
}
}
}
public void commandAction(Command c, Displayable d) {
if (c.getPriority() == 0 || c == ok) {
selectIndex = sgui.getSelectedIndex();
}
MIDletManager.show(d);
}
}
public void doPaint(Pen point, HtmlDocument _htmlDocument) {
if (_htmlDocument.focusIndex == this.index) {
point.save();
point.setColor(backColor);
point.drawRects(left, top, width, height);
point.reset();
}
point.save();
point.setColor(0x0);
point.drawRect(left, top, width, height);
int w = 16;
int h = this.font.getHeight()>>2;
int s = left + width - w;
w = w>>2;
point.drawLine(s, top, s, buttom);
//繪制三角形
point.setColor(0x0);
s+=w;
point.fillTriangle(s , top + h, s+2*w, top + h, s+w, top + 3*h);
// point.fillTriangle(s + w << 1, top + height / 3, s + w << 2,
// top + height >> 2,
// s + (w << 2) * 3, top + height << 2);
try {
point.drawString(selectOption[this.selectIndex].name, left + 2, top,
20);
} catch (Exception e) {
// #if (debug == true)
e.printStackTrace();
// #endif
}
}
String getValue(){
return selectOption[this.selectIndex].value;
}
}
class SelectOption {
String name;
String value;
public SelectOption(String name, String value) {
this.name = name;
this.value = value;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -