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

📄 scrolldefaults.c

📁 操作系统SunOS 4.1.3版本的源码
💻 C
📖 第 1 页 / 共 3 页
字号:
#ifndef lint#ifdef sccsstatic  char sccsid[] = "@(#)scrolldefaults.c 1.1 92/07/30 Copyr 1985 Sun Micro";#endif#endif/**************************************************************************//* 			scrolldefaults.c                                  *//**************************************************************************/#include <stdio.h>#include <strings.h>#include <suntool/sunview.h>#include <suntool/panel.h>#include <suntool/scrollbar.h>#include <sunwindow/defaults.h>#include <suntool/textsw.h>#ifdef STANDALONE#define EXIT(n)		exit(n)#else#define EXIT(n)		return(n)#endif/* Panel notify procs */static void     save_proc();static void     default_proc();static void     quit_proc();static void     have_v_sb_proc();static void     have_h_sb_proc();static void     use_normalize_proc();static void     h_gravity_proc();static void     v_gravity_proc();static void     bar_display_proc();static void     bubble_display_proc();static void     have_buttons_proc();static void     show_active_proc();static void     bar_width_proc();static void     end_point_area_proc();static void     repeat_proc();static void     button_length_proc();static void     bubble_margin_proc();static void     bubble_color_proc();static void     bar_color_proc();static void     border_proc();/* Misc init & util procs */static void	init_text();static void	init_control();static void	set_panel_from_scrollbars();static void	init_panel();/* Windows and Panel items */static Frame    base_frame;static Panel    control, panel;static Textsw   msg_textsw;static Panel_item have_v_sb_item;static Panel_item have_h_sb_item;static Panel_item h_gravity_item;static Panel_item v_gravity_item;static Panel_item bar_display_item;static Panel_item bubble_display_item;static Panel_item have_buttons_item;static Panel_item bar_width_item;static Panel_item button_length_item;static Panel_item end_point_area_item;static Panel_item repeat_item;static Panel_item bubble_margin_item;static Panel_item bubble_color_item;static Panel_item bar_color_item;static Panel_item border_item;/* statics */static int      texttoo = FALSE;static int      debugging = FALSE;static char     Textsw_string[4000];static int      my_margin = 15;static int      my_gap = 5;static int      my_row_height = 55;static int      my_col_width = 110;static Scrollbar vertical_sb, horizontal_sb;/* Note: these defaults should be in scrollbar.h!! */#define HORIZ_PLACEMENT_DEFAULT	SCROLL_NORTH#define VERT_PLACEMENT_DEFAULT	SCROLL_WEST#define BAR_DISPLAY_DEFAULT	SCROLL_ALWAYS#define BAR_THICKNESS_DEFAULT	14#define BAR_COLOR_DEFAULT	SCROLL_GREY#define BUBBLE_DISPLAY_DEFAULT	SCROLL_ALWAYS#define BUBBLE_MARGIN_DEFAULT	0#define BUBBLE_COLOR_DEFAULT    SCROLL_GREY#define BUTTON_DISPLAY_DEFAULT	TRUE#define BUTTON_LENGTH_DEFAULT	15#define BORDER_DEFAULT		TRUE#define END_POINT_AREA_DEFAULT	6#define REPEAT_TIME_DEFAULT	10#define MIN_THICKNESS		2/* Icons */static short icon_data[] = {#include <images/scrollbar_demo.icon>};static short folder_data[] = {    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,    0x0000, 0x0000, 0x007F, 0xFFC0, 0x0000, 0x0000, 0x0080, 0x0040,    0x3FFF, 0xFFFF, 0xFF80, 0x0020, 0x4000, 0x0000, 0x0080, 0x0030,    0x4000, 0x0000, 0x007F, 0xFFE8, 0x8000, 0x0000, 0x0000, 0x0034,    0x8000, 0x0000, 0x0000, 0x002A, 0x8000, 0x0000, 0x0000, 0x0034,    0x8000, 0x0000, 0x0000, 0x002A, 0x8000, 0x0000, 0x0000, 0x0034,    0x8000, 0x0000, 0x0000, 0x002A, 0x8000, 0x0000, 0x0000, 0x0034,    0x8000, 0x0000, 0x0000, 0x002A, 0x8000, 0x0000, 0x0000, 0x0034,    0x8000, 0x0000, 0x0000, 0x002A, 0x8000, 0x0000, 0x0000, 0x0034,    0x8000, 0x0000, 0x0000, 0x002A, 0x8000, 0x0000, 0x0000, 0x0034,    0x8000, 0x0000, 0x0000, 0x002A, 0x8000, 0x0000, 0x0000, 0x0034,    0x8000, 0x0000, 0x0000, 0x002A, 0x8000, 0x0000, 0x0000, 0x0034,    0x8000, 0x0000, 0x0000, 0x002A, 0x8000, 0x0000, 0x0000, 0x0034,    0x8000, 0x0000, 0x0000, 0x002A, 0x8000, 0x0000, 0x0000, 0x0034,    0x8000, 0x0000, 0x0000, 0x002A, 0x8000, 0x0000, 0x0000, 0x0034,    0x8000, 0x0000, 0x0000, 0x002A, 0x8000, 0x0000, 0x0000, 0x0034,    0x8000, 0x0000, 0x0000, 0x002A, 0x8000, 0x0000, 0x0000, 0x0034,    0x8000, 0x0000, 0x0000, 0x002A, 0x8000, 0x0000, 0x0000, 0x0034,    0x8000, 0x0000, 0x0000, 0x002A, 0x8000, 0x0000, 0x0000, 0x0034,    0x8000, 0x0000, 0x0000, 0x002A, 0x8000, 0x0000, 0x0000, 0x0034,    0x8000, 0x0000, 0x0000, 0x002A, 0x8000, 0x0000, 0x0000, 0x0034,    0x8000, 0x0000, 0x0000, 0x002A, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFF4,    0x2AAA, 0xAAAA, 0xAAAA, 0xAAAA, 0x1555, 0x5555, 0x5555, 0x5554,    0x0AAA, 0xAAAA, 0xAAAA, 0xAAAA, 0x0555, 0x5555, 0x5555, 0x5554};static short paper_data[] = {    0x000F, 0xFFFF, 0xFFE0, 0x0000, 0x0008, 0x0000, 0x0030, 0x0000,    0x0008, 0x0000, 0x0028, 0x0000, 0x0008, 0x0000, 0x0024, 0x0000,    0x0008, 0x0000, 0x0022, 0x0000, 0x0008, 0x0000, 0x0021, 0x0000,    0x0008, 0x0000, 0x0020, 0x8000, 0x0008, 0x0000, 0x0020, 0x4000,    0x0008, 0x0000, 0x0020, 0x2000, 0x0008, 0x0000, 0x003F, 0xF000,    0x0008, 0x0000, 0x0000, 0x1000, 0x0008, 0x0000, 0x0000, 0x1000,    0x0008, 0x0000, 0x0000, 0x1000, 0x0008, 0x0000, 0x0000, 0x1000,    0x0008, 0x0000, 0x0000, 0x1000, 0x0008, 0x0000, 0x0000, 0x1000,    0x0008, 0x0000, 0x0000, 0x1000, 0x0008, 0x0000, 0x0000, 0x1000,    0x0008, 0x0000, 0x0000, 0x1000, 0x0008, 0x0000, 0x0000, 0x1000,    0x0008, 0x0000, 0x0000, 0x1000, 0x0008, 0x0000, 0x0000, 0x1000,    0x0008, 0x0000, 0x0000, 0x1000, 0x0008, 0x0000, 0x0000, 0x1000,    0x0008, 0x0000, 0x0000, 0x1000, 0x0008, 0x0000, 0x0000, 0x1000,    0x0008, 0x0000, 0x0000, 0x1000, 0x0008, 0x0000, 0x0000, 0x1000,    0x0008, 0x0000, 0x0000, 0x1000, 0x0008, 0x0000, 0x0000, 0x1000,    0x0008, 0x0000, 0x0000, 0x1000, 0x0008, 0x0000, 0x0000, 0x1000,    0x0008, 0x0000, 0x0000, 0x1000, 0x0008, 0x0000, 0x0000, 0x1000,    0x0008, 0x0000, 0x0000, 0x1000, 0x0008, 0x0000, 0x0000, 0x1000,    0x0008, 0x0000, 0x0000, 0x1000, 0x0008, 0x0000, 0x0000, 0x1000,    0x0008, 0x0000, 0x0000, 0x1000, 0x0008, 0x0000, 0x0000, 0x1000,    0x0008, 0x0000, 0x0000, 0x1000, 0x0008, 0x0000, 0x0000, 0x1000,    0x0008, 0x0000, 0x0000, 0x1000, 0x0008, 0x0000, 0x0000, 0x1000,    0x0008, 0x0000, 0x0000, 0x1000, 0x0008, 0x0000, 0x0000, 0x1000,    0x0008, 0x0000, 0x0000, 0x1000, 0x0008, 0x0000, 0x0000, 0x1000,    0x0008, 0x0000, 0x0000, 0x1000, 0x0008, 0x0000, 0x0000, 0x1000,    0x0008, 0x0000, 0x0000, 0x1000, 0x000F, 0xFFFF, 0xFFFF, 0xF000};mpr_static(scrd_icon_image, 64, 64, 1, icon_data);mpr_static(scrd_folder_image, 64, 52, 1, folder_data);mpr_static(scrd_paper_image, 64, 52, 1, paper_data);/**************************************************************************//* main                                                                   *//**************************************************************************/#ifdef STANDALONEmain(argc,argv)#elseint scrolldefaults_main(argc,argv)#endif    int             argc;    char          **argv;{/*    moncontrol (0); */    defaults_special_mode();    base_frame = window_create((Window)NULL, FRAME,	FRAME_ARGC_PTR_ARGV, &argc, argv,	FRAME_LABEL, "scrolldefaults",	FRAME_ICON, icon_create(ICON_IMAGE, &scrd_icon_image, 0),	WIN_ROWS, 26,	WIN_ERROR_MSG, "base frame error!",	0);    if (base_frame == NULL) {        (void)fprintf(stderr,"defaultstool: unable to create frame\n");        exit(1);    }    my_row_height += (int) window_get(base_frame, WIN_ROW_HEIGHT);    argv++;    argc--;    while (argc > 0 && **argv == '-') {	switch (argv[0][1]) {	case 'm':	    my_margin = atoi(&argv[0][2]);	    break;	case 'g':	    my_gap = atoi(&argv[0][2]);	    break;	case 't':	    texttoo = TRUE;	    break;	case '?':	case 'h':	    (void)printf ("Usage: scrolldefaults [-t] [-d] [-gN] [-mN]\n");	    (void)printf ("Options:\n");	    (void)printf ("    -t     Text window too.\n");	    (void)printf ("    -d     Debug mode\n");	    (void)printf ("    -gN    Gap    = N pixels (for SCROLL_TO_GRID)\n");	    (void)printf ("    -mN    Margin = N pixels (for SCROLL_TO_GRID)\n");	    EXIT(0);	case 'd':	    debugging = TRUE;	    /* test stuff here */	    break;	}	argv++;	argc--;    }    my_row_height += my_gap;    my_col_width  += my_gap;    vertical_sb = scrollbar_create(	SCROLL_MARGIN, my_margin,	SCROLL_GAP,    my_gap,	0);    horizontal_sb = scrollbar_create(	SCROLL_MARGIN, my_margin,	SCROLL_GAP,    my_gap,	0);    if (debugging) {        (void)printf("Scrollbar_thickness=%d\n",	    scrollbar_get(vertical_sb, SCROLL_THICKNESS));        (void)printf("Scrollbar_end_point_area=%d\n",	    scrollbar_get(vertical_sb, SCROLL_END_POINT_AREA));	(void)printf("Scrollbar_repeat_time=%d\n",	    scrollbar_get (vertical_sb, SCROLL_REPEAT_TIME));    }    init_panel();    init_control();    if (texttoo)	init_text(TRUE);    (void)window_fit(base_frame);    window_main_loop(base_frame);        EXIT(0);}/**************************************************************************//* initialize panels                                                      *//**************************************************************************/static voidinit_text(first_time)    int             first_time;{    if (first_time)	while (strlen(Textsw_string) < sizeof(Textsw_string) - 500) {	    (void)strcat(Textsw_string, "Jjfkd sone ofhtr aos\n");	    (void)strcat(Textsw_string, "hroehnf lceh. Fho\n");	    (void)strcat(Textsw_string, "blux vah? Boen tgrf!\n");	    (void)strcat(Textsw_string, "Mani hfi do ehf os fh\n");	    (void)strcat(Textsw_string, "jf id hf ikdjf odfj.\n\n");	}    else	textsw_destroy(msg_textsw);    msg_textsw = (Textsw)(LINT_CAST(window_create(   	(Window)(LINT_CAST(base_frame)), TEXTSW,	WIN_COLUMNS, 25,	TEXTSW_CONTENTS, Textsw_string,	WIN_ERROR_MSG, "textsw creation error!",	0)));    if (msg_textsw == NULL) {         (void)fprintf(stderr,"defaultstool: unable to create message window\n");         exit(1);     }}static voidinit_control(){    int		row = 0;        control = window_create(base_frame, PANEL,	WIN_ERROR_MSG, "panel creation error!",	0);    if (control == NULL) {         (void)fprintf(stderr,"defaultstool: unable to create panel\n");         exit(1);     }    (void)panel_create_item(control, PANEL_MESSAGE,	PANEL_LABEL_BOLD, TRUE,	PANEL_LABEL_X, ATTR_COL(0), PANEL_LABEL_Y, ATTR_ROW(row++),	PANEL_LABEL_STRING, "   User Settable Defaults",	0);    v_gravity_item = panel_create_item(control, PANEL_CYCLE,	PANEL_LABEL_X, ATTR_COL(0), PANEL_LABEL_Y, ATTR_ROW(row++),	PANEL_LABEL_STRING, " Vert. Bar Placement",	PANEL_CHOICE_STRINGS, "West ", "East", 0,	PANEL_NOTIFY_PROC, v_gravity_proc,	0);    h_gravity_item = panel_create_item(control, PANEL_CYCLE,	PANEL_LABEL_X, ATTR_COL(0), PANEL_LABEL_Y, ATTR_ROW(row++),	PANEL_LABEL_STRING, "Horiz. Bar Placement",	PANEL_CHOICE_STRINGS, "North", "South", 0,	PANEL_NOTIFY_PROC, h_gravity_proc,	0);    bubble_display_item = panel_create_item(control, PANEL_CYCLE,	PANEL_LABEL_X, ATTR_COL(0), PANEL_LABEL_Y, ATTR_ROW(row++),	PANEL_LABEL_STRING, "         Show Bubble",	PANEL_CHOICE_STRINGS, "Always", "Active", "Never", 0,	PANEL_MENU_CHOICE_STRINGS, "Always", "Active (when in scrollbar)",	"Never", 0,	PANEL_NOTIFY_PROC, bubble_display_proc,	0);    bar_display_item = panel_create_item(control, PANEL_CYCLE,	PANEL_LABEL_X, ATTR_COL(0), PANEL_LABEL_Y, ATTR_ROW(row++),	PANEL_LABEL_STRING, "            Show Bar",	PANEL_CHOICE_STRINGS, "Always", "Active", "Never", 0,	PANEL_MENU_CHOICE_STRINGS, "Always",	"Active (when in scrollbar)",	"Never", 0,	PANEL_NOTIFY_PROC, bar_display_proc,	0);    bubble_color_item = panel_create_item(control, PANEL_CYCLE,	PANEL_LABEL_X, ATTR_COL(0), PANEL_LABEL_Y, ATTR_ROW(row++),	PANEL_LABEL_STRING, "        Bubble Color",	PANEL_CHOICE_STRINGS, "Grey", "Black", 0,	PANEL_NOTIFY_PROC, bubble_color_proc,	0);    bar_color_item = panel_create_item(control, PANEL_CYCLE,	PANEL_LABEL_X, ATTR_COL(0), PANEL_LABEL_Y, ATTR_ROW(row++),	PANEL_LABEL_STRING, "           Bar Color",	PANEL_CHOICE_STRINGS, "Grey", "White", 0,	PANEL_NOTIFY_PROC, bar_color_proc,	0);    bubble_margin_item = panel_create_item(control, PANEL_CYCLE,	PANEL_LABEL_X, ATTR_COL(0), PANEL_LABEL_Y, ATTR_ROW(row++),	PANEL_LABEL_STRING, "       Bubble Margin",	PANEL_CHOICE_STRINGS, "0", "1", "2", "3", "4", "5", "6", "7", "8", 0,	PANEL_NOTIFY_PROC, bubble_margin_proc,	0);

⌨️ 快捷键说明

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