/*-*-C-*-
 * General dialogue box processing for Misc 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 void gui_load_len_field (
    char *val,
    int *len
);
extern void 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_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_filetype (
    WindowPtr dbox,
    int valicon,            /* to contain, eg, "Text     (&fff)" */
    int filetype
);
extern error * gui_get_filetype (
    WindowPtr dbox,
    int valicon,            /* contains, eg, "Unknown  (&123)" */
    int *filetype
);
extern error * gui_put_filetype_string (
    WindowPtr dbox,
    int valicon,            /* to contain, eg, "Text     (&fff)" */
    char *type
);
extern error * gui_get_filetype_string (
    WindowPtr dbox,
    int valicon,            /* contains, eg, "Unknown  (&123)" */
    char *type
);
extern error * gui_put_filetype_from_user (
    WindowPtr dbox,
    int valicon,
    char *type
);

extern int gui_get_colour (WindowPtr dbox, int icon);
extern void gui_put_colour (WindowPtr dbox, int icon, int n);

extern error * gui_get_rgb_colour (
    WindowPtr dbox,
    int icon,
    unsigned *rgb
);
extern error * gui_put_rgb_colour (
    WindowPtr dbox,
    int icon,
    unsigned rgb
);


#endif
