Exemple #1
0
static void Exec_Update_Window(LCUI_Widget *win_p)
/* 功能:更新窗口图形数据 */
{
    LCUI_Widget *titlebar = Get_Window_TitleBar(win_p);
    LCUI_Widget *client_area = Get_Window_Client_Area(win_p);
    /* 更改窗口边框风格时,这个函数起到一定作用,因为要根据风格来调整窗口的内容 */
    Window_Widget_Auto_Size(win_p);
    /* 更新下面的部件 */
    Draw_Widget(titlebar);
    Draw_Widget(client_area);
}
Exemple #2
0
void Set_ProgressBar_Value(LCUI_Widget *widget, int value)
/* 功能:设定进度条当前值 */
{
	LCUI_ProgressBar *pb = Get_Widget_PrivData(widget);
	pb->value = value; 
	Draw_Widget(widget);
}
Exemple #3
0
void Set_ProgressBar_Max_Value(LCUI_Widget *widget, int max_value)
/* 功能:设定进度条最大值 */
{
	LCUI_ProgressBar *pb = Get_Widget_PrivData(widget);
	pb->max_value = max_value; 
	Draw_Widget(widget); 
}
Exemple #4
0
void Set_PictureBox_Size_Mode(LCUI_Widget *widget, int mode)
/* 功能:设定图片盒子的图像显示模式 */
{
    LCUI_PictureBox *pic_box = (LCUI_PictureBox*)
                               Get_Widget_PrivData(widget);

    if(pic_box->size_mode == mode) return;

    float scale_x,scale_y;
    pic_box->size_mode = mode;
    if(pic_box->image == NULL) return;

    switch(mode) {
    case SIZE_MODE_BLOCK_ZOOM:
    case SIZE_MODE_ZOOM:
        if( widget->size.w <= 0 || widget->size.h <= 0) {
            pic_box->scale = 1.0;
        } else {
            scale_x = (float)widget->size.w / pic_box->image->width;
            scale_y = (float)widget->size.h / pic_box->image->height;
            if(scale_x < scale_y) pic_box->scale = scale_x;
            else pic_box->scale = scale_y;
        }
        Zoom_PictureBox_View_Area(widget, pic_box->scale);
        break;
    default:
        pic_box->scale = 1.0;
        break;
    }
    Draw_Widget(widget);
}
Exemple #5
0
int Zoom_PictureBox_View_Area(LCUI_Widget *widget, float scale)
/* 功能:缩放PictureBox部件的图片浏览区域 */
{
	LCUI_Graph buff, temp;
	LCUI_PictureBox *pic_box;
	
	pic_box = Get_Widget_PrivData(widget);
	if(!Graph_Valid(pic_box->image)) {
		return -1;
	}
	Graph_Init(&buff);
	Graph_Init(&temp);
	/* 有效范围为2%~2000% */
	if(scale < 0.02) {
		scale = 0.02;
	}
	if(scale > 20) {
		scale = 20;
	}
	if(pic_box->size_mode != SIZE_MODE_ZOOM
	 && pic_box->size_mode != SIZE_MODE_BLOCK_ZOOM) {
		pic_box->size_mode = SIZE_MODE_ZOOM; /* 改为缩放模式 */
	}
	pic_box->scale = scale; 
	Update_BuffGraph(widget); 
	Update_ReadBox(widget);
	Draw_Widget(widget);
	Refresh_Widget(widget);
	return 0;
}
Exemple #6
0
int 
Label_TextStyle( LCUI_Widget *widget, LCUI_TextStyle style )
/* 为Label部件内显示的文本设定文本样式 */
{
	LCUI_Label *label;
	
	label = Get_Widget_PrivData( widget );
	TextLayer_Text_Set_Default_Style( &label->layer, style );
	Draw_Widget( widget ); 
	return 0;
}
Exemple #7
0
int Move_PictureBox_View_Area(LCUI_Widget *widget, LCUI_Pos des_pos)
/* 功能:移动图片盒子内的图片的显示区域的位置 */
{
	LCUI_Size size;
	LCUI_Graph *p;
	LCUI_PictureBox *pic_box;
	
	pic_box = Get_Widget_PrivData(widget);
	
	if(!Graph_Valid(pic_box->image)) {
		return -1;
	}
	if(pic_box->scale == 1.00 || !Graph_Valid(&pic_box->buff_graph)) {
		p = pic_box->image;
	} else {
		p = &pic_box->buff_graph;
	}
	size.w = pic_box->read_box.width;
	size.h = pic_box->read_box.height;
	/* 处理区域数据,使之为有效区域 */
	if(des_pos.x < 0) {
		des_pos.x = 0;
	}
	if(des_pos.y < 0) {
		des_pos.y = 0;
	}
	if(des_pos.x + size.w > p->width) {
		des_pos.x = p->width - size.w;
	}
	if(des_pos.y + size.h > p->height) {
		des_pos.y = p->height - size.h;
	}
	if(des_pos.x == pic_box->read_box.x 
	&& des_pos.y == pic_box->read_box.y) {
		return 0; 
	}
	/* 更新图片盒子内的图像 */
	pic_box->read_box.x = des_pos.x;
	pic_box->read_box.y = des_pos.y;
	/* 重新计算中心点的位置 */ 
	pic_box->read_box.center_x = (des_pos.x + size.w/2.0)/p->width;
	pic_box->read_box.center_y = (des_pos.y + size.h/2.0)/p->height;
	
	Draw_Widget(widget);
	//用于调试
	//printf("read box: %d,%d,%d,%d; %d/%d, %d/%d\n", 
	//pic_box->read_box.x, pic_box->read_box.y, 
	//pic_box->read_box.width, pic_box->read_box.height, 
	//pic_box->read_box.x + pic_box->read_box.width,
	//pic_box->read_box.y + pic_box->read_box.height,
	//pic_box->buff_graph.width, pic_box->buff_graph.height);
	return 0;
}
Exemple #8
0
void Resize_PictureBox_View_Area(LCUI_Widget *widget, int width, int height)
/* 功能:设定PictureBox部件的图片显示区域的大小 */
{
	LCUI_Pos start, center_pos;
	LCUI_PictureBox *pic_box;
	
	pic_box = Get_Widget_PrivData(widget);
	
	if(width <= 0 || height <= 0) {
		return;
	}
	if(!Graph_Valid(pic_box->image)) {
		return;
	}
	/* 将中心点位置转换成坐标 */
	center_pos.x = pic_box->read_box.center_x * pic_box->scale * pic_box->image->width;
	center_pos.y = pic_box->read_box.center_y * pic_box->scale * pic_box->image->height;
	/* 处理区域数据,使之为有效区域 */
	start.x = center_pos.x - width/2.0;
	start.y = center_pos.y - height/2.0;
	if(start.x < 0) start.x = 0;
	if(start.y < 0) start.y = 0;
	if(start.x + width > pic_box->image->width)
	start.x = pic_box->image->width - width;
	if(start.y + height > pic_box->image->height)
	start.y = pic_box->image->height - height;
	if(start.x < 0) {
		start.x = 0;
		width = pic_box->image->width;
	}
	if(start.y < 0) {
		start.y = 0;
		height = pic_box->image->height;
	}
	pic_box->read_box.x = start.x;
	pic_box->read_box.y = start.y;
	pic_box->read_box.width = width;
	pic_box->read_box.height = height;
	/* 更新图片盒子内的图像 */
	Draw_Widget(widget);
	Refresh_Widget(widget); 
}
Exemple #9
0
void Set_PictureBox_Image_From_Graph(LCUI_Widget *widget, LCUI_Graph *image)
/* 功能:添加一个图片数据至图片盒子 */
{
    int i;
    float scale_x,scale_y;
    LCUI_Graph *graph = image;
    LCUI_PictureBox *pic_box = (LCUI_PictureBox*)
                               Get_Widget_PrivData(widget);
    for(i = 0; i < 2; ++i) {
        /* 如果image有效 */
        if(Graph_Valid(graph)) {
            /* 图片更换了,就释放缓存图形 */
            Graph_Free(&pic_box->buff_graph);
            pic_box->image = graph;
            /* 读取的范区域为整个图片区域 */
            pic_box->read_box.x = 0;
            pic_box->read_box.y = 0;
            pic_box->read_box.width = graph->width;
            pic_box->read_box.height = graph->height;
            pic_box->read_box.center_x = 0.5;
            pic_box->read_box.center_y = 0.5;
            pic_box->scale = 1.0;

            //printf("Set_PictureBox_Image_From_Graph(): img, w: %d, h: %d\n", graph->width, graph->height);
            //printf("Set_PictureBox_Image_From_Graph(): pb: w: %d, h: %d\n", widget->size.w, widget->size.h);
            //printf("Set_PictureBox_Image_From_Graph(): size mode: %d\n", pic_box->size_mode);
            switch(pic_box->size_mode) {
            case SIZE_MODE_BLOCK_ZOOM:
            case SIZE_MODE_ZOOM:
                //printf("Set_PictureBox_Image_From_Graph(): widget: w: %d, h: %d\n", widget->size.w, widget->size.h);
                if(widget->size.w <= 0 || widget->size.h <= 0) {
                    //printf("Set_PictureBox_Image_From_Graph(): break\n");
                    break;
                }
                scale_x = (float)widget->size.w / pic_box->image->width;
                scale_y = (float)widget->size.h / pic_box->image->height;
                if(scale_x < scale_y) pic_box->scale = scale_x;
                else pic_box->scale = scale_y;
                //printf("Set_PictureBox_Image_From_Graph(): scale: %.4f, x: %.4f, y: %.4f\n",
                //pic_box->scale, scale_x, scale_y);
                Zoom_PictureBox_View_Area(widget, pic_box->scale);
                //printf("Set_PictureBox_Image_From_Graph(): read box: %d,%d,%d,%d\n",
                //pic_box->read_box.x, pic_box->read_box.y,
                //pic_box->read_box.width, pic_box->read_box.height);
                break;
            /* 正常模式 */
            case SIZE_MODE_NORMAL:
                break;
            /* 拉伸模式 */
            case SIZE_MODE_STRETCH:
                break;
            /* 平铺模式 */
            case SIZE_MODE_TILE:
                break;
            case SIZE_MODE_CENTER:
                /* 判断图像的尺寸是否超出图片盒子的尺寸 */
                if(pic_box->image->width >= widget->size.w) {
                    pic_box->read_box.x = (pic_box->image->width - widget->size.w)/2.0;
                    pic_box->read_box.width = widget->size.w;
                }
                if(pic_box->image->height >= widget->size.h) {
                    pic_box->read_box.y = (pic_box->image->height - widget->size.h)/2.0;
                    pic_box->read_box.height = widget->size.h;
                }
                break;
            default :
                break;
            }
            break;
        } else if(pic_box->image_status == IMAGE_STATUS_LOADING) {
            /* 使用对应的图片 */
            if(Graph_Valid(&pic_box->initial_image)) {
                graph = &pic_box->initial_image;
            } else {
                return;
            }
        }
        else { /* 使用对应的图片 */
            if(Graph_Valid(&pic_box->error_image)) {
                graph = &pic_box->error_image;
                pic_box->image_status = IMAGE_STATUS_FAIL;
            } else {
                return;
            }
        }
    }
    /* 如果记录中有该部件,那判断该部件使用的图像是否为同一个,不一样就释放之前的 */
    graph_data *data;
    i = find_widget_data(widget);
    if(i >= 0) {
        data = (graph_data*)Queue_Get(&picbox_graph_mem, i);
        if(data->image != image) {
            Queue_Delete(&picbox_graph_mem, i);
        }
    }
    Draw_Widget(widget);
}