home *** CD-ROM | disk | FTP | other *** search
- /* cat > headers/dialog.h << "EOF" */
- /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
- /* dialog.h: header for dialog.c file */
- /* provides dialog box to force user to input */
- /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
- /* SCCS information: %W% %G% - NCSA */
-
- #define dialog_h 1
-
- #include "all.h"
- #include "newext.h"
-
- /* EOF */
- /* cat > src+obj/dialog/dialog_event.c << "EOF" */
- /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
- /* dialog_event: event handler for dialog panel text */
- /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
- /* SCCS information: %W% %G% - NCSA */
-
- /* #include "dialog.h" */
-
- dialog_event (item, event)
- Panel_item item;
- Event *event;
- {
- Menu which_menu;
- Menu_item menu_item;
-
- /* handle ASCII characters first */
- if (event_is_ascii (event))
- {
- /* printf ("event = %d\n", event_action (event)); */
- /* panel_accept_key (item, event); */
- panel_default_handle_event (item, event);
- return;
- }
- /* get menu from client data */
- if ((which_menu = (Menu) panel_get (text_item, PANEL_CLIENT_DATA)) != NULL)
- if (display_panel_menu (item, event, dialog_panel, which_menu))
- { /* store first item from menu into panel text */
- menu_item = menu_get (which_menu, MENU_NTH_ITEM, 1);
- panel_set_value (text_item, menu_get (menu_item, MENU_STRING));
- return;
- }
- }
- /* EOF */
- /* cat > src+obj/dialog/dialog_proc.c << "EOF" */
- /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
- /* dialog_proc: dialog procedure */
- /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
- /* SCCS information: %W% %G% - NCSA */
-
- /* #include "dialog.h" */
-
- Panel_setting
- dialog_proc (item, event)
- Panel_item item;
- Event *event;
- {
- switch (event_id (event))
- {
- case '\t':
- return PANEL_INSERT;
- case '\r':
- case '\n':
- window_return (1);
- return PANEL_NONE;
- default:
- return PANEL_INSERT;
- }
- }
- /* EOF */
- /* cat > src+obj/dialog/init_dialog.c << "EOF" */
- /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
- /* init_dialog: initialize dialog */
- /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
- /* SCCS information: %W% %G% - NCSA */
-
- /* #include "dialog.h" */
-
- Frame
- init_dialog (name, msg, result, ok_only, d, r, menu)
- char *name;
- /* input: label for panel text */
- char *msg;
- /* input: panel message above panel text */
- char *result;
- /* input: initial value displayed
- return: value in panel text */
- int ok_only;
- /* input: 0 - require typed response, item is used
- 1 - no typed response, msg is used */
- int d;
- /* input: number of characters displayed in the panel text */
- int r;
- /* input: number of characters stored for the panel text */
- Menu menu;
- /* input: for PANEL_TEXT = text_item:
- (not) NULL - a menu to be popped up
- NULL - no menu provided */
- {
- Frame dialog_box;
- int top, left, w, h;
-
- dialog_box = window_create (0, FRAME, FRAME_SHOW_LABEL, FALSE, 0);
- dialog_panel = window_create (dialog_box, PANEL,
- PANEL_FONT, font_panel,
- 0);
- top = left = 0;
- w = 50;
- h = 25;
- if (msg != NULL)
- {
- panel_create_item (dialog_panel, PANEL_MESSAGE,
- PANEL_LABEL_STRING, msg,
- PANEL_LABEL_BOLD, TRUE,
- 0);
- top += h;
- left += w;
- }
- if (!ok_only)
- {
- text_item = panel_create_item (dialog_panel, PANEL_TEXT,
- PANEL_ITEM_X, left,
- PANEL_ITEM_Y, top,
- PANEL_VALUE_DISPLAY_LENGTH, d,
- PANEL_VALUE_STORED_LENGTH, r,
- PANEL_LABEL_STRING, name,
- PANEL_LABEL_BOLD, FALSE,
- PANEL_NOTIFY_STRING, "\r\t\n",
- PANEL_CLIENT_DATA, menu,
- PANEL_EVENT_PROC, dialog_event,
- PANEL_NOTIFY_PROC, dialog_proc,
- 0);
- if (strlen (result) > 0)
- /* initialize with input value */
- panel_set_value (text_item, result);
- top += h;
- left += 2 * w;
- }
- panel_create_item (dialog_panel, PANEL_BUTTON,
- PANEL_ITEM_X, left,
- PANEL_ITEM_Y, top,
- PANEL_LABEL_IMAGE, panel_button_image (dialog_panel, "Ok", 3, font_panel_button),
- PANEL_CLIENT_DATA, 1,
- PANEL_NOTIFY_PROC, ok_cancel,
- 0);
- panel_create_item (dialog_panel, PANEL_BUTTON,
- PANEL_ITEM_X, left + w,
- PANEL_ITEM_Y, top,
- PANEL_LABEL_IMAGE, panel_button_image (dialog_panel, "Cancel", 6, font_panel_button),
- PANEL_CLIENT_DATA, 0,
- PANEL_NOTIFY_PROC, ok_cancel,
- 0);
- window_fit (dialog_panel);
- window_fit (dialog_box);
-
- w = (int) window_get (dialog_box, WIN_WIDTH);
- h = (int) window_get (dialog_box, WIN_HEIGHT);
-
- window_set (dialog_box, WIN_X, 1150 / 2 - w / 2, WIN_Y, 900 / 2 - h / 2, 0);
-
- /* set color map same with imagetool */
- (void) color_dialog_win ();
-
- return dialog_box;
- }
- /* EOF */
- /* cat > src+obj/dialog/mydialog.c << "EOF" */
- /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
- /* mydialog: create my dialog */
- /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
- /* SCCS information: %W% %G% - NCSA */
-
- /* #include "dialog.h" */
-
- mydialog (item, msg, result, ok_only, show_length, real_length, menu)
- char *item;
- /* input: label for panel text */
- char *msg;
- /* input: panel message above panel text */
- char *result;
- /* input: initial value displayed
- return: value in panel text */
- int ok_only;
- /* input: 0 - require typed response, item is used
- 1 - no typed response, msg is used */
- int show_length;
- /* input: number of characters displayed in the panel text */
- int real_length;
- /* input: number of character stored for the panel text */
- Menu menu;
- /* input: for PANEL_TEXT = text_item:
- (not) NULL - menu to be popped up
- NULL - no menu provided */
- {
- Frame dialog;
- int answer;
-
- if (!ok_only)
- {
- if (item == NULL || result == NULL)
- return (-1);
- }
-
- dialog = init_dialog (item, msg, result, ok_only, show_length, real_length, menu);
-
- if ((answer = (int) window_loop (dialog)) && !ok_only)
- {
- strcpy (result, (char *) panel_get_value (text_item));
- if (strlen (result) == 0) /* answer yes but no name */
- answer = -1;
- }
-
- window_set (dialog, FRAME_NO_CONFIRM, TRUE, 0);
- window_destroy (dialog);
- return (answer);
- }
- /* EOF */
- /* cat > src+obj/dialog/ok_cancel.c << "EOF" */
- /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
- /* ok_cancel: ok to cancel */
- /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
- /* SCCS information: %W% %G% - NCSA */
-
- /* #include "dialog.h" */
-
- ok_cancel (item, event)
- Panel_item item;
- Event *event;
- {
- window_return ((int) panel_get (item, PANEL_CLIENT_DATA));
- }
- /* EOF */
-