📄 create_panels.c
字号:
#ifndef lint#ifdef sccsstatic char sccsid[] = "@(#)create_panels.c 1.1 92/07/30 Copyr 1987 Sun Micro";#endif#endif/* * Copyright (c) 1987 by Sun Microsystems, Inc. *//* * Mailtool - creation of control panels */#define NULLSTRING (char *) 0#include <stdio.h>#include <errno.h>#include <signal.h>#include <ctype.h>#include <sunwindow/window_hs.h>#include <sys/stat.h>#include <sys/wait.h>#include <sys/types.h>#include <varargs.h>#include <suntool/window.h>#include <suntool/frame.h>#include <suntool/panel.h>#include <suntool/text.h>#include <suntool/scrollbar.h>#include <suntool/selection.h>#include <suntool/selection_svc.h>#include <suntool/selection_attributes.h>#include <suntool/walkmenu.h>#include <suntool/icon.h>#include "glob.h"#include "tool.h"int mt_cmdpanel_fd; /* the command panel subwindow fd. Used for * releasing the event lock for some * operations that are time consuming */Panel_item mt_show_item, mt_del_item, mt_print_item, mt_state_item;Panel_item mt_compose_item,/* mt_others_item, mt_others_label_item,*/ mt_file_item;Panel_item mt_folder_item, mt_info_item, mt_dir_item;Panel_item mt_deliver_item, mt_cancel_item;Panel_item mt_pre_item;Frame mt_cd_frame;static Panel_item panel_create_old_button(), panel_create_new_button();static Panel_item panel_create_image(), panel_create_3Dimage();static Panel_item panel_create_3Dbutton(), mt_panel_create_item();static void mt_layout_cmdpanel(), mt_create_replysw(), mt_layout_reply_panel(), mt_create_3D_cd_popup(), mt_create_2D_cd_popup();static void mt_layout_panel(), mt_cd_done_proc();static Notify_value mt_cmdpanel_event_proc(), mt_reply_panel_event_proc(), mt_replysw_event_proc();#define TOOL_COLS 80#define BUTTON_SPACING 5Pixfont *mt_3Dfont;Pixrect *outline_image(), *outline_string();Pixrect *mt_newmail_pr, *mt_nomail_pr, *mt_trash_pr, *mt_trashfull_pr;#ifdef USE_IMAGES/* * Images for buttons */static short mt_show1_data[ ] = {#include <images/show.image>};mpr_static(mt_show1_pr, 32, 33, 1, mt_show1_data);static short mt_next1_data[ ] = {#include <images/next.image>};mpr_static(mt_next1_pr, 16, 23, 1, mt_next1_data);static short mt_trash1_data[ ] = {#include <images/trash.image>};mpr_static(mt_trash1_pr, 32, 30, 1, mt_trash1_data);static short mt_trashfull1_data[ ] = {#include <images/trashfull.image>};mpr_static(mt_trashfull1_pr, 32, 30, 1, mt_trashfull1_data);static short mt_reply1_data[ ] = {#include <images/reply.image>};mpr_static(mt_reply1_pr, 64, 31, 1, mt_reply1_data);static short mt_compose1_data[ ] = {#include <images/compose.image>};mpr_static(mt_compose1_pr, 32, 31, 1, mt_compose1_data);static short mt_folder1_data[ ] = {#include <images/folder.image>};mpr_static(mt_folder1_pr, 32, 28, 1, mt_folder1_data);static short mt_save1_data[ ] = {#include <images/save.image>};mpr_static(mt_save1_pr, 32, 31, 1, mt_save1_data);static short mt_printer1_data[ ] = {#include <images/printer.image>};mpr_static(mt_printer1_pr, 48, 27, 1, mt_printer1_data);static short mt_newmail1_data[ ] = {#include <images/newmail.image>};mpr_static(mt_newmail1_pr, 32, 31, 1, mt_newmail1_data);static short mt_nomail1_data[ ] = {#include <images/nomail.image>};mpr_static(mt_nomail1_pr, 32, 31, 1, mt_nomail1_data);/* images with no outlines for use with 3d buttons */static short mt_show2_data[] = {#include <images/show.3Dimage>};mpr_static(mt_show2_pr, 64, 52, 1, mt_show2_data);static short mt_load2_data[] = {#include <images/load.3Dimage>};mpr_static(mt_load2_pr, 64, 52, 1, mt_load2_data);static short mt_store2_data[] = {#include <images/store.3Dimage>};mpr_static(mt_store2_pr, 64, 52, 1, mt_store2_data);static short mt_print2_data[] = {#include <images/print.3Dimage>};mpr_static(mt_print2_pr, 64, 52, 1, mt_print2_data);static short mt_new_mail2_data[] = {#include <images/new_mail_open.3Dimage>};mpr_static(mt_new_mail2_pr, 64, 52, 1, mt_new_mail2_data);static short mt_no_mail2_data[] = {#include <images/no_mail.3Dimage>};mpr_static(mt_no_mail2_pr, 64, 52, 1, mt_no_mail2_data);static short mt_compose2_data[] = {#include <images/compose.3Dimage>};mpr_static(mt_compose2_pr, 64, 52, 1, mt_compose2_data);static short mt_reply2_data[] = {#include <images/reply.3Dimage>};mpr_static(mt_reply2_pr, 64, 52, 1, mt_reply2_data);static short mt_delete2_data[] = {#include <images/delete.3Dimage>};mpr_static(mt_delete2_pr, 64, 52, 1, mt_delete2_data);static short mt_deletefull2_data[] = {#include <images/delete_full.3Dimage>};mpr_static(mt_deletefull2_pr, 64, 52, 1, mt_deletefull2_data);static short mt_prev2_data[] = {#include <images/prev.3Dimage>};mpr_static(mt_prev2_pr, 28, 20, 1, mt_prev2_data);static short mt_next2_data[] = {#include <images/next.3Dimage>};mpr_static(mt_next2_pr, 28, 20, 1, mt_next2_data);static short mt_done2_data[] = {#include <images/done.3Dimage>};mpr_static(mt_done2_pr, 64, 20, 1, mt_done2_data);static short mt_misc2_data[] = {#include <images/misc.3Dimage>};mpr_static(mt_misc2_pr, 64, 20, 1, mt_misc2_data);#endifstatic short mt_menu1_data[ ] = {#include <images/menu.image>};mpr_static(mt_menu1_pr, 16, 16, 1, mt_menu1_data);/* * above is outside of ifdef because it is used in the old style panel to * provide a method fo getting back to the new style (or three d) panel *//* * create control panel using graphic images for buttons, simplified layout. * Panel is 3 rows high, not scrollable */voidmt_create_3Dimages_panel(){#ifdef USE_IMAGES Panel_item item; Menu menu, pull_right; struct panel_item_data *p; mt_3Dfont = pf_open("/usr/lib/fonts/fixedwidthfonts/screen.r.13"); /* NEED TO CHECK FOR FONT BEING THERE */ mt_cmdpanel = window_create(mt_frame, PANEL, WIN_ERROR_MSG, "Unable to create panel\n", WIN_SHOW, FALSE, 0); if (mt_cmdpanel == NULL) { if (mt_debugging) (void)fprintf(stderr,"Unable to create 3D-image panel\n"); mt_warn(mt_frame, "Unable to create 3D-image panel", 0); exit(1); } mt_add_window((Window)mt_cmdpanel, mt_Panel); mt_cmdpanel_fd = (int)window_get(mt_cmdpanel, WIN_FD); (void) panel_create_3Dimage(mt_cmdpanel, &mt_prev2_pr, 5, 5, mt_prev_proc, "Previous", NULLSTRING, NULLSTRING, NULLSTRING); (void) panel_create_3Dimage(mt_cmdpanel, &mt_next2_pr, 5, 37, mt_next_proc, "Next", NULLSTRING, NULLSTRING, NULLSTRING); mt_show_item = panel_create_3Dimage(mt_cmdpanel, &mt_show2_pr, (1*77)-31, 5, mt_show_proc, "Show", "Show Full Header [Shift]", NULLSTRING, NULLSTRING); mt_trash_pr = outline_image(&mt_delete2_pr); mt_trashfull_pr = outline_image(&mt_deletefull2_pr); mt_del_item = panel_create_3Dimage(mt_cmdpanel, ((mt_delp == NULL) ? &mt_delete2_pr : &mt_delete2_pr), (2*77)-31, 5, mt_del_proc, NULLSTRING, NULLSTRING, NULLSTRING, NULLSTRING); menu = mt_create_menu_for_button(mt_del_item); /* the menu behind * mt_del_item */ pull_right = mt_create_menu_for_button((Panel_item) 0); /* the pullright menu */ (void) menu_set(pull_right, MENU_GEN_PROC, mt_del_gen_proc, 0); /* delete menu depends on setting of "autoprint" */ (void) menu_set(menu, MENU_PULLRIGHT_ITEM, "Delete", pull_right, 0); mt_add_menu_item(menu, "Undelete", mt_undel_proc, 0); (void) menu_set(menu_get(menu, MENU_NTH_ITEM, 2), MENU_INACTIVE, (mt_delp == NULL), 0); item = panel_create_3Dimage(mt_cmdpanel, &mt_store2_pr, (3*77)-31, 5, mt_save_proc, NULLSTRING, NULLSTRING, NULLSTRING, NULLSTRING); pull_right = mt_create_menu_for_button((Panel_item) 0); /* the pullright menu */ (void) menu_set(pull_right, MENU_GEN_PROC, mt_save_gen_proc, 0); /* save menu depends on setting of "autoprint" */ menu = mt_create_menu_for_button(item); /* the menu behind * the save button */ (void) menu_set(menu, MENU_PULLRIGHT_ITEM, "Save", pull_right, 0); mt_add_menu_item(menu, "Copy", mt_copy_proc, 0); mt_folder_item = panel_create_3Dimage(mt_cmdpanel, &mt_load2_pr, (4*77)-31, 5, mt_folder_proc, NULLSTRING, NULLSTRING, NULLSTRING, NULLSTRING); (void) panel_set(mt_folder_item, PANEL_EVENT_PROC, mt_folder_event, 0); /* * mt_folder_event computes a menu consisting of the folders */ mt_compose_item = panel_create_3Dimage(mt_cmdpanel, &mt_compose2_pr, (5*77)-31, 5, mt_comp_proc, NULLSTRING, NULLSTRING, NULLSTRING, NULLSTRING); /* * compose menu depends on setting of "askcc" */ (void) menu_set(mt_create_menu_for_button(mt_compose_item), MENU_GEN_PROC, mt_compose_gen_proc, 0); item = panel_create_3Dimage(mt_cmdpanel, &mt_reply2_pr, (6*77)-31, 5, mt_reply_proc, NULLSTRING, NULLSTRING, NULLSTRING, NULLSTRING); /* * reply menu is depends on on setting of "replyall" */ (void) menu_set(mt_create_menu_for_button(item), MENU_GEN_PROC, mt_reply_gen_proc, 0); mt_print_item = panel_create_3Dimage(mt_cmdpanel, &mt_print2_pr, (7*77)-31, 5, mt_print_proc, "Print", NULLSTRING, NULLSTRING, NULLSTRING); mt_newmail_pr = outline_image(&mt_new_mail2_pr); mt_nomail_pr = outline_image(&mt_no_mail2_pr); mt_state_item = panel_create_3Dimage(mt_cmdpanel, &mt_new_mail2_pr, (8*77)-31, 5, mt_new_mail_proc, NULLSTRING, NULLSTRING, NULLSTRING, NULLSTRING); /* * menu depends on whether in system mail box or not */ (void) menu_set(mt_create_menu_for_button(mt_state_item), MENU_GEN_PROC, mt_new_mail_gen_proc, 0); mt_file_item = panel_create_item(mt_cmdpanel, PANEL_TEXT, PANEL_LABEL_STRING, "File:", PANEL_LABEL_X, 5, PANEL_LABEL_Y, 71, PANEL_VALUE_STORED_LENGTH, 128, PANEL_VALUE_DISPLAY_LENGTH, 45, /* XXX SHOULD FIGURE OUT HOW TO COMPUTE THIS NUMBER SO WHEN PANEL IS STRETCHED, IT GET's READJUSTED */ PANEL_EVENT_PROC, mt_file_event, PANEL_BOXED, TRUE, 0); item = panel_create_3Dimage(mt_cmdpanel, &mt_misc2_pr, (7*77)-31, 70, mt_cd_proc, NULLSTRING, NULLSTRING, NULLSTRING, NULLSTRING); menu = mt_create_menu_for_button(item); mt_add_menu_items(menu, "Change Directory", mt_cd_proc, 0, "Source .mailrc", mt_mailrc_proc, 0, "Preserve", mt_preserve_proc, 0, 0); if (mt_41_features) (void) menu_set(menu, MENU_GEN_PULLRIGHT_ITEM, "Panel Style", mt_panel_style_gen_proc, 0); item = panel_create_3Dimage(mt_cmdpanel, &mt_done2_pr, (8*77)-31, 70, mt_done_proc, "Commit Changes and Close", NULLSTRING, NULLSTRING, NULLSTRING); p = (struct panel_item_data *)LINT_CAST(panel_get( item, PANEL_CLIENT_DATA)); mt_add_menu_items(p->menu, "Commit Changes and Quit", mt_quit_proc, 0, "Quit Without Committing Changes", mt_abort_proc, 0, 0); p = (struct panel_item_data *)calloc(1, sizeof(struct panel_item_data)); window_fit_height(mt_cmdpanel); (void) window_set(mt_cmdpanel, WIN_SHOW, TRUE, 0);#endif}voidmt_create_cd_popup(){ if (nfds_avail() < 4) { mt_warn(mt_frame, "Not enough fds left to create popup!", 0); return; } else if (mt_panel_style == mt_3DImages) mt_create_3D_cd_popup(); else mt_create_2D_cd_popup(); panel_set_value(mt_dir_item, mt_wdir); (void) window_set(mt_cd_frame, WIN_SHOW, TRUE, 0);}static voidmt_create_3D_cd_popup(){#ifdef USE_IMAGES Panel mt_cd_panel; int x; mt_cd_frame = window_create(mt_frame, FRAME, WIN_ERROR_MSG, "Unable to create 3D-cd frame\n", 0); if (mt_cd_frame == NULL) { if (mt_debugging) (void)fprintf(stderr,"Unable to create 3D-cd frame\n", mt_warn(mt_frame, "Unable to create 3D-cd frame", 0); exit(1); } mt_cd_panel = window_create(mt_cd_frame, PANEL, WIN_ERROR_MSG, "Unable to create 3D-cd panel\n", WIN_FONT, mt_3Dfont, 0); if (mt_cd_panel == NULL) { if (mt_debugging) (void)fprintf(stderr,"Unable to create 3D-cd panel\n"); mt_warn(mt_frame, "Unable to create 3D-cd panel", 0); exit(1); } (void) panel_create_3Dbutton(mt_cd_panel, "Change Directory", 0, 0, mt_cd_proc, "Change Directory", NULLSTRING, NULLSTRING, NULLSTRING); (void) panel_create_3Dbutton(mt_cd_panel, "Dismiss", 0, 53, mt_cd_done_proc, "Dismiss This Panel", NULLSTRING, NULLSTRING, NULLSTRING); (void) window_set(mt_cd_frame, FRAME_DONE_PROC, mt_cd_done_proc, 0); mt_dir_item = panel_create_item(mt_cd_panel, PANEL_TEXT, PANEL_ITEM_X, ATTR_COL(0), PANEL_ITEM_Y, ATTR_ROW(1) + 20, PANEL_VALUE_DISPLAY_LENGTH, 50, PANEL_LABEL_STRING, "Directory:", PANEL_BOXED, TRUE, 0); window_fit(mt_cd_panel); window_fit(mt_cd_frame); x = ((int)window_get(mt_frame, WIN_WIDTH) - (int)window_get(mt_cd_frame, WIN_WIDTH)) / 2; (void) window_set(mt_cd_frame, WIN_X, x, WIN_Y, 320, 0);#endif}static voidmt_create_2D_cd_popup(){ Panel mt_cd_panel; int x; mt_cd_frame = window_create(mt_frame, FRAME, WIN_ERROR_MSG, "Unable to create 2D-cd frame\n", 0); if (mt_cd_frame == NULL) { if (mt_debugging) (void)fprintf(stderr,"Unable to create 2D-cd frame\n"); mt_warn(mt_frame, "Unable to create 2D-cd frame", 0); exit(1); } mt_cd_panel = window_create(mt_cd_frame, PANEL, WIN_ERROR_MSG, "Unable to create 2D-cd panel\n", WIN_FONT, mt_font, 0); if (mt_cd_panel == NULL) { if (mt_debugging) (void)fprintf(stderr,"Unable to create 2D-cd panel\n"); mt_warn(mt_frame, "Unable to create 2D-cd panel", 0); exit(1); } (void) panel_create_new_button(mt_cd_panel, "Change Directory", 0, 0, mt_cd_proc, "Change Directory", NULLSTRING, NULLSTRING, NULLSTRING); (void) panel_create_new_button(mt_cd_panel, "Dismiss", 0, 53, mt_cd_done_proc, "Dismiss This Panel", NULLSTRING, NULLSTRING, NULLSTRING); (void) window_set(mt_cd_frame, FRAME_DONE_PROC, mt_cd_done_proc, 0); mt_dir_item = panel_create_item(mt_cd_panel, PANEL_TEXT, PANEL_ITEM_X, ATTR_COL(0), PANEL_ITEM_Y, ATTR_ROW(1) + 10, PANEL_VALUE_DISPLAY_LENGTH, 50, PANEL_LABEL_STRING, "Directory:", PANEL_BOXED, TRUE, 0); window_fit(mt_cd_panel); window_fit(mt_cd_frame); x = ((int)window_get(mt_frame, WIN_WIDTH) - (int)window_get(mt_cd_frame, WIN_WIDTH)) / 2; (void) window_set(mt_cd_frame, WIN_X, x, WIN_BELOW, mt_cmdpanel, 0);}/* * dismiss popup panel. Called from done button on panel and its frame menu. *//* ARGSUSED */static voidmt_cd_done_proc(item, ie) Panel_item item; Event *ie;{ mt_destroy_cd_popup(); /* window_set(mt_misc_frame, WIN_SHOW, FALSE, 0); */}voidmt_destroy_cd_popup(){ mt_dir_item = NULL; (void) window_set(mt_cd_frame, FRAME_NO_CONFIRM, TRUE, 0); (void) window_destroy(mt_cd_frame); mt_cd_frame = NULL;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -