/*-*-C-*-
 * General dialogue box processing for Windows CSE
 */


#ifndef __defined_gui_h
#define __defined_gui_h


/*
 * This macro fills in an option icon in a dialogue box according to the
 *  presence of any of the bits defined by 'mask' in 'word'.
 */

#define  GUI_PUT_FLAG(dbox, opticon, word, mask)  dbox_setbutton (dbox, opticon, (word) & (mask))

/*
 * This macro sets all of the bits defined by 'mask' in the word 'word'
 *  according to the state of an option icon in a dialogue box.
 */

#define  GUI_GET_FLAG(dbox, opticon, word, mask)  if (dbox_getbutton (dbox, opticon)) word |= mask; else word &= ~(mask)

/*
 * This macro toggles the "faded" status of the given icon
 */

#define  GUI_TOGGLE_FADE(dbox, icon)  dbox_iconflag (dbox, icon, 0, IF_SHADED)


extern int gui_load_len_field (
    char *val,
    int *len
);
extern int gui_save_len_field (
    char *val,
    int len
);
extern error * gui_put_len_opt_str (
    WindowPtr dbox,       /* the dialogue box */
    int opticon,          /* the option icon */
    int valicon,          /* the writable icon to contain the text value */
    int lenicon,          /* the writable icon to contain the length value */
    char *val,            /* the text value - might be NULL */
    int len               /* the length value */
);
extern error * gui_get_len_opt_str (
    WindowPtr dbox,       /* the dialogue box */
    int opticon,          /* the option icon */
    int valicon,          /* the writable icon containing the text value */
    int lenicon,          /* the writable icon containing the length value */
    char **val,           /* to hold the retrieved text value - maybe NULL */
    int *len              /* to hold the retrieved length value */
);
extern error * gui_put_opt_str (
    WindowPtr dbox,       /* the dialogue box */
    int opticon,          /* the option icon */
    int valicon,          /* the writable icon to contain the text value */
    char *val             /* the text value - might be NULL */
);
extern error * gui_get_opt_str (
    WindowPtr dbox,       /* the dialogue box */
    int opticon,          /* the option icon */
    int valicon,          /* the writable icon containing the text value */
    char **val            /* to hold the retrieved text value - maybe NULL */
);
extern error * gui_put_len_str (
    WindowPtr dbox,       /* the dialogue box */
    int valicon,          /* the writable icon to contain the text value */
    int lenicon,          /* the writable icon to contain the length value */
    char *val,            /* the text value - might be NULL */
    int len               /* the length value */
);
extern error * gui_get_len_str (
    WindowPtr dbox,       /* the dialogue box */
    int valicon,          /* the writable icon containing the text value */
    int lenicon,          /* the writable icon containing the length value */
    char **val,           /* to hold the retrieved text value - maybe NULL */
    int *len              /* to hold the retrieved length value */
);
extern error * gui_put_str (
    WindowPtr dbox,       /* the dialogue box */
    int valicon,          /* the writable icon to contain the text value */
    char *val             /* the text value - might be NULL */
);
extern error * gui_get_str (
    WindowPtr dbox,       /* the dialogue box */
    int valicon,          /* the writable icon containing the text value */
    char **val            /* to hold the retrieved text value - maybe NULL */
);
extern error * gui_adjust_len (
    WindowPtr dbox,         /* the dialogue box */
    int lenicon,            /* the writable icon containing the length */
    int valicon,            /* ... and the corresponding string */
    int delta,              /* change required */
    unsigned int modifiers  /* if SHIFT bit set, multiply by 10 */
);
extern error * gui_adjust_coord (
    WindowPtr dbox,         /* the dialogue box */
    int icon,               /* the writable icon containing the coordinate */
    int delta,              /* change required (usually +/-1) */
    unsigned int modifiers  /* if SHIFT bit set, multiply by 10 */
);
extern error * gui_put_opt_event (
    WindowPtr dbox,         /* the dialogue box */
    int dflticon,           /* the "raise default event" radio button */
    int othericon,          /* the "raise user-defined event" radio button */
    int noneicon,           /* the "do not raise any event" radio button */
    int valicon,            /* the writable icon containing the event */
    int val,                /* the event - 0 => default */
    Bool none               /* TRUE iff no event is to be raised */
);
extern error * gui_get_opt_event (
    WindowPtr dbox,
    int dflticon,
    int noneicon,
    int valicon,
    int *val,
    unsigned *flags,        /* flags word to be updated */
    unsigned mask           /* identifies "no event" bit in flags */
);
extern error * gui_put_mand_event (
    WindowPtr dbox,         /* the dialogue box */
    int dflticon,           /* the "raise default event" radio button */
    int othericon,          /* the "raise user-defined event" radio button */
    int valicon,            /* the writable icon containing the event */
    int val                 /* the event - 0 => default */
);
extern error * gui_get_mand_event (
    WindowPtr dbox,
    int dflticon,
    int valicon,
    int *val
);
extern error * gui_put_allowable (
    WindowPtr dbox,         /* the dialogue box */
    int opticon,            /* the 'specify allowed chars' option icon */
    int lcicon,             /* the 'a-z' option icon */
    int ucicon,             /* the 'A-Z' option icon */
    int numicon,            /* the '0-9' option icon */
    int otheropticon,       /* the 'Other' option icon */
    int othervalicon,       /* the 'Other' validation string writable icon */
    int lenicon,            /* the 'length' writable icon */
    int upicon,             /* up adjuster associated with length */
    int downicon,           /* down adjuster associated with length */
    char *valid,            /* the validation string - may be NULL */
    int len                 /* and its maximum length */
);
extern error * gui_get_allowable (
    WindowPtr dbox,         /* the dialogue box */
    int opticon,            /* the 'specify allowed chars' option icon */
    int lcicon,             /* the 'a-z' option icon */
    int ucicon,             /* the 'A-Z' option icon */
    int numicon,            /* the '0-9' option icon */
    int otheropticon,       /* the 'Other' option icon */
    int othervalicon,       /* the 'Other' validation string writable icon */
    int lenicon,            /* the 'length' writable icon */
    int upicon,             /* up adjuster associated with length */
    int downicon,           /* down adjuster associated with length */
    char **valid,           /* the location for the validation string */
    int *len                /* and for its maximum length */
);
extern error * gui_put_link (
    WindowPtr dbox,         /* the dialogue box */
    int opticon,            /* the option icon (link present or not) */
    int valicon,            /* the writable icon for the component id */
    int id                  /* and the value to put there (-1 => none) */
);
extern error * gui_get_link (
    WindowPtr dbox,         /* the dialogue box */
    int opticon,            /* the option icon (link present or not) */
    int valicon,            /* the writable icon for the component id */
    int *id                 /* and where to put the value (-1 for none) */
);

extern int gui_get_colour (WindowPtr dbox, int icon);
extern void gui_put_colour (
    WindowPtr dbox,
    int icon,
    int n,
    Bool realcolours
);
extern int gui_get_event (WindowPtr dbox, int opticon, int valicon);
extern void gui_put_event (WindowPtr dbox, int opticon, int valicon, int n);

#endif
