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

📄 canvas.c

📁 操作系统SunOS 4.1.3版本的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
    }    if (new_v_sb)	canvas_setup_scrollbar(canvas, SCROLL_VERTICAL, v_sb);    if (new_h_sb)	canvas_setup_scrollbar(canvas, SCROLL_HORIZONTAL, h_sb);    show_updates = (int) window_get((Window)(LINT_CAST(canvas)),    			WIN_SHOW_UPDATES);    /* If new h_sb or v_sb and client allows updates, ask     * for repaint. If updates are not allowed set the dirty bit.     */    if (new_v_sb || new_h_sb)        if (show_updates) 	   repaint = TRUE;       else 	   status_set(canvas, dirty);    if (new_pw_size || new_canvas_size || new_v_sb || new_h_sb)	canvas_update_scrollbars(canvas, !repaint && show_updates);    if (repaint) {	/* the canvas has changed and the client	 * allows the updates to be shown, so repaint.	 * Make sure we can repaint all of the dirty areas.	 */	(void)pw_exposed(canvas->pw);	canvas_repaint_window(canvas);    }    return ok;}/* ARGSUSED */static caddr_tcanvas_get(canvas, attr, arg1, arg2, arg3)register Canvas_info	*canvas;Canvas_attribute	attr;{    switch (attr) {	case CANVAS_PIXWIN:	    return (caddr_t) canvas->pw;	case CANVAS_FAST_MONO:	    return (caddr_t) (canvas->pw->pw_pixrect->pr_depth == 1);	case CANVAS_WIDTH:	    return (caddr_t) canvas_width(canvas);	case CANVAS_HEIGHT:	    return (caddr_t) canvas_height(canvas);	case CANVAS_LEFT:	    return (caddr_t) canvas_left(canvas);	case CANVAS_TOP:	    return (caddr_t) canvas_top(canvas);	case CANVAS_DEPTH:	    return (caddr_t) canvas->depth;	case CANVAS_REPAINT_PROC:	    return (caddr_t) (LINT_CAST(canvas->repaint_proc));	case CANVAS_RESIZE_PROC:	    return (caddr_t) (LINT_CAST(canvas->resize_proc));	case CANVAS_AUTO_CLEAR:	    return (caddr_t) status(canvas, auto_clear);	case CANVAS_AUTO_EXPAND:	    return (caddr_t) status(canvas, auto_expand);	case CANVAS_AUTO_SHRINK:	    return (caddr_t) status(canvas, auto_shrink);	case CANVAS_RETAINED:	    return (caddr_t) status(canvas, retained);	case CANVAS_FIXED_IMAGE:	    return (caddr_t) status(canvas, fixed_image);	case WIN_VERTICAL_SCROLLBAR:	    return (caddr_t) canvas_sb(canvas, SCROLL_VERTICAL);	case WIN_HORIZONTAL_SCROLLBAR:	    return (caddr_t) canvas_sb(canvas, SCROLL_HORIZONTAL); 	case HELP_DATA: 	    return canvas->help_data;	default:	    return (caddr_t) 0;    }}/* translate a canvas-space event to a * window-space event. */Event *canvas_window_event(canvas_client, event)register Canvas		canvas_client;register Event		*event;{    Canvas_info		*canvas;    canvas = (Canvas_info *)(LINT_CAST(canvas_client));    event_set_x(event, event_x(event) - canvas_x_offset(canvas) + 		view_left(canvas));    event_set_y(event, event_y(event) - canvas_y_offset(canvas) +		view_top(canvas));    return event;}/* translate a window-space event to a * canvas-space event. */Event *canvas_event(canvas_client, event)register Canvas		canvas_client;register Event		*event;{    Canvas_info		*canvas;    canvas = (Canvas_info *)(LINT_CAST(canvas_client));    event_set_x(event, event_x(event) + canvas_x_offset(canvas) - 		view_left(canvas));    event_set_y(event, event_y(event) + canvas_y_offset(canvas) -		view_top(canvas));    return event;}/* ARGSUSED */static Notify_valuecanvas_handle_event(canvas, event, arg, type)register Canvas_info	*canvas;register Event		*event;Notify_arg		arg;Notify_event_type	type;{    register short	has_position	= FALSE;    short		pass_through	= TRUE;    short	is_in_view;    /* by default, we assume the event is one that     * should be passed through to the client, and that it does     * not have a position (e.g. WIN_REPAINT or ascii).     */    switch (event_action(event)) {	case WIN_REPAINT:	    /* if we still have never called the resize proc,	     * call it now.	     */	    if (!status(canvas, first_resize)) {		status_set(canvas, first_resize);		canvas_inform_resize(canvas);	    }	    canvas_repaint_window(canvas);	    break;	case WIN_RESIZE: {	    Rect	*rect = (Rect *) (LINT_CAST(window_get(	    		    (Window)(LINT_CAST(canvas)), WIN_RECT)));	    Function	resize_proc;	    /* if this is the first resize event,	     * make sure canvas_resize_pixwin() does	     * not call the resize proc, then	     * call it for sure below.	     */	    if (!status(canvas, first_resize)) {		resize_proc = canvas->resize_proc;		canvas->resize_proc = 0;	    }	    if (rect->r_width != win_width(canvas) || 		rect->r_height != win_height(canvas)) {		canvas->win_rect = *rect;		(void) canvas_resize_pixwin(canvas, FALSE);		canvas_update_scrollbars(canvas, FALSE);	    }	    /* if we still have never called the resize proc,	     * call it now.	     */	    if (!status(canvas, first_resize)) {		canvas->resize_proc = resize_proc;		status_set(canvas, first_resize);		canvas_inform_resize(canvas);	    }	    break;	}	case SCROLL_REQUEST:	    canvas_scroll(canvas, (Scrollbar) arg);	    break;	case KBD_USE:	    /* hilite the border if ascii events	     * are enabled in the input mask.	     */	    if (window_get((Window)(LINT_CAST(canvas)),	    		WIN_CONSUME_KBD_EVENT, WIN_ASCII_EVENTS))		(void)tool_kbd_use((struct tool *)(LINT_CAST(			window_get((Window)(LINT_CAST(canvas)),	WIN_OWNER))), 			(char *)(LINT_CAST(canvas)));	    break;	case KBD_REQUEST:	    /* accept the keyboard request only if ascii events	     * are enabled in the input mask.	     */	    if (!window_get((Window)(LINT_CAST(canvas)),	    	WIN_CONSUME_KBD_EVENT, WIN_ASCII_EVENTS)) 		(void)win_refuse_kbd_focus((int)(LINT_CAST(window_get(			(Window)(LINT_CAST(canvas)), WIN_FD))));	    break;	case KBD_DONE:	    (void)tool_kbd_done((struct tool *)(LINT_CAST(	    	window_get((Window)(LINT_CAST(canvas)),	WIN_OWNER))), 		(char *)(LINT_CAST(canvas)));	    break;	case LOC_RGNENTER:	    /* let this event through when mouse moves from scrollbar 	     * directly into canvas. 	     */	    if (status(canvas, in_view))                return NOTIFY_DONE;            else {	        is_in_view = rect_includespoint(view_rect(canvas),                             event_x(event), event_y(event));                if (is_in_view) {	            status_set(canvas, in_view);                    break;		}	    }	case LOC_RGNEXIT:	    /* let this event through when mouse moves from canvas 	     * directly into scrollbar. 	     */            if (!status(canvas, in_view))                return NOTIFY_DONE;            else {                is_in_view = rect_includespoint(view_rect(canvas),                             event_x(event), event_y(event));                 if (!is_in_view) {                    status_reset(canvas, in_view);                    break;		}	    }	case LOC_MOVE:	case LOC_STILL:	case LOC_WINENTER:	case LOC_WINEXIT:	case LOC_DRAG:	case LOC_TRAJECTORY:	    /* all these have an (x, y) position */	    has_position = TRUE;	    break;	/* 	 * BUG: see the BUG comments in canvas_window_object	 */	case ACTION_PROPS:	case ACTION_OPEN:	case ACTION_FRONT:	case ACTION_CLOSE:	case ACTION_BACK:	    tool_input(window_get((Window)canvas, WIN_OWNER), event,	    		(Notify_arg)0, NOTIFY_SAFE);	    break; 	case ACTION_HELP: 	    if (canvas->help_data != NULL) { 		if (event_is_down(event)) 	            help_request((Window)(LINT_CAST(canvas)), 				 canvas->help_data, event); 		return NOTIFY_DONE; 	    } 	    has_position = TRUE; 	    break;	default:	    if (event_is_button(event))		has_position = TRUE;	    break;    }    if (has_position) {	/* this event has an (x, y) position, so see	 * if it is in the canvas pixwin region.	 */	is_in_view = rect_includespoint(view_rect(canvas), 	    event_x(event), event_y(event));	/* map to region enter/exit if needed */	if (is_in_view) {	    if (!status(canvas, in_view)) {		/* this event is in the view, and the last		 * event was not, so map this event to a		 * region-enter.		 */		event_set_id(event, LOC_RGNENTER);		status_set(canvas, in_view);	    }	} else if (status(canvas, in_view)) {	    /* this event is not in the view, and the last	     * event was, so map this event to a	     * region-exit.	     */	    event_set_id(event, LOC_RGNEXIT);	    status_reset(canvas, in_view);	} else	    /* this event is not in the view, and the last	     * event was also not in the view, so don't pass	     * this event through.	     */	    pass_through = FALSE;    }    /* call the client event proc,     * if any.     */    if (pass_through || win_is_io_grabbed((int)window_get(    		(Window)(LINT_CAST(canvas)), WIN_FD)))	window_event_proc(((Window)(LINT_CAST(canvas))), 		canvas_event((Canvas)(LINT_CAST(canvas)), event), arg);    return NOTIFY_DONE;}static Notify_valuecanvas_destroy(canvas, stat)register Canvas_info	*canvas;Destroy_status		stat;{    Scrollbar	sb;    if (stat == DESTROY_CHECKING)       return NOTIFY_IGNORED;    if (stat == DESTROY_CLEANUP) {       if (sb = canvas_sb(canvas, SCROLL_VERTICAL))         (void)notify_post_destroy(sb, stat, NOTIFY_IMMEDIATE);       if (sb = canvas_sb(canvas, SCROLL_HORIZONTAL))         (void)notify_post_destroy(sb, stat, NOTIFY_IMMEDIATE);    }    if (status(canvas, retained) && canvas_pr(canvas)) {	(void)pr_destroy(canvas_pr(canvas));	canvas_set_pr(canvas, 0);    }    (void)pw_close(canvas->pw);    free((char *)(LINT_CAST(canvas)));    return NOTIFY_DONE;}

⌨️ 快捷键说明

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