/***********************************************************************
 *
 * TITLE:
 *      chdate.c
 *
 * AUTHOR:
 *      Cassie Mulnix
 *
 * DESCRIPTION:
 *      This module is part of the OPPS editor, xopps.  It contains
 *      object routines to handle chdate objects.
 *
 *                              CHANGE HISTORY
 *
 * $Log: chdate.c,v $
 * Revision 1.23  1994/08/10  22:02:18  cassie
 * fixed DialogFlagSet calls
 *
 * Revision 1.22  1994/07/20  19:06:35  clm
 * updated TRUE, ERROR etc in cancel & ok_button functions
 * to DIALOG_ constants
 *
 * Revision 1.21  1994/06/16  21:55:48  clm
 * updated to new dialog routines - extra parameter to DialogTextCreate
 *
 * Revision 1.20  1994/06/16  16:56:35  clm
 * updated to new gr_ routines using GR_ for font names
 *
 * Revision 1.19  1994/06/08  18:47:59  clm
 * removed Xm library includes since they are in dialog
 *
 * Revision 1.18  1994/06/01  22:27:07  clm
 * rewrote init functions to use dialog oellib functions
 * also don't initialize popups until object called
 *
 * Revision 1.17  1994/05/20  23:31:43  clm
 * updated with HP, SGI changes
 *
 * Revision 1.16  1994/05/04  23:34:36  clm
 * ported to ANSI C
 *
 * Revision 1.15  1993/05/18  20:58:30  clm
 * added new message.c function
 *
 * Revision 1.14  1992/12/22  16:00:38  clm
 * fixed lim and load so objects cannot be loaded or moved outside chart lines
 *
 * Revision 1.13  1992/12/15  16:41:34  clm
 * fixed memory leak in Color widget
 *
 * Revision 1.12  1992/12/10  21:45:40  clm
 * fixed new_index so chart is always object 0
 *
 * Revision 1.11  1992/10/02  19:49:18  clm
 * housekeeping
 *
 * Revision 1.10  1992/09/17  15:24:24  clm
 * added display options to object
 *
 * Revision 1.9  1992/09/16  14:55:03  clm
 * fixed load function so doesn't add object if error in load
 *
 * Revision 1.8  1992/09/14  18:33:36  clm
 * added layer to object
 *
 * Revision 1.7  1992/08/31  23:03:24  clm
 * added color to chart date object
 *
 * Revision 1.6  1992/08/20  18:05:54  clm
 * fixed load error checking for font
 *
 * Revision 1.5  1992/08/20  15:16:49  clm
 * fixed font value
 *
 * Revision 1.4  1992/08/13  18:08:09  clm
 * fixed error checking for load_chdate
 *
 * Revision 1.2  1992/08/10  17:58:25  clm
 * fixed aesthetics of popup
 *
 * Revision 1.1  1992/08/04  17:01:53  clm
 * Initial revision
 *
 *
 ***********************************************************************
 *
 * WARNINGS:
 *
 * EXTERNAL CALLABLE COMPONENTS (PUBLIC):
 *
 * GLOBALS:
 *
 * WAIVERS:
 *
 * NOTES:
 *
 * MANPAGE:
 *
 ***********************************************************************/

#ifndef lint
static char rcsid[] =
    "$Id: chdate.c,v 1.23 1994/08/10 22:02:18 cassie OEL $";
#endif

/*************************************************************************
    global functions:
        add_chdate(x, y, font, point, layer) - add object to data base
***************************************************************************/

/*
    local functions:
        dsp_chdate(i) - display chdate object
        edt_chdate(i, new) - change contents of chdate field
        rem_chdate(i) - remove chdate object
        lim_chdate(i) - limit range of motion of chdate object
        loc_chdate(i) - locate position of chdate object on screen
        mov_chdate(i) - move chdate object
        cpy_chdate(to, from) - copy chdate object
        msg_chdate(i) - display message on screen
        sav_chdate(i, file) - save chdate to file
*/

#include "xopps.h"

static int font_values[] = {
    GR_COURIER, GR_COURIER_BOLD, GR_HELVETICA, GR_HELVETICA_BOLD, GR_TIMES, 
    GR_TIMES_BOLD
};

static int font_sizes[] = {
        8, 10, 12, 14, 18, 24
};

        /* local functions */
static void create_dialog(void);
static int load_chdate(char *);			/* load a chdate object */
static void cdt_ok_button(void);		/* Callback for ok button */
static void cancel_button(void);		/* Callback for cancel button */
static void change_point(Widget, XtPointer, XtPointer);
static void change_font(Widget, XtPointer, XtPointer);
static void change_color(Widget, XtPointer, XtPointer);
static void change_drawlyr(Widget, XtPointer, XtPointer);
static void change_disp(Widget, XtPointer, XtPointer);
static void dsp_chdate(int);
static void edt_chdate(int, int);
static void rem_chdate(int, int);
static void lim_chdate(int, int *, int *, int *, int *, int);
static void loc_chdate(int, int);
static void mov_chdate(int, int, int, int);
static void cpy_chdate(struct obj *, struct obj *);
static void msg_chdate(int, int);
static void sav_chdate(int, FILE *, int);
static void verify_fun(Widget, XtPointer, XtPointer);

static struct ops cdt_ops = {
    dsp_chdate, edt_chdate, rem_chdate, lim_chdate, loc_chdate, mov_chdate,
    cpy_chdate, msg_chdate, sav_chdate
};

static Widget chdate_dialog;                     /* dialog shell for popup */
static Widget parent_shell;

static DialogOption *fontw, *pointw;
static DialogOption *colorw;
static DialogOption *dispw;
static DialogOption *drawlyrw;

static int new_point;                           /* new point id */
static int new_font;                            /* new font id */
static int new_color;				/* new color id */
static int new_drawlyr;				/* new draw layer id */
static int new_disp;				/* new display date id */

/***********************************************************************
 *
 * FUNCTION:
 *      init_chdate_object()
 * INPUTS:
 *      parent  (Widget)
 *
 * OUTPUTS:
 *	none
 *
 * RETURNS:
 *	none
 *
 * EXTERNALLY READ:
 *	none
 *
 * EXTERNALLY MODIFIED: *
 *	none
 *
 * DESCRIPTION:
 *	registers the chart date object and sets the parent
 *	
 */

void 
init_chdate_object(Widget parent)
{

    register_io_obj('Z', load_chdate);            /* register object */
    parent_shell = parent;
}

/***********************************************************************
 *
 * FUNCTION:
 *      create_dialog()
 *
 * INPUTS:
 *	none
 *
 * OUTPUTS:
 *	none
 *
 * RETURNS:
 *	none
 *
 * EXTERNALLY READ:
 *	none
 *
 * EXTERNALLY MODIFIED: *
 *	none
 *
 * DESCRIPTION:
 *	initializes the widgets for the chart date dialog
 *	
 */

static void
create_dialog(void)
{
    static char *fonts[] = { "Courier", "Courier Bold", "Helvetica",
        "Helvetica Bold", "Times", "Times Bold" };
    static char *points[] = { "8", "10", "12", "14", "18", "24" };
    static char *drawlyrs[] = { "0", "1", "2", "3" };
    static char *disps[] = { "DOY", "Mon. Day, Year", "Month Day, Year",
	"mm/dd/yy" };

    chdate_dialog = DialogInit(parent_shell, "Chart Date Object", "chartdate",
	verify_fun, (XtPointer)DIALOG_CANCEL);
    fontw = DialogOptionCreate("Font: ", 6, 5, change_font, 
	DIALOG_OPT_STR_ARY, fonts, font_values);
    pointw = DialogOptionCreate("Point: ", 6, 10, change_point, 
	DIALOG_OPT_STR_ARY, points, font_sizes);

    colorw = DialogOptionCreate("Color: ", ncolor, 0, change_color, 
	DIALOG_OPT_STR_ARY, color_name, color_index);

    drawlyrw = DialogOptionCreate("Draw Layer: ", 4, 0, change_drawlyr, 
	DIALOG_OPT_STR_ARY, drawlyrs, NULL);
    dispw = DialogOptionCreate("Display Date", 4, 1, change_disp, 
	DIALOG_OPT_STR_ARY, disps, NULL);

    DialogStdButtons(verify_fun, (XtPointer)DIALOG_UPDATE, verify_fun,
        (XtPointer)DIALOG_CANCEL, (XtCallbackProc)ShowHelp, "chartdate");

}

/***********************************************************************
 *
 * FUNCTION:
 *      add_chdate()
 *
 * INPUTS:
 *      x, y, font, point, layer, color, disp  (int)
 *
 * OUTPUTS:
 *
 * RETURNS:
 *
 * EXTERNALLY READ:
 *
 * EXTERNALLY MODIFIED:
 *
 * DESCRIPTION:
 *      adds new chdate object
 */

int 
add_chdate(int x, int y, int font, int point, int layer, int color, int disp)
{
    int i;              /* index */

    i = new_index(FALSE);
    objary[i].z.cdtptr = (struct cdt *)XtMalloc(sizeof(struct cdt));
    objary[i].z.cdtptr->x = x;
    objary[i].z.cdtptr->y = y;
    objary[i].z.cdtptr->font = font;
    objary[i].z.cdtptr->point = point;
    objary[i].z.cdtptr->color = color;
    objary[i].z.cdtptr->disp = disp;
    objary[i].type = OBJ_CDT;
    objary[i].opsptr = &cdt_ops;
    objary[i].layer = layer;
    return i;
}

/***********************************************************************
 *
 * FUNCTION:
 *      cpy_chdate()
 *
 * INPUTS:
 *      to, from        (obj *)
 *
 * OUTPUTS:
 *
 * RETURNS:
 *
 * EXTERNALLY READ:
 *
 * EXTERNALLY MODIFIED:
 *
 * DESCRIPTION:
 *      copies chdate object from to chdate object to
 */

static void 
cpy_chdate(struct obj *to, struct obj *from)
{

    if (from->type == OBJ_NUL) return;

    to->z.cdtptr = (struct cdt *)XtMalloc(sizeof(struct cdt));
    to->z.cdtptr->font = from->z.cdtptr->font;
    to->z.cdtptr->point = from->z.cdtptr->point;
    to->z.cdtptr->x = from->z.cdtptr->x;
    to->z.cdtptr->y = from->z.cdtptr->y;
    to->z.cdtptr->color = from->z.cdtptr->color;
    to->z.cdtptr->disp = from->z.cdtptr->disp;
    to->type = OBJ_CDT;
    to->layer = from->layer;
    to->opsptr = &cdt_ops;
    to->rlist = copyRectList(from->rlist);
}

/***********************************************************************
 *
 * FUNCTION:
 *      rem_chdate()
 *
 * INPUTS:
 *      i       (int)
 *
 * OUTPUTS:
 *
 * RETURNS:
 *
 * EXTERNALLY READ:
 *
 * EXTERNALLY MODIFIED:
 *
 * DESCRIPTION:
 *      removes chdate object i
 */

static void 
rem_chdate(int i, int dir)
{
    struct obj *objptr;

    switch (i) {
    case BACK:
        objptr = &objbck;
        break;
    case TEMP:
        objptr = &objtmp;
        break;
    default: 
	objptr = &(objary[i]);
        break;
    }
    freeRectList(objptr->rlist);
    XtFree((char *)objptr->z.cdtptr);
    rem_object(objptr);
}

/***********************************************************************
 *
 * FUNCTION:
 *      lim_chdate()
 *
 * INPUTS:
 *      i       (int)
 *      x1, y1, x2, y2  (int *)
 *
 * OUTPUTS:
 *
 * RETURNS:
 *
 * EXTERNALLY READ:
 *
 * EXTERNALLY MODIFIED:
 *
 * DESCRIPTION:
 *      limits range of motion of chdate object
 */

static void 
lim_chdate(int i, int *x1, int *y1, int *x2, int *y2, int dir)
{
    XRectangle *(*r)[];

    r = getMoveRect(objary[i].rlist);
    *x1 = xlnary[0].z.lnptr->cord;
    *y1 = ylnary[0].z.lnptr->cord;
    *x2 = xlnary[nxln-1].z.lnptr->cord - (1 + (*r)[0]->width);
    *y2 = ylnary[nyln-1].z.lnptr->cord - (1 + (*r)[0]->height);
}

/***********************************************************************
 *
 * FUNCTION:
 *      loc_chdate()
 *
 * INPUTS:
 *      i       (int)
 *
 * OUTPUTS:
 *
 * RETURNS:
 *
 * EXTERNALLY READ:
 *
 * EXTERNALLY MODIFIED:
 *
 * DESCRIPTION:
 *      locates position of chdate object i
 */

static void 
loc_chdate(int i, int dir)
{
    struct cdt *cdtptr;         /* local pointer */
    XRectangle r;               /* rectangle */
    char buf[128];		/* temp buffer */
    int sdoy, edoy;		/* start and end day of year */
    int smo, sda, syr;		/* start date */
    int emo, eda, eyr;		/* end date */
    static char *mn[12] = {
	"JAN", "FEB", "MAR", "APR", "MAY", "JUNE", "JULY", "AUG", "SEPT",
	"OCT", "NOV", "DEC"
    };
    static char *month[12] = {
	"January", "February", "March", "April", "May", "June", "July",
	"August", "September", "October", "November", "December"
    };
    static char *monum[12] = {
	"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"
    };

    cdtptr = objary[i].z.cdtptr;
    if (cdtptr->disp == 0) {
	sdoy = get_doy(objary[0].z.chtptr->start_date);
	edoy = get_doy(objary[0].z.chtptr->end_date);
	(void)sprintf(buf, "Chart Date %d to %d", sdoy, edoy);
    } else if (cdtptr->disp == 1) {
	get_mdy(&smo, &sda, &syr, objary[0].z.chtptr->start_date);
	get_mdy(&emo, &eda, &eyr, objary[0].z.chtptr->end_date);
	(void)sprintf(buf, "Chart Date %s %d,%d to %s %d,%d", mn[smo-1], sda, 
	    syr, mn[emo-1], eda, eyr);
    } else if (cdtptr->disp == 2) {
	get_mdy(&smo, &sda, &syr, objary[0].z.chtptr->start_date);
	get_mdy(&emo, &eda, &eyr, objary[0].z.chtptr->end_date);
	(void)sprintf(buf, "Chart Date %s %d,%d to %s %d,%d", month[smo-1], 
	    sda, syr, month[emo-1], eda, eyr);
    } else if (cdtptr->disp == 3) {
	get_mdy(&smo, &sda, &syr, objary[0].z.chtptr->start_date);
	get_mdy(&emo, &eda, &eyr, objary[0].z.chtptr->end_date);
	(void)sprintf(buf, "Chart Date %s/%d/%d to %s/%d/%d", monum[smo-1], 
	    sda, syr, monum[emo-1], eda, eyr);
    }
    r.width = gr_strwidth(buf, cdtptr->font|cdtptr->point);
    r.height = gr_txheight(cdtptr->font|cdtptr->point) + 1;
    r.x = cdtptr->x;
    r.y = cdtptr->y;
    setRectList(objary[i].rlist, 1, &r, RL_PRIMARY);
}

/***********************************************************************
 *
 * FUNCTION:
 *      mov_chdate()
 *
 * INPUTS:
 *      i, x, y (int)
 *
 * OUTPUTS:
 *
 * RETURNS:
 *
 * EXTERNALLY READ:
 *
 * EXTERNALLY MODIFIED:
 *
 * DESCRIPTION:
 *      moves chdate object i to (x,y)
 */

static void 
mov_chdate(int i, int x, int y, int dir)
{
    objary[i].z.cdtptr->x += x;
    objary[i].z.cdtptr->y += y;
}

/***********************************************************************
 *
 * FUNCTION:
 *      dsp_chdate()
 *
 * INPUTS:
 *      i       (int)
 *
 * OUTPUTS:
 *
 * RETURNS:
 *
 * EXTERNALLY READ:
 *
 * EXTERNALLY MODIFIED:
 *
 * DESCRIPTION:
 *      displays chdate object i on screen
 */

static void 
dsp_chdate(int i)
{
    struct cdt *cdtptr;         /* local pointer */
    char buf[128];		/* temp buffer */
    int height;			/* height of text */
    int sdoy, edoy;		/* start and end day of year */
    int smo, sda, syr;		/* start date */
    int emo, eda, eyr;		/* end date */
    static char *mn[12] = {
	"JAN", "FEB", "MAR", "APR", "MAY", "JUNE", "JULY", "AUG", "SEPT",
	"OCT", "NOV", "DEC"
    };
    static char *month[12] = {
	"January", "February", "March", "April", "May", "June", "July",
	"August", "September", "October", "November", "December"
    };
    static char *monum[12] = {
	"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"
    };

    cdtptr = objary[i].z.cdtptr;
    gr_set_color(color_name[cdtptr->color], color_gscale[cdtptr->color]);
    if (cdtptr->disp == 0) {
	sdoy = get_doy(objary[0].z.chtptr->start_date);
	edoy = get_doy(objary[0].z.chtptr->end_date);
	(void)sprintf(buf, "Chart Date %d to %d", sdoy, edoy);
    } else if (cdtptr->disp == 1) {
	get_mdy(&smo, &sda, &syr, objary[0].z.chtptr->start_date);
	get_mdy(&emo, &eda, &eyr, objary[0].z.chtptr->end_date);
	(void)sprintf(buf, "Chart Date %s %d,%d to %s %d,%d", mn[smo-1], sda, 
	    syr, mn[emo-1], eda,eyr);
    } else if (cdtptr->disp == 2) {
	get_mdy(&smo, &sda, &syr, objary[0].z.chtptr->start_date);
	get_mdy(&emo, &eda, &eyr, objary[0].z.chtptr->end_date);
	(void)sprintf(buf, "Chart Date %s %d,%d to %s %d,%d", month[smo-1], 
	    sda, syr, month[emo-1], eda, eyr);
    } else if (cdtptr->disp == 3) {
	get_mdy(&smo, &sda, &syr, objary[0].z.chtptr->start_date);
	get_mdy(&emo, &eda, &eyr, objary[0].z.chtptr->end_date);
	(void)sprintf(buf, "Chart Date %s/%d/%d to %s/%d/%d", monum[smo-1], 
	    sda, syr, monum[emo-1], eda, eyr);
    }
    height = gr_txheight(cdtptr->font|cdtptr->point);
    gr_text(cdtptr->x, cdtptr->y + height, buf, GR_LEFT,
       (cdtptr->font|cdtptr->point), 0);
}

/***********************************************************************
 *
 * FUNCTION
 *      msg_chdate()
 *
 * INPUTS:
 *      i       (int)
 *
 * OUTPUTS:
 *
 * RETURNS:
 *
 * EXTERNALLY READ:
 *
 * EXTERNALLY MODIFIED:
 *
 * DESCRIPTION:
 *      displays chdate message on screen
 */

static void 
msg_chdate(int i, int dir)
{
    char buf[64];

    (void)sprintf(buf, "Chart Date");
    Message(buf);
}

/***********************************************************************
 *
 * FUNCTION:
 *      sav_chdate()
 *
 * INPUTS:
 *      i       (int)
 *      fp      (FILE *)
 *
 * OUTPUTS:
 *
 * RETURNS:
 *
 * EXTERNALLY READ:
 *
 * EXTERNALLY MODIFIED:
 *
 * DESCRIPTION:
 *      saves chdate record i to fp
 */

static void 
sav_chdate(int i, FILE *fp, int dir)
{
    struct cdt *cdtptr;
    char buf[256];

    cdtptr = objary[i].z.cdtptr;
    buf[0] = 'Z';
    buf[1] = ' ';
    record_print(buf + 2, "ddddddd", cdtptr->x, cdtptr->y, cdtptr->font,
	 cdtptr->point, objary[i].layer, cdtptr->color, cdtptr->disp);
    fputs(buf, fp);
}

/***********************************************************************
 *
 * FUNCTION:
 *      load_chdate()
 *
 * INPUTS:
 *      buf     (char *)
 *
 * OUTPUTS:
 *
 * RETURNS:
 *
 * EXTERNALLY READ:
 *
 * EXTERNALLY MODIFIED:
 *
 * DESCRIPTION:
 *      loads chdate object record
 */

static int 
load_chdate(char *buf)
{
    int x, y, font, point, layer, color, disp;
    int i;

    if (record_scan(buf + 1, "ddddddd", &x, &y, &font, &point, &layer, &color,
	&disp) == 7) {
	if ((x < xlnary[0].z.lnptr->cord) || 
	    (x > xlnary[nxln-1].z.lnptr->cord)) {
	    Warning("Illegal Chart Date x %d", x);
	} else if ((y < ylnary[0].z.lnptr->cord) || 
	    (y > ylnary[nyln-1].z.lnptr->cord)) {
	    Warning("Illegal Chart Date y %d", y);
	} else if ((font != GR_COURIER) && (font != GR_COURIER_BOLD) && 
	    (font != GR_HELVETICA) && (font != GR_HELVETICA_BOLD) && 
	    (font != GR_TIMES) && (font != GR_TIMES_BOLD)) {
	    Warning("Illegal Chart Date font %d", font);
	} else if ((point != 8) && (point != 10) && (point != 12) &&
	    (point != 14) && (point != 18) && (point != 24)) {
	    Warning("Illegal Chart Date point %d", point);
	} else if ((layer < 0) || (layer > 3)) {
	    Warning("Illegal Chart Date layer %d", layer);
	} else if ((color < 0) || (color > ncolor)) {
	    Warning("Illegal Chart Date color %d", color);
	} else if ((disp < 0) || (disp > 3)) {
	    Warning("Illegal Chart Date display date option %d", disp);
	} else {
            i = add_chdate(x, y, font, point, layer, color, disp);
            (*(objary[i].opsptr->loc))(i, OBJECT);
            return 0;
	}
        return -1;
    } else {
        return -1;
    }
}

/***********************************************************************
 *
 * FUNCTION:
 *      edt_chdate()
 *
 * INPUTS:
 *      i, new  (int)
 *
 * OUTPUTS:
 *
 * RETURNS:
 *
 * EXTERNALLY READ:
 *
 * EXTERNALLY MODIFIED:
 *
 * DESCRIPTION:
 *      edits chdate object i
 */

static void 
edt_chdate(int i, int new)
{
    if (chdate_dialog == NULL) {
	create_dialog();
    }

    (*(objary[i].opsptr->cpy))(&objtmp, &objary[i]);
    new_point =  objtmp.z.cdtptr->point;
    new_font  =  objtmp.z.cdtptr->font;
    new_color = objtmp.z.cdtptr->color;
    new_drawlyr = objtmp.layer;
    new_disp = objtmp.z.cdtptr->disp;
    if (new) {
        (*(objary[i].opsptr->rem))(i, OBJECT);
        i = -1;
    }
    DialogOptionSet(fontw, (int)new_font);
    DialogOptionSet(pointw, (int)new_point);
    DialogOptionSet(colorw, (int)new_color);
    DialogOptionSet(dispw, (int)new_disp);
    DialogOptionSet(drawlyrw, (int)new_drawlyr);
    EditObject(i, chdate_dialog);
}

/***********************************************************************
 *
 * FUNCTION:
 *      cdt_ok_button()
 *
 * INPUTS:
 *
 * OUTPUTS:
 *
 * RETURNS:
 *
 * EXTERNALLY READ:
 *
 * EXTERNALLY MODIFIED:
 *
 * DESCRIPTION:
 *      checks input after ok button is pressed
 */

static void 
cdt_ok_button(void)
{
    int change = DIALOG_NO_CHANGE;	/* temp boolean to see if changed */

    if (new_font != objtmp.z.cdtptr->font) {
	change |= DIALOG_UPDATE;
    }
    objtmp.z.cdtptr->font = DialogOptionGet(fontw);
    if (new_point != objtmp.z.cdtptr->point) {
	change |= DIALOG_UPDATE;
    }
    objtmp.z.cdtptr->point = DialogOptionGet(pointw);

    if (new_color != objtmp.z.cdtptr->color) {
	change |= DIALOG_UPDATE;
    }
    objtmp.z.cdtptr->color = DialogOptionGet(colorw);

    if (new_disp != objtmp.z.cdtptr->disp) {
	change |= DIALOG_UPDATE;
    }
    objtmp.z.cdtptr->disp = DialogOptionGet(dispw);
    if (new_drawlyr != objtmp.layer) {
	change |= DIALOG_UPDATE;
    }
    objtmp.layer = DialogOptionGet(drawlyrw);
    object_change = change;
    DialogFlagSet(change);
}

/***********************************************************************
 *
 * FUNCTION:
 *      cancel_button()
 *
 * INPUTS:
 *
 * OUTPUTS:
 *
 * RETURNS:
 *
 * EXTERNALLY READ:
 *
 * EXTERNALLY MODIFIED:
 *
 * DESCRIPTION:
 *      discards any edits and closes edit window
 */

static void 
cancel_button(void)
{
    object_change = DIALOG_CANCEL;
    DialogFlagSet(DIALOG_CANCEL);
}

/***********************************************************************
 *
 * FUNCTION:
 *      change_point()
 *
 * INPUTS:
 *      button  (Widget)
 *      option, any_data        (int)
 *
 * OUTPUTS:
 *
 * RETURNS:
 *
 * EXTERNALLY READ:
 *
 * EXTERNALLY MODIFIED:
 *
 * DESCRIPTION:
 *      sets new font point size for chdate object
 */

static void 
change_point(Widget button, XtPointer option, XtPointer any_data)
{
    new_point = (int)option;
}

/***********************************************************************
 *
 * FUNCTION:
 *      change_font()
 *
 * INPUTS:
 *      button  (Widget)
 *      option, any_data        (int)
 *
 * OUTPUTS:
 *
 * RETURNS:
 *
 * EXTERNALLY READ:
 *
 * EXTERNALLY MODIFIED:
 *
 * DESCRIPTION:
 *      sets new font for chdate object
 */

static void 
change_font(Widget button, XtPointer option, XtPointer any_data)
{
    new_font = (int)option;
}

/***********************************************************************
 *
 * FUNCTION:
 *      change_color()
 *
 * INPUTS:
 *      button  (Widget)
 *      option, any_data        (int)
 *
 * OUTPUTS:
 *
 * RETURNS:
 *
 * EXTERNALLY READ:
 *
 * EXTERNALLY MODIFIED:
 *
 * DESCRIPTION:
 *      sets new color for chdate object
 */

static void 
change_color(Widget button, XtPointer option, XtPointer any_data)
{
    new_color = (int)option;
}

/***********************************************************************
 *
 * FUNCTION:
 *      change_drawlyr()
 *
 * INPUTS:
 *      button  (Widget)
 *      option, any_data        (int)
 *
 * OUTPUTS:
 *
 * RETURNS:
 *
 * EXTERNALLY READ:
 *
 * EXTERNALLY MODIFIED:
 *
 * DESCRIPTION:
 *      sets new drawlyr for symbol object
 */

static void 
change_drawlyr(Widget button, XtPointer option, XtPointer any_data)
{
    new_drawlyr = (int)option;
}

/***********************************************************************
 *
 * FUNCTION:
 *      change_disp()
 *
 * INPUTS:
 *      button          (Widget)
 *      option          (int)
 *      anydata         (int)
 *
 * OUTPUTS:
 *
 * RETURNS:
 *
 * EXTERNALLY READ:
 *
 * EXTERNALLY MODIFIED:
 *
 * DESCRIPTION:
 *      changes display date to the input value
 */

static void 
change_disp(Widget button, XtPointer option, XtPointer any_data)
{
    new_disp = (int)option;
}

/***********************************************************************
 *
 * FUNCTION:
 *      verify_fun()
 *
 * INPUTS:
 *      w       (Widget)
 *      x, y    (XtPointer)
 *
 * OUTPUTS:
 *      none
 *
 * RETURNS:
 *      none
 *
 * EXTERNALLY READ:
 *      none
 *
 * EXTERNALLY MODIFIED:
 *      none
 *
 * DESCRIPTION:
 *      validates that the popup dialog can be closed
 */

static void
verify_fun(Widget w, XtPointer x, XtPointer y)
{

    if ((int)x == DIALOG_CANCEL) {
        if (!ShellValidateClose(w)) return;
        cancel_button();
    } else if ((int)x == DIALOG_UPDATE) {
        cdt_ok_button();
    }
}

