📄 iconedit_panel.c
字号:
#ifndef lint#ifdef sccsstatic char sccsid[] = "@(#)iconedit_panel.c 1.1 92/07/30 SMI";#endif#endif/**************************************************************************//* iconedit_panel.c *//* Copyright (c) 1986 by Sun Microsystems Inc. *//**************************************************************************/#include "iconedit.h"#include <sys/param.h>#include <sys/stat.h>#include <suntool/alert.h>#include <suntool/icon_load.h>#include <suntool/frame.h>#include <suntool/fullscreen.h>static int confirmed;static Menu store_menu;extern char *sys_errlist[];extern int errno;/**************************************************************************//* pixfonts *//**************************************************************************/struct pixfont *iced_screenr7, *iced_screenr11, *iced_screenb12, *iced_screenr12, *iced_screenr14, *iced_screenb14, *iced_cmrb14, *iced_cmrr14, *iced_gallantr19, *iced_font, *iced_bold_font, *iced_abc_font;/**************************************************************************//* for invoking store or quit with keyboard accelerators *//**************************************************************************/#define ESC 27 /* escape for file-name completion */#define CTRL_L 12 /* control-L for "load" */#define CTRL_S 19 /* control-S for "store" */#define CTRL_B 2 /* control-B for "browse" */#define CTRL_Q 17 /* control-Q for "quit" */static int store_invoked_from_keyboard = FALSE;static int quit_invoked_from_keyboard = FALSE;static int ctrl_s_pending = FALSE;static int ctrl_q_pending = FALSE;/************************************************************************//* mouse and msg panel declarations *//************************************************************************/Panel iced_mouse_panel;Panel iced_msg_panel;static Panel_item mousemsg_left_mouse_item;static Panel_item mousemsg_left_text_item;static Panel_item mousemsg_mid_mouse_item;static Panel_item mousemsg_mid_text_item;static Panel_item mousemsg_right_mouse_item;static Panel_item mousemsg_right_text_item;static Panel_item canvasmsg_item;static Panel_item panelmsg_top_item;static Panel_item panelmsg_bottom_item;static void confirm_mouse_proc();static void canvas_mouse_proc();/************************************************************************//* control panel declarations *//************************************************************************/Panel iced_panel;Panel_item iced_dir_item;Panel_item iced_fname_item;Panel_item iced_load_item;Panel_item iced_store_item;Panel_item iced_browse_item;Panel_item iced_quit_item;Panel_item iced_size_item;Panel_item iced_grid_item;Panel_item iced_draw_item;Panel_item iced_mode_item;Panel_item iced_clear_item;Panel_item iced_invert_item;Panel_item iced_fill_canvas_item;Panel_item iced_fill_square_item;Panel_item iced_fill_circle_item;Panel_item iced_abc_item;Panel_item iced_font_item;Panel_item iced_proof_op_item;Panel_item iced_load_op_item;Panel_item iced_fill_op_item;Panel_item iced_proof_background_item;static Panel_setting dir_proc();static Panel_setting fname_proc();static void store_proc();static void quit_proc();static void size_proc();static void grid_proc();static void mode_proc();static void invert_proc();static void fill_canvas_proc();static void fill_square_proc();static void fill_circle_proc();static Panel_setting abc_proc();static void font_proc();static void proof_background_proc();static void proof_op_proc();static void store_button_event_proc();static int val_to_op();/************************************************************************//* iced_init_mouse_panel *//************************************************************************/iced_init_mouse_panel() { iced_mouse_panel = window_create(iced_base_frame, PANEL, WIN_WIDTH, iced_mouse_panel_width, WIN_HEIGHT, iced_mouse_panel_height, WIN_FONT, iced_bold_font, PANEL_LABEL_BOLD, FALSE, WIN_ERROR_MSG, "Unable to create mouse panel\n", 0); if (iced_mouse_panel == NULL) { (void)fprintf(stderr,"Unable to create mouse panel\n"); exit(1); } mousemsg_left_mouse_item = panel_create_item(iced_mouse_panel, PANEL_MESSAGE, PANEL_LABEL_X, 10+PANEL_CU(11), PANEL_LABEL_Y, 2, PANEL_LABEL_IMAGE, &iced_mouse_left, 0); mousemsg_left_text_item = panel_create_item(iced_mouse_panel, PANEL_MESSAGE, PANEL_LABEL_X, 30+PANEL_CU(11), PANEL_LABEL_Y, 3, PANEL_LABEL_STRING, "Paint", 0); mousemsg_mid_mouse_item = panel_create_item(iced_mouse_panel, PANEL_MESSAGE, PANEL_LABEL_X, 105+PANEL_CU(11), PANEL_LABEL_Y, 2, PANEL_LABEL_IMAGE, &iced_mouse_middle, 0); mousemsg_mid_text_item = panel_create_item(iced_mouse_panel, PANEL_MESSAGE, PANEL_LABEL_X, 125+PANEL_CU(11), PANEL_LABEL_Y, 3, PANEL_LABEL_STRING, "Clear", 0); mousemsg_right_mouse_item = panel_create_item(iced_mouse_panel, PANEL_MESSAGE, PANEL_LABEL_X, 200+PANEL_CU(11), PANEL_LABEL_Y, 2, PANEL_LABEL_IMAGE, &iced_mouse_right, 0); mousemsg_right_text_item = panel_create_item(iced_mouse_panel, PANEL_MESSAGE, PANEL_LABEL_X, 220+PANEL_CU(11), PANEL_LABEL_Y, 3, PANEL_LABEL_STRING, "Undo", 0); canvasmsg_item = panel_create_item(iced_mouse_panel, PANEL_MESSAGE, PANEL_LABEL_X, 10, PANEL_LABEL_Y, 22, PANEL_LABEL_STRING, " Points: Pick points to Paint or Clear.", 0);}/************************************************************************//* iced_init_msg_panel *//************************************************************************/iced_init_msg_panel() { iced_msg_panel = window_create(iced_base_frame, PANEL, WIN_WIDTH, iced_msg_panel_width, WIN_HEIGHT, iced_msg_panel_height, WIN_FONT, iced_bold_font, PANEL_LABEL_BOLD, FALSE, WIN_ERROR_MSG, "Unable to create msg panel\n", 0); if (iced_msg_panel == NULL) { (void)fprintf(stderr,"Unable to create msg panel\n"); exit(1); } panelmsg_top_item = panel_create_item(iced_msg_panel, PANEL_MESSAGE, PANEL_LABEL_X, 10, PANEL_LABEL_Y, 3, PANEL_LABEL_STRING, "", 0); panelmsg_bottom_item = panel_create_item(iced_msg_panel, PANEL_MESSAGE, PANEL_LABEL_X, 10, PANEL_LABEL_Y, 22, PANEL_LABEL_STRING, "", 0);}/************************************************************************//* message routines *//************************************************************************/staticmousemsg(left,mid,right) char *left,*mid,*right; { panel_set(mousemsg_left_text_item, PANEL_LABEL_STRING, left, 0); panel_set(mousemsg_mid_text_item, PANEL_LABEL_STRING, mid, 0); panel_set(mousemsg_right_text_item, PANEL_LABEL_STRING, right, 0);}staticcanvasmsg(msg) char *msg; { panel_set(canvasmsg_item, PANEL_LABEL_STRING, msg, 0);}iced_panelmsg(top_msg,bottom_msg) char *top_msg,*bottom_msg; { panel_set(panelmsg_top_item, PANEL_LABEL_STRING, top_msg, 0); panel_set(panelmsg_bottom_item, PANEL_LABEL_STRING, bottom_msg, 0);}/************************************************************************//* control panel section *//************************************************************************/iced_init_panel() { int row1 = 5; int row2 = 28; int row3 = 53; int row4 = 84; int row5 = 109; char current_directory[MAXPATHLEN+1]; iced_abc_font = iced_screenr12; iced_panel = window_create(iced_base_frame, PANEL, WIN_WIDTH, iced_panel_width, WIN_HEIGHT, iced_panel_height, WIN_CURSOR, &iconedit_main_cursor, WIN_FONT, iced_bold_font, WIN_ERROR_MSG, "Unable to create iced panel\n", PANEL_LABEL_BOLD, FALSE, 0); if (iced_panel == NULL) { (void)fprintf(stderr,"Unable to create iced panel\n"); exit(1); } (void) getwd(current_directory); iced_dir_item = panel_create_item(iced_panel, PANEL_TEXT, PANEL_LABEL_X, 10, PANEL_LABEL_Y, row1, PANEL_VALUE_DISPLAY_LENGTH,21, PANEL_LABEL_BOLD, FALSE, PANEL_LABEL_FONT, iced_bold_font, PANEL_VALUE_FONT, iced_bold_font, PANEL_LABEL_STRING, "Dir: ", PANEL_VALUE, current_directory, PANEL_MENU_TITLE_STRING, " Current Directory", PANEL_MENU_CHOICE_FONTS, iced_bold_font,0, PANEL_MENU_CHOICE_STRINGS, " ^L - Load image from file", " ^S - Store image to file", " ^B - Browse directory", " ^Q - Quit", 0, PANEL_MENU_CHOICE_VALUES, CTRL_L, CTRL_S, CTRL_B, CTRL_Q, 0, PANEL_SHOW_MENU, TRUE, PANEL_NOTIFY_LEVEL, PANEL_ALL, PANEL_NOTIFY_PROC, dir_proc, 0); iced_fname_item = panel_create_item(iced_panel, PANEL_TEXT, PANEL_LABEL_X, 10, PANEL_LABEL_Y, row2, PANEL_VALUE_DISPLAY_LENGTH,21, PANEL_LABEL_FONT, iced_bold_font, PANEL_LABEL_BOLD, FALSE, PANEL_LABEL_STRING, "File:", PANEL_NOTIFY_LEVEL, PANEL_ALL, PANEL_MENU_TITLE_STRING, " Current File", PANEL_MENU_CHOICE_FONTS, iced_bold_font,0, PANEL_MENU_CHOICE_STRINGS, "ESC - Filename completion", " ^L - Load image from file", " ^S - Store image to file", " ^B - Browse directory", " ^Q - Quit", 0, PANEL_MENU_CHOICE_VALUES, ESC, CTRL_L, CTRL_S, CTRL_B, CTRL_Q, 0, PANEL_SHOW_MENU, TRUE, PANEL_VALUE_FONT, iced_bold_font, PANEL_NOTIFY_PROC, fname_proc, 0); iced_load_item = panel_create_item(iced_panel, PANEL_BUTTON, PANEL_LABEL_X, 10, PANEL_LABEL_Y, row3, PANEL_LABEL_IMAGE, panel_button_image(iced_panel,"Load",4,iced_bold_font), PANEL_SHOW_MENU, TRUE, PANEL_MENU_CHOICE_STRINGS, "Load image from file",0, PANEL_MENU_CHOICE_FONTS, iced_bold_font,0, PANEL_NOTIFY_PROC, iced_load_proc, 0); iced_store_item = panel_create_item(iced_panel, PANEL_BUTTON, PANEL_LABEL_X, 60, PANEL_LABEL_Y, row3, PANEL_LABEL_IMAGE, panel_button_image(iced_panel,"Store",5,iced_bold_font), /* PANEL_SHOW_MENU, TRUE, PANEL_MENU_CHOICE_STRINGS, "Store image to file", 0, */ PANEL_MENU_CHOICE_FONTS, iced_bold_font,0, PANEL_NOTIFY_PROC, store_proc, PANEL_EVENT_PROC, store_button_event_proc, 0); store_menu = menu_create(MENU_STRINGS, "Store entire image", "Store trimmed image", 0, 0); iced_browse_item = panel_create_item(iced_panel, PANEL_BUTTON, PANEL_LABEL_X, 118, PANEL_LABEL_Y, row3, PANEL_LABEL_IMAGE, panel_button_image(iced_panel,"Browse",6,iced_bold_font), PANEL_SHOW_MENU, TRUE, PANEL_MENU_CHOICE_STRINGS, "Browse images in current directory",0, PANEL_MENU_CHOICE_FONTS, iced_bold_font,0, PANEL_NOTIFY_PROC, iced_browse_proc, 0); iced_quit_item = panel_create_item(iced_panel, PANEL_BUTTON, PANEL_LABEL_X, 184, PANEL_LABEL_Y, row3, PANEL_LABEL_IMAGE, panel_button_image(iced_panel,"Quit",4,iced_bold_font), PANEL_NOTIFY_PROC, quit_proc, 0); iced_size_item = panel_create_item(iced_panel, PANEL_CYCLE, PANEL_ITEM_X, 10, PANEL_ITEM_Y, row4 - 4, PANEL_MARK_YS, row4, 0, PANEL_LABEL_STRING, "Size", PANEL_CHOICE_STRINGS, "Icon", "Cursor", 0, PANEL_NOTIFY_PROC, size_proc, 0); iced_grid_item = panel_create_item(iced_panel, PANEL_CYCLE, PANEL_ITEM_X, 145, PANEL_ITEM_Y, row4 - 4, PANEL_LABEL_STRING, "Grid", PANEL_MARK_YS, row4, 0, PANEL_CHOICE_STRINGS, "Off", "On", 0, PANEL_NOTIFY_PROC, grid_proc, 0); /* iced_size_item = panel_create_item(iced_panel, PANEL_CYCLE, PANEL_ITEM_X, 10, PANEL_ITEM_Y, 88, PANEL_LABEL_FONT, iced_bold_font, PANEL_CHOICE_FONTS, iced_bold_font, 0, PANEL_LABEL_BOLD, FALSE, PANEL_LABEL_STRING, "Size:", PANEL_CHOICE_STRINGS, "Icon", "Cursor", 0, PANEL_MENU_CHOICE_FONTS, iced_bold_font,0, PANEL_MENU_TITLE_STRING, "Canvas Size", PANEL_MENU_TITLE_FONT, iced_bold_font, PANEL_MENU_CHOICE_STRINGS, "Icon (64 x 64)", "Cursor (16 x 16)", 0, PANEL_NOTIFY_PROC, size_proc, 0); iced_grid_item = panel_create_item(iced_panel, PANEL_CYCLE, PANEL_ITEM_X, 135, PANEL_ITEM_Y, 88, PANEL_LABEL_STRING, "Grid:", PANEL_LABEL_FONT, iced_bold_font, PANEL_CHOICE_FONTS, iced_bold_font, 0, PANEL_LABEL_BOLD, FALSE, PANEL_CHOICE_STRINGS, "On", "Off", 0, PANEL_MENU_TITLE_STRING, "Canvas Grid ", PANEL_MENU_TITLE_FONT, iced_bold_font, PANEL_MENU_CHOICE_STRINGS, "Off","On",0, PANEL_MENU_CHOICE_FONTS, iced_bold_font,0, PANEL_NOTIFY_PROC, grid_proc, 0); */ /* iced_size_item = panel_create_item(iced_panel, PANEL_CHOICE, PANEL_LABEL_X, 23, PANEL_LABEL_Y, 61, PANEL_LABEL_FONT, iced_bold_font, PANEL_LABEL_BOLD, FALSE, PANEL_LABEL_STRING, "Size:", PANEL_FEEDBACK, PANEL_MARKED, PANEL_MARK_IMAGES, &tri_right,0, PANEL_NOMARK_IMAGES, 0, PANEL_CHOICE_FONTS, iced_bold_font, 0, PANEL_CHOICE_STRINGS, "Icon", "Cursor", 0, PANEL_MARK_XS, 76,133,0, PANEL_MARK_YS, row3 + 4,0, PANEL_CHOICE_XS, 90,146,0, PANEL_CHOICE_YS, row3 + 2,0, PANEL_MENU_CHOICE_FONTS, iced_bold_font,0, PANEL_MENU_TITLE_STRING, "Canvas Size", PANEL_MENU_TITLE_FONT, iced_bold_font, PANEL_MENU_CHOICE_STRINGS, "Icon (64 x 64)", "Cursor (16 x 16)", 0, PANEL_NOTIFY_PROC, size_proc,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -