示例#1
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;
}
示例#2
0
文件: button.c 项目: yydaor/LCUI
/* 初始化按钮部件的数据 */
static void
Button_Init( LCUI_Widget *widget )
{
	int valid_state;
	LCUI_Button *button;
	
	button = WidgetPrivData_New(widget, sizeof(LCUI_Button));
	/* 初始化图像数据 */ 
	Graph_Init(&button->btn_disable);
	Graph_Init(&button->btn_normal);
	Graph_Init(&button->btn_focus);
	Graph_Init(&button->btn_down);
	Graph_Init(&button->btn_over);
	
	valid_state = (WIDGET_STATE_NORMAL | WIDGET_STATE_ACTIVE);
	valid_state |= (WIDGET_STATE_DISABLE | WIDGET_STATE_OVERLAY);
	Widget_SetValidState( widget, valid_state );
	button->label = Widget_New("label");/* 创建label部件 */ 
	/* 将按钮部件作为label部件的容器 */
	Widget_Container_Add(widget, button->label);
	/* label部件居中显示 */
	Widget_SetAlign(button->label, ALIGN_MIDDLE_CENTER, Pos(0,0));
	Widget_Show(button->label); /* 显示label部件 */
	/* 启用自动尺寸调整,以适应内容 */
	Widget_SetAutoSize( widget, TRUE, AUTOSIZE_MODE_GROW_AND_SHRINK);
	Widget_SetStyleID( widget, BUTTON_STYLE_DEFAULT );
	/* 关联EVENT_FOCUSOUT事件,以在按钮失去焦点时重绘按钮 */
	Widget_Event_Connect( widget, EVENT_FOCUSOUT, Button_ProcFocusOut );
}
示例#3
0
文件: picturebox.c 项目: fshunj/LCUI
/* 缩放PictureBox部件的图片浏览区域 */
LCUI_API int
PictureBox_ZoomViewArea( LCUI_Widget *widget, double scale )
{
	LCUI_Graph buff, temp;
	LCUI_PictureBox *pic_box;
	
	pic_box = Widget_GetPrivData(widget);
	if(!Graph_IsValid(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);
	Widget_Draw(widget);
	Widget_Refresh(widget);
	return 0;
}
示例#4
0
static void ProgressBar_Init(LCUI_Widget *widget)
/* 功能:初始化进度条的数据结构体 */
{
	LCUI_ProgressBar *pb = (LCUI_ProgressBar*)
				Widget_Create_PrivData
				(widget, sizeof(LCUI_ProgressBar));
	pb->thread = 0;
	Graph_Init(&pb->fore_graph); 
	Graph_Init(&pb->flash_image);
	pb->img_move_speed = 200;
	pb->sleep_time = 100000;
	pb->max_value = 1;
	pb->value = 0;
	
	LCUI_Widget *f_pb, *img_pb;
	f_pb = Create_Widget("picture_box"); 
	img_pb = Create_Widget("picture_box");
	/* 以自己为容器,将这些部件放进去 */
	Widget_Container_Add(f_pb, img_pb);
	Widget_Container_Add(widget, f_pb); 
	/* 没有背景图时就填充背景色 */
	Set_Widget_BG_Mode(widget, BG_MODE_FILL_BACKCOLOR);
	Set_Widget_Border(widget, RGB(50,50,50), Border(1,1,1,1));
	
	Set_Widget_Style(widget, "classic"); /* 进度条为经典风格 */
	
	Set_PictureBox_Size_Mode(f_pb, SIZE_MODE_STRETCH); 
	
	Show_Widget(f_pb); 
	Show_Widget(img_pb);
	
	pb->fore_pic_box = f_pb; 
	pb->img_pic_box = img_pb;
}
示例#5
0
int main(int argc, char *argv[])
{
	clock_t start;
	LCUI_Graph slot, graph;
	/* 初始化数据结构 */
	Graph_Init( &graph );
	Graph_Init( &slot );
	
	if(argc == 2) {
		/* 载入图片文件 */
		if( Load_Image( argv[1], &graph ) != 0) {
			printf("can not load images!\n");
			return -1;
		}
		/* 开始计时 */
		start = clock(); 
		/* 默认使用高斯模糊算法,输入数据为graph, 数据输出至slot, sigma = 20 */
		Graph_Smooth( &graph, &slot, 20.0 );
		printf("smooth, use time: %ld us\n", clock()-start);
		start = clock();
		/* 将图像数据保存至文件 */
		write_png( "output.png", &slot );
		printf("write, use time: %ld us\n", clock()-start);
		/* 释放资源 */
		Graph_Free( &slot );
		Graph_Free( &graph );
	} else {
		printf( "usage:\n%s  imgfile\n", argv[0] );
	}
	return 0;
}
示例#6
0
文件: LCUI_Window.c 项目: dwdcth/LCUI
static void Window_Init(LCUI_Widget *win_p)
/*
 * 功能:初始化窗口
 * 说明:类似于构造函数
 **/
{
    LCUI_Widget *titlebar;
    LCUI_Widget *client_area;
    LCUI_Widget *btn_close;
    LCUI_Window *win;

    win = (LCUI_Window*)Widget_Create_PrivData(win_p, sizeof(LCUI_Window));

    win->hide_style	= NONE;
    win->show_style	= NONE;
    win->count	= 0;
    win->init_align	= ALIGN_MIDDLE_CENTER;

    /* 创建一个标题栏部件 */
    titlebar = Create_Widget("titlebar");
    /* 再创建一个客户区部件 */
    client_area = Create_Widget(NULL);
    btn_close = Create_Widget("button");

    static LCUI_Graph btn_highlight, btn_normal, btn_down;
    Graph_Init(&btn_down);
    Graph_Init(&btn_highlight);
    Graph_Init(&btn_normal);
    /* 载入默认图形 */
    Load_Graph_Default_TitleBar_CloseBox_Normal(&btn_normal);
    Load_Graph_Default_TitleBar_CloseBox_Down(&btn_down);
    Load_Graph_Default_TitleBar_CloseBox_HighLight(&btn_highlight);
    /* 显示在左上角 */
    Set_Widget_Align(btn_close, ALIGN_TOP_RIGHT, Pos(0, -2));
    /* 将尺寸改成和图片一样 */
    Resize_Widget(btn_close, Size(btn_normal.width, btn_normal.height));
    Custom_Button_Style(btn_close, &btn_normal, &btn_highlight,
                        &btn_down, NULL, NULL);
    /* 关联按钮的点击事件,当按钮被点击后,调用Quit_Window函数 */
    Widget_Clicked_Event_Connect(btn_close, Quit_Parent_Window, NULL);
    Graph_Free(&btn_highlight);
    Graph_Free(&btn_down);
    Graph_Free(&btn_normal);

    win->client_area = client_area;
    win->titlebar = titlebar;
    win->btn_close = btn_close;
    /* 没有背景图就填充背景色 */
    Set_Widget_BG_Mode(win_p, BG_MODE_FILL_BACKCOLOR);
    Set_Widget_Border_Style(win_p, BORDER_STYLE_STANDARD);
    /* 放入至容器 */
    Widget_Container_Add(titlebar, btn_close);
    Widget_Container_Add(win_p, titlebar);
    Widget_Container_Add(win_p, client_area);
    Resize_Widget(win_p, Size(50, 50));
    Show_Widget(btn_close);

    Widget_Drag_Event_Connect(titlebar, Move_Window);
}
示例#7
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);
}
示例#8
0
文件: graphlayer.c 项目: aem3372/LCUI
LCUI_API LCUI_GraphLayer* GraphLayer_New( void )
{
	LCUI_GraphLayer * glayer;
	
	glayer = (LCUI_GraphLayer*)malloc( sizeof( LCUI_GraphLayer ) );
	if( glayer == NULL ) {
		return NULL;
	}
	/* 赋初始值 */
	glayer->visible = FALSE;
	glayer->inherit_alpha = TRUE;
	glayer->pos.x = glayer->pos.y = glayer->z_index = 0;
	glayer->padding.left = 0;
	glayer->padding.top = 0;
	glayer->padding.bottom = 0;
	glayer->padding.right = 0;
	glayer->parent = NULL;
	/* 初始化图像数据 */
	Graph_Init( &glayer->graph );
	/* 初始化子图层列表 */
	Queue_Init( &glayer->child, 0, NULL );
	/* 标记该队列用于存储指针,即使销毁队列后,也不自动释放指针指向的内存空间 */ 
	Queue_UsingPointer( &glayer->child ); 
	return glayer;
}
示例#9
0
文件: textlayer.c 项目: oyjGit/LCUI
void TextLayer_Init( LCUI_TextLayer *layer )
{
	layer->max_width = 0;
	layer->max_height = 0;
	layer->offset_x = 0;
	layer->offset_y = 0;
	layer->new_offset_x = 0;
	layer->new_offset_y = 0;
	layer->insert_x = 0;
	layer->insert_y = 0;
	layer->is_mulitiline_mode = FALSE;
	layer->is_autowrap_mode = FALSE;
	layer->is_using_style_tags = FALSE;
	layer->is_using_buffer = TRUE;
	layer->text_align = TEXT_ALIGN_LEFT;

	layer->row_list.max_rows = 0;
	layer->row_list.rows = 0;
	layer->row_list.rowdata = NULL;
	
	TextStyle_Init( &layer->text_style );
	TaskData_Init( &layer->task );
	DirtyRectList_Init( &layer->dirty_rect );
	Graph_Init( &layer->graph );
	TextRowList_InsertNewRow( &layer->row_list, 0 );
	layer->graph.color_type = COLOR_TYPE_ARGB;
}
示例#10
0
文件: LCUI_Window.c 项目: dwdcth/LCUI
static void Window_TitleBar_Init(LCUI_Widget *titlebar)
/* 功能:初始化窗口标题栏 */
{
    LCUI_Graph img;
    LCUI_TitleBar *t;

    Graph_Init(&img);
    t = Widget_Create_PrivData(titlebar, sizeof(LCUI_TitleBar));
    t->icon_box = Create_Widget("picture_box");
    t->label = Create_Widget("label");

    Widget_Container_Add(titlebar, t->icon_box);
    Widget_Container_Add(titlebar, t->label);

    Resize_Widget(t->icon_box, Size(18,18));
    Set_PictureBox_Size_Mode(t->icon_box, SIZE_MODE_CENTER);

    Show_Widget(t->icon_box);
    Show_Widget(t->label);

    Set_Widget_Align(t->icon_box, ALIGN_MIDDLE_LEFT, Pos(0,0));
    Set_Widget_Align(t->label, ALIGN_MIDDLE_LEFT, Pos(2,-2));
    Load_Graph_Default_TitleBar_BG(&img);
    Set_Widget_Background_Image(titlebar, &img, LAYOUT_STRETCH);
}
示例#11
0
文件: load_image.c 项目: dwdcth/LCUI
int Load_Image(const char *filepath, LCUI_Graph *out)
/* 
 * 功能:载入指定图片文件的图形数据
 * 说明:打开图片文件,并解码至内存,打开的图片文件越大,占用的内存也就越大 
 * */
{
	FILE *fp;
	int result = 0;   /* 错误代号为0 */
	
	Graph_Init(out); 
	out->have_alpha = IS_FALSE;
	/*fp是全局变量,其它函数会用到它*/
	if ((fp = fopen(filepath,"r")) == NULL) {
		perror(filepath);
		result = OPEN_ERROR; 
	} else {
		fgetc(fp);
		if (!ferror (fp)) {/*r如果没出错*/
			fseek(fp,0,SEEK_END);
			if (ftell(fp)>4) {
				fclose(fp);
				result = detect_image(filepath, out); 
			} else {
				result = SHORT_FILE;//文件过小 
				fclose(fp);
			}
		}
	}
	return result;   /* 返回错误代码 */
}
示例#12
0
文件: main.c 项目: yydaor/LCUI
/* 初始化游标数据 */
static void LCUIModule_Cursor_Init( void )
{
	LCUI_Graph pic;
	Graph_Init( &pic );
	Load_Graph_Default_Cursor( &pic );/* 载入自带的游标的图形数据 */ 
	LCUICursor_SetGraph( &pic );
}
示例#13
0
文件: window.c 项目: gateslu/LCUI
static void 
Window_TitleBar_Init(LCUI_Widget *titlebar)
/* 功能:初始化窗口标题栏 */
{
	LCUI_Graph img;
	LCUI_TitleBar *t;
	
	Graph_Init(&img);
	t = Widget_NewPrivData(titlebar, sizeof(LCUI_TitleBar));
	t->icon_box = Widget_New("picture_box");
	t->label = Widget_New("label");
	/* 窗口图标和标题文字不可获得焦点,并忽略鼠标点击 */
	t->label->focus = FALSE;
	t->icon_box->focus = FALSE;
	Widget_SetClickableAlpha( t->label, 0, 1 );
	Widget_SetClickableAlpha( t->icon_box, 0, 1 );
	
	Widget_Container_Add(titlebar, t->icon_box);
	Widget_Container_Add(titlebar, t->label);
	
	Widget_Resize(t->icon_box, Size(18,18));
	PictureBox_SetSizeMode(t->icon_box, SIZE_MODE_CENTER);
	
	Widget_Show(t->icon_box);
	Widget_Show(t->label);
	
	Widget_SetAlign(t->icon_box, ALIGN_MIDDLE_LEFT, Pos(0,0));
	Widget_SetAlign(t->label, ALIGN_MIDDLE_LEFT, Pos(2,-2));
}
示例#14
0
Create_Frames(LCUI_Size size)
/* 
 * 功能:创建一个能存放动画数据的容器
 * 说明:该容器用于记录动画的每一帧的信息,需要指定该容器的尺寸。
 *  */
{
	int pos;
	LCUI_Frames *p, frames; 
	 
	Queue_Init(&frames.pic, sizeof(LCUI_Frame), NULL);
	Queue_Init(&frames.func_data, sizeof(LCUI_Func), NULL);
	Graph_Init(&frames.slot);
	frames.slot.have_alpha = TRUE;
	frames.current = 0;
	frames.state = 0;
	frames.size = size; 
	if( !database_init ) {
		Queue_Init(&frames_database, sizeof(LCUI_Frames), NULL); 
		database_init = TRUE;
	}
	/* 记录该动画至库中 */ 
	pos = Queue_Add(&frames_database, &frames); 
	p = Queue_Get(&frames_database, pos); 
	return p;
}
示例#15
0
/** 计算背景样式 */
void Widget_ComputeBackgroundStyle( LCUI_Widget widget )
{
	LCUI_Style *s;
	LCUI_StyleSheet ss = widget->style;
	LCUI_Background *bg = &widget->computed_style.background;
	int key = key_background_start + 1;

	for( ; key < key_background_end; ++key ) {
		s = &ss->sheet[key];
		if( !s->is_valid ) {
			continue;
		}
		switch( key ) {
		case key_background_color:
			bg->color = s->color;
			break;
		case key_background_image:
			switch( s->type ) {
			case SVT_IMAGE:
				if( !s->image ) {
					Graph_Init( &bg->image );
					break;
				}
				Graph_Quote( &bg->image, s->image, NULL );
				break;
			case SVT_STRING:
				AsyncLoadImage( widget, s->string );
			default: break;
			}
			break;
		case key_background_position:
			bg->position.using_value = TRUE;
			bg->position.value = s->value;
			break;
		case key_background_position_x:
			bg->position.using_value = FALSE;
			bg->position.x = *s;
			break;
		case key_background_position_y:
			bg->position.using_value = FALSE;
			bg->position.y = *s;
			break;
		case key_background_size:
			bg->size.using_value = TRUE;
			bg->position.value = s->value;
			break;
		case key_background_size_width:
			bg->size.using_value = FALSE;
			bg->size.w = *s;
			break;
		case key_background_size_height:
			bg->size.using_value = FALSE;
			bg->size.h = *s;
			break;
		default: break;
		}
	}
	Widget_AddTask( widget, WTT_BODY );
}
示例#16
0
文件: painter.c 项目: spacefan/LCUI
LCUI_PaintContext LCUIPainter_Begin( LCUI_Graph *canvas, LCUI_Rect *rect )
{
	ASSIGN( paint, LCUI_PaintContext );
	paint->rect = *rect;
	paint->with_alpha = FALSE;
	Graph_Init( &paint->canvas );
	Graph_Quote( &paint->canvas, canvas, &paint->rect );
	return paint;
}
示例#17
0
void Background_Init( LCUI_Background *bg )
{
	bg->color = RGB( 255, 255, 255 );
	Graph_Init( &bg->image );
	bg->size.using_value = TRUE;
	bg->size.value = SV_AUTO;
	bg->position.using_value = TRUE;
	bg->position.value = SV_AUTO;
}
示例#18
0
文件: screenlock.c 项目: FrankHB/LCUI
static void LoadIMG(void)
{
	int i;
	char filepath[1024];
	for(i=0; i<10; ++i) {
		sprintf( filepath, "drawable/time_%d.png", i );
		Graph_Init( &img_digital[i] );
		Graph_LoadImage( filepath, &img_digital[i] );
	}
	Graph_Init( &img_dot );
	Graph_Init( &img_btn );
	Graph_Init( &img_btn_bg );
	Graph_Init( &img_bg );
	Graph_LoadImage( "drawable/time_dot.png", &img_dot );
	Graph_LoadImage( "drawable/btn.png", &img_btn );
	Graph_LoadImage( "drawable/btn_bg.png", &img_btn_bg );
	Graph_LoadImage( "drawable/bg.png", &img_bg );
}
示例#19
0
文件: LCUI_Graph.c 项目: fshunj/LCUI
LCUI_API int Graph_FillImage(	LCUI_Graph *graph,
				LCUI_Graph *bg, 
				int mode,
				LCUI_RGB color )
{
	LCUI_Size size;
	LCUI_Pos pos;
	LCUI_Graph temp_bg;
	LCUI_BOOL replace_mix;
	
	if( Check_Option( mode, GRAPH_MIX_FLAG_REPLACE ) ) {
		/* 将alpha通道置为0 */
		Graph_FillAlpha( graph, 0 );
		replace_mix = TRUE;
	} else {
		/* 填充背景色,将alpha通道置为255 */
		Graph_FillColor( graph, color );
		Graph_FillAlpha( graph, 255 );
		replace_mix = FALSE;
	}
	if(!Graph_IsValid(bg) || !Graph_IsValid(graph)) {
		return -1; 
	}
	size.w = graph->w;
	size.h = graph->h;
	Graph_Init(&temp_bg);
	pos.x = pos.y = 0;
	/* 平铺 */
	if( Check_Option( mode, LAYOUT_TILE ) ) {
		return Graph_Tile( bg, graph, replace_mix );
	}
	/* 缩放 */
	if( Check_Option( mode, LAYOUT_ZOOM ) ) {
		Graph_Zoom( bg, &temp_bg, TRUE, size );
		pos.x = (size.w - temp_bg.w) / 2.0;
		pos.y = (size.h - temp_bg.h) / 2.0;
		bg = &temp_bg;
	}
	/* 拉伸 */
	else if( Check_Option( mode, LAYOUT_STRETCH ) ) {
		Graph_Zoom( bg, &temp_bg, FALSE, size );
		bg = &temp_bg;
	}
	/* 居中 */
	else if( Check_Option( mode, LAYOUT_CENTER ) ) {
		pos.x = (size.w - bg->w) / 2.0;
		pos.y = (size.h - bg->h) / 2.0;
	}
	if( replace_mix ) {
		Graph_Replace( graph, bg, pos );
	} else {
		Graph_Mix( graph, bg, pos );
	}
	Graph_Free( &temp_bg );
	return 0; 
}
示例#20
0
文件: img_cursor.c 项目: yydaor/LCUI
LCUI_API int Load_Graph_Default_Cursor(LCUI_Graph *pic)
/* 功能:载入默认的鼠标指针的图形 */
{
	unsigned char red[]={
		3,3,0,0,0,0,0,0,0,0,0,0,3,3,3,0,0,0,0,0,0,0,0,0,3,229,3,3,0,0,0,0,0,
		0,0,0,3,255,229,3,3,0,0,0,0,0,0,0,3,255,255,229,3,3,0,0,0,0,0,0,3,255,255,255,229,
		3,3,0,0,0,0,0,3,255,255,255,255,229,3,3,0,0,0,0,3,255,255,255,255,253,226,3,3,0,0,0,3,
		255,255,255,253,251,248,220,3,3,0,0,3,255,255,253,251,248,245,241,214,3,3,0,3,255,253,251,248,245,241,238,234,
		207,3,3,3,253,251,248,245,241,238,234,230,226,201,3,3,251,248,245,217,238,234,3,3,3,3,3,3,248,245,217,3,
		164,230,3,3,0,0,0,3,245,217,3,3,3,226,201,3,0,0,0,3,217,3,3,0,3,176,219,3,3,0,0,3,
		3,3,0,0,3,3,216,192,3,0,0,0,0,0,0,0,0,3,192,211,3,0,0,0,0,0,0,0,0,3,3,3,
		3,0,0};
	unsigned char green[]={
		6,6,0,0,0,0,0,0,0,0,0,0,6,6,6,0,0,0,0,0,0,0,0,0,6,230,6,6,0,0,0,0,0,
		0,0,0,6,255,230,6,6,0,0,0,0,0,0,0,6,255,255,230,6,6,0,0,0,0,0,0,6,255,255,255,230,
		6,6,0,0,0,0,0,6,255,255,255,255,230,6,6,0,0,0,0,6,255,255,255,255,253,226,6,6,0,0,0,6,
		255,255,255,253,251,248,221,6,6,0,0,6,255,255,253,251,248,245,241,214,6,6,0,6,255,253,251,248,245,241,238,234,
		207,6,6,6,253,251,248,245,241,238,234,230,226,201,6,6,251,248,245,217,238,234,6,6,6,6,6,6,248,245,217,6,
		165,230,6,6,0,0,0,6,245,217,6,6,6,226,201,6,0,0,0,6,217,6,6,0,6,176,219,6,6,0,0,6,
		6,6,0,0,6,6,216,192,6,0,0,0,0,0,0,0,0,6,192,211,6,0,0,0,0,0,0,0,0,6,6,6,
		6,0,0};
	unsigned char blue[]={
		26,26,0,0,0,0,0,0,0,0,0,0,26,26,26,0,0,0,0,0,0,0,0,0,26,232,26,26,0,0,0,0,0,
		0,0,0,26,255,232,26,26,0,0,0,0,0,0,0,26,255,255,232,26,26,0,0,0,0,0,0,26,255,255,255,232,
		26,26,0,0,0,0,0,26,255,255,255,255,232,26,26,0,0,0,0,26,255,255,255,255,253,228,26,26,0,0,0,26,
		255,255,255,253,251,248,223,26,26,0,0,26,255,255,253,251,248,245,241,216,26,26,0,26,255,253,251,248,245,241,238,234,
		209,26,26,26,253,251,248,245,241,238,234,230,226,203,26,26,251,248,245,219,238,234,26,26,26,26,26,26,248,245,219,26,
		171,230,26,26,0,0,0,26,245,219,26,26,26,226,203,26,0,0,0,26,219,26,26,0,26,181,219,26,26,0,0,26,
		26,26,0,0,26,26,216,194,26,0,0,0,0,0,0,0,0,26,194,211,26,0,0,0,0,0,0,0,0,26,26,26,
		26,0,0};
	unsigned char alpha[]={
		231,55,0,0,0,0,0,0,0,0,0,0,231,189,55,0,0,0,0,0,0,0,0,0,231,255,189,55,0,0,0,0,0,
		0,0,0,231,255,255,189,55,0,0,0,0,0,0,0,231,255,255,255,189,55,0,0,0,0,0,0,231,255,255,255,255,
		189,55,0,0,0,0,0,231,255,255,255,255,255,189,55,0,0,0,0,231,255,255,255,255,255,255,189,55,0,0,0,231,
		255,255,255,255,255,255,255,189,55,0,0,231,255,255,255,255,255,255,255,255,189,55,0,231,255,255,255,255,255,255,255,255,
		255,189,55,231,255,255,255,255,255,255,255,255,255,255,189,231,255,255,255,255,255,255,189,189,189,189,189,231,255,255,255,244,
		255,255,188,77,0,0,0,231,255,255,244,55,211,255,255,211,0,0,0,231,255,244,55,0,180,255,255,180,77,0,0,189,
		244,55,0,0,55,215,255,255,209,0,0,0,0,0,0,0,0,180,255,255,204,0,0,0,0,0,0,0,0,26,215,158,
		49,0,0};
	int value;
	if(Graph_IsValid(pic)) {
		Graph_Free(pic);
	}
	Graph_Init(pic);
	pic->have_alpha = TRUE;
	pic->type = TYPE_PNG;
	pic->alpha = 255;
	value = Graph_Create(pic,12,19);
	if(value == 0) {
		memcpy(pic->rgba[0], red, sizeof(red));
		memcpy(pic->rgba[1], green, sizeof(green));
		memcpy(pic->rgba[2], blue, sizeof(blue));
		memcpy(pic->rgba[3], alpha, sizeof(alpha));
	}
	return value;
}
示例#21
0
文件: helloworld.c 项目: rokite/LCUI
int main( int argc, char **argv )
{
	LCUI_Widget w, root, text;
	LCUI_Graph desktop_image;

	InitConsoleWindow();
	LCUI_Init();
	LCUIDisplay_SetMode( LDM_WINDOWED );
	LCUIDisplay_SetSize( 960, 540 );
	w = LCUIWidget_New("debug-widget");
	text = LCUIWidget_New("textview");
	Widget_Append( w, text );
	TextView_SetTextW( text, L"测试文本内容,呵呵达!\nABCDEFG,abcdefg,[color=#ff0000]color font[/color]");
	Widget_Top( w );
	Widget_Show( w );
	Widget_Resize( w, 320, 240 );
	Widget_Move( w, 200, 200 );
	Widget_SetTitleW( w, L"测试" );
	Graph_Init( &desktop_image );
	Graph_LoadImage( "images/background-image.png", &desktop_image );
	root = LCUIWidget_GetRoot();

	Widget_PullStyle( root, WSS_BACKGROUND );
	root->style.background.color = RGB(255,242,223);
	root->style.background.image = desktop_image;
	root->style.background.size.using_value = TRUE;
	root->style.background.size.value = SV_COVER;
	Widget_PushStyle( root, WSS_BACKGROUND );

	Widget_PullStyle( w, WSS_BACKGROUND | WSS_SHADOW | WSS_BORDER );
	w->style.background.color.value = 0xccffffff;
	w->style.background.size.w.scale = 0.50; 
	w->style.background.size.h.px = 200;
	w->style.background.size.w.type = SVT_SCALE;
	w->style.background.size.h.type = SVT_PX;
	w->style.background.size.using_value = FALSE;
	w->style.background.position.using_value = TRUE;
	w->style.background.position.value = SV_BOTTOM_CENTER;
	w->style.shadow.color = ARGB(200,0,122,204);
	w->style.shadow.x = 2;
	w->style.shadow.y = 2;
	w->style.shadow.spread = 0;
	w->style.shadow.blur = 8;
	w->style.border.top.width = 1;
	w->style.border.right.width = 1;
	w->style.border.bottom.width = 1;
	w->style.border.left.width = 1;
	w->style.border.top.color = RGB(0,122,204);
	w->style.border.right.color = RGB(0,122,204);
	w->style.border.bottom.color = RGB(0,122,204);
	w->style.border.left.color = RGB(0,122,204);
	Widget_PushStyle( w, WSS_BACKGROUND | WSS_SHADOW | WSS_BORDER );
	//LCUITimer_Set( 5000, onTimer, NULL, TRUE );
	return LCUI_Main();
}
示例#22
0
文件: window.c 项目: gateslu/LCUI
/* 初始化window部件相关数据 */
static void 
Window_Init( LCUI_Widget *win_p )
{
	LCUI_Widget *titlebar;
	LCUI_Widget *client_area;
	LCUI_Widget *btn_close;
	LCUI_Window *win;
	static LCUI_Graph btn_bg; 
	
	win = (LCUI_Window*)Widget_NewPrivData(win_p, sizeof(LCUI_Window));
	
	titlebar = Widget_New("titlebar"); 
	client_area = Widget_New(NULL); 
	btn_close = Widget_New("button"); 
	titlebar->focus = FALSE;
	Widget_SetFocus( client_area );

	Graph_Init( &btn_bg );
	/* 载入按钮背景 */
	Window_GetCloseButtonBG( &btn_bg );
	/* 显示在左上角 */
	Widget_SetAlign(btn_close, ALIGN_TOP_RIGHT, Pos(0, 0)); 
	/* 将尺寸改成和图片一样 */
	Widget_SetAutoSize( btn_close, FALSE, 0 );
	Widget_Resize(btn_close, Size(44, 20));
	Widget_SetBackgroundImage( btn_close, &btn_bg );
	Widget_SetBackgroundLayout( btn_close, LAYOUT_CENTER );
	/* 没有背景图就填充背景色 */
	Widget_SetBackgroundTransparent( win_p, FALSE );
	/* 部件的风格ID */
	Widget_SetStyleID( win_p, WINDOW_STYLE_PURE_BLUE );
	Widget_SetStyleID( btn_close, BUTTON_STYLE_FLAT );
	/* 保存部件指针 */
	win->client_area = client_area;
	win->titlebar = titlebar;
	win->btn_close = btn_close;
	/* 放入至容器 */
	Widget_Container_Add(titlebar, btn_close);
	Widget_Container_Add(win_p, titlebar);
	Widget_Container_Add(win_p, client_area);
	/* 窗口初始尺寸 */
	Widget_Resize(win_p, Size(100, 50));
	Widget_Show(btn_close);
	/* 关联拖动事件,让鼠标能够拖动标题栏并使窗口移动 */
	Widget_Event_Connect(titlebar, EVENT_DRAG, Window_ExecMove );
	/* 
	 * 由于需要在窗口获得/失去焦点时进行相关处理,因此需要将回调函数 与部件
	 * 的FOCUS_IN和FOCUS_OUT事件 进行关联
	 * */
	Widget_Event_Connect( win_p, EVENT_FOCUSOUT, Window_FocusOut );
	Widget_Event_Connect( win_p, EVENT_FOCUSIN, Window_FocusIn );
	/* 设置窗口部件的初始位置 */
	Widget_SetAlign( win_p, ALIGN_MIDDLE_CENTER, Pos(0,0) );
}
示例#23
0
int main(int argc,char*argv[])
/* 主函数,程序的入口 */
{ 
	LCUI_Widget	*window, 
					*label,
					*pic_box,
					*fore_box; /* 使用指向widget部件的指针 */
					
	int			 width, height; 
	/* 自定义默认字体文件位置 */
	//Set_Default_Font("msyh.ttf");
	/* 初始化LCUI */ 
	LCUI_Init(argc, argv);
	/* 创建一个LCUI程序窗口 */
	width  = 320; /* 窗口的宽度 */
	height = 240; /* 窗口的高度 */
	/* 创建部件 */
	window		= Create_Widget("window");
	label		= Create_Widget("label");
	pic_box		= Create_Widget("picture_box");
	fore_box	= Create_Widget("picture_box");
	 
	Resize_Widget(fore_box, Size(190, 190));
	Resize_Widget(pic_box, Size(135,135));
	Resize_Widget(window, Size(width, height));
	 
	Set_Window_Title_Text(window, "头像");
	
	LCUI_Graph pic;
	Graph_Init(&pic); 
	Set_PictureBox_Size_Mode(pic_box, SIZE_MODE_STRETCH); 
	Set_PictureBox_Image_From_File(pic_box, "image.jpg");
	Set_PictureBox_Image_From_File(fore_box, "border.png");
	 
	Set_Label_Text(label, "蛋疼的头像");
	Set_Label_Font(label, 16, NULL);
	
	Set_Widget_Align(pic_box, ALIGN_MIDDLE_CENTER, Pos(0, -20));
	Set_Widget_Align(fore_box, ALIGN_MIDDLE_CENTER, Pos(0, -20));
	Set_Widget_Align(label, ALIGN_MIDDLE_CENTER, Pos(0, +75));
	
	Window_Client_Area_Add(window, label);
	Window_Client_Area_Add(window, pic_box); 
	Window_Client_Area_Add(window, fore_box);
	
	Show_Widget(label);
	Show_Widget(pic_box);
	Show_Widget(fore_box);
	Show_Widget(window); 
	return LCUI_Main(); 
}
示例#24
0
文件: window.c 项目: FrankHB/LCUI
static void CloseButton_OnUpdate( LCUI_Widget *widget )
{
	LCUI_Graph img;
	LCUI_Color color;
	LCUI_Widget *wnd;

	Graph_Init( &img );
	LoadCloseButtonIMG( &img );
	
	wnd = Widget_GetParent( widget, WIDGET_WINDOW );
	if( wnd ) {
		/* 若所在窗口并未获得焦点 */
		if( !Widget_GetFocus(wnd) ) {
			color = RGB(200,200,200);
		} else {
			LCUI_Window *wnd_data;
			wnd_data = (LCUI_Window*)Widget_GetPrivateData( wnd );
			color = wnd_data->theme_color;
		}
	} else {
		color = RGB(255,0,0);
	}
	
	switch(widget->state) {
	case WIDGET_STATE_NORMAL:
		Graph_FillColor( &img, RGB(150,150,150) );
		Widget_SetBackgroundImage( widget, &img );
		Widget_SetBackgroundLayout( widget, LAYOUT_CENTER );
		Widget_SetBackgroundTransparent( widget, TRUE );
		break;
	case WIDGET_STATE_ACTIVE:
		color.red = _ALPHA_BLEND( 0, color.red, 100 );
		color.green = _ALPHA_BLEND( 0, color.green, 100 );
		color.blue = _ALPHA_BLEND( 0, color.blue, 100 );
		Graph_FillColor( &img, RGB(255,255,255) );
		Widget_SetBackgroundImage( widget, &img );
		Widget_SetBackgroundColor( widget, color );
		Widget_SetBackgroundLayout( widget, LAYOUT_CENTER );
		Widget_SetBackgroundTransparent( widget, FALSE );
		break;
	case WIDGET_STATE_OVERLAY:
		Graph_FillColor( &img, RGB(255,255,255) );
		Widget_SetBackgroundImage( widget, &img );
		Widget_SetBackgroundColor( widget, color );
		Widget_SetBackgroundLayout( widget, LAYOUT_CENTER );
		Widget_SetBackgroundTransparent( widget, FALSE );
	case WIDGET_STATE_DISABLE:
	default:break;
	}
	Graph_Free( &img );
}
示例#25
0
文件: button.c 项目: yydaor/LCUI
/* 自定义按钮在各种状态下显示的位图 */
LCUI_API void
Button_CustomStyle(	LCUI_Widget *widget, LCUI_Graph *normal, 
			LCUI_Graph *over, LCUI_Graph *down, 
			LCUI_Graph *focus, LCUI_Graph *disable)
{
	LCUI_Button *btn_data;
	btn_data = Widget_GetPrivData(widget);
	if( Graph_IsValid(normal) ) {
		btn_data->btn_normal = *normal;
	} else {
		Graph_Init( &btn_data->btn_normal );
	}
	if( Graph_IsValid(over) ) {
		btn_data->btn_over = *over;
	} else {
		Graph_Init( &btn_data->btn_over );
	}
	if( Graph_IsValid(down) ) {
		btn_data->btn_down = *down;
	} else {
		Graph_Init( &btn_data->btn_down );
	}
	if( Graph_IsValid(focus) ) {
		btn_data->btn_focus = *focus;
	} else {
		Graph_Init( &btn_data->btn_focus );
	}
	if( Graph_IsValid(disable) ) {
		btn_data->btn_disable = *disable;
	} else {
		Graph_Init( &btn_data->btn_disable );
	}
	/* 设定为自定义风格 */
	Widget_SetStyleID(widget, BUTTON_STYLE_CUSTOM);
	Widget_Draw(widget); /* 重新绘制部件 */
}
示例#26
0
文件: helloworld.c 项目: li5219/LCUI
int main(int argc, char*argv[]) 
{
	/* 目前传递给LCUI_Init()函数的参数没用,以后会完善,比如指定字体路径,是否显示鼠标游标等 */
    LCUI_Init(argc, argv);
    LCUI_Widget *window, *label;
    LCUI_Graph pic;
    /* 初始化结构体 */
    Graph_Init(&pic);
    /* 载入库中自带的图形数据,这个图形是18x18尺寸的LCUI的图标 */
    Load_Graph_Icon_LCUI_18x18(&pic);
    /* 创建部件 */
    window  = Create_Widget("window");
    label   = Create_Widget("label");
    
    /* 设定窗口标题的文本 */
    Set_Window_Title_Text(window, "测试窗口");
    /* 设定窗口标题的图标 */
    Set_Window_Title_Icon(window, &pic);
    /* 改变窗口的尺寸 */
    window->resize(window, Size(320, 240));
    /* 将窗口客户区作为label部件的容器添加进去 */
    Window_Client_Area_Add(window, label);
    /* 居中显示 */
    label->set_align(label, ALIGN_MIDDLE_CENTER, Pos(0,0));
    /* 
     * 设定label部件显示的文本
     * <color=R,G,B>文字</color> 表示的是:“文字”将使用自定义颜色 
     * Set_Label_Text函数使用方法和sprintf函数基本一样,支持控制符
     **/
    Set_Label_Text(label, 
                "Hello,World!\n"
                "<color=255,0,0>世</color>"
                "<color=100,155,0>界</color>"
                "<color=0,0,0>,</color>"
                "<color=0,255,0>你</color>"
                "<color=0,100,155>好</color>"
                "<color=0,0,255>!</color>\n"); 
    
    /* 
     * 改变label部件的字体大小,单位为pixel(像素),不是pt(点数)
     * 第三个参数是自定义使用的字体文件,我设定为NULL,表示不使用。
     **/
    Set_Label_Font(label, 24, NULL);
    /* 显示部件 */
    label->show(label);
    window->show(window);
    return LCUI_Main(); /* 进入主循环 */
}
示例#27
0
文件: boxshadow.c 项目: bitbegin/LCUI
static void Graph_DrawTopLeftShadow( LCUI_PaintContext paint, LCUI_Rect *box, 
				     LCUI_BoxShadow *shadow)
{
	LCUI_Pos pos;
	LCUI_Rect bound;
	LCUI_Graph canvas;
	bound.w = bound.h = BLUR_WIDTH(shadow);
	bound.x = box->x + BoxShadow_GetX( shadow );
	bound.y = box->y + BoxShadow_GetY( shadow );
	if( LCUIRect_GetOverlayRect( &bound, &paint->rect, &bound ) ) {
		Graph_Init( &canvas );
		bound.x -= paint->rect.x;
		bound.y -= paint->rect.y;
		pos.x = bound.x + BLUR_WIDTH( shadow );
		pos.y = bound.y + BLUR_WIDTH( shadow );
		Graph_Quote( &canvas, &paint->canvas, &bound );
		DrawCircle( &canvas, pos, bound.w, shadow->color );
	}
}
示例#28
0
int main()
{
	LCUI_Graph graph_buff;
	LCUI_GraphLayer *root_glayer;
	LCUI_GraphLayer *a_glayer, *b_glayer, *c_glayer;

	Graph_Init( &graph_buff );
	/* 新建图层 */
	root_glayer = GraphLayer_New();
	a_glayer = GraphLayer_New();
	b_glayer = GraphLayer_New();
	c_glayer = GraphLayer_New();
	/* 调整图层尺寸 */
	GraphLayer_Resize( root_glayer, 320, 240 );
	GraphLayer_Resize( a_glayer, 200, 150 );
	GraphLayer_Resize( b_glayer, 100, 100 );
	GraphLayer_Resize( c_glayer, 80, 80 );
	/* 填充颜色 */
	Graph_FillColor( &root_glayer->graph, RGB(255,255,255) );
	Graph_FillColor( &a_glayer->graph, RGB(255,50,50) );
	Graph_FillColor( &b_glayer->graph, RGB(50,255,50) );
	Graph_FillColor( &c_glayer->graph, RGB(50,50,255) );
	/* 建立父子图层关系 */
	GraphLayer_AddChild( b_glayer, c_glayer );
	GraphLayer_AddChild( root_glayer, a_glayer );
	GraphLayer_AddChild( root_glayer, b_glayer );
	/* 调整图层坐标 */
	GraphLayer_SetPos( a_glayer, 50, 50 );
	GraphLayer_SetPos( b_glayer, 175, 125 );
	GraphLayer_SetPos( c_glayer, -15, 30 );
	/* 显示图层 */
	GraphLayer_Show( root_glayer );
	GraphLayer_Show( a_glayer );
	GraphLayer_Show( b_glayer );
	GraphLayer_Show( c_glayer );
	/* 获取根图层指定区域内实际显示的图形 */
	GraphLayer_GetGraph( root_glayer, &graph_buff, Rect(0,0,320,240) );
	/* 写入至文件 */
	Graph_WritePNG( OUTPUT_GRAPHFILE, &graph_buff );
	printf( "please see file: %s \n", OUTPUT_GRAPHFILE );
	GraphLayer_Free( root_glayer );
	return 0;
}
示例#29
0
/** 构造函数 */
static void $(Init)( LCUI_Widget widget )
{
	widget->style.z_index = 0;
	widget->style.x.type = SVT_NONE;
	widget->style.y.type = SVT_NONE;
	widget->style.width.type = SVT_AUTO;
	widget->style.height.type = SVT_AUTO;
	widget->style.box_sizing = CONTENT_BOX;
	widget->style.opacity = 1.0;
	widget->style.margin.top.px = 0;
	widget->style.margin.right.px = 0;
	widget->style.margin.bottom.px = 0;
	widget->style.margin.left.px = 0;
	widget->style.margin.top.type = SVT_PX;
	widget->style.margin.right.type = SVT_PX;
	widget->style.margin.bottom.type = SVT_PX;
	widget->style.margin.left.type = SVT_PX;
	widget->style.padding.top.px = 0;
	widget->style.padding.right.px = 0;
	widget->style.padding.bottom.px = 0;
	widget->style.padding.left.px = 0;
	widget->style.padding.top.type = SVT_PX;
	widget->style.padding.right.type = SVT_PX;
	widget->style.padding.bottom.type = SVT_PX;
	widget->style.padding.left.type = SVT_PX;
	widget->event = LCUIEventBox_Create();
	memset( &widget->base, 0, sizeof(widget->base));
	widget->parent = NULL;
	widget->title = NULL;
	widget->event = LCUIEventBox_Create();
	Widget_InitTaskBox( widget );
	Background_Init( &widget->style.background );
	BoxShadow_Init( &widget->style.shadow );
	Border_Init( &widget->style.border );
	LinkedList_Init( &widget->children, sizeof(struct LCUI_WidgetFull) );
	LinkedList_Init( &widget->children_show, 0 );
	LinkedList_SetDestroyFunc( &widget->children, $(OnDestroy) );
	LinkedList_SetDataNeedFree( &widget->children, TRUE );
	LinkedList_SetDataNeedFree( &widget->children_show, FALSE );
	DirtyRectList_Init( &widget->dirty_rects );
	Graph_Init( &widget->graph );
}
示例#30
0
int main( int argc, char*argv[] )
{ 
	LCUI_Graph pic;
	int width = 320, height = 240;
	LCUI_Widget *window, *label, *pic_box, *fore_box;
	
	LCUI_Init();
	Graph_Init(&pic); 
	
	window	 = Widget_New("window");
	label	 = Widget_New("label");
	pic_box	 = Widget_New("picture_box");
	fore_box = Widget_New("picture_box");
	 
	Widget_Resize(fore_box, Size(190, 190));
	Widget_Resize(pic_box, Size(135,135));
	Widget_Resize(window, Size(width, height));
	 
	Window_SetTitleText(window, "头像");
	
	PictureBox_SetSizeMode(pic_box, SIZE_MODE_STRETCH); 
	PictureBox_SetImageFile(pic_box, "image.jpg");
	PictureBox_SetImageFile(fore_box, "border.png");
	 
	Label_Text(label, "蛋疼的头像");
	
	Widget_SetAlign(pic_box, ALIGN_MIDDLE_CENTER, Pos(0, -20));
	Widget_SetAlign(fore_box, ALIGN_MIDDLE_CENTER, Pos(0, -20));
	Widget_SetAlign(label, ALIGN_MIDDLE_CENTER, Pos(0, +75));
	
	Window_ClientArea_Add(window, label);
	Window_ClientArea_Add(window, pic_box); 
	Window_ClientArea_Add(window, fore_box);
	
	Widget_Event_Connect( Window_GetCloseButton(window), EVENT_CLICKED, destroy );
	
	Widget_Show(label);
	Widget_Show(pic_box);
	Widget_Show(fore_box);
	Widget_Show(window); 
	return LCUI_Main(); 
}