#ifndef XM_XFACILITIES_H_
/*
 ************
 
   $Id: xfacilities.h,v 1.1 2008/07/19 22:30:29 jgs Exp $
   
   Description:	Facilities structures for X-Windows graphics primitives 
 		wishing to use points, annotate, boxes, etc
 
 ************
*/

#include "fcinterface.h"
#include "mtypes.h"

/*
 ************************
  These are mode flags shared by all facilities
 ************************
*/

#define L_CleanExit 0
#define L_Draw 1
#define L_Interactive (-1)
#define L_OneShot (-2)
#define L_Preload (-3)
#define L_InitFacilities 999

/*
 ************************
  Annotate specific flags
 ************************
*/

#define L_RemoveText (-1)
#define L_DeselectText 0
#define L_SelectText 1
#define L_MoveText 2

#define L_FreeFonts (-2)
#define L_LoadOneFont (-1)
#define L_FontAttributes 0
#define L_ChangeBG 1
#define L_LoadAllFonts 2
#define L_ChangeColor 3
#define L_ChangeAnchor 4
#define L_GetFontPtr 5
#define L_FreeFontPtr (-5)
#define L_GetTextExtents (-4)
#define L_SetPixel (-3)
#define L_NotSet (-1)

#define L_XFAFill 1
#define L_XFAMidAnchor 2
#define L_XFAEndAnchor 4
#define L_XFANoGravity 8
#define L_XFANoBS 16

typedef struct {
  int_2 x, y;
  int_2 mode;
  int_2 size;
  FSTRING(text, 128);
  FSTRING(font, 128);
  FSTRING(color, 24);
  int_4 f_id;
  int_4 p_id;
  int_4 pixel;
  int_2 w, h;
  int_2 a, xc, yc, d;
} XFANNOTATION;

#define L_xfannotation 312

/*
 ************************
  Box specific flags
 ************************
*/

typedef union {
    struct {
      real_8 xyX;
      real_8 xyY;
      real_8 xyW;
      real_8 xyH;
    } xy;
    struct {
      real_8 yxY;
      real_8 yxX;
      real_8 yxH;
      real_8 yxW;
    } yx;
    struct {
      real_8 x1;
      real_8 y1;
      real_8 x2;
      real_8 y2;
    } alt;
  } XFBOX;

#define L_xfbox 32

/*
 ************************
  Control panel specific flags
 ************************
*/

#define L_SavePanel 4
#define L_FocusPanel 5
#define xfc_disp 1
#define xfc_awake 2
#define xfc_edit 4
#define xfc_monitor 8
#define xfc_mfocus 16
#define xfc_blink 32

/*
  Added for headless
 
  MENU
*/
#define xfc_moption 64
#define xfc_mleft 128
#define xfc_mtop 256
#define xfc_mright 512

/*
 ************************
  Point specific flags
 ************************
*/

typedef union {
    struct {
      real_8 xyX;
      real_8 xyY;
    } xy;
    struct {
      real_8 yxY;
      real_8 yxX;
    } yx;
  } XFPOINT;

#define L_xfpoint 16

typedef struct {
  M_PTR ROUTINE;   /* primitive's local specs routine */
  M_PTR mqdloc;    /* queued message data structure */
  M_PTR annt;      /* array of ptrs to /XFANNOTATE/ structs */
  M_PTR adefault;  /* the default /XFANNOTATE/ struct */
  M_PTR box;       /* array of /XFBOX/ structs */
  M_PTR con;       /* array of /XWIDGET/ structs */
  M_PTR cpsetup;   /* int_4 array of (x,y,flag) */
  M_PTR chcb;      /* optional keyword file header */
  M_PTR pwork;     /* work buffer to convert to pixels in */
  M_PTR point;     /* array of /XFPOINT/ structs */

  bool_4 xy;         /* indicates whether pts,boxes are ordered x,y */
  int_4 iarg;        /* integer used for message passing */
  int_4 msgid;       /* id of primitive to send info messages to */
  int_4 msgmask;     /* mask specifying which messages to send */
  bool_4 clip;       /* TRUE: Boxes, Points, Annt clip to area below */
  int_4 x1, x2;       /* left and right pixel coords for clipping */
  int_4 y1, y2;       /* top and bottom pixel coords for clipping */

  bool_4 aview;      /* when FALSE annotate visibility is toggled off */
  int_4 mannt;       /* maximum number of points in array */
  int_4 nannt;       /* number of valid points in array */

  bool_4 bview;      /* when FALSE box visibility is toggled off */
  int_4 bnumbers;    /* < 0: XOR text, 0 no numbers, > 0 tied to ANNOTATE */
  int_4 mbox;        /* maximum number of boxes in array */
  int_4 nbox;        /* number of valid boxes in array */

  bool_4 configure;  /* when TRUE panel widgets are being configured */
  int_4 cstatus;     /* return status of XCALL */
  int_4 current;     /* current panel widget to receive keypresses */
  int_4 cmenulit;    /* number of last menu to be entered */
  int_4 mcon;        /* maximum number of controls in array */
  int_4 ncon;        /* number of valid conrols in array */

  bool_4 psort;      /* when TRUE points are sorted */
  int_4 pline;       /* indicates width of connecting line (1 or 0) */
  int_4 pdot;        /* type of symbols to be drawn */
  int_4 prad;        /* radius of the symbol to be drawn on screen */
  int_4 mpoint;      /* maximum number of points in array */
  int_4 npoint;      /* number of valid points in array */

/*
 +++
  wgd added
*/
  int_4 MRMMaster;   /* Master Macro MRM Pointer */
  int_4 MRMPtr;      /* 8 Byte alignment... */
/*
 ---
*/

} XFACILITIES;

#define L_xfacilities sizeof(XFACILITIES)

#define XM_XFACILITIES_H_
#endif /* XM_XFACILITIES_H_ */
