📄 maincanvas.java
字号:
/**
* Class : short description
* @author Natale Vinto ebballon@interfree.it
* @author Michele 'Miccar' Cardinale miccar@gmail.com
* @version 1.0
*/
/*
* goText : text messaging over GPRS
* Copyright (C) 2006 Natale Vinto <ebballon@interfree.it>
* OpenJLab Group www.openjlab.org
* Copyright (C) 2006 Michele Cardinale 'Miccar' <miccar@gmail.com>
* www.miccar.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
import javax.microedition.lcdui.*;
import java.io.*;
public class MainCanvas extends Canvas {
goText gotext;
private int cursorex=0;
private int cursorey=0;
private int LUN=getWidth();
private int ALT=getHeight();
private int xy=ALT/10;
private int cx;
private Image[] vim;
private int xx,xin,xoff;
private int font=0;
private int lfont=0;
private String screen="";
private int a,b,c,d,e,f,g_,h,i,l,m,o;
Lang la;
public MainCanvas(goText gotext) {
super();
this.gotext=gotext;
cx=0;
xx=ALT/5;
cursorey=xx;
xin=xx*4+22;
xoff=(ALT-xin)/2;
cx=0;
a=192;
b=98;
c=253;
//c=255;
if(ALT>110) {
font=Font.SIZE_MEDIUM;
lfont=22;
} else {
font=Font.SIZE_SMALL;
screen="p";
lfont=16;
}
try {
vim=new Image[5];
for(int i=0;i<vim.length;i++)
vim[i]=Image.createImage("/img/"+i+""+screen+".png");
} catch(IOException e){System.out.println(e.toString()+" can't find image(s)");}
la=new Lang(gotext.lang);
this.show();
}
public void show(){
gotext.display.setCurrent(this);
}
public void paint(Graphics g) {
g.setColor(255,255,255);
g.fillRect(0,0,getWidth(),getHeight());
g.setColor(63,157,253);
Font myFont= Font.getFont(Font.FACE_PROPORTIONAL,Font.STYLE_BOLD,font);
g.setFont(myFont);
g.drawImage(vim[0],LUN/2,xoff,Graphics.HCENTER | Graphics.TOP);
g.fillRect(2,(xoff+xx*(cx+1))-1,getWidth()-4,lfont+2);
g.drawImage(vim[1],LUN-lfont,xoff+xx,Graphics.RIGHT | Graphics.TOP);
g.setColor(63+a,157+b,253-c);
g.drawString(la.MC_TEXT,5,xoff+xx,Graphics.LEFT | Graphics.TOP);
g.drawImage(vim[2],LUN-lfont,xoff+xx*2,Graphics.RIGHT | Graphics.TOP);
g.setColor(63+d,157+e,253-f);
g.drawString(la.MC_SETTINGS,5,xoff+xx*2,Graphics.LEFT | Graphics.TOP);
g.drawImage(vim[3],LUN-lfont,xoff+xx*3,Graphics.RIGHT | Graphics.TOP);
g.setColor(63+g_,157+h,253-i);
g.drawString(la.MC_INFO,5,xoff+xx*3,Graphics.LEFT | Graphics.TOP);
g.drawImage(vim[4],LUN-lfont,xoff+xx*4,Graphics.RIGHT | Graphics.TOP);
g.setColor(63+l,157+m,253-o);
g.drawString(la.MC_EXIT,5,xoff+xx*4,Graphics.LEFT | Graphics.TOP);
}
private void change(int n) {
switch(n) {
case 0:a=192;b=98;c=253;d=0;e=0;f=0;g_=0;h=0;i=0;l=0;m=0;o=0;break;
case 1:a=0;b=0;c=0;d=192;e=98;f=253;g_=0;h=0;i=0;l=0;m=0;o=0;break;
case 2:a=0;b=0;c=0;d=0;e=0;f=0;g_=192;h=98;i=253;l=0;m=0;o=0;break;
case 3:a=0;b=0;c=0;d=0;e=0;f=0;g_=0;h=0;i=0;l=192;m=98;o=253;break;
default:a=0;b=0;c=0;d=0;e=0;f=0;g_=0;h=0;i=0;l=0;m=0;o=0;
}
}
protected void keyPressed(int keyCode) {
int k = getGameAction(keyCode);
switch (k){
case Canvas.UP:
cursorey-=xx;
if (cursorey<xx){
cursorey=xx;
}
cx--;
if(cx<0){
cx=0;
}
change(cx);
repaint();
break;
case Canvas.DOWN:
cursorey+=xx;
if (cursorey>xx*4){
cursorey=xx*4;
}
cx++;
if(cx>3){
cx=3;
}
change(cx);
repaint();
break;
}
}
protected void keyReleased(int keyCode) {
int k = getGameAction(keyCode);
switch (k){
case Canvas.FIRE:
if(cx==0){
new ListSelectService(gotext);
} else if(cx==1) {
new ListSettings(gotext);
} else if(cx==2){
new FormInfo(gotext);
} else {
gotext.destroyApp(true);
}
break;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -