Palm Foundation Classes (PFC)

GZipped Source & Binaries | Latest Version: 0.1.0 | Updated: 9-29-2005

Status: Initial Release

Audience: Experienced PalmOS Developers

License: LGPL

PFC is a class library for writing m68k Palm OS (i.e., OS 5 and earlier) applications. It is similar to the Microsoft Foundation Classes (MFC) used to program Windows, though the similarity was, at first, accidental. The class library has been used to build production applications since 2001 (though it has grown and changed much during that time).

Currently, PFC is at an initial release state. I have been using it for the past four years, so I am fairly confident in the correctness and robustness of the existing code. However, there is little in the way of documentation at this time, and not much in the way of samples. (I can't release the source for the main applications I wrote using PFC, as they're not mine to release, but I have written some sample applications that show off the main features).

Therefore, while anyone is welcome to try out the library, I expect that those who may see the most benefit from the library in the short term are experienced PalmOS developers.

From a technical standpoint, PFC is not earth-shattering, but it does have some nice features. For instance, it uses trampolines (via the ffcall library) to overcome the problem of mapping the C-centric PalmOS API to an object-oriented framework in which multiple instances of a class wish to share a single callback function implementation, without resorting to a lookup table (and thus with a minimal loss in speed of event dispatch).

The most important feature of PFC is its event dispatching system. It relies on message maps, which may be implemented using either C macros or via explicit override of an OnEvent function, to hook event handler functions up to a backend message pump. PFC provides a slightly richer event handling abstraction than the PalmOS itself provides, making it easy to dispatch events to individual "control" classes, rather than forcing the programmer to use a single form event handler with a large switch on the message type. This aides the programmer in writing reusable control classes.

Much as I would have preferred otherwise, PFC makes only minimal use of templates because of the constraints placed on code size by the OS's 32K jump limit.

PFC's message pump is pluggable at the application, form and control levels, so functionality may be added to a PFC application by creating an instance of a plugin class and calling a method to add the plugin to the dispatch loop at the appropriate level.

PFC uses its message pump to implement some features that developers often need but for which the PalmOS provides poor or no support. For instance, PFC forms have a ShowDialog method that implements Win32-style modal dialogs (which do not return to the caller until the user has dismissed them). Palm has provided some sample code in the past regarding how to do this, but there is no single method in the API to implement it -- it has traditionally required much more work on the part of the programmer than it should.

PFC provides a mechanism for delivering events to the message pump at scheduled times, which is useful for applications such as games. A control class (PalmTimerControl) is available that uses that lower-level event scheduling ability to implement a Win32-like timer control.

PFC provides a set of data classes to aide applications in working with Palm databases. The particular set of classes implemented in PFC are probably less universally applicable than PFC's forms support, but the database support and forms support are not tied together, so applications for which the database classes are not particularly suited are not constrained to use them.