Adding Resource Type Editors

Note: The procedure for adding new resource type editors is similar to the procedure for adding widgets.


On most systems, Builder Xcessory dynamically loads the shared library containing the callbacks. If the function AddUserDefinedEditors is in the callback library, that function is called. In the AddUserDefinedEditors function, you can make calls to other functions to register the callbacks with Builder Xcessory on all systems.

Building the library

To establish the library, build a shared library and include an object file with the function AddUserDefinedEditors defined in the file.

When Builder Xcessory starts, it searches the following locations (such that definitions in the second override definitions in the first):

{BX}/xcessory/lib/editors
{HOME}/.builderXcessory/lib/editors/

Builder Xcessory opens all shared libraries, and searches for the function AddUserDefinedEditors. Builder Xcessory calls all AddUserDefinedEditors functions it finds.

Systems running SunOS 4

On systems running SunOS 4 (or other systems where shared libraries are not feasible), you must modify your interface file (addWidgets.c in our example), and add to the AddUserDefinedEditors functions defined in the file. Then, re-link Builder Xcessory with addWidgets.c and with a new file containing the callbacks, as described in 
Chapter 2--Adding Widgets.

Adding extended editors

Builder Xcessory understands and provides editors for a large number of resource types. From time to time, you will add a widget or class component to Builder Xcessory that defines a new resource type. In order to more easily work with the new resource type, you might decide to add a new resource type editor (an extended editor) to Builder Xcessory.

Example

For example, the XmDumbLabel defines a new resource type named "justify". We will add both a simple type editor (the editor that appears in the Resource Editor) and an extended editor (the editor that appears when you click on the "..." button next to the simple editor).

Modifying the WML file

With respect to XmDumbLabel, modification of the WML file generated by Builder Xcessory is unnecessary. However, Builder Xcessory cannot recognize that the XmNjustify resource is of a special type.

Modify your WML file to include a DataType entry for the justify data type as follows:

DataType justify {
TypeName = "Justify";
TypeSize = sizeofChar;
};

Changing the resource definition

Change the resource definition for XmNjustify to the following resource:

XmNjustify:Argument{
Type=justify;
};

The next time you run Builder Xcessory, the XmNjustify resource for the XmDumbLabel widget will use the editors specified for the justify datatype. For a more detailed description of the options available in the WML file, refer toChapter 8--Modifying the WML File.

Entry points

Builder Xcessory views a resource type editor as a "black box" with only three known entry points:

  • Creation
  • Update (Display)
  • Fetch

Defining functions

We define both resource type editors for the justify resource type according the following information:

  • Two creation functions (one for the simple editor and one for the extended editor)
  • Two update functions
  • Two fetch functions

The following sections describe these functions in detail.

Documentation: