📄 guigeneral.java
字号:
import java.util.Timer;
import java.util.TimerTask;
import java.util.Vector;
import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.AlertType;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Gauge;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.Item;
import javax.microedition.lcdui.ItemStateListener;
import javax.microedition.lcdui.List;
import javax.microedition.lcdui.Spacer;
import javax.microedition.lcdui.TextBox;
class GUIGeneral extends Form
implements CommandListener, ItemStateListener
{
private final byte PACK_KEYPRESS = 4;
private final byte PACK_KEYRELEASE = 5;
private final byte PACK_INTEGERINPUT = 6;
private final byte PACK_TEXTINPUT = 10;
private final byte PACK_SCREENPROPERTY = 12;
private static byte NUM0 = 0;
private static byte NUM1 = 1;
private static byte NUM2 = 2;
private static byte NUM3 = 3;
private static byte NUM4 = 4;
private static byte NUM5 = 5;
private static byte NUM6 = 6;
private static byte NUM7 = 7;
private static byte NUM8 = 8;
private static byte NUM9 = 9;
private static byte NUM_LEFT = 10;
private static byte NUM_RIGHT = 11;
private static byte NUM_UP = 12;
private static byte NUM_DOWN = 13;
private static byte NUM_FIRE = 15;
private static byte KEY_STAR = 16;
private static byte KEY_POUND = 17;
private static byte SHOW_MENU = 0;
private static byte SHOW_DIALOG = 1;
private static byte SHOW_IMAGE = 2;
private static byte SHOW_PERCENT_INPUT = 3;
private static byte SHOW_PROGRESS = 4;
private static byte SHOW_TEXT = 5;
private static byte SHOW_TEXT_INPUT = 6;
private static int SCREEN_SIZE_FULL = 0;
private static int SCREEN_SIZE_LIMITED = 1;
private final Command SCR_MAIN_BACK_CMD = new Command("Back", 2, 1);
private final Command SCR_MAIN_OK_CMD = new Command("OK", 4, 1);
private final byte TITLECANVAS_TEXT = 0;
private final byte TITLECANVAS_TEXT_IMAGE_NOTIYF = 1;
private final byte TITLECANVAS_IMAGE_UPDATE = 2;
private final byte TITLECANVAS_TEXT_UPDATE = 3;
private List menuList;
private final Alert textDialog = new Alert("", "", null, AlertType.INFO);
private Applications parent;
private BluetoothRemoteControl own;
public String mainTitle;
private Gauge percentInput;
private TextBox myInput;
private int stateDisplay;
private GUIGeneral.MyCanvas can;
private GUIGeneral.MyImageCanvas img;
private GUIGeneral.MyTitleCanvas tCan;
private Form bufferForm;
private int fullScreenSize;
private final int MAX_STRING_BUFFER = 1000;
private String[] stringBuffer = new String[1000];
private Displayable parentWin;
private int menuCount;
private static int MAX_MENU_ITEMS = 40;
private static byte DIRECTION_NO = 0;
private static byte DIRECTION_PREVIOUS = 1;
private static byte DIRECTION_NEXT = 2;
private Vector menuStore;
private boolean bold;
private boolean small;
private boolean large;
private boolean underlined;
private boolean left;
private boolean right;
private boolean space;
private int style;
private int size;
private boolean scroll;
public GUIGeneral(Applications paramApplications, BluetoothRemoteControl paramBluetoothRemoteControl, String paramString)
{
super("Bluetooth RC");
this.parent = paramApplications;
this.own = paramBluetoothRemoteControl;
this.mainTitle = paramString;
this.can = new GUIGeneral.MyCanvas(this);
this.img = new GUIGeneral.MyImageCanvas(this);
this.tCan = new GUIGeneral.MyTitleCanvas(this);
this.fullScreenSize = SCREEN_SIZE_LIMITED;
addCommand(this.SCR_MAIN_BACK_CMD);
addCommand(this.SCR_MAIN_OK_CMD);
setCommandListener(this);
setItemStateListener(this);
this.bufferForm = new Form("Bluetooth RC");
this.bufferForm.addCommand(this.SCR_MAIN_BACK_CMD);
this.bufferForm.addCommand(this.SCR_MAIN_OK_CMD);
this.bufferForm.setCommandListener(this);
this.bufferForm.setItemStateListener(this);
this.textDialog.addCommand(this.SCR_MAIN_BACK_CMD);
this.textDialog.setCommandListener(this);
Display localDisplay = Display.getDisplay(paramBluetoothRemoteControl);
int i = localDisplay.getColor(0);
int j = localDisplay.getColor(1);
int k = localDisplay.getColor(4);
this.can.setColor(i, j, k);
this.tCan.setColor(i, j, k);
this.img.setColor(i, j, k);
this.menuStore = new Vector();
this.menuCount = 0;
}
public void show()
{
Display.getDisplay(this.own).setCurrent(this);
}
public void showForm2()
{
Display.getDisplay(this.own).setCurrent(this.bufferForm);
}
private void showMenuList()
{
Display.getDisplay(this.own).setCurrent(this.menuList);
}
public void showTextBox()
{
Display.getDisplay(this.own).setCurrent(this.myInput);
}
public synchronized void execute(byte[] paramArrayOfByte, int paramInt)
{
setTitle(this.mainTitle);
try
{
switch (paramArrayOfByte[1])
{
case 2:
showMenu(paramArrayOfByte, paramInt, DIRECTION_NO);
break;
case 3:
showDialog(paramArrayOfByte, paramInt);
break;
case 4:
if (this.fullScreenSize == SCREEN_SIZE_FULL)
try
{
this.img.setFullScreenMode(false);
this.fullScreenSize = SCREEN_SIZE_LIMITED;
}
catch (Exception localException1)
{
this.fullScreenSize = SCREEN_SIZE_LIMITED;
}
catch (Error localError1)
{
this.fullScreenSize = SCREEN_SIZE_LIMITED;
}
showImage(paramArrayOfByte, paramInt);
break;
case 5:
showPercentInput(paramArrayOfByte, paramInt);
break;
case 6:
showProgress(paramArrayOfByte, paramInt);
break;
case 7:
showText(paramArrayOfByte, paramInt);
break;
case 8:
showTextInput(paramArrayOfByte, paramInt);
break;
case 9:
replayScreenProperty();
break;
case 12:
if (this.fullScreenSize == SCREEN_SIZE_LIMITED)
try
{
this.img.setFullScreenMode(true);
this.fullScreenSize = SCREEN_SIZE_FULL;
}
catch (Exception localException2)
{
this.fullScreenSize = SCREEN_SIZE_LIMITED;
}
catch (Error localError2)
{
this.fullScreenSize = SCREEN_SIZE_LIMITED;
}
showImage(paramArrayOfByte, paramInt);
break;
case 13:
showTextTitleCanvas(paramArrayOfByte, paramInt);
break;
case 14:
vibrate(paramArrayOfByte, paramInt);
break label286:
case 10:
case 11:
}
}
catch (Exception localException3)
{
this.own.informError("Application " + localException3.toString());
}
catch (Error localError3)
{
label286: this.own.informError("Application " + localError3.toString());
}
}
public void commandAction(Command paramCommand, Displayable paramDisplayable)
{
Object localObject1;
BluetoothRemoteControl.debug("Event");
if (paramCommand == Alert.DISMISS_COMMAND)
{
Display.getDisplay(this.own).setCurrent(this.parentWin);
return;
}
if (paramCommand == this.SCR_MAIN_BACK_CMD)
{
this.parent.sendBack();
return;
}
if (paramCommand == List.SELECT_COMMAND)
{
localObject1 = this.menuList.getString(this.menuList.getSelectedIndex());
if (((String)localObject1).compareTo("Next...") == 0)
try
{
showMenu(null, 0, DIRECTION_NEXT);
}
catch (Exception localException1)
{
}
catch (Error localError1)
{
}
if (((String)localObject1).compareTo("Previous...") == 0)
try
{
showMenu(null, 0, DIRECTION_PREVIOUS);
}
catch (Exception localException2)
{
}
catch (Error localError2)
{
}
this.menuStore.removeAllElements();
sendMenuIntInput(paramDisplayable);
return;
}
if (paramCommand == this.SCR_MAIN_OK_CMD)
{
BluetoothRemoteControl.debug("SCR_MAIN_OK_CMD");
if (this.stateDisplay == SHOW_MENU)
{
sendMenuIntInput(paramDisplayable);
return;
}
if (this.stateDisplay == SHOW_PERCENT_INPUT)
{
this.parent.sendOK();
return;
}
if (this.stateDisplay == SHOW_TEXT_INPUT)
{
String str = this.myInput.getString();
BluetoothRemoteControl.debug("Input: " + str);
int i = str.length();
localObject1 = new byte[4 + i];
localObject1[0] = 0;
localObject1[1] = 10;
setLengthAtPos(localObject1, 2, i);
copyDataToPos(localObject1, 4, str, i);
writePacket(localObject1);
return;
}
this.parent.sendOK();
return;
}
}
public void itemStateChanged(Item paramItem)
{
BluetoothRemoteControl.debug("itemStateChanged");
if (this.stateDisplay == SHOW_PERCENT_INPUT)
{
byte[] arrayOfByte = new byte[6];
int i = this.percentInput.getValue();
arrayOfByte[0] = 0;
arrayOfByte[1] = 6;
arrayOfByte[2] = 0;
arrayOfByte[3] = 2;
setLengthAtPos(arrayOfByte, 4, i);
writePacket(arrayOfByte);
}
}
private void sendMenuIntInput(Displayable paramDisplayable)
{
int i = ((List)paramDisplayable).getSelectedIndex();
if (this.menuCount > 0)
i = this.menuCount * MAX_MENU_ITEMS + i - 1;
byte[] arrayOfByte = new byte[6];
arrayOfByte[0] = 0;
arrayOfByte[1] = 6;
arrayOfByte[2] = 0;
arrayOfByte[3] = 2;
setLengthAtPos(arrayOfByte, 4, i);
writePacket(arrayOfByte);
}
public static int unsignedByteToInt(byte paramByte)
{
return (paramByte & 0xFF);
}
public static int getLengthAtPos(byte[] paramArrayOfByte, int paramInt)
throws Exception, Error
{
int i;
Object localObject1;
try
{
i = 0;
int j = paramInt;
i += (unsignedByteToInt(paramArrayOfByte[j]) << 8);
i += (unsignedByteToInt(paramArrayOfByte[(j + 1)]) << 0);
int k = i;
return k;
}
catch (Exception localException)
{
localObject1 = new Exception("getLengthAtPos " + localException.toString());
throw ((Throwable)localObject1);
}
catch (Error localError)
{
localObject1 = new Error("getLengthAtPos " + localError.toString());
throw ((Throwable)localObject1);
}
}
public static void setLengthAtPos(byte[] paramArrayOfByte, int paramInt1, int paramInt2)
{
int i = (byte)paramInt2;
paramInt2 >>= 8;
paramInt2 &= 255;
int j = (byte)paramInt2;
paramArrayOfByte[paramInt1] = j;
paramArrayOfByte[(paramInt1 + 1)] = i;
}
public static void copyDataToPos(byte[] paramArrayOfByte, int paramInt1, String paramString, int paramInt2)
{
char[] arrayOfChar = paramString.toCharArray();
for (int i = 0; i < paramInt2; ++i)
paramArrayOfByte[(i + paramInt1)] = (byte)arrayOfChar[i];
}
public void writePacket(byte[] paramArrayOfByte)
{
this.parent.write(paramArrayOfByte);
}
private int getSubStrings(String paramString, String[] paramArrayOfString)
throws Exception, Error
{
Object localObject1;
String str = paramString;
int j = 0;
try
{
do
{
if (str.length() <= 0)
break;
int i = str.indexOf("\n");
if (i != -1)
{
paramArrayOfString[j] = str.substring(0, i - 1);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -