/* **********************************************************************
 * *                                                                    *
 * *   SIGMET X related library                                         *
 * *                                                                    *
 * **********************************************************************
 * File: include/xsig_lib.h
 *
 *             COPYRIGHT (c) 1996, 1997, 2000, 2002, 2003 BY
 *          SIGMET INCORPORATED, WESTFORD MASSACHUSETTS, U.S.A.
 * 
 * THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND  COPIED
 * ONLY  IN  ACCORDANCE WITH  THE  TERMS  OF  SUCH  LICENSE  AND WITH THE
 * INCLUSION OF THE ABOVE COPYRIGHT NOTICE.  THIS SOFTWARE  OR  ANY OTHER
 * COPIES  THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY
 * OTHER PERSON.  NO TITLE TO AND OWNERSHIP OF  THE  SOFTWARE  IS  HEREBY
 * TRANSFERED.
 */
#ifndef SIGMET_XSIG_LIB_H
#define SIGMET_XSIG_LIB_H 1

#ifdef __cplusplus
extern "C" {
#endif

/* ============================================================================
 * Local X structure, routines 
 */

typedef void (*Xs1ArgCallbackProc)( void *arg1_a );
typedef void (*Xs2ArgCallbackProc)( Widget wgt_a, char *arg2_a );

/*-----------------------------------------------------------------------------
 Structures 
*/

  /* Maximum number of entries in pulldown widgets */
#define XSIG_PULLDOWN_MAX (40)

struct XsLabBarBtnTxt_struct
{
  Widget lab, bar, cas, pdw, txt;
};
typedef struct XsLabBarBtnTxt_struct XsPDW_TXT;

struct XsLabOpt_struct
{
  Widget lab, opt, btn, pdw;
};
typedef struct XsLabOpt_struct XsLAB_OPT;

struct XsLabTxt_struct
{
  Widget lab, txt;
};
typedef struct XsLabTxt_struct XsLAB_TXT;

struct XsBtnTxt_structp  /* to be phase out */
{
  Widget lab, btn, txt;
};
typedef struct XsBtnTxt_structp XsBTN_TXT;

struct XsBtnTxtFrm_struct
{
  Widget btn, txt, frm;
};
typedef struct XsBtnTxtFrm_struct XsBTN_TXT_FRM;

struct XsLabTgl_struct
{
  Widget lab, tgl;
};
typedef struct XsLabTgl_struct XsLAB_TGL;

struct XsLabTxtScl_struct
{
  Widget lab, txt, scl;
};
typedef struct XsLabTxtScl_struct XsTXT_SCL;


struct XsTimeDateDlg_struct
{
  Widget frm;
  Widget hhi_btn, hhd_btn, mii_btn, mid_btn, ssi_btn, ssd_btn;
  Widget dai_btn, dad_btn, moi_btn, mod_btn, yyi_btn, yyd_btn;
  Widget txt;
  Widget ebt;
  struct ymds_time ymds;

  Xs2ArgCallbackProc cbf_a; 
};
typedef struct XsTimeDateDlg_struct XsTIME_DATE_DLG;


/*-----------------------------------------------------------------------------
 Form-Option-List-Button Widget
*/
struct XsFrmOptLstBtn_struct
{
  Widget frm, opt, pdw, btns[25], lst, ebt;
  void   (*cbf_a)( Widget wgt, char *tag, XmAnyCallbackStruct *cbd); 
};
typedef struct XsFrmOptLstBtn_struct XsFOLB;

XsFOLB* XsCreateFOLB
(Widget pwgt_a,
 char* snam_a,
 int icnt_a,
 void(*cbf_a)( Widget wgt, char *tag, XmAnyCallbackStruct *cbd));
XsFOLB* XsCreateDFOLB
(Widget pwgt_a,
 char* snam_a,
 int icnt_a,
 void(*cbf_a)( Widget wgt, char *tag, XmAnyCallbackStruct *cbd));

/*-----------------------------------------------------------------------------
 Button-Text Widget
*/
struct XsBtnTxt_struct
{
  Widget lab, btn, txt;
  Xs2ArgCallbackProc cbf_a; 
};
typedef struct XsBtnTxt_struct XsBTNTXT;


/*-----------------------------------------------------------------------------
 Frm-List-Button Widget
*/
struct XsFrmLstBtn_struct
{
  Widget frm, lst, ebt;
  void   (*cbf_a)( Widget wgt, char *tag, XmListCallbackStruct* cbd ); 
};
typedef struct XsFrmLstBtn_struct XsFLB;

XsFLB*  XsCreateFLB
( Widget pwgt_a, 
 char* snam_a,
 void(*cbf_a)( Widget wgt, char *tag, XmListCallbackStruct* cbd) );

XsFLB*  XsCreateFLBNoExit
( Widget pwgt_a,
 char* snam_a,
 void(*cbf_a)( Widget wgt, char *tag, XmListCallbackStruct* cbd) );

XsFLB*  XsCreateFLBNoDestroy
( Widget pwgt_a,
 char* snam_a,
 void(*cbf_a)( Widget wgt, char *tag, XmListCallbackStruct* cbd) );

XsFLB* XsCreateDFLB
( Widget pwgt_a,
 char* snam_a,
 void(*cbf_a)( Widget wgt, char *tag, XmListCallbackStruct* cbd) );


/*-----------------------------------------------------------------------------
 * Function prototypes
 */


char* pstrcat( char* str1_a, char* str2_a );
char* pstridx( char* str1_a, int idx_a );


/* Form Attach Routines */
void XsAttach1LTRX( Widget, Widget lfwgt_a, Widget tpwgt_a, Widget rtwgt_a);
void XsAttach1LTFX( Widget, Widget lfwgt_a, Widget tpwgt_a );
void XsAttach1LTFF( Widget, Widget lfwgt_a, Widget tpwgt_a );
void XsAttach1LTXF( Widget, Widget lfwgt_a, Widget tpwgt_a );
void XsAttach1LTXX( Widget, Widget lfwgt_a, Widget tpwgt_a );
void XsAttach1OTXX( Widget, Widget lfwgt_a, Widget tpwgt_a );
void XsAttach1OOXX( Widget, Widget lfwgt_a, Widget tpwgt_a );
void XsAttach1LFFX( Widget, Widget lfwgt_a );
void XsAttach1FTFX( Widget, Widget tpwgt_a );
void XsAttach1FTFF( Widget, Widget tpwgt_a );
void XsAttach1FTFB( Widget, Widget tpwgt_a, Widget btwgt_a );
void XsAttach1FTRF( Widget, Widget tpwgt_a, Widget rtwgt_a );
void XsAttach1FTXX( Widget, Widget tpwgt_a );
void XsAttach1FTXF( Widget, Widget tpwgt_a );
void XsAttach1FFFB( Widget, Widget btwgt_a );
void XsAttach1FFFX( Widget );
void XsAttach1FFXX( Widget );
void XsAttach1FXFF( Widget );
void XsAttach1XTFF( Widget, Widget tpwgt_a );
void XsAttach1XTRX( Widget, Widget tpwgt_a, Widget rtwgt_a );
void XsAttach1XTOX( Widget, Widget tpwgt_a, Widget rtwgt_a );
void XsAttach1XTFX( Widget, Widget tpwgt_a );
void XsAttach1XTXX( Widget, Widget tpwgt_a );
void XsAttach1XFFX( Widget );
void XsAttach1XXXF( Widget );
void XsAttach1FXXF( Widget );
void XsAttach1LXXF( Widget, Widget lfwgt_a );
void XsAttach1nFFFB( Widget wgts_a[], SINT2 icnt_a );

void XsAttach2LTXX( Widget, Widget, Widget lfwgt_a, Widget tpwgt_a );
void XsAttach2XTRX( Widget, Widget, Widget tpwgt_a, Widget rtwgt_a );
void XsAttach2LTRX( Widget, Widget, Widget lfwgt_a, Widget tpwgt_a, Widget rtwgt_a);
void XsAttach2LTFX( Widget, Widget, Widget lfwgt_a, Widget tpwgt_a );
void XsAttach2LFXX( Widget, Widget, Widget lfwgt_a );
void XsAttach2LFFX( Widget, Widget, Widget lfwgt_a );
void XsAttach2FTXF( Widget, Widget, Widget tpwgt_a );
void XsAttach2FTXX( Widget, Widget, Widget tpwgt_a );
void XsAttach2XTFX( Widget, Widget, Widget tpwgt_a );
void XsAttach2FTFX( Widget, Widget, Widget tpwgt_a );
void XsAttach2FTFF( Widget, Widget, Widget tpwgt_a );
void XsAttach2FFFX( Widget, Widget );
void XsAttach2FFXX( Widget, Widget );
void XsAttach2FXXF( Widget, Widget );
void XsAttach2XXXF( Widget, Widget );

void XsAttach3LTFX( Widget, Widget, Widget,  Widget lfwgt_a, Widget tpwgt_a );
void XsAttach3LTXX( Widget, Widget, Widget,  Widget lfwgt_a, Widget tpwgt_a );
void XsAttach3LFFX( Widget, Widget, Widget,  Widget lfwgt_a );
void XsAttach3FTFX( Widget, Widget, Widget,  Widget tpwgt_a );
void XsAttach3FTXX( Widget, Widget, Widget,  Widget tpwgt_a );
void XsAttach3FTXF( Widget, Widget, Widget,  Widget tpwgt_a );
void XsAttach3FFXX( Widget, Widget, Widget );
void XsAttach3FFFX( Widget, Widget, Widget );
void XsAttach3FXXF( Widget, Widget, Widget );
void XsAttach3XXXF( Widget, Widget, Widget );

XsBTNTXT* XsCreateBTNTXT
(Widget pwgt_a,
 char* snam_a,
 Xs2ArgCallbackProc cbf_a );

void   XsCreateBTN_TXT( Widget parent_a,   
		      XsBTN_TXT* wgtset_a, char* sname_a, 
		      void(*btn_cbf_a)(), void(*txt_cbf_a)() );
void   XsCreateBTN_OTXT( Widget parent_a,   
		      XsBTN_TXT* wgtset_a, char* sname_a, 
		      void(*btn_cbf_a)() );

Widget XsCreateBtnBar( Widget pid_a, char* snam_a );
Widget XsCreateBtn1Pdw(Widget bar_a, char* snam_a, int icnt_a, void(*cbf_a)());
Widget XsCreateBtnsPdw( Widget base_a, char* sshl_a, int idx_a, int icnt_a,
			void(*cbf_a)( Widget, int, XmPushButtonCallbackStruct *) );
Widget XsCreateBtnsPop( Widget base_a, char* sshl_a, int icnt_a,
		        void(*cbf_a)() );

void   XsCreateHHmmPop( Widget  base_a,
		      Widget* shl_a, char* sshl_a,
		      Widget* txt_a, char* stxt_a,
		      void    (*hhmm_cbf_a)() );

void   XsCreateHHmmssPop( Widget  base_a,
		      Widget* shl_a, char* sshl_a,
		      Widget* txt_a, char* stxt_a,
		      void    (*hhmm_cbf_a)() );

void   XsCreateHHmmssNonePop( Widget  base_a,
		      Widget* shl_a, char* sshl_a,
		      Widget* txt_a, char* stxt_a,
		      void    (*hhmm_cbf_a)() );

void   XsCreateHHmmddmoyyPop(Widget  base_a,
			   Widget* shl_a, char* sshl_a,
			   Widget* txt_a, char* stxt_a,
			   void    (*hhmmddmoyy_cbf_a)() );

void   XsCreateLAB_TXT( Widget     parent_a,  
		      XsLAB_TXT* wgtset_a, char* sname_a, void(*btn_cbf)() ); 

void   XsCreateLAB_TGL( Widget     parent_a,  
		      XsLAB_TGL* wgtset_a, char* sname_a, void(*tgl_cbf)() ); 

void   XsCreateMPBTNS(Widget parent_a, 
		      Widget array_a[], char* sname_a, int icnt_a,
		      void(*cbf_a)() );

Widget XsCreateOptMnu                       /* File: xscreatewgt.c */
(Widget  parent_a,  char* soptnam_a,
 Widget* btnwgts_a, int ibtncnt_a, void (*btn_cbf)() );

Widget XsCreateOText1( Widget ipid_a, char* snam_a, void* args_a, int icnt_a );
Widget XsCreateOText( Widget ipid_a, char* snam_a, void* args_a, int icnt_a );

Widget XsCreatePBTN( Widget pwgt_a, char* snam_a, void(*cbf_a)());

void   XsCreatePDW_TXT( Widget parent_a,   
		       XsPDW_TXT* wgtset_a, char* sname_a, 
		       int icnt_a, void(*btn_cbf_a)(), void(*txt_cbf_a)() );
void   XsCreateSize_PDW_TXT( Widget parent_a,   
			    XsPDW_TXT* wgtset_a, char* sname_a, 
			    int icnt_a, int, int,
			    void(*btn_cbf_a)(), void(*txt_cbf_a)() );

XsTIME_DATE_DLG* XsCreateTimeDateDLG
( Widget, char*, Xs2ArgCallbackProc cbf_a );

void     XsOffsetsLXXX( Widget, SINT2 );
void     XsOffsetsXTXX( Widget, SINT2 );
void     XsOffsetsXXRX( Widget, SINT2 );
void     XsOffsetsXXXB( Widget, SINT2 );
void     XsOffsetsLTRB( Widget, SINT2, SINT2, SINT2, SINT2 );
void     XsOffsetsLTRX( Widget, SINT2, SINT2, SINT2 );
void     XsOffsetsLTXX( Widget, SINT2, SINT2 );
void     XsOffsetsLXRB( Widget, SINT2, SINT2, SINT2 );
void     XsOffsetsXXRB( Widget, SINT2, SINT2 );
void     XsOffsetsXTRX( Widget, SINT2, SINT2 );
void     XsOffsetsLXRX( Widget, SINT2, SINT2 );
void     XsOffsetsXTXB( Widget, SINT2, SINT2 );


void     XsSetLabel( Widget wgt_a, char* snam_a );
void     XsSetOption( Widget optwgt_a, Widget hotwgt_a );
#ifdef SIGMET_HEADERS_H
void     XsSetDevicePdwBtnsLabs(Widget pdw_a,DEVICE_INFO devs[],SINT2 icnt_a );
#endif  /* #ifdef SIGMET_HEADERS_H */
void     XsSetEditable(Widget wgt1_a);
void     XsSetNonEditable(Widget wgt1_a);
void     XsSetPromptText( Widget wgt_a, char* stext_a );
void     XsSetTitle( Widget wgt_a, char* site_a, char* smenu_a, char* sfile_a );

SINT2    XsStrToList( Widget lstwgt_a, char* str_a );

void     XsSetPdwBtnsLabs(Widget wgt_a, char *btnlabs_a, SINT2 icnt_a );

/* ============================================================================
 *  Thres_critera
 *
 *    The routines here are related to the setting and displaying of the signal
 *thresholding.
 */

#define FCMTOKM( icm ) ( ((float)icm)/100000.0 )
#define IKMTOCM( fkm ) ( (SINT4)(fkm*100000.0) )

UINT2 enter_csr_f( UINT2 icrit_a );
UINT2 enter_log_f( UINT2 icrit_a );
UINT2 enter_sqi_f( UINT2 icrit_a );
SINT2 ixslistcnt_f( Widget );
SINT2 ixslistpos_f( Widget );
SINT2 ixslisttop_f( Widget );

char* sazm_txt_f( SINT2 iscan_mode_a, SINT2 isweeps_a, UINT4 *iang_list_a );
char* selv_txt_f( SINT2 iscan_mode_a, SINT2 isweeps_a, UINT4 *iang_list_a );
char* scan_abbrev_f( SINT2 iscan_a );

void  start_process( char *sexe, char *spid );
char* sthrs_crit_txt_f( UINT2 icrit_a );

#ifdef __cplusplus
}
#endif
#endif /* #ifndef SIGMET_XSIG_LIB_H */
