I started a thread a few weeks ago in an attempt to find a good way to provide
graphical buttons that worked on color devices and was backwards compatible with
Palm OS 3.0. I have found a solution that seems to work.
Palm OS has a graphical button that works great, but is only available on OS
versions 3.5 and later.
The usual way to provide graphical buttons that work on OS versions prior to 3.5
is to overlay a bitmap with a button (without a label). This works fine on black
and white devices, but the button does not highlight in the right colors on color
devices.
The best solution proposed for color devices was to create a font with the
appropriate bitmaps and use the custom font for the button label. There are two
drawbacks to this solution. Constructor does not allow you to specify custom
fonts for button labels. PilRC allows this, but I did not want to convert all of
my application from Constructor to PilRC. This option also does not allow you to
take advantage of some of the features of graphical buttons such as a different
bitmap for the selected state.
The solution I have come up with is as follows. Start with the bitmap and a
regular button overlay. On top of this overlay a graphical button with the bitmap
set to the same bitmap. Set the usable bit for the graphical bitmap to false.
In the frmOpenEvent of the form do a simple check of the OS version, and if it
is version 3.5 or later, show the graphical button. This solution works on OS
versions prior to 3.5 (the graphical button is hidden) and supports full graphical
buttons on OS version 3.5 and later (the graphic button is shown).
Code snippets:
At application start:
// get the ROM version
const UInt32 rom35Version = 0x03503000;
UInt32 RomVersion = 0;
FtrGet(sysFtrCreator, sysFtrNumROMVersion, & RomVersion); // update RomVersion
Form event handler:
Boolean FormHandleEvent(EventPtr eventPtr)
{
FormPtr frmPtr = FrmGetActiveForm();
switch (eventPtr->eType)
{
case frmOpenEvent:
if (RomVersion >= rom35Version)
FrmShowObject(frmPtr, FrmGetObjectIndex(frmPtr, GraphicButton));
...
break;
...
case ctlSelectEvent:
switch (eventPtr->data.ctlEnter.controlID)
{
case RegularButton:
case GraphicButton:
// process button press (common to both buttons)
break;
...
}
}
}
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/