?? panel.java
字號:
/********************************************************************
*
* 版權說明,此程序僅供學習參考。不能用于商業
*
********************************************************************/
package org.pook.ui.form;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import org.pook.log.Log;
import org.pook.ui.Command;
import org.pook.ui.Part;
import org.pook.ui.SoftButton;
import org.pook.ui.core.Platform;
import org.pook.ui.event.CommandListener;
import org.pook.ui.event.PartChangeListener;
/**
* <b>類名:Panel.java</b> </br> 編寫日期: 2006-9-15 <br/> 程序功能描述?? <br/> Demo: <br/>
* Bug: <br/>
*
* 程序變更日期 ??<br/> 變更作??? ??<br/> 變更說明 ??<br/>
*
* @author wuhua </br> <a href="mailto:rrq12345@163.com">rrq12345@163.com</a>
*/
public abstract class Panel extends Canvas {
private static Log log = Log.getLog("Panel");
final int X = 0;
final int Y = 1;
final int WIDTH = 2;
final int HEIGHT = 3;
/** 顯示主要部分.比如菜單的Icon,List的數據的位置 */
int[] viewContent = new int[4];
Image icon;
Part part;
SoftButton softButton;
Part timer;
public Panel(){
init();
}
public Panel(Image icon) {
init();
this.icon = icon;
//此方法是讓所以的Panel都添加一個TimerPart
//以后重構的時候應該???慮要不要這么做
//this.setTimer(null);
}
private void init() {
setFullScreenMode(true);
initViewContent();
this.softButton = new SoftButton();
}
public void addCommand(Command cmd) {
if (cmd == null)
return;
softButton.addCommand(cmd);
}
public Part getPart() {
return part;
}
public void append(Part part){
this.part = part;
}
public void setPartChangeListener(PartChangeListener partChangeListener) {
this.part.setPartChangeListener(partChangeListener);
}
public void removeCommand(int type) {
softButton.removeCommand(type);
}
public void setSoftButtonListener(CommandListener cmdListener) {
if (softButton != null)
softButton.setCommandListener(cmdListener);
}
public void setSoftButtonStyle(int bgColor, int fontColor){
this.softButton.setStyle(bgColor, fontColor);
}
public abstract void paint(Graphics g);
protected abstract void keyPressed(int keyCode);
/**
* 長按事件
*/
protected void keyRepeated(int keyCode) {
keyPressed(keyCode);
}
private void initViewContent() {
viewContent[X] = 0;
viewContent[Y] = 45;
viewContent[WIDTH] = Platform.WIDTH;
viewContent[HEIGHT] = Platform.HEIGHT;
}
public SoftButton getSoftButton() {
return softButton;
}
public void setSoftButton(SoftButton softButton) {
this.softButton = softButton;
}
/**
* 增加時間顯示
*/
public void setTimer(Part timer){
this.timer = timer;
}
void paintTimerImpl(Graphics g){
if(timer != null)
timer.paint(g);
}
public void repaintTimer(){
if(timer != null){
int [] view = timer.getView();
repaint(view[X],view[Y],view[WIDTH], view[HEIGHT] );
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -