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

📄 tool_bdry.c

📁 操作系统SunOS 4.1.3版本的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
		if (borders_on == BORDERS_NONE)			continue;				tool_compute_constraint(tool, sw, &rconstrain);				switch (borders_on) {		case BORDERS_LEFT:			hole = rect_right(&rconstrain) - rect_right(r);			if (hole > 0)				r->r_width += hole;			break;					case BORDERS_RIGHT:			hole = r->r_left - rconstrain.r_left;			if (hole > 0) {				r->r_width += hole;				r->r_left = rconstrain.r_left;			}			break;					case BORDERS_TOP:			hole = rect_bottom(&rconstrain) - rect_bottom(r);			if (hole > 0)				r->r_height += hole;			break;					case BORDERS_BOTTOM:			hole = r->r_top - rconstrain.r_top;			if (hole > 0) {				r->r_height += hole;				r->r_top = rconstrain.r_top;			}			break;		}					rect_marginadjust(r, -swsp);		sw_set_rect(sw, r, tool_left, tool_top, tool_right,		            tool_bottom);	}		rect_marginadjust(old_rect, -(swsp + 1));	(void)win_unlockdata(tool->tl_windowfd);}/* Compute the border relationship of * neighbor_rect to target_rect. */static Borderrect_border(neighbor_rect, target_rect)register Rect	*neighbor_rect;register Rect	*target_rect;{	if (rect_right(neighbor_rect) == (target_rect->r_left - 1))		return BORDERS_LEFT;			if (neighbor_rect->r_left == (rect_right(target_rect) + 1))		return BORDERS_RIGHT;			if (rect_bottom(neighbor_rect) == (target_rect->r_top - 1))		return BORDERS_TOP;			if (neighbor_rect->r_top == (rect_bottom(target_rect) + 1))		return BORDERS_BOTTOM;		return BORDERS_NONE;}		/* Constrain target_sw according to * its shadows.  rconstrain is computed as the tallest, lowest, and * widest that target_sw can be.  Note that if tool is iconic, * rconstrain will be offset by the usual TOOL_ICONIC_OFFSET. */void		tool_compute_constraint(tool, target_sw, rconstrain)Tool		*tool;Toolsw		*target_sw;register Rect	*rconstrain;{	Toolsw		*sw;	Rect		rect;	register int	constraint;	register short	swsp = tool_subwindowspacing(tool) / 2;	Rect		left_rect, right_rect;	Rect		top_rect, bottom_rect;	register Rect	*left_shadow = &left_rect, *right_shadow = &right_rect;	register Rect	*top_shadow = &top_rect, *bottom_shadow = &bottom_rect;		constrain_from_tool(tool, rconstrain);	/* compute constraint for the outer borders */	rect_marginadjust(rconstrain, swsp);		compute_shadows(tool, target_sw, left_shadow, right_shadow, 			top_shadow, bottom_shadow);					/* For each subwindow in the shadow */	for (sw = tool->tl_sw; sw; sw = sw->ts_next) {		if (sw == target_sw)			continue;					(void)win_getrect(sw->ts_windowfd, &rect);		rect_marginadjust(&rect, swsp + 1);				if (rect_intersectsrect(&rect, left_shadow)) {			constraint = rect_right(&rect) + 1;			if (constraint > rconstrain->r_left) {				rconstrain->r_width -=					 constraint - rconstrain->r_left;				rconstrain->r_left = constraint;			}		} else if (rect_intersectsrect(&rect, right_shadow)) {			constraint = rect.r_left - 1;			if (constraint < rect_right(rconstrain))				rconstrain->r_width -= 				    rect_right(rconstrain) - constraint;		}		if (rect_intersectsrect(&rect, top_shadow)) {			constraint = rect_bottom(&rect) + 1;			if (constraint > rconstrain->r_top) {				rconstrain->r_height -=					 constraint - rconstrain->r_top;				rconstrain->r_top = constraint;			}		} else if (rect_intersectsrect(&rect, bottom_shadow)) {			constraint = rect.r_top - 1;			if (constraint < rect_bottom(rconstrain))				rconstrain->r_height -= 				    rect_bottom(rconstrain) - constraint;		}	}}/* Compute the shadow rects * for target_sw. */static voidcompute_shadows(tool, target_sw, left_shadow, right_shadow,	        top_shadow, bottom_shadow)register Tool	*tool;Toolsw		*target_sw;register Rect	*left_shadow, *right_shadow;register Rect	*top_shadow, *bottom_shadow;{	Rect	target_rect;	/* Compute the min & max shadow rects */	(void)win_getrect(target_sw->ts_windowfd, &target_rect);	rect_construct(left_shadow,			0, target_rect.r_top, 			target_rect.r_left, target_rect.r_height);	rect_construct(right_shadow,			rect_right(&target_rect), target_rect.r_top, 			tool->tl_rectcache.r_width - rect_right(&target_rect), 			target_rect.r_height);		      	rect_construct(top_shadow,			target_rect.r_left, 0, 			target_rect.r_width, target_rect.r_top);	rect_construct(bottom_shadow, target_rect.r_left, 			rect_bottom(&target_rect), 			target_rect.r_width, 			tool->tl_rectcache.r_height - target_rect.r_top);}		/* Change target_sw to new_rect and contort any * obstacles. */		     static voidchange_sw(tool, target_sw, new_rect, wants_fill)Tool	*tool;Toolsw	*target_sw;Rect	*new_rect;int	 wants_fill;{	register Toolsw	*sw;	Rect		rect, rectoriginal;	register Rect	*r = &rect;	register short	swsp = tool_subwindowspacing(tool) / 2;	short		width_left, width_right, width;	int		width_area;	short		height_above, height_below, height;	int		height_area;	int		tool_left, tool_top, tool_right, tool_bottom;	get_tool_info(tool, &tool_left, &tool_top,		      &tool_right, &tool_bottom);		/* First set the rect for the target */	sw_set_rect(target_sw, new_rect, tool_left, tool_top, tool_right, 	            tool_bottom);		rect_marginadjust(new_rect, swsp + 1);	(void)win_lockdata(tool->tl_windowfd);		/* For each subwindow in the way */	for (sw = tool->tl_sw; sw; sw = sw->ts_next) {		if (sw == target_sw)			continue;					(void)win_getrect(sw->ts_windowfd, r);		rectoriginal = *r;		rect_marginadjust(r, swsp);		if (!rect_intersectsrect(r, new_rect))			continue;					compute_contortion(r, new_rect, 			&width_left, &width_right, &width,			&height_above, &height_below, &height);		width_area = (width < MIN_SW_WIDTH) ? 0 : (width * r->r_height);		height_area = (height < MIN_SW_HEIGHT) ? 0 : (height * r->r_width);					if (width_area >= height_area) {		    if (width == width_right)		           r->r_left = rect_right(new_rect) + 1;		    r->r_width = width;		} else {		    if (height == height_below)		        r->r_top = rect_bottom(new_rect) + 1;		    r->r_height = height;		}		rect_marginadjust(r, -swsp);		sw_set_rect(sw, r, tool_left, tool_top, tool_right, 	                    tool_bottom);					if (wants_fill)			tool_expand_neighbors(tool, sw, &rectoriginal);	}	rect_marginadjust(new_rect, -(swsp + 1));	(void)win_unlockdata(tool->tl_windowfd);}/* Compute the possible contortions of a victim rectangle caused by * overlapping an agressor rectangle. */static voidcompute_contortion(victim, aggressor, width_left, width_right, width,		   height_above, height_below, height)register Rect	*victim, *aggressor;short		*width_left, *width_right, *width;short		*height_above, *height_below, *height;{	/* allow one pixel between rectangles.	 * if we want to move next to position x, we skip	 * x + 1 and use x + 2. Note that width = right - left + 1	 * and height = bottom - top + 1.	 */	*width_left = (aggressor->r_left - 1) - victim->r_left + 1;	*width_right = rect_right(victim) - (rect_right(aggressor) + 1) + 1;	*width = max(*width_left, *width_right);				*height_above = (aggressor->r_top - 1) - victim->r_top + 1;	*height_below = rect_bottom(victim) - (rect_bottom(aggressor) + 1) + 1;	*height = max(*height_above, *height_below);}static voidsw_set_rect(target_sw, new_rect, tool_left, tool_top, tool_right, tool_bottom)Toolsw	*target_sw;Rect	*new_rect;int	tool_left, tool_top, tool_right, tool_bottom;{	Rect	old_rect;	extern void wmgr_completechangerect();		/* don't clobber the width or height	 * unless it changed.	 */	(void)win_getrect(target_sw->ts_windowfd, &old_rect);	if (old_rect.r_width != new_rect->r_width)		target_sw->ts_width = new_rect->r_width;	if (old_rect.r_height != new_rect->r_height)		target_sw->ts_height = new_rect->r_height;			/* Only allow subwindows which actually border	 * the tool to be extend-to-edge.	 * Also if the sw now borders the tool,	 * make it extend-to-edge.	 */	if (rect_right(new_rect) >= tool_right)		target_sw->ts_width = TOOL_SWEXTENDTOEDGE;	else if (target_sw->ts_width == TOOL_SWEXTENDTOEDGE)		target_sw->ts_width = new_rect->r_width;	if (rect_bottom(new_rect) >= tool_bottom)		target_sw->ts_height = TOOL_SWEXTENDTOEDGE;	else if (target_sw->ts_height == TOOL_SWEXTENDTOEDGE)		target_sw->ts_height = new_rect->r_height;			wmgr_completechangerect(target_sw->ts_windowfd, new_rect, &old_rect,		tool_left, tool_top);}/* Compute the left, top of the tool in screen coordinates, * and compute the rightmost and bottommost point in tool-relative * coordinates. */static voidget_tool_info(tool, left, top, right, bottom)Tool	*tool;int	*left, *top, *right, *bottom;{	Rect		 rect;	register Rect	*r = &rect;	register int	 border_width = tool_borderwidth(tool);		(void)win_getrect(tool->tl_windowfd, r);	*left = r->r_left;	*top = r->r_top;	*right = r->r_width - border_width - 1;	*bottom = r->r_height - border_width - 1;}/* This is no longer needed since we use wmgr_providefeedback() * now. */#ifdef notdef#define	xor_box(r) \	_tool_draw_box(fsglobal->fs_pixwin, PIX_NOT(PIX_DST), (r), 1, BLACK);wmgr_dragboundary(feedbackfd, r, rconstrain, event, changewidth)	int	feedbackfd;	struct	rect  *r, *rconstrain;	struct	inputevent *event;	int	changewidth;{	struct	rect  rold;	struct	fullscreen *fs;	/*	 * Get full screen access	 */	fs = fullscreen_init(feedbackfd);	/*	 * put the outline up to start	 */	xor_box(r);		do {		if (input_readevent(feedbackfd, event)==-1)			break;		rold = *r;		if (rect_includespoint(rconstrain,		    event->ie_locx, event->ie_locy)) {			if (changewidth)				r->r_width = event->ie_locx-r->r_left;			else				r->r_height = event->ie_locy-r->r_top;			if (!(rect_equal(r, &rold))) {				xor_box(&rold); 				xor_box(r);			}		}	} while (!((event->ie_code==SELECT_BUT || event->ie_code==MS_MIDDLE) &&	    win_inputnegevent(event)));	/*	 * Erase box	 */	xor_box(r);	fullscreen_destroy(fs);	return;}#endif notdef

⌨️ 快捷键说明

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