[Thinlet-development] thinlet/src/midp MANIFEST.MF,NONE,1.1 ThinletDemo.jad,NONE,1.1 ThinletDemo.png
Brought to you by:
bajzat
From: <ab...@us...> - 2003-06-26 15:22:01
|
Update of /cvsroot/thinlet/thinlet/src/midp In directory sc8-pr-cvs1:/tmp/cvs-serv29772/src/midp Added Files: MANIFEST.MF ThinletDemo.jad ThinletDemo.png eventcode.txt readme.txt Log Message: New CVS layout and build infrastructure. Contributed by Campbell Boucher-Burnet. Many thanks\! --- NEW FILE: MANIFEST.MF --- MIDlet-1: Demo, /ThinletDemo.png, thinlet.midp.demo.Demo MIDlet-2: Calculator, /ThinletDemo.png, thinlet.midp.examples.calculator.Calculator MIDlet-Name: ThinletDemo MIDlet-Vendor: Sun Microsystems MIDlet-Version: 1.0 MicroEdition-Configuration: CLDC-1.0 MicroEdition-Profile: MIDP-1.0 --- NEW FILE: ThinletDemo.jad --- MIDlet-1: Demo, /ThinletDemo.png, thinlet.midp.demo.Demo MIDlet-2: Calculator, /ThinletDemo.png, thinlet.midp.calculator.Calculator MIDlet-Jar-Size: 37778 MIDlet-Jar-URL: ThinletDemo.jar MIDlet-Name: ThinletDemo MIDlet-Vendor: Sun Microsystems MIDlet-Version: 1.0 --- NEW FILE: ThinletDemo.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: eventcode.txt --- private static final int MOUSE_ENTERED = 1; private static final int MOUSE_EXITED = 2; // private static final int MOUSE_PRESSED = 3; private static final int MOUSE_DRAGGED = 4; private static final int MOUSE_RELEASED = 5; private static final int DRAG_ENTERED = 6; private static final int DRAG_EXITED = 7; protected void pointerPressed(int x, int y) { findComponent(content, x, y); if (popupowner != null) { String classname = getClass(mouseinside); if ((popupowner != mouseinside) && (classname != ":popup") && (classname != ":combolist")) { closeup(); } } handleMouseEvent(x, y, 1, false, false, false, MouseEvent.MOUSE_ENTERED, mouseinside, insidepart); mousepressed = mouseinside; pressedpart = insidepart; handleMouseEvent(x, y, 1, false, false, false, MouseEvent.MOUSE_PRESSED, mousepressed, pressedpart); } protected void pointerReleased(int x, int y) { Object mouserelease = mousepressed; Object releasepart = pressedpart; mousepressed = pressedpart = null; handleMouseEvent(x, y, 1, false, false, false, MouseEvent.MOUSE_RELEASED, mouserelease, releasepart); } protected void pointerDragged(int x, int y) { Object previnside = mouseinside; Object prevpart = insidepart; findComponent(content, x, y); boolean same = (previnside == mouseinside) && (prevpart == insidepart); boolean isin = (mousepressed == mouseinside) && (pressedpart == insidepart); boolean wasin = (mousepressed == previnside) && (pressedpart == prevpart); if (wasin && !isin) { handleMouseEvent(x, y, 1, false, false, false, MouseEvent.MOUSE_EXITED, mousepressed, pressedpart); } else if (!same && (popupowner != null) && !wasin) { handleMouseEvent(x, y, 1, false, false, false, DRAG_EXITED, previnside, prevpart); } if (isin && !wasin) { handleMouseEvent(x, y, 1, false, false, false, MouseEvent.MOUSE_ENTERED, mousepressed, pressedpart); } else if (!same && (popupowner != null) && !isin) { handleMouseEvent(x, y, 1, false, false, false, DRAG_ENTERED, mouseinside, insidepart); } if (isin == wasin) { handleMouseEvent(x, y, 1, false, false, false, MouseEvent.MOUSE_DRAGGED, mousepressed, pressedpart); } } protected void keyPressed(int keyCode) { if ((popupowner != null) || (focusowner != null)) { hideTip(); if (keyCode > 0) { processKeyPress((popupowner != null) ? popupowner : focusowner, false, false, 1, keyCode, 0); } else { int keychar = 0, key = 0; switch (getGameAction(keyCode)) { case UP: key = KeyEvent.VK_UP; break; case LEFT: key = KeyEvent.VK_LEFT; break; case DOWN: key = KeyEvent.VK_DOWN; break; case RIGHT: key = KeyEvent.VK_RIGHT; break; case FIRE: key = KeyEvent.VK_ENTER; keychar = KeyEvent.VK_SPACE; break; case GAME_A: key = KeyEvent.VK_ESCAPE; break; } if (key != 0) { processKeyPress((popupowner != null) ? popupowner : focusowner, false, false, 1, keychar, key); } //if (keyCode == getKeyCode(LEFT)) { } } } protected void keyRepeated(int keyCode) { keyPressed(keyCode); } private static final Command nextcommand = new Command("Next", Command.SCREEN, 0); //private static final Command prevcommand = new Command("Previous", Command.SCREEN, 0); { addCommand(nextcommand); //addCommand(prevcommand); setCommandListener(this); } public void commandAction(Command command, Displayable displayable) { if (command == nextcommand) { setNextFocusable(focusowner, false); repaint(focusowner); closeup(); } //else if (command == prevcommand) { //setPreviousFocusable(focusowner, null, true, true, false); //repaint(focusowner); //closeup(); //} } --- NEW FILE: readme.txt --- To make a MIDP version of Thinlet you have to compile the Converter file in this directory and run it (javac Converter.java; java Converter). Now you have the thinlet\midp\Thinlet.java file. Two simple demo application is included a calculator and a widget demo, to compile and run it you need the J2ME Wireless Toolkit. Do the followings: - create a new project (e.g. ThinletDemo) - copy MANIFEST.MF and ThinletDemo.jad to \WTK104\apps\ThinletDemo\bin - copy Thinlet.java to \WTK104\apps\ThinletDemo\src\thinlet\midp - copy calculator\Calculator.java to \WTK104\apps\ThinletDemo\src\thinlet\midp\calculator - copy demo\Demo.java to \WTK104\apps\ThinletDemo\src\thinlet\midp\demo - copy ThinletDemo.png \WTK104\apps\ThinletDemo\res - copy calculator\calculator.xml to \WTK104\apps\ThinletDemo\res\thinlet\midp\calculator - copy demo\demo.xml and demo\image.png to \WTK104\apps\ThinletDemo\res\thinlet\midp\demo The MIDP version is very similar to the J2SE version, the only difference is the event handling (because there is no reflection), you have to overwrite Thinlet's protected void handle(Object source, String action) method. |