Exemplo n.º 1
0
Arquivo: rect.c Projeto: fshunj/LCUI
/* 将数值转换成LCUI_Rect型结构体 */
LCUI_API LCUI_Rect
Rect( int x, int y, int width, int height )
{
	LCUI_Rect s;

	Rect_Init (&s);
	s.x = x;
	s.y = y;
	s.width = width;
	s.height = height;
	return s;
}
Exemplo n.º 2
0
static void PictureBox_Init(LCUI_Widget *widget)
/* 功能:初始化图片盒子 */
{
    LCUI_PictureBox *pic_box = (LCUI_PictureBox*)
                               Widget_Create_PrivData(widget, sizeof(LCUI_PictureBox));;

    Rect_Init(&pic_box->read_box);
    pic_box->image		= NULL;
    pic_box->scale		= 1.0;
    pic_box->size_mode	= SIZE_MODE_CENTER;
    Graph_Init(&pic_box->buff_graph);
    Graph_Init(&pic_box->error_image);
    Graph_Init(&pic_box->initial_image);
    //Set_Widget_BG_Mode(widget, BG_MODE_FILL_BACKCOLOR);
}
Exemplo n.º 3
0
void Get_Moved_Rect_Refresh_Area (int new_x, int new_y, LCUI_Rect rect,
							 LCUI_Rect * rect_a, LCUI_Rect * rect_b)
/* 功能:获取一个矩形移动后需要刷新的残留区域,也就是A和B两个区域。 */
{
	Rect_Init (rect_a);
	Rect_Init (rect_b);
	if (rect.x < new_x)
	{							/* 如果是向右移 */
		rect_a->x = rect.x;
		rect_a->y = rect.y;
		rect_a->width = new_x - rect.x;
		rect_a->height = rect.height;
		if (rect.y > new_y)
		{						/* 如果是向上移 */
			rect_b->x = new_x;
			rect_b->y = new_y + rect.height;
			rect_b->width = rect.width - rect_a->width;
			rect_b->height = rect.y - new_y;
		}
		else
		{
			rect_b->x = new_x;
			rect_b->y = rect.y;
			rect_b->width = rect.width - rect_a->width;
			rect_b->height = new_y - rect.y;
		}
	}
	else if (rect.x > new_x)
	{							/* 如果是向左移 */
		rect_a->x = new_x + rect.width;
		rect_a->y = rect.y;
		rect_a->width = rect.x - new_x;
		rect_a->height = rect.height;

		if (rect.y > new_y)
		{						/* 如果是向上移 */
			rect_b->x = rect.x;
			rect_b->y = new_y + rect.height;
			rect_b->width = rect.width - rect_a->width;
			rect_b->height = rect.y - new_y;
		}
		else
		{
			rect_b->x = rect.x;
			rect_b->y = rect.y;
			rect_b->width = rect.width - rect_a->width;
			rect_b->height = new_y - rect.y;
		}
	}
	else
	{							/* 否则,没有向左右移动,只有向上和向下 */
		rect_a->x = rect.x;
		rect_a->y = rect.y;
		rect_a->width = 0;
		rect_a->height = 0;
		if (rect.y > new_y)
		{						/* 如果是向上移 */
			rect_b->x = rect.x;
			rect_b->y = new_y + rect.height;
			rect_b->width = rect.width;
			rect_b->height = rect.y - new_y;
		}
		else
		{
			rect_b->x = rect.x;
			rect_b->y = rect.y;
			rect_b->width = rect.width;
			rect_b->height = new_y - rect.y;
		}
	}
}
Exemplo n.º 4
0
Arquivo: rect.c Projeto: fshunj/LCUI
/*
 * 功能:将有重叠部分的两个矩形,进行分割,并得到分割后的矩形
 * 说明:主要用于局部区域刷新里,添加的需刷新的区域有可能会与已添加的区域重叠,为避免
 * 重复刷新同一块区域,需要在添加时对矩形进行分割,得到完全重叠和不重叠的矩形。
 * 参数说明:
 * old : 已存在的矩形区域
 * new : 将要添加的矩形区域
 * rq  : 指向矩形的队列的指针
 * 注意!传递参数时,请勿颠倒old和new位置。
 **/
LCUI_API int
LCUIRect_Cut(	LCUI_Rect	old_rect,
		LCUI_Rect	new_rect, 
		LCUI_Queue	*rects_buff )
{
	int i; 
	LCUI_Rect r[5];
	
	for(i=0; i<5; ++i) {
		Rect_Init(&r[i]); 
	}
	
	/* 计算各个矩形的x轴坐标和宽度 */
	r[0].x = new_rect.x;
	r[0].y = new_rect.y; 
	//printf("old,pos(%d,%d), size(%d,%d)\n", old_rect.x, old_rect.y, old_rect.width, old_rect.height);
	//printf("new,pos(%d,%d), size(%d,%d)\n", new_rect.x, new_rect.y, new_rect.width, new_rect.height);
	/* 如果前景矩形在背景矩形的左边 */  
	if(new_rect.x < old_rect.x) {
		/* 如果X轴上与背景矩形不重叠 */  
		if(new_rect.x + new_rect.width <= old_rect.x) {
			return -1;
		}
		r[0].width = old_rect.x - new_rect.x;
		r[1].x = old_rect.x;
		r[2].x = r[1].x;
		r[4].x = r[2].x;
		/* 如果前景矩形在X轴上包含背景矩形 */  
		if(new_rect.x + new_rect.width > old_rect.x + old_rect.width) {
			r[1].width = old_rect.width;
			
			r[3].x = old_rect.x + old_rect.width;
			r[3].width = new_rect.x + new_rect.width - r[3].x;
		} else { /* 得出矩形2的宽度 */ 
			r[1].width = new_rect.x + new_rect.width - old_rect.x;  
		}
		/* 得出矩形3和5的宽度 */ 
		r[2].width = r[1].width;
		r[4].width = r[2].width;
	} else {  
		if(old_rect.x + old_rect.width <= new_rect.x) { 
			return -1;
		}
		r[1].x = new_rect.x;
		r[2].x = r[1].x; 
		r[4].x = r[2].x;
		
		if(new_rect.x + new_rect.width > old_rect.x + old_rect.width) {  
			r[1].width = old_rect.x + old_rect.width - r[1].x;
			r[3].x = old_rect.x + old_rect.width;
			r[3].width = new_rect.x + new_rect.width - r[3].x;
		} else {
			r[1].width = new_rect.width; 
		}
			
		r[2].width = r[1].width;
		r[4].width = r[2].width;
	}
	 
	/* 计算各个矩形的y轴坐标和高度 */
	r[0].height = new_rect.height;
	r[3].y = new_rect.y;
	r[3].height = r[0].height;
	r[4].y = old_rect.y + old_rect.height; 
	if(new_rect.y < old_rect.y) {
		if(new_rect.y + new_rect.height <= old_rect.y) { 
			return -1;
		}
		r[1].y = new_rect.y; 
		r[1].height = old_rect.y - new_rect.y;
		r[2].y = old_rect.y; 
		/* 如果前景矩形在Y轴上包含背景矩形 */ 
		if(new_rect.y + new_rect.height > old_rect.y + old_rect.height) { 
			r[2].height = old_rect.height;
			r[4].height = new_rect.y + new_rect.height - r[4].y; 
		} else { 
			r[2].height = new_rect.y + new_rect.height - old_rect.y;  
		}
	} else {  
		if(new_rect.y >= old_rect.y + old_rect.height) { 
			return -1;
		}
		r[2].y = new_rect.y; 
		
		if(new_rect.y + new_rect.height > old_rect.y + old_rect.height) {  
			r[2].height = old_rect.y + old_rect.height - r[2].y;
			r[4].height = new_rect.y + new_rect.height - r[4].y;
		} else r[2].height = new_rect.y + new_rect.height - r[2].y;
	}
	
	//r[0].width -= 1;
	//r[1].height -= 1;
	//r[3].x += 1;
	//r[3].width -= 1;
	//r[4].y += 1;
	//r[4].height -= 1;
	  
	for(i=0; i<5; i++) { 
		//if(debug_mark)
		//	printf("slip rect[%d]: %d,%d, %d,%d\n", i, r[i].x, r[i].y, r[i].width, r[i].height);
		Queue_Add(rects_buff, &r[i]); 
	}
	return 0;
}