?? dialog.java
字號:
/********************************************************************
*
* 版權說明,此程序僅供學習參考。不能用于商業
*
********************************************************************/
package org.pook.ui.form;
import java.util.TimerTask;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import org.pook.log.Log;
import org.pook.ui.Command;
import org.pook.ui.SoftButton;
import org.pook.ui.core.Platform;
import org.pook.ui.event.CommandListener;
import org.pook.ui.timer.TimerTaskManager;
/**
* <b>類名:Dialog.java</b> </br> 編寫日期: 2006-9-16 <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 Dialog extends Canvas implements Runnable {
private static Log log = Log.getLog("Dialog");
protected final int X = 0;
protected final int Y = 1;
protected final int WIDTH = 2;
protected final int HEIGHT = 3;
/** 顯示主要部分.比如菜單的Icon,List的數據的位置 */
protected int[] view = new int[4];
/** Preset alternative containing OK */
public static final int DIALOG_OK = 0;
/** Preset alternative containing CANCEL = 1 */
public static final int DIALOG_CANCEL = 2;
/** Preset alternatives containing YES and NO */
public static final int DIALOG_YES_NO = 3;
/** Preset alternatives containing OK and CANCEL */
public static final int DIALOG_OK_CANCEL = 4;
/** Preset alternatives containing YES, NO, and CANCEL */
public static final int DIALOG_YES_NO_CANCEL = 5;
public static final int DIALOG_TEXT = 6;
/**
* 保存當前窗口,主要用???是,當前對話筐消失的時???,要求重繪??. 永遠刷新父類
*/
protected Panel parent;
protected boolean hasFocus;
/**
* 定義超時參數
*/
long timeOut;
/**
* 對話框類??
*/
int type;
/** 對話框標?? */
protected String title;
/**
* 把單行標題轉換為多行以方便顯??
*/
protected String[] rowTitle;
protected int bgColor;
protected int fontColor;
protected Font font = Font.getDefaultFont();
/** 用于執行消失窗口 */
protected TimerTask task;
protected Display display;
protected SoftButton softButton;
/**
* 構???一個默認的標題,父類的窗??
*
* @param title
* @param parent
*/
public Dialog(String title, Panel parent, Display display) {
this(title, parent, display, 3000);
}
/**
* 構???一個指定時間的構???窗??
*
* @param title
* @param parent
* @param timeOut
*/
public Dialog(String title, Panel parent, Display display, long timeOut) {
this(title, parent, display, Dialog.DIALOG_OK, timeOut);
}
/**
* 構???一個指定窗口類??,時間的窗??
*
* @param title
* @param parent
* @param type
* @param timeOut
*/
public Dialog(String title, Panel parent, Display display, int type,
long timeOut) {
setFullScreenMode(true);
this.parent = parent;
checkParent();
this.timeOut = timeOut;
this.type = type;
this.title = title;
this.display = display;
softButton = new SoftButton();
if (timeOut != 0)
task = TimerTaskManager.getInstace().add(this, timeOut);
//設置默認的風??
setStyle(0x0033FF, 0xFFFFFF);
}
public void setStyle(int bgColor, int fontColor) {
this.bgColor = bgColor;
this.fontColor = fontColor;
}
public void cancel() {
//log.debug("Stop...");
if (parent == null)
throw new NullPointerException("Parent is not Null.");
task.cancel();
if(parent == null)
return;
display.setCurrent(parent);
}
public void addCommand(Command cmd) {
this.softButton.addCommand(cmd);
}
public void setSoftButtonListener(CommandListener cml) {
this.softButton.setCommandListener(cml);
}
public void setSoftButtonStyle(int bgColor, int fontColor){
this.softButton.setStyle(bgColor, fontColor);
}
public void run() {
cancel();
}
/** 繪制透明?? * */
public void drawRGB(Graphics g) {
int ai[] = new int[Platform.WIDTH];
for (int j1 = 0; j1 < ai.length; j1++)
ai[j1] = 0x90000000;
g.drawRGB(ai, 0, 0, 0, 0, Platform.WIDTH, Platform.HEIGHT, true); // 繪制透明景色
}
private void checkParent() {
if (parent == null){
throw new NullPointerException("Parent is not null");
}
}
protected void keyPressed(int keyCode) {
softButton.onClick(keyCode);
}
public void setPanel(Panel panel) {
this.parent = panel;
}
public void setTimeOut(long timeOut) {
this.timeOut = timeOut;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -