next up previous contents
Next: Bibliography Up: Creating a Custom Window Previous: trial_data_refresh()   Contents

Adding a New Library

It is easiest to assemble all the code to implement a new panel into a single library. Along with the above routines, do not forget to write the trial_handler() as detailed in Section 3.1. This routine should call the routine trial_open() and be placed in the file trial_hnd.c.

The computational code which is executed when buttons are pressed should be placed in a file called trial_go.c. Note that this file should be completely independent of the windowing system. It should use the data structure written by trial_read_window(). For our example, the code in trial_go.c is simply the following:

#include <stdio.h>

#include <pm_main.h>

extern int trial_choice;
extern double *trial_varb_value;

/*
 * trial_button1_go()
 *
 * puts chosen value into postmaster
 */
int
  trial_button1_go()
{
  pm(PUT, Traj_Ds_Object, Varb_Ic, trial_choice, 
          trial_varb_value[trial_choice], NULL);
}

There is a general Makefile already written for use with dstool which should be used to make the new library. To copy it, type

     cd $DSTOOL_USER/trial
     cp $DSTOOL_USER/userlib/Makefile.generic Makefile

Now edit the Makefile to include your new code. For our example, the following lines should read:

LIBRARY = triallib.a

SOURCES_A = \
        trial_cui.c \
        trial_hnd.c \
        trial.c \
        trial_go.c

DEPS_A = trial_cui.h

You will also need to add this new library into the list of libraries contained in the Makefile in the directory $DSTOOL_USER. Do this by adding triallib.a to the list of USER_LIBS.

USER_LIBS = \
        models/modellib.a \
        userlib/userlib.a \
        trial/triallib.a

Now when the user's local version of dstool is recompiled, the new window code will be incorporated into dstool. Recall that the compilation is initiated from the $DSTOOL_USER directory with the command make dstool_u.


next up previous contents
Next: Bibliography Up: Creating a Custom Window Previous: trial_data_refresh()   Contents
root
1998-11-02