PM Support Classes

Important PM things

<JPM.hpp> defines JPM. This is a very important class. It holds the anchor block, message queue id, and current exception information for a thread. In the normal run of things, you never need to create one: there's a static one in JLib for the main thread, available when main() is called, and whenever you use JThread to create a new thread, it will create a new JPM before calling your thread function. Note the static method to obtain the current thread's JPM and the process method, used to pump the message queue. A simple main, then, would be:

int main()
{
   MyFrame fr;
   JPM::current()->process();
   return 0;
}

<JSystem.hpp> defines JSystem, this is really just a namespace for a collection of useful functions. Arguably most useful of all is JSystem::beep(), a very handy debugging aid. Also methods to get the user's preferred fonts from the ini and get sysvalues (eg. the height of a titlebar).

<JPointer.hpp> provides another namespace for doing things to the mouse pointer. If you want to capture the mouse pointer, look at JWindow::capturePointer().

<JHelp.hpp> is JLib's interface to IPF. It defines the JHelpManager class, and declares an instance of it. Use this instance, don't try to create your own. JLib supports two styles of doing help, decided upon by which version of JHelpManager::init() you call.

  1. Resource - define HELPSUBTABLE etc. records in your resource file, and everything should just work. In my experience it never does.
  2. Dynamic - JLib responds to WM_HELP messages to a frame by calling its getHelpID() method, and displaying that page of IPF. This means you should call the frame (dialog, whatever)'s setHelpID() method at a suitable juncture. Eg during construction.

Useful dialogs

<JMsgBox.hpp> defines JMsgBox, which is a message box. It has few advantages over the normal PM sort, mainly that it's less painful to provide help, and isn't restricted to appearing in the middle of the screen.

<JOpenDlg.hpp> defines JOpenDlg and a bunch of hangers-on. This allows you to use the WinFileDlg api to display PM's default file dialog. It can do interesting things, such as do the loading of selected files for you and call you back asynchronously.

<JSaveDlg.hpp> defines JSaveDlg. This is a RISC-OS style save dialog, which uses drag and drop. Asynchronous fun here too. If you want a traditional save dialog, use JOpenDlg and the makeSaveDialog() method.

Looking for a font dialog? Use JFont::pickFont().

Simple datatypes

<JBuffer.hpp> defines a bunch of classes to enable storing data, and most importantly the interface JVBuffer.

<JStr.hpp> defines JStr which is JLib's string class. JStr has reference counting and copy-on-write, making returning strings from methods by value a valid thing to do. We also have JVStr which is printf-like.

<JCoord.hpp> defines a bunch of classes to do basic geometry with, JPoint, JSize, and JRect being the most useful.

<JSwp.hpp> defines JSWP <JResID.hpp> defines a noddy JResID class, for talking about resources with.

<JMParam.hpp> defines JMP which is a C++ version of the PM MPARAM (or MRESULT) packed dword type, used in messages and things.

<JDtTime.hpp> defines classes for dealing with the date & time. OS2.ini gets looked at to work out the user's preferred formats, but there's english text hardcoded into the module for the `get long date' function.

Error handling

<JExcept.hpp> is the throbbing heart of JLib's error handling system. More info. Basically, JException gets defined here; all library exceptions are derived from this class.

<JTrace.hpp> provides the runtime debugging aid; you'll need JDebug to connect to the other end. See error handling. The instance of JTrace declared here, trace is `the' trace, if you like. Write to it to display stuff in JDebug.

PM building blocks

<JAtoms.hpp> defines JAtom, JAtomTable, and JMsgID to provide access to atoms. The msgid class is for defining unique message ids from strings, using atoms.

<JAccel.hpp> provides classes for messing around with accelerator tables, JAccel and JAccelTable.

<JIcon.hpp> defines JIcon which is a wrapper round what PM calls a HPOINTER.

<JPParam.hpp> provides an enumeration of presentation parameter types for using with JWindow::setColour.

<JProfile.hpp> defines an INI file class, JProfile. There are static members for accessing the system & user ini files.


John Fairhurst 11th June 1998