[ Previous | Next | Contents | Glossary | Home | Search ]
Motif 2.1 Widget Writer's Guide

Make the Widget Accessible to Applications

After writing a widget, you will need to test it by instantiating it from a Motif application. Motif provides two mechanisms for generating applications:

  1. Through a C application

  2. Through a UIL or WML-based application, as described in Chapter 14

    It is very easy to make your new widget accessible to C applications. All you have to do is compile your widget's source code file. The resulting object file can be bound to Motif applications. You do not have to place the object file into libXm.a.

    If you have written several related widgets, then we suggest bundling the resulting object files into an archive file (a library).

    From a Motif application programmer's point of view, it is very easy to access the new widget. Application programmers need to do only the following three things:

    1. The application must include the public header file for the new widget For example, to access the ExmSimple widget, the application must include its header file, as follows:
      #include <Exm/Simple.h>

    2. The application must instantiate the widget. For example, to instantiate the ExmSimple widget, call ExmCreateSimple or call XtCreateWidget, passing exmSimpleWidgetClass as an argument.

    3. On the link command line, make sure that your application gets bound to the new widget's object file(s) or archives.

      The Motif directory demos/programs/Exm/simple_app contains a short C application that exercises the ExmSimple widget. This directory also contains an Imakefile for building the ExmSimple widget and the application.

    4. [ Previous | Next | Contents | Glossary | Home | Search ]