⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 menu.c

📁 操作系统SunOS 4.1.3版本的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
#ifndef lintstatic  char sccsid[] = "@(#)menu.c 1.1 92/07/30 Copyr 1990 Sun Micro";#endif/* * Copyright (c) 1990 by Sun Microsystems, Inc. *//**********************************************************************//* Include files *//**********************************************************************/#include <stdio.h>#include <sys/file.h>#include <sys/ioctl.h>#include <sys/wait.h>#include <sys/time.h>#include <strings.h>#include <suntool/sunview.h>#include <suntool/panel.h>#include <suntool/textsw.h>#include <suntool/alert.h>#include <pixrect/pixrect_hs.h>#include <esd.h>#include <esd_icon.h>/**********************************************************************//* External variables *//**********************************************************************/externchar		*sprintf();externvoid		pmessage();externstruct test	sb_testlist[];externchar		*timestamp();/**********************************************************************//* Static variables *//**********************************************************************/staticstruct itimerval	timer;staticPixfont		*bigfont,		*bold_bigfont;staticFrame		main_frame;staticTextsw		msg_window;staticPanel		sel_panel,		disp_panel;staticPanel_item	int_button,		sb_button,		loops_blck_item,		loops_brd_item,		title_text_item,		stop_button,		test_title_item,		timer_item;staticint		pid,		*pipe_fd,		sb_test_select,		secs,		swap = 0;/**********************************************************************/exec_menu(fildes)/**********************************************************************/int *fildes;{    extern Notify_value pipe_report();    /* initialisation of variables */    bigfont = pf_open("/usr/lib/fonts/fixedwidthfonts/cour.r.24");    bold_bigfont = pf_open("/usr/lib/fonts/fixedwidthfonts/cour.b.24");    pipe_fd = fildes;    sb_test_select = get_test_selection(sb_testlist, LIST_DEFAULT);    pid = 0;    /* set timer */    timer.it_value.tv_usec = 0;    timer.it_value.tv_sec  = 1;    /* interval to reload timer */    timer.it_interval.tv_usec = 0;    timer.it_interval.tv_sec  = 1;    main_frame = window_create((Window)NULL, FRAME,				FRAME_LABEL, "CG12 SYSTEM DIAGNOSTICS",				FRAME_SUBWINDOWS_ADJUSTABLE, FALSE,				0);    build_menu(main_frame);    (void)notify_set_input_func(main_frame, pipe_report, fildes[0]);    window_main_loop(main_frame);}/**********************************************************************/build_menu(base_frame)/**********************************************************************/Frame base_frame;{    extern Notify_value my_frame_destroyer();    extern int stop_proc(),	       int_exec_proc(),	       sb_exec_proc();    extern Panel_item create_button();    extern Panel_item create_cycle_item();    int x;    int y;    int h;    int w;    int y1;    int fd_tmp;    int screen_width;    int screen_height;    Rect *r;    r = (Rect *)window_get(base_frame, WIN_SCREEN_RECT);    screen_width = r->r_width;    screen_height = r->r_height;    (void)window_set(base_frame, WIN_X, 0,				WIN_Y, 0,				WIN_WIDTH, screen_width,				WIN_HEIGHT, screen_height/2,				0);    sel_panel = window_create(base_frame, PANEL,				WIN_X, 0,				WIN_Y, 0,				PANEL_ITEM_X_GAP, 15,				0);    int_button = create_button(sel_panel, &int_button_image,				INTEGRATION_TEST, int_exec_proc,				"Run Integration Test", (char *)NULL, (char *)NULL);    sb_button = create_button(sel_panel, &sb_button_image,				SINGLE_BLOCK_TEST, sb_exec_proc,				"Default", "All", "Select");    title_text_item = panel_create_item(sel_panel, PANEL_MESSAGE,				PANEL_ITEM_X, 0,				PANEL_ITEM_Y, 0,				PANEL_LABEL_FONT, bold_bigfont,				PANEL_LABEL_STRING, "CG12 SYSTEM DIAGNOSTICS",				0);    loops_blck_item = create_cycle_item(sel_panel, "#loops/block : ");    loops_brd_item = create_cycle_item(sel_panel, "#loops/board : ");        window_fit_height(sel_panel);    /* relocate items */    r = (Rect *)panel_get(title_text_item, PANEL_ITEM_RECT);    w = r->r_width;    h = r->r_height;    r = (Rect *)window_get(sel_panel, WIN_RECT);    (void)panel_set(title_text_item, PANEL_ITEM_X, (screen_width-w)/2,				PANEL_ITEM_Y, (r->r_height-h)/2,				0);        h = r->r_height;    r = (Rect *)panel_get(loops_blck_item, PANEL_ITEM_RECT);    x = screen_width - (r->r_width+(int)panel_get(sel_panel, PANEL_ITEM_X_GAP)*2);    y = (h-((r->r_height*2)+(int)panel_get(sel_panel, PANEL_ITEM_Y_GAP)))/2;    (void)panel_set(loops_blck_item, PANEL_ITEM_X, x,				PANEL_ITEM_Y, y,				PANEL_VALUE, 0,				0);    y1 = y;    y = y+r->r_height+(int)panel_get(loops_blck_item, PANEL_ITEM_Y_GAP);    (void)panel_set(loops_brd_item, PANEL_ITEM_X, x,				PANEL_ITEM_Y, y,				PANEL_VALUE, 0,				0);    /* create new panel */    r = (Rect *)window_get(sel_panel, WIN_RECT);    disp_panel = window_create(base_frame, PANEL,				WIN_X, r->r_left,				WIN_Y, r->r_top,				WIN_WIDTH, r->r_width,				WIN_HEIGHT, r->r_height,				PANEL_ITEM_X_GAP, 15,				WIN_SHOW, FALSE,				0);    stop_button = create_button(disp_panel, &stop_button_image,				NULL, stop_proc, (char *)NULL, (char *)NULL, (char *)NULL);    test_title_item = panel_create_item(disp_panel, PANEL_MESSAGE,				PANEL_ITEM_X, x,				PANEL_ITEM_Y, y1,				PANEL_LABEL_FONT, bold_bigfont,				0);    timer_item = panel_create_item(disp_panel, PANEL_MESSAGE,				PANEL_LABEL_STRING, "000:00:00",				PANEL_LABEL_FONT, bold_bigfont,				0);    /* reposition items */    r = (Rect *)panel_get(timer_item, PANEL_ITEM_RECT);    x = (screen_width-r->r_width)/2;    (void)panel_set(timer_item, PANEL_ITEM_X, x,				PANEL_ITEM_Y, y,				0);    /* message window */    (void)unlink(TEXTSW_TMP_FILE);    fd_tmp = open(TEXTSW_TMP_FILE, O_RDWR | O_CREAT, 0666);    if (fd_tmp)        (void)close(fd_tmp);    msg_window = (Textsw) window_create(base_frame, TEXTSW,				WIN_BELOW, sel_panel,				TEXTSW_MENU, (Menu)NULL,				TEXTSW_BROWSING, TRUE,				TEXTSW_IGNORE_LIMIT, TEXTSW_INFINITY,				TEXTSW_FILE, TEXTSW_TMP_FILE,				0);        (void)notify_interpose_destroy_func(base_frame, my_frame_destroyer);}/**********************************************************************/static Notify_valuemy_frame_destroyer(frame, status)/**********************************************************************/Frame frame;Destroy_status status;{    int result;    if (status == DESTROY_CHECKING) {	result = alert_prompt(main_frame, (Event *) NULL,				ALERT_MESSAGE_STRINGS, "Do you want to quit CG12 Diagnostics tool ?", 0,				ALERT_BUTTON_YES, "Confirm Quit",				ALERT_BUTTON_NO, "Cancel",				ALERT_MESSAGE_FONT, bold_bigfont,				ALERT_BUTTON_FONT, bold_bigfont,				0);	if (result == ALERT_YES) {	    (void)unlink(TEXTSW_TMP_FILE);	    (void)window_set(main_frame, FRAME_NO_CONFIRM, TRUE, 0);	} else {	    (void)notify_veto_destroy(main_frame);	    return(NOTIFY_DONE);	}    }    return(notify_next_destroy_func(frame, status));}/*ARGSUSED*//**********************************************************************/Notify_valuepipe_report(me, fd)/**********************************************************************/int *me;int fd;{    int cc, bcount;    char textbuf[512];    /* read message from pipe */    while ((ioctl(fd, FIONREAD, &cc) != -1) && cc > 0) {            bcount = read(fd, textbuf, (cc <= 511) ? cc : 511);	    textbuf[bcount] = '\0';            pmessage(textbuf);    }    return(NOTIFY_DONE);}/*ARGSUSED*//**********************************************************************/static Panel_itemcreate_button(panel, image, client_data, proc, m1, m2, m3)/**********************************************************************/Panel panel;int client_data;Pixrect *image;int (*proc)();char *m1, *m2, *m3;{    extern int show_menu_proc();    Panel_item item;    Menu menu;    Menu_item mi;    register char **p;    register int i;    static int mv[] = {0, LIST_DEFAULT, LIST_ALL, LIST_SELECT};    item = panel_create_item(panel, PANEL_BUTTON,				PANEL_LABEL_IMAGE, image,				PANEL_NOTIFY_PROC, proc,				0);    if (m1 != NULL) {	menu = menu_create(MENU_CLIENT_DATA, client_data,				MENU_LEFT_MARGIN, 10,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -