CHAPTER 1 - THE XDL_VIEW MANAGEMENT ROUTINES

1.1 INTRODUCTION

This file contains a series of routines concerned with the management and coding of XDL_VIEW view-objects. Some are application callable and have Fortran interfaces whereas the others are for internal use within the source code of the view-objects.

The following sets of routines are available:

Application Callable Management Routines
Special Purpose Application Callable Routines
Creating Windows when Coding View-Objects
Creating Active Strips when Coding View-Objects
Registering View-Objects and Windows when Coding View-Objects
Getting Items from a View-Objects List when Coding View-Objects
Deleteing a Panel Item when Coding View-Objects
Handling Selections when Coding View-Objects
Outputting Error Messages when Coding View-Objects
Miscellaneous Routines used when Coding View-Objects

1.2 APPLICATION CALLABLE MANAGEMENT ROUTINES

1.2.1 Introduction

These are routines commonly used by the application programmer making use of the xdl_view package. There are routines to initialise the XDL_VIEW package, handle events and delete view-objects. A routine is provided which must be used when passing character strings from a Fortran program. There are further routines to raise and lower windows and get their positions.

The following routines are available:

XDL_VIEW initialisation - xdl_open_view
XDL_VIEW event handling - xdl_get_events
XDL_VIEW event flushing - xdl_flush_events
Delete an XDL_VIEW view-object - xdl_delete_view_object
Pointers list index of a Fortran character string - xdlstr
Get root coordinates - xdl_view_object_rootxy
Raise a view-object - xdl_view_object_raise
Lower a view-object - xdl_view_object_lower

1.2.2 XDL_VIEW initialisation - xdl_open_view

The initialisation routine xdl_open_view (xdlf_open_view) must be called before any other XDL_VIEW routine. It initialises the list of view-objects. It also sets up, in addition to a a small default colour map which contains the colours black, white and the six primary and secondary colours, colour maps based on the user's requirements for the application if possible. In addition to these items, a number of other global data items, which may be used within the code for the individual view-objects, are set up by the initialisation routine. Fonts will normally be defined as X-windows resources Xdl*font1...Xdl*font5 and Xdl*boldFont1...Xdl*boldFont5. There are five normal and five bold fonts. These should normally be fixed width fonts. Each series must be in ascending size order. Bold fonts must match normal fonts to within 1 pixel in width and two in height. Some of the view-objects assume that the small font does not exceed 7x13 in pixels in size; a warning will be output if this size is exceeded.
The following defaults are used by xdl_open_view if the font resources 
are not defined:

Normal fonts

    *adobe-courier-medium-r*--8*
    *adobe-courier-medium-r*--12*
    *adobe-courier-medium-r*--14*
    *adobe-courier-medium-r*--18*
    *adobe-courier-medium-r*--24*

Bold fonts

    *adobe-courier-bold-r*--8*
    *adobe-courier-bold-r*--12*
    *adobe-courier-bold-r*--14*
    *adobe-courier-bold-r*--18*
    *adobe-courier-bold-r*--24*
 
Fortran call:
 
         CALL XDLF_OPEN_VIEW (NUMC, NCOLORS, NPLANES, IERR)
 
Parameters:
 
NUMC     (R)  No. of colorsets (see numc)
NCOLORS  (R)  Integer array of nos. of colors (see ncolors)
NPLANES  (R)  Integer array of nos. of overlay planes 
              (see nplanes)
IERR     (W)  Returns the status from the xdl_open_view call
 
'C' call:
 
int xdl_open_view (numc, ncolors, nplanes)
 
Parameters:
 
int numc;           /*Number of colorsets to be allocated in addition
                      to the standard short pallette (may be 0) (R)*/
int ncolors[];      /*Array of 'ncolors' values for the XAllocColorCells
                      routines (numc values) (R)*/
int nplanes[];      /*Array of 'nplanes' values for the XAllocColorCells
                      routines (numc values) (R)*/

Return:  =0 if OK, >0 if error:
                      bit 0  set unable to allocate the requested 
                             colorsets.
                             (XDL_csets_alloc will be set to 0)
                             non-fatal - view-objects should cope with this
                             case.

1.2.3 XDL_VIEW event handling - xdl_get_events

An important part of XDL_VIEW is the X event handling mechanism. This is normally done through a call from the application program to the routine xdl_get_events (xdlf_get_events). When the routine is called, the user specifies a list of the view objects from which the program is ready to receive input ('active' view-objects). The routine services all the X events, passing them on to the approriate event handling routines until an event causes program input from one of the active view-objects; when this occurs, a return is made from the routine giving the view-object handle of the routine from which the input originated.
 
Fortran call:
 
         CALL XDLF_GET_EVENTS (NUMIVH, IVHLIST, IVH)
 
Parameters:
 
NUMIVH   (R)  Number of view-objects to return data (see num-vh)
IVHLIST  (R)  Array of NUMIVH view object handles (see vh_list)
IVH      (W)  Returns the view-object handle of object returning
              the data (return from xdl_get_events)
              the data (return from xdl_get_events)
 
'C' call:
 
int xdl_get_events (num_vh, vh_list)
 
Parameters:
 
int num_vh;      /* Number of view objects from which data are to be
                    returned (may be 0 if no return is required)
                    if -num_vh is given then the routine be in a no wait
                    mode and will return when either input is received or
                    all current events have been flushed (R)*/
int vh_list[];   /* Array of the num_vh view-object handles (R)*/

Return:  The view-object handle of the view object returning the data.
         (May be 0 in no wait mode)

1.2.4 XDL_VIEW event flushing - xdl_flush_events

The routine xdl_flush_events (xdlf_flush_events) services queued up events. It may be called at intervals during a long calculation to keep event handling going. It is only used when the application is not waiting to receive data from a view-object. It returns when the event queue is empty.
 
Fortran call:
 
         CALL XDLF_FLUSH_EVENTS (IDUM)
 
Parameters:
 
IDUM     (R)  Dummy parameter
 
'C' call:
 
void xdl_flush_events (dummy)
 
Parameters:
 
int dummy;       /* Dummy parameter (R)*/

Return:  None

1.2.5 Delete an XDL_VIEW view-object - xdl_delete_view_object

The routine xdl_delete_view_object (xdlf_delete_view_object) deletes a view-object and any of its children.
 
Fortran call:
 
         CALL XDLF_DELETE_VIEW_OBJECT (IVH, IERR)
 
Parameters:
 
IVH     (R)   View-object handle (see vh)
IERR    (W)   Return from xdl_delete_view_object routine
 
'C' call:
 
int xdl_delete_view_object (vh)
 
Parameters:
 
int vh;               /* The view object handle (R) */

Return:  0 = OK, 1 = requested view object not found

1.2.6 Pointers list index of a Fortran character string - xdlstr

The routine xdlstr is used to return an index to a list of character string pointers held within XDL_VIEW and used where a Fortran callable routine passes character data to or from the routine. The actual paramter(s) expected by the C routine are machine dependent. The Fortran call is of the form: XDLSTR (CHS) where CHS is a Fortran character variable or string. The function XDLSTR must be declared in the calling Fortran program as an INTEGER FUNCTION.
 
'C' call:
 
{
   XDL_pointers_index++;
   if (XDL_pointers_index>=MAXPOINTERS) XDL_pointers_index = 0;
   XDL_pointers[XDL_pointers_index] = ch;
   return XDL_pointers_index;
}

#endif

#if CHAR_STRING_TYPE == 2

typedef struct
{
   short int len;
   unsigned char type;
   unsigned char class;
   char * addr;
}
   Vax_ch_desc;

int xdlstr (ch_desc)
 
Parameters:
 
Vax_ch_desc *ch_desc;     /* Pointer to character descriptor (R)*/

Return:  Index in the XDL_pointers list from 0 to MAXPOINTERS-1

1.2.7 Get root coordinates - xdl_view_object_rootxy

The routine xdl_view_object_rootxy (xdlf_view_object_rootxy)is used to convert x, y coordinates within a view object to xroot, yroot coordinates relative to the root window.
 
Fortran call:
 
         CALL XDLF_VIEW_OBJECT_ROOTXY (IVH, IX, IY, IXROOT, IYROOT, IERR)
 
Parameters:
 
IVH         (R)  View-object handle (see vh)
IX          (R)  X coordinate within the view-object (see x)
IY          (R)  Y coordinate within the view-object (see y)
IXROOT      (W)  Returns the root window X coordinate (see xroot)
IYROOT      (W)  Returns the root window Y coordinate (see yroot)
IERR        (W)  Return from the xdl_view_object_rootxy call
 
'C' call:
 
int xdl_view_object_rootxy (vh, x, y, xroot, yroot)
 
Parameters:
 
int vh;          /* View-object handle (R)*/
int x;           /* x coordinate within view-object (R)*/
int y;           /* y coordinate within view-object (R)*/
int *xroot;      /* Returns x coordinate with respect to the root 
                    window (W)*/
int *yroot;      /* Returns y coordinate with respect to the root 
                    window (W)*/

Return:  =0 OK, =1 view-object not found

1.2.8 Raise a view-object - xdl_view_object_raise

The routine xdl_view_object_raise (xdlf_view_object_raise) is used to raise a view-object to the top (i.e to the front) of the stacking order amongst its siblings (view-objects with the same parent) on the screen.
 
Fortran call:
 
         CALL XDLF_VIEW_OBJECT_RAISE (IVH, IERR)
 
Parameters:
 
IVH         (R)  View-object handle (see vh)
IERR        (W)  Return from the xdl_view_object_raise call
 
'C' call:
 
int xdl_view_object_raise (vh)
 
Parameters:
 
int vh;          /* View-object handle (R)*/

Return:  =0 OK, =1 view-object not found

1.2.9 Lower a view-object - xdl_view_object_lower

The routine xdl_view_object_lower (xdlf_view_object_lower) is used to lower a view-object to the bottom (i.e to the back) of the stacking order amongst its siblings (view-objects with the same parent) on the screen.
 
Fortran call:
 
         CALL XDLF_VIEW_OBJECT_LOWER (IVH, IERR)
 
Parameters:
 
IVH         (R)  View-object handle (see vh)
IERR        (W)  Return from the xdl_view_object_lower call
 
'C' call:
 
int xdl_view_object_lower (vh)
 
Parameters:
 
int vh;          /* View-object handle (R)*/

Return:  =0 OK, =1 view-object not found

1.3 SPECIAL PURPOSE APPLICATION CALLABLE ROUTINES

1.3.1 Introduction

These are some additional special purpose routines which may be used by the application programmer if needed. They include routines for handling non-blocking terminal input, handling events at timed interrupts, synchronising X calls and introducing a program delay.

The following routines are available:

Event handling with time out- xdl_get_events_timeout
XDL_VIEW event and standard input handling - xdl_getio_events
Get string after xdl_getio_events call - xdl_getio_string
Read a string from the terminal - xdl_tread
XDL_VIEW timer driven event handling - xdl_timer_events
XDL_VIEW XSync/XSyschronise calls - xdl_sync
Delay - xdl_delay

1.3.2 Event handling with time out- xdl_get_events_timeout

An important part of XDL_VIEW is the X event handling mechanism. This is normally done through a call from the application program to the routine xdl_get_events (xdlf_get_events). When the routine is called, the user specifies a list of the view objects from which the program is ready to receive input ('active' view-objects). The routine services all the X events, passing them on to the approriate event handling routines until an event causes program input from one of the active view-objects; when this occurs, a return is made from the routine giving the view-object handle of the routine from which the input originated. The xdl_get_events_timeout (xdlf_get_events_timeout) routine has the additional function that a return will be made after a requested interval if there has not been a return occasioned by input to an active window. The time out interval may be taken from the invocation of the routine or from the last time an event occured in any of a list of specified view-objects.
 
Fortran call:
 
         CALL XDLF_GET_EVENTS_TIMEOUT (NUMIVH, IVHLIST, MSECS, 
        +                              NUMIVH2, IVHLIST2, IVH)
 
Parameters:
 
NUMIVH   (R)  Number of view-objects to return data (see num_vh)
IVHLIST  (R)  Array of NUMIVH view object handles (see vh_list)
MSECS    (R)  Return after this number of milliseconds if no
              input has been done (0 = no time out)
NUMIVH2  (R)  Number of view-objects in list 2 for re-setting
              the time interval (see IVHLIST2); may be 0.
IVHLIST2 (R)  Array of NUMIVH2 view object handles; the time out
              period will be re-started whenever an event takes place
              in any of these listed view-objects so that the
              time out return will only occur when no events have
              taken place in these objects for the time out period.
IVH      (W)  Returns the view-object handle of object returning
              the data (return from xdl_get_events)
 
'C' call:
 
int xdl_get_events_timeout (num_vh, vh_list, msecs, num_vh2, vh_list2)
 
Parameters:
 
int num_vh;      /* Number of view objects from which data are to be
                    returned (may be 0 if no return is required)
                    if -num_vh is given then the routine be in a no wait
                    mode and will return when either input is received or
                    all current events have been flushed (R)*/
int vh_list[];   /* Array of the num_vh view-object handles (R)*/
int msecs;       /* Return after this number of milliseconds if no
                    input has been done (0 = no time out) (R)*/
int num_vh2;     /* Number of view objects in list 2 (see vh_list2)
                    for re-setting the time interval; may be 0 (R)*/
int vh_list2[];  /* Array of NUMIVH2 view object handles; the time out
                    period will be re-started whenever an event takes 
                    place in any of these listed view-objects so that 
                    the time out return will only occur when no events 
                    have taken place in these objects for the time out 
                    period. (R)*/

Return:  The view-object handle of the view object returning the data.
         May be 0 in no wait mode or  -1 if the return is due to timing 
         out after the requested interval.

1.3.3 XDL_VIEW event and standard input handling - xdl_getio_events

An important part of XDL_VIEW is the X event handling mechanism. This is normally done through a call from the application program to the routine xdl_get_events (xdlf_get_events). When the routine is called, the user specifies a list of the view objects from which the program is ready to receive input ('active' view-objects). The routine services all the X events, passing them on to the approriate event handling routines until an event causes program input from one of the active view-objects; when this occurs, a return is made from the routine giving the view-object handle of the routine from which the input originated. If, in addition to handling these window events, the user wishes to read data from the standard input stream then this input must be done in a 'non-blocking' mode or the whole process may hang. The routine xdl_getio_events (xdlf_getio_events) allows such input in addition to any other event handling required.
 
Fortran call:
 
         CALL XDLF_GETIO_EVENTS (NUMIVH, IVHLIST, IVH)
 
Parameters:
 
NUMIVH   (R)  Number of view-objects to return data (see num-vh)
              (may be 0)
IVHLIST  (R)  Array of NUMIVH view object handles (see vh_list)
IVH      (W)  Returns the view-object handle of object returning
              the data (return from xdl_getio_events) or 0 is 
              there was input from stdin.
 
'C' call:
 
int xdl_getio_events (num_vh, vh_list)
 
Parameters:
 
int num_vh;      /* Number of view objects from which data are to be
                    returned (may be 0) (R)*/
int vh_list[];   /* Array of the num_vh view-object handles (R)*/

Return:  The view-object handle of the view object returning the data.
         or 0 if input data was from stdin.

1.3.4 Get string after xdl_getio_events call - xdl_getio_string

The routine xdl_getio_string (xdlf_getio_string) is called to return the last string input from the terminal (in a non-blocking read mode) when the routine xdl_getio_events (xdlf_getio_events) returns a view-object handle of 0.
 
Fortran call:
 
         CALL XDLF_GETIO_STRING (XDLSTR(STRING), MAXLEN, IERR)
 
Parameters:
 
STRING    (W)      Returned string (see string)
                   ** Pass address using the XDLSTR function **
MAXLEN    (R)      Maximum allowed length for the returned string
                   ( > 0 ) (cf max_len)
IERR      (W)      Return status from the xdl_getio_string call
 
'C' call:
 
int xdl_getio_string (string, max_len)
 
Parameters:
 
char string[];   /* Returned string (W)*/
int max_len;     /* if >0 Maximum length of returned string allowed
                          (excluding terminating null - string must be at
                          least max_len + 1 characters in length)
                    if <0 abs(max_len) characters will be returned padded
                          with blanks if needed (for 'fortran' use) (R)*/

Return: = 0 OK string present, =1 blank/null string

1.3.5 Read a string from the terminal - xdl_tread

The routine xdl_tread (xdlf_tread) is used to read a string from the terminal (standard input). The routine performs reads in a non-blocking mode and the background handling of X events for the view-objects will continue. Normal reads should not be used as this will block event handling and can cause a hang-up.
 
Fortran call:
 
         CALL XDLF_TREAD (XDLSTR(STRING), MAXLEN, IERR)
 
Parameters:
 
STRING    (W)      Returned string (see string)
                   ** Pass address using the XDLSTR function **
MAXLEN    (R)      Maximum allowed length for the returned string
                   ( > 0 ) (cf max_len)
IERR      (W)      Return status from the xdl_tread call
 
'C' call:
 
int xdl_tread (string, max_len)
 
Parameters:
 
char string[];   /* Returned string (W)*/
int max_len;     /* if >0 Maximum length of returned string allowed
                          (excluding terminating null - string must be at
                          least max_len + 1 characters in length)
                    if <0 abs(max_len) characters will be returned padded
                          with blanks if needed (for 'fortran' use) (R)*/

Return: = 0 OK string returned, =1 blank/null string returned

1.3.6 XDL_VIEW timer driven event handling - xdl_timer_events

An important part of XDL_VIEW is the X event handling mechanism. This is normally done through a call from the application program to the routine xdl_get_events (xdlf_get_events). In some applications, it may not be convenient to handle events in this way and this routine provides a mechanism to keep the event queue serviced at regular intervals using a system timer. It may also be used during lengthy calculations to keep the event queue serviced. The routine is only used when the program is not waiting for input from one or more view-objects. It should be noted that a call to xdl_get_events (xdlf_get_events) or xdl_getio_events (xdlf_getio_events) switches off the timer driven event handling so that it will need to be switched on again after such a call if required. Where possible, the use of this routine should be avoided.
 
Fortran call:
 
         CALL XDLF_TIMER_EVENTS (IOPT)
 
Parameters:
 
IOPT     (R)  = 0 turn off timer driven event handling, 
              = 1 turn on timer driven event handling
 
'C' call:
 
int xdl_timer_events (on_off)
 
Parameters:
 
int on_off;      /* = 1 turn timer driven event handling on,
                    = 0 turn timer driven event handling off (R)*/
Return:  

1.3.7 XDL_VIEW XSync/XSyschronise calls - xdl_sync

The routine xdl_sync (xdlf_sync) routine enables access to the X-windows XSync and XSynchronize functions in case these are needed.
 
Fortran call:
 
         CALL XDLF_SYNC (IOPT)
 
Parameters:
 
IOPT     (R)  Flag =1 XSync, no discard
                   =2 XSync, discard
                   =3 XSynchronize on
                   =4 XSynchronize off
 
'C' call:
 
void xdl_sync (opt)
 
Parameters:
 
int opt;       /* Flage =1 XSync, no discard
                        =2 XSync, discard
                        =3 XSynchronize on
                        =4 XSynchronize off (R)*/

Return:  None

1.3.8 Delay - xdl_delay

The routine xdl_delay (xdlf_delay) is used to introduce a program delay for a requested no. of milliseconds e.g. to wait for new windows to be exposed.
 
Fortran call:
 
         CALL XDLF_DELAY (MSEC)
 
Parameters:
 
MSEC       (R)  Time of delay in milliseconds
 
'C' call:
 
void xdl_delay (msec)
 
Parameters:
 
int msec;          /* Delay in milliseconds (R)*/

Return:  none

1.4 CREATING WINDOWS WHEN CODING VIEW-OBJECTS

1.4.1 Introduction

These are routines used to create windows when coding a new view-object.

The following routines are available:

Create a base frame window - xdl_create_base_frame_window
Create a frame window - xdl_create_frame_window
Create a paint window - xdl_create_paint_window

1.4.2 Create a base frame window - xdl_create_base_frame_window

The routine xdl_create_base_frame_window is used to create (and map) a base frame window. This window is a child of the Rootwindow. The routine sends a title, icon label, hints etc. to the window manager.
 
'C' call:
 
Window xdl_create_base_frame_window (title, icon_label, x, y, 
                                     width, height)
 
Parameters:
 
char * title;       /*Title for passing to window manager (null term) (R)*/
char * icon_label;  /*Icon label for passing to window manager 
                      (null term) (R)*/
int x;              /*Root x coordinate for window (-1 to leave selection
                      to the window manager) (R)*/
int y;              /*Root y coordinate for window (-1 to leave selection
                      to the window manager) (R)*/
int width;          /*Window width (including border of 1 at each side) 
                      (R)*/
int height;         /*Window height (including border of 1 at top and 
                      bottom (R)*/

Return:  The window id

1.4.3 Create a frame window - xdl_create_frame_window

The routine xdl_create_frame_window is used to create (and map) a frame window. Such a window is normally used as the top level window of a view-object when it has a parent view-object.
 
'C' call:
 
Window xdl_create_frame_window (wparent, x, y, width, height, cset)
 
Parameters:
 
Window wparent;     /*Window id of the parent window (R)*/
int x;              /*x position of top left pixel (of border) (R)*/
int y;              /*y position of top left pixel (of border) (R)*/
int width;          /*Window width (including border of 1 at each side) 
                      (R)*/
int height;         /*Window height (including border of 1 at top and 
                      bottom (R)*/
int cset;           /*XDL_VIEW Colorset number (R)*/

         /* Note: Origin pixel at top left within border */
Return:  The window id

1.4.4 Create a paint window - xdl_create_paint_window

The routine xdl_create_paint_window is used to create (and map) an input/output paint window.
 
'C' call:
 
Window xdl_create_paint_window (wparent, x, y, brdw, width, height, 
                                cset)
 
Parameters:
 
Window wparent;     /*Window id of the parent window (R)*/
int x;              /*x position of top left pixel (of border) (R)*/
int y;              /*y position of top left pixel (of border) (R)*/
int brdw;           /*Border width in pixels (normally 1)*/
int width;          /*Window width (including border at each side) (R)*/
int height;         /*Window height (including border at top and 
                      bottom (R)*/
int cset;           /*XDL_VIEW Colorset number (R)*/

         /* Note: Origin pixel at top left within border */
         /*       Paintable width  = width - 2*brdw      */
         /*       Paintable height = height - 2*brdw     */
Return:  The window id

1.5 CREATING ACTIVE STRIPS WHEN CODING VIEW-OBJECTS

1.5.1 Introduction

These are routines used to create active strips when coding a new view-object.

The following routines are available:

Create an active strip - xdl_create_active_strip
Set active strip to 'on' - xdl_active_strip_on
Set active strip to 'off' - xdl_active_strip_off

1.5.2 Create an active strip - xdl_create_active_strip

The routine xdl_create_active_strip is used to create an active strip window and add it to the view-object's window list. This strip indicates whether or not the application is waiting for input from a view object. The on/off states are set by the routines xdl_active_strip_on and xdl_active_strip_off. A filled square in green (or black if b/w display) indicates that input is awaited and a text string indicates the nature of the required input. An open square indicates that input is not awaited. The strip will be placed with its origin at 4, 4 of the parent window with a depth of 20. The required width (normally the parent window width - 8) is passed to the routine. Bold text should be used when the window has the keyboard focus and normal text be used otherwise.
 
'C' call:
 
Window xdl_create_active_strip (wparent, vh, width, repaint)
 
Parameters:
 
Window wparent;        /* The parent window for which the strip is to be 
                          created (R) */
int vh;                /* View-object handle (The view object must have
                          been added to the list of view-objects using 
                          the routine xdl_add_new_view_object before 
                          xdl_create_active_strip is called (R) */
int width;             /* The width for the strip (R) */
void (*repaint)();     /* Active strip repaint function (R)*/

Return:  The created window

1.5.3 Set active strip to 'on' - xdl_active_strip_on

The routine xdl_active_strip_on is used to set an active strip to its 'on' state.
 
'C' call:
 
void xdl_active_strip_on (wid, str, bold)
 
Parameters:
 
Window wid;          /* The active strip window id (R) */
char * str;          /* The string to be displayed (R) */
int bold;            /* =1 Use bold text (to indicate keyboard focus) or
                        =0 Use normal text (R) */

Return:  None

1.5.4 Set active strip to 'off' - xdl_active_strip_off

The routine xdl_active_strip_off is used to set an active strip to its 'off' state.
 
'C' call:
 
void xdl_active_strip_off (wid)
 
Parameters:
 
Window wid;      /* The active strip window id (R) */

Return:  None

1.6 REGISTERING VIEW-OBJECTS AND WINDOWS WHEN CODING VIEW-OBJECTS

1.6.1 Introduction

These are routines used to register new view-objects by adding them to an internal list and to add window information to that list when coding a new view-object.

The following routines are available:

Add a new view-object - xdl_new_view_object
Add a window to the windows list - xdl_add_window
Add a library window to windows list - xdl_add_libwin
Add to level window callbacks - xdl_add_top_callbacks

1.6.2 Add a new view-object - xdl_new_view_object

The routine xdl_new_view_object is used to add a new view-object to the list of view-objects and to initialiase its associated data.
 
'C' call:
 
int xdl_new_view_object (vh, wid, vh_parent, gd, type, on_off, tidy_up)
 
Parameters:
 
int vh;                 /*The view_object handle for the new view object
                          (vh) (R)*/
Window wid;             /*The parent window of the new view object (R)*/
int vh_parent;          /*The view-object handle for the parent 
                          (0 if none) (R)*/
char * gd;              /*Pointer to the global data area used by the 
                          view-object's routines (R)*/
int type;               /*A unique integer for the view-object type (R)*/
void (*on_off)();       /*Pointer to the input on/off function for the
                          view object. May be NULL if not required or
                          implemented. (Used by xdl_get_events) (R)*/
void (*tidy_up)();      /*Pointer to the tidy up routine for the 
                          view-object. This routine will be called by 
                          xdl_delete_view_object when the view object
                          is deleted. It should be used for example
                          to free any memory areas allocated by the 
                          view-object (except for the global data area 
                          which will be automatically freed by 
                          xdl_delete_view_object). May be NULL if not 
                          required or implemented. (R)*/

Return: The offset in the XDL_view_objects array for the new view object.

1.6.3 Add a window to the windows list - xdl_add_window

The routine xdl_add_window is used to add a derived (child/subwindow) to a list of such windows for the view-object.
 
'C' call:
 
void xdl_add_window (vh, wid, repaint, ehp)
 
Parameters:
 
int vh;              /*The view-object handle for the view-object to 
                       whose derived windows list the new window is to 
                       be appended (R)*/
Window wid;          /*The id of the window to be added (R)*/
void (*repaint)();   /*Address of repaint routine for the window 
                       (may be NULL) (R)*/
void (*ehp)();       /*Address of event handling procedure for the window 
                       (may be NULL) (R)*/

Return:  None.

1.6.4 Add a library window to windows list - xdl_add_libwin

The routine xdl_add_libwin is used to add a derived (child/subwindow) library routine window to the list of windows for a view-object.
 
'C' call:
 
void xdl_add_libwin (vh, wid, gd, repaint, ehp, callback, tidy_up)
 
Parameters:
 
int vh;              /*The view-object handle for the view-object to 
                       whose derived windows list the new window is to 
                       be appended (R)*/
Window wid;          /*The id of the window to be added (R)*/
char *gd;            /*The global data area associated with the window -
                       normally that of the parent view-object's global
                       data area for routines forming part of the code
                       for a view-object. Normally a separately defined
                       area for special library routine window objects 
                       (R)*/
void (*repaint)();   /*Address of repaint routine for the window 
                       (may be NULL) (R)*/
void (*ehp)();       /*Address of event handling procedure for the window 
                       (may be NULL) (R)*/
void (*callback)();  /*Address of callback routine if required. 
                       Normally NULL except when using a library routine 
                       window which will return data to the calling 
                       view-object (R)*/
void (*tidy_up)();   /*Routine to be called when a window is deleted to
                       tidy up (e.g. free allocated memory areas or other
                       allocated resources). May be NULL if not required.
                       For a window set up by a routine forming part of 
                       the specific code for the view object, all the 
                       tidying up will normally be done by the one 
                       tidy_up routine associated with its top level 
                       window (R)*/
                       
Return:  None.

1.6.5 Add to level window callbacks - xdl_add_top_callbacks

The routine xdl_add_top_callbacks allows the normally NULL callbacks (repaint and event handling) to be reset for the top level window of a view object.
 
'C' call:
 
void xdl_add_top_callbacks (vh, repaint, ehp)
 
Parameters:
 
int vh;              /*The view-object handle for the view-object to 
                       whose derived windows list the new window is to 
                       be appended (R)*/
void (*repaint)();   /*Address of repaint routine for the window 
                       (may be NULL) (R)*/
void (*ehp)();       /*Address of event handling procedure for the window 
                       (may be NULL) (R)*/

Return:  None.

1.7 GETTING ITEMS FROM A VIEW-OBJECTS LIST WHEN CODING VIEW-OBJECTS

1.7.1 Introduction

These are routines used to get data items from a view-objects internal list when coding a new view object.

The following routines are available:

Get offset in view-objects list from handle - xdl_getiv
Get global data area from window id - xdl_get_global
Get view-object handle from window id - xdl_get_vh

1.7.2 Get offset in view-objects list from handle - xdl_getiv

The routine xdl_getiv is used to find the offset in the XDL_view_objects array for a requested view-object handle.
 
'C' call:
 
int xdl_getiv (vh)
 
Parameters:
 
int vh;              /*The view-object handle (vh) (R)*/

Return:  The offset (>=0) or -1 if view object-handle not present.

1.7.3 Get global data area from window id - xdl_get_global

The routine xdl_get_global is used to get a pointer to the main view-object global data area for a given window.
 
'C' call:
 
char * xdl_get_global (wid)
 
Parameters:
 
Window wid;      /* The window id for which the view-object's data area 
                    is to be found (R)*/

Return:  The pointer to the global data (0 if none found)

1.7.4 Get view-object handle from window id - xdl_get_vh

The routine xdl_get_vh is used to get the view-object handle for the view-object to which a given window belongs.
 
'C' call:
 
int xdl_get_vh (wid)
 
Parameters:
 
Window wid;      /* The window id for which the view-object handle is 
                    to be found (R)*/

Return:  The view-object handle (0 if none found)

1.8 DELETEING A PANEL ITEM WHEN CODING VIEW-OBJECTS

1.8.1 Introduction

These are routines used to delete panel items if required when coding a new view-object.

The following routines are available:

Delete a panel item - xdl_delete_panel_item

1.8.2 Delete a panel item - xdl_delete_panel_item

The routine xdl_delete_panel_item is used to delete a panel item while the view-object is still in use.
 
'C' call:
 
void xdl_delete_panel_item (vh, wid)
 
Parameters:
 
int vh;      /* View-object handle for the view-object to which the
                panel item belongs (R) */
Window wid;  /* The window id. of the panel item (R)*/

Return:  None

1.9 HANDLING SELECTIONS WHEN CODING VIEW-OBJECTS

1.9.1 Introduction

These are routines used assit with the handling of text selections from/to a window if this is required when coding a new view-object.

The following routines are available:

Request selection ownership - xdl_select_owner
Cancel selection ownership - xdl_select_cancel
Request a selection - xdl_select_request
Receive selection data - xdl_select_receive

1.9.2 Request selection ownership - xdl_select_owner

The routine xdl_select_owner is used to get the selection ownership of the XA_PRIMARY selection (for an example of the use of these selection routines, see the xdl_io_window.c view-object code).
 
'C' call:
 
void xdl_select_owner (wid)
 
Parameters:
 
Window wid;      /* The window id of the window requesting the selection
                    ownership (R) */

Return:  None

1.9.3 Cancel selection ownership - xdl_select_cancel

The routine xdl_select_cancel is used to cancel the selection ownership of the XA_PRIMARY selection (for an example of the use of these selection routines, see the xdl_io_window.c view-object code).
 
'C' call:
 
void xdl_select_cancel ()
 
Parameters:
 
{
    XSetSelectionOwner (XDL_display, XA_PRIMARY, None, CurrentTime);
    return;
}
/*
*******************************
**     xdl_select_respond    **
******************************

Purpose: Respond to selection request (XA_PRIMARY)

Return:  None

Author:  John W. Campbell, August 1993
*/

/*Doc:
Respond to selection request - xdl_select_respond

The routine xdl_select_respond is used to respond to a selection request
from another client on XA_PRIMARY. Only string requests are translated; 
otherwise a null reply is given (for an example of the use of these selection
routines, see the xdl_io_window.c view-object code).
*/

void xdl_select_respond (event, str, nitems)

XEvent * event;  /* The selection request event (R)*/
char *str;       /* The string containing the currently selected data (R)*/
int nitems;      /* Number of characters in the string to be sent (excluding
                    any null terminator); may be 0 (R) */

Return:  None

1.9.4 Request a selection - xdl_select_request

The routine xdl_select_request is used to request a (string) selection from the XA_PRIMARY selection (for an example of the use of these selection routines, see the xdl_io_window.c view-object code).
 
'C' call:
 
void xdl_select_request (event, wid)
 
Parameters:
 
XEvent *event;   /* The event triggering the request (for timing) */
Window wid;      /* The window id of the window requesting the selection (R)*/

Return:  None

1.9.5 Receive selection data - xdl_select_receive

The routine xdl_select_receive is used to get the (string) data received following a selection request. This will only be successful if the selection owner can translate the request to the required (string) form (for an example of the use of these selection routines, see the xdl_io_window.c view-object code).
 
'C' call:
 
int xdl_select_receive (event,wid,str,nitems,maxinstring)
 
Parameters:
 
XEvent *event;   /* The selection notify event (R)*/
Window wid;      /* The window id of the window requesting the selection
                    ownership (R) */
char **str;      /* Pointer to the received data 

                    NOTE   This data is allocated by the routine
                    ====   and should be freed after it has been 
                           used unless it is a null pointer; this is
                           only needed if the return is 1 (true) as
                           it will already be freed by this routine
                           when the return is 0 (R)*/

int *nitems;     /* Returns the number of items in the string (excluding
                    terminating null (W)*/
int maxinstring; /* Maximum number of items (characters) which may be
                    received */

Return:  =1 string received; =0 request could not be satisfied

1.10 OUTPUTTING ERROR MESSAGES WHEN CODING VIEW-OBJECTS

1.10.1 Introduction

These are routines used to output error messages in a standard format when coding a new view-object.

The following routines are available:

Output an XDL_VIEW error message - xdl_view_errmsg
'View-object not found' error message - xdl_view_iv_errmsg
Error message for wrong type - xdl_view_type_errmsg

1.10.2 Output an XDL_VIEW error message - xdl_view_errmsg

The routine xdl_view_errmsg is used to output an error message for xdl_view routines. The error message will be of the form: . ** xdl_view error in routine xdl_routine_name ** ** user supplied error message ** . The stars around the user's message are supplied by the routine.
 
'C' call:
 
void xdl_view_errmsg (routine_name, message)
 
Parameters:
 
char *routine_name;   /* The name of the routine giving the error (null
                         terminated string (R) */
char *message;        /* A null terminated string describing the error */

1.10.3 'View-object not found' error message - xdl_view_iv_errmsg

The routine xdl_view_iv_errmsg is used to output an error message for xdl_view routines for when a requested view-object handle is not found in the list of view objects. The error message will be of the form: . ** xdl_view error in routine xdl_routine_name ** ** view-object handle n not found in current list of view-objects ** .
 
'C' call:
 
void xdl_view_iv_errmsg (routine_name, vh)
 
Parameters:
 
char *routine_name;   /* The name of the routine giving the error 
                         (null terminated string) (R) */
int vh;               /* The view-object handle */

1.10.4 Error message for wrong type - xdl_view_type_errmsg

The routine xdl_view_type_errmsg is used to output an error message for xdl_view routines for when a requested view-object handle is used in a routine which corresponds to an incorrect type of view object. e.g. an xdl_menu_area_setmenu routine was called with a view handle corresponding to an xdl_param_table view-object. The error message will be of the form: . ** xdl_view error in routine xdl_routine_name ** ** view-object for handle n is not of type view_object_type ** .
 
'C' call:
 
void xdl_view_type_errmsg (routine_name, vh, view_object_type)
 
Parameters:
 
char *routine_name;     /* The name of the routine giving the error (null
                           terminated string)
                           e.g. "xdl_param_table_setvalue" (R) */
int vh;                 /* The view-object handle (R)*/
char *view_object_type; /* Null terminated string giving the view-object
                           type to which the routine belongs
                           e.g. "xdl_param_table" (R) */

1.11 MISCELLANEOUS ROUTINES USED WHEN CODING VIEW-OBJECTS

1.11.1 Introduction

These are some miscellaneous routines which may be used if required when coding a new view-object.

The following routines are available:

Get root x, y coordinates - xdl_rootxy
Copy an output string - xdl_copy_chars
Test for a blank string - xdl_blank_string
Chop trailing blanks - xdl_chop_blanks
Number of digits in an integer - xdl_ndigit
Convert a string to upper case - xdl_upc
Convert a string to lower case - xdl_lwc
Convert a character to upper case - xdl_upcc
Convert a character to lower case - xdl_lwcc
Random number, 0-32767 - xdl_rand16
Get character size - xdl_ch_size
Set a 64 level gray scale - xdl_set64gray
Set a 64 level gray + yellow scale - xdl_set64gray_yel
Set a 64 level colour scale - xdl_set64color
Get a 64 level gray scale - xdl_get64gray
Get a 64 level gray + yellow scale - xdl_get64gray_yel
Get a 64 level colour scale - xdl_get64color
Delete view-object children - xdl_delete_children
See if a view-object has children - xdl_any_children

1.11.2 Get root x, y coordinates - xdl_rootxy

The routine xdl_rootxy is used to get the root window x, y coordinates from the x, y coordinates within a given window.
 
'C' call:
 
void xdl_rootxy (wid, x, y, xroot, yroot)
 
Parameters:
 
Window wid;    /*The window id of the window to which x, y coordinates 
                 apply (R)*/
int x;         /*The x coordinate (R)*/
int y;         /*The y coordinate (R)*/
int *xroot;    /*Returns the x coordinate in the root window (W)*/
int *yroot;    /*Returns the y coordinate in the root window (W)*/

Return:  xroot, yroot via parameters list

1.11.3 Copy an output string - xdl_copy_chars

The routine xdl_copy_chars is used to copy an output string from an XDL_VIEW view-object routine. The output string may be either a 'c' type string which will be null terminated, or a 'fortran' type string which will be padded with blanks if required but will have no terminating null.
 
'C' call:
 
void xdl_copy_chars (string_in, string_out, max_len)
 
Parameters:
 
char * string_in;    /*The string to be copied (must be null terminated) 
                       (R)*/
char * string_out;   /*The output string address for the copied string 
                       (W) */
int    max_len;      /*If >0 it is the maximum length allowed for the null
                             terminated copied string. string_out must be 
                             at least (max_len + 1) characters in length.
                       if <0 then up to abs(max_len) characters are copied 
                             to the output string. If the number of 
                             characters in the input string is less than 
                             this then the output string will be padded to 
                             abs(max_len) characters with blanks. (R) */

1.11.4 Test for a blank string - xdl_blank_string

The routine xdl_blank_string is used to test for a blank (/null) character string.
 
'C' call:
 
int xdl_blank_string (str)
 
Parameters:
 
char str[];   /*String to test (null terminated) (R)*/

Return:  =1 (true) blank or null string found,
         =0 not a blank/null string

1.11.5 Chop trailing blanks - xdl_chop_blanks

The routine xdl_chop_blanks is used to remove trailing blanks from a character string.
 
'C' call:
 
void xdl_chop_blanks (str)
 
Parameters:
 
char str[];   /*String from which trailing blanks are to be removed 
                (null terminated on input and output) (M)*/

1.11.6 Number of digits in an integer - xdl_ndigit

The routine xdl_ndigit finds the number of decimal digits in an integer value.
 
'C' call:
 
int xdl_ndigit (i)
 
Parameters:
 
int i;     /*The integer value for which the number of digits is to 
             be found (R)*/

Return:  The number of digits.

1.11.7 Convert a string to upper case - xdl_upc

The routine xdl_upc is a machine independent routine to convert a character string to upper case.
 
'C' call:
 
void xdl_upc (str)
 
Parameters:
 
char str[];    /*String to be converted to upper case 
                 (null terminated) (M)*/

1.11.8 Convert a string to lower case - xdl_lwc

The routine xdl_lwc is a machine independent routine to convert a character string to lower case.
 
'C' call:
 
void xdl_lwc (str)
 
Parameters:
 
char str[];    /*String to be converted to lower case 
                 (null terminated) (M)*/

1.11.9 Convert a character to upper case - xdl_upcc

The routine xdl_upcc is a machine independent routine to convert a character to upper case.
 
'C' call:
 
void xdl_upcc (ch)
 
Parameters:
 
char *ch;    /*Pointer to character to be converted to upper case (M)*/

1.11.10 Convert a character to lower case - xdl_lwcc

The routine xdl_lwcc is a machine independent routine to convert a character to lower case.
 
'C' call:
 
void xdl_lwcc (ch)
 
Parameters:
 
char *ch;    /*Pointer to character to be converted to lower case (M)*/

1.11.11 Random number, 0-32767 - xdl_rand16

The routine xdl_rand16 is a machine independent routine to return a pseudo-random number in the range 0 to 32767. The seed may be reset with the routine xdl_srand16; its initial value is 1.
 
'C' call:
 
int xdl_rand16 ()
 
Parameters:
 
{
   xdl_next_seed = xdl_next_seed*1103515245 + 12345;
   return (unsigned int) (xdl_next_seed/65536)%32768;
}

/*
***************************
**      xdl_srand16      **
***************************

Purpose: Set new seed for random number routine xdl_rand16

Author:  John Campbell, July 1992 (from K&R)

*/

/*Doc:
Set seed for xdl_rand16 - xdl_srand16

The routine xdl_srand16 is used to reset the seed value for the pseudo-random
number routine xdl_rand16.
*/


void xdl_srand16 (seed)

unsigned int seed;  /* New seed value (R)*/

1.11.12 Get character size - xdl_ch_size

The routine xdl_ch_size is used to get the character size for a character in one of the XDL_VIEW standard fonts; this may be for a normal font, a bold font or the larger or smaller dimensions of the two.
 
'C' call:
 
void xdl_ch_size (font_type, opt, ch_width, ch_height, ascent, descent)
 
Parameters:
 
int font_type;     /* Font type (1 to 5) (R)*/
int opt;           /* = 0, normal font
                      = 1, bold font
                      = 2, larger dimensions of the normal/bold fonts
                      = 3, smaller dimensions of the normal/bold fonts
                      (R)*/
int *ch_width;     /* Returns the character width in pixels (W)*/
int *ch_height;    /* Returns the character height in pixels (W)*/
int *ascent;       /* Returns font ascent (W)*/
int *descent;      /* Returns font descent (W)*/

1.11.13 Set a 64 level gray scale - xdl_set64gray

The routine xdl_set64gray is used to set up a 64 level gray scale. The colorset must have been allocated when xdl_open_view (xdlf_open_view) was called and must have at least 64 colorcells allocated.
 
'C' call:
 
int xdl_set64gray (cset, contrast_val, type)
 
Parameters:
 
int cset;         /* The colorset number (R)*/
int contrast_val; /* Contrast value from 1 to 1024 (R)*/
int type;         /* =1 high density = black, 
                     =2 high density = white (R)*/

Return:  1=OK, 0= colorset not allocated or has <64 cells or 
                  contast parameter out of range

1.11.14 Set a 64 level gray + yellow scale - xdl_set64gray_yel

The routine xdl_set64gray_yel is used to set up a 64 level gray scale with the top level gray being replaced by yellow. The colorset must have been allocated when xdl_open_view (xdlf_open_view) was called and must have at least 64 colorcells allocated.
 
'C' call:
 
int xdl_set64gray_yel (cset, contrast_val, type)
 
Parameters:
 
int cset;         /* The colorset number (R)*/
int contrast_val; /* Contrast value from 1 to 1024 (R)*/
int type;         /* =1 high density = black, 
                     =2 high density = white (R)*/

Return:  1=OK, 0= colorset not allocated or has <64 cells 
                  or contrast parameter out of range

1.11.15 Set a 64 level colour scale - xdl_set64color

The routine xdl_set64color is used to set up a 64 level colour scale. The colour scale is blue..purple..red..orange..yellow with increasing brightness or the same colour sequence in reverse order. The routine. The colorset must have been allocated when xdl_open_view (xdlf_open_view) was called and must have at least 64 colorcells allocated.
 
'C' call:
 
int xdl_set64color (cset, contrast_val, type)
 
Parameters:
 
int cset;         /* The colorset number (R)*/
int contrast_val; /* Contrast value from 1 to 1024 (R)*/
int type;         /* =1 high density at blue end of scale
                     =2 high density at yellow end of scale (R)*/

Return:  1=OK, 0= colorset not allocated or <64 cells 
                  or contrast parameter out of range

1.11.16 Get a 64 level gray scale - xdl_get64gray

The routine xdl_get64gray is used to get a 64 level gray scale. The nearest colours available will be allocated.
 
'C' call:
 
int xdl_get64gray (pixels, contrast_val, type)
 
Parameters:
 
unsigned long pixels[64];         /* The returned pixels list (W)*/
int contrast_val;                 /* Contrast value from 1 to 1024 (R)*/
int type;                         /* =1 high density = black, 
                                     =2 high density = white (R)*/

Return:  1=OK, 0= contast parameter out of range

1.11.17 Get a 64 level gray + yellow scale - xdl_get64gray_yel

The routine xdl_get64gray_yel is used to get a 64 level gray scale with the top level gray being replaced by yellow. The nearest available colours are allocated.
 
'C' call:
 
int xdl_get64gray_yel (pixels, contrast_val, type)
 
Parameters:
 
unsigned long pixels[64];         /* The returned pixels list (W)*/
int contrast_val;                 /* Contrast value from 1 to 1024 (R)*/
int type;                         /* =1 high density = black, 
                                     =2 high density = white (R)*/

Return:  1=OK, 0= contrast parameter out of range

1.11.18 Get a 64 level colour scale - xdl_get64color

The routine xdl_get64color is used to get a 64 level colour scale. The colour scale is blue..purple..red..orange..yellow with increasing brightness or the same colour sequence in reverse order. The nearest available colours are allocated.
 
'C' call:
 
int xdl_get64color (pixels, contrast_val, type)
 
Parameters:
 
unsigned long pixels[64];         /* The returned pixels list (W)*/
int contrast_val;                 /* Contrast value from 1 to 1024 (R)*/
int type;                         /* =1 high density at blue end of scale
                                     =2 high density at yellow end of scale 
                                        (R)*/

Return:  1=OK, 0= contrast parameter out of range

1.11.19 Delete view-object children - xdl_delete_children

The routine xdl_delete_children is used to delete the children of a view-object. (Recursively)
 
'C' call:
 
void xdl_delete_children (vh_parent)
 
Parameters:
 
int vh_parent;           /* View-object handle of the parent (R) */

Return:  None

1.11.20 See if a view-object has children - xdl_any_children

The routine xdl_any_children is used to find whether or not a view-object has any child view-objects.
 
'C' call:
 
int xdl_any_children (vh)
 
Parameters:
 
int vh;           /* View-object handle (R) */

Return:  =1 (true) child or children found, =0 no children;



John W. Campbell
CCLRC Daresbury Laboratory
Last update 4 Feb 1998