/***********************************************************************
 *
 * TITLE:
 *	status.c
 *
 * AUTHOR:
 *      Cassie Mulnix
 *
 * DESCRIPTION:
 *	This module is part of the OPPS editor, xopps.  It contains object
 *	routines to handle the status date line.
 *
 *                              CHANGE HISTORY
 *
 * $Log: status.c,v $
 * Revision 1.23  1994/08/10  22:05:48  cassie
 * removed call to DialogFlagSet in verify_fun since
 * it is already set in ok_button
 *
 * 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:57:27  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:48:45  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  22:39:41  clm
 * added meaningful error messages for check_num and check_day
 *
 * Revision 1.14  1993/05/18  20:58:30  clm
 * added new message.c function
 *
 * Revision 1.13  1993/03/25  18:34:43  clm
 * added error checking for XVAL_EARLY and XVAL_LATE of status date
 *
 * Revision 1.12  1992/12/22  16:00:38  clm
 * fixed lim and load so objects cannot be loaded or moved outside chart lines
 *
 * Revision 1.11  1992/12/10  21:45:40  clm
 * fixed new_index so chart is always object 0
 *
 * Revision 1.10  1992/10/02  20:44:16  clm
 * housekeeping
 *
 * Revision 1.9  1992/09/16  14:56:08  clm
 * fixed load function so doesn't add object if error in load
 *
 * Revision 1.8  1992/09/14  14:16:02  clm
 * fixed error checking of font in load_status
 *
 * Revision 1.7  1992/09/01  17:30:33  clm
 * added color menu
 *
 * Revision 1.6  1992/08/26  19:53:35  clm
 * changed status date text color
 *
 * Revision 1.5  1992/08/20  15:04:42  clm
 * fixed font and point problem
 *
 * Revision 1.4  1992/08/13  18:09:21  clm
 * fixed error checking for load module
 *
 * Revision 1.2  1992/08/10  17:57:59  clm
 * fixed aesthetics of popup
 *
 * Revision 1.1  1992/08/04  17:02:11  clm
 * Initial revision
 *
 ***********************************************************************
 *
 * WARNINGS:
 *
 * EXTERNAL CALLABLE COMPONENTS (PUBLIC):
 *
 * GLOBALS:
 *
 * WAIVERS:
 *
 * NOTES:
 *
 * MANPAGE:
 *
 ***********************************************************************/

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

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

/*
    local functions:
        dsp_status(i) - display status object
        edt_status(i) - change contents of status field
        rem_status(i) - remove status object
        mov_status(i) - move status object
        msg_status(i) - display message on screen

        stt_done_handle() - handler for status edit panel
*/

#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
};

static void create_dialog(void);
static void dsp_status(int);
static void edt_status(int, int);
static void rem_status(int, int );
static void lim_status(int, int *, int *, int *, int *, int );
static void loc_status(int, int );
static void mov_status(int, int, int, int );
static void cpy_status(struct obj *, struct obj *);
static void msg_status(int, int );
static void sav_status(int, FILE *, int );
static int load_status(char *);
static void status_ok_button(void);
static void cancel_button(void);
static void change_font(Widget, XtPointer, XtPointer);
static void change_point(Widget, XtPointer, XtPointer);
static void change_drawlyr(Widget, XtPointer, XtPointer);
static void change_date(Widget, XtPointer, XtPointer);
static void change_disp(Widget, XtPointer, XtPointer);
static void change_event(Widget, XtPointer, XtPointer);
static void change_color(Widget, XtPointer, XtPointer);
static void verify_fun(Widget, XtPointer, XtPointer);

static struct ops stt_ops = {
    dsp_status, edt_status, rem_status, lim_status, loc_status, mov_status, 
    cpy_status, msg_status, sav_status
};

static DialogDate *sdate;
static DialogOption *fontw, *pointw;
static DialogOption *drawlyr, *disp;
static DialogOption *event, *date, *color;

static Widget status_dialog;                     /* dialog shell for popup */
static Widget parent_shell;
static int new_point;                           /* new point id */
static int new_font;                            /* new font id */
static int new_layer;				/* new layer id */
static int new_date;				/* new toggle id */
static int new_disp;				/* new toggle id */
static int new_color;				/* new toggle id */
static int new_event;				/* new toggle id */

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

void 
init_status_object(Widget parent)
{

    register_io_obj('W', load_status);		/* 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 status date object
 */

static void 
create_dialog(void)
{

    static char *point[] = {
	"8", "10", "12", "14", "18", "24"
    };

    static char *font_list[] = {
        "Courier", "Courier Bold", "Helvetica", "Helvetica Bold",
        "Times", "Times Bold"
    };

    static char *date_list[] = {
	"No", "Yes"
    };

    static char *disp_list[] = {
	"No", "Yes"
    };

    static char *event_list[] = {
	"No", "Yes"
    };

    static char *layer[] = {
	"0", "1", "2", "3"
    };

    status_dialog = DialogInit(parent_shell, "Status Dialog", "status", 
	verify_fun, (XtPointer)DIALOG_CANCEL);

    sdate = DialogDateCreate("Status Date ");

    DialogAddRow(2);
    drawlyr = DialogOptionCreate("Draw Layer ", 4, 0, change_drawlyr,
        DIALOG_OPT_STR_ARY, layer, NULL);
    color = DialogOptionCreate("Color ", ncolor, 0, change_color,
        DIALOG_OPT_STR_ARY, color_name, color_index);

    DialogAddRow(2);
    fontw = DialogOptionCreate("Font ", 6, 4, change_font, DIALOG_OPT_STR_ARY,
        font_list, font_values);
    pointw = DialogOptionCreate("Point ", 6, 10, change_point,
        DIALOG_OPT_STR_ARY, point, font_sizes);

    disp = DialogOptionCreate("Display Status Date", 2, 0, change_disp,
        DIALOG_OPT_STR_ARY, disp_list, NULL);

    date = DialogOptionCreate("Auto Reset of % Dates", 2, 0, change_date,
        DIALOG_OPT_STR_ARY, date_list, NULL);

    event = DialogOptionCreate("Auto Reset of Event Symbols", 2, 0, 
	change_event, DIALOG_OPT_STR_ARY, event_list, NULL);

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

}

/***********************************************************************
 *
 * FUNCTION:
 *      add_status()
 *
 * INPUTS:
 *      x, y, font, point, layer, color	(int)
 *
 * OUTPUTS:
 *
 * RETURNS:
 *
 * EXTERNALLY READ:
 *
 * EXTERNALLY MODIFIED:
 *
 * DESCRIPTION:
 *      adds an status date object
 */

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

    if ((i = find_object_type(OBJ_STT)) == -1) {
	/* only one status date allowed */
	i = new_index(FALSE);
    	objary[i].z.sttptr = (struct stt *)XtMalloc(sizeof(struct stt));
    }
    objary[i].layer = 1;
    objary[i].z.sttptr->font = font;
    objary[i].z.sttptr->point = point;
    objary[i].z.sttptr->x = x;
    objary[i].z.sttptr->y = y;
    objary[i].z.sttptr->color = color;
    objary[i].type = OBJ_STT;
    objary[i].opsptr = &stt_ops;
    return i;
}

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

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

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

    to->z.sttptr = (struct stt *)XtMalloc(sizeof(struct stt));
    to->z.sttptr->x = from->z.sttptr->x;
    to->z.sttptr->y = from->z.sttptr->y;
    to->z.sttptr->font = from->z.sttptr->font;
    to->z.sttptr->point = from->z.sttptr->point;
    to->z.sttptr->color = from->z.sttptr->color;
    to->type = OBJ_STT;
    to->layer = from->layer;
    to->opsptr = &stt_ops;
    to->rlist = copyRectList(from->rlist);
}

/***********************************************************************
 *
 * FUNCTION:
 *      rem_status()
 *
 * INPUTS:
 *      i       (int)
 *
 * OUTPUTS:
 *
 * RETURNS:
 *
 * EXTERNALLY READ:
 *
 * EXTERNALLY MODIFIED:
 *
 * DESCRIPTION:
 *      This module removes status i from the data base
 */

static void 
rem_status(int i, int dir)
{
    /* you don't actually remove the status date
     * you just don't display it
     * to undo the deletion you just turn the display
     * toggle back to yes
     */
    st_flag = TOG_OFF;
}

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

static void 
lim_status(int i, int *x1, int *y1, int *x2, int *y2, int dir)
{
    /*
     * status line cannot move , only text string can move
     */

    XRectangle *(*r)[];			/* rectangle */

    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:
 *      status_ok_button()
 *
 * INPUTS:
 *
 * OUTPUTS:
 *
 * RETURNS:
 *
 * EXTERNALLY READ:
 *
 * EXTERNALLY MODIFIED:
 *
 * DESCRIPTION:
 *      checks the values when the ok button is selected
 */

static void 
status_ok_button(void)
{
    int change = DIALOG_NO_CHANGE;		/* change occured */
    utc_val temp_date;

    temp_date = DialogDateGet(sdate);
    if (temp_date != UTC_INVALID) {
        if (temp_date != st_date) {
	    change |= DIALOG_UPDATE;
	}
    } else {
	Warning("Improper Status Date");
	change |= DIALOG_ERROR;
    }
    st_date = temp_date;

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

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

    if (new_date != auto_areset) {
	change |= DIALOG_UPDATE;
    }
    auto_areset = DialogOptionGet(date);

    if (new_disp != st_flag) {
	change |= DIALOG_UPDATE;
    }
    st_flag = DialogOptionGet(disp);

    if (new_event != auto_ereset) {
	change |= DIALOG_UPDATE;
    }
    auto_ereset = DialogOptionGet(event);

    if (new_layer != objtmp.layer) {
        change |= DIALOG_UPDATE;
    }
    objtmp.layer = DialogOptionGet(drawlyr);

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

    object_change = change;
    DialogFlagSet(change);
}

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

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

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

static int 
load_status(char *buf)
{
    int x, y;				/* x and y coordinates */
    int font, point;         		/* pieces of object */
    int layer;                          /* layer of object */
    int color;				/* color of object */
    int i;

    if (record_scan(buf+1, "dddddd", &x, &y, &font, &point, &layer, &color)
	 == 6) {
	if ((x < xlnary[0].z.lnptr->cord) || 
	    (x > xlnary[nxln-1].z.lnptr->cord)) {
	    Warning("Illegal Status x %d", x);
	} else if ((y < ylnary[0].z.lnptr->cord) || 
	    (y > ylnary[nyln-1].z.lnptr->cord)) {
	    Warning("Illegal Status 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 Status font %d", font);
	} else if ((point != 8) && (point != 10) && (point != 12) &&
	    (point != 14) && (point != 18) && (point != 24)) {
	    Warning("Illegal Status point %d", point);
	} else if ((layer < 0) || (layer > 3)) {
	    Warning("Illegal Status layer %d", layer);
	} else if ((color < 0) || (color > ncolor)) {
	    Warning("illegal Status color %d", color);
  	} else {
            i = add_status(x, y, font, point, layer, color);
            (*(objary[i].opsptr->loc))(i, OBJECT);
            return 0;
	}
        return -1;
    } else {
        return -1;
    }
}

/***********************************************************************
 *
 * FUNCTION:
 *      sav_status()
 *
 * INPUTS:
 *      i               (int)
 *      fp              (FILE *)
 *
 * OUTPUTS:
 *
 * RETURNS:
 *
 * EXTERNALLY READ:
 *
 * EXTERNALLY MODIFIED:
 *
 * DESCRIPTION:
 *      This module saves status i to file fp.
 */

static void 
sav_status(int i, FILE *fp, int dir)
{
    struct stt *sttptr;                         /* status object pointer */
    char buf[128];                              /* temp text buffer */
    
    sttptr = objary[i].z.sttptr;
    buf[0] = 'W';
    buf[1] = ' ';
    record_print(buf+2, "dddddd", sttptr->x, sttptr->y, sttptr->font, 
	sttptr->point, objary[i].layer, sttptr->color);
    fputs(buf, fp);
}

/***********************************************************************
 *
 * FUNCTION:
 *      msg_status()
 *
 * INPUTS:
 *      i       (int)
 *
 * OUTPUTS:
 *
 * RETURNS:
 *
 * EXTERNALLY READ:
 *
 * EXTERNALLY MODIFIED:
 *
 * DESCRIPTION:
 *      displays the status message for status i
 */

static void 
msg_status(int i, int dir)
{
    char buf[64];                               /* temp text buffer */
    int mo, da, yr;				/* month, day, and year */

    get_mdy(&mo, &da, &yr, st_date);
    (void)sprintf(buf, "Status Date: %d/%d/%d", mo, da, yr);
    Message(buf);
}

/***********************************************************************
 *
 * FUNCTION:
 *      dsp_status()
 *
 * INPUTS:
 *      i       (int)
 *
 * OUTPUTS:
 *
 * RETURNS:
 *
 * EXTERNALLY READ:
 *
 * EXTERNALLY MODIFIED:
 *
 * DESCRIPTION:
 *      draws the status date
 */

static void 
dsp_status(int i)
{
    XRectangle *(*r)[];				/* rectangle */
    struct stt *sttptr;                         /* local pointer */
    enum tog mask;				/* toggle mask for white back */
    char buf[26];				/* temp text buffer */
    int month, day, year;			/* month, day, and year */
    int x;					/* temp x coordinate */

    sttptr = objary[i].z.sttptr;
    r = getMoveRect(objary[i].rlist);
    gr_set_color(color_name[sttptr->color], color_gscale[sttptr->color]);
    if (st_flag == TOG_ON) {
	if (objary[i].layer == 0) {
	    mask = TOG_OFF;
	} else {
	    mask = TOG_ON;
	}
	get_mdy(&month, &day, &year, st_date);
	(void)sprintf(buf, "STATUS AS OF: %d/%d/%d", month, day, year);
	gr_text((*r)[0]->x, (*r)[0]->y + (*r)[0]->height, buf, GR_LEFT, 
	    sttptr->font|sttptr->point, (int)mask);
        gr_set_color(color_name[objary[0].z.chtptr->color],
	    color_gscale[objary[0].z.chtptr->color]);
	x = utc_to_x(st_date);
	if ((x != XVAL_EARLY) && (x != XVAL_LATE)) {
	    gr_set_line(GR_SHORT_DASH);
	    gr_masked_line(x, y_act_bottom, x, y_lines_end);
	    gr_set_line(GR_SOLID_LINE);
	}
    }
}

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

static void 
loc_status(int i, int dir)
{
    struct stt *sttptr;         /* local pointer */
    XRectangle r,r2;            /* rectangle */
    char buf[26];               /* temp text buffer */
    int month, day, year;	/* date of status line */

    sttptr = objary[i].z.sttptr;
    get_mdy(&month, &day, &year, st_date);
    (void)sprintf(buf, "STATUS AS OF: %d/%d/%d", month, day, year);
    r.width = gr_strwidth(buf, sttptr->font|sttptr->point);
    r.height = gr_txheight(sttptr->font|sttptr->point) - 1;
    r.x = sttptr->x - (GR_LEFT % 3) * r.width / 2;
    r.y = sttptr->y;

    r2.x = x_left_margin;
    r2.y = y_top_margin;
    r2.width = x_right_margin - x_left_margin;
    r2.height = y_bottom_margin - y_top_margin;
    setRectList(objary[i].rlist, 2, &r, RL_PRIMARY, &r2, RL_EXPOSE);
}

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

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

/***********************************************************************
 *
 * FUNCTION:
 *      change_point()
 *
 * INPUTS:
 *      button  (Widget)
 *      option, any_data        (XtPointer)
 *
 * OUTPUTS:
 *
 * RETURNS:
 *
 * EXTERNALLY READ:
 *
 * EXTERNALLY MODIFIED:
 *
 * DESCRIPTION:
 *      sets new font point size for status 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        (XtPointer)
 *
 * OUTPUTS:
 *
 * RETURNS:
 *
 * EXTERNALLY READ:
 *
 * EXTERNALLY MODIFIED:
 *
 * DESCRIPTION:
 *      sets new font for status object
 */

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

/***********************************************************************
 *
 * FUNCTION:
 *      change_drawlyr()
 *
 * INPUTS:
 *      button          - (Widget)
 *      option          - (XtPointer)
 *      any_data        - (XtPointer)
 *
 * OUTPUTS:
 *
 * RETURNS:
 *
 * EXTERNALLY READ:
 *
 * EXTERNALLY MODIFIED:
 *
 * DESCRIPTION:
 *      This module sets the selected draw layer.
 */

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

/***********************************************************************
 *
 * FUNCTION:
 *      change_date()
 *
 * INPUTS:
 *      button          - (Widget)
 *      option          - (XtPointer)
 *      any_data        - (XtPointer)
 *
 * OUTPUTS:
 *
 * RETURNS:
 *
 * EXTERNALLY READ:
 *
 * EXTERNALLY MODIFIED:
 *
 * DESCRIPTION:
 *      This module sets the selected change % dates toggle
 */

static void 
change_date(Widget button, XtPointer option, XtPointer any_data)
{
    new_date = (int)option;
}

/***********************************************************************
 *
 * FUNCTION:
 *      change_disp()
 *
 * INPUTS:
 *      button          - (Widget)
 *      option          - (XtPointer)
 *      any_data        - (XtPointer)
 *
 * OUTPUTS:
 *
 * RETURNS:
 *
 * EXTERNALLY READ:
 *
 * EXTERNALLY MODIFIED:
 *
 * DESCRIPTION:
 *      This module sets the selected display status date toggle
 */

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

/***********************************************************************
 *
 * FUNCTION:
 *      change_event()
 *
 * INPUTS:
 *      button          - (Widget)
 *      option          - (XtPointer)
 *      any_data        - (XtPointer)
 *
 * OUTPUTS:
 *
 * RETURNS:
 *
 * EXTERNALLY READ:
 *
 * EXTERNALLY MODIFIED:
 *
 * DESCRIPTION:
 *      This module sets the selected change event toggle
 */

static void 
change_event(Widget button, XtPointer option, XtPointer any_data)
{
    new_event = (int)option;
}

/***********************************************************************
 *
 * FUNCTION:
 *      change_color()
 *
 * INPUTS:
 *      button          - (Widget)
 *      option          - (XtPointer)
 *      any_data        - (XtPointer)
 *
 * OUTPUTS:
 *
 * RETURNS:
 *
 * EXTERNALLY READ:
 *
 * EXTERNALLY MODIFIED:
 *
 * DESCRIPTION:
 *      This module sets the selected change color
 */

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

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

static void 
edt_status(int i, int new)
{

    if (status_dialog == NULL) {
	create_dialog();
    }

    (*(objary[i].opsptr->cpy))(&objtmp, &objary[i]);
    new_point = objtmp.z.sttptr->point;
    new_font  = objtmp.z.sttptr->font;
    new_color  = objtmp.z.sttptr->color;
    new_event = auto_ereset;
    new_disp = st_flag;
    new_date = auto_areset;

    DialogDateSet(sdate, st_date);
    DialogOptionSet(fontw, (int)new_font);
    DialogOptionSet(pointw, (int)new_point);
    DialogOptionSet(date, (int)auto_areset);
    DialogOptionSet(event, (int)auto_ereset);
    DialogOptionSet(disp, (int)new_disp);
    DialogOptionSet(color, (int)new_color);
    EditObject(i, status_dialog);
}

/***********************************************************************
 *
 * 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) {
        status_ok_button();
    }
}

