02
This commit is contained in:
parent
ed54cd866e
commit
fb2e469b6d
214
src/About.java
Normal file
214
src/About.java
Normal file
@ -0,0 +1,214 @@
|
||||
|
||||
|
||||
/*
|
||||
* aNNiMON 2010
|
||||
* For more info visit http://annimon.com/
|
||||
*/
|
||||
|
||||
/*
|
||||
* Íà îñíîâå êëàññà MultiLineText îò À.Ñ. Ëåäêîâà
|
||||
* www.mobilab.ru
|
||||
*/
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.util.Vector;
|
||||
import javax.microedition.lcdui.*;
|
||||
|
||||
public class About extends Canvas {
|
||||
|
||||
private Font defaultFont;
|
||||
private Displayable dspl;
|
||||
private int fontHeight, defaultFontHeight;
|
||||
private String text; //òåêñò
|
||||
|
||||
private int w, h; //ðàçìåðû
|
||||
|
||||
private int workingHeight; //Ðàçìåð îãðàíè÷èâàþùåãî ïðÿìîóãîëüíèêà;
|
||||
private int yBase; //Ïîëîæåíèå âåðõíåãî êðàÿ òåêñòà
|
||||
private int scrollStep; //Øàã ïðè ïðîêðóòêå òåêñòà
|
||||
private int allTextHeight; //Îáùàÿ âûñîòà òåêñòà
|
||||
private Vector strLines;
|
||||
|
||||
public About(Displayable dspl) {
|
||||
setFullScreenMode(true);
|
||||
this.dspl = dspl;
|
||||
w = getWidth();
|
||||
h = getHeight();
|
||||
text = getText("/lang/about_"+Rms.languageApp);
|
||||
fontHeight = UI.getSoftBarHeight()+2;
|
||||
defaultFont = Font.getDefaultFont();
|
||||
scrollStep = defaultFontHeight = defaultFont.getHeight()+2;
|
||||
workingHeight = h - fontHeight*2 - 2;
|
||||
setParameters();
|
||||
}
|
||||
|
||||
protected void sizeChanged(int w, int h) {
|
||||
this.w = w;
|
||||
this.h = h;
|
||||
workingHeight = h - fontHeight*2 - 2;
|
||||
setParameters();
|
||||
}
|
||||
|
||||
|
||||
protected void paint(Graphics g) {
|
||||
g.setColor(P.backgrnd);
|
||||
g.fillRect(0, 0, w, h);
|
||||
UI.drawTitle(g, L.str[L.about]);
|
||||
g.setColor(P.fmtextnc);
|
||||
g.setFont(defaultFont);
|
||||
g.setClip(0, fontHeight+1, w, workingHeight);
|
||||
int y1 = yBase;
|
||||
for (int i = 0; i < strLines.size(); i++) {
|
||||
if ((y1 + defaultFontHeight) > 0) {
|
||||
g.drawString(strLines.elementAt(i).toString(), 1, fontHeight + 5 + y1, Graphics.LEFT | Graphics.TOP);
|
||||
}
|
||||
y1 = y1 + defaultFontHeight;
|
||||
if (y1 > workingHeight) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
g.setClip(0, 0, w, h);
|
||||
UI.drawSoftBar(g, "", L.str[L.back]);
|
||||
}
|
||||
|
||||
protected void keyPressed(int key) {
|
||||
int ga = getGameAction(key);
|
||||
if(ga==UP) MoveUp();
|
||||
else if(ga==DOWN) MoveDown();
|
||||
else if(ga==LEFT) PageUp();
|
||||
else if(ga==RIGHT) PageDown();
|
||||
else if(ga==FIRE || key==Key.rightSoftKey) Main.dsp.setCurrent(dspl);
|
||||
else if(key==Key.leftSoftKey) {
|
||||
System.gc();
|
||||
}
|
||||
repaint();
|
||||
}
|
||||
|
||||
protected void keyRepeated(int key) {
|
||||
keyPressed(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Óñòàíîâêà íåîáõîäèìûõ ïàðàìåòðîâ äëÿ òåêñòà
|
||||
*/
|
||||
private void setParameters() {
|
||||
//Ðàçáèâàåì ñòðîêó íà ìàññèâ ñòðîê
|
||||
strLines = new Vector();
|
||||
String[] arr = splitString(text, "\n");
|
||||
for(int i = 0; i<arr.length; i++) {
|
||||
String substr = arr[i];
|
||||
int i0 = 0, space = 0, in = 0, j = 0, jw = 0; //Ñìåùåíèå îò íà÷àëà ñòðîêè
|
||||
int imax = substr.length(); //Äëèíà ñòðîêè
|
||||
boolean isexit = true;
|
||||
yBase = 0;
|
||||
while (isexit) {
|
||||
space = substr.indexOf(" ", i0 + 1);
|
||||
if (space <= i0) {
|
||||
space = imax;
|
||||
isexit = false;
|
||||
}
|
||||
|
||||
j = defaultFont.stringWidth(substr.substring(i0, space));
|
||||
if (jw + j < w) {//Ñëîâî óìåùàåòñÿ
|
||||
jw = jw + j;
|
||||
i0 = space;
|
||||
} else {//Ñëîâî íå óìåùàåòñÿ
|
||||
strLines.addElement(substr.substring(in, i0));
|
||||
in = i0 + 1;
|
||||
jw = j;
|
||||
if (j > w) {//Ñëîâî ïîëíîñòüþ íå óìåùàåòñÿ â ñòðîêå
|
||||
space = i0;
|
||||
while (jw > w) {
|
||||
j = 0;
|
||||
while (j < w) {
|
||||
space++;
|
||||
j = defaultFont.stringWidth(substr.substring(in, space));
|
||||
}
|
||||
space = space - 1;
|
||||
j = defaultFont.stringWidth(substr.substring(in, space));
|
||||
strLines.addElement(substr.substring(in, space));
|
||||
jw = jw - j;
|
||||
i0 = space;
|
||||
in = space;
|
||||
}
|
||||
jw = 0;
|
||||
} else {
|
||||
i0 = space;
|
||||
}
|
||||
}
|
||||
}
|
||||
strLines.addElement(substr.substring(in, imax));
|
||||
}
|
||||
allTextHeight = strLines.size() * defaultFontHeight;
|
||||
}
|
||||
|
||||
private void MoveDown() {
|
||||
if (allTextHeight > workingHeight) {
|
||||
yBase = yBase - scrollStep;
|
||||
if (workingHeight - yBase > allTextHeight) {
|
||||
yBase = workingHeight - allTextHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void MoveUp() {
|
||||
if (allTextHeight > workingHeight) {
|
||||
yBase = yBase + scrollStep;
|
||||
if (yBase > 0) {
|
||||
yBase = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void PageUp() {
|
||||
if (allTextHeight > workingHeight) {
|
||||
yBase = yBase + workingHeight;
|
||||
if (yBase > 0) {
|
||||
yBase = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void PageDown() {
|
||||
if (allTextHeight > workingHeight) {
|
||||
yBase = yBase - workingHeight;
|
||||
if (workingHeight - yBase > allTextHeight) {
|
||||
yBase = workingHeight - allTextHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String[] splitString(String str, String delim) {
|
||||
if (str.length() == 0 || delim.length() == 0) return new String[]{str};
|
||||
|
||||
Vector v = new Vector();
|
||||
int pos = 0;
|
||||
int newpos = str.indexOf(delim, 0);
|
||||
|
||||
while (newpos != -1) {
|
||||
v.addElement(str.substring(pos, newpos));
|
||||
pos = newpos + delim.length();
|
||||
newpos = str.indexOf(delim, pos);
|
||||
}
|
||||
v.addElement(str.substring(pos));
|
||||
|
||||
String[] s = new String[v.size()];
|
||||
v.copyInto(s);
|
||||
return s;
|
||||
}
|
||||
|
||||
private String getText(String path) {
|
||||
DataInputStream dis = new DataInputStream(getClass().getResourceAsStream(path));
|
||||
StringBuffer strBuff = new StringBuffer();
|
||||
int ch = 0;
|
||||
try {
|
||||
while ((ch = dis.read()) != -1) {
|
||||
strBuff.append(StringEncoder.decodeCharCP1251((byte)ch));
|
||||
}
|
||||
dis.close();
|
||||
} catch (Exception e) {e.printStackTrace();}
|
||||
return strBuff.toString();
|
||||
}
|
||||
}
|
64
src/FWCashe.java
Normal file
64
src/FWCashe.java
Normal file
@ -0,0 +1,64 @@
|
||||
|
||||
|
||||
import javax.microedition.lcdui.Font;
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
* Êëàññ êýøà øèðèíû áóêâ øðèôòà
|
||||
*/
|
||||
public class FWCashe {
|
||||
|
||||
/**
|
||||
* Ïîëó÷èòü êýø
|
||||
* @param font øðèôò, èç êîòîðîãî ïîëó÷àåì êýø øèðèíû áóêâ
|
||||
* @return ýêçåìïëÿð êëàññà
|
||||
*/
|
||||
public static FWCashe getCache(Font font) {
|
||||
Vector fwc = new Vector();
|
||||
Vector fwc_f = new Vector();
|
||||
for (int i = 0; i < fwc.size(); i++) {
|
||||
if (fwc_f.elementAt(i).equals(font)) {
|
||||
return (FWCashe) fwc.elementAt(i);
|
||||
}
|
||||
}
|
||||
fwc_f.addElement(font);
|
||||
FWCashe f = new FWCashe(font);
|
||||
fwc.addElement(f);
|
||||
return f;
|
||||
}
|
||||
|
||||
protected Font font;
|
||||
protected byte[][] caches;
|
||||
|
||||
protected FWCashe(Font font) {
|
||||
this.font = font;
|
||||
caches = new byte[256][];
|
||||
for (int i = 0; i < 256; i++) {
|
||||
caches[i] = null;
|
||||
}
|
||||
}
|
||||
|
||||
public int charWidth(char ch) {
|
||||
int hi = (ch >> 8) & 0xFF;
|
||||
int lo = (ch) & 0xFF;
|
||||
if (caches[hi] == null) {
|
||||
caches[hi] = new byte[256];
|
||||
for (int i = 0; i < 256; i++) {
|
||||
caches[hi][i] = -1;
|
||||
}
|
||||
}
|
||||
if (caches[hi][lo] == -1) {
|
||||
caches[hi][lo] = (byte) font.charWidth(ch);
|
||||
}
|
||||
return caches[hi][lo];
|
||||
}
|
||||
|
||||
public int stringWidth(String s) {
|
||||
int width = 0;
|
||||
int len = s.length();
|
||||
for (int i = 0; i < len; i++) {
|
||||
width += charWidth(s.charAt(i));
|
||||
}
|
||||
return width;
|
||||
}
|
||||
}
|
479
src/FileManager.java
Normal file
479
src/FileManager.java
Normal file
@ -0,0 +1,479 @@
|
||||
import java.util.*;
|
||||
import javax.microedition.lcdui.*;
|
||||
import midedit.CompositionForm;
|
||||
import midedit.MixerMain;
|
||||
import midedit.io.AbstractFile;
|
||||
|
||||
/**
|
||||
* Ôàéëîâûé ìåíåäæåð
|
||||
* Èñïîëüçóåòñÿ äëÿ îòêðûòèÿ è ñîõðàíåíèÿ ôàéëîâ
|
||||
*
|
||||
* @author aNNiMON
|
||||
*/
|
||||
public class FileManager extends Canvas {
|
||||
|
||||
/* Ðàñøèðåíèÿ äëÿ ãðóïï äàííûõ */
|
||||
/** MIDI-ôàéëû */
|
||||
private static final String[] TypeMid = {
|
||||
"mid", "midi"
|
||||
};
|
||||
|
||||
/** Âûñîòà øðèôòà */
|
||||
private static final int FONT_HEIGHT = P.smBold.getHeight()+2;
|
||||
/** Âûñîòà êóðñîðà */
|
||||
private static final int SH_HEIGHT = FONT_HEIGHT + 1;
|
||||
|
||||
|
||||
/** Ïóòü ê ïàïêå */
|
||||
public String pathFile;
|
||||
|
||||
/** Ðàçìåð ýêðàíà */
|
||||
private int w, h;
|
||||
|
||||
/** Ýêðàí, â êîòîðûé ïîïàäàåì ïðè íàæàòèè Îòìåíà*/
|
||||
private Displayable previousDisplayable;
|
||||
|
||||
/** Êýø øèðèíû áóêâ äëÿ ìàëåíüêîãî æèðíîãî øðèôòà */
|
||||
private FWCashe fontCashe;
|
||||
|
||||
/** Ôàéëîâàÿ ñèñòåìà */
|
||||
private AbstractFile file;
|
||||
|
||||
/** Èçîáðàæåíèÿ è èêîíêè ãðóïï ôàéëîâ */
|
||||
//private Image folderIcon, imageIcon, fileIcon, fontIcon, videoIcon;
|
||||
|
||||
/** Ñïèñîê ôàéëîâ è ïàïîê */
|
||||
private String[] data;
|
||||
/** Ñïèñîê ïóíêòîâ ìåíþ */
|
||||
private String[] menu;
|
||||
|
||||
/* Ïåðåìåííûå äëÿ ðàñ÷åòà êîîðäèíàò âûâîäà ñïèñêà ôàéëîâ */
|
||||
private int CursorY, startPrintFile, numFiles;
|
||||
|
||||
/** Ðàçìåðû è êîîðäèíàòû âûâîäà ïàíåëè ìåíþ */
|
||||
private int menuY, menuWidth, menuHeight;
|
||||
|
||||
/** Âûáðàííûé ïóíêò â ñïèñêå ôàéëîâ è ìåíþ */
|
||||
private int curFiles, curMenu;
|
||||
|
||||
/** Îòîáðàæàòü ëè ìåíþ */
|
||||
private boolean showMenu;
|
||||
|
||||
/**
|
||||
* Êîíñòðóêòîð äëÿ îòêðûòèÿ ôàéëîâ
|
||||
* @param s ñòàðòîâûé ïóòü ê ïàïêå
|
||||
* @param aFile ôñ
|
||||
*/
|
||||
public FileManager(String s, AbstractFile aFile) {
|
||||
setFullScreenMode(true);
|
||||
w = getWidth();
|
||||
h = getHeight();
|
||||
|
||||
pathFile = s;
|
||||
file = aFile;
|
||||
|
||||
fontCashe = FWCashe.getCache(P.smBold);
|
||||
CursorY = startPrintFile = curFiles = numFiles = 0;
|
||||
showMenu = false;
|
||||
|
||||
loadImages();
|
||||
// Ñïèñîê ïóíêòîâ ìåíþ
|
||||
menu = new String[] {
|
||||
L.str[L.open],
|
||||
L.str[L.play],
|
||||
L.str[L.cancel]
|
||||
};
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
/**
|
||||
* Êîíñòðóêòîð äëÿ ñîõðàíåíèÿ
|
||||
* @param s ïóòü ê ïàïêå
|
||||
* @param prev ýêðàí, êóäà âåðí¸ìñÿ ïîñëå îòìåíû
|
||||
* @param aFile ôñ
|
||||
*/
|
||||
public FileManager(String s, Displayable prev, AbstractFile aFile) {
|
||||
this(s, aFile);
|
||||
previousDisplayable = prev;
|
||||
// ìåíþ ñîõðàíåíèÿ
|
||||
menu = new String[] {
|
||||
L.str[L.saveInThisFolder],
|
||||
// L.str[L.newFolder],
|
||||
L.str[L.cancel]
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Ïîêàçàòü ýêðàí ôàéëìåíåäæåðà è ïðè íåîáõîäèìîñòè îáíîâèòü ñïèñîê ôàéëîâ
|
||||
* @param update îáíîâèòü ñïèñîê ôàéëîâ
|
||||
*/
|
||||
public void setCurrent(boolean update) {
|
||||
if(update) update();
|
||||
Main.dsp.setCurrent(this);
|
||||
}
|
||||
|
||||
/** Çàäàòü ñïèñîê ôàéëîâ â ìåíþ */
|
||||
private void setMenu() {
|
||||
Vector vt = new Vector();
|
||||
if (menu[0].equals(L.str[L.saveInThisFolder])) {
|
||||
// Ïóíêòû ïðè ñîõðàíåíèè
|
||||
vt.addElement(L.str[L.saveInThisFolder]);
|
||||
//vt.addElement(L.str[L.newFolder]);
|
||||
} else {
|
||||
// Ïóíêòû ïðè îòêðûòèè
|
||||
vt.addElement(L.str[L.open]);
|
||||
if (getType(TypeMid, data[curFiles])) {
|
||||
vt.addElement(L.str[L.play]);
|
||||
//vt.addElement(L.str[L.openToBuffer]);
|
||||
}
|
||||
}
|
||||
vt.addElement(L.str[L.cancel]);
|
||||
menu = new String[vt.size()];
|
||||
vt.copyInto(menu);
|
||||
vt = null;
|
||||
|
||||
// Ðàñ÷èòûâàåì ðàçìåðû è êîîðäèíàòû ïàíåëè ìåíþ
|
||||
calcMenuPos();
|
||||
}
|
||||
|
||||
/**
|
||||
* Âû÷èñëÿåì ðàçìåðû è êîîðäèíàòû ïàíåëè ìåíþ
|
||||
*/
|
||||
private void calcMenuPos() {
|
||||
menuHeight = FONT_HEIGHT * menu.length;
|
||||
menuWidth = 0;
|
||||
for(int i = 0; i < menu.length; i++) {
|
||||
int itemWidth = fontCashe.stringWidth(menu[i]);
|
||||
if(itemWidth > menuWidth) menuWidth = itemWidth;
|
||||
}
|
||||
menuWidth = menuWidth + 3; // Óâåëè÷èâàåì øèðèíó, ÷òîá óæ íàâåðíÿêà
|
||||
menuY = h - menuHeight - UI.getSoftBarHeight();
|
||||
}
|
||||
|
||||
protected void sizeChanged(int w, int h) {
|
||||
this.w = getWidth();
|
||||
this.h = getHeight();
|
||||
super.sizeChanged(w, h);
|
||||
}
|
||||
|
||||
protected void paint(Graphics g) {
|
||||
g.setColor(P.backgrnd);
|
||||
g.fillRect(0, 0, w, h);
|
||||
drawFiles(g);
|
||||
if (showMenu) {
|
||||
drawMenu(g);
|
||||
}
|
||||
UI.drawTitle(g, pathFile);
|
||||
UI.drawSoftBar(g,L.str[L.menu],L.str[L.back]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Îòðèñîâêà ñïèñêà ôàéëîâ
|
||||
* @param g êîíòåêñò ãðàôèêè
|
||||
*/
|
||||
private void drawFiles(Graphics g) {
|
||||
if (numFiles > 0) {
|
||||
// Ðèñóåì êóðñîð
|
||||
g.setColor(P.obv);
|
||||
g.fillRect(0, CursorY + SH_HEIGHT, w, FONT_HEIGHT);
|
||||
g.setColor(P.fmbord);
|
||||
g.drawRect(0, CursorY + FONT_HEIGHT, w, FONT_HEIGHT);
|
||||
}
|
||||
int FileY = 0;
|
||||
g.setFont(P.smBold);
|
||||
for (int i = startPrintFile; i < numFiles; i++) {
|
||||
// Èêîíêà òèïà ôàéëà
|
||||
/*Image tmp = fileIcon;
|
||||
if (data[i].indexOf("/") != -1) tmp = folderIcon;
|
||||
else if (getType(TypeMid, data[i])) tmp = imageIcon;
|
||||
g.drawImage(tmp, 1, FileY + SH_HEIGHT + 1, 0);*/
|
||||
// Òåêñò
|
||||
int col = P.fmtextnc;
|
||||
if (FileY == CursorY) col = P.fmtextcur;
|
||||
g.setColor(col);
|
||||
g.drawString(data[i], 18, FileY + SH_HEIGHT, 20);
|
||||
|
||||
FileY += FONT_HEIGHT;
|
||||
if(FileY > (h - (SH_HEIGHT*2)-3)) break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Îòðèñîâêà ìåíþ
|
||||
* @param g êîíòåêñò ãðàôèêè
|
||||
*/
|
||||
private void drawMenu(Graphics g) {
|
||||
final int menuX = 3;
|
||||
|
||||
g.setFont(P.smPlain);
|
||||
int colorBack, colorObv, colorText;
|
||||
// Îòðèñîâóåì ïóíêòû ìåíþ
|
||||
for (int i = 0; i < menu.length; i++) {
|
||||
// Äëÿ êóðñîðà èñïîëüçóþòñÿ äðóãèå öâåòà
|
||||
if (i == curMenu) {
|
||||
colorBack = P.fmbord;
|
||||
colorObv = P.fmcurbord;
|
||||
colorText = P.fmtextuppan;
|
||||
} else {
|
||||
colorBack = P.fmback1;
|
||||
colorObv = P.obv;
|
||||
colorText = P.fmcurbord;
|
||||
}
|
||||
int hh = menuY + i * (FONT_HEIGHT - 1);
|
||||
g.setColor(colorBack);
|
||||
g.fillRect(menuX, hh, menuWidth, FONT_HEIGHT - 1);
|
||||
g.setColor(colorObv);
|
||||
g.drawRect(menuX, hh, menuWidth, FONT_HEIGHT - 1);
|
||||
g.setColor(colorText);
|
||||
g.drawString(menu[i], menuX + 3, hh + 1, 20);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Îáðàáîòêà âûáðàííûõ ïóíêòîâ
|
||||
* @param selected ID âûáðàííîãî ïóíêòà ìåíþ
|
||||
*/
|
||||
private void selectItem(int selected) {
|
||||
// Âûáðàííûé ïóíêò ìåíþ
|
||||
final String cur = menu[selected];
|
||||
// Âûáðàííûé ïóíêò â ñïèñêå ôàéëîâ
|
||||
final String fileSelected = data[curFiles];
|
||||
|
||||
curMenu = 0;
|
||||
showMenu = false;
|
||||
|
||||
if (cur.equals(L.str[L.open])) {
|
||||
// Îòêðûòü
|
||||
nextDir(fileSelected);
|
||||
P.path = pathFile;
|
||||
}
|
||||
else if (cur.equals(L.str[L.play])) {
|
||||
// Ïðîèãðûâàíèå
|
||||
/*if (getType(TypeMid, fileSelected)) {
|
||||
Image img = JSR75.getImage(pathFile, fileSelected);
|
||||
PPM.midlet.imgname = fileSelected.substring(0, fileSelected.lastIndexOf('.'));
|
||||
PPM.dsp.setCurrent(new Viewer(img, this));
|
||||
} else if (getType(TypePpf, fileSelected)) {
|
||||
Image img = JSR75.getPPFImage(pathFile, fileSelected);
|
||||
PPM.dsp.setCurrent(new Viewer(img, this));
|
||||
}
|
||||
P.path = pathFile;*/
|
||||
}
|
||||
else if (cur.equals( L.str[L.cancel])) {
|
||||
// Îòìåíà
|
||||
P.path = pathFile;
|
||||
if(menu[0].equals(L.str[L.saveInThisFolder])) Main.dsp.setCurrent(previousDisplayable);
|
||||
else Main.dsp.setCurrent(Main.midlet.menu);
|
||||
}
|
||||
else if (cur.equals(L.str[L.saveInThisFolder])) {
|
||||
P.path = pathFile;
|
||||
}
|
||||
/*else if (cur.equals(L.str[L.newFolder])) {
|
||||
// Íîâàÿ ïàïêà
|
||||
NewFolderForm newFolder = new NewFolderForm(L.str[L.newFolder], this, pathFile);
|
||||
PPM.dsp.setCurrent(newFolder);
|
||||
}*/
|
||||
}
|
||||
|
||||
/** Çàãðóçêà èçîáðàæåíèé */
|
||||
private void loadImages() {
|
||||
/*Image allimg = new GetImage().loadImages(0);//icons
|
||||
try {
|
||||
imageIcon = Image.createImage(allimg, 0, 0, 16, 15, 0);
|
||||
folderIcon = Image.createImage(allimg, 16, 0, 14, 15, 0);
|
||||
fileIcon = Image.createImage(allimg, 30, 0, 13, 15, 0);
|
||||
videoIcon = Image.createImage(allimg, 43, 0, 13, 15, 0);
|
||||
fontIcon = Image.createImage(allimg, 57, 0, 13, 15, 0);
|
||||
} catch (Exception ioe) {
|
||||
}*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Âîçâðàòèòüñÿ â ïðåäûäóùóþ ïàïêó
|
||||
*/
|
||||
private void backDir() {
|
||||
CursorY = 0;
|
||||
curFiles = 0;
|
||||
startPrintFile = 0;
|
||||
int i = pathFile.lastIndexOf('/', pathFile.length() - 2);
|
||||
if (i != -1) {
|
||||
pathFile = pathFile.substring(0, i + 1);
|
||||
} else {
|
||||
pathFile = "/";
|
||||
return;
|
||||
}
|
||||
P.path = pathFile;
|
||||
update();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ïåðåéòè â ñëåäóþùóþ ïàïêó èëè îòêðûòü ôàéë
|
||||
* @param s èìÿ ôàéëà / ïàïêè
|
||||
*/
|
||||
private void nextDir(String s) {
|
||||
if (s.indexOf("/") != -1) {
|
||||
pathFile = pathFile + s;
|
||||
P.path = pathFile;
|
||||
update();
|
||||
curFiles = 0;
|
||||
startPrintFile = 0;
|
||||
CursorY = 0;
|
||||
} else if (getType(TypeMid, s)) {
|
||||
if(menu[0].equals(L.str[L.saveInThisFolder])) return;
|
||||
try {
|
||||
if (Main.midlet.compositionForm != null) {
|
||||
Main.midlet.compositionForm.releaseMem();
|
||||
}
|
||||
Main.midlet.compositionForm = null;
|
||||
System.gc();
|
||||
//
|
||||
String openSaveString = pathFile + s;
|
||||
Main.midlet.compositionForm = new CompositionForm(new MixerMain(), openSaveString);
|
||||
Main.dsp.setCurrent(Main.midlet.compositionForm);
|
||||
new Thread(Main.midlet.compositionForm).start();
|
||||
|
||||
} catch (Exception e) {
|
||||
/*Alert a = new Alert(Constants.getStringName(13), Constants.getStringName(13) + ":\n" + e.getMessage(), null, null);
|
||||
display.setCurrent(a);
|
||||
if (compositionForm != null) {
|
||||
compositionForm.releaseMem();
|
||||
}
|
||||
compositionForm = null;*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void keyPressed(int i) {
|
||||
super.keyPressed(i);
|
||||
int ga = getGameAction(i);
|
||||
if (showMenu) {
|
||||
// Îòêðûòî ìåíþ - ïåðåìåùàåìñÿ ïî íåìó
|
||||
if (ga==UP) {
|
||||
curMenu--;
|
||||
if(curMenu<0) curMenu = menu.length - 1;
|
||||
}
|
||||
else if (ga==DOWN) {
|
||||
curMenu++;
|
||||
if(curMenu >= menu.length) curMenu = 0;
|
||||
}
|
||||
else if (ga==FIRE || ga==RIGHT) selectItem(curMenu);
|
||||
else if (i == Key.leftSoftKey) showMenu = !showMenu;
|
||||
} else {
|
||||
if(i == Key.leftSoftKey) {
|
||||
showMenu = true;
|
||||
curMenu = 0;
|
||||
setMenu();
|
||||
}
|
||||
else if(ga == LEFT || i == Key.rightSoftKey) {
|
||||
backDir();
|
||||
}
|
||||
else switch(ga) {
|
||||
case DOWN: cursorDown(); break;
|
||||
case UP: cursorUp(); break;
|
||||
case FIRE:
|
||||
case RIGHT:
|
||||
nextDir(data[curFiles]);
|
||||
break;
|
||||
}
|
||||
switch (i) {
|
||||
case KEY_NUM3:
|
||||
for(int qq=0; qq<10; qq++) cursorUp();
|
||||
break;
|
||||
case KEY_NUM9:
|
||||
for(int qq=0; qq<10; qq++) cursorDown();
|
||||
break;
|
||||
}
|
||||
}
|
||||
repaint();
|
||||
}
|
||||
|
||||
protected void pointerPressed(int pix, int piy) {
|
||||
int y = UI.getSoftBarHeight();
|
||||
if (showMenu) {
|
||||
if(pix<2*y && piy>h-y) {
|
||||
showMenu = !showMenu;
|
||||
}
|
||||
}
|
||||
if(pix<2*y && piy>h-y) {
|
||||
showMenu = true;
|
||||
curMenu = 0;
|
||||
setMenu();
|
||||
}else if(pix>w-2*y && piy>h-y) {
|
||||
backDir();
|
||||
}
|
||||
repaint();
|
||||
}
|
||||
|
||||
|
||||
public void keyRepeated(int i) {
|
||||
keyPressed(i);
|
||||
}
|
||||
|
||||
private void cursorDown() {
|
||||
if (data.length > 0) {
|
||||
final int maxHeight = h - 2 * SH_HEIGHT;
|
||||
if (curFiles == data.length - 1) {
|
||||
CursorY = 0;
|
||||
curFiles = 0;
|
||||
startPrintFile = 0;
|
||||
} else if (curFiles > (maxHeight / FONT_HEIGHT - 3)) {
|
||||
if (CursorY >= (maxHeight - 2 * FONT_HEIGHT)) {
|
||||
startPrintFile++;
|
||||
curFiles++;
|
||||
} else {
|
||||
curFiles++;
|
||||
CursorY += FONT_HEIGHT;
|
||||
}
|
||||
} else {
|
||||
CursorY += FONT_HEIGHT;
|
||||
curFiles++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void cursorUp() {
|
||||
if (data.length > 0) {
|
||||
if (curFiles == 0) {
|
||||
curFiles = data.length - 1;
|
||||
final int maxHeight = h - 2 * SH_HEIGHT;
|
||||
if (data.length > (maxHeight / FONT_HEIGHT)) {
|
||||
startPrintFile = (data.length - maxHeight / FONT_HEIGHT) + 1;
|
||||
CursorY = (data.length - 1 - startPrintFile) * FONT_HEIGHT;
|
||||
} else {
|
||||
CursorY = (data.length - 1) * FONT_HEIGHT;
|
||||
}
|
||||
} else if ((CursorY == 0) && (curFiles > 0)) {
|
||||
startPrintFile--;
|
||||
curFiles--;
|
||||
} else if (CursorY > 0) {
|
||||
CursorY -= FONT_HEIGHT;
|
||||
curFiles--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Îïðåäåëèòü ïðèíàäëåæíîñòü ôàéëà ê êàêîìó-òî òèïó äàííûõ ïî ðàñøèðåíèþ
|
||||
* @param type ìàññèâ ðàñøèðåíèé äàííîãî òèïà
|
||||
* @param file èìÿ ôàéëà
|
||||
* @return true - ïðèíàäëåæèò
|
||||
*/
|
||||
private boolean getType(String[] type, String file) {
|
||||
for (int i = 0; i < type.length; i++) {
|
||||
if (file.toLowerCase().endsWith("." + type[i])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Îáíîâèòü ñïèñîê ôàéëîâ
|
||||
*/
|
||||
private void update() {
|
||||
data = file.list(pathFile);
|
||||
numFiles = data.length;
|
||||
}
|
||||
|
||||
}
|
85
src/Key.java
Normal file
85
src/Key.java
Normal file
@ -0,0 +1,85 @@
|
||||
|
||||
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* @author sinaz
|
||||
*/
|
||||
public class Key {
|
||||
|
||||
public static String Platform = "";//ìîæíî óáðàòü åñëè íå íóæíî
|
||||
public static int leftSoftKey = -6;//ALL Devices
|
||||
public static int rightSoftKey = -7;//ALL Devices
|
||||
public static int Clear = -1000;//SonyEricsson & Nokia(S60)
|
||||
public static int Call = - 1000;// Samsung Z500 & Siemens Devices
|
||||
public static int Hangup = - 1000;//Siemens Devices (S-Gold)
|
||||
public static int Back = -1000;//SonyEricsson
|
||||
public static int InputMode = -1000;//Only Nokia Devices (S60)
|
||||
|
||||
//Only SonyEricsson JP6
|
||||
public static int VolPlus = -1000;
|
||||
public static int VolMinus = -1000;
|
||||
public static int Camera = -1000;
|
||||
public static int Focus = -1000;
|
||||
public static int Snapshot = -1000;
|
||||
//*************************
|
||||
|
||||
|
||||
static {
|
||||
String microeditionPlatform = System.getProperty("microedition.platform");
|
||||
if (microeditionPlatform != null) {
|
||||
String melc = microeditionPlatform.toLowerCase();
|
||||
if (melc.indexOf("ericsson") != -1)//SonyEricsson
|
||||
{
|
||||
Clear = -8;
|
||||
Back = -11;
|
||||
Call = -10;
|
||||
//Only SonyEricsson JP6
|
||||
VolPlus = -36;
|
||||
VolMinus = -37;
|
||||
Camera = -24;
|
||||
Focus = -25;
|
||||
Snapshot = -26;
|
||||
Platform = "Sony Ericsson";
|
||||
} else if (melc.indexOf("nokia") != -1)//Nokia Devices (S40) (S60)
|
||||
{
|
||||
//Only Nokia Devices (S60)
|
||||
Clear = -8;
|
||||
InputMode = -50;
|
||||
Platform = "Nokia";
|
||||
} else {//îñòàëüíûå íå âûäàþò ôèðìó,à òîëüêî ìàðêó ìîáèëû íàïðèìåð Z500,ïîòîìó èõ ëó÷øå ëîâèòü ïî êëàññàì
|
||||
try {
|
||||
Class.forName("com.samsung.util.Vibration");//Samsung
|
||||
Call = -5;// Samsung Z500
|
||||
Platform = "Samsung";
|
||||
} catch (Throwable t0) {
|
||||
|
||||
try {
|
||||
Class.forName("com.siemens.mp.io.file.FileConnection");//Siemens Devices (S-Gold)
|
||||
leftSoftKey = -1;
|
||||
rightSoftKey = -4;
|
||||
Call = -11;
|
||||
Hangup = -12;
|
||||
Camera = -20;
|
||||
Platform = "Siemens";
|
||||
} catch (Throwable t1) {
|
||||
|
||||
try {
|
||||
Class.forName("com.motorola.io.file.FileConnection");
|
||||
leftSoftKey = -21;
|
||||
rightSoftKey = -22;
|
||||
Call = -10;
|
||||
//Motorola V300, V500, V525 äîëæíû áûòü ñîôòû leftSoftKey = 21;rightSoftKey = 22;
|
||||
Platform = "Motorola";
|
||||
} catch (Throwable t2) { //ñþäà ìîæíî âïèñàòü åø¸ ïëàòôîðìó ìîòîðîëëû ñ êëàññîì com.motorola.io.FileConnection
|
||||
//íî ó íå¸ ôàéëîâàÿ ìóäàöêàÿ
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
153
src/L.java
Normal file
153
src/L.java
Normal file
@ -0,0 +1,153 @@
|
||||
import java.io.*;
|
||||
import java.util.Vector;
|
||||
import midedit.BufDataInputStream;
|
||||
|
||||
/**
|
||||
* Êëàññ òåêñòîâûõ ìåòîê
|
||||
* @author aNNiMON
|
||||
*/
|
||||
public class L {
|
||||
|
||||
/** Íîìåðà ñòðîê òåêñòîâûõ ìåòîê */
|
||||
public static final byte
|
||||
create = 0,
|
||||
resume = 1,
|
||||
about = 2,
|
||||
open = 3,
|
||||
save = 4,
|
||||
saveAs = 5,
|
||||
file = 6,
|
||||
options = 7,
|
||||
exit = 8,
|
||||
RMS = 9,
|
||||
cancel = 10,
|
||||
error = 11,
|
||||
openError = 12,
|
||||
toolsList = 13,
|
||||
impossible = 14,
|
||||
saved = 15,
|
||||
savingError = 16,
|
||||
saving = 17,
|
||||
opening = 18,
|
||||
chooserError = 19,
|
||||
updateError = 20,
|
||||
apiError = 21,
|
||||
instruments = 22,
|
||||
menu = 23,
|
||||
back = 24,
|
||||
insertNoteWithCurrentAttributes = 25,
|
||||
noteAttributeHelp = 26,
|
||||
deleteNote = 27,
|
||||
undo = 28,
|
||||
noteVolume = 29,
|
||||
playFromCurrent = 30,
|
||||
playNoteOnCursor = 31,
|
||||
selectNoteAttribute = 32,
|
||||
changeNoteAttribute = 33,
|
||||
stop = 34,
|
||||
navigationOnComposition = 35,
|
||||
quicknav = 36,
|
||||
markBegin = 37,
|
||||
markEnd = 38,
|
||||
copy = 39,
|
||||
pasteInsert = 40,
|
||||
pasteReplace = 41,
|
||||
pasteOverwrite = 42,
|
||||
shiftDelete = 43,
|
||||
clean = 44,
|
||||
playChannelOnScreen = 45,
|
||||
playChannelAll = 46,
|
||||
redo = 47,
|
||||
addInstrument = 48,
|
||||
edit = 49,
|
||||
setInstrument = 50,
|
||||
delInstrument = 51,
|
||||
tempoBox = 52,
|
||||
volumeBox = 53,
|
||||
meter = 54,
|
||||
play = 55,
|
||||
playOrigin = 56,
|
||||
ok = 57,
|
||||
upOneLevel = 58,
|
||||
delete = 59,
|
||||
chooseFolder = 60,
|
||||
openFile = 61,
|
||||
pleaseWait = 62,
|
||||
updatingList = 63,
|
||||
saveInThisFolder = 64,
|
||||
insertTempo = 65,
|
||||
deleteTempo = 66,
|
||||
tempo = 67,
|
||||
time = 68,
|
||||
seek = 69,
|
||||
numerator = 70,
|
||||
denominator = 71,
|
||||
meterInfo = 72,
|
||||
delta = 73,
|
||||
playStop = 74,
|
||||
playAll = 75,
|
||||
playScreen = 76,
|
||||
trackAll = 77,
|
||||
trackScreen = 78,
|
||||
mark = 79,
|
||||
unmark = 80,
|
||||
modifyBlock = 81,
|
||||
modifyMode = 82,
|
||||
paste = 83,
|
||||
insert = 84,
|
||||
replace = 85,
|
||||
blend = 86,
|
||||
removeSelection = 87,
|
||||
help = 88,
|
||||
keymap = 89,
|
||||
quickCommands = 90,
|
||||
navigation = 91,
|
||||
numkeysOptionString = 92,
|
||||
iconsOptionString = 93;
|
||||
|
||||
|
||||
/** Ìàññèâ òåêñòîâûõ ìåòîê */
|
||||
public static String[] str, instr;
|
||||
|
||||
/**
|
||||
* Ïðî÷èòàòü ÿçûêîâîé ðåñóðñ
|
||||
* @param lang èìÿ ëîêàëèçàöèè (en, ru)
|
||||
* @param appLang ÷èòàòü ÿçûêîâîé ðåñóðñ ïðèëîæåíèÿ (true), èíñòðóìåíòîâ (false)
|
||||
*/
|
||||
public static void readLang(String lang, boolean appLang) {
|
||||
try {
|
||||
final String path = (appLang ? "strings" : "instr") + "_";
|
||||
System.out.println("/lang/" + path + lang + ".loc");
|
||||
BufDataInputStream bdis = new BufDataInputStream(Runtime.getRuntime().getClass().getResourceAsStream("/lang/" + path + lang + ".loc"));
|
||||
if (!bdis.checkBOM()) {
|
||||
bdis.close();
|
||||
}
|
||||
char c = ' ';
|
||||
Vector v = new Vector();
|
||||
StringBuffer s;
|
||||
while (bdis.available() > 0) {
|
||||
s = new StringBuffer();
|
||||
do {
|
||||
c = bdis.readCharUTF();
|
||||
if (c == '\n') {
|
||||
break;
|
||||
}
|
||||
s.append(c);
|
||||
} while (bdis.available() > 0);
|
||||
v.addElement(s.toString());
|
||||
}
|
||||
if(appLang) {
|
||||
str = new String[v.size()];
|
||||
v.copyInto(str);
|
||||
} else {
|
||||
instr = new String[v.size()];
|
||||
v.copyInto(instr);
|
||||
}
|
||||
bdis.close();
|
||||
v = null;
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -5,27 +5,40 @@
|
||||
|
||||
import javax.microedition.lcdui.*;
|
||||
import javax.microedition.midlet.*;
|
||||
import midedit.CompositionForm;
|
||||
import midedit.MixerModel;
|
||||
|
||||
/**
|
||||
* @author aNNiMON
|
||||
*/
|
||||
public class Main extends MIDlet {
|
||||
|
||||
public Display dsp;
|
||||
public static Display dsp;
|
||||
public static Main midlet;
|
||||
|
||||
public Menu menu;
|
||||
public MixerModel model;
|
||||
public CompositionForm compositionForm;
|
||||
|
||||
public Main() {
|
||||
midlet = Main.this;
|
||||
dsp = Display.getDisplay(Main.this);
|
||||
}
|
||||
|
||||
public void startApp() {
|
||||
Rms.restoreOptions();
|
||||
L.readLang(Rms.languageApp, true);
|
||||
menu = new Menu();
|
||||
model = new MixerModel();
|
||||
dsp.setCurrent(menu);
|
||||
}
|
||||
|
||||
public void pauseApp() {
|
||||
}
|
||||
|
||||
public void destroyApp(boolean ex) {
|
||||
if(Rms.firstStart) Rms.firstStart = false;
|
||||
Rms.saveOptions();
|
||||
notifyDestroyed();
|
||||
}
|
||||
}
|
||||
|
243
src/Menu.java
Normal file
243
src/Menu.java
Normal file
@ -0,0 +1,243 @@
|
||||
import java.io.IOException;
|
||||
import javax.microedition.lcdui.*;
|
||||
import midedit.MixerModel;
|
||||
|
||||
/**
|
||||
* Ìåíþ â ïðîãðàììå
|
||||
* @author aNNiMON
|
||||
*/
|
||||
public class Menu extends Canvas {
|
||||
|
||||
/** Êîë-âî èêîíîê ìåíþ */
|
||||
private static final int MAX_MENU_ICONS = 9;
|
||||
/** ID èêîíîê */
|
||||
private static final int CREATE_NEW = 0;
|
||||
private static final int RESUME = 1;
|
||||
private static final int OPEN = 2;
|
||||
private static final int SAVE = 3;
|
||||
private static final int SAVE_AS = 4;
|
||||
private static final int RMS_FS = 5;
|
||||
private static final int OPTIONS = 6;
|
||||
private static final int ABOUT = 7;
|
||||
private static final int EXIT = 8;
|
||||
|
||||
/** Ðàçìåð ýêðàíà */
|
||||
private int w, h;
|
||||
/** Ïðåäûäóùèé ýêðàí, êóäà áóäåì âîçâðàùàòüñÿ ïðè íàæàòèè Íàçàä */
|
||||
private Displayable pr;
|
||||
|
||||
/** Ìåíþ */
|
||||
private String[] menu;
|
||||
/** Âûäåëåííûé ïóíêò ìåíþ */
|
||||
private int cu = 0;
|
||||
|
||||
/** Èêîíêè */
|
||||
private Image[] icons;
|
||||
|
||||
private final int iconsSize;
|
||||
|
||||
private int FileY, CursorY, stFh, startPrintFile;
|
||||
private int FILE_HEIGHT;
|
||||
|
||||
/** Âðåìÿ äëÿ double-êëèêà â touchscreen */
|
||||
private long time;
|
||||
|
||||
/**
|
||||
* Ñîçäàòü ìåíþ ñ òèïîì mode
|
||||
*/
|
||||
public Menu() {
|
||||
setFullScreenMode(true);
|
||||
w = getWidth();
|
||||
h = getHeight();
|
||||
readImages();
|
||||
iconsSize = icons[0].getHeight();
|
||||
// Äîáàâëÿåì ïóíêòû
|
||||
menu = new String[] {
|
||||
L.str[L.create],
|
||||
L.str[L.resume],
|
||||
L.str[L.open],
|
||||
L.str[L.save],
|
||||
L.str[L.saveAs],
|
||||
L.str[L.file],
|
||||
L.str[L.options],
|
||||
L.str[L.about],
|
||||
L.str[L.exit]
|
||||
};
|
||||
FILE_HEIGHT = iconsSize + 2;//P.medPlain.getHeight() + 2;
|
||||
stFh = P.medPlain.getHeight() + P.medPlain.getHeight() / 2;
|
||||
CursorY = FileY = startPrintFile = 0;
|
||||
}
|
||||
|
||||
protected void sizeChanged(int w, int h) {
|
||||
this.w = getWidth();
|
||||
this.h = getHeight();
|
||||
super.sizeChanged(w, h);
|
||||
}
|
||||
|
||||
protected void paint(Graphics g) {
|
||||
// Î÷èñòêà ýêðàíà
|
||||
g.setColor(P.backgrnd);
|
||||
g.fillRect(0, 0, w, h);
|
||||
|
||||
String title = "MidEdit. "+Key.Platform;
|
||||
UI.drawTitle(g, title);
|
||||
UI.drawSoftBar(g, L.str[L.ok], L.str[L.exit]);
|
||||
|
||||
g.setFont(P.medBold);
|
||||
|
||||
g.setColor(P.fmback1);
|
||||
g.translate(0, stFh);
|
||||
// Êóðñîð
|
||||
g.setColor(P.obv);
|
||||
g.fillRect(-1, CursorY, w, FILE_HEIGHT-1);
|
||||
g.setColor(P.fmbord);
|
||||
g.drawRect(-1, CursorY-1, w, FILE_HEIGHT);
|
||||
|
||||
FileY = 0;
|
||||
// Âûâîäèì ïóíêòû ìåíþ
|
||||
for (int i = startPrintFile; i < menu.length; i++) {
|
||||
g.setColor(P.fmtextnc);
|
||||
final String s = menu[i];
|
||||
if (FileY == CursorY) {
|
||||
g.setColor(P.fmshadow);
|
||||
g.drawString(s, iconsSize + 4, FileY + iconsSize / 4, Graphics.TOP | Graphics.LEFT);
|
||||
g.setColor(P.fmtextcur);
|
||||
}
|
||||
|
||||
// Âûâîä èêîíîê
|
||||
int id = 0;
|
||||
if(s.equals(L.str[L.create])) id = CREATE_NEW;
|
||||
else if(s.equals(L.str[L.resume])) id = RESUME;
|
||||
else if(s.equals(L.str[L.open])) id = OPEN;
|
||||
else if(s.equals(L.str[L.save])) id = SAVE;
|
||||
else if(s.equals(L.str[L.saveAs])) id = SAVE_AS;
|
||||
else if(s.equals(L.str[L.RMS]) || s.equals(L.str[L.file])) id = RMS_FS;
|
||||
else if(s.equals(L.str[L.options])) id = OPTIONS;
|
||||
else if(s.equals(L.str[L.about])) id = ABOUT;
|
||||
else if(s.equals(L.str[L.exit])) id = EXIT;
|
||||
|
||||
g.drawImage(icons[id], iconsSize + 2, FileY + 1, 24);
|
||||
|
||||
// Íàçâàíèå ïóíêòà
|
||||
g.drawString(s, iconsSize + 3, FileY + iconsSize / 4, Graphics.TOP | Graphics.LEFT);
|
||||
FileY += FILE_HEIGHT;
|
||||
if(FileY > (h - (stFh*2) - FILE_HEIGHT)) break;
|
||||
}
|
||||
g.setColor(0x00);
|
||||
g.fillRect(-1, FileY+1, w+1, 2);
|
||||
g.fillRect(-1, -2, w+1, 2);
|
||||
g.translate(0, -stFh);
|
||||
}
|
||||
|
||||
/**
|
||||
* Îáðàáîòêà âûáðàííûõ ïóíêòîâ
|
||||
* @param selected ID âûáðàííîãî ïóíêòà ìåíþ
|
||||
*/
|
||||
private void selectItem(int selected) {
|
||||
String v = menu[selected];
|
||||
/*if(v.equals(L.str[L.create])) Main.dsp.setCurrent(new CreateNew(this));
|
||||
else */if(v.equals(L.str[L.open])) Main.dsp.setCurrent(new FileManager(P.path, MixerModel.getLocalFile()));
|
||||
/*else if(v.equals(L.str[L.save])) {
|
||||
}
|
||||
else if(v.equals(L.str[L.help])) {
|
||||
TextView tv = new TextView();
|
||||
tv.openFile("/lang/help", this, L.str[L.help]);
|
||||
Main.dsp.setCurrent(tv);
|
||||
}*/
|
||||
else if(v.equals(L.str[L.about])) Main.dsp.setCurrent(new About(this));
|
||||
else if(v.equals(L.str[L.exit])) Main.midlet.destroyApp(true);
|
||||
}
|
||||
|
||||
protected void keyPressed (int key) {
|
||||
int ga = getGameAction(key);
|
||||
|
||||
if(ga==UP || ga==LEFT) {cursorUp();}
|
||||
else if(ga==DOWN || ga==RIGHT) {cursorDown();}
|
||||
else if (ga==FIRE || key==Key.leftSoftKey) selectItem(cu);
|
||||
else if (key==Key.rightSoftKey) rightSoft();
|
||||
repaint();
|
||||
}
|
||||
|
||||
protected void keyRepeated (int key) {
|
||||
keyPressed(key);
|
||||
}
|
||||
|
||||
private void rightSoft() {
|
||||
Main.midlet.destroyApp(true);
|
||||
}
|
||||
|
||||
private void cursorDown() {
|
||||
if (menu.length > 0) {
|
||||
final int maxHeight = h - 2 * stFh;
|
||||
if (cu == menu.length - 1) {
|
||||
CursorY = 0;
|
||||
cu = 0;
|
||||
startPrintFile = 0;
|
||||
} else if (cu > (maxHeight / FILE_HEIGHT - 3) ) {
|
||||
if (CursorY >= (maxHeight - 2 * FILE_HEIGHT)) {
|
||||
startPrintFile++;
|
||||
cu++;
|
||||
} else {
|
||||
cu++;
|
||||
CursorY += FILE_HEIGHT;
|
||||
}
|
||||
} else {
|
||||
CursorY += FILE_HEIGHT;
|
||||
cu++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void cursorUp() {
|
||||
if (menu.length > 0) {
|
||||
if (cu == 0) {
|
||||
cu = menu.length - 1;
|
||||
final int maxHeight = h - 2 * stFh;
|
||||
if (menu.length > ( (maxHeight - FILE_HEIGHT) / FILE_HEIGHT)) {
|
||||
startPrintFile = (menu.length - ( maxHeight / FILE_HEIGHT));
|
||||
CursorY = (cu - startPrintFile) * FILE_HEIGHT;
|
||||
} else {
|
||||
CursorY = cu * FILE_HEIGHT;
|
||||
}
|
||||
} else if ((CursorY == 0) && (cu > 0)) {
|
||||
startPrintFile--;
|
||||
cu--;
|
||||
} else if (CursorY > 0) {
|
||||
CursorY -= FILE_HEIGHT;
|
||||
cu--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ïîëó÷èòü èçîáðàæåíèÿ èêîíîê ìåíþ
|
||||
*/
|
||||
private void readImages() {
|
||||
icons = new Image[MAX_MENU_ICONS];
|
||||
for (int i = 0; i < icons.length; i++) {
|
||||
try {
|
||||
icons[i] = Image.createImage("/img/main/"+i+".png");
|
||||
} catch (IOException ioe) {
|
||||
icons[i] = Image.createImage(1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void pointerPressed(int pix, int piy) {
|
||||
int q = UI.getSoftBarHeight();
|
||||
if(pix<2*q && piy>h-q) selectItem(cu);
|
||||
else if(pix>w-2*q && piy>h-q) rightSoft();
|
||||
else {
|
||||
int cu1 = cu;
|
||||
piy -= 2*P.medPlain.getHeight();
|
||||
if(piy>0 && piy<menu.length*FILE_HEIGHT) {
|
||||
cu = piy/FILE_HEIGHT;
|
||||
CursorY = cu * FILE_HEIGHT;
|
||||
}
|
||||
if(System.currentTimeMillis()-time<700 && cu1==cu) selectItem(cu);
|
||||
time = System.currentTimeMillis();
|
||||
}
|
||||
repaint();
|
||||
}
|
||||
|
||||
}
|
45
src/P.java
Normal file
45
src/P.java
Normal file
@ -0,0 +1,45 @@
|
||||
import java.util.Random;
|
||||
import javax.microedition.lcdui.*;
|
||||
|
||||
/**
|
||||
* Êëàññ ïàðàìåòðîâ
|
||||
* @author aNNiMON
|
||||
*/
|
||||
public class P {
|
||||
|
||||
/** Ìàëåíüêèé øðèôò */
|
||||
public static final Font smPlain = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL);
|
||||
/** Æèðíûé ìàëåíüêèé øðèôò */
|
||||
public static final Font smBold = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_SMALL);
|
||||
/** Ñðåäíèé øðèôò */
|
||||
public static final Font medPlain = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_MEDIUM);
|
||||
/** Æèðíûé ñðåäíèé øðèôò */
|
||||
public static final Font medBold = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_MEDIUM);
|
||||
|
||||
/** Ïóòü â ôàéë-ìåíåäæåðå */
|
||||
public static String path = "/";
|
||||
|
||||
|
||||
public static Random rnd = new Random();
|
||||
|
||||
//ñêèíû
|
||||
//title and soft
|
||||
public static int colup = 0xD01C712F;
|
||||
public static int coldn = 0xD0093A14;
|
||||
//selection (lang)
|
||||
public static int selup = 0x1B991B;
|
||||
public static int seldn = 0x646464;
|
||||
//çàäíèé ôîí
|
||||
public static int backgrnd = 0xEEEEEE;
|
||||
//îáâîäêà
|
||||
public static int obv = 0x005804;
|
||||
// ôì
|
||||
public static int fmback1 = 0x222222;
|
||||
public static int fmtextcur = 0xD8C922;
|
||||
public static int fmtextnc = 0x296321;
|
||||
public static int fmbord = 0x008909;
|
||||
public static int fmshadow = 0x282828;
|
||||
public static int fmcurbord = 0xA89C1A;
|
||||
public static int fmtextuppan = 0xE0FFFA;
|
||||
|
||||
}
|
76
src/Rms.java
Normal file
76
src/Rms.java
Normal file
@ -0,0 +1,76 @@
|
||||
|
||||
|
||||
|
||||
import java.io.*;
|
||||
import javax.microedition.rms.*;
|
||||
|
||||
/**
|
||||
* Êëàññ ñîõðàíåíèÿ íàñòðîåê
|
||||
* @author aNNiMON
|
||||
*/
|
||||
public class Rms {
|
||||
|
||||
private static final String rmsName = "MidEdit_2_1";
|
||||
private static RecordStore rmsStore;
|
||||
|
||||
// Ïàðàìåòðû
|
||||
public static boolean firstStart = true; // ïåðâûé ñòàðò
|
||||
public static String languageApp = "en"; // ÿçûê ïðîãðàììû
|
||||
public static String languageInstr = "en"; // ÿçûê èíñòðóìåíòîâ
|
||||
|
||||
/**
|
||||
* Ñîõðàíåíèå íàñòðîåê
|
||||
*/
|
||||
public static void saveOptions() {
|
||||
if (rmsStore != null) {
|
||||
byte[] options = null;
|
||||
try {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
DataOutputStream dos = new DataOutputStream(baos);
|
||||
dos.writeBoolean(firstStart);
|
||||
dos.writeUTF(languageApp);
|
||||
dos.writeUTF(languageInstr);
|
||||
dos.flush();
|
||||
options = baos.toByteArray();
|
||||
dos.close();
|
||||
rmsStore.setRecord(1, options, 0, options.length);
|
||||
} catch (InvalidRecordIDException ridex) {
|
||||
try {
|
||||
rmsStore.addRecord(options, 0, options.length);
|
||||
} catch (RecordStoreException ex) {
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
}
|
||||
if (rmsStore != null) {
|
||||
try {
|
||||
rmsStore.closeRecordStore();
|
||||
rmsStore = null;
|
||||
} catch (RecordStoreException ex) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Âîññòàíîâèòü íàñòðîéêè
|
||||
* Ïóñòûå dis.readBoolean() îñòàâëåíû äëÿ ñîâìåñòèìîñòè ñ ïðîøëûìè âåðñèÿìè
|
||||
*/
|
||||
public static void restoreOptions() {
|
||||
try {
|
||||
rmsStore = RecordStore.openRecordStore(rmsName, true);
|
||||
} catch (RecordStoreException ex) {
|
||||
rmsStore = null;
|
||||
}
|
||||
if (rmsStore != null) {
|
||||
try {
|
||||
DataInputStream dis = new DataInputStream(new ByteArrayInputStream(rmsStore.getRecord(1)));
|
||||
firstStart = dis.readBoolean(); // ïåðâûé ðàç çàïóùåí
|
||||
languageApp = dis.readUTF();
|
||||
languageInstr = dis.readUTF();
|
||||
dis.close();
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
51
src/StringEncoder.java
Normal file
51
src/StringEncoder.java
Normal file
@ -0,0 +1,51 @@
|
||||
|
||||
|
||||
public class StringEncoder {
|
||||
|
||||
protected static char cp1251[] = {
|
||||
'\u0410', '\u0411', '\u0412', '\u0413', '\u0414', '\u0415', '\u0416',
|
||||
'\u0417', '\u0418', '\u0419', '\u041A', '\u041B', '\u041C', '\u041D',
|
||||
'\u041E', '\u041F', '\u0420', '\u0421', '\u0422', '\u0423', '\u0424',
|
||||
'\u0425', '\u0426', '\u0427', '\u0428', '\u0429', '\u042A', '\u042B',
|
||||
'\u042C', '\u042D', '\u042E', '\u042F', '\u0430', '\u0431', '\u0432',
|
||||
'\u0433', '\u0434', '\u0435', '\u0436', '\u0437', '\u0438', '\u0439',
|
||||
'\u043A', '\u043B', '\u043C', '\u043D', '\u043E', '\u043F', '\u0440',
|
||||
'\u0441', '\u0442', '\u0443', '\u0444', '\u0445', '\u0446', '\u0447',
|
||||
'\u0448', '\u0449', '\u044A', '\u044B', '\u044C', '\u044D', '\u044E',
|
||||
'\u044F'
|
||||
};
|
||||
|
||||
public static char decodeCharCP1251(byte b) {
|
||||
int ich = b & 0xff;
|
||||
if (ich == 0xb8) // ¸
|
||||
{
|
||||
return 0x0451;
|
||||
} else if (ich == 0xa8) // ¨
|
||||
{
|
||||
return 0x0401;
|
||||
} else if (ich >= 0xc0) {
|
||||
return cp1251[ich - 192];
|
||||
}
|
||||
return (char) ich;
|
||||
}
|
||||
|
||||
/** Êîäèðîâàòü ñèìâîë â windows-1251 */
|
||||
public static byte encodeCharCP1251(char ch) {
|
||||
if (ch > 0 && ch < 128) {
|
||||
return (byte) ch;
|
||||
} else if (ch == 0x401) {
|
||||
return -88; // ¨
|
||||
} else if (ch == 0x404) {
|
||||
return -86; // ª
|
||||
} else if (ch == 0x407) {
|
||||
return -81; // ¯
|
||||
} else if (ch == 0x451) {
|
||||
return -72; // ¸
|
||||
} else if (ch == 0x454) {
|
||||
return -70; // º
|
||||
} else if (ch == 0x457) {
|
||||
return -65; // ¿
|
||||
}
|
||||
return (byte) ((byte) (ch) + 176);
|
||||
}
|
||||
}
|
271
src/UI.java
Normal file
271
src/UI.java
Normal file
@ -0,0 +1,271 @@
|
||||
import java.util.Calendar;
|
||||
import javax.microedition.lcdui.*;
|
||||
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* @author aNNiMON
|
||||
*/
|
||||
public class UI {
|
||||
|
||||
/** Øðèôò çàãîëîâêîâ è ñîôò-áàðà */
|
||||
private static final Font smallFont = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL);
|
||||
/** Âûñîòà ñîôò-áàðà */
|
||||
private static final int softBarHeight = smallFont.getHeight() + 2;
|
||||
|
||||
/**
|
||||
* Îòðèñîâêà ñîôò-áàðà
|
||||
* @param g êîíòåêñò ãðàôèêè
|
||||
* @param left íàäïèñü íà ëåâîì ñîôòå
|
||||
* @param right íàäïèñü íà ïðàâîì ñîôòå
|
||||
*/
|
||||
public static void drawSoftBar(Graphics g, String left, String right) {
|
||||
final int w = g.getClipWidth();
|
||||
final int h = g.getClipHeight() - 1;
|
||||
final int w2 = w / 2;
|
||||
drawHGradient(g, P.coldn, P.colup, 0, h - softBarHeight - 1, w2, softBarHeight + 2);
|
||||
drawHGradient(g, P.colup, P.coldn, w2, h - softBarHeight - 1, w2, softBarHeight + 2);
|
||||
g.setColor(0);
|
||||
g.drawLine(0, h - softBarHeight - 2, w, h - softBarHeight - 2);
|
||||
g.setFont(smallFont);
|
||||
g.setColor(0xFFFFFF);
|
||||
g.drawString(left, 3, h, Graphics.LEFT | Graphics.BOTTOM);
|
||||
g.drawString(right, w - 3, h, Graphics.RIGHT | Graphics.BOTTOM);
|
||||
g.setColor(P.backgrnd);
|
||||
g.drawString(getTime(), w2, h, Graphics.HCENTER | Graphics.BOTTOM);
|
||||
}
|
||||
|
||||
/**
|
||||
* Îòðèñîâêà çàãîëîâêà
|
||||
* @param g êîíòåêñò ãðàôèêè
|
||||
* @param title íàäïèñü çàãîëîâêà
|
||||
*/
|
||||
public static void drawTitle(Graphics g, String title) {
|
||||
final int w = g.getClipWidth();
|
||||
drawVGradient(g, P.colup, P.coldn, 0, 0, w, softBarHeight);
|
||||
g.setColor(P.colup);
|
||||
g.drawLine(0, softBarHeight, w, softBarHeight);
|
||||
g.setFont(smallFont);
|
||||
g.setColor(0xFFFFFF);
|
||||
g.drawString(title, w / 2, softBarHeight, Graphics.HCENTER | Graphics.BOTTOM);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Îòðèñîâêà èíòåðôåéñà îêíà
|
||||
* @param g êîíòåêñò ãðàôèêè
|
||||
* @param title íàäïèñü çàãîëîâêà
|
||||
* @param rightsoft íàäïèñü íà ïðàâîì ñîôòå
|
||||
*/
|
||||
public static void drawMenuInterface(Graphics g, String title, String rightsoft) {
|
||||
drawTitle(g, title);
|
||||
drawSoftBar(g, "", rightsoft);
|
||||
}
|
||||
|
||||
/**
|
||||
* Îòðèñîâêà ñîñòîÿíèÿ ïî ìàññèâó (â ýôôåòêàõ)
|
||||
* @param g êîíòåêñò ãðàôèêè
|
||||
* @param dd ìàññèâ ñî çíà÷åíèÿìè
|
||||
*/
|
||||
public static void drawStatusBar(Graphics g, int[] dd) {
|
||||
drawStatusBar(g, Math.abs(dd[0]) + dd[1], Math.abs(dd[2]) + Math.abs(dd[0]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Îòðèñîâêà ñîñòîÿíèÿ ïî ìàññèâó (â ýôôåòêàõ)
|
||||
* @param g êîíòåêñò ãðàôèêè
|
||||
* @param cur òåêóùåå ñîñòîÿíèå
|
||||
* @param all âñåãî
|
||||
*/
|
||||
private static void drawStatusBar(Graphics g, int cur, int all) {
|
||||
int w = g.getClipWidth();
|
||||
int h = g.getClipHeight();
|
||||
int sw = w / 20;
|
||||
int sh = h - h / 20;
|
||||
g.setColor(0x00);
|
||||
g.drawRect(w - 2 * sw - 1, h/25 - 1, sw + 1, sh + 1);
|
||||
int curr = (cur * sh) / all;
|
||||
drawRect(g, P.colup, P.coldn, w - 2 * sw, (h/25 + (sh - curr)), sw, sh - (sh - curr));
|
||||
}
|
||||
|
||||
/**
|
||||
* Ïîëó÷èòü âûñîòó øðèôòà.
|
||||
* @return âûñîòà soft- è title- áàðà
|
||||
*/
|
||||
public static int getSoftBarHeight() {
|
||||
return softBarHeight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ïîëó÷èòü âðåìÿ
|
||||
* @return ñòðîêà ñ âðåìåíåì âèäà: HH:MM
|
||||
*/
|
||||
private static String getTime() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
Calendar cal = Calendar.getInstance();
|
||||
int tmp = cal.get(Calendar.HOUR_OF_DAY);
|
||||
if(tmp <= 9) sb.append('0');
|
||||
sb.append(tmp);
|
||||
sb.append(':');
|
||||
//Ìèíóòà
|
||||
tmp = cal.get(Calendar.MINUTE);
|
||||
if(tmp <= 9) sb.append('0');
|
||||
sb.append(tmp);
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Îðòèñîâêà íåïðîçðà÷íîãî ãðàäèåíòà
|
||||
* @param g êîíòåêñò ãðàôèêè
|
||||
* @param color1 âåðõíèé öâåò ãðàäèåíòà
|
||||
* @param color2 íèæíèé öâåò ãðàäèåíòà
|
||||
* @param x1 X
|
||||
* @param y1 Y
|
||||
* @param w øèðèíà
|
||||
* @param h âûñîòà
|
||||
*/
|
||||
public static void drawRect(Graphics g, int color1, int color2, int x1, int y1, int w, int h) {
|
||||
// Åñëè öâåòà îäèíàêîâû, òî ãðàäèåíò íàì íå íóæåí
|
||||
if(color1 == color2) {
|
||||
g.setColor(color1);
|
||||
g.fillRect(x1, y1, w, h);
|
||||
return;
|
||||
} else {
|
||||
drawVGradient(g, color1, color2, x1, y1, w, h);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Îðòèñîâêà ïðîçðà÷íîãî ãðàäèåíòà
|
||||
* @param g êîíòåêñò ãðàôèêè
|
||||
* @param color1 âåðõíèé öâåò ãðàäèåíòà
|
||||
* @param color2 íèæíèé öâåò ãðàäèåíòà
|
||||
* @param x1 X
|
||||
* @param y1 Y
|
||||
* @param w øèðèíà
|
||||
* @param h âûñîòà
|
||||
*/
|
||||
private static void drawRGB(Graphics g, int color1, int color2, int x1, int y1, int w, int h) {
|
||||
int a1 = (color1 >> 24) & 0xff;
|
||||
int a2 = (color2 >> 24) & 0xff;
|
||||
if(a1>253 && a2>253) {
|
||||
drawRect(g, color1, color2, x1, y1, w, h);
|
||||
return;
|
||||
}
|
||||
|
||||
int r1 = (color1 >> 16) & 0xff;
|
||||
int g1 = (color1 >> 8) & 0xff;
|
||||
int b1 = color1 & 0xff;
|
||||
|
||||
int r2 = (color2 >> 16) & 0xff;
|
||||
int g2 = (color2 >> 8) & 0xff;
|
||||
int b2 = color2 & 0xff;
|
||||
|
||||
int count = h/3;
|
||||
if (count<0) count=-count;
|
||||
if (count<8) count = 8;
|
||||
int crd1, crd2;
|
||||
|
||||
for (int i = count - 1; i >= 0; i--) {
|
||||
crd1 = i * h / count + y1;
|
||||
crd2 = (i + 1) * h / count + y1;
|
||||
if (crd1 == crd2) continue;
|
||||
int[] pixelArray = new int[w * (crd2 - crd1)];
|
||||
int color = (i * (a2 - a1) / (count - 1) + a1) << 24 |
|
||||
((i * (r2 - r1) / (count - 1) + r1) << 16) |
|
||||
((i * (g2 - g1) / (count - 1) + g1) << 8) |
|
||||
(i * (b2 - b1) / (count - 1) + b1);
|
||||
for (int zi = 0; zi < pixelArray.length; zi++) {
|
||||
pixelArray[zi] = color;
|
||||
}
|
||||
g.drawRGB(pixelArray, 0, w, x1, crd1, w, crd2 - crd1, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Îòðèñîâêà âåðòèêàëüíîãî ãðàäèåíòà
|
||||
* @param graphics êîíòåêñò ãðàôèêè
|
||||
* @param rgb1 âåðõíèé öâåò ãðàäèåíòà
|
||||
* @param rgb2 íèæíèé öâåò ãðàäèåíòà
|
||||
* @param xn X
|
||||
* @param yn Y
|
||||
* @param wdh øèðèíà
|
||||
* @param hgt âûñîòà
|
||||
*/
|
||||
private static void drawVGradient(Graphics graphics, int rgb1, int rgb2, int xn, int yn, int wdh, int hgt) {
|
||||
// Ïåðâûé öâåò
|
||||
int r1 = acolor(rgb1, 'r');
|
||||
int g1 = acolor(rgb1, 'g');
|
||||
int b1 = acolor(rgb1, 'b');
|
||||
// Ðàçíèöà ìåæäó âòîðûì è ïåðâûì öâåòîì
|
||||
int deltaR = acolor(rgb2, 'r') - r1;
|
||||
int deltaG = acolor(rgb2, 'g') - g1;
|
||||
int deltaB = acolor(rgb2, 'b') - b1;
|
||||
try {
|
||||
wdh += xn;
|
||||
hgt += yn;
|
||||
final int deltaHeight = hgt - yn - 1;
|
||||
for (int i = yn; i < hgt; i++) {
|
||||
int r = r1 + ((i - hgt + 1) * deltaR) / deltaHeight + deltaR;
|
||||
int g = g1 + ((i - hgt + 1) * deltaG) / deltaHeight + deltaG;
|
||||
int b = b1 + ((i - hgt + 1) * deltaB) / deltaHeight + deltaB;
|
||||
graphics.setColor(r, g, b);
|
||||
graphics.drawLine(xn, i, wdh - 1, i);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Îòðèñîâêà ãîðèçîíòàëüíîãî ãðàäèåíòà
|
||||
* @param graphics êîíòåêñò ãðàôèêè
|
||||
* @param rgb1 âåðõíèé öâåò ãðàäèåíòà
|
||||
* @param rgb2 íèæíèé öâåò ãðàäèåíòà
|
||||
* @param xn X
|
||||
* @param yn Y
|
||||
* @param wdh øèðèíà
|
||||
* @param hgt âûñîòà
|
||||
*/
|
||||
private static void drawHGradient(Graphics graphics, int rgb1, int rgb2, int xn, int yn, int wdh, int hgt) {
|
||||
int r, g, b;
|
||||
r = g = b = 0;
|
||||
// Ïåðâûé öâåò
|
||||
int r1 = acolor(rgb1, 'r');
|
||||
int g1 = acolor(rgb1, 'g');
|
||||
int b1 = acolor(rgb1, 'b');
|
||||
// Ðàçíèöà ìåæäó âòîðûì è ïåðâûì öâåòîì
|
||||
int deltaR = acolor(rgb2, 'r') - r1;
|
||||
int deltaG = acolor(rgb2, 'g') - g1;
|
||||
int deltaB = acolor(rgb2, 'b') - b1;
|
||||
try {
|
||||
wdh += xn;
|
||||
hgt += yn;
|
||||
final int deltaWidth = wdh - xn - 1;
|
||||
for (int i = xn; i < wdh; i++) {
|
||||
r = r1 + ((i - wdh + 1) * deltaR) / deltaWidth + deltaR;
|
||||
g = g1 + ((i - wdh + 1) * deltaG) / deltaWidth + deltaG;
|
||||
b = b1 + ((i - wdh + 1) * deltaB) / deltaWidth + deltaB;
|
||||
graphics.setColor(r, g, b);
|
||||
graphics.drawLine(i, yn, i, hgt - 1);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ïîëó÷èòü öâåò íóæíîãî êàíàëà â ïèêñåëå
|
||||
* @param argb ïèêñåëü
|
||||
* @param c ñèìâîëüíûé ïàðàìåòð - íàçâàíèå êàíàëà (a, r, g, b)
|
||||
* @return
|
||||
*/
|
||||
private static int acolor(int argb, char c) {
|
||||
if(c=='r') return ((argb >> 16) & 0xff);
|
||||
else if(c=='g') return ((argb >> 8) & 0xff);
|
||||
else if(c=='b') return (argb & 0xff);
|
||||
else if(c=='a') return ((argb >> 24) & 0xff);
|
||||
else return argb;
|
||||
}
|
||||
}
|
@ -14,27 +14,7 @@ import java.util.Vector;
|
||||
*/
|
||||
public class Constants
|
||||
{
|
||||
// private static Hashtable hashInstrums ;
|
||||
/**
|
||||
public Constants()
|
||||
{
|
||||
//instruments = getInstruments();
|
||||
// hashInstrums= new Hashtable(129);
|
||||
// for(int i=0; i<instruments.length; ++i)
|
||||
// hashInstrums.put(Settings.instrStrings[i], new Integer(i));
|
||||
}
|
||||
|
||||
* @param s
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
// public int getInstrumInd(String s) throws Exception
|
||||
// {
|
||||
// Integer intVal = (Integer)hashInstrums.get(s);
|
||||
// if(intVal == null)
|
||||
// throw new Exception("intVal == null");
|
||||
// return intVal.intValue();
|
||||
// }
|
||||
/**
|
||||
*
|
||||
* @param index
|
||||
@ -131,8 +111,8 @@ public class Constants
|
||||
"<#> ",getStringName(49),
|
||||
};
|
||||
static VectorArr instrVectorArr=new VectorArr(Settings.parserInstr.stringResourses, 1, 128);
|
||||
}
|
||||
class VectorArr extends Vector {
|
||||
|
||||
static class VectorArr extends Vector {
|
||||
public VectorArr(Object src, int beg, int length) {
|
||||
super(length);
|
||||
setSize(length);
|
||||
@ -140,3 +120,4 @@ class VectorArr extends Vector {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -51,9 +51,9 @@ public class FileChooser extends List implements CommandListener, Runnable {
|
||||
if (isSave) {
|
||||
saveThis = new Command(Constants.getStringName(66), Command.SCREEN, 0);
|
||||
this.addCommand(saveThis);
|
||||
}
|
||||
else if (MixerModel.isRMSMode)
|
||||
} else if (MixerModel.isRMSMode)
|
||||
this.addCommand(delete);
|
||||
|
||||
this.addCommand(Settings.comCancel);
|
||||
this.setCommandListener(this);
|
||||
updateView();
|
||||
|
@ -14,7 +14,7 @@ public class Settings implements CommandListener {
|
||||
//RMSFile rmsFile = new RMSFile();
|
||||
static String[] langList = {"en", "ru"};
|
||||
Image[] langImgs = {createImg("/img/en_GB.png"), createImg("/img/ru_RU.png")},
|
||||
controlImgs = {createImg("/img/keyPad.png"), createImg("/img/iconsMenu.png")};
|
||||
controlImgs = {createImg("/img/keyPad.png"), createImg("/img/icon.png")};
|
||||
ChoiceGroup langChoice = new ChoiceGroup("Language", 1, langList, langImgs),
|
||||
langInstr = new ChoiceGroup("Instruments Language", 1, langList, langImgs),
|
||||
controlChoice;// = new ChoiceGroup("Controls", 1, controlList, controlImgs);
|
||||
|
@ -18,9 +18,8 @@ public abstract class AbstractFile {
|
||||
*
|
||||
* @param pathName
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
public abstract String[] list(String pathName) throws IOException;
|
||||
public abstract String[] list(String pathName);
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -18,49 +18,34 @@ public class JSR75File extends AbstractFile {
|
||||
private String lastFileURL = null;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param pathName
|
||||
* @return
|
||||
* @throws IOException
|
||||
* Ïîëó÷èòü ñïèñîê ôàéëîâ â ïàïêå path
|
||||
* @param pathName ïóòü ê ïàïêå
|
||||
* @return ìàññèâ ñ îòñîðòèðîâàííûì ñïèñêîì ôàéëîâ
|
||||
*/
|
||||
public String[] list(String pathName) throws IOException {
|
||||
public String[] list(String pathName) {
|
||||
lastPath = pathName;
|
||||
Enumeration e;
|
||||
Vector vector = new Vector();
|
||||
Enumeration en;
|
||||
try {
|
||||
FileConnection currDir = null;
|
||||
|
||||
|
||||
if (pathName.equals("/")) {
|
||||
e = FileSystemRegistry.listRoots();
|
||||
lastPath = "/";
|
||||
} else {
|
||||
currDir = (FileConnection) Connector.open(getPrefix() + pathName);
|
||||
if (currDir.exists() && currDir.isDirectory()) {
|
||||
e = currDir.list();
|
||||
lastPath = pathName;
|
||||
} else {
|
||||
e = FileSystemRegistry.listRoots();
|
||||
lastPath = "/";
|
||||
// Äëÿ ïîëó÷åíèÿ ñïèñêà äèñêîâ èñïîëüçóåì FileSystemRegistry
|
||||
if ("/".equals(pathName)) en = FileSystemRegistry.listRoots();
|
||||
else {
|
||||
// Äëÿ îñòàëüíûõ ïàïîê - îáû÷íûé FileConnection
|
||||
currDir = (FileConnection) Connector.open("file://" + pathName, Connector.READ);
|
||||
en = currDir.list();
|
||||
}
|
||||
// Ïåðåìåùàåì ñïèñîê â âåêòîð
|
||||
while(en.hasMoreElements()) {
|
||||
String s1 = (String) en.nextElement();
|
||||
vector.addElement(s1);
|
||||
}
|
||||
|
||||
|
||||
if (e == null) {
|
||||
throw new IOException("e==null");
|
||||
if (currDir != null) currDir.close();
|
||||
} catch (IOException ion) {
|
||||
ion.printStackTrace();
|
||||
}
|
||||
|
||||
Vector v = new Vector();
|
||||
for (; e.hasMoreElements();) {
|
||||
v.addElement(e.nextElement());
|
||||
}
|
||||
String[] listFile = new String[v.size()];
|
||||
int i;
|
||||
Enumeration enumer;
|
||||
for (i = 0, enumer = v.elements(); i < listFile.length; ++i) {
|
||||
listFile[i] = (String) (enumer.nextElement());
|
||||
}
|
||||
|
||||
|
||||
return listFile;
|
||||
// Ñîðòèðóåì è âîçâðàùàåì ñïèñîê
|
||||
return bubbleSort(vector);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -281,4 +266,50 @@ public class JSR75File extends AbstractFile {
|
||||
public String getAns() {
|
||||
return "save ok";
|
||||
}
|
||||
|
||||
/**
|
||||
* Ïóçûðüêîâàÿ ñîðòèðîâêà.
|
||||
* Ñîðòèðóåò ïî èìåíè, à ïîòîì ïîäûìàåò ïàïêè â íà÷àëî
|
||||
* @param files âåêòîð ñî ñïèñêîì èì¸í ôàéëîâ è ïàïîê
|
||||
* @param reverse true - ñîðòèðîâêà ïî óáûâàíèþ
|
||||
* @return
|
||||
*/
|
||||
private static String[] bubbleSort(Vector files) {
|
||||
String tmp;
|
||||
for (int i = files.size() - 1; i >= 0; i--) {
|
||||
for (int j = 0; j < i; j++) {
|
||||
if ((tmp = (String) files.elementAt(j)).toLowerCase().compareTo(((String) files.elementAt(j + 1)).toLowerCase()) > 0) {
|
||||
files.setElementAt((String) files.elementAt(j + 1), j);
|
||||
files.setElementAt(tmp, j + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
String[] arr = sortFiles(files);
|
||||
return arr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ñîðòèðîâêà ôàéëîâ.
|
||||
* Ïàïêè ïîäíèìàþòñÿ â íà÷àëî ñïèñêà, îñòàëüíûå ôàéëû íå òðîãàþòñÿ.
|
||||
* @param files âåêòîð ñî ñïèñêîì èì¸í ôàéëîâ è ïàïîê
|
||||
* @return ìàññèâ ñ îòñîðòèðîâàííûì ñïèñêîì
|
||||
*/
|
||||
private static String[] sortFiles(Vector files) {
|
||||
int length = files.size();
|
||||
String[] out = new String[length];
|
||||
int i = 0;
|
||||
for (int j = 0; j < length; j++) {
|
||||
if (((String)files.elementAt(j)).indexOf("/") != -1) {
|
||||
out[i] = ((String)files.elementAt(j));
|
||||
i++;
|
||||
}
|
||||
}
|
||||
for (int k = 0; k < length; k++) {
|
||||
if (((String)files.elementAt(k)).indexOf("/") == -1) {
|
||||
out[i] = ((String)files.elementAt(k));
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ public class RMSFile extends AbstractFile {
|
||||
private RecordStore curRecordStore = null;
|
||||
private int recordID = 0;
|
||||
|
||||
public String[] list(String pathName) throws IOException {
|
||||
public String[] list(String pathName) {
|
||||
String[] fileList = RecordStore.listRecordStores();
|
||||
return fileList;
|
||||
}
|
||||
|
@ -8,4 +8,5 @@ MIDedit 2.1 / 3.0
|
||||
|
||||
******
|
||||
При первом запуске - настройки
|
||||
Help â aNMPWR
|
||||
player.realize
|
Loading…
Reference in New Issue
Block a user