📄 view.java.svn-base
字号:
package org.gggeye.easymf.ui;
import java.util.Hashtable;
import javax.microedition.lcdui.Font;
/**
* 所有可视对象的超类。
* @author wuhua
* <a href="http://wuhua.3geye.net">我的博客</a>
*
*/
public abstract class View {
protected int top; //x
protected int left; //y
protected int right;
protected int buttom;
protected int width;
protected int height;
byte type; //q
Hashtable attr;
public String name;
protected String id;
protected String action;
protected String value;
protected String[] values;
protected String alt;
protected Font font = Panel.defaultFont;
protected int fontColor;
protected int backColor;
protected int index; // 控件在文档中的索引
protected boolean hasFocus;
//每一个元素都有一个连接
protected HyperLink hyperLink;
EventListener eventListener;
HtmlDocument htmlDocument;
public View() {
}
public void setTopPostion(int _height) {
this.top += _height;
this.buttom = top + height;
}
// Event event; //绑定事件
View(int fontColor, int backColor, Font font) {
this.fontColor = fontColor;
this.backColor = backColor;
this.font = font == null ? Panel.defaultFont : font;
}
void doClick(int _keyCode) {
//if (_keyCode == 8) {
if (eventListener != null)
eventListener.viewDoClick(_keyCode, this);
//}
this.subDoClick(_keyCode);
}
/**
* 需要传递事件到子对象的实现这个方法
* @param _keyCode
*/
void subDoClick(int _keyCode){
}
public abstract void doPaint(Pen _pen, HtmlDocument _document);
/**
* 判读此控件是否在屏幕范围内
* @param x int
* @param y int
* @return boolean
*/
boolean onSreenContent(byte _type, int _top, int _buttom) {
if (_type == Container.VIEW_MOVE_DOWN && top > _buttom - 10) {
return false;
} else if (_type == Container.VIEW_MOVE_UP
&& top < _top - this.height) {
return false;
} else
return true;
}
boolean inSreenContent(byte _type, int _top, int _buttom) {
if (_type == Container.VIEW_MOVE_DOWN && top > _top) {
return true;
} else if (_type == Container.VIEW_MOVE_UP && _buttom > top + width)
return true;
else
return false;
}
boolean nearScreenContent(int _top, int _buttom) {
if (_top > top - 40 || _buttom < this.buttom - 40) {
return false;
}
return true;
}
public final void addHyperLink(HyperLink _hyperLink) {
this.hyperLink = _hyperLink;
this.hasFocus = hyperLink != null;
}
public int getIndex() {
return this.index;
}
public String getName() {
return this.name;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -