Changes in SuperWaba version 2.0 beta 4 Smarter, smaller and faster! 1. Smarter: no more desktop/device classes, no more classpath changes! Just run your program, and SW will be smart enough to select the appropriate classes! And all native methods working smoothly in both platforms. 2. Smaller: Comparing to SW 2.0beta3, the VM (prc) have now 87.7kb against 90.6kb, and the class files (pdb) have 175kb against 143kb. Hey, wait a second, the pdb is larger! Yes, but it now has more classes (Menu classes, International Char convertions, Compression, Random, RadioGroup). So, give a discount! 3. Faster: After spend two weeks on optimizations (i really love that!), the VM is 45.7% faster comparing with Waba 1.0! In the table below, you can see the results running the Bench program in my PalmProfessional (PalmOS 2.0, 1mb ram): Benchmark with examples/Bench.java (values in millis): Benchs on : Graphics+NatMeths, Loop, Field, Method, Array, GC+String (Total ms) . Waba 1.0 : 143010, 33340, 8860, 25940, 126460, 53250 (390860 ms) . SuperWaba 2.0beta3: 117220, 36030, 9640, 27570, 130740, 69980 (391180 ms) . SuperWaba 2.0beta4: 80290, 24470, 5310, 15600, 94540, 33030 (253240 ms) . SuperWaba 4.02 : 59180, 21240, 4040, 11320, 75120, 43640 (214540 ms) - 20031008 Read the ! with care. Note: now the changes can be identified in the code. Search for the number preceding the fixed item. eg: guich@200b4_1 for fix #1 (unfortunately, i only decided this at the end of this beta4 developement :-) ) . Note! The very long startup delay when running in PalmOS 2.0 is due to the memory manager of PalmOS 2.0. For a "quick" startup you need more than 550kb free. This will be solved maybe in beta5, with the new SuperWaba memory manager, which will make SW require less memory to run. ! changed DRAW_PAINT_COLOR to DRAW_REPLACE_COLOR and DRAW_SPRITE_COLOR to DRAW_SPRITE. makes much more sense. . converted gray scale's drawBitmap routine to assembler. my benchmark timmings went from 1270ms to 250ms . added constructor MainWindow(String title, byte style) to match the Window's constructor. . corrected the fatal error message that was appearing "being being". Thanks to Keith Rollin. . fixed the generation of javadoc classes for package waba.lang. . now the setRect constants can be added or subtracted by a constant. EG: PREFERRED+2 (show the control with it desired size plus 2), CENTER-10 (show the control centered minus 10 pixels to left), RIGHT-1 (show the control right justified to the container moved one pixel left), etc. . you can also use CENTER like above in the method Graphics.drawImage. . Changed in waba.ui.PushButtonGroup . now if you press inside a gap between buttons no event is throwed. . if a button name is null, that button isnt showed and dont throw events. If the buttons are all same width, then this skipped button will have the same width of the other buttons; if not, then the button(s) skipped will have a computed average size. . corrected a wrong calculation when there was more than one row with gaps between them. . simplified some methods. . now the button captions are vertically centered . corrected JustifiedContainer when the Y justify was CENTER. . Note: depending on the font, the control's PREFERRED height can stay too small. this occurs because of wrong information passed in the font's info. . corrected ListBox item selection with the mouse. Also corrected selected item cursor height. . new method extra.io.builtin.Memo static findMemo(String title, boolean ignoreCase). improved documentation regarding null Memos. . new String methods: startsWith and endsWith. . corrected compilation of Mail class. Mr.Tines sent it to me with lots of typos bugs! . new class: waba.ui.RadioGroup: It handles the click on a radio, unchecking the last selected one. It is very simple. See the javadocs to learn how to use it. . fixed a bug in the desktop when you open a messagebox and minimize the window. pointed out by imran zahid. . added static waba.ui.Event.getNextAvailableEventId(). with this, you (and all apps running) may register your events and get their id without a conflict possibility. . made waba.ui.Calculator class public. now its javadocs are also available. . corrected Edit.popupKCC, bringing the focus back to the edit before popup. . corrected bug when poping up the Keyboard and some controls painted over it. . fixed bug when the keyboard was poped up and using popupKCC and the first F11 key was ignored. ! to fix the above error, i had to change Control.postEvent in the way that it now tests if the parent of the control has changed. In this case, the event is no longer broadcasted. This can cause problems (maybe) in old programs, please let me know if this happens. . new class waba.util.Compression: applies huffman algorithm for compression in a text. thanks to Valentim Batista . now at ListBox, the selected index starts with -1. pointed by Bjoern Knafla. . added waba.util.Random class by Sean Luke. . added the Cards Shuffling classes by Imran Zahid to the examples directory. maybe in the future it will be moved to the ext\games\cards package. . added extra.ui.ProgressBar class to ext\otherUI directory. if everybody complain that its needed, than i can move to the waba.ui package. thanks again to Imran Zihad . removed the reference of rt.jar from the compilation with javac in the make.bat files. thanks to Jean Rissoto . new class waba.ui.MenuBar and waba.ui.PopupMenu. Created from scratch. The menu handles checked and disabled items. PopupMenu automatically saves the covered part of the screen and restores it after is closed. . Now if the window has a title and you click the title area, the menu (if assigned) is displayed. . new methods Window.saveBehind and Window.loadBehind. it saves and loads the area behind of the current window. Use it carefully, bc some devices may not have too much memory to keep storing the windows. . changed Keyboard.names (the string matrix that defines the keys) to public static. Maybe will be useful to customize it to other languages. . added examples\barcode, an example of how to use the barcode scanner. thanks to Andrew Chitty. ! now the _focus in Window._postEvent is always tested. if its null, move it to the current window. maybe this can have some effects that i did not realized. if so, please let me know. . fixed an error when a window was poped up and the other windows, for some reason, was repainted (as a minimize in the desktop), and the controls looked faded. . fixed an error that sometimes a superwaba application (created in a Frame) stopped generating key events to the canvas. . added a test for strings being readed by the desktop\waba.io.DataStream class. If a "possible" invalid string is readed, a warning is issued and the program fails. . fixed drawBitmap when trying to draw it at negative positions (like doing a pan in a big bitmap). Thanks to Chris Dawson. . moved "timeStamp = Vm.getTimeStamp()" ControlEvent and ScanEvent to the Event class default constructor. . fixed a bug in the UserFont and Graphics.drawText when the char was invalid. Fixed also at the device. Thanks to Jean-Eric Cuendet. . New method TabPanel.setBorderStyle: Sets the type of border. see the waba.ui.Window xxx_BORDER constants. PS: currently, only the NO_BORDER and RECT_BORDER are supported. NO_BORDER only draws the line under the tabs. Thanks to Jean-Eric Cuendet. . changed TabPanel drawing: removed the underlying line of the active tab. ! new method ListBox.drawItem, to let you extend ListBox and overload the method to draw the items. new constructors PopList(int x, int y, ListBox lb) and ComboBox(String []items, ListBox userListBox) make possible you create user defined combos. Changed also all references of String to Object in ComboBox,ListBox and PopList. thanks to Jean-Eric Cuendet (note: bc of this last modification, you must recompile your classes if you use ListBox or ComboBox) . To create an app AT THE DESKTOP just to read or write a pdb file, without a Graphical User Interface, please set the waba.applet.JavaBridge.nonGUIApp flag to true using the method setNonGUIApp. This way, the openInputStream and openOutputStream will use the FileInputStream/FileOutputStream only. Thanks to Jean Rissoto and Nick Forde Here is an example of how to do it: waba.applet.JavaBridge.nonGUIApp = true; Catalog cat = new Catalog("J:\\org\\wabavm\\palm\\desktop\\MemoDB.memo.DATA",Catalog.READ_WRITE); if (cat.isOpen()) ... When writting back the db, the path is stripped. . corrected the problem in reading some pdb files on the desktop, specially the ones created in the device. The problem relied in the fact that my routines was not prepared to find an AppInfoBlock between the header and the data. The AppInfoBlock now is readed and is available for use. Thanks to Jean Rissoto. . now all attributes readed from the pdb are stored back in case it is writted. they are also available to the programmer. improved documentation about the header fields. See desktop\waba.io.Catalog. . VERY IMPORTANT! If you open a Catalog, be sure to write the data using the same Catalog object, or you'll loose important information readed and the database may be unusable. also, the info regarding categories are writted in the appInfoBlock. if you dont want to understand how it is generated, please dont change the order of the records (by deleting/inserting in the middle) of the Memo database (and other internal databases that deals categories), because if you do that, the categories will point to the wrong record. . Now the database name is limited back to 31 characters. There is a wrong information at some documentations that says that the maximum is 32 bytes, but POSE don't agree with that. . new constructor Socket(host,port,timeout) so you can set the timeout for opening the connection. . created a method to return the total available memory of the device. EG: this is the memory available for your database. . now SW reserve 50kb of memory to dont let the user consume all the free memory and that way make sure that SW will have enough memory to start again. . fixed DRAW_REPLACE_COLOR in palm OS >= 3.5. i had to implement a (relatively slow) routine to make it work, since palm dont have the kind of operation i defined . new draw operation: DRAW_SWAP_COLORS: swap foreground and background colors. . added eraseVLineNOCT and invVLineNOCT to GraphicPalm.c. . note: this could not be done bc pose insist in give a address error where there is no address error. Keith already complained that it is an error of Pose but that it is fixed in next version. So, please wait for Pose 3.3. //bypassed emulator bug that was not updating correctly the display. thanks to Keith Rollin. . changed getBitmapPixel to getBitmapRow. improved performance in collision detect. . new method Edit.setMaxLength to set the maximum length of String that can be inputted. . Fixed the popup Keyboard backspace key not working in SPT1700 device. . new ControlEvent.WINDOW_MOVED: The event type for a recently moved window. This indicate that all the Graphic objects must be translated or reinitialized. This event is broadcasted to all controls inside the Window being moved. . new method Container.broadcastEvent. used in the above situation. . new method Graphics.drawCursorOutline. the correct name for drawCursor should be fillCursor, and then i could add drawCursor. but drawCursor fills the cursor, so i needed to use drawCursorOutline instead to keep backward compatibility. . reduced flickering when poping up windows. now, instead of repainting the full window, it repaint only the focused control, if it needsPaint. . new constructor IntHashtable(DataStream ds) and new method IntHashtable.saveTo(DataStream ds). Now the IntHashtable can easily be saved and stored from a Stream. . New method in Event: touch, to set the current time on the timeStamp member. changed some places that reuse the event to touch that event so the time is correctly updated. . fixed repaintNow: if the control is a Window, it calls doPaint instead of onPaint, repainting all controls inside it. Else, if it is a Container, it calls paintChildren. . fixed Math.rol and Math.ror. By mistake, i sent desktop\Math.java with native methods. Now all are not-native. . new methods in String class: getBytes, replace and equalsIgnoreCase. new constructors: String(byte []value) e String(byte []value, int offset, int count). The new constructor and the getBytes uses the current CharacterConverter assigned class. . new method Hashtable.get(Object). Removed all methods that has String as parameter and replaced them with method that has Object as paremeter. . MERGE OF DESKTOP/DEVICE CLASSES . moved waba.lang.* sources to java.lang. There is the right place to put them. Also, created a txt explaining what are they. . fixed onExit was not being called . new class waba.sys.CharacterConverter. The bytes are converted to char and vice-versa using the CharacterConverter associated in the charConverter member of the String class. . changed MethodsHash so it recognizes the class name is the first parameter, no need to specify the package. . modified the Warp /x command: now it test if the class names given are part (starts with) of the class name (after removing the package) . eg: /x NativeMethods4JDK may exclude waba/fx/NativeMethods4JDK$GraphicsBag.class, waba/fx/NativeMethods4JDK.class, waba/io/NativeMethods4JDK$CatalogBag.class, waba/io/NativeMethods4JDK.class, waba/sys/NativeMethods4JDK$ClipboardObserver.class, waba/sys/NativeMethods4JDK.class, waba/ui/NativeMethods4JDK.class . Convert.toString(Boolean) isnt native anymore. ! All package fields converted to private. Also, some protected fields also converted to private. So, if you extend any class of SW and something goes wrong, dont hesitate to ask me to put them back to protected! 1. fixed an error in MainWindow that it was not checking the appropriate needsPaint flag. This fix also corrected the bug of not displaying a DialogBox in the onStart method. 2. fixed clicking in the last element near the border of the ComboBox dont select it 3. added two methods sent from Zahid Inram: Random.rand(char s, char e) and rand(int s, int e). . removed constants LEFT,RIGHT,CENTER of class Label. This will be transparent to you, since the Control class already definess those constants. You'll just have to recompile your program. Thanks to Jean Rissoto . changed the warp and exegen and added Wxgn that calls both in just one class call. Thanks to Jean Rissoto 4. changed appPath tests to: if appPath == null then appPath = "./" . Added a output to make sure nobody gets surprised with this, since this can change some behaviours . somehow, this bug (of beta3) is fixed: create 2 edits. call the popupkeyboard in one. close popup keyboard. move focus to the other. call popupkeyboard. the last edit will paint over the poped up keyboard. . corrected some javadocs. 5. new emulation key: LAUNCH (isnt HOME, but LAUNCH). new constant Vm.SK_LAUNCH. Now you can intercept the launch (home) key, BUT you must create another way to exit the application. Note: SK_ALL does not intercept the SK_LAUNCH key (to maintain compatibility with older applications. You must use SK_ALL | SK_LAUNCH to intercept the launch key. 6. Graphics.drawRoundRect and fillRoundRect: If r is greater than width/2 or greater than height/2, it will be adjusted to the minimum of both values. thanks to Humphrey Bien 7. New method Vm.getSystemKeysPressed. This method returns simultaneous key presses (ideal for games). new Constants Vm.SK_PAGE_UP, Vm.SK_PAGE_DOWN. All other VM_SK constants has changed their values. Note that only some few keys can be returned in this method, and also that the key is still queued. This method is correctly being emulated in Desktop. 8. fixed rounding in toString(double). Thanks to Peter D. 9. fixed wrong count of varsNeeded in the hooks. This may be responsible for lots of annoying bugs. 10. Fixed the "light gray box" that bounds objects at device only. The bug was at the clearScreen method; it was not clearing the screen correctly. 11. fixed error when exit sw in palm os 2.0 and come back without restarting the vm. 12. new method Graphics.translateTo(x,y) to set the translation from origin. 13. fixed doubleBuffering in desktop. Thanks to Jean Rissoto for the example. 14. Eric Frik: I found if I made the small change to nmpalm_c.c the getScanManagerVersion and getScanPortDriverVersion to check for STATUS_OK instead of <= 0 the data was returned properly, otherwise it always returned empty strings... 15. fixed a bug when a bitmap was drawed in the onPaint and only a part of the bitmap was marked for repaint. 16. fixed bug when removing a control from the container. Now it changes the focus (if necessary) and repaint's the hole parent area. Thanks to John Mann for the tip. 17. automatic disable the keyboard of Visor when opening and closing the serial port. thanks to dodah12 (aka bob). 18. fixed double painting when the keyboard is poped up . Changed org/wabavm to org/superwaba. 19. fixed concurrent use of Memo and Vm.debug. 20. improved colors and fixed doublebuffer in PalmOS >= 3.5. The bugs were related, and after 1 full day of debugging i discovered that the bug was in PalmOS. PalmOS does not handle correctly bitmap convertion of a offscreen with 8bpp in a device with 4bpp. To bypass this, i had to create the asm functions to draw in 4bpp (2 days away from my deadline!). 21. fixed invVLineNOCT_Color. 22. fixed bug when using a offscreen image in color devices regarding the palette. 23. optimized Edit.draw when cursorOnly 24. changed all fonts from Helvetica to SW to improve startup speed. 25. fixed bug when a VM error was displayed and the VM crash . added examples\GuiBuilder, a handly UI designer to be used in your device. Thanks to Yehuda Miron 26. new method Convert.toStringArray(Object []) by calling toString in each object. 27. fixed array cast exception in desktop/Catalog.listCatalogs 28. fixed MessageBox when the size of the Window got bigger than the screen. 29. fixed in MessageBox the fontMetrics it uses to get the width of the Title (which is not the same of the text, since the title is in Bold) . new Welcome application, with great functionality! 30. new class waba.applet.Handy with handy method to use in the desktop side only. New handy method to parse the text that you want to display using the MessageBox class: see waba.applet.Handy.boundText. Here is an example of use: waba.applet.Handy.boundText(154,'|',getFontMetrics(getFont()),"This is a very long text and i dont want to waste my time parsing it to be fit in the MessageBox!"); 31. new constructor for Vector class: Vector(Object []startingWith). The vector still can grow in size when initializing with this. . fixed javadocs for class Window. Thanks to Tobin. 32. new member boolean Vm.onDevice: true if we're running on device. Faster than testing (Vm.getPlatform().equals("Java")). 33. fixed bug in MessageBox: now if a button is pressed and the cursor is moved out of the button, it doesnt closes the MB. 34. new constructor Catalog(Name, boolean createIfNeeded). Just a handy constructor. 35. fixed Palette.getColor(index). 36. new Image.doAntialias (very slow). 37. fixed clipping of images when creating a Graphics object. 38. fixed Graphics.getClip. . removed Window.drawOffscreen . removed PopList constructors that takes x,y as parameters. they are useless. . Scanner classes now moved to org.superwaba.palm.ext.scanner.* . Scanner native library tested and working. It is also fully documented to serve as an example to build native libraries. 39. now if were a color device, change the MainWindow background a little... 40. on Window.unpop, now if double buffer is true we free up resources. 41. new protected method Window.popupMenuBar(). 42. now you can use the arrow keys to scroll the text int the MessageBox. 43. new methods String.toUpperCase and toLowerCase (they call waba.sys.Convert methods) 44. now MessageBox uses the Graphics.drawArrow routine.