/* dialog structure, one for each item or collection of items in the dialog box */
typedef struct dialog_item
{
short type; /* dialog type from defines above */
void *data; /* dialog data */
/* end of initialized data */
unsigned short dialog_state;/* memory and focus state of dialog */
fg_box_t focus; /* box drawn when focusing in dialog */
struct dialog_item *next; /* next dialog item in the linked list */
} DIALOG_ITEM;
/** DIALOG TEXT STRUCTURE **/
typedef struct
{
char *name; /* character string of text */
short loc_x,loc_y; /* location of text relative to dialog box lower left corner, values are in units of quarter text cells */
unsigned short status; /* text status from defines above */
/* end of initialized data */
} TEXT;
/** DIALOG BUTTON STRUCTURE **/
typedef struct
{
short id; /* associated message id */
char *name; /* name on button */
short accelerator; /* accelerator key or 0 if none */
short loc_x,loc_y; /* location of button relative to dialog box lower left corner, values are in units of quarter text cells */
unsigned short status; /* button status from defines above */
/* end of initialized data */
fg_box_t screen; /* button hotspot in screen coordinates, filled when dialog is opened */
} BUTTON;
/** DIALOG RADIO BUTTON STRUCTURE **/
typedef struct
{
short id; /* id of radio button set */
short number_of_buttons; /* number of buttons in radio collection */
BUTTON *buttons; /* array of buttons in radio collection */
unsigned short status; /* radio button status from defines above */
/* end of initialized data */
DIALOG_ITEM *dialog; /* parent dialog */
} RADIOBUTTON;
/** DIALOG LISTBOX STRUCTURE **/
/* allocation sizes and allocation sequencing */
#define LISTBOX_MEM_PAGE_SIZE 64
#define LISTBOX_FIRST_PAGE 0
#define LISTBOX_SUCCEEDING_PAGES 1
/* listbox displayed characters */
#define LIST_UPARROW 24
#define LIST_DOWNARROW 25
#define LIST_RIGHTARROW 16
typedef struct listbox_page
{
char *listbox_items; /* data for listbox */
short number_of_items; /* number of items in listbox */
struct listbox_page *previous_page; /* previous page in doubly linked list of pages */
struct listbox_page *next_page; /* next page in doubly linked list of pages */
} LISTBOX_PAGE;
typedef struct
{
short id; /* associated message id */
short loc_x,loc_y; /* location of listbox relative to dialog box lower left corner, values are in units of quarter text cells */
short width,height; /* listbox dimensions in quarter text cells, the displayed listbox will be rounded down in full text cells */
short (*first_item)(char *str); /* function which returns first item in listbox or NULL if none */
short (*next_item)(char *str); /* function which returns next item in listbox or NULL if none */
unsigned short status; /* whether or not list box is active, see dialog status defines above */
/* end of initialized data */
fg_box_t screen; /* listbox hotspot in screen coordinates, filled when dialog is opened */
fg_box_t marker; /* hotspots for marker area */
fg_box_t listbox; /* hotspots for list area */
fg_box_t up; /* up arrow hotspots */
fg_box_t down; /* down arrow hotspots */
LISTBOX_PAGE *first_page; /* pointer to start of linked list of pages in listbox */
LISTBOX_PAGE *current_page; /* pointer to current page in list of pages */
short page_offset; /* offset in current page for first item on screen */
short screen_offset; /* offset on screen for current place marker */
} LISTBOX;
/** DIALOG EDITBOX STRUCTURE **/
/* EDITBOX message modifiers */
#define EDITBOX_CHANGE 0 /* a change occurred in the editbox */
#define EDITBOX_ACCEPT 1 /* the RETURN key was pressed in the editbox */
/* special keys used in editbox */
#define EDITBOX_HOME HOME /* move to start of edit */
#define EDITBOX_END END /* move to end of edit */
#define EDITBOX_DELETE_EOL CTRLEND /* delete to end of line */
#define isprint_ibm(c) ((c<256&&isprint(c))||((c)>=128&&(c)<=175)||((c)>=224&&(c)<=239)) /* ibm extended character set for foreign language characters only */
/* other editbox control keys are: LEFTARROW,RIGHTARROW,INS,DELETE and BKSP */
/* editbox displayed characters */
#define EDITBOX_CURSOR_INSERT 22 /* cursor displayed when inserting */
#define EDITBOX_CURSOR_OVERWRITE '_'/* cursor displayed when overwriting */
typedef struct
{
short id; /* associated message id */
short loc_x,loc_y; /* location of editbox relative to dialog box lower left corner, values are in units of quarter text cells */
short screen_width; /* displayed editbox width in quarter text cells, the displayed editbox will be rounded down in full text cells */
short edit_width; /* width of editable string in FULL text cells.
* If this is greater than the screen_width, the text is scrolled.
* Note storage space in edit_string must be edit_width+1
* The screen width should never be greater than the
* edit width */
char *edit_string; /* storage for string in editbox */
unsigned short status; /* whether or not edit box is active, see dialog status defines above */
/* end of initialized data */
fg_box_t screen; /* editbox hotspot in screen coordinates, filled when dialog is opened */
short curtype,curpos,xpos,scroll_offset,insert; /* editbox static data */
} EDITBOX;
/** DIALOG PROTOTYPES **/
short dialog_open(DIALOG_ITEM dialog[],short number_of_items,short loc_x,short loc_y,short width,short height); /* draws a dialog box */