waba-commits Mailing List for Waba Virtual Machine (Page 4)
Status: Abandoned
Brought to you by:
bornet
You can subscribe to this list here.
2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(34) |
Sep
(34) |
Oct
(86) |
Nov
(31) |
Dec
(71) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2002 |
Jan
(105) |
Feb
(23) |
Mar
(1) |
Apr
(6) |
May
(4) |
Jun
(1) |
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2003 |
Jan
(14) |
Feb
(1) |
Mar
(10) |
Apr
(60) |
May
(82) |
Jun
(22) |
Jul
(2) |
Aug
(39) |
Sep
|
Oct
(32) |
Nov
|
Dec
|
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(117) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(13) |
Update of /cvsroot/waba/waba/examples/Scribble In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv926/examples/Scribble Removed Files: DrawArea.java Makefile.am Scribble.html Scribble.java Title.java clean.bat icon.bmp make.bat Log Message: Removed old examples --- DrawArea.java DELETED --- --- Makefile.am DELETED --- --- Scribble.html DELETED --- --- Scribble.java DELETED --- --- Title.java DELETED --- --- clean.bat DELETED --- --- icon.bmp DELETED --- --- make.bat DELETED --- |
From: Manfred R. <mr...@us...> - 2004-07-10 14:34:42
|
Update of /cvsroot/waba/waba/examples/RegistryTest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv926/examples/RegistryTest Removed Files: Makefile.am RegistryTest.java SkipBytesTest.java Log Message: Removed old examples --- Makefile.am DELETED --- --- RegistryTest.java DELETED --- --- SkipBytesTest.java DELETED --- |
Update of /cvsroot/waba/waba/examples/PocketWatch In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv926/examples/PocketWatch Removed Files: Makefile.am PocketWatch.html PocketWatch.icon PocketWatch.java clean.bat icon.bmp make.bat watch.bmp Log Message: Removed old examples --- Makefile.am DELETED --- --- PocketWatch.html DELETED --- --- PocketWatch.icon DELETED --- --- PocketWatch.java DELETED --- --- clean.bat DELETED --- --- icon.bmp DELETED --- --- make.bat DELETED --- --- watch.bmp DELETED --- |
From: Manfred R. <mr...@us...> - 2004-07-10 14:34:41
|
Update of /cvsroot/waba/waba/examples/LangTest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv926/examples/LangTest Removed Files: LangTest.java Makefile.am Log Message: Removed old examples --- LangTest.java DELETED --- --- Makefile.am DELETED --- |
From: Manfred R. <mr...@us...> - 2004-07-10 14:34:41
|
Update of /cvsroot/waba/waba/examples/Controls In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv926/examples/Controls Removed Files: Controls.html Controls.java Makefile.am clean.bat icon.bmp make.bat Log Message: Removed old examples --- Controls.html DELETED --- --- Controls.java DELETED --- --- Makefile.am DELETED --- --- clean.bat DELETED --- --- icon.bmp DELETED --- --- make.bat DELETED --- |
From: Manfred R. <mr...@us...> - 2004-07-10 14:34:41
|
Update of /cvsroot/waba/waba/examples/CoreTest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv926/examples/CoreTest Removed Files: CoreTest.html CoreTest.java Makefile.am clean.bat icon.bmp make.bat test.bmp Log Message: Removed old examples --- CoreTest.html DELETED --- --- CoreTest.java DELETED --- --- Makefile.am DELETED --- --- clean.bat DELETED --- --- icon.bmp DELETED --- --- make.bat DELETED --- --- test.bmp DELETED --- |
From: Manfred R. <mr...@us...> - 2004-07-10 14:34:41
|
Update of /cvsroot/waba/waba/examples/ImageSplit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv926/examples/ImageSplit Removed Files: ImageSplit.html ImageSplit.java Makefile.am clean.bat icon.bmp make.bat taki.bmp Log Message: Removed old examples --- ImageSplit.html DELETED --- --- ImageSplit.java DELETED --- --- Makefile.am DELETED --- --- clean.bat DELETED --- --- icon.bmp DELETED --- --- make.bat DELETED --- --- taki.bmp DELETED --- |
From: Manfred R. <mr...@us...> - 2004-07-10 14:34:41
|
Update of /cvsroot/waba/waba/examples/HelloWorldWABA In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv926/examples/HelloWorldWABA Removed Files: HelloWorldWABA.java Makefile.am Log Message: Removed old examples --- HelloWorldWABA.java DELETED --- --- Makefile.am DELETED --- |
From: Manfred R. <mr...@us...> - 2004-07-10 14:34:40
|
Update of /cvsroot/waba/waba/examples/Applications In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv926/examples/Applications Removed Files: EmptyArray.java FileTest.java HelloWorld.java Makefile.am Nop.java README Log Message: Removed old examples --- EmptyArray.java DELETED --- --- FileTest.java DELETED --- --- HelloWorld.java DELETED --- --- Makefile.am DELETED --- --- Nop.java DELETED --- --- README DELETED --- |
Update of /cvsroot/waba/waba/examples/AddrScan In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv926/examples/AddrScan Removed Files: AddrCatalog.java AddrPanel.java AddrRec.java AddrScan.java Makefile.am Title.java clean.bat icon.bmp make.bat Log Message: Removed old examples --- AddrCatalog.java DELETED --- --- AddrPanel.java DELETED --- --- AddrRec.java DELETED --- --- AddrScan.java DELETED --- --- Makefile.am DELETED --- --- Title.java DELETED --- --- clean.bat DELETED --- --- icon.bmp DELETED --- --- make.bat DELETED --- |
From: Manfred R. <mr...@us...> - 2004-07-10 14:34:39
|
Update of /cvsroot/waba/waba/examples In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv926/examples Removed Files: Makefile.am Log Message: Removed old examples --- Makefile.am DELETED --- |
From: Manfred R. <mr...@us...> - 2004-07-10 14:31:55
|
Update of /cvsroot/waba/waba/examples/pp/helloworld In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv577/pp/helloworld Removed Files: HelloWorld.java HelloWorldAWT.java Log Message: Removed PP example --- HelloWorld.java DELETED --- --- HelloWorldAWT.java DELETED --- |
From: Manfred R. <mr...@us...> - 2004-07-10 14:30:55
|
Update of /cvsroot/waba/waba/examples/midp/helloworld In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv450/midp/helloworld Removed Files: HelloWorld.java README Log Message: Removed MIDP example --- HelloWorld.java DELETED --- --- README DELETED --- |
From: Manfred R. <mr...@us...> - 2004-07-10 14:28:36
|
Update of /cvsroot/waba/waba In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32567 Modified Files: README Log Message: Major cleanup on README file Index: README =================================================================== RCS file: /cvsroot/waba/waba/README,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** README 13 Apr 2002 16:47:35 -0000 1.13 --- README 10 Jul 2004 14:28:28 -0000 1.14 *************** *** 1,285 **** - WABA RELEASE 1.5 - - Revision of this file: - $Id$ - - TO COMPLETE BEFORE RELEASING 1.6: - - Requirements - - Specific ./configure options for Waba. - - installation of binaries - - tested on - - file HISTORY - - +--------------+ - | INTRODUCTION | - +--------------+ - - This directory has the latest Waba Virtual Machine. - - Report any bugs to wa...@sm... - - Main web site is http://waba.sourceforge.net/ -- see that site for the - latest updates. - - To see difference with the latest version, see the file HISTORY. - - +--------------+ - | Requirements | - +--------------+ - - Every GTK based installation needs at least GTK version 1.2.0. - - If you want to use the PicoGUI graphical interface, please install it - from http://pgui.sourceforge.net/. Since either PicoGUI and Waba are - in active developement, the current implementation of Waba uses the - last CVS version of PicoGUI. Please note using PicoGUI is not fully - supported now, so use it at your own risk. - - You can cross-compile from Linux for uClinux 2.0, PalmOS and WIN32 - target. Maybe other targets can be used, but no tests have been done. - - To cross-compile for uClinux, you need tools from uClinux distribution. - See the file README.uClinux for more informations. - - To cross-compile for PalmOS, you need prc-tools - (http://prc-tools.sourceforge.net/) and PilRC (http://www.pilrc.com/). - - To cross-compile for WIN32, you need "Minimalist GNU For Windows" - (http://mingw.sourceforge.net/). RPM binary for Linux is available at - http://www.devolution.com/~slouken/SDL/Xmingw32/ - - +-----------------------------------------------------+ - | Installation from the tar/zip sources distributions | - +-----------------------------------------------------+ - - If you are reading this file, it's certainly mean you already have - downloaded the archive, and explode it. If not, go to the main waba - site http://waba.sourceforge.net/, download latest source distribution - and explode it with the correct tool. - - 1. For the impatient : - ---------------------- - - ./configure - make - make install - - 2. Details of the installation : - -------------------------------- - - a. ./configure - -------------- - - ./configure has a lot of options. To have the full list, just type : - - ./configure --help - - Specific waba options are : - - --with-prefix=<tool prefix> - Specify the prefix to use with gcc, ar, ... For example : - --with-prefix=m68k-palmos will compile with the m68k-palmos-gcc compiler. - - --with-buildprc=/path/to/build-prc - Specify the build-prc path if needed (default to build-prc) - --with-warp=/path/to/warp - Specify the warp path if needed (default to warp) - --with-exegen=/path/to/exegen - Specify the exegen path if needed (default to exegen) - - --with-nogui - Build a Waba VM with a "NULL" graphics library instead of the GTK default - --with-pgui - Compilation for PicoGUI instead of GTK - --with-glib - Use this if you want to use glib with PicoGUI for the definition of types - --with-x - Build a Waba VM with an Xlib GUI instead of GTK - - --enable-debug - If you want to have a code with debug information - - --with-classpath - If you want to specify the CLASSPATH - --with-javac-flags - If you want to use javac with option - --with-javac - If you want to specify which java compiler to use - - - Others usefull options are : - - --prefix=/where/to/install - - - NOTE ON JAVA COMPILERS: - ----------------------- - The current Waba version has been tested with various versions of Java compilers. - The following ones, along with their required configure parameters, are working: - - - Kaffe kjc (version 1.3C): - - ./configure <other_configure_parameters> --with-javac=<path_to_kjc>/kjc - - - Sun javac (J2SE 1.3): - - ./configure <other_configure_parameters> --with-javac=<path_to_javac>/javac - - - IBM jikes (version 1.11): - - ./configure <other_configure_parameters> --with-javac=<path_to_jikes>/jikes - --with-classpath=<path_to_jdk>/jre/lib/rt.jar:<path_to_waba_install>/waba_classes - --with-javac-flags=+CSO - - Notice that Jikes requires additional classpath information and compiler flags - (to be adapted for your installation and configuration): - - - the standard libraries (I guess the other compilers take their respective - defaults, Kaffe and Sun's library); using Sun's standard libraries has been - tested and works, it should be possible to use Kaffe's standard classes as - well, but this has not been tested yet ! - the path where the source Waba classes reside (with the full path where you ! have untarred or checked out the Waba sources); for example, if you have the ! Waba sources in /home/joe/waba, the source Waba classes are in ! /home/joe/waba/waba_classes ! ! - the "+CSO" compiler option ! ! Without the last two, Jikes reports errors when it compiles a class that depends ! on another one not yet compiled. ! ! ! So far, GNU gcj has been reported as not working. ! ! ! a1. cross-compilation ! """"""""""""""""""""" ! ! A typical configuration line to cross-compile for a uClinux version is : ! ! ./configure --with-pgui=/path/of/pgui_for_m68k --with-prefix=m68k-pic-coff ! ! A typical configuration line to cross-compile for a PalmOS version is : ! ! ./configure --with-prefix=m68k-palmos --enable-optimisation ! ! NOTE: The --enable-optimisation is required to shrink the binaries ! enough to be PalmOS friendly. ! ! A typical configuration line to cross-compile for a WIN32 version is : ! ! ./configure --with-prefix=i386-mingw32msvc ! ! Note cross-compilation requiere developements tools for uClinux, ! PalmOS and/or WIN32 installed on your system. See "Requirements" ! chapter for more information. ! ! b. make ! ------- ! ! make will go trough all the directories and compile everything it's needed. ! ! c. make install ! --------------- ! ! make install will install all the needed files in the given prefix. By default, ! it install : ! ! - binaries in /usr/local/bin ! - classes in /usr/local/classes ! - samples in /usr/local/examples ! ! d. use of the Waba VM ! --------------------- ! ! You first need to have correct paths for PATH and CLASSPATH. For a ! default installation, you need to have /usr/local/bin in your PATH and ! /usr/local/share/waba/classes as well as /usr/local/share/doc/waba/examples ! in your CLASSPATH. Then you can try to do: ! ! waba ! ! This will display an about box. ! ! The examples are all in a separate package named after their main class. ! For instance, the CoreTest example is in the CoreTest package, and to ! run it, type: ! ! waba CoreTest.CoreTest ! ! Some examples need extra files (images, etc.), and will require you ! to cd to their directory before running them. They should still be ! run with the package name though, as in: ! ! cd <waba_dir>/examples/PocketWatch ! waba PocketWatch.PocketWatch ! ! If you need help about existing running options, use -h : ! ! waba -h ! ! +------------------------------------------------------+ ! | Installation from the tar/zip binaries distributions | ! +------------------------------------------------------+ ! ! TO COMPLETE WHEN RELEASE 1.5 is OUT ! ! +-----------------------------------+ ! | Installation from the CVS sources | ! +-----------------------------------+ ! ! CVS version is the actualy on heavy developement. Use this version ! only if you want to contribute, or if you really need a feature not ! allready in a distributed version. ! ! Using the CVS sources implies your known the basic use of CVS ! (http://www.cvshome.org/). It also implies you have some basic ! development tools installed, in particular autoconf and automake (see ! http://www.gnu.org/ for more informations about them). ! ! To get the actual cvs version, you can do (just hit return when asked ! for a password): ! ! cvs -d:pserver:ano...@cv...:/cvsroot/waba login ! cvs -z3 -d:pserver:ano...@cv...:/cvsroot/waba co . ! ! Then prepare the sources with : ! ! ./autogen.sh ! ! Remaning steps for the installation is the same as installing from ! the tar/zip sources distributions. ! ! +---------------+ ! | Building RPMs | ! +---------------+ ! ! To build a "standard" RPMs, configure with the following : ! ! ./configure --with-javac=javac --prefix=/usr --with-rpm-root=NONE ! ! and then run : ! ! make rpm ! ! This will generate 4 RPMs : ! ! waba-vm : the virtual machine ! waba-classes : all the Waba classes ! waba-examples : the examples ! waba-mdl : the config for Bee. Not used at this time. ! ! +-----------+ ! | Tested on | ! +-----------+ ! ! The current version was tested on : ! - Linux 2.4.4 with GTK 1.2.8. ! - Linux 2.4.4 with PicoGUI CVS. ! - FreeBSD 4.1.1 with GTK 1.2.8. ! - Solaris 7 with GTK 1.2.8. --- 1,5 ---- ! README ! ------ ! --END |
Update of /cvsroot/waba/waba In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32426 Removed Files: waba.spec.in README.uClinux AUTHORS Makefile.am Waba.mdl acconfig.h autogen.sh configure.in test_all_make.sh Log Message: Removed old files, we are going to redo building entirely. --- waba.spec.in DELETED --- --- README.uClinux DELETED --- --- AUTHORS DELETED --- --- Makefile.am DELETED --- --- Waba.mdl DELETED --- --- acconfig.h DELETED --- --- autogen.sh DELETED --- --- configure.in DELETED --- --- test_all_make.sh DELETED --- |
From: Manfred R. <mr...@us...> - 2004-07-10 14:23:40
|
Update of /cvsroot/waba/waba In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31902 Removed Files: .project .classpath Log Message: Remove Eclipse build files as ANT is the main build tool --- .project DELETED --- --- .classpath DELETED --- |
From: Manfred R. <mr...@us...> - 2004-07-10 14:22:02
|
Update of /cvsroot/waba/waba In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31633 Added Files: build.xml Log Message: Readded ANT based build file |
From: Manfred R. <mr...@us...> - 2004-07-10 14:20:07
|
Update of /cvsroot/waba/waba/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31260/lib Added Files: IGNORE Log Message: Added base lib directory --- NEW FILE: IGNORE --- |
From: Manfred R. <mr...@us...> - 2004-07-10 14:19:45
|
Update of /cvsroot/waba/waba/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31216/lib Log Message: Directory /cvsroot/waba/waba/lib added to the repository |
From: Manfred R. <mr...@us...> - 2004-07-10 14:18:15
|
Update of /cvsroot/waba/waba/src/share/classes/waba/io In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30799/src/share/classes/waba/io Added Files: Catalog.java DataStream.java File.java Registry.java SerialPort.java Socket.java Stream.java Log Message: Moved to new location --- NEW FILE: Catalog.java --- package waba.io; /* $Id: Catalog.java,v 1.1 2004/07/10 14:18:02 mriem Exp $ Copyright (c) 1998, 1999 Wabasoft All rights reserved. This software is furnished under a license and may be used only in accordance with the terms of that license. This software and documentation, and its copyrights are owned by Wabasoft and are protected by copyright law. THIS SOFTWARE AND REFERENCE MATERIALS ARE PROVIDED "AS IS" WITHOUT WARRANTY AS TO THEIR PERFORMANCE, MERCHANTABILITY, FITNESS FOR ANY PARTICULAR PURPOSE, OR AGAINST INFRINGEMENT. WABASOFT ASSUMES NO RESPONSIBILITY FOR THE USE OR INABILITY TO USE THIS SOFTWARE. WABASOFT SHALL NOT BE LIABLE FOR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES RESULTING FROM THE USE OF THIS PRODUCT. WABASOFT SHALL HAVE NO LIABILITY OR RESPONSIBILITY FOR SOFTWARE ALTERED, MODIFIED, OR CONVERTED BY YOU OR A THIRD PARTY, DAMAGES RESULTING FROM ACCIDENT, ABUSE OR MISAPPLICATION, OR FOR PROBLEMS DUE TO THE MALFUNCTION OF YOUR EQUIPMENT OR SOFTWARE NOT SUPPLIED BY WABASOFT. */ import waba.util.Vector; import waba.sys.Vm; import waba.sys.VmShell; /** * Catalog is a collection of records commonly referred to as a database * on small devices. * <p> * Here is an example showing data being read from records in a catalog: * * <pre> * Catalog c = new Catalog("MyCatalog", Catalog.READ_ONLY); * if (!c.isOpen()) * return; * int count = c.getRecordCount(); * byte b[] = new byte[10]; * for (int i = 0; i < count; i++) * { * c.setRecord(i); * c.readBytes(b, 0, 10); * ... * } * c.close(); * </pre> * Notes added by Dave Slaughter @120 * Catalog now reads from and writes to .pdb files, so you can do a full test of your * database application. * The path of the database is the <current directory>\db. */ public class Catalog extends Stream { /** Read-only open mode. */ public static final int READ_ONLY = 1; /** Write-only open mode. */ public static final int WRITE_ONLY = 2; /** Read-write open mode. */ public static final int READ_WRITE = 3; // READ | WRITE /** Create open mode. Used to create a database if one does not exist. */ public static final int CREATE = 4; private boolean _isOpen; private String _name; private int _mode; private Vector _records; private int _recordPos; private int _cursor; private String _creator; // ds@120 private String _type; // ds@120 private boolean _modified; // ds@120 private static final String BASE_DIR = "db"; // ds@120 /** * Opens a catalog with the given name and mode. If mode is CREATE, the * catalog will be created if it does not exist. * <p> * For PalmOS: A PalmOS creator id and type can be specified by appending * a 4 character creator id and 4 character type to the name seperated * by periods. For example: * <pre> * Catalog c = new Catalog("MyCatalog.CRTR.TYPE", Catalog.CREATE); * </pre> * Will create a PalmOS database with the name "MyCatalog", creator id * of "CRTR" and type of "TYPE". * <p> * If no creator id and type is specified, the creator id will default * to the creator id of current waba program and the type will default * to "DATA". * <p> * You must close the catalog to write the data to pdb file on disk! * <br><b>Note</b>: since a bug in the original Waba vm, the <i>TYPE</i> * <b>must</b> be identical to <i>MyCatalog</i> and they must have 4 letters. * If you don't follow this rules and you write a conduit to talk with the waba * created database, you will never find it with the conduit! (guich@120) * <p> * Under PalmOS, the name of the catalog must be 31 characters or less, * not including the creator id and type. Windows CE supports a 32 * character catalog name but to maintain compatibility with PalmOS, * you should use 31 characters maximum for the name of the catalog. * @param name catalog name * @param mode one of READ_ONLY, WRITE_ONLY, READ_WRITE or CREATE */ public Catalog(String name, int mode) { // parse name int i, j; i = name.indexOf('.'); if (i == -1) { _name = name; _creator = "CRTR"; _type = "DATA"; } else { _name = name.substring(0, i); j = i + 1; if ((i = name.indexOf('.', j)) == -1) { _creator = name.substring(j); _type = "DATA"; } else { _creator = name.substring(j, i); _type = name.substring(++i); } } _mode = mode; if (mode == CREATE) { _records = new Vector(); if (!toPDB(File.CREATE)) { // make sure empty file is written so it gets included in the list _isOpen = false; } else { _isOpen = true; }; } else { if (!fromPDB()) { _isOpen = false; } else { _isOpen = true; } } } private int _readWriteBytes(byte buf[], int start, int count, boolean isRead) { if (_recordPos == -1 || (start < 0 || count < 0) || (start + count > buf.length)) return -1; if ((_mode == READ_ONLY && !isRead) || (_mode == WRITE_ONLY && isRead)) { return -1; } byte rec[] = (byte[])_records.get(_recordPos); if (_cursor + count > rec.length) return -1; if (isRead) // guich@120: System.arraycopy is faster than a for loop. { Vm.copyArray(rec,_cursor,buf,start,count); VmShell.println("Copied bytes:"); for (int i=0; i<count; ++i) VmShell.print(buf[start+i]+" "); } else Vm.copyArray(buf,start,rec,_cursor,count); if (!isRead) _modified = true; _cursor += count; return count; } /** * Adds a record to the end of the catalog. If this operation is successful, * the position of the new record is returned and the current position is * set to the new record. If it is unsuccessful the current position is * unset and -1 is returned. * @param size the size in bytes of the record to add */ public int addRecord(int size) { if (!_isOpen) return -1; _recordPos = _records.getCount(); _records.add(new byte[size]); _cursor = 0; return _recordPos; } /** * Adds a record to the <pos> position of the catalog. If this operation is successful, * the position of the new record is returned and the current position is * set to the new record. If it is unsuccessful the current position is * unset and -1 is returned. * implemented by guich (gu...@em...) in 06/30/2000. * @param size the size in bytes of the record to add */ public int addRecord(int size, int pos) { if (!_isOpen || size < 0) return -1; if (pos < 0 || pos > _records.getCount()) return -1; _records.insert(pos, new byte[size]); _recordPos = pos; _cursor = 0; return _recordPos; } /** * Closes the catalog: writtes all information back to the pdb file. * Returns true if the operation is successful and false otherwise. */ public boolean close() { if (!_isOpen) return false; if (_modified) { // guich@120 - write only if modified toPDB(File.READ_WRITE); } _isOpen = false; _recordPos = -1; return true; } /** * Deletes all the records of the catalog. Returns true if the operation is successful and false * otherwise. Note that this behavior is diferent from palm os, because in applets we cannot erase files at the server. */ public boolean delete() { if (!_isOpen) return false; _records.removeAll(); // erases the vector _isOpen = false; _recordPos = -1; File os = new File(getFileName(), File.WRITE_ONLY); if (os == null) return false; return true; } /** * Deletes the current record and sets the current record position to -1. * The record is immediately removed from the catalog and all subsequent * records are moved up one position. */ public boolean deleteRecord() { if (_recordPos == -1) return false; _records.del(_recordPos); _recordPos = -1; return true; } /** reads a pdb file */ private boolean fromPDB() { File file = new File(getFileName(), File.READ_ONLY); if (!file.isOpen()) { return false; } DataStream is = new DataStream(file); // DatabaseHdrType byte name[] = new byte[32]; // ps: the writted string is in c++ format, so this routine doesnt loads the name correctly (comes trash with it) byte type[] = new byte[4]; byte creator[] = new byte[4]; is.readBytes(name,0,name.length); short attributes = is.readShort(); short version = is.readShort(); int creationDate = is.readInt(); int modificationDate = is.readInt(); int lastBackupDate = is.readInt(); int modificationNumber = is.readInt(); int appInfoID = is.readInt(); int sortInfoID = is.readInt(); is.readBytes(type,0,type.length); is.readBytes(creator,0,creator.length); int uniqueIDSeed = is.readInt(); // verify if the creatorId is valid if (!_creator.equals(getString(creator)) || !_type.equals(getString(type))) { is.close(); return false; } // RecordListType int nextRecordListID = is.readInt(); short numRecords = is.readShort(); VmShell.println("# records: "+numRecords); // reads the header (meaningless) int recOffsets[] = new int[numRecords + 1]; byte recAttributes; byte recUniqueID[] = new byte[3]; for (int i = 0; i < numRecords; i++) { int nOffset = is.readInt(); // offset recOffsets[i] = nOffset; VmShell.println("Offset "+i+": "+nOffset); recAttributes = is.readByte(); VmShell.println(" attributes: "+recAttributes); VmShell.println("recUniqueID.length = "+recUniqueID.length); is.readBytes(recUniqueID,0,recUniqueID.length); for (int k=0; k<recUniqueID.length; ++k) VmShell.println(" "+recUniqueID[k]); } recOffsets[numRecords] = file.getLength(); // add the total size so we can compute the size of each record is.readShort(); // pad int offset = 80 + numRecords * 8; // the records were writted in sequence from here _records = new Vector(numRecords); int size = 0; for (int i = 0; i < numRecords; i++) { size = recOffsets[i + 1] - recOffsets[i]; byte[] bytes = new byte[size]; file.seek(recOffsets[i]); is.readBytes(bytes,0,size); _records.add(bytes); } is.close(); return true; } private byte[] getBytes(String s) { char[] chars = s.toCharArray(); byte[] bytes = new byte[chars.length]; for (int i=chars.length -1; i>=0; i--) { bytes[i] = (byte) chars[i]; } return bytes; } /** returns the file name of this catalog */ // guich@120 private String getFileName() { return BASE_DIR+"/"+_name+".PDB";//+_creator+"."+_type; } /** * Returns the number of records in the catalog or -1 if the catalog is not open. */ public int getRecordCount() { if (!_isOpen) return -1; return _records.getCount(); } /** * Returns the size of the current record in bytes or -1 if there is no * current record. */ public int getRecordSize() { if (_recordPos == -1) return -1; byte rec[] = (byte[]) _records.get(_recordPos); return rec.length; } private String getString(byte[] bytes) { char[] chars = new char[bytes.length]; for (int i=bytes.length -1; i>=0; i--) { chars[i] = (char) bytes[i]; } return new String(chars); } /** Inspects a record. use this method with careful, none of the params are checked for validity. * the cursor is not advanced, neither the current record position. this method must be used * only for a fast way of viewing the contents of a record, * like searching for a specific header or filling a grid of data. * <i>buf.length</i> bytes (at maximum) are readen from the record into <i>buf</i>. * Returns the number of bytes read (can be different of buf.length if buf.length is greater * than the record size) or -1 if an error prevented the read operation from occurring. added by guich*/ public int inspectRecord(byte buf[], int recPosition) { byte rec[] = (byte[]) _records.get(recPosition); int count; if (rec.length > buf.length) { count = buf.length; } else { count = rec.length; } waba.sys.Vm.copyArray(rec, 0, buf, 0, count); return count; } /** * Returns true if the catalog is open and false otherwise. This can * be used to check if opening or creating a catalog was successful. */ public boolean isOpen() { return _isOpen; } /** * Returns the complete list of existing catalogs. If no catalogs exist, this * method returns null. */ public static String[] listCatalogs() { File dir = new File(BASE_DIR, File.READ_ONLY); if (!dir.isDir()) { return null; } String[] files = dir.listDir(); int j = 0; for (int i = 0; i < files.length; i++) { int len = files[i].length(); if (len > 4 && waba.sys.Convert.toLowerCase(files[i].substring(len-4)).equals(".pdb")) { files[j] = files[i].substring(0,len-4); j++; } } if (j == 0) { return null; } if (j != files.length) { String[] valid = new String[j]; Vm.copyArray(files, 0, valid, 0, j); return valid; } return files; } /** * Reads bytes from the current record into a byte array. Returns the * number of bytes actually read or -1 if an error prevented the * read operation from occurring. After the read is complete, the location of * the cursor in the current record (where read and write operations start from) * is advanced the number of bytes read. * @param buf the byte array to read data into * @param start the start position in the array * @param count the number of bytes to read */ public int readBytes(byte buf[], int start, int count) { return _readWriteBytes(buf, start, count, true); } /** * Resizes a record. This method changes the size (in bytes) of the current record. * The contents of the existing record are preserved if the new size is larger * than the existing size. If the new size is less than the existing size, the * contents of the record are also preserved but truncated to the new size. * Returns true if the operation is successful and false otherwise. * @param size the new size of the record */ public boolean resizeRecord(int size) { if (_recordPos == -1) return false; byte oldRec[] = (byte[]) _records.get(_recordPos); byte newRec[] = new byte[size]; int copyLen; if (oldRec.length < newRec.length) copyLen = oldRec.length; else copyLen = newRec.length; waba.sys.Vm.copyArray(oldRec, 0, newRec, 0, copyLen); _records.set(_recordPos, newRec); //_cursor = 0; guich@120 return true; } /** * Sets the current record position and locks the given record. The value * -1 can be passed to unset and unlock the current record. If the operation * is succesful, true is returned and the read/write cursor is set to * the beginning of the record. Otherwise, false is returned. */ public boolean setRecordPos(int pos) { if (pos < 0 || pos >= _records.getCount()) { _recordPos = -1; return false; } _recordPos = pos; _cursor = 0; return true; } /** * Advances the cursor in the current record a number of bytes. The cursor * defines where read and write operations start from in the record. Returns * the number of bytes actually skipped or -1 if an error occurs. * @param count the number of bytes to skip */ public int skipBytes(int count) { if (_recordPos == -1) return -1; byte rec[] = (byte[]) _records.get(_recordPos); if (_cursor + count > rec.length) return -1; _cursor += count; return count; } /** converts the records to a pdb file. */ private boolean toPDB(int fileType) { File dir = new File(BASE_DIR, File.DONT_OPEN); if (!dir.exists()) { dir.createDir(); } File file = new File(getFileName(), fileType); if (!file.isOpen()) { return false; } byte name[] = new byte[32]; short attributes = (short) 0x8000; short version = 1; int creationDate = 0xb08823ad; int modificationDate = 0xb08823ad; int lastBackupDate = 0xb08823ad; int modificationNumber = 1; int appInfoID = 0; int sortInfoID = 0; byte type[] = getBytes(_type); byte creator[] = getBytes(_creator); int uniqueIDSeed = 0; // copies the db name to inside the array <name> byte[] bn = getBytes(_name); for (int i = 0; i < name.length; i++) name[i] = (i < bn.length) ? bn[i] : (byte)0; short numRecords = (short) _records.getCount(); DataStream os = new DataStream(file); int offset = 80 + numRecords * 8; // DatabaseHdrType os.writeBytes(name, 0, name.length); os.writeShort(attributes); os.writeShort(version); os.writeInt(creationDate); os.writeInt(modificationDate); os.writeInt(lastBackupDate); os.writeInt(modificationNumber); os.writeInt(appInfoID); os.writeInt(sortInfoID); os.writeBytes(type, 0, type.length); os.writeBytes(creator, 0, creator.length); os.writeInt(uniqueIDSeed); // RecordListType int nextRecordListID = 0; os.writeInt(nextRecordListID); os.writeShort(numRecords); for (int i = 0; i < numRecords; i++) { os.writeInt(offset); // LocalChunkID os.writeByte(0); // attributes os.writeByte((byte) (i >> 16)); // uniqueID os.writeByte((byte) (i >> 8)); // uniqueID os.writeByte((byte) (i >> 0)); // uniqueID offset += ((byte[]) _records.get(i)).length; } os.writeShort(0); // pad for (int i = 0; i < numRecords; i++) { byte[] bytes = (byte[]) _records.get(i); os.writeBytes(bytes, 0, bytes.length); } os.close(); return true; } /** * Writes to the current record. Returns the number of bytes written or -1 * if an error prevented the write operation from occurring. * After the write is complete, the location of the cursor in the current record * (where read and write operations start from) is advanced the number of bytes * written. * @param buf the byte array to write data from * @param start the start position in the byte array * @param count the number of bytes to write */ public int writeBytes(byte buf[], int start, int count) { return _readWriteBytes(buf, start, count, false); } } --- NEW FILE: DataStream.java --- /* $Id: DataStream.java,v 1.1 2004/07/10 14:18:02 mriem Exp $ */ /***************************************************************************** * Waba Extras * * Version History * Date Version Programmer * ---------- ------- ------- ------------------------------------------ * 17/10/1999 New 1.0.0 Rob Nielsen * Class created * 22/07/2000 1.0.1 Guich * Added support for Strings. * ****************************************************************************/ package waba.io; import waba.sys.*; /** * DataStream is a wrapper you can place around any Stream such as a * SerialPort, Catalog, or BufferStream which lets you read and write * standard Waba data types like ints, floats, and Strings in a simple * manner. Here's an example * <pre> * SerialPort port=new SerialPort(9600,0); * DataStream ds=new DataStream(port); * ds.writeString("Hello"); * int status=ds.readUnsignedByte(); * if (status==1) * { * ds.writeString("Pi"); * ds.writeFloat(3.14); * } * port.close(); * </pre> * <br>ps: this class was created in the Waba Extras package, but i added a few methods * for storing and retrieving strings. (gu...@em...) */ public class DataStream extends Stream { /** the underlying stream */ protected Stream stream; /** a four byte array for reading and writing numbers */ protected byte[] b=new byte[4]; /** * Constructs a new DataStream which sits upon the given stream using * big endian notation for multibyte values. * @param stream the base stream */ public DataStream(Stream stream) { this.stream=stream; } /** closes the stream */ public boolean close() { if (stream != null) return stream.close(); return true; } /** * Reads an integer from the stream as four bytes. The returned value * will range from -2147483648 to 2147483647. * @return the integer */ public int readInt() { stream.readBytes(b,0,4); return (((b[0]&0xFF) << 24) | ((b[1]&0xFF) << 16) | ((b[2]&0xFF) << 8) | (b[3]&0xFF)); } /** * Writes an integer to the stream as four bytes. * @param i the integer to write * @return the number of bytes written */ public int writeInt(int i) { for(int j=0;j<4;j++) { b[3-j]=(byte)(i&0xFF); i>>=8; } stream.writeBytes(b,0,4); return 4; } /** * Reads a short from the stream as two bytes. The returned value will * range from -32768 to 32767. * @return the short */ public short readShort() { return (short)readUnsignedShort(); } /** * Writes an short to the stream as two bytes. As there is no * short type in Waba but we often only want to only use two bytes in * storage. * an int is used but the upper two bytes are ignored. * @param i the short to write * @return the number of bytes written */ public int writeShort(int i) { for(int j=0;j<2;j++) { b[1-j]=(byte)(i&0xFF); i>>=8; } stream.writeBytes(b,0,2); return 2; } /** * Reads an unsigned short from the stream as two bytes. The returned * value will range from 0 to 65535. * @return the short */ public int readUnsignedShort() { stream.readBytes(b,0,2); return (((b[0]&0xFF) << 8) | (b[1]&0xFF)); } /** * Reads a float value from the stream as four bytes in IEEE 754 format. * @return the float value */ public float readFloat() { return Convert.toFloatBitwise(readInt()); } /** * Writes a float value to the stream as four bytes in IEEE 754 format * @param f the float to write * @return the number of bytes written */ public int writeFloat(float f) { writeInt(Convert.toIntBitwise(f)); return 4; } /** * Reads a boolean from the stream as a byte. True is returned if * the byte is not zero, false if it is. * @returns the boolean value read. */ public boolean readBoolean() { stream.readBytes(b,0,1); return b[0]!=0; } /** * Writes a boolean to the stream as a byte. True values are written as * 1 and false values as 0. * @param b the boolean to write * @return the number of bytes written */ public int writeBoolean(boolean bool) { b[0]=(bool?(byte)1:(byte)0); stream.writeBytes(b,0,1); return 1; } /** * Reads a single byte from the stream. The returned value will range * from -128 to 127. * @returns the read byte */ public byte readByte() { stream.readBytes(b,0,1); return b[0]; } /** * Writes a single byte to the stream. * @param b the byte to write * @return the number of bytes written */ public int writeByte(byte by) { b[0]=by; stream.writeBytes(b,0,1); return 1; } /** * Writes a single byte to the stream. * @param b the byte to write (only least significant byte is written) * @return the number of bytes written */ public int writeByte(int by) { b[0]=(byte)(by&0xFF); stream.writeBytes(b,0,1); return 1; } /** * Reads a single unsigned byte from the stream. The returned value will * range from 0 to 255. * @returns the read byte. */ public int readUnsignedByte() { stream.readBytes(b,0,1); return b[0]&0xFF; } /** * Skips reading the next n bytes in the stream * @param n the number of bytes to skip */ public void skip(int n) { byte[] b=new byte[n]; stream.readBytes(b,0,n); } /** * Reads bytes from the stream. Returns the * number of bytes actually read or -1 if an error prevented the * read operation from occurring. * @param buf the byte array to read data into * @param start the start position in the array * @param count the number of bytes to read */ public int readBytes(byte buf[], int start, int count) { return stream.readBytes(buf,start,count); } /** * Writes bytes to the the stream. Returns the * number of bytes actually written or -1 if an error prevented the * write operation from occurring. * @param buf the byte array to write data from * @param start the start position in the byte array * @param count the number of bytes to write */ public int writeBytes(byte buf[], int start, int count) { return stream.writeBytes(buf,start,count); } /////////////////////////////// added by guich //////////////////////////////////// static private char chars[] = new char[128]; // buffer static private byte bytes[] = new byte[128]; // buffer /** pads the stream writting n bytes. all bytes will be 0. added by guich */ public int pad(int n) { for (int i =0; i < n; i++) bytes[i] = 0; writeBytes(bytes,0,n); return n; } /** reads an string. @returns a zero or more length string. null is never returned. */ public String readString() { int len = readShort(); if (len == 0) return ""; if (chars.length < len) chars = new char[len+16]; // grows the buffer if necessary readBytes(bytes,0,len); for (int i=0; i < len; i++) chars[i] = (char) bytes[i]; return new String(chars,0,len); } /** reads an array of string. @returns an zero or more length array. null is never returned. */ public String[] readStringArray() { int size = (int)readShort(); String []a = new String[size]; for (int i =0; i < size; i++) a[i] = readString(); return a; } /** writes the string array into the stream */ public int writeStringArray(String []v) { int n = 0; if (v == null || v.length == 0) n += writeShort((short)0); else { n += writeShort((short)v.length); for (int i=0; i < v.length; i++) n += writeString(v[i]); } return n; } /** writes the string into the stream */ public int writeString(String s) { int n = 0; if (s != null && s.length() > 0) { char[] c = s.toCharArray(); if (bytes.length < c.length) bytes =new byte[c.length+16]; for (int i=0; i < c.length; i++) bytes[i] = (byte) c[i]; n += writeShort((short)c.length); n += writeBytes(bytes,0,c.length); } else n += writeShort(0); return n; } } --- NEW FILE: File.java --- /* $Id: File.java,v 1.1 2004/07/10 14:18:02 mriem Exp $ Copyright (c) 1998, 1999 Wabasoft All rights reserved. This software is furnished under a license and may be used only in accordance with the terms of that license. This software and documentation, and its copyrights are owned by Wabasoft and are protected by copyright law. THIS SOFTWARE AND REFERENCE MATERIALS ARE PROVIDED "AS IS" WITHOUT WARRANTY AS TO THEIR PERFORMANCE, MERCHANTABILITY, FITNESS FOR ANY PARTICULAR PURPOSE, OR AGAINST INFRINGEMENT. WABASOFT ASSUMES NO RESPONSIBILITY FOR THE USE OR INABILITY TO USE THIS SOFTWARE. WABASOFT SHALL NOT BE LIABLE FOR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES RESULTING FROM THE USE OF THIS PRODUCT. WABASOFT SHALL HAVE NO LIABILITY OR RESPONSIBILITY FOR SOFTWARE ALTERED, MODIFIED, OR CONVERTED BY YOU OR A THIRD PARTY, DAMAGES RESULTING FROM ACCIDENT, ABUSE OR MISAPPLICATION, OR FOR PROBLEMS DUE TO THE MALFUNCTION OF YOUR EQUIPMENT OR SOFTWARE NOT SUPPLIED BY WABASOFT. */ package waba.io; /** * File is a file or directory. * <p> * The File class will not work under the PalmPilot since it does not * contain a filesystem. * <p> * Here is an example showing data being read from a file: * * <pre> * File file = new File("/temp/tempfile", File.READ_ONLY); * if (!file.isOpen()) * return; * byte b[] = new byte[10]; * file.readBytes(b, 0, 10); * file.close(); * file = new File("/temp/tempfile", File.DONT_OPEN); * file.delete(); * </pre> */ public class File extends Stream { /** Don't open the file mode. */ public static final int DONT_OPEN = 0; /** Read-only open mode. */ public static final int READ_ONLY = 1; /** Write-only open mode. */ public static final int WRITE_ONLY = 2; /** Read-write open mode. */ public static final int READ_WRITE = 3; // READ | WRITE /** Create open mode. Used to create a file if one does not exist. */ public static final int CREATE = 4; String path; int mode; /** * Opens a file with the given name and mode. If mode is CREATE, the * file will be created if it does not exist. The DONT_OPEN mode * allows the exists(), rename(), delete(), listDir(), createDir() * and isDir() methods to be called without requiring the file to be * open for reading or writing. * @param path the file's path * @param mode one of DONT_OPEN, READ_ONLY, WRITE_ONLY, READ_WRITE or CREATE */ public File(String path, int mode) { this.path = path; this.mode = mode; _nativeCreate(); } private native void _nativeCreate(); /** * Closes the file. Returns true if the operation is successful and false * otherwise. */ public native boolean close(); /** * Returns true if the file is open for reading or writing and * false otherwise. This can be used to check if opening or * creating a file was successful. */ public native boolean isOpen(); /** * Creates a directory. Returns true if the operation is successful and false * otherwise. */ public native boolean createDir(); /** * Deletes the file or directory. Returns true if the operation is * successful and false otherwise. */ public native boolean delete(); /** Returns true if the file exists and false otherwise. */ public native boolean exists(); /** Returns the length of the file in bytes. If the file is not open * 0 will be returned. */ public native int getLength(); /** Return the file's path. */ public String getPath() { return path; } /** Returns true if the file is a directory and false otherwise. */ public native boolean isDir(); /** * Lists the files contained in a directory. The strings returned are the * names of the files and directories contained within this directory. * This method returns null if the directory can't be read or if the * operation fails. */ public native String []listDir(); /** * Reads bytes from the file into a byte array. Returns the * number of bytes actually read or -1 if an error prevented the * read operation from occurring. After the read is complete, the location of * the file pointer (where read and write operations start from) * is advanced the number of bytes read. * @param buf the byte array to read data into * @param start the start position in the array * @param count the number of bytes to read */ public native int readBytes(byte b[], int off, int len); /** * Writes to the file. Returns the number of bytes written or -1 * if an error prevented the write operation from occurring. * After the write is complete, the file pointer (where read and * write operations start from) is advanced the number of bytes * written. * @param buf the byte array to write data from * @param start the start position in the byte array * @param count the number of bytes to write */ public native int writeBytes(byte b[], int off, int len); /** * Renames the file. If the path given is in a different directory, the * existing file will be moved to the directory in the specified path. * Returns true if the renaming was successful and false otherwise. */ public native boolean rename(String path); /** * Sets the file pointer for read and write operations to the given * position. The position passed is an absolute position, in bytes, * from the beginning of the file. To set the position to just after * the end of the file, you can call: * <pre> * file.seek(file.getLength()); * </pre> * True is returned if the operation is successful and false otherwise. */ public native boolean seek(int pos); } --- NEW FILE: Registry.java --- /* $Id: Registry.java,v 1.1 2004/07/10 14:18:02 mriem Exp $ Copyright (c) 2001 SmartData This software is furnished under a license and may be used only in accordance with the terms of that license. This software and documentation, and its copyrights are owned by SmartData and are protected by copyright law. THIS SOFTWARE AND REFERENCE MATERIALS ARE PROVIDED "AS IS" WITHOUT WARRANTY AS TO THEIR PERFORMANCE, MERCHANTABILITY, FITNESS FOR ANY PARTICULAR PURPOSE, OR AGAINST INFRINGEMENT. SMARTDATA ASSUMES NO RESPONSIBILITY FOR THE USE OR INABILITY TO USE THIS SOFTWARE. SMARTDATA SHALL NOT BE LIABLE FOR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES RESULTING FROM THE USE OF THIS PRODUCT. SMARTDATA SHALL HAVE NO LIABILITY OR RESPONSIBILITY FOR SOFTWARE ALTERED, MODIFIED, OR CONVERTED BY YOU OR A THIRD PARTY, DAMAGES RESULTING FROM ACCIDENT, ABUSE OR MISAPPLICATION, OR FOR PROBLEMS DUE TO THE MALFUNCTION OF YOUR EQUIPMENT OR SOFTWARE NOT SUPPLIED BY SMARTDATA. */ package waba.io; /** Registry <P> Allows to save and read application-specific data in non-volatile storage. <P> A Registry is a stream that, once obtained, can be read from or written to. It is also possible to skip bytes, using a positive argument to skip forward and a negative argument to skip back to a previous position. <P> It is also important to close the Registry when data has been written to it, as its contents is not guaranteed to be saved in non-volatile storage until the Registry is closed. <P> Deleting the Registry eliminates all data currently contained in it. Reading from or writing to the Registry after it has been deleted has undefined results. After deleting the Registry, it should be re-obtained using <TT>getRegistry ()</TT>. <P> Registry data is associated with the Waba main class name, so as to be application-specific. Accessing the Registry simultaneously by multiple instances of the same application can yield unexpected results. <P> Here is an example of Registry usage: <PRE> (...) Registry r = Registry.getRegistry (); byte [] data = {0x1F, 0x07, 'A', 'B'}; r.writeBytes (data, 0, 4); r.close (); (...) r = Registry.getRegistry (); r.readBytes (data, 0, 4); (...) </PRE> */ public class Registry extends Stream { private static Registry registry = null; private Registry () { _nativeCreate (); } private native boolean _nativeCreate (); /** Obtain the Registry object associated with this application. */ public static Registry getRegistry () { if (registry == null) { registry = new Registry (); } return registry; } /** Return the space available in the Registry object associated with this application. <P> Depending on the specific underlying implementation of Registry objects, the total size returned by this method might not be available at the next write, as it may have been claimed by another application in the mean time. @return the space available in bytes */ public static synchronized native int spaceAvailable (); /** Read bytes from the Registry at the current position. @param buf buffer into which the data should be stored @param start position in the buffer to start storing data @param count number of bytes to read @return the number of bytes actually read, -1 indicating an error */ public native int readBytes (byte [] buf, int start, int count); /** Write bytes into the Registry at the current position. @param buf buffer from which the data should be taken @param start position in the buffer to start taking data @param count number of bytes to write @return the number of bytes actually written, -1 indicating an error */ public synchronized native int writeBytes (byte [] buf, int start, int count); /** Skip bytes. @param count the number of bytes to skip; the result of skipping past data that has been previously written is implementation-dependent @return the new position in the Registry, or -1 if an error occurred */ public native int skipBytes (int count); /** Close the Registry and save its contents into non-volatile storage. @return <TT>false</TT> if an error occurred, <TT>true</TT> otherwise */ public synchronized boolean close () { boolean retValue = _nativeClose (); registry = null; return retValue; } private native boolean _nativeClose (); /** Delete the Registry and all its contents from non-volatile storage. @return <TT>false</TT> if an error occurred, <TT>true</TT> otherwise */ public boolean delete () { boolean retValue = _nativeDelete (); registry = null; return retValue; } private native boolean _nativeDelete (); } --- NEW FILE: SerialPort.java --- /* $Id: SerialPort.java,v 1.1 2004/07/10 14:18:02 mriem Exp $ Copyright (c) 1998, 1999 Wabasoft All rights reserved. This software is furnished under a license and may be used only in accordance with the terms of that license. This software and documentation, and its copyrights are owned by Wabasoft and are protected by copyright law. THIS SOFTWARE AND REFERENCE MATERIALS ARE PROVIDED "AS IS" WITHOUT WARRANTY AS TO THEIR PERFORMANCE, MERCHANTABILITY, FITNESS FOR ANY PARTICULAR PURPOSE, OR AGAINST INFRINGEMENT. WABASOFT ASSUMES NO RESPONSIBILITY FOR THE USE OR INABILITY TO USE THIS SOFTWARE. WABASOFT SHALL NOT BE LIABLE FOR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES RESULTING FROM THE USE OF THIS PRODUCT. WABASOFT SHALL HAVE NO LIABILITY OR RESPONSIBILITY FOR SOFTWARE ALTERED, MODIFIED, OR CONVERTED BY YOU OR A THIRD PARTY, DAMAGES RESULTING FROM ACCIDENT, ABUSE OR MISAPPLICATION, OR FOR PROBLEMS DUE TO THE MALFUNCTION OF YOUR EQUIPMENT OR SOFTWARE NOT SUPPLIED BY WABASOFT. */ package waba.io; /** * SerialPort accesses a device's serial port. * <p> * Serial port access is only available when running under a native WabaVM, it * is not supported when running under Java. * <p> * When a serial port is created, an attempt is made to open the port. * If the open attempt is successful, a call to isOpen() * will return true and the port will remain open until close() is called. * If close() is never called, the port will be closed when the object * is garbage collected. * <p> * * Here is an example showing data being written and read from a serial port: * * <pre> * SerialPort port = new SerialPort(0, 9600); * if (!port.isOpen()) * return; * byte buf[] = new byte[10]; * buf[0] = 3; * buf[1] = 7; * port.writeBytes(buf, 0, 2); * int count = port.readBytes(buf, 0, 10); * if (count == 10) * ... * port.close(); * </pre> */ public class SerialPort extends Stream { /** * Opens a serial port. The number passed is the number of the * serial port for devices with multiple serial ports. Port number * 0 defines the "default port" of a given type. For Windows CE * and PalmPilot devices, you should pass 0 as the port number to * access the device's single serial port. * <p> * On Windows devices, port numbers map to COM port numbers. * For example, serial port 2 maps to "COM2:". * <p> * Here is an example showing how to open the serial port of a * PalmPilot device at 9600 baud with settings of 8 bits, * no partity and one stop bit (8/N/1): * <pre> * SerialPort port = new SerialPort(0, 9600, 8, false, 1); * </pre> * Here is an example of opening serial port COM2: on a Windows device: * <pre> * SerialPort port = new SerialPort(2, 57600, 8, false, 1); * </pre> * No serial XON/XOFF flow control (commonly called software flow control) * is used and RTS/CTS flow control (commonly called hardware flow control) * is turn on by default on all platforms but Windows CE. The parity setting * is a boolean. If false, no parity is used. If true, "even" parity is used. * * @param number port number * @param baudRate baud rate * @param bits bits per char [5 to 8] * @param parity true for even parity, false for no parity * @param stopBits number of stop bits * @see #setFlowControl */ public SerialPort(int number, int baudRate, int bits, boolean parity, int stopBits) { _nativeCreate(number, baudRate, bits, parity, stopBits); } /** * Open a serial port with settings of 8 bits, no parity and 1 stop bit. * These are the most commonly used serial port settings. */ public SerialPort(int number, int baudRate) { this(number, baudRate, 8, false, 1); } private native void _nativeCreate(int number, int baudRate, int bits, boolean parity, int stopBits); /** * Closes the port. Returns true if the operation is successful * and false otherwise. */ public native boolean close(); /** * Returns true if the port is open and false otherwise. This can * be used to check if opening the serial port was successful. */ public native boolean isOpen(); /** * Turns RTS/CTS flow control (hardware flow control) on or off. * @param on pass true to set flow control on and false to set it off */ public native boolean setFlowControl(boolean on); /** * Sets the timeout value for read operations. The value specifies * the number of milliseconds to wait from the time of last activity * before timing out a read operation. Passing a value of 0 sets * no timeout causing any read operation to return immediately with * or without data. The default timeout is 100 milliseconds. This * method returns true if successful and false if the value passed * is negative or the port is not open. * @param millis timeout in milliseconds */ public native boolean setReadTimeout(int millis); /** * Reads bytes from the port into a byte array. Returns the * number of bytes actually read or -1 if an error prevented the read * operation from occurring. The read will timeout if no activity * takes place within the timeout value for the port. * @param buf the byte array to read data into * @param start the start position in the byte array * @param count the number of bytes to read * @see #setReadTimeout */ public native int readBytes(byte buf[], int start, int count); /** * Returns the number of bytes currently available to be read from the * serial port's queue. This method only works under PalmOS and not WinCE * due to limitations in the Win32 CE API. Under Win32 and Java, * this method will always return -1. */ public native int readCheck(); /** * Writes to the port. Returns the number of bytes written or -1 * if an error prevented the write operation from occurring. If data * can't be written to the port and flow control is on, the write * operation will time out and fail after approximately 2 seconds. * @param buf the byte array to write data from * @param start the start position in the byte array * @param count the number of bytes to write */ public native int writeBytes(byte buf[], int start, int count); } --- NEW FILE: Socket.java --- /* $Id: Socket.java,v 1.1 2004/07/10 14:18:02 mriem Exp $ Copyright (c) 1998, 1999 Wabasoft All rights reserved. This software is furnished under a license and may be used only in accordance with the terms of that license. This software and documentation, and its copyrights are owned by Wabasoft and are protected by copyright law. THIS SOFTWARE AND REFERENCE MATERIALS ARE PROVIDED "AS IS" WITHOUT WARRANTY AS TO THEIR PERFORMANCE, MERCHANTABILITY, FITNESS FOR ANY PARTICULAR PURPOSE, OR AGAINST INFRINGEMENT. WABASOFT ASSUMES NO RESPONSIBILITY FOR THE USE OR INABILITY TO USE THIS SOFTWARE. WABASOFT SHALL NOT BE LIABLE FOR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES RESULTING FROM THE USE OF THIS PRODUCT. WABASOFT SHALL HAVE NO LIABILITY OR RESPONSIBILITY FOR SOFTWARE ALTERED, MODIFIED, OR CONVERTED BY YOU OR A THIRD PARTY, DAMAGES RESULTING FROM ACCIDENT, ABUSE OR MISAPPLICATION, OR FOR PROBLEMS DUE TO THE MALFUNCTION OF YOUR EQUIPMENT OR SOFTWARE NOT SUPPLIED BY WABASOFT. */ package waba.io; /** * Socket is a TCP/IP network socket. * <p> * Under Java and Windows CE, if no network is present, the socket * constructor may hang for an extended period of time due to the * implementation of sockets in the underlying OS. This is a known * problem. * <p> * Here is an example showing data being written and read from a socket: * * <pre> * Socket socket = new Socket("www.yahoo.com", 80); * if (!socket.isOpen()) * return; * byte buf[] = new byte[10]; * buf[0] = 3; * buf[1] = 7; * socket.writeBytes(buf, 0, 2); * int count = socket.readBytes(buf, 0, 10); * if (count == 10) * ... * socket.close(); * </pre> */ public class Socket extends Stream { /** * Opens a socket. This method establishes a socket connection by * looking up the given host and performing the 3 way TCP/IP handshake. * @param host the host name or IP address to connect to * @param port the port number to connect to */ public Socket(String host, int port) { _nativeCreate(host, port); } private native void _nativeCreate(String host, int port); /** * Closes the socket. Returns true if the operation is successful * and false otherwise. */ public native boolean close(); /** * Returns true if the socket is open and false otherwise. This can * be used to check if opening the socket was successful. */ public native boolean isOpen(); /** * Sets the timeout value for read operations. The value specifies * the number of milliseconds to wait from the time of last activity * before timing out a read operation. Passing a value of 0 sets * no timeout causing any read operation to return immediately with * or without data. The default timeout is 1500 milliseconds. This * method returns true if successful and false if the value passed * is negative or the socket is not open. Calling this method * currently has no effect under Win32 or WindowsCE. The * read timeout under those platforms will remain the system default. * @param millis timeout in milliseconds */ public native boolean setReadTimeout(int millis); /** * Reads bytes from the socket into a byte array. Returns the * number of bytes actually read or -1 if the server closed * the connection or an error prevented the read operation from * occurring. * @param buf the byte array to read data into * @param start the start position in the byte array * @param count the number of bytes to read */ public native int readBytes(byte buf[], int start, int count); /** * Writes to the socket. Returns the number of bytes written or -1 * if an error prevented the write operation from occurring. If data * can't be written to the socket for approximately 2 seconds, the * write operation will time out. * @param buf the byte array to write data from * @param start the start position in the byte array * @param count the number of bytes to write */ public native int writeBytes(byte buf[], int start, int count); } --- NEW FILE: Stream.java --- /* $Id: Stream.java,v 1.1 2004/07/10 14:18:02 mriem Exp $ Copyright (c) 1998, 1999 Wabasoft All rights reserved. This software is furnished under a license and may be used only in accordance with the terms of that license. This software and documentation, and its copyrights are owned by Wabasoft and are protected by copyright law. THIS SOFTWARE AND REFERENCE MATERIALS ARE PROVIDED "AS IS" WITHOUT WARRANTY AS TO THEIR PERFORMANCE, MERCHANTABILITY, FITNESS FOR ANY PARTICULAR PURPOSE, OR AGAINST INFRINGEMENT. WABASOFT ASSUMES NO RESPONSIBILITY FOR THE USE OR INABILITY TO USE THIS SOFTWARE. WABASOFT SHALL NOT BE LIABLE FOR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES RESULTING FROM THE USE OF THIS PRODUCT. WABASOFT SHALL HAVE NO LIABILITY OR RESPONSIBILITY FOR SOFTWARE ALTERED, MODIFIED, OR CONVERTED BY YOU OR A THIRD PARTY, DAMAGES RESULTING FROM ACCIDENT, ABUSE OR MISAPPLICATION, OR FOR PROBLEMS DUE TO THE MALFUNCTION OF YOUR EQUIPMENT OR SOFTWARE NOT SUPPLIED BY WABASOFT. */ package waba.io; /** * Stream is the base class for all stream-based I/O classes. */ public abstract class Stream { /** * Reads bytes from the stream. Returns the * number of bytes actually read or -1 if an error prevented the * read operation from occurring. * @param buf the byte array to read data into * @param start the start position in the array * @param count the number of bytes to read */ public abstract int readBytes(byte buf[], int start, int count); /** * Writes bytes to the the stream. Returns the * number of bytes actually written or -1 if an error prevented the * write operation from occurring. * @param buf the byte array to write data from * @param start the start position in the byte array * @param count the number of bytes to write */ public abstract int writeBytes(byte buf[], int start, int count); /** * Closes the stream. Returns true if the operation is successful * and false otherwise. */ public abstract boolean close(); } |
Update of /cvsroot/waba/waba/src/share/classes/waba/fx In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30799/src/share/classes/waba/fx Added Files: Color.java Font.java FontMetrics.java Graphics.java ISurface.java Image.java Rect.java Sound.java SoundClip.java Log Message: Moved to new location --- NEW FILE: Color.java --- /* $Id: Color.java,v 1.1 2004/07/10 14:18:02 mriem Exp $ Copyright (c) 1998, 1999 Wabasoft All rights reserved. This software is furnished under a license and may be used only in accordance with the terms of that license. This software and documentation, and its copyrights are owned by Wabasoft and are protected by copyright law. THIS SOFTWARE AND REFERENCE MATERIALS ARE PROVIDED "AS IS" WITHOUT WARRANTY AS TO THEIR PERFORMANCE, MERCHANTABILITY, FITNESS FOR ANY PARTICULAR PURPOSE, OR AGAINST INFRINGEMENT. WABASOFT ASSUMES NO RESPONSIBILITY FOR THE USE OR INABILITY TO USE THIS SOFTWARE. WABASOFT SHALL NOT BE LIABLE FOR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES RESULTING FROM THE USE OF THIS PRODUCT. WABASOFT SHALL HAVE NO LIABILITY OR RESPONSIBILITY FOR SOFTWARE ALTERED, MODIFIED, OR CONVERTED BY YOU OR A THIRD PARTY, DAMAGES RESULTING FROM ACCIDENT, ABUSE OR MISAPPLICATION, OR FOR PROBLEMS DUE TO THE MALFUNCTION OF YOUR EQUIPMENT OR SOFTWARE NOT SUPPLIED BY WABASOFT. */ package waba.fx; /** * Color represents a color. * <p> * A color is defined as a mixture of red, green and blue color values. * Each value is in the range of 0 to 255 where 0 is darkest and 255 is brightest. * For example, Color(255, 0, 0) is the color red. * <p> * Here are some more examples: * <ul> * <li>Color(0, 0, 0) is black * <li>Color(255, 255, 255) is white * <li>Color(0, 255, 0) is green * <li>Color(0, 0, 255) is blue * </ul> */ public class Color { int red; int green; int blue; /** * Constructs a color object with the given red, green and blue values. * @param red the red value in the range of 0 to 255 * @param green the green value in the range of 0 to 255 * @param blue the blue value in the range of 0 to 255 */ public Color(int red, int green, int blue) { this.red = red; this.green = green; this.blue = blue; } /** Returns the blue value of the color. */ public int getBlue() { return blue; } /** Returns the green value of the color. */ public int getGreen() { return green; } /** Returns the red value of the color. */ public int getRed() { return red; } /** Sets the blue value of the color. */ public void setBlue(int blue) { this.blue = blue; } /** Sets the green value of the color. */ public void setGreen(int green) { this.green = green; } /** Sets the red value of the color. */ public void setRed(int red) { this.red = red; } } --- NEW FILE: Font.java --- /* $Id: Font.java,v 1.1 2004/07/10 14:18:02 mriem Exp $ Copyright (c) 1998, 1999 Wabasoft All rights reserved. This software is furnished under a license and may be used only in accordance with the terms of that license. This software and documentation, and its copyrights are owned by Wabasoft and are protected by copyright law. THIS SOFTWARE AND REFERENCE MATERIALS ARE PROVIDED "AS IS" WITHOUT WARRANTY AS TO THEIR PERFORMANCE, MERCHANTABILITY, FITNESS FOR ANY PARTICULAR PURPOSE, OR AGAINST INFRINGEMENT. WABASOFT ASSUMES NO RESPONSIBILITY FOR THE USE OR INABILITY TO USE THIS SOFTWARE. WABASOFT SHALL NOT BE LIABLE FOR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES RESULTING FROM THE USE OF THIS PRODUCT. WABASOFT SHALL HAVE NO LIABILITY OR RESPONSIBILITY FOR SOFTWARE ALTERED, MODIFIED, OR CONVERTED BY YOU OR A THIRD PARTY, DAMAGES RESULTING FROM ACCIDENT, ABUSE OR MISAPPLICATION, OR FOR PROBLEMS DUE TO THE MALFUNCTION OF YOUR EQUIPMENT OR SOFTWARE NOT SUPPLIED BY WABASOFT. */ package waba.fx; /** * Font is the character font used when drawing text on a surface. * <p> * Fonts have a name, such as "Helvetica", a style and a point size (usually * around 10). It's important to note that many devices have an extremely * limited number of fonts. For example, most PalmPilot devices have only * two fonts: plain and bold. If the font specified can't be found during * drawing, the closest matching font will be used. * <p> * Here is an example showing text being drawn in a given font: * * <pre> * ... * Font font = new Font("Helvetica", Font.BOLD, 10); * } * * public void onPaint(Graphics g) * { * g.setFont(font); * g.drawText("Hello", 10, 10); * ... * </pre> */ public class Font { String name; int style; int size; /** A plain font style. */ public static final int PLAIN = 0; /** A bold font style. */ public static final int BOLD = 1; /** * Creates a font of the given name, style and size. Font styles are defined * in this class. * @see #PLAIN * @see #BOLD * @see Graphics */ public Font(String name, int style, int size) { this.name = name; this.style = style; this.size = size; } /** Returns the name of the font. */ public String getName() { return name; } /** Returns the size of the font. */ public int getSize() { return size; } /** * Returns the style of the font. Font styles are defined in this class. * @see #PLAIN * @see #BOLD */ public int getStyle() { return style; } } --- NEW FILE: FontMetrics.java --- /* $Id: FontMetrics.java,v 1.1 2004/07/10 14:18:02 mriem Exp $ Copyright (c) 1998, 1999 Wabasoft All rights reserved. This software is furnished under a license and may be used only in accordance with the terms of that license. This software and documentation, and its copyrights are owned by Wabasoft and are protected by copyright law. THIS SOFTWARE AND REFERENCE MATERIALS ARE PROVIDED "AS IS" WITHOUT WARRANTY AS TO THEIR PERFORMANCE, MERCHANTABILITY, FITNESS FOR ANY PARTICULAR PURPOSE, OR AGAINST INFRINGEMENT. WABASOFT ASSUMES NO RESPONSIBILITY FOR THE USE OR INABILITY TO USE THIS SOFTWARE. WABASOFT SHALL NOT BE LIABLE FOR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES RESULTING FROM THE USE OF THIS PRODUCT. WABASOFT SHALL HAVE NO LIABILITY OR RESPONSIBILITY FOR SOFTWARE ALTERED, MODIFIED, OR CONVERTED BY YOU OR A THIRD PARTY, DAMAGES RESULTING FROM ACCIDENT, ABUSE OR MISAPPLICATION, OR FOR PROBLEMS DUE TO THE MALFUNCTION OF YOUR EQUIPMENT OR SOFTWARE NOT SUPPLIED BY WABASOFT. */ package waba.fx; /** * FontMetrics computes font metrics including string width and height. * <p> * FontMetrics are usually used to obtain information about the widths and * heights of characters and strings when drawing text on a surface. * A FontMetrics object references a font and surface since fonts may have * different metrics on different surfaces. * <p> * Here is an example that uses FontMetrics to get the width of a string: * * <pre> * ... * Font font = new Font("Helvetica", Font.BOLD, 10); * FontMetrics fm = getFontMetrics(); * String s = "This is a line of text."; * int stringWidth = fm.getTextWidth(s); * ... * </pre> */ public class FontMetrics { Font font; ISurface surface; int ascent; int descent; int leading; /** * Constructs a font metrics object referencing the given font and surface. * <p> * If you are trying to create a font metrics object in a Control subclass, * use the getFontMetrics() method in the Control class. * @see waba.ui.Control#getFontMetrics(waba.fx.Font font) */ public FontMetrics(Font font, ISurface surface) { this.font = font; this.surface = surface; _nativeCreate(); } private native void _nativeCreate(); /** * Returns the ascent of the font. This is the distance from the baseline * of a character to its top. */ public int getAscent() { return ascent; } /** * Returns the width of the given character in pixels. */ public native int getCharWidth(char c); /** * Returns the descent of a font. This is the distance from the baseline * of a character to the bottom of the character. */ public int getDescent() { return descent; } /** * Returns the height of the referenced font. This is equal to the font's * ascent plus its descent. This does not include leading (the space between lines). */ public int getHeight() { return ascent + descent; } /** * Returns the external leading which is the space between lines. */ public int getLeading() { return leading; } /** * Returns the width of the given text string in pixels. */ public native int getTextWidth(String s); /** * Returns the width of the given text in pixels. * @param chars the text character array * @param start the start position in array * @param count the number of characters */ public native int getTextWidth(char chars[], int start, int count); } --- NEW FILE: Graphics.java --- /* $Id: Graphics.java,v 1.1 2004/07/10 14:18:02 mriem Exp $ Copyright (c) 1998, 1999 Wabasoft All rights reserved. This software is furnished under a license and may be used only in accordance with the terms of that license. This software and documentation, and its copyrights are owned by Wabasoft and are protected by copyright law. THIS SOFTWARE AND REFERENCE MATERIALS ARE PROVIDED "AS IS" WITHOUT WARRANTY AS TO THEIR PERFORMANCE, MERCHANTABILITY, FITNESS FOR ANY PARTICULAR PURPOSE, OR AGAINST INFRINGEMENT. WABASOFT ASSUMES NO RESPONSIBILITY FOR THE USE OR INABILITY TO USE THIS SOFTWARE. WABASOFT SHALL NOT BE LIABLE FOR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES RESULTING FROM THE USE OF THIS PRODUCT. WABASOFT SHALL HAVE NO LIABILITY OR RESPONSIBILITY FOR SOFTWARE ALTERED, MODIFIED, OR CONVERTED BY YOU OR A THIRD PARTY, DAMAGES RESULTING FROM ACCIDENT, ABUSE OR MISAPPLICATION, OR FOR PROBLEMS DUE TO THE MALFUNCTION OF YOUR EQUIPMENT OR SOFTWARE NOT SUPPLIED BY WABASOFT. */ package waba.fx; /** * Graphics draws on a surface. * <p> * Surfaces are objects that implement the ISurface interface. * MainWindow and Image are both examples of surfaces. * <p> * Here is an example that uses Graphics to draw a line: * * <pre> * public class MyProgram extends MainWindow * { * public void onPaint(Graphics g) * { * g.setColor(0, 0, 255); * g.drawLine(0, 0, 10, 10); * ... * </pre> */ public class Graphics { private ISurface surface; /** * The constant for a draw operation that draws the source over * the destination. */ public static final int DRAW_OVER = 1; /** * The constant for a draw operation that AND's the source with the * destination. Commonly used to create image masks. */ public static final int DRAW_AND = 2; /** * The constant for a draw operation that OR's the source with the * destination. Commonly used with image masks. */ public static final int DRAW_OR = 3; /** * The constant for a draw operation that XOR's the source with the * destination. */ public static final int DRAW_XOR = 4; /** * Constructs a graphics object which can be used to draw on the given * surface. For the sake of the methods in this class, the given surface * is known as the "current surface". * <p> * If you are trying to create a graphics object for drawing in a subclass * of control, use the createGraphics() method in the Control class. It * creates a graphics object and translated the origin to the origin of * the control. */ public Graphics(ISurface surface) { this.surface = surface; _nativeCreate(); } private native void _nativeCreate(); /** * Clears the current clipping rectangle. This allows drawing to occur * anywhere on the current surface. */ public native void clearClip(); /** * Copies a rectangular area from a surface to the given coordinates on * the current surface. The copy operation is performed by combining * pixels according to the setting of the current drawing operation. * The same surface can be used as a source and destination to * implement quick scrolling. * <p> * Not all combinations of surfaces are supported on all platforms. * PalmOS has problems copying from an Window surface to an Image and * between two Image surfaces. Java doesn't allow copying from an * Window surface to an Image. * * @param surface the surface to copy from * @param x the source x coordinate * @param y the source y coordinate * @param width the width of the area on the source surface * @param height the height of the area on the source surface * @param dstX the destination x location on the current surface * @param dstY the destination y location on the current surface * @see #setDrawOp */ public native void copyRect( ISurface surface, int x, int y, int width, int height, int dstX, int dstY); /** * Frees any system resources (native device contexts) associated with the * graphics object. After calling this function, the graphics object can no * longer be used to draw. Calling this method is not required since any * system resources allocated will be freed when the object is garbage * collected. However, if a program uses many graphics objects, free() * should be called whenever one is no longer needed to prevent allocating * too many system resources before garbage collection can occur. */ public native void free(); /** * Draws text at the given coordinates. The x and y coordinates specify * the upper left hand corner of the text's bounding box. * @param chars the character array to display * @param start the start position in array * @param count the number of characters to display * @param x the left coordinate of the text's bounding box * @param y the top coordinate of the text's bounding box */ public native void drawText(char chars[], int start, int count, int x, int y); /** Draws an image at the given x and y coordinates.*/ public void drawImage(Image image, int x, int y) { copyRect(image, 0, 0, image.getWidth(), image.getHeight(), x, y); } /** Draws a cursor by XORing the given rectangular area on the surface. * Since it is XORed, calling the method a second time with the same * parameters will erase the cursor. */ public native void drawCursor(int x, int y, int width, int height); /** * Draws a line at the given coordinates. The drawing includes both * endpoints of the line. */ public native void drawLine(int x1, int y1, int x2, int y2); /** * Draws a rectangle at the given coordinates. */ public void drawRect(int x, int y, int width, int height) { // NOTE: only valid for drawing rects with width >=1, height >= 1 int x2 = x + width - 1; int y2 = y + height - 1; drawLine(x, y, x2 - 1, y); drawLine(x2, y, x2, y2 - 1); drawLine(x2, y2, x + 1, y2); drawLine(x, y2, x, y + 1); } /** * Draws a dotted line at the given coordinates. Dotted lines must * be either horizontal or vertical, they can't be drawn at arbitrary angles. */ public native void drawDots(int x1, int y1, int x2, int y2); /** * Draws the outline of a polygon with the given coordinates. * The polygon is automatically closed, you should not duplicate * the start point to close the polygon. * @param x x vertex coordinates * @param y y vertex coordinates * @param count number of vertices */ public void drawPolygon(int x[], int y[], int count) { if(count < 3) return; int i = 0; for(; i < count - 1; i++) drawLine(x[i], y[i], x[i + 1], y[i + 1]); drawLine(x[i], y[i], x[0], y[0]); } /** * Draws a filled polygon with the given coordinates. * The polygon is automatically closed, you should not duplicate * the start point to close the polygon. The polygon is filled * according to Jordan's rule - a point is inside if a horizontal * line to the point intersects the polygon an odd number of times. * This function is not implemented for the PalmOS VM. Under PalmOS only * the outline of the polygon is drawn. * @param x x vertex coordinates * @param y y vertex coordinates * @param count number of vertices */ public native void fillPolygon(int x[], int y[], int count); /** * Draws text at the given coordinates. The x and y coordinates specify * the upper left hand corner of the text. */ public native void drawText(String s, int x, int y); /** * Fills a rectangular area with the current color. */ public native void fillRect(int x, int y, int width, int height); /** * Sets a clipping rectangle. Anything drawn outside of the rectangular * area specified will be clipped. Setting a clip overrides any previous clip. */ public native void setClip(int x, int y, int width, int height); /** * Sets the x, y, width and height coordinates in the rectangle passed * to the current clip coordinates. To reduce the use of temporary objects * during drawing, this method does not allocate its own rectangle * object. If there is no current clip, null will be returned and * the rectangle passed will remain unchanged. Upon success, the * rectangle passed to the method will be returned. */ public native Rect getClip(Rect r); /** * Sets the current color for drawing operations. * @param r the red value (0..255) * @param g the green value (0..255) * @param b the blue value (0..255) */ public native void setColor(int r, int g, int b); public native void setForeColor(int r, int g, int b); public native void setBackColor(int r, int g, int b); public native void setTextColor(int r, int g, int b); /** * Sets the drawing operation. The setting determines the raster * operation to use when drawing lines, rectangles, text and * images on the current surface. It also determines how pixels are * combined when copying one surface to another. The setting of * DRAW_OVER, where any drawing simply draws over the pixels on * a surface, is the default. * <p> * Not all operations are supported on all platforms. When used with * Java, DRAW_OVER is supported for all types of drawing and DRAW_XOR * is supported for drawing lines, rectangles, text and images. * However, DRAW_XOR is not supported when copying surface areas and * the DRAW_AND and DRAW_OR operations aren't supported at all under * Java. * <p> * PalmOS platforms supports all the drawing operations when drawing * images and copying surface regions. However, only the DRAW_OVER * operation is supported when drawing lines, rectangles and text. * If you need to use the XOR drawing operation for drawing lines * under PalmOS, you can draw the line into an image and then draw * the image with an XOR drawing operation. * <p> * Win32 and Windows CE platforms support all the drawing operations * except when drawing text. Only DRAW_OVER is supported when drawing * text. If you need to draw XOR'ed text, you can draw the text into * an image and then draw the image with an XOR draw operation. * <p> * When calculating the result of XOR, AND and OR drawing, the value * of the color black is all 1's (fully set) in binary and white is * all 0's (fully unset). * * @param op drawing operation * @see #DRAW_OVER * @see #DRAW_AND * @see #DRAW_OR * @see #DRAW_XOR */ public native void setDrawOp(int drawOp); /** Sets the current font for operations that draw text. */ public native void setFont(Font font); /** * Translates the origin of the current coordinate system by the given * x and y values. */ public native void translate(int x, int y); } --- NEW FILE: ISurface.java --- /* $Id: ISurface.java,v 1.1 2004/07/10 14:18:02 mriem Exp $ Copyright (c) 1998, 1999 Wabasoft All rights reserved. This software is furnished under a license and may be used only in accordance with the terms of that license. This software and documentation, and its copyrights are owned by Wabasoft and are protected by copyright law. THIS SOFTWARE AND REFERENCE MATERIALS ARE PROVIDED "AS IS" WITHOUT WARRANTY AS TO THEIR PERFORMANCE, MERCHANTABILITY, FITNESS FOR ANY PARTICULAR PURPOSE, OR AGAINST INFRINGEMENT. WABASOFT ASSUMES NO RESPONSIBILITY FOR THE USE OR INABILITY TO USE THIS SOFTWARE. WABASOFT SHALL NOT BE LIABLE FOR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES RESULTING FROM THE USE OF THIS PRODUCT. WABASOFT SHALL HAVE NO LIABILITY OR RESPONSIBILITY FOR SOFTWARE ALTERED, MODIFIED, OR CONVERTED BY YOU OR A THIRD PARTY, DAMAGES RESULTING FROM ACCIDENT, ABUSE OR MISAPPLICATION, OR FOR PROBLEMS DUE TO THE MALFUNCTION OF YOUR EQUIPMENT OR SOFTWARE NOT SUPPLIED BY WABASOFT. */ package waba.fx; /** * ISurface is an interface implemented by drawing surfaces. * <p> * MainWindow and Image are two classes that implement the ISurface interface. */ public interface ISurface { } --- NEW FILE: Image.java --- /* $Id: Image.java,v 1.1 2004/07/10 14:18:02 mriem Exp $ Copyright (c) 1998, 1999 Wabasoft All rights reserved. This software is furnished under a license and may be used only in accordance with the terms of that license. This software and documentation, and its copyrights are owned by Wabasoft and are protected by copyright law. THIS SOFTWARE AND REFERENCE MATERIALS ARE PROVIDED "AS IS" WITHOUT WARRANTY AS TO THEIR PERFORMANCE, MERCHANTABILITY, FITNESS FOR ANY PARTICULAR PURPOSE, OR AGAINST INFRINGEMENT. WABASOFT ASSUMES NO RESPONSIBILITY FOR THE USE OR INABILITY TO USE THIS SOFTWARE. WABASOFT SHALL NOT BE LIABLE FOR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES RESULTING FROM THE USE OF THIS PRODUCT. WABASOFT SHALL HAVE NO LIABILITY OR RESPONSIBILITY FOR SOFTWARE ALTERED, MODIFIED, OR CONVERTED BY YOU OR A THIRD PARTY, DAMAGES RESULTING FROM ACCIDENT, ABUSE OR MISAPPLICATION, OR FOR PROBLEMS DUE TO THE MALFUNCTION OF YOUR EQUIPMENT OR SOFTWARE NOT SUPPLIED BY WABASOFT. */ package waba.fx; /** * Image is a rectangular image. * <p> * You can draw into an image and copy an image to a surface using a Graphics * object. * @see Graphics */ public class Image implements ISurface { int width; int height; /** * Creates an image of the specified width and height. The image has * a color depth (number of bitplanes) and color map that matches the * default drawing surface. */ public Image(int width, int height) { useImagePalette(true); this.width = width; this.height = height; _nativeCreate(); } private native void _nativeCreate(); /** * Loads and constructs an image from a file. The path given is the path to the * image file. The file must be in 2, 16 or 256 color uncompressed BMP bitmap * format. If the image cannot be loaded, the image constructed will have * a width and height of 0. */ public Image(String path) { useImagePalette(true); _nativeLoad(path); } private native void _nativeLoad(String path); /** * Creates an image of the specified width and height. The image has * a color depth (number of bitplanes) and color map that matches the * default drawing surface. *<p> *Set enable to false, when system palette matches that of the image for *faster performance. */ public Image(int width, int height, boolean enable) { useImagePalette(enable); this.width = width; this.height = height; _nativeCreate(); } /** * Loads and constructs an image from a file. The path given is the path to the * image file. The file must be in 2, 16 or 256 color uncompressed BMP bitmap * format. If the image cannot be loaded, the image constructed will have * a width and height of 0. *<p> *Set enable to false, when system palette matches that of the image for *faster performance. */ public Image(String path, boolean enable) { useImagePalette(enable); _nativeLoad(path); } /** * Sets one or more row(s) of pixels in an image. This method sets the values of * a number of pixel rows in an image and is commonly used when writing code * to load an image from a stream such as a file. The source pixels byte array * must be in 1, 4 or 8 bit per pixel format with a matching color map size * of 2, 16 or 256 colors. * <p> * Each color in the color map of the source pixels is identified by a single * integer value. The integer is composed of 8 bits (value [0..255]) of red, * green and blue using the following calculation: * <pre> * int color = (red << 16) | (green << 8) | blue; * </pre> * As an example, to load a 16 color image, we would pass bitsPerPixel * as 4 and would create a int array of 16 values for the color map. * Then we would set each of the values in the color map to the colors * used using the equation above. We could then either read data line * by line from the source stream, calling this method for each row of * pixels or could read a number of rows at once and then call this * method to set the pixels. * <p> * The former approach uses less memory, the latter approach is faster. * * @param bitsPerPixel bits per pixel of the source pixels (1, 4 or 8) * @param colorMap the color map of the source pixels (must be 2, 16 or 256 in length) * @param bytesPerRow number of bytes per row of pixels in the source pixels array * @param numRows the number of rows of pixels in the source pixels array * @param y y coordinate in the image to start setting pixels * @param pixels array containing the source pixels */ public native void setPixels(int bitsPerPixel, int colorMap[], int bytesPerRow, int numRows, int y, byte pixels[]); /** * Sets the image width and height to 0 and frees any systems resources * associated with the image. */ public native void free(); public native void useImagePalette(boolean enable); /** Returns the height of the image. */ public int getHeight() { return height; } /** Returns the width of the image. */ public int getWidth() { return width; } } --- NEW FILE: Rect.java --- /* $Id: Rect.java,v 1.1 2004/07/10 14:18:02 mriem Exp $ Copyright (c) 1998, 1999 Wabasoft All rights reserved. This software is furnished under a license and may be used only in accordance with the terms of that license. This software and documentation, and its copyrights are owned by Wabasoft and are protected by copyright law. THIS SOFTWARE AND REFERENCE MATERIALS ARE PROVIDED "AS IS" WITHOUT WARRANTY AS TO THEIR PERFORMANCE, MERCHANTABILITY, FITNESS FOR ANY PARTICULAR PURPOSE, OR AGAINST INFRINGEMENT. WABASOFT ASSUMES NO RESPONSIBILITY FOR THE USE OR INABILITY TO USE THIS SOFTWARE. WABASOFT SHALL NOT BE LIABLE FOR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES RESULTING FROM THE USE OF THIS PRODUCT. WABASOFT SHALL HAVE NO LIABILITY OR RESPONSIBILITY FOR SOFTWARE ALTERED, MODIFIED, OR CONVERTED BY YOU OR A THIRD PARTY, DAMAGES RESULTING FROM ACCIDENT, ABUSE OR MISAPPLICATION, OR FOR PROBLEMS DUE TO THE MALFUNCTION OF YOUR EQUIPMENT OR SOFTWARE NOT SUPPLIED BY WABASOFT. */ package waba.fx; /** * Rect is a rectangle. */ public class Rect { /** x position */ public int x; /** y position */ public int y; /** rectangle width */ public int width; /** rectangle height */ public int height; /** Constructs a rectangle with the given x, y, width and height. */ public Rect(int x, int y, int width, int height) { this.x = x; this.y = y; this.width = width; this.height = height; } } --- NEW FILE: Sound.java --- /* $Id: Sound.java,v 1.1 2004/07/10 14:18:02 mriem Exp $ Copyright (c) 1998, 1999 Wabasoft All rights reserved. This software is furnished under a license and may be used only in accordance with the terms of that license. This software and documentation, and its copyrights are owned by Wabasoft and are protected by copyright law. THIS SOFTWARE AND REFERENCE MATERIALS ARE PROVIDED "AS IS" WITHOUT WARRANTY AS TO THEIR PERFORMANCE, MERCHANTABILITY, FITNESS FOR ANY PARTICULAR PURPOSE, OR AGAINST INFRINGEMENT. WABASOFT ASSUMES NO RESPONSIBILITY FOR THE USE OR INABILITY TO USE THIS SOFTWARE. WABASOFT SHALL NOT BE LIABLE FOR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES RESULTING FROM THE USE OF THIS PRODUCT. WABASOFT SHALL HAVE NO LIABILITY OR RESPONSIBILITY FOR SOFTWARE ALTERED, MODIFIED, OR CONVERTED BY YOU OR A THIRD PARTY, DAMAGES RESULTING FROM ACCIDENT, ABUSE OR MISAPPLICATION, OR FOR PROBLEMS DUE TO THE MALFUNCTION OF YOUR EQUIPMENT OR SOFTWARE NOT SUPPLIED BY WABASOFT. */ package waba.fx; /** * Sound is used to play sounds such as beeps and tones. * <p> * Playing beeps is supported under all platforms but tones are only supported * where the underlying platform supports generating tones. Tones aren't supported * under Java or Windows CE. * <p> * Here is an example that beeps the speaker and plays a tone: * * <pre> * Sound.beep(); * Sound.tone(4000, 300); * </pre> */ public class Sound { /** Plays the device's default beep sound. */ public native static void beep(); /** * Plays a tone of the specified frequency for the specified * duration. Tones will only play under Win32 and PalmOS, they won't * play under Java or Windows CE due to underlying platform limitations. * @param freq frequency in hertz from 32 to 32767 * @param duration duration in milliseconds */ public native static void tone(int freq, int duration); } --- NEW FILE: SoundClip.java --- /* $Id: SoundClip.java,v 1.1 2004/07/10 14:18:02 mriem Exp $ Copyright (c) 1998, 1999 Wabasoft All rights reserved. This software is furnished under a license and may be used only in accordance with the terms of that license. This software and documentation, and its copyrights are owned by Wabasoft and are protected by copyright law. THIS SOFTWARE AND REFERENCE MATERIALS ARE PROVIDED "AS IS" WITHOUT WARRANTY AS TO THEIR PERFORMANCE, MERCHANTABILITY, FITNESS FOR ANY PARTICULAR PURPOSE, OR AGAINST INFRINGEMENT. WABASOFT ASSUMES NO RESPONSIBILITY FOR THE USE OR INABILITY TO USE THIS SOFTWARE. WABASOFT SHALL NOT BE LIABLE FOR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES RESULTING FROM THE USE OF THIS PRODUCT. WABASOFT SHALL HAVE NO LIABILITY OR RESPONSIBILITY FOR SOFTWARE ALTERED, MODIFIED, OR CONVERTED BY YOU OR A THIRD PARTY, DAMAGES RESULTING FROM ACCIDENT, ABUSE OR MISAPPLICATION, OR FOR PROBLEMS DUE TO THE MALFUNCTION OF YOUR EQUIPMENT OR SOFTWARE NOT SUPPLIED BY WABASOFT. */ package waba.fx; /** * SoundClip is a sound clip. * <p> * Support for sound clips varies between platforms. Under Java, sound clips are * only supported by Java applets - not applications. This is primarily because * AudioClips in Java weren't supported in Java applications until the JDK 1.2 * without using undocumented method calls. Even when using applets, some Java * virtual machines support .wav and .au sound files and some versions don't * seem to support either format. * <p> * Using a Waba Virtual Machine, .wav format sound clips are supported under * Win32 and WinCE. The WabaVM under PalmOS has no support for sound clips. * Under Win32 and WinCE, the .wav files for sound clips must exist in a file * outside of the programs warp (resource) file. * <p> * If you're playing a sound clip under a Windows CE device and you don't hear * anything, make sure that the device is set to allow programs to play sounds. * To check the setting, look at: * <p> * Start->Settings->Volume & Sounds * <p> * for the check box: * <p> * Enable sounds for: Programs * <p> * If it is not checked on, sound clips won't play. * <p> * Here is an example that plays a sound: * * <pre> * SoundClip s = new SoundClip("sound.wav"); * s.play(); * </pre> */ public class SoundClip { String path; boolean loaded; /** * Loads and constructs a sound clip from a file. */ public SoundClip(String path) { this.path = path; loaded = false; } /** * Plays the sound clip. Returns true if the sound starts playing and false otherwise. */ public native boolean play(); } |
From: Manfred R. <mr...@us...> - 2004-07-10 14:18:14
|
Update of /cvsroot/waba/waba/src/share/classes/waba/sys In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30799/src/share/classes/waba/sys Added Files: Convert.java Runnable.java Thread.java Time.java Vm.java VmShell.java Log Message: Moved to new location --- NEW FILE: Convert.java --- /* $Id: Convert.java,v 1.1 2004/07/10 14:18:02 mriem Exp $ Copyright (c) 1998, 1999 Wabasoft All rights reserved. This software is furnished under a license and may be used only in accordance with the terms of that license. This software and documentation, and its copyrights are owned by Wabasoft and are protected by copyright law. THIS SOFTWARE AND REFERENCE MATERIALS ARE PROVIDED "AS IS" WITHOUT WARRANTY AS TO THEIR PERFORMANCE, MERCHANTABILITY, FITNESS FOR ANY PARTICULAR PURPOSE, OR AGAINST INFRINGEMENT. WABASOFT ASSUMES NO RESPONSIBILITY FOR THE USE OR INABILITY TO USE THIS SOFTWARE. WABASOFT SHALL NOT BE LIABLE FOR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES RESULTING FROM THE USE OF THIS PRODUCT. WABASOFT SHALL HAVE NO LIABILITY OR RESPONSIBILITY FOR SOFTWARE ALTERED, MODIFIED, OR CONVERTED BY YOU OR A THIRD PARTY, DAMAGES RESULTING FROM ACCIDENT, ABUSE OR MISAPPLICATION, OR FOR PROBLEMS DUE TO THE MALFUNCTION OF YOUR EQUIPMENT OR SOFTWARE NOT SUPPLIED BY WABASOFT. */ package waba.sys; /** * Convert is used to convert between objects and basic types. */ public class Convert { private Convert() { } /** * Converts the given String to an int. If the string passed is not a valid * integer, 0 is returned. */ public native static int toInt(String s); /** Converts the given boolean to a String. */ public native static String toString(boolean b); /** Converts the given char to a String. */ public native static String toString(char c); /** Converts the given float to its bit representation in IEEE 754 format. */ public native static int toIntBitwise(float f); /** Converts the given IEEE 754 bit representation of a float to a float. */ public native static float toFloatBitwise(int i); /** Converts the given float to a String. */ public native static String toString(float f); /** Converts the given double to a String. */ public native static String toString(double d); /** Converts the given int to a String. */ /** converts the string to upper case letters */ public static String toUpperCase(String s) { char[] c = s.toCharArray(); for (int i=0; i < c.length; i++) c[i] = toUpperCase(c[i]); return new String(c); } /** converts the string to lower case letters */ public static String toLowerCase(String s) { char[] c = s.toCharArray(); for (int i=0; i < c.length; i++) c[i] = toLowerCase(c[i]); return new String(c); } /** converts the char to lower case letter */ public static char toLowerCase(char c) { if ('A' <= c && c <= 'Z') c += 32; return c; } /** converts the char to upper case letter */ public static char toUpperCase(char c) { if ('a' <= c && c <= 'z') c -= 32; return c; } public native static String toString(int i); /** Converts the given long to a String. */ public native static String toString(long l); } --- NEW FILE: Runnable.java --- /* $Id: Runnable.java,v 1.1 2004/07/10 14:18:02 mriem Exp $ Copyright (c) 2000 Monaka (mon...@mo...) All rights reserved. This software is furnished under a license and may be used only in accordance with the terms of that license. This software and documentation, and its copyrights are owned by Monaka and are protected by copyright law. THIS SOFTWARE AND REFERENCE MATERIALS ARE PROVIDED "AS IS" WITHOUT WARRANTY AS TO THEIR PERFORMANCE, MERCHANTABILITY, FITNESS FOR ANY PARTICULAR PURPOSE, OR AGAINST INFRINGEMENT. AUTHOR ASSUMES NO RESPONSIBILITY FOR THE USE OR INABILITY TO USE THIS SOFTWARE. AUTHOR SHALL NOT BE LIABLE FOR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES RESULTING FROM THE USE OF THIS PRODUCT. AUTHOR SHALL HAVE NO LIABILITY OR RESPONSIBILITY FOR SOFTWARE ALTERED, MODIFIED, OR CONVERTED BY YOU OR A THIRD PARTY, DAMAGES RESULTING FROM ACCIDENT, ABUSE OR MISAPPLICATION, OR FOR PROBLEMS DUE TO THE MALFUNCTION OF YOUR EQUIPMENT OR SOFTWARE NOT SUPPLIED BY AUTHOR. */ package waba.sys; public interface Runnable { public abstract void run(); } --- NEW FILE: Thread.java --- /* $Id: Thread.java,v 1.1 2004/07/10 14:18:02 mriem Exp $ Copyright (c) 2000 Wabasoft All rights reserved. This software is furnished under a license and may be used only in accordance with the terms of that license. This software and documentation, and its copyrights are owned by Wabasoft and are protected by copyright law. THIS SOFTWARE AND REFERENCE MATERIALS ARE PROVIDED "AS IS" WITHOUT WARRANTY AS TO THEIR PERFORMANCE, MERCHANTABILITY, FITNESS FOR ANY PARTICULAR PURPOSE, OR AGAINST INFRINGEMENT. WABASOFT ASSUMES NO RESPONSIBILITY FOR THE USE OR INABILITY TO USE THIS SOFTWARE. WABASOFT SHALL NOT BE LIABLE FOR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES RESULTING FROM THE USE OF THIS PRODUCT. WABASOFT SHALL HAVE NO LIABILITY OR RESPONSIBILITY FOR SOFTWARE ALTERED, MODIFIED, OR CONVERTED BY YOU OR A THIRD PARTY, DAMAGES RESULTING FROM ACCIDENT, ABUSE OR MISAPPLICATION, OR FOR PROBLEMS DUE TO THE MALFUNCTION OF YOUR EQUIPMENT OR SOFTWARE NOT SUPPLIED BY WABASOFT. */ /* 2001.08.06 * This file is modified by Monaka (mon...@mo...) * enabled to use Runnable interface. * appended dummy code for yield. */ /* Waba Thread: <p> It works pretty much like Java's Thread class, except with few cabiats... <p> On all platforms: Everytime you use it, you have to write out as "waba.sys.Thread", instead of just "Thread". This way, Java compiler doesn't get confused with java.lang.Thread. <p> On PalmOS: Threads are implemented as "GREEN" threads which let you run threads on platforms which doesn't support native multi-threading. <p> You have to ".stop()" it, when it's done. <p> It blocks everything if ".run()" method calls other time-consuming methods. i.e. serial and socket communication. Since it blocks everything else, you don't have to do any shared-resource protection. <p> The main thread scheduler (sounds very fancy, but it's very simple) is always running, even there's no thread is running. So, it eats the battery power some more. <p> Also, the run() method is always called by the VM, so the while(true){...} is not necessary within the run() method. <p> On WinCE & Win32: Now native threading is implemented on WinCE & Win32 paltforms(11/15/2001). <p> Thus, the resolution of context switch becomes system dependent, possibly slower than green thread implementation. <p> Also any shared-resources, i.e. Graphics, GUIs, Serial Port, Socket, etc. need some kind of thread synchronization. <br> Sync methods / blocks and signal(for notify() in Java) / signalAll (notifyAll() in Java) are provided for this purpose, but they are not tested at the time of writing (2001-11-20). <p> If you could provide me some detail information of the problem when it's encountered (when and how or what caused the problem, and the trace of the situation leading up to that point), I will try to fix as much as my free time alllows (as many other open-source project). ;-( */ package waba.sys; import waba.sys.Runnable; public class Thread { private Runnable target; /** Allocate a new thread object */ public Thread(Runnable target) { this.target = target; } /** Allocate a new thread object */ public Thread() { target = null; } //private native void _nativeCreate(); /** * Causes this thread to starts execution. * After this function called, WabaVM calls run() method. * @also run() */ public final native void start(); /** * If this thread was constructed with the object Runnable inheritance, * it calls the Runnable object's run(). Otherwize it just returns and * does nothing. * * On PalmOS: * Once Threads are ".start()"ed, * the run() method is always called by the VM, * so the while(true){...} is not necessary within the run() method. */ public void run() { if (target != null) target.run(); } /** * On PalmOS: * Causes this thread to stop execution. * This method is still necessary for green threads. */ public final native void stop(); /** * Causes this thread to sleep. * <p> * On PalmOS: * @param millisecond The value is NOT based on mill-seconds, * but rather specifies how many times * a thread yields its turn to other threads. *<p> * i.e. when sleep counts are set to two different threads as threadA.sleep(1) and threadB.sleep(5), * Thread B gives up 5 turns to Thread A. * The implementation became like this, since there is no high-resolution timer * for some of the supported platforms (notably PalmOS). */ public final native void sleep(int millisecond); /** * Causes currently executed thread to pause tempolary and to enable the another thread execution. * This is not implemented yet. */ public static final /*native*/ void yield() {}; public final native void waitForSignal(); public final native void signalAll(); public final native void signal(); public static native Thread currentThread(); public static native void setPriority(int priorityNumber); } --- NEW FILE: Time.java --- /* $Id: Time.java,v 1.1 2004/07/10 14:18:02 mriem Exp $ Copyright (c) 1998, 1999 Wabasoft All rights reserved. This software is furnished under a license and may be used only in accordance with the terms of that license. This software and documentation, and its copyrights are owned by Wabasoft and are protected by copyright law. THIS SOFTWARE AND REFERENCE MATERIALS ARE PROVIDED "AS IS" WITHOUT WARRANTY AS TO THEIR PERFORMANCE, MERCHANTABILITY, FITNESS FOR ANY PARTICULAR PURPOSE, OR AGAINST INFRINGEMENT. WABASOFT ASSUMES NO RESPONSIBILITY FOR THE USE OR INABILITY TO USE THIS SOFTWARE. WABASOFT SHALL NOT BE LIABLE FOR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES RESULTING FROM THE USE OF THIS PRODUCT. WABASOFT SHALL HAVE NO LIABILITY OR RESPONSIBILITY FOR SOFTWARE ALTERED, MODIFIED, OR CONVERTED BY YOU OR A THIRD PARTY, DAMAGES RESULTING FROM ACCIDENT, ABUSE OR MISAPPLICATION, OR FOR PROBLEMS DUE TO THE MALFUNCTION OF YOUR EQUIPMENT OR SOFTWARE NOT SUPPLIED BY WABASOFT. */ package waba.sys; /** * Time identifies a date and time. * <p> * Here is an example of Time being used to display the current date: * * <pre> * Time t = new Time(); * ... * g.drawText("Today is " + t.year + "/" + t.month + "/" + t.day); * </pre> */ public class Time { /** The year as its full set of digits (year 2010 is 2010). */ public int year; /** The month in the range of 1 to 12. */ public int month; /** The day in the range of 1 to the last day in the month. */ public int day; /** The hour in the range of 0 to 23. */ public int hour; /** The minute in the range of 0 to 59. */ public int minute; /** The second in the range of 0 to 59. */ public int second; /** Milliseconds in the range of 0 to 999. */ public int millis; /** * Constructs a time object set to the current date and time. */ public Time() { _nativeCreate(); } private native void _nativeCreate(); } --- NEW FILE: Vm.java --- /* $Id: Vm.java,v 1.1 2004/07/10 14:18:02 mriem Exp $ Copyright (c) 1998, 1999 Wabasoft All rights reserved. This software is furnished under a license and may be used only in accordance with the terms of that license. This software and documentation, and its copyrights are owned by Wabasoft and are protected by copyright law. THIS SOFTWARE AND REFERENCE MATERIALS ARE PROVIDED "AS IS" WITHOUT WARRANTY AS TO THEIR PERFORMANCE, MERCHANTABILITY, FITNESS FOR ANY PARTICULAR PURPOSE, OR AGAINST INFRINGEMENT. WABASOFT ASSUMES NO RESPONSIBILITY FOR THE USE OR INABILITY TO USE THIS SOFTWARE. WABASOFT SHALL NOT BE LIABLE FOR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES RESULTING FROM THE USE OF THIS PRODUCT. WABASOFT SHALL HAVE NO LIABILITY OR RESPONSIBILITY FOR SOFTWARE ALTERED, MODIFIED, OR CONVERTED BY YOU OR A THIRD PARTY, DAMAGES RESULTING FROM ACCIDENT, ABUSE OR MISAPPLICATION, OR FOR PROBLEMS DUE TO THE MALFUNCTION OF YOUR EQUIPMENT OR SOFTWARE NOT SUPPLIED BY WABASOFT. */ package waba.sys; /** * Vm contains various system level methods. * <p> * This class contains methods to copy arrays, obtain a timestamp, * sleep and get platform and version information. */ // NOTE: // In the future, these methods may include getting unique object id's, // getting object classes, sleep (for single threaded apps), // getting amount of memory used/free, etc. // The reason these methods should appear in this class and not somewhere // like the Object class is because each method added to the Object class // adds one more method to every object in the system. public class Vm { private Vm() { } /** * Copies the elements of one array to another array. This method returns * true if the copy is successful. It will return false if the array types * are not compatible or if either array is null. If the length parameter * would cause the copy to read or write past the end of one of the arrays, * an index out of range error will occur. If false is returned then no * copying has been performed. * @param srcArray the array to copy elements from * @param srcStart the starting position in the source array * @param dstArray the array to copy elements to * @param dstStart the starting position in the destination array * @param length the number of elements to copy */ public static native boolean copyArray(Object srcArray, int srcStart, Object dstArray, int dstStart, int length); /** * Returns true if the system supports a color display and false otherwise. */ public static native boolean isColor(); /** * Returns a time stamp in milliseconds. The time stamp is the time * in milliseconds since some arbitrary starting time fixed when * the VM starts executing. The maximum time stamp value is (1 << 30) and * when it is reached, the timer will reset to 0 and will continue counting * from there. */ public static native int getTimeStamp(); /** Returns the platform the Virtual Machine is running under as a string. */ public static native String getPlatform(); /** * Returns the username of the user running the Virutal Machine. Because of * Java's security model, this method will return null when called in a Java * applet. This method will also return null under most WinCE devices (that * will be fixed in a future release). */ public static native String getUserName(); /** * Returns the version of the Waba Virtual Machine. The major version is * base 100. For example, version 1.0 has value 100. Version 2.0 has a * version value of 200. A beta 0.8 VM will have version 80. */ public static int getVersion() { return 150; } /** * Executes a command. * <p> * As an example, the following call could be used to run the command * "scandir /p mydir" under Java, Win32 or WinCE: * <pre> * int result = Vm.exec("scandir", "/p mydir", 0, true); * </pre> * This example executes the Scribble program under PalmOS: * <pre> * Vm.exec("Scribble", null, 0, false); * </pre> * This example executes the web clipper program under PalmOS, telling * it to display a web page by using launchCode 54 (CmdGoToURL). * <pre> * Vm.exec("Clipper", "http://www.yahoo.com", 54, true); * </pre> * The args parameter passed to this method is the arguments string * to pass to the program being executed. * <p> * The launchCode parameter is only used under PalmOS. Under PalmOS, it is * the launch code value to use when the Vm calls SysUIAppSwitch(). * If 0 is passed, the default launch code (CmdNormalLaunch) is used to * execute the program. * <p> * The wait parameter passed to this method determines whether to execute * the command asynchronously. If false, then the method will return without * waiting for the command to complete execution. If true, the method will * wait for the program to finish executing and the return value of the * method will be the value returned from the application under Java, Win32 * and WinCE. * <p> * Under PalmOS, the wait parameter is ignored since executing another * program terminates the running program. * * @param command the command to execute * @param args command arguments * @param launchCode launch code for PalmOS applications * @param wait whether to wait for the command to complete execution before returning */ public static native int exec(String command, String args, int launchCode, boolean wait); /** * Sets the device's "auto-off" time. This is the time in seconds where, if no * user interaction occurs with the device, it turns off. To keep the device always * on, pass 0. This method only works under PalmOS. The integer returned is * the previous auto-off time in seconds. */ public static native int setDeviceAutoOff(int seconds); /** * Causes the VM to pause execution for the given number of milliseconds. * @param millis time to sleep in milliseconds */ public static native void sleep(int millis); } --- NEW FILE: VmShell.java --- /* $Id: VmShell.java,v 1.1 2004/07/10 14:18:02 mriem Exp $ Copyright (c) 2000 SmartData This software is furnished under a license and may be used only in accordance with the terms of that license. This software and documentation, and its copyrights are owned by SmartData and are protected by copyright law. THIS SOFTWARE AND REFERENCE MATERIALS ARE PROVIDED "AS IS" WITHOUT WARRANTY AS TO THEIR PERFORMANCE, MERCHANTABILITY, FITNESS FOR ANY PARTICULAR PURPOSE, OR AGAINST INFRINGEMENT. SMARTDATA ASSUMES NO RESPONSIBILITY FOR THE USE OR INABILITY TO USE THIS SOFTWARE. SMARTDATA SHALL NOT BE LIABLE FOR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES RESULTING FROM THE USE OF THIS PRODUCT. SMARTDATA SHALL HAVE NO LIABILITY OR RESPONSIBILITY FOR SOFTWARE ALTERED, MODIFIED, OR CONVERTED BY YOU OR A THIRD PARTY, DAMAGES RESULTING FROM ACCIDENT, ABUSE OR MISAPPLICATION, OR FOR PROBLEMS DUE TO THE MALFUNCTION OF YOUR EQUIPMENT OR SOFTWARE NOT SUPPLIED BY SMARTDATA. */ package waba.sys; /** * Vm contains various system level methods. * <p> * This class contains methods to copy arrays, obtain a timestamp, * sleep and get platform and version information. */ // NOTE: // In the future, these methods may include getting unique object id's, // getting object classes, sleep (for single threaded apps), // getting amount of memory used/free, etc. // The reason these methods should appear in this class and not somewhere // like the Object class is because each method added to the Object class // adds one more method to every object in the system. public class VmShell { private VmShell() {} public static native void print(String str); public static native void println(String str); } |
From: Manfred R. <mr...@us...> - 2004-07-10 14:18:14
|
Update of /cvsroot/waba/waba/src/share/classes/java/lang In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30799/src/share/classes/java/lang Added Files: CharSequence.java Comparable.java Exception.java Object.java Runnable.java RuntimeException.java String.java StringBuffer.java System.java Thread.java Throwable.java Log Message: Moved to new location --- NEW FILE: CharSequence.java --- /* * $Id: CharSequence.java,v 1.1 2004/07/10 14:18:01 mriem Exp $ * * Copyright (c) 2004 Waba @ Sourceforge. All Rights Reserved. */ package java.lang; /** * @author Manfred N. Riem (mr...@us...) * @version $Revision: 1.1 $ */ public interface CharSequence { } --- NEW FILE: Comparable.java --- /* * $Id: Comparable.java,v 1.1 2004/07/10 14:18:01 mriem Exp $ * * Copyright (c) 2004 Waba @ Sourceforge. All Rights Reserved. */ package java.lang; /** * @author Manfred N. Riem (mr...@us...) * @version $Revision: 1.1 $ */ public interface Comparable { } --- NEW FILE: Exception.java --- /* * $Id: Exception.java,v 1.1 2004/07/10 14:18:01 mriem Exp $ * * Copyright (c) 2004 Waba @ Sourceforge. All Rights Reserved. */ package java.lang; /** * @author Manfred N. Riem (mr...@us...) * @version $Revision: 1.1 $ */ public class Exception extends Throwable { /** */ public Exception() { } /** */ public Exception(String message) { super(message); } } --- NEW FILE: Object.java --- /* * $Id: Object.java,v 1.1 2004/07/10 14:18:01 mriem Exp $ * * Copyright (c) 2004 Waba @ Sourceforge. All Rights Reserved. */ package java.lang; /** * Every object in Java inherits from this class. <p> * * @author Manfred N. Riem (mr...@us...) * @version $Revision: 1.1 $ */ public class Object { } --- NEW FILE: Runnable.java --- /* * $Id: Runnable.java,v 1.1 2004/07/10 14:18:01 mriem Exp $ * * Copyright (c) 2004 Waba @ Sourceforge. All Rights Reserved. */ package java.lang; /** * @author Manfred N. Riem (mr...@us...) * @version $Revision: 1.1 $ */ public interface Runnable { } --- NEW FILE: RuntimeException.java --- /* * $Id: RuntimeException.java,v 1.1 2004/07/10 14:18:01 mriem Exp $ * * Copyright (c) 2004 Waba @ Sourceforge. All Rights Reserved. */ package java.lang; /** * @author Manfred N. Riem (mr...@us...) * @version $Revision: 1.1 $ */ public class RuntimeException extends Exception { /** */ public RuntimeException() { } /** */ public RuntimeException(String message) { super(message); } } --- NEW FILE: String.java --- /* * $Id: String.java,v 1.1 2004/07/10 14:18:01 mriem Exp $ * * Copyright (c) 2004 Waba @ Sourceforge. All Rights Reserved. */ package java.lang; import java.io.Serializable; /** * @author Manfred N. Riem (mr...@us...) * @version $Revision: 1.1 $ */ public class String implements Serializable, Comparable, CharSequence { /** */ public String(byte[] bytes, int offset, int length) { throw new RuntimeException("Not supported"); } /** */ public String(char[] value) { } /** */ public String(char[] value, int offset, int count) { } /** */ public char charAt(int index) { throw new RuntimeException("Not supported"); } /** */ public int compareTo(Object o) { throw new RuntimeException("Not supported"); } /** */ public boolean equals(Object anObject) { throw new RuntimeException("Not supported"); } /** */ public int indexOf(int ch) { throw new RuntimeException("Not supported"); } /** */ public int indexOf(int ch, int fromIndex) { throw new RuntimeException("Not supported"); } /** */ public int length() { throw new RuntimeException("Not supported"); } /** */ public CharSequence subSequence(int start, int end) { throw new RuntimeException("Not supported"); } /** */ public String substring(int beginIndex) { throw new RuntimeException("Not supported"); } /** */ public String substring(int beginIndex, int endIndex) { throw new RuntimeException("Not supported"); } /** * Converts this string to an array of characters. <p> * * @return the newly allocated character array. */ public char[] toCharArray() { throw new RuntimeException("Not supported"); } } --- NEW FILE: StringBuffer.java --- /* * $Id: StringBuffer.java,v 1.1 2004/07/10 14:18:01 mriem Exp $ * * Copyright (c) 2004 Waba @ Sourceforge. All Rights Reserved. */ package java.lang; import java.io.Serializable; /** * @author Manfred N. Riem (mr...@us...) * @version $Revision: 1.1 $ */ public class StringBuffer implements Serializable, CharSequence { /** */ public StringBuffer append(char c) { throw new RuntimeException("Not supported"); } /** */ public StringBuffer append(int i) { throw new RuntimeException("Not supported"); } /** */ public StringBuffer append(String str) { throw new RuntimeException("Not supported"); } /** */ public char charAt(int index) { throw new RuntimeException("Not supported"); } /** */ public int length() { throw new RuntimeException("Not supported"); } /** */ public CharSequence subSequence(int start, int end) { throw new RuntimeException("Not supported"); } /** */ public String toString() { throw new RuntimeException("Not supported"); } } --- NEW FILE: System.java --- /* * $Id: System.java,v 1.1 2004/07/10 14:18:01 mriem Exp $ * * Copyright (c) 2004 Waba @ Sourceforge. All Rights Reserved. */ package java.lang; import java.io.PrintStream; /** * @author Manfred N. Riem (mr...@us...) * @version $Revision: 1.1 $ */ public class System { /** * Stores the static "standard" output stream. <p> */ public static final PrintStream out = null; } --- NEW FILE: Thread.java --- /* * $Id: Thread.java,v 1.1 2004/07/10 14:18:01 mriem Exp $ * * Copyright (c) 2004 Waba @ Sourceforge. All Rights Reserved. */ package java.lang; /** * @author Manfred N. Riem (mr...@us...) * @version $Revision: 1.1 $ */ public class Thread implements java.lang.Runnable { /** */ public void run() { } } --- NEW FILE: Throwable.java --- /* * $Id: Throwable.java,v 1.1 2004/07/10 14:18:01 mriem Exp $ * * Copyright (c) 2004 Waba @ Sourceforge. All Rights Reserved. */ package java.lang; /** * @author Manfred N. Riem (mr...@us...) * @version $Revision: 1.1 $ */ public class Throwable { /** */ public Throwable() { } /** */ public Throwable(String message) { } } |
Update of /cvsroot/waba/waba/src/share/classes/waba/ui In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30799/src/share/classes/waba/ui Added Files: Button.java Check.java Container.java Control.java ControlEvent.java Edit.java Event.java IKeys.java KeyEvent.java Label.java MainWindow.java PalmOsPref.java PenEvent.java Radio.java ScrollPane.java ScrollPanel.java Tab.java TabBar.java Timer.java ToolBar.java WabaAbout.java WabaPref.java Welcome.java Window.java Log Message: Moved to new location --- NEW FILE: Button.java --- /* $Id: Button.java,v 1.1 2004/07/10 14:18:02 mriem Exp $ Copyright (c) 1998, 1999 Wabasoft All rights reserved. This software is furnished under a license and may be used only in accordance with the terms of that license. This software and documentation, and its copyrights are owned by Wabasoft and are protected by copyright law. THIS SOFTWARE AND REFERENCE MATERIALS ARE PROVIDED "AS IS" WITHOUT WARRANTY AS TO THEIR PERFORMANCE, MERCHANTABILITY, FITNESS FOR ANY PARTICULAR PURPOSE, OR AGAINST INFRINGEMENT. WABASOFT ASSUMES NO RESPONSIBILITY FOR THE USE OR INABILITY TO USE THIS SOFTWARE. WABASOFT SHALL NOT BE LIABLE FOR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES RESULTING FROM THE USE OF THIS PRODUCT. WABASOFT SHALL HAVE NO LIABILITY OR RESPONSIBILITY FOR SOFTWARE ALTERED, MODIFIED, OR CONVERTED BY YOU OR A THIRD PARTY, DAMAGES RESULTING FROM ACCIDENT, ABUSE OR MISAPPLICATION, OR FOR PROBLEMS DUE TO THE MALFUNCTION OF YOUR EQUIPMENT OR SOFTWARE NOT SUPPLIED BY WABASOFT. */ package waba.ui; import waba.fx.*; import waba.sys.Vm; /** * Button is a push button control. * <p> * Here is an example showing a push button being used: * * <pre> * public class MyProgram extends MainWindow * { * Button pushB; * * public void onStart() * { * pushB = new Button("Push me"); * pushB.setRect(10, 10, 80, 30); * add(pushB); * } * * public void onEvent(Event event) * { * if (event.type == ControlEvent.PRESSED && * event.target == pushB) * { * ... handle pushB being pressed * </pre> */ public class Button extends Control { //static boolean isToggledDownStaticCopy; Image buttonImage; String text; Font font; boolean armed; boolean isTogglable; boolean isToggledDown; int imgWidth, imgHeight; /** Creates a button displaying the given text. */ public Button(String text) { this.init(text, null, false); } public Button(String text, boolean togglable) { this.init(text, null, togglable); } public Button(Image passedButtonImage) { this.init(null, passedButtonImage, false); } public Button(Image passedButtonImage, boolean togglable) { this.init(null, passedButtonImage, togglable); } public Button(String text, Image passedButtonImage) { this.init(text, passedButtonImage, false); } public Button(String text, Image passedButtonImage, boolean togglable) { this.init(text, passedButtonImage, togglable); } private void init(String text, Image passedButtonImage, boolean togglable) { this.font = MainWindow.defaultFont; this.isTogglable = togglable; this.isToggledDown = false; if(text != null) this.text = text; if(passedButtonImage != null) { buttonImage = passedButtonImage; imgWidth = buttonImage.getWidth(); imgHeight = buttonImage.getHeight(); } } public void press() { armed = true; isToggledDown = true; repaint(); } public void release() { armed = false; isToggledDown = false; repaint(); } /** Sets the text that is displayed in the button. */ public void setText(String text) { this.text = text; repaint(); } /** Gets the text displayed in the button. */ public String getText() { return text; } /** Sets the image that is displayed in the button. */ public void setImage(Image passedButtonImage) { this.buttonImage = passedButtonImage; imgWidth = buttonImage.getWidth(); imgHeight = buttonImage.getHeight(); repaint(); } /** Gets the image that is displayed in the button. */ public Image getImage() { return this.buttonImage; } /** Gets the image that is displayed in the button. */ public int getImageWidth() { return imgWidth; } /** Gets the image that is displayed in the button. */ public int getImageHeight() { return imgHeight; } /** Called by the system to pass events to the button. */ public void onEvent(Event evnt) { if(evnt.type == PenEvent.PEN_DOWN) { armed = true; if(isTogglable) { isToggledDown = !isToggledDown; //isToggledDownStaticCopy = isToggledDown; } repaint(); } else if(evnt.type == PenEvent.PEN_UP) { armed = false; repaint(); PenEvent pe = (PenEvent)evnt; if(pe.x >= 0 && pe.x < this.width && pe.y >= 0 && pe.y < this.height) postEvent(new ControlEvent(ControlEvent.PRESSED, this)); } else if(evnt.type == PenEvent.PEN_DRAG) { PenEvent pe = (PenEvent)evnt; boolean lArmed = false; if(pe.x >= 0 && pe.x < this.width && pe.y >= 0 && pe.y < this.height) lArmed = true; if(armed != lArmed) { armed = lArmed; repaint(); } } } //public static void drawButton(Graphics g, boolean armed, int width, int height) public void drawButton(Graphics g, boolean armed, int width, int height) { boolean isColor = Vm.isColor(); int x2 = width - 1; int y2 = height - 1; if(!isColor) { // draw top, bottom, left and right lines g.setColor(0, 0, 0); g.drawLine(3, 0, x2 - 3, 0); g.drawLine(3, y2, x2 - 3, y2); g.drawLine(0, 3, 0, y2 - 3); g.drawLine(x2, 3, x2, y2 - 3); //if(armed) if( (armed)||(isToggledDown) ) g.fillRect(1, 1, width - 2, height - 2); else { // draw corners (tl, tr, bl, br) g.drawLine(1, 1, 2, 1); g.drawLine(x2 - 2, 1, x2 - 1, 1); g.drawLine(1, y2 - 1, 2, y2 - 1); g.drawLine(x2 - 2, y2 - 1, x2 - 1, y2 - 1); // draw corner dots g.drawLine(1, 2, 1, 2); g.drawLine(x2 - 1, 2, x2 - 1, 2); g.drawLine(1, y2 - 2, 1, y2 - 2); g.drawLine(x2 - 1, y2 - 2, x2 - 1, y2 - 2); } } else { // top, left //if(armed) if( (armed)||(isToggledDown) ) g.setColor(0, 0, 0); else g.setColor(255, 255, 255); g.drawLine(0, 0, x2 - 1, 0); g.drawLine(0, 0, 0, y2 - 1); // top, left shadow //if(armed) if( (armed)||(isToggledDown) ) { g.setColor(130, 130, 130); g.drawLine(1, 1, x2 - 1, 1); g.drawLine(1, 1, 1, y2 - 1); } // bottom, right //if(armed) if( (armed)||(isToggledDown) ) g.setColor(255, 255, 255); else g.setColor(0, 0, 0); g.drawLine(0, y2, x2, y2); g.drawLine(x2, y2, x2, 0); // bottom, right shadow //if(!armed) if( (!armed)||(!isToggledDown) ) { g.setColor(130, 130, 130); g.drawLine(1, y2 - 1, x2 - 1, y2 - 1); g.drawLine(x2 - 1, y2 - 1, x2 - 1, 1); } } } /** Called by the system to draw the button. */ public void onPaint(Graphics g) { drawButton(g, armed, this.width, this.height); // draw label if (armed && !Vm.isColor()) g.setColor(255, 255, 255); else g.setColor(0, 0, 0); g.setFont(font); FontMetrics fm = getFontMetrics(font); int fntX = (this.width - fm.getTextWidth(text)) / 2; int fntY = (this.height - fm.getHeight()) / 2; int imgX = (this.width - imgWidth) / 2; int imgY = (this.height - imgHeight) / 2; int offset = 0; if( (armed)||(isToggledDown) ) { offset = 1; /* fntX++; fntY++; imgX++; imgY++; */ } /* if( (text != null)&&(buttonImage != null) ) { g.drawImage(buttonImage, imgX, imgY); g.drawText(text, fntX, fntY); } */ if(text != null) g.drawText(text, fntX+offset, fntY+offset); if(buttonImage != null) g.drawImage(buttonImage, imgX+offset, imgY+offset); } } --- NEW FILE: Check.java --- /* $Id: Check.java,v 1.1 2004/07/10 14:18:02 mriem Exp $ Copyright (c) 1998, 1999 Wabasoft All rights reserved. This software is furnished under a license and may be used only in accordance with the terms of that license. This software and documentation, and its copyrights are owned by Wabasoft and are protected by copyright law. THIS SOFTWARE AND REFERENCE MATERIALS ARE PROVIDED "AS IS" WITHOUT WARRANTY AS TO THEIR PERFORMANCE, MERCHANTABILITY, FITNESS FOR ANY PARTICULAR PURPOSE, OR AGAINST INFRINGEMENT. WABASOFT ASSUMES NO RESPONSIBILITY FOR THE USE OR INABILITY TO USE THIS SOFTWARE. WABASOFT SHALL NOT BE LIABLE FOR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES RESULTING FROM THE USE OF THIS PRODUCT. WABASOFT SHALL HAVE NO LIABILITY OR RESPONSIBILITY FOR SOFTWARE ALTERED, MODIFIED, OR CONVERTED BY YOU OR A THIRD PARTY, DAMAGES RESULTING FROM ACCIDENT, ABUSE OR MISAPPLICATION, OR FOR PROBLEMS DUE TO THE MALFUNCTION OF YOUR EQUIPMENT OR SOFTWARE NOT SUPPLIED BY WABASOFT. */ package waba.ui; import waba.fx.*; import waba.sys.Vm; /** * Check is a check control. * <p> * Here is an example showing a check being used: * * <pre> * public class MyProgram extends MainWindow * { * Check check; * * public void onStart() * { * check = new Check("Check me"); * check.setRect(10, 10, 80, 30); * add(check); * } * * public void onEvent(Event event) * { * if (event.type == ControlEvent.PRESSED && * event.target == check) * { * ... handle check being pressed * </pre> */ public class Check extends Control { String text; Font font; boolean checked; /** Creates a check control displaying the given text. */ public Check(String text) { this.text = text; this.font = MainWindow.defaultFont; checked = false; } /** Called by the system to pass events to the check control. */ public void onEvent(Event event) { if (event.type == PenEvent.PEN_DOWN) { checked = !checked; repaint(); PenEvent pe = (PenEvent)event; if (pe.x >= 0 && pe.x < this.width && pe.y >= 0 && pe.y < this.height) postEvent(new ControlEvent(ControlEvent.PRESSED, this)); } } /** Gets the text displayed in the check. */ public String getText() { return text; } /** Returns the checked state of the control. */ public boolean getChecked() { return checked; } /** Sets the checked state of the control. */ public void setChecked(boolean checked) { if (this.checked == checked) return; this.checked = checked; repaint(); } /** Draws the check box graphic at the given position. */ public static void drawCheck(Graphics g, boolean checked, int x, int y) { int x1 = x; int y1 = y; int x2 = x + 12; int y2 = y + 12; if (Vm.isColor()) { g.setColor(130, 130, 130); g.drawLine(x1, y1, x2 - 1, y); g.drawLine(x1, y1 + 1, x1, y2 - 1); g.setColor(0, 0, 0); g.drawLine(x1 + 1, y1 + 1, x2 - 2, y1 + 1); g.drawLine(x1 + 1, y1 + 2, x1 + 1, y2 - 2); g.setColor(200, 200, 200); g.drawLine(x1 + 1, y2 - 1, x2 - 1, y2 - 1); g.drawLine(x2 - 1, y1 + 1, x2 - 1, y2 - 2); g.setColor(255, 255, 255); g.drawLine(x1, y2, x2, y2); g.drawLine(x2, y, x2, y2 - 1); g.fillRect(x + 2, y + 2, 9, 9); } else { g.setColor(0, 0, 0); g.drawRect(x1 + 1, y1 + 1, 11, 11); g.setColor(255, 255, 255); g.fillRect(x1 + 2, y1 + 2, 9, 9); } if (checked) { g.setColor(0, 0, 0); x1 = x + 3; y1 = y + 5; for (int i = 0; i < 7; i++) { g.drawLine(x1, y1, x1, y1 + 2); x1++; if (i < 2) y1++; else y1--; } } } /** Called by the system to draw the check control. */ public void onPaint(Graphics g) { int y = (this.height - 13) / 2; drawCheck(g, checked, 0, y); // draw label g.setColor(0, 0, 0); g.setFont(font); FontMetrics fm = getFontMetrics(font); int fontHeight = fm.getHeight(); y = (this.height - fontHeight) / 2; g.drawText(text, 17, y); } } --- NEW FILE: Container.java --- /* $Id: Container.java,v 1.1 2004/07/10 14:18:02 mriem Exp $ Copyright (c) 1998, 1999 Wabasoft All rights reserved. This software is furnished under a license and may be used only in accordance with the terms of that license. This software and documentation, and its copyrights are owned by Wabasoft and are protected by copyright law. THIS SOFTWARE AND REFERENCE MATERIALS ARE PROVIDED "AS IS" WITHOUT WARRANTY AS TO THEIR PERFORMANCE, MERCHANTABILITY, FITNESS FOR ANY PARTICULAR PURPOSE, OR AGAINST INFRINGEMENT. WABASOFT ASSUMES NO RESPONSIBILITY FOR THE USE OR INABILITY TO USE THIS SOFTWARE. WABASOFT SHALL NOT BE LIABLE FOR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES RESULTING FROM THE USE OF THIS PRODUCT. WABASOFT SHALL HAVE NO LIABILITY OR RESPONSIBILITY FOR SOFTWARE ALTERED, MODIFIED, OR CONVERTED BY YOU OR A THIRD PARTY, DAMAGES RESULTING FROM ACCIDENT, ABUSE OR MISAPPLICATION, OR FOR PROBLEMS DUE TO THE MALFUNCTION OF YOUR EQUIPMENT OR SOFTWARE NOT SUPPLIED BY WABASOFT. */ package waba.ui; import waba.fx.*; /** * Container is a control that contains child controls. */ public class Container extends Control { /** The children of the container. */ protected Control children; /** The tail of the children list. */ protected Control tail; /** * Adds a child control to this container. */ public void add(Control control) { if(control.parent != null) control.parent.remove(control); // set children, next, prev, tail and parent control.next = null; if (children == null) children = control; else tail.next = control; control.prev = tail; tail = control; control.parent = this; // numChildren++; control.repaint(); } /** * Removes a child control from the container. */ public void remove(Control control) { if(control.parent != this) return; // set children, next, prev, tail and parent Control prev = control.prev; Control next = control.next; if(prev == null) children = next; else prev.next = next; if(next != null) next.prev = prev; if(tail == control) tail = prev; control.next = null; control.prev = null; // numChildren--; control.repaint(); control.parent = null; } /** Returns the child located at the given x and y coordinates. */ public Control findChild(int x, int y) { Container container; Control child; container = this; while(true) { // Search tail to head since paint goes head to tail child = container.tail; while (child != null && !child.contains(x, y)) child = child.prev; if (child == null) return container; if (!(child instanceof Container)) return child; x -= child.x; y -= child.y; container = (Container)child; } } /*** Called by the system to draw the children of the container. ***/ public void paintChildren(Graphics g, int x, int y, int width, int height) { Control child = children; //while (child != null) while(child != null) { int x1 = x; int y1 = y; int x2 = x + width - 1; int y2 = y + height - 1; int cx1 = child.x; int cy1 = child.y; int cx2 = cx1 + child.width - 1; int cy2 = cy1 + child.height - 1; // Trivial clip if(x2 < cx1 || x1 > cx2 || y2 < cy1 || y1 > cy2) { child = child.next; continue; } if (x1 < cx1) x1 = cx1; if (y1 < cy1) y1 = cy1; if (x2 > cx2) x2 = cx2; if (y2 > cy2) y2 = cy2; g.setClip(x1, y1, x2 - x1 + 1, y2 - y1 + 1); g.translate(cx1, cy1); if(child.doRepaint) child.onPaint(g); g.clearClip(); if(child instanceof Container) { Container c = (Container)child; if(child.doRepaint) c.paintChildren(g, x1 - cx1, y1 - cy1, x2 - x1 + 1, y2 - y1 + 1); } g.translate(- cx1, - cy1); child = child.next; }//End of while( (child != null)&&(child.noRepaint) ) }//End of public void paintChildren(Graphics g, int x, int y, int width, int height) }//End of class Container --- NEW FILE: Control.java --- /* $Id: Control.java,v 1.1 2004/07/10 14:18:02 mriem Exp $ Copyright (c) 1998, 1999 Wabasoft All rights reserved. This software is furnished under a license and may be used only in accordance with the terms of that license. This software and documentation, and its copyrights are owned by Wabasoft and are protected by copyright law. THIS SOFTWARE AND REFERENCE MATERIALS ARE PROVIDED "AS IS" WITHOUT WARRANTY AS TO THEIR PERFORMANCE, MERCHANTABILITY, FITNESS FOR ANY PARTICULAR PURPOSE, OR AGAINST INFRINGEMENT. WABASOFT ASSUMES NO RESPONSIBILITY FOR THE USE OR INABILITY TO USE THIS SOFTWARE. WABASOFT SHALL NOT BE LIABLE FOR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES RESULTING FROM THE USE OF THIS PRODUCT. WABASOFT SHALL HAVE NO LIABILITY OR RESPONSIBILITY FOR SOFTWARE ALTERED, MODIFIED, OR CONVERTED BY YOU OR A THIRD PARTY, DAMAGES RESULTING FROM ACCIDENT, ABUSE OR MISAPPLICATION, OR FOR PROBLEMS DUE TO THE MALFUNCTION OF YOUR EQUIPMENT OR SOFTWARE NOT SUPPLIED BY WABASOFT. */ package waba.ui; import waba.fx.*; /** * Control is the base class for user-interface objects. */ public class Control { /** The control's x location */ protected int x; /** The control's y location */ protected int y; /** The control's width */ protected int width; /** The control's height */ protected int height; /** The parent of the control. */ protected Container parent; /** The control's next sibling. */ protected Control next; /** The control's previous sibling. */ protected Control prev; /*** The control's repainting control by Isao F. Yamashita 09/22/2000 ***/ protected boolean doRepaint = true; public Control() { //doRepaint = true; } /*** The control's repainting control by Isao F. Yamashita 09/22/2000 ***/ public void setRepaint(boolean enable) { doRepaint = enable; } /** * Adds a timer to a control. Each time the timer ticks, a TIMER * event will be posted to the control. The timer does * not interrupt the program during its execution at the timer interval, * it is scheduled along with application events. The timer object * returned from this method can be passed to removeTimer() to * remove the timer. Under Windows, the timer has a minimum resolution * of 55ms due to the native Windows system clock resolution of 55ms. * * @param millis the timer tick interval in milliseconds * @see ControlEvent */ public Timer addTimer(int millis) { MainWindow win = MainWindow.getMainWindow(); return win.addTimer(this, millis); } /** * Removes a timer from a control. True is returned if the timer was * found and removed and false is returned if the timer could not be * found (meaning it was not active). */ public boolean removeTimer(Timer timer) { MainWindow win = MainWindow.getMainWindow(); return win.removeTimer(timer); } /** Returns the font metrics for a given font. */ public FontMetrics getFontMetrics(Font font) { MainWindow win = MainWindow.getMainWindow(); return win.getFontMetrics(font); } /** Sets or changes a control's position and size. */ public void setRect(int x, int y, int width, int height) { if(parent != null) repaint(); this.x = x; this.y = y; this.width = width; this.height = height; if(parent != null) repaint(); } /** * Returns a copy of the control's rectangle. A control's rectangle * defines its location and size. */ public Rect getRect() { return new Rect(this.x, this.y, this.width, this.height); } /** Returns the control's parent container. */ public Container getParent() { return parent; } /** Returns the next child in the parent's list of controls. */ public Control getNext() { return next; } /** * Returns true if the given x and y coordinate in the parent's * coordinate system is contained within this control. */ public boolean contains(int x, int y) { int rx = this.x; int ry = this.y; if (x < rx || x >= rx + this.width || y < ry || y > ry + this.height) return false; return true; } /** Redraws the control. */ public void repaint() { int x = 0; int y = 0; Control c = this; while(!(c instanceof Window)) { x += c.x; y += c.y; c = c.parent; if(c == null) return; } Window win = (Window)c; win.damageRect(x, y, this.width, this.height); } /** * Creates a Graphics object which can be used to draw in the control. * This method finds the surface associated with the control, creates * a graphics assoicated with it and translates the graphics to the * origin of the control. It does not set a clipping rectangle on the * graphics. */ public Graphics createGraphics() { int x = 0; int y = 0; Control c = this; while(!(c instanceof Window)) { x += c.x; y += c.y; c = c.parent; if(c == null) return null; } Window win = (Window)c; Graphics g = new Graphics(win); g.translate(x, y); return g; } /** * Posts an event. The event pass will be posted to this control * and all the parent controls of this control (all the containers * this control is within). * @see Event */ public void postEvent(Event event) { Control c; c = this; while(c != null) { c.onEvent(event); c = c.parent; } } /** * Called to process key, pen, control and other posted events. * @param event the event to process * @see Event * @see KeyEvent * @see PenEvent */ public void onEvent(Event event) { } /** * Called to draw the control. When this method is called, the graphics * object passed has been translated into the coordinate system of the * control and the area behind the control has * already been painted. The background is painted by the top-level * window control. * @param g the graphics object for drawing * @see Graphics */ public void onPaint(Graphics g) { } }//End of class Control --- NEW FILE: ControlEvent.java --- /* $Id: ControlEvent.java,v 1.1 2004/07/10 14:18:02 mriem Exp $ Copyright (c) 1998, 1999 Wabasoft All rights reserved. This software is furnished under a license and may be used only in accordance with the terms of that license. This software and documentation, and its copyrights are owned by Wabasoft and are protected by copyright law. THIS SOFTWARE AND REFERENCE MATERIALS ARE PROVIDED "AS IS" WITHOUT WARRANTY AS TO THEIR PERFORMANCE, MERCHANTABILITY, FITNESS FOR ANY PARTICULAR PURPOSE, OR AGAINST INFRINGEMENT. WABASOFT ASSUMES NO RESPONSIBILITY FOR THE USE OR INABILITY TO USE THIS SOFTWARE. WABASOFT SHALL NOT BE LIABLE FOR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES RESULTING FROM THE USE OF THIS PRODUCT. WABASOFT SHALL HAVE NO LIABILITY OR RESPONSIBILITY FOR SOFTWARE ALTERED, MODIFIED, OR CONVERTED BY YOU OR A THIRD PARTY, DAMAGES RESULTING FROM ACCIDENT, ABUSE OR MISAPPLICATION, OR FOR PROBLEMS DUE TO THE MALFUNCTION OF YOUR EQUIPMENT OR SOFTWARE NOT SUPPLIED BY WABASOFT. */ package waba.ui; import waba.sys.*; /** * ControlEvent is an event posted by a control. */ public class ControlEvent extends Event { /** The event type for a pressed event. */ public static final int PRESSED = 300; /** The event type for a focus in event. */ public static final int FOCUS_IN = 301; /** The event type for a focus out event. */ public static final int FOCUS_OUT = 302; /** The event type for a timer event. */ public static final int TIMER = 303; public ControlEvent() { } /** * Constructs a control event of the given type. * @param type the type of event * @param c the target control */ public ControlEvent(int type, Control c) { this.type = type; target = c; timeStamp = Vm.getTimeStamp(); } } --- NEW FILE: Edit.java --- /* $Id: Edit.java,v 1.1 2004/07/10 14:18:02 mriem Exp $ Copyright (c) 1998, 1999 Wabasoft All rights reserved. This software is furnished under a license and may be used only in accordance with the terms of that license. This software and documentation, and its copyrights are owned by Wabasoft and are protected by copyright law. THIS SOFTWARE AND REFERENCE MATERIALS ARE PROVIDED "AS IS" WITHOUT WARRANTY AS TO THEIR PERFORMANCE, MERCHANTABILITY, FITNESS FOR ANY PARTICULAR PURPOSE, OR AGAINST INFRINGEMENT. WABASOFT ASSUMES NO RESPONSIBILITY FOR THE USE OR INABILITY TO USE THIS SOFTWARE. WABASOFT SHALL NOT BE LIABLE FOR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES RESULTING FROM THE USE OF THIS PRODUCT. WABASOFT SHALL HAVE NO LIABILITY OR RESPONSIBILITY FOR SOFTWARE ALTERED, MODIFIED, OR CONVERTED BY YOU OR A THIRD PARTY, DAMAGES RESULTING FROM ACCIDENT, ABUSE OR MISAPPLICATION, OR FOR PROBLEMS DUE TO THE MALFUNCTION OF YOUR EQUIPMENT OR SOFTWARE NOT SUPPLIED BY WABASOFT. */ package waba.ui; import waba.fx.*; import waba.sys.Vm; /** * Edit is a text entry control. * <p> * Here is an example showing an edit control being used: * * <pre> * public class MyProgram extends MainWindow * { * Edit edit; * * public void onStart() * { * edit = new Edit(); * edit.setRect(10, 10, 80, 30); * add(edit); * } * </pre> */ public class Edit extends Control { Font font; FontMetrics fm; Graphics drawg; // only valid while the edit has focus Timer blinkTimer; // only valid while the edit has focus //NOTE: later these should be bitflags in a state int in the Control class boolean hasFocus = false; boolean cursorShowing = false; boolean isPalmOS = false; /* Make it protected so as to be accessible by a subclass */ protected char chars[] = new char[4]; byte charWidths[] = new byte[4]; Rect clipRect; // allocated when used and reused in many cases (see code) int totalCharWidth = 0; int len = 0; int insertPosition, lastInsertPosition; int startSelectPos; int xOffset; public Edit() { String platformStr = "PalmOS"; if( platformStr.equals(Vm.getPlatform()) ) isPalmOS = true; this.font = MainWindow.defaultFont; fm = getFontMetrics (this.font); clearPosState(); } /** Return the display representation of an internal character at a given position. @param i position @return the display representation */ protected char getDisplayChar (int i) { return chars [i]; } /** Return the display representation of a given character. @param c the character @return the display representation */ protected char getDisplayChar (char c) { return c; } /** Return the display representation of all the internal characters. @return the display representation */ protected char [] getDisplayChars () { return chars; } private void clearPosState() { insertPosition = 0; lastInsertPosition = 0; startSelectPos = -1; if(Vm.isColor()) xOffset = 4; else xOffset = 1; } private int XToCharPos(int x) { int cx = xOffset; for (int i = 0; i < len; i++) { int cw = charWidths[i]; if (x <= cx + (cw / 2)) return i; cx += cw; } return len; } private int CharPosToX(int n) { int cx = xOffset; if (n > len) n = len; for (int i = 0; i < n; i++) cx += charWidths[i]; return cx; } /** * Returns the text displayed in the edit control. */ public String getText() { return new String(chars, 0, len); } /** * Sets the text displayed in the edit control. */ public void setText(String s) { chars = s.toCharArray(); len = chars.length; charWidths = null; totalCharWidth = 0; clearPosState(); repaint(); } private void draw(Graphics g, boolean cursorOnly) { /* to prevent Null exception pointer as suggested in bug #450570 */ if( g == null ) return; g.setFont(font); if(charWidths == null) { charWidths = new byte[len]; totalCharWidth = 0; for(int i = 0; i < len; i++) { int charWidth = fm.getCharWidth(getDisplayChar (i)); charWidths[i] = (byte)charWidth; totalCharWidth += charWidth; } } int height = fm.getHeight(); int xMin; int xMax; int y; if(Vm.isColor()) { xMin = 4; xMax = this.width - 4 - 1; height -= 1; y = this.height - height - 1; } else { xMin = 1; xMax = this.width - 1 - 1; y = this.height - height - 1; } if(clipRect == null) clipRect = new Rect(0, 0, 0, 0); //Get current clip rect and intersect with edit rect to set a new clip to draw in int cx1 = xMin; int cy1 = y; int cx2 = xMax; int cy2 = y + height - 1; Rect clip = g.getClip(clipRect); if(clip != null) { //Intersect current clip rect and edit rect if (cx1 < clip.x) cx1 = clip.x; if (cy1 < clip.y) cy1 = clip.y; int clipX2 = clip.x + clip.width - 1; if (cx2 > clipX2) cx2 = clipX2; int clipY2 = clip.y + clip.height - 1; if (cy2 > clipY2) cy2 = clipY2; } g.setClip(cx1, cy1, cx2 - cx1 + 1, cy2 - cy1 + 1); int x = xOffset; if(cursorOnly) ; else if(startSelectPos == -1) { //Draw unselected chars g.setColor(255, 255, 255); //Color after the text. if(isPalmOS) g.setBackColor(255, 255, 255); //Edit field background g.fillRect(xMin, y, xMax - xMin + 1, height); g.setColor(0, 0, 0); g.setTextColor(0, 0, 0); g.drawText(getDisplayChars (), 0, len, x, y); } else { //Character regions are: //0 to selection start-1 (sel1-1) to selection start (sel1) to //selection end-1 (sel2-1) to selection end (sel2) to last character int sel1 = startSelectPos; int sel2 = insertPosition; if(sel1 > sel2) { int temp = sel1; sel1 = sel2; sel2 = temp; } int sel1X = CharPosToX(sel1); int sel2X = CharPosToX(sel2); //0 to selection start-1 (sel1-1) to selection end (sel2) to last_char if(isPalmOS) g.setBackColor(255, 255, 255); g.fillRect(xMin, y, sel1X - xMin, height); g.fillRect(sel2X, y, xMax - sel2X + 1, height); //<--- Here's the glitch 05/06/2000 last cursor doesn't go away. g.setColor(0, 0, 0); if(isPalmOS) g.setTextColor(0, 0, 0); g.drawText(getDisplayChars (), 0, sel1, x, y); g.drawText(getDisplayChars (), sel2, len - sel2, sel2X, y); //Draw selection start (sel1) to selection end-1 (sel2-1) if(isPalmOS) g.setColor(255, 255, 0); else g.setColor(0, 0, 120); g.fillRect(sel1X, y, sel2X - sel1X, height); if(isPalmOS) g.setBackColor(255, 255, 0); else g.setColor(255, 255, 255); g.drawText(getDisplayChars (), sel1, sel2 - sel1, sel1X, y); } // restore clip rect if (clip == null) g.clearClip(); else g.setClip(clip.x, clip.y, clip.width, clip.height); if(!cursorOnly) { //Erase the space for the cursor at (xMin - 1) g.setColor(255, 255, 255); g.drawLine(xMin-1, y, xMin-1, y+height-1); if(isPalmOS) g.drawCursor((CharPosToX(lastInsertPosition)-1), y, 1, height); } if(hasFocus) { //Draw cursor if(isPalmOS) { if(cursorShowing) g.setColor(0, 0, 0); g.drawCursor((CharPosToX(insertPosition)-1), y, 1, height); //Immediately set back to white. //Otherwise you'll see ugly black band behind the last character. g.setColor(255, 255, 255); } else { int cx = CharPosToX(insertPosition)-1; g.drawCursor(cx, y, 1, height); } if(cursorOnly) cursorShowing = !cursorShowing; else cursorShowing = true; } else cursorShowing = false; } /** Called by the system to pass events to the edit control. */ public void onEvent(Event event) { if(charWidths == null) return; // widths have not been initialized - not added to hierarchy boolean redraw = false; boolean extendSelect = false; boolean clearSelect = false; int newinsertPosition = insertPosition; switch(event.type) { case ControlEvent.TIMER: { draw(drawg, true); return; } case ControlEvent.FOCUS_IN: { drawg = createGraphics(); hasFocus = true; redraw = true; blinkTimer = addTimer(350); break; } case ControlEvent.FOCUS_OUT: { hasFocus = false; clearPosState(); newinsertPosition = lastInsertPosition = 0; redraw = true; removeTimer(blinkTimer); break; } case KeyEvent.KEY_PRESS: { KeyEvent ke = (KeyEvent)event; boolean isPrintable; if (ke.key > 0 && ke.key < 65536 && (ke.modifiers & IKeys.ALT) == 0 && (ke.modifiers & IKeys.CONTROL) == 0) isPrintable = true; else isPrintable = false; boolean isDelete = (ke.key == IKeys.DELETE); boolean isBackspace = (ke.key == IKeys.BACKSPACE); int del1 = -1; int del2 = -1; int sel1 = startSelectPos; int sel2 = insertPosition; if(sel1 > sel2) { int temp = sel1; sel1 = sel2; sel2 = temp; } if(sel1 != -1 && (isPrintable || isDelete || isBackspace)) { del1 = sel1; del2 = sel2 - 1; } else if(isDelete) { del1 = insertPosition; del2 = insertPosition; } else if(isBackspace) { del1 = insertPosition - 1; del2 = insertPosition - 1; } if(del1 >= 0 && del2 < len) { int deleteCount = del2 - del1 + 1; int numOnRight = len - del2 - 1; for(int i = del1; i <= del2; i++) totalCharWidth -= charWidths[i]; if(numOnRight > 0) { Vm.copyArray(chars, del2 + 1, chars, del1, numOnRight); Vm.copyArray(charWidths, del2 + 1, charWidths, del1, numOnRight); } len -= deleteCount; newinsertPosition = del1; redraw = true; clearSelect = true; } if(isPrintable) { // grow the array if required (grows by 8) if(len == chars.length) { char newChars[] = new char[len + 8]; Vm.copyArray(chars, 0, newChars, 0, len); chars = newChars; byte newCharWidths[] = new byte[len + 8]; Vm.copyArray(charWidths, 0, newCharWidths, 0, len); charWidths = newCharWidths; } char c = (char)ke.key; int charWidth = fm.getCharWidth(getDisplayChar (c)); if(newinsertPosition != len) { int i = newinsertPosition; int l = len - newinsertPosition; Vm.copyArray(chars, i, chars, i + 1, l); Vm.copyArray(charWidths, i, charWidths, i + 1, l); } chars[newinsertPosition] = c; charWidths[newinsertPosition] = (byte)charWidth; len++; lastInsertPosition = newinsertPosition; //Isao newinsertPosition++; totalCharWidth += charWidth; redraw = true; clearSelect = true; } boolean isMove = false; switch (ke.key) { case IKeys.HOME: case IKeys.END: case IKeys.LEFT: case IKeys.RIGHT: case IKeys.UP: case IKeys.DOWN: { isMove = true; break; } } if(isMove) { if (ke.key == IKeys.HOME) newinsertPosition = 0; else if (ke.key == IKeys.END) newinsertPosition = len; else if (ke.key == IKeys.LEFT || ke.key == IKeys.UP) newinsertPosition--; else if (ke.key == IKeys.RIGHT || ke.key == IKeys.DOWN) newinsertPosition++; if(newinsertPosition != insertPosition) { lastInsertPosition = insertPosition; if((ke.modifiers & IKeys.SHIFT) > 0) extendSelect = true; else clearSelect = true; } } break; } case PenEvent.PEN_DOWN: { PenEvent pe = (PenEvent)event; newinsertPosition = XToCharPos(pe.x); if((pe.modifiers & IKeys.SHIFT) > 0) // shift extendSelect = true; else clearSelect = true; break; } case PenEvent.PEN_DRAG: { PenEvent pe = (PenEvent)event; newinsertPosition = XToCharPos(pe.x); if (newinsertPosition != insertPosition) { lastInsertPosition = insertPosition; extendSelect = true; } break; } default: return; } if(extendSelect) { if(startSelectPos == -1) { lastInsertPosition = insertPosition; startSelectPos = insertPosition; } else if (newinsertPosition == startSelectPos) { lastInsertPosition = -1; startSelectPos = -1; } redraw = true; } if(clearSelect && startSelectPos != -1) { lastInsertPosition = -1; startSelectPos = -1; redraw = true; } if (newinsertPosition > len) newinsertPosition = len; if (newinsertPosition < 0) newinsertPosition = 0; Graphics g = drawg; boolean insertChanged = (newinsertPosition != insertPosition); if(insertChanged && !redraw && cursorShowing) { lastInsertPosition = insertPosition; draw(g, true); // erase cursor at old insert position } if(insertChanged) { int xMin; int xMax; if(Vm.isColor()) { xMin = 4; xMax = this.width - 4 - 1; } else { //xMin = 1; //xMax = this.width - 1 - 1; xMin = 1; xMax = this.width - 1; } int x = CharPosToX(newinsertPosition); if(x - 5 < xMin) { // characters hidden on left - jump xOffset += (xMin - x) + 20; if(xOffset > xMin) xOffset = xMin; redraw = true; } if(x + 5 > xMax) { // characters hidden on right - jump xOffset -= (x - xMax) + 20; if (xOffset < xMax - totalCharWidth) xOffset = xMax - totalCharWidth; redraw = true; } if(totalCharWidth < xMax - xMin && xOffset != xMin) { xOffset = xMin; redraw = true; } } lastInsertPosition = insertPosition; insertPosition = newinsertPosition; if(redraw) draw(g, false); else if(insertChanged) { //Draw cursor at new insert position //changed by Isao F. Yamashita 01/29/2001 if(isPalmOS) draw(g, false); else draw(g, true); } if(event.type == ControlEvent.FOCUS_OUT) { drawg = null; clipRect = null; } } /** Called by the system to draw the edit control. */ public void onPaint(Graphics g) { int width = this.width; int height = this.height; int x2 = width - 1; int y2 = height - 1; if(Vm.isColor()) { // top, left g.setColor(127, 127, 127); g.drawLine(0, 0, x2 - 1, 0); g.drawLine(0, 0, 0, y2 - 1); // top, left shadow g.setColor(0, 0, 0); g.drawLine(1, 1, x2 - 2, 1); g.drawLine(1, 1, 1, y2 - 2); // bottom, right g.setColor(208, 208, 208); g.drawLine(0, y2, x2, y2); g.drawLine(x2, y2, x2, 0); g.setColor(255, 255, 255); g.fillRect(2, 2, width - 4, height - 4); } else { g.setColor(0, 0, 0); g.drawDots(0, y2, x2, y2); } draw(g, false); clipRect = null; }//End of public void onPaint(Graphics g) } --- NEW FILE: Event.java --- /* $Id: Event.java,v 1.1 2004/07/10 14:18:02 mriem Exp $ Copyright (c) 1998, 1999 Wabasoft All rights reserved. This software is furnished under a license and may be used only in accordance with the terms of that license. This software and documentation, and its copyrights are owned by Wabasoft and are protected by copyright law. THIS SOFTWARE AND REFERENCE MATERIALS ARE PROVIDED "AS IS" WITHOUT WARRANTY AS TO THEIR PERFORMANCE, MERCHANTABILITY, FITNESS FOR ANY PARTICULAR PURPOSE, OR AGAINST INFRINGEMENT. WABASOFT ASSUMES NO RESPONSIBILITY FOR THE USE OR INABILITY TO USE THIS SOFTWARE. WABASOFT SHALL NOT BE LIABLE FOR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES RESULTING FROM THE USE OF THIS PRODUCT. WABASOFT SHALL HAVE NO LIABILITY OR RESPONSIBILITY FOR SOFTWARE ALTERED, MODIFIED, OR CONVERTED BY YOU OR A THIRD PARTY, DAMAGES RESULTING FROM ACCIDENT, ABUSE OR MISAPPLICATION, OR FOR PROBLEMS DUE TO THE MALFUNCTION OF YOUR EQUIPMENT OR SOFTWARE NOT SUPPLIED BY WABASOFT. */ package waba.ui; /** * Event is the base class for all events. */ public class Event { /** The type of event. */ public int type; /** * The target of the event. For user-interface events, this is the * control the event is associated with. */ public Object target; /** * The event's timestamp. * @see waba.sys.Vm#getTimeStamp() */ public int timeStamp; } --- NEW FILE: IKeys.java --- /* $Id: IKeys.java,v 1.1 2004/07/10 14:18:02 mriem Exp $ Copyright (c) 1998, 1999 Wabasoft All rights reserved. This software is furnished under a license and may be used only in accordance with the terms of that license. This software and documentation, and its copyrights are owned by Wabasoft and are protected by copyright law. THIS SOFTWARE AND REFERENCE MATERIALS ARE PROVIDED "AS IS" WITHOUT WARRANTY AS TO THEIR PERFORMANCE, MERCHANTABILITY, FITNESS FOR ANY PARTICULAR PURPOSE, OR AGAINST INFRINGEMENT. WABASOFT ASSUMES NO RESPONSIBILITY FOR THE USE OR INABILITY TO USE THIS SOFTWARE. WABASOFT SHALL NOT BE LIABLE FOR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES RESULTING FROM THE USE OF THIS PRODUCT. WABASOFT SHALL HAVE NO LIABILITY OR RESPONSIBILITY FOR SOFTWARE ALTERED, MODIFIED, OR CONVERTED BY YOU OR A THIRD PARTY, DAMAGES RESULTING FROM ACCIDENT, ABUSE OR MISAPPLICATION, OR FOR PROBLEMS DUE TO THE MALFUNCTION OF YOUR EQUIPMENT OR SOFTWARE NOT SUPPLIED BY WABASOFT. */ package waba.ui; /** * IKeys is an interface containing values for special keys and modifiers. * <p> * Below is an example of IKeys being used. * * <pre> * public void onEvent(Event event) * { * if (event.type == KeyEvent.KEY_PRESS) * { * KeyEvent ke = (KeyEvent)event; * if ((ke.modifiers & CONTROL) > 0) * ... control key was held down * if (ke.key == PAGE_DOWN) * ... page down key pressed * </pre> */ public interface IKeys { // NOTE: The WabaVM indexes directly to these values /** modifier for alt key */ public static final int ALT = (1 << 0); /** modifier for control key */ public static final int CONTROL = (1 << 1); /** modifier for shift key */ public static final int SHIFT = (1 << 2); /** special key */ public static final int PAGE_UP = 75000; /** special key */ public static final int PAGE_DOWN = 75001; /** special key */ public static final int HOME = 75002; /** special key */ public static final int END = 75003; /** special key */ public static final int UP = 75004; /** special key */ public static final int DOWN = 75005; /** special key */ public static final int LEFT = 75006; /** special key */ public static final int RIGHT = 75007; /** special key */ public static final int INSERT = 75008; /** special key */ public static final int ENTER = 75009; /** special key */ public static final int TAB = 75010; /** special key */ public static final int BACKSPACE = 75011; /** special key */ public static final int ESCAPE = 75012; /** special key */ public static final int DELETE = 75013; /** special key */ public static final int MENU = 75014; /** special key */ public static final int COMMAND = 75015; } --- NEW FILE: KeyEvent.java --- /* $Id: KeyEvent.java,v 1.1 2004/07/10 14:18:02 mriem Exp $ Copyright (c) 1998, 1999 Wabasoft All rights reserved. This software is furnished under a license and may be used only in accordance with the terms of that license. This software and documentation, and its copyrights are owned by Wabasoft and are protected by copyright law. THIS SOFTWARE AND REFERENCE MATERIALS ARE PROVIDED "AS IS" WITHOUT WARRANTY AS TO THEIR PERFORMANCE, MERCHANTABILITY, FITNESS FOR ANY PARTICULAR PURPOSE, OR AGAINST INFRINGEMENT. WABASOFT ASSUMES NO RESPONSIBILITY FOR THE USE OR INABILITY TO USE THIS SOFTWARE. WABASOFT SHALL NOT BE LIABLE FOR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES RESULTING FROM THE USE OF THIS PRODUCT. WABASOFT SHALL HAVE NO LIABILITY OR RESPONSIBILITY FOR SOFTWARE ALTERED, MODIFIED, OR CONVERTED BY YOU OR A THIRD PARTY, DAMAGES RESULTING FROM ACCIDENT, ABUSE OR MISAPPLICATION, OR FOR PROBLEMS DUE TO THE MALFUNCTION OF YOUR EQUIPMENT OR SOFTWARE NOT SUPPLIED BY WABASOFT. */ package waba.ui; /** * KeyEvent is a key press event. */ public class KeyEvent extends Event { /** The event type for a key press event. */ public static final int KEY_PRESS = 100; /** * The key pressed or entered by other means (grafitti input). This * is either a normal character key (if the value is < 70000) or * one of the special keys defined in the IKeys interface. * @see IKeys */ public int key; /** * The state of the modifier keys when the event occured. This is a * OR'ed combination of the modifiers present in the IKeys interface. * @see IKeys */ public int modifiers; } --- NEW FILE: Label.java --- /* $Id: Label.java,v 1.1 2004/07/10 14:18:02 mriem Exp $ Copyright (c) 1998, 1999 Wabasoft All rights reserved. This software is furnished under a license and may be used only in accordance with the terms of that license. This software and documentation, and its copyrights are owned by Wabasoft and are protected by copyright law. THIS SOFTWARE AND REFERENCE MATERIALS ARE PROVIDED "AS IS" WITHOUT WARRANTY AS TO THEIR PERFORMANCE, MERCHANTABILITY, FITNESS FOR ANY PARTICULAR PURPOSE, OR AGAINST INFRINGEMENT. WABASOFT ASSUMES NO RESPONSIBILITY FOR THE USE OR INABILITY TO USE THIS SOFTWARE. WABASOFT SHALL NOT BE LIABLE FOR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES RESULTING FROM THE USE OF THIS PRODUCT. WABASOFT SHALL HAVE NO LIABILITY OR RESPONSIBILITY FOR SOFTWARE ALTERED, MODIFIED, OR CONVERTED BY YOU OR A THIRD PARTY, DAMAGES RESULTING FROM ACCIDENT, ABUSE OR MISAPPLICATION, OR FOR PROBLEMS DUE TO THE MALFUNCTION OF YOUR EQUIPMENT OR SOFTWARE NOT SUPPLIED BY WABASOFT. */ package waba.ui; import waba.fx.*; /** * Label is a text label control. * <p> * Here is an example showing a label being used: * * <pre> * public class MyProgram extends MainWindow * { * public void onStart() * { * Label label = new Label("Value:"); * label.setRect(10, 10, 80, 30); * add(label); * } * </pre> */ public class Label extends Control { /** Constant for left alignment. */ public static final int LEFT = 0; /** Constant for center alignment. */ public static final int CENTER = 1; /** Constant for right alignment. */ public static final int RIGHT = 2; Image labelImg; String text; Font font; int align; int imgWidth, imgHeight; /** * Creates a label displaying the given text with left alignment. */ public Label(String text) { this(text, LEFT); } /** * Creates a label displaying the given text with the given alignment. * @param text the text displayed * @param align the alignment * @see #LEFT * @see #RIGHT * @see #CENTER */ public Label(String text, int align) { this.text = text; this.align = align; this.font = MainWindow.defaultFont; } public Label(Image labelImage) { this.text = null; this.align = LEFT; this.labelImg = labelImage; this.font = MainWindow.defaultFont; imgWidth = labelImg.getWidth(); imgHeight = labelImg.getHeight(); } public Label(String text, Image passedlabelImg, int align) { this.text = text; this.align = align; this.labelImg = passedlabelImg; this.font = MainWindow.defaultFont; imgWidth = labelImg.getWidth(); imgHeight = labelImg.getHeight(); } /** Sets the image that is displayed in the label. */ public void setImage(Image passedlabelImg) { this.labelImg = passedlabelImg; imgWidth = labelImg.getWidth(); imgHeight = labelImg.getHeight(); repaint(); } public Image getImage() { return this.labelImg; } /** Sets the font that to be used in the label. */ public void setFont(Font font) { this.font = font; } /** Sets the font that to be used in the label. */ public Font getFont() { return this.font; } /** Sets the text that is displayed in the label. */ public void setText(String text) { this.text = text; repaint(); } /** Gets the text that is displayed in the label. */ public String getText() { return text; } /** Called by the system to draw the button. */ public void onPaint(Graphics g) { // draw label g.setColor(0, 0, 0); g.setFont(font); FontMetrics fm = getFontMetrics(font); int fntX = 0; int fntY = (this.height - fm.getHeight()) / 2; int imgX = (this.width - imgWidth) / 2; int imgY = (this.height - imgHeight) / 2; if (align == CENTER) fntX = (this.width - fm.getTextWidth(text)) / 2; else if (align == RIGHT) fntX = this.width - fm.getTextWidth(text); if(text != null) g.drawText(text, fntX, fntY); if(labelImg != null) g.drawImage(labelImg, imgX, imgY); } } --- NEW FILE: MainWindow.java --- /* $Id: MainWindow.java,v 1.1 2004/07/10 14:18:02 mriem Exp $ Copyright (c) 1998, 1999 Wabasoft All rights reserved. This software is furnished under a license and may be used only in accordance with the terms of that license. This software and documentation, and its copyrights are owned by Wabasoft and are protected by copyright law. THIS SOFTWARE AND REFERENCE MATERIALS ARE PROVIDED "AS IS" WITHOUT WARRANTY AS TO THEIR PERFORMANCE, MERCHANTABILITY, FITNESS FOR ANY PARTICULAR PURPOSE, OR AGAINST INFRINGEMENT. WABASOFT ASSUMES NO RESPONSIBILITY FOR THE USE OR INABILITY TO USE THIS SOFTWARE. WABASOFT SHALL NOT BE LIABLE FOR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES RESULTING FROM THE USE OF THIS PRODUCT. WABASOFT SHALL HAVE NO LIABILITY OR RESPONSIBILITY FOR SOFTWARE ALTERED, MODIFIED, OR CONVERTED BY YOU OR A THIRD PARTY, DAMAGES RESULTING FROM ACCIDENT, ABUSE OR MISAPPLICATION, OR FOR PROBLEMS DUE TO THE MALFUNCTION OF YOUR EQUIPMENT OR SOFTWARE NOT SUPPLIED BY WABASOFT. */ package waba.ui; import waba.fx.*; import waba.sys.Vm; /** * MainWindow is the main window of a UI based application. * <p> * All Waba programs with a user-interface must have a main window. * <p> * Here is an example showing a basic application: * * <pre> * public class MyProgram extends MainWindow * { * public void onStart() * { * ... initialization code ... * Label label = new Label("Name:"); * label.setRect(..); * add(label); * } * } * </pre> */ public class MainWindow extends Window { Timer timers; Font _cachedFont; FontMetrics _cachedFontMetrics; public static Font defaultFont = new Font("Helvetica", Font.PLAIN, 12); static MainWindow _mainWindow; /** Constructs a main window. */ public MainWindow() { _mainWindow = this; _nativeCreate(); } private native void _nativeCreate(); /** * Notifies the application that it should stop executing and exit. It will * exit after executing any pending events. If the underlying system supports * it, the exitCode passed is returned to the program that started the app. */ public native void exit(int exitCode); /** Returns the MainWindow of the current application. */ public static MainWindow getMainWindow() { return _mainWindow; } /** Returns the font metrics for a given font. */ public FontMetrics getFontMetrics(Font font) { if (font == _cachedFont) return _cachedFontMetrics; _cachedFont = font; _cachedFontMetrics = new FontMetrics(font, this); return _cachedFontMetrics; } /** * Change the font of the MainWindow */ public void setFont( Font font ) { defaultFont = font; } /** * Adds a timer to a control. This method is protected, the public * method to add a timer to a control is the addTimer() method in * the Control class. */ protected Timer addTimer(Control target, int millis) { Timer t = new Timer(); t.target = target; t.millis = millis; t.lastTick = Vm.getTimeStamp(); t.next = timers; timers = t; _onTimerTick(); return t; } /** * Removes a timer. This method returns true if the timer was found * and removed and false if the given timer could not be found. */ public boolean removeTimer(Timer timer) { if (timer == null) return false; Timer t = timers; Timer prev = null; while (t != timer) { if (t == null) return false; prev = t; t = t.next; } if (prev == null) timers = t.next; else prev.next = t.next; _onTimerTick(); return true; } /** * Called just before an application exits. */ public void onExit() { } /** * Called when an application starts. Initialization code is usually either placed * in this method or simply in the app's constructor. This method is called * just after the app's constructor is called. */ public void onStart() { } /** * Called by the VM to process timer interrupts. This method is not private * to prevent the compiler from removing it during optimization. */ public void _onTimerTick() { int minInterval = 0; int now = Vm.getTimeStamp(); Timer timer = timers; while (timer != null) { int diff = now - timer.lastTick; if (diff < 0) diff += (1 << 30); // wrap around - max stamp is (1 << 30) int interval; if (diff >= timer.millis) { // post TIMER event Control c = timer.target; _controlEvent.type = ControlEvent.TIMER; _controlEvent.target = c; c.postEvent(_controlEvent); timer.lastTick = now; interval = timer.millis; } else interval = timer.millis - diff; if (interval < minInterval || minInterval == 0) minInterval = interval; timer = timer.next; } _setTimerInterval(minInterval); if (needsPaint) _doPaint(paintX, paintY, paintWidth, paintHeight); } /** * Called to set the VM's timer interval. This method is not public, * you should use the addTimer() method in the Control class to * create a timer. */ protected native void _setTimerInterval(int milliseconds); /** * Called by the Waba VM to copy back the graphics on the off-screen buffer. * <p> * For the ultimate flexisibility, * also an user can call this method to update the screen immediately. */ public static final native void paint(); } --- NEW FILE: PalmOsPref.java --- /* $Id: PalmOsPref.java,v 1.1 2004/07/10 14:18:02 mriem Exp $ PalmOsPref.java Copyright (c) 2000 Amy High Craft, Ltd. All rights are reserved. **************************************** 01/18/2001 Isao F. Yamashita : Inital coding. */ package waba.ui; import waba.fx.*; public class PalmOsPref extends Container { Button lBtn, rBtn; Font boldFont; Font plainFont; Label screenDepthLabel, tmpLbl; String screenDepthChoice[] = {"Automatic", "Black & White", "4 Level Gray", "16 Level Gray", "256 Color", "65536 Color"}; //Notice, that I can't use bit shift operation to easily set the value here, //since '-1' and '24' is included in the selection. byte screenDepthValue[] = {-1, 1, 2, 4, 8, 16 /*, 24, 32 ... in the future */}; int screenDepthChoiceIndex = 0; byte palmOsPrefData[] = new byte[1]; byte tmpData; public PalmOsPref() { boldFont = new Font("Helvetica", Font.BOLD, 12); plainFont = new Font("Helvetica", Font.PLAIN, 12); if(getPalmOsPref(palmOsPrefData, 0, 1) != -1) { for( screenDepthChoiceIndex = 0; (screenDepthValue[screenDepthChoiceIndex] != palmOsPrefData[0])&&(screenDepthChoiceIndex < 5); screenDepthChoiceIndex++); } screenDepthLabel = new Label(screenDepthChoice[screenDepthChoiceIndex], Label.CENTER); //screenDepthLabel = new Label(String.valueOf(palmOsPrefData[0]), Label.CENTER); screenDepthLabel.setRect(38, 40, 80, 20); add(screenDepthLabel); //tmpLbl = new Label(String.valueOf(screenDepthChoiceIndex), Label.CENTER); //tmpLbl.setRect(38, 95, 80, 20); //add(tmpLbl); lBtn = new Button("<"); rBtn = new Button(">"); lBtn.setRect(38, 70, 40, 20); rBtn.setRect(78, 70, 40, 20); add(lBtn); add(rBtn); }//End of constructor public void onEvent(Event evnt) { if(evnt.type == ControlEvent.PRESSED) { if(evnt.target == lBtn) { if(screenDepthChoiceIndex > 0) screenDepthChoiceIndex--; }//End of if(evnt.target == lBtn) else if(evnt.target == rBtn) { if(screenDepthChoiceIndex < 5) screenDepthChoiceIndex++; }//End of else if(evnt.target == rBtn) palmOsPrefData[0] = screenDepthValue[screenDepthChoiceIndex]; setPalmOsPref(palmOsPrefData); screenDepthLabel.setText(screenDepthChoice[screenDepthChoiceIndex]); //screenDepthLabel.setText(String.valueOf(palmOsPrefData[0])); //tmpLbl.setText(String.valueOf(screenDepthChoiceIndex)); repaint(); }//End of if(evnt.type == ControlEvent.PRESSED) }//End of onEvent() public void onPaint(Graphics scrn) { scrn.setColor(0, 0, 0); scrn.setFont(boldFont); scrn.drawText("Force Color Setting of", 28, 10); scrn.drawText("Waba for This PalmOS to:", 18, 20); }//End of onPaint() //private final native byte[] getPalmOsPref(); private final native int getPalmOsPref(byte buf[], int start, int count); private final native void setPalmOsPref(byte[] prefData); }//End of class PalmOsPref --- NEW FILE: PenEvent.java --- /* $Id: PenEvent.java,v 1.1 2004/07/10 14:18:02 mriem Exp $ Copyright (c) 1998, 1999 Wabasoft All rights reserved. This software is furnished under a license and may be used only in accordance with the terms of that license. This software and documentation, and its copyrights are owned by Wabasoft and are protected by copyright law. THIS SOFTWARE AND REFERENCE MATERIALS ARE PROVIDED "AS IS" WITHOUT WARRANTY AS TO THEIR PERFORMANCE, MERCHANTABILITY, FITNESS FOR ANY PARTICULAR PURPOSE, OR AGAINST INFRINGEMENT. WABASOFT ASSUMES NO RESPONSIBILITY FOR THE USE OR INABILITY TO USE THIS SOFTWARE. WABASOFT SHALL NOT BE LIABLE FOR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES RESULTING FROM THE USE OF THIS PRODUCT. WABASOFT SHALL HAVE NO LIABILITY OR RESPONSIBI... [truncated message content] |
From: Manfred R. <mr...@us...> - 2004-07-10 14:18:13
|
Update of /cvsroot/waba/waba/src/share/classes/javax/accessibility In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30799/src/share/classes/javax/accessibility Added Files: Accessible.java Log Message: Moved to new location --- NEW FILE: Accessible.java --- /* * $Id: Accessible.java,v 1.1 2004/07/10 14:18:02 mriem Exp $ * * Copyright (c) 2004 Waba @ Sourceforge. All Rights Reserved. */ package javax.accessibility; /** * @author Manfred N. Riem (mr...@us...) * @version $Revision: 1.1 $ */ public interface Accessible { } |