📄 xbbox.c
字号:
/* * This material contains proprietary software of Entropic Research * Laboratory, Inc. Any reproduction, distribution, or publication * without the prior written permission of Entropic Research * Laboratory, Inc. is strictly prohibited. Any public distribution * of copies of this work authorized in writing by Entropic Research * Laboratory, Inc. must bear the notice * * "Copyright (c) 1991 Entropic Research Laboratory, Inc. * All rights reserved." * * Program: xbbox.c * * Written by: John Shore * Checked by: * * functions for popping up a button box */#ifndef lintstatic char *sccs_id = "@(#)xbbox.c 1.26 6/5/93 ERL";#endif/* * system include files */#include <stdio.h>#include <xview/xview.h>#include <xview/defaults.h>#include <xview/frame.h>#include <xview/panel.h>#include <xview/cms.h>#include <xview/notice.h>/* * other include files */#include <esps/esps.h> #include <esps/exview.h>#ifndef NULL#define NULL 0#endif#define EXV_WINDOW_TITLE "ESPS Button Panel"#define EXV_ICON_TITLE "buttons"#define LAST_VAL_KEY 13432extern int debug_level;extern int do_color; extern char **Envp;static int check_par();static bbox_par *bbox_defaults();static int new_row();char *savestring();void exec_command();void print_bbox_par();static void exec_data();static void quit_proc();static void but_selected();static void menu_item_sel();static void choice_item_sel();static int menu_but_selected();static Panel_item add_button_menu();static Panel_item add_panel_list();static int add_menu_file_buttons();/* * global variables */static int tot_buttons = 0; /* cumulative button number */static int last_row = 0; /* when this changes, a new row has started*/static bbox_par *bbox_params = NULL; /* global, ugly. */bbox_par *exv_bbox(params, bbox_frame, bbox_panel)bbox_par *params;Frame *bbox_frame;Panel *bbox_panel;{ Panel_item button; int n_but = 0; menudata *but_menu = NULL; int but_menu_ok = 1;#if defined(DS3100) || defined(SG) || defined(hpux)/* This is an ugly hack because I can't figure out how to fix this correctly on the DS3100 XView port. Without this hack, the aux panels in xvwaves come up black and white. */Xv_singlecolor ffg, fbg; /* frame foreground/background colors */int dffg = 0x000000, /* default frame foreground color */ dfbg = 0xf0ffff; /* " " background " */#endif bbox_params = params; /* set global; ugly! */ if (debug_level > 1) Fprintf(stderr, "entered exv_bbox\n"); /* the following call will return if an ESPS or waves license exists (but not necessarily checked out or available). */ check_header2(); #if defined(DS3100) || defined(SG) || defined(hpux) ffg.red = (dffg >> 16) & 0xff; /* unpack some colormap values */ ffg.green = (dffg >> 8 ) & 0xff; ffg.blue = dffg & 0xff; fbg.red = (dfbg >> 16) & 0xff; fbg.green = (dfbg >> 8 ) & 0xff; fbg.blue = dfbg & 0xff;#endif /* make sure panel handle is NULL unless we create one */ *bbox_panel = NULL; /* generate default parameters if asked */ if (bbox_params == NULL) { bbox_params = bbox_defaults(); return(bbox_params); } /* initialization */ tot_buttons = last_row = 0; if (bbox_params->owner == NULL) *bbox_frame = NULL; if (!check_par(bbox_params)) return(NULL); if (bbox_params->menu_file != NULL) { but_menu = read_olwm_menu(bbox_params->menu_file); if (debug_level) { if ((but_menu == NULL) || (but_menu->bfirst == NULL)) Fprintf(stderr, "exv_bbox: no valid menu from olwm menu\n"); else Fprintf(stderr, "exv_bbox: read olwm menu file ok\n"); } } if (debug_level > 2) { print_bbox_par(bbox_params); if (but_menu != NULL) print_olwm_menu(but_menu); } if (bbox_params->owner != NULL) { *bbox_panel = xv_create(bbox_params->owner, PANEL, XV_WIDTH, 1100, PANEL_LAYOUT, PANEL_HORIZONTAL, OPENWIN_SHOW_BORDERS, TRUE, WIN_BORDER, TRUE, XV_KEY_DATA, EXVK_BUT_DATA_PROC, bbox_params->but_data_proc, 0); *bbox_frame = bbox_params->owner; } else { /* no owner, so create frame, complete with icon, and button panel */ *bbox_frame = (Frame)xv_create(NULL, FRAME, XV_SHOW, FALSE, XV_LABEL, bbox_params->title,#if defined(DS3100) || defined(SG) || defined(hpux) FRAME_FOREGROUND_COLOR, &ffg, FRAME_BACKGROUND_COLOR, &fbg, FRAME_INHERIT_COLORS, FALSE,#endif FRAME_INHERIT_COLORS, TRUE, FRAME_SHOW_FOOTER, FALSE, FRAME_SHOW_RESIZE_CORNER, TRUE, 0); *bbox_panel = xv_create(*bbox_frame, PANEL, XV_X, 0, XV_WIDTH, 1100, PANEL_LAYOUT, PANEL_HORIZONTAL, OPENWIN_SHOW_BORDERS, TRUE, WIN_BORDER, TRUE, XV_KEY_DATA, EXVK_BUT_DATA_PROC, bbox_params->but_data_proc, 0); (void) exv_attach_icon(*bbox_frame, ERL_NOBORD_ICON, bbox_params->icon_title, TRANSPARENT); } if (bbox_params->quit_button || getenv("BBOX_QUIT_BUTTON")) { button = xv_create(*bbox_panel, PANEL_BUTTON, PANEL_LABEL_STRING, bbox_params->quit_label, PANEL_CLIENT_DATA, *bbox_frame, PANEL_NOTIFY_PROC, quit_proc, PANEL_NEXT_ROW, -1, 0); } n_but = 0; if ((bbox_params->but_labels != NULL) && (bbox_params->but_data != NULL)) { while ((bbox_params->but_labels[n_but] != NULL) && (bbox_params->but_data[n_but] !=NULL)) { button = xv_create(*bbox_panel, PANEL_BUTTON, PANEL_LABEL_STRING, bbox_params->but_labels[n_but], PANEL_CLIENT_DATA, bbox_params->but_data[n_but], PANEL_NOTIFY_PROC, but_selected, 0); /* start next row if appropriate */ if (new_row(bbox_params)) xv_set(button, PANEL_NEXT_ROW, -1, 0); n_but++; } } /* now fill in buttons derived from olwm menu file */ but_menu_ok = 1; if (but_menu != NULL) { but_menu_ok = add_menu_file_buttons(bbox_panel, bbox_params, but_menu); } if ((n_but == 0) && (!but_menu_ok)) { Fprintf(stderr, "exv_bbox: could not create any buttons.\n"); *bbox_panel = NULL; return(bbox_params); } (void)window_fit(*bbox_panel); (void)window_fit(*bbox_frame);/* separating the XV_X, XV_Y sets from the original xv_create seemsnecessary to have some window managers pay attention to positioning */ if (bbox_params->owner == NULL) { if ((bbox_params->x_pos >= 0) && (bbox_params->y_pos >= 0)) xv_set(*bbox_frame, XV_X, bbox_params->x_pos, XV_Y, bbox_params->y_pos, XV_SHOW, bbox_params->show, 0); else xv_set(*bbox_frame, XV_SHOW, bbox_params->show, 0); } else if ((bbox_params->x_pos >= 0) && (bbox_params->y_pos >= 0)) xv_set(*bbox_frame, XV_X, bbox_params->x_pos, XV_Y, bbox_params->y_pos, 0); return(bbox_params); }static intadd_menu_file_buttons(panel, params, butmenu)Panel *panel;bbox_par *params;menudata *butmenu;{/* This function adds to the panel buttons that are specified in * the olwm menuy butmenu. */ Panel_item button; buttondata *butdata; int n_buttons = 0; butdata = butmenu->bfirst; while (butdata != NULL) { if (butdata->submenu == NULL) { if ((butdata->name != NULL) && (butdata->exec != NULL)) { /* it's a plain button, so we just add it */ button = xv_create(*panel, PANEL_BUTTON, PANEL_LABEL_STRING, butdata->name, PANEL_CLIENT_DATA, butdata->exec, PANEL_NOTIFY_PROC, but_selected, 0); } else { Fprintf(stderr, "exv_bbox: skipped button with (nil) name or exec function\n"); button = NULL; } } else { /* it's a submenu, so we create a menu button or panel choice*/ if (params->button_choice) button = add_panel_list(params, panel, (menudata*) butdata->submenu); else button = add_button_menu(panel, (menudata*) butdata->submenu); } if (button != NULL) { n_buttons++; if (new_row(params)) xv_set(button, PANEL_NEXT_ROW, -1, 0); } butdata = butdata->next; } if (n_buttons > 0) return(1); else return(0);}static Panel_itemadd_button_menu(bpanel, smenu)Panel *bpanel;menudata *smenu;{/* This function adds to the panel (bpanel) a menu button; i.e. * a button which, when pressed, produces a pop-down menu. The * submenu used derives from an olwm menu file. This function is * called from add_menu_file_buttons in the case of a submenu. */ Panel_item menu_button = NULL; buttondata *subdata; menudata *submenu; Menu button_menu; Menu_item mi; int n_item = 0; button_menu = (Menu) xv_create(NULL, MENU, 0); subdata = smenu->bfirst; while(subdata != NULL) { if (subdata->submenu == NULL) { if ((subdata->name != NULL) && (subdata->exec != NULL)) { mi = (Menu_item) xv_create(NULL, MENUITEM, MENU_STRING, subdata->name, MENU_NOTIFY_PROC, menu_item_sel, MENU_CLIENT_DATA, subdata->exec, 0); xv_set(button_menu, MENU_APPEND_ITEM, mi, 0); n_item++; if (subdata->isDefault) xv_set(button_menu, MENU_DEFAULT, n_item, 0); } else { Fprintf(stderr, "exv_bbox: skipped button with (nil) name or exec function\n"); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -