📄 create_panels.c
字号:
/* * create control panel using labelled buttons, simplified layout. * Panel is 3 rows high, not scrollable */voidmt_create_new_style_panel(){ Panel_item item; Menu menu, pull_right; struct panel_item_data *p; int button_width, last_button_col, i; char *s; button_width = 9; last_button_col = 71; if ((s = mt_value("buttonwidth")) && (i = atoi(s)) > 0) button_width = i; mt_cmdpanel = window_create(mt_frame, PANEL, WIN_ROW_GAP, 7, WIN_ERROR_MSG, "Unable to create new-style panel\n", WIN_SHOW, FALSE,/* set to true after call to * mt_layout_cmdpanel or otherwise in case * where changing style of panels, i.e., * window is already visible, would see those * items that are reset by mt_layout would * get painted */ 0); if (mt_cmdpanel == NULL) { if (mt_debugging) (void)fprintf(stderr,"Unable to create new-style panel\n"); mt_warn(mt_frame, "Unable to create new-style panel", 0); exit(1); } mt_add_window((Window)mt_cmdpanel, mt_Panel); mt_cmdpanel_fd = (int)window_get(mt_cmdpanel, WIN_FD); mt_show_item = panel_create_new_button(mt_cmdpanel, "Show", 0, 0, mt_show_proc, "Show", "Show Full Header [Shift]", NULLSTRING, NULLSTRING); (void) panel_create_new_button(mt_cmdpanel, "Next", 0, (1 * button_width), mt_next_proc, "Next", "Previous [Shift]", NULLSTRING, NULLSTRING); mt_del_item = panel_create_new_button(mt_cmdpanel, "Delete", 0, (2 * button_width), mt_del_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_del_gen_proc, 0); /* delete menu depends on setting of "autoprint" */ menu = mt_create_menu_for_button(mt_del_item); /* the menu behind * mt_del_item */ (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_new_button(mt_cmdpanel, "Save", 1, 0, 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_new_button(mt_cmdpanel, "Folder", 1, (1 * button_width), 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 */ item = panel_create_new_button(mt_cmdpanel, "Reply", 0, (3 * button_width), 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_compose_item = panel_create_new_button(mt_cmdpanel, "Compose", 0, (4 * button_width), mt_comp_proc, NULLSTRING, NULLSTRING, NULLSTRING, NULLSTRING); /* * compose menu is depends on on setting of "askcc" */ (void) menu_set(mt_create_menu_for_button(mt_compose_item), MENU_GEN_PROC, mt_compose_gen_proc, 0); mt_print_item = panel_create_new_button(mt_cmdpanel, "Print", 0, (last_button_col - (1 * button_width)), mt_print_proc, "Print", NULLSTRING, NULLSTRING, NULLSTRING); mt_state_item = panel_create_new_button(mt_cmdpanel, "New Mail", 0, last_button_col, 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); item = panel_create_old_button(mt_cmdpanel, "Done", 1, last_button_col, mt_done_proc, "Commit Changes and Close", NULLSTRING, NULLSTRING, NULLSTRING); /* * difference between old and new is padding of 7 vs 8. Since this * is under the new mail button, and that is wider because it * consists of 8 characters, looks better if done button is same width. */ 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); item = panel_create_new_button(mt_cmdpanel, "Misc", 1, (last_button_col - (1 * button_width)), 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); p = (struct panel_item_data *)calloc(1, sizeof(struct panel_item_data)); p->width = (last_button_col - (1 * button_width)) - (2 * button_width) - 8; /* * position of misc, minus 18, position of "File:" * minus 6, number of characters in "File: " + some padding */ mt_file_item = panel_create_item(mt_cmdpanel, PANEL_TEXT, PANEL_LABEL_STRING, "File:", PANEL_LABEL_X, ATTR_COL(2 * button_width) + 5, PANEL_LABEL_Y, ATTR_ROW(1) + 2 + BUTTON_SPACING, PANEL_VALUE_DISPLAY_LENGTH, p->width, PANEL_CLIENT_DATA, p, PANEL_EVENT_PROC, mt_file_event, 0); if (mt_41_features) (void) panel_set(mt_file_item, PANEL_BOXED, TRUE, 0); (void) window_set(mt_cmdpanel, WIN_FIT_HEIGHT, BUTTON_SPACING, 0); mt_layout_cmdpanel(); /* readjust positions of right justified * items in case width of tool is not the * default */ (void) window_set(mt_cmdpanel, WIN_SHOW, TRUE, 0); notify_interpose_event_func(mt_cmdpanel, mt_cmdpanel_event_proc, NOTIFY_SAFE); /* arrange to relay out cmd panel when resized */}/* * create cmd panel. 7 rows of buttons, 4 visible, no graphics, i.e., * identical to that in 3.2 release */voidmt_create_old_style_panel(){ Panel_item item; Menu menu; struct panel_item_data *p; mt_cmdpanel = window_create(mt_frame, PANEL, WIN_ROW_GAP, 7, WIN_HEIGHT, ATTR_LINES(mt_cmdlines) + 4 + BUTTON_SPACING, WIN_VERTICAL_SCROLLBAR, scrollbar_create(0), WIN_ERROR_MSG, "Unable to create old-style panel\n", 0); if (mt_cmdpanel == NULL) { if (mt_debugging) (void)fprintf(stderr,"Unable to create old-style panel\n"); mt_warn(mt_frame, "Unable to create old-style panel", 0); exit(1); } mt_add_window((Window)mt_cmdpanel, mt_Panel); mt_cmdpanel_fd = window_fd(mt_cmdpanel); /* first line */ mt_show_item = panel_create_old_button(mt_cmdpanel, "show", 0, 0, mt_show_proc, "show", "show all headers [Shift]", NULLSTRING, NULLSTRING); (void) panel_create_old_button(mt_cmdpanel, "next", 0, 10, mt_next_proc, "next", "prev [Shift]", NULLSTRING, NULLSTRING); item = panel_create_old_button(mt_cmdpanel, "delete", 0, 20, mt_del_proc, NULLSTRING, NULLSTRING, NULLSTRING, NULLSTRING); /* delete menu depends on setting of "autoprint" */ (void) menu_set(mt_create_menu_for_button(item), MENU_GEN_PROC, mt_del_gen_proc, 0); (void) panel_create_old_button(mt_cmdpanel, "undelete", 0, 30, mt_undel_proc, "undelete", NULLSTRING, NULLSTRING, NULLSTRING); (void) panel_create_old_button(mt_cmdpanel, "print", 0, 40, mt_print_proc, "print", NULLSTRING, NULLSTRING, NULLSTRING); mt_state_item = panel_create_old_button(mt_cmdpanel, "new mail", 0, 50, mt_new_mail_proc, (mt_3x_compatibility ? "new mail" : "incorporate new mail"), NULLSTRING, NULLSTRING, NULLSTRING); (void) panel_create_old_button(mt_cmdpanel, "done", 0, 60, mt_done_proc, "done", NULLSTRING, NULLSTRING, NULLSTRING); /* second line */ item = panel_create_old_button(mt_cmdpanel, "reply", 1, 0, 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_compose_item = panel_create_old_button(mt_cmdpanel, "compose", 1, 10, mt_comp_proc, NULLSTRING, NULLSTRING, NULLSTRING, NULLSTRING); /* * compose menu is depends on on setting of "replyall" */ (void) menu_set(mt_create_menu_for_button(mt_compose_item), MENU_GEN_PROC, mt_compose_gen_proc, 0); mt_deliver_item = panel_create_old_button(mt_cmdpanel, "deliver", 1, 30, mt_deliver_proc, "deliver", NULLSTRING, NULLSTRING, NULLSTRING); (void) panel_set(mt_deliver_item, PANEL_SHOW_ITEM, FALSE, 0); mt_cancel_item = panel_create_old_button(mt_cmdpanel, "cancel", 1, 40, mt_cancel_proc, "cancel", "", "cancel, no confirm [Ctrl]", NULLSTRING); (void) panel_set(mt_cancel_item, PANEL_SHOW_ITEM, FALSE, 0); (void) panel_create_old_button(mt_cmdpanel, "commit", 1, 60, mt_commit_proc, "commit", NULLSTRING, NULLSTRING, NULLSTRING); /* third line */ item = panel_create_old_button(mt_cmdpanel, "save", 2, 0, mt_save_proc, NULLSTRING, NULLSTRING, NULLSTRING, NULLSTRING); (void) menu_set(mt_create_menu_for_button(item), MENU_GEN_PROC, mt_save_gen_proc, 0); /* save menu depends on setting of "autoprint" */ (void) panel_create_old_button(mt_cmdpanel, "copy", 2, 10, mt_copy_proc, "copy", NULLSTRING, NULLSTRING, NULLSTRING); mt_file_item = panel_create_item(mt_cmdpanel, PANEL_TEXT, PANEL_LABEL_STRING, "File: ", PANEL_LABEL_Y, ATTR_ROW(2) + 7, PANEL_LABEL_X, ATTR_COL(20) + 5, PANEL_VALUE_STORED_LENGTH, 1024, PANEL_VALUE_DISPLAY_LENGTH, 50, PANEL_EVENT_PROC, mt_file_event, 0); /* fourth line */ mt_folder_item = panel_create_old_button(mt_cmdpanel, "folder", 3, 0, mt_folder_proc, NULLSTRING, NULLSTRING, NULLSTRING, NULLSTRING); (void) panel_set(mt_folder_item, PANEL_EVENT_PROC, mt_folder_event, 0); p = (struct panel_item_data *)calloc(1, sizeof(struct panel_item_data)); mt_info_item = panel_create_item(mt_cmdpanel, PANEL_TEXT, PANEL_LABEL_STRING, "", PANEL_LABEL_Y, ATTR_ROW(3) + 7, PANEL_LABEL_X, ATTR_COL(11) + 5, PANEL_VALUE_DISPLAY_LENGTH, 68, PANEL_VALUE_STORED_LENGTH, 128, PANEL_CLIENT_DATA, p, PANEL_EVENT_PROC, mt_panel_event, PANEL_READ_ONLY, TRUE, 0); /* * this really should be a MESSAGE item but no way to specify * display length for MESSAGE items */ /* fifth line */ mt_pre_item = panel_create_old_button(mt_cmdpanel, "preserve", 4, 0, mt_preserve_proc, "preserve", NULLSTRING, NULLSTRING, NULLSTRING); (void) panel_create_old_button(mt_cmdpanel, "cd", 4, 10, mt_cd_proc, "change directory", NULLSTRING, NULLSTRING, NULLSTRING); mt_dir_item = panel_create_item(mt_cmdpanel, PANEL_TEXT, PANEL_LABEL_STRING, "Directory: ", PANEL_LABEL_Y, ATTR_ROW(4) + 7, PANEL_LABEL_X, ATTR_COL(20) + 5, PANEL_VALUE, mt_wdir, PANEL_VALUE_STORED_LENGTH, 1024, PANEL_VALUE_DISPLAY_LENGTH, 50, 0); /* sixth line */ (void) panel_create_old_button(mt_cmdpanel, ".mailrc", 5, 0, mt_mailrc_proc, "source .mailrc", NULLSTRING, NULLSTRING, NULLSTRING); if (mt_41_features) { item = panel_create_image(mt_cmdpanel, &mt_menu1_pr, ATTR_ROW(5) + 5, 11, mt_nop_proc, NULLSTRING, NULLSTRING, NULLSTRING, NULLSTRING); menu = mt_create_menu_for_button(item); (void) menu_set(menu, MENU_GEN_PROC, mt_panel_style_gen_proc, 0); item = panel_create_item(mt_cmdpanel, PANEL_MESSAGE, PANEL_LABEL_STRING, "Panel Style", PANEL_LABEL_X, ATTR_COL(14), PANEL_LABEL_Y, ATTR_ROW(5) + 6, PANEL_EVENT_PROC, mt_nop_proc, 0); } (void) panel_create_old_button(mt_cmdpanel, "quit", 5, 50, mt_quit_proc, "quit", "", "quit, no confirm [Ctrl]", NULLSTRING); (void) panel_create_old_button(mt_cmdpanel, "abort", 5, 60, mt_abort_proc, "abort", "", "abort, no confirm [Ctrl]", NULLSTRING);}struct reply_panel_data *mt_create_reply_panel(frame) Frame frame;{ Panel panel; Panel_item item; struct reply_panel_data *ptr; struct panel_item_data *p; if((ptr = (struct reply_panel_data *)LINT_CAST(calloc(1, sizeof(struct reply_panel_data)))) == NULL) { mt_warn(frame, "malloc failed in mt_create_reply_panel,", 0); return(NULL); } ptr->behavior = mt_Disappear; ptr->inuse = FALSE; ptr->normalized = TRUE; ptr->frame = frame; if (mt_3x_compatibility) { mt_create_replysw(ptr); return(ptr); } panel = window_create(frame, PANEL, WIN_ERROR_MSG, "Unable to create reply panel\n", WIN_SHOW, FALSE, WIN_FONT, ((mt_panel_style == mt_3DImages) ? mt_3Dfont : mt_font), 0); if (panel == NULL) { if (mt_debugging) (void)fprintf(stderr,"Unable to create reply panel\n"); mt_warn(frame, "Unable to create reply panel,", 0); free(ptr); ptr = NULL; /* make sure ptr does not point to anything */ return (ptr); } (void) panel_set(panel, PANEL_CLIENT_DATA, ptr, 0); ptr->reply_panel = panel; if (mt_panel_style == mt_3DImages) { (void) panel_create_3Dbutton(panel, "Include", 0, 0, mt_include_proc, "Include, Bracketed", "", "Include, Indented [Ctrl]", NULL); ptr->deliver_item = panel_create_3Dbutton(panel, "Deliver", 0, 11, mt_deliver_proc, "Deliver, Take Down Window", "", "Deliver, Leave Window Intact [Ctrl]", NULLSTRING); (void) panel_create_3Dbutton(panel, "Re-address", 0, 32, mt_readdress_proc, "Insert Address Template", NULLSTRING, NULLSTRING, NULLSTRING); /* * re-address button also on reply panel so that user can * close mailtool but still compose messages in a popup. Also * allows user to use deliver, leave intact option, and then * wrap To:, Subject: header around the message */ item = panel_create_3Dbutton(panel, "Cancel", 0, 22, mt_cancel_proc, NULLSTRING, NULLSTRING, NULLSTRING, NULLSTRING); } else { (void) panel_create_new_button(panel, "Include", 0, 0, mt_include_proc, "Include, Bracketed", "", "Include, Indented [Ctrl]", NULLSTRING); ptr->deliver_item = panel_create_new_button(panel, "Deliver", 0, 9, mt_deliver_proc, "Deliver, Take Down Window", "", "Deliver, Leave Window Intact [Ctrl]", NULLSTRING); (void) panel_create_new_button(panel, "Re-address", 0, 28, mt_readdress_proc, "Insert Address Template", NULLSTRING, NULLSTRING, NULLSTRING); item = panel_create_new_button(panel, "Cancel", 0, 18, mt_cancel_proc, NULLSTRING, NULLSTRING, NULLSTRING, NULLSTRING); } (void) menu_set(mt_create_menu_for_button(item), MENU_GEN_PROC, mt_cancel_gen_proc, 0); ptr->cancel_item = item;/* so can change string to "clear" when * replysw is made permanent */ p = (struct panel_item_data *)calloc(1, sizeof(struct panel_item_data)); p->column = 69; item = panel_create_item(panel, PANEL_CYCLE, PANEL_CHOICE_STRINGS, "Disappear", "Stay Up", 0, PANEL_LABEL_X, ATTR_COL(p->column) + 5, PANEL_LABEL_Y, -4, PANEL_NOTIFY_PROC, mt_replysw_proc, PANEL_EVENT_PROC, mt_panel_event, PANEL_CLIENT_DATA, p, 0); /* * reason for having this go through mt_panel_event is to get * consistent treatement of tracing */ if (frame != mt_frame) (void) panel_set(item, PANEL_CHOICE_STRINGS, "Disappear", "Stay Up", "Close", 0, 0); ptr->cycle_item = item; window_fit_height(panel); mt_layout_reply_panel(panel); /* * arrange to re-layout panel when window is resized. Put this * procedure on the panel, rather than the frame, so that it isn't * called if the window is simply stretched vertically. */ mt_create_replysw(ptr); if (ptr->replysw == NULL) { /* * the calling funct mt_create_new_replysw will remove * the panel with a window_done call. */ free(ptr); /* Reply sw not created - mssg already given */ ptr = NULL; return(ptr); } notify_interpose_event_func(panel, mt_reply_panel_event_proc, NOTIFY_SAFE); mt_add_window((Window)panel, mt_Panel); return (ptr);}static voidmt_create_replysw(ptr) struct reply_panel_data *ptr;{ char *replysw_file; ptr->replysw = (Textsw)window_create(ptr->frame, TEXT, WIN_ERROR_MSG, "Unable to create reply subwindow\n", WIN_SHOW, FALSE, TEXTSW_MEMORY_MAXIMUM, mt_memory_maximum, TEXTSW_CONFIRM_OVERWRITE, FALSE, TEXTSW_STORE_SELF_IS_SAVE, TRUE, WIN_CLIENT_DATA, ptr, 0); if (ptr->replysw == NULL) { if (mt_debugging) (void)fprintf(stderr,"Unable to create reply subwindow\n"); mt_warn(mt_frame, "Unable to create reply subwindow,", 0); return; } replysw_file = (char *)LINT_CAST(malloc(32)); (void) strcpy(replysw_file, "/tmp/MTrXXXXXX"); (void) mktemp(replysw_file); ptr->replysw_file = replysw_file; mt_add_window((Window)ptr->replysw, mt_Text); if (!mt_retained) notify_interpose_event_func(ptr->replysw, mt_replysw_event_proc, NOTIFY_SAFE);}static Notify_valuemt_replysw_event_proc(client, event, arg, when) Notify_client client; Event *event;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -