Shortly after I began working with Sun’s Mobile Information Device Profile (MIDP) for Palm OS, I noticed two vexing limitations—adding a color icon and accessing a monospaced font. I'll share my workarounds with you here. First, I will show you how to use a custom color icon for your application. Then, I'll explain how to access a monospaced font from MIDP for Palm OS.
Supporting custom color icons
Being a developer, I couldn’t care less what kind of an icon my application displays on the Palm device desktop. But that's the kind of thing marketing folks stay up all night worrying about. So when I finally received a color icon to be used with my application, I simply opened up Sun’s tool for creating a PRC out of my standard MIDP JAR file and told it to use the icon provided to me. I was astonished when I found that my PRC file had reverted to the default icon, shown in Figure A.
After plowing through the documentation, I discovered to my absolute horror that color icons are not supported by Sun’s PRC creation tools. The workaround I devised requires you to do a bit of gathering to collect the right tools. First, you will need to download and install a demonstration version of Metrowerks CodeWarrior for Palm OS onto your development desktop. Next, you will need to download and install RsrcEdit onto the same Palm OS device as your MIDP application.
Once you have done both of these things, the workaround itself is quite simple. First, create a standard Palm OS, C-based application using CodeWarrior. Then, use CodeWarrior’s Constructor tool to create color icons for this application. In case you are unfamiliar with CodeWarrior, here are the steps to follow:
- Open the CodeWarrior for Palm OS Platform 7.0 program group on the Windows Start menu.
- Choose CodeWarrior IDE.
- In the CodeWarrior IDE, choose the Open command from the File menu.
- Open the (CodeWarrior Examples)\Metrowerks Sample Projects for Palm OS\Tic-Tac-Toe 1.1\Tic-Tac-Toe.mcp file from wherever you chose to install CodeWarrior.
- Double-click Tic-Tac-Toe.rsrc.
- Under Bitmaps, edit the following icons:
App Icon (Large, Color), as shown in Figure B
App Icon (Small, Color)
- Close the Constructor.
- Choose Make from the Project menu.
- Copy the Tic-Tac-Toe PRC file generated to your Palm OS device.
|Icons under Bitmap|
Next, load this application and RsrcEdit onto the same Palm OS device as your MIDP application. Finally, use RsrcEdit to copy the color icons from your CodeWarrior C application and paste them into your MIDP application following these steps:
- Launch RsrcEdit.
- Choose your CodeWarrior application (Tic-Tac-Toe, for example) from the drop-down list.
- Click Open.
- Choose tAIB1001 for the small icon or tAIB1000 for the large one.
- Click Open.
- To copy your icon, click the Palm’s Menu button; choose Edit, then Copy from the drop-down list.
To paste your icon into the MIDP application, repeat steps 1 through 5 for your MIDP application, but in step 6, choose Edit, then Paste from the drop-down list.
When you create new icons, you can also choose variations in color support levels (256 colors, 8 million colors, etc.), as shown in Figure C.
|Pick your color support levels.|
Writing support for monospaced fonts
The second issue involves the absence of support for a monospaced font under MIDP for Palm OS. In short, MIDP for Palm OS will never use a monospaced font. If you ask it to use a monospaced font, it will just silently ignore it. The reason for this, in fairness to Sun, is that Palm OS devices do not ship with even a single monospaced font.
To work around this limitation, you must, once again, begin with a bit of a gathering expedition on the Internet. First, download Sergey Menshikov’s excellent FontHack123 program. Next, find some monospaced fonts for Palm OS that you like and download them. A good example (in case you don’t want to search for yourself) is the Midget-Mono XS font in the Alpha Fonts collection. Finally, unzip everything and install X-Master (from the FontHack123 package), FontHack123, and your custom font all to the same device as your MIDP application.
At this point, you are ready to perform the workaround. Launch X-Master and select FontHack123 (Figure D).
Using the interface provided on the next screen, shown in Figure E, you can force any application to use the font of your choice. So depending upon how much you like your new custom font, you can associate it with:
- All—to force every application on your device to use your new font.
- Java HQ—to force every MIDP application to use your new font.
- Just your custom application.
|Interface for selecting the fonts for your applications|
After you have made this association and exited X-Master, start up your custom application. You will see that everything within it now uses your custom, monospaced font. Unfortunately, it is an all-or-nothing proposition, but it is the best workaround currently available for this limitation in MIDP for Palm OS.