Esempio n. 1
0
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 );
}
Esempio n. 2
0
/* 初始化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) );
}
Esempio n. 3
0
File: button.c Progetto: yydaor/LCUI
static void Button_ExecCustomUpdate( LCUI_Widget *widget )
{
	LCUI_Button *btn;
	LCUI_Graph *img;
	
	btn = Widget_GetPrivData( widget );
	switch(widget->state) {
	case WIDGET_STATE_NORMAL: img = &btn->btn_normal; break;
	case WIDGET_STATE_OVERLAY: img = &btn->btn_over; break;
	case WIDGET_STATE_ACTIVE: img = &btn->btn_down; break;
	case WIDGET_STATE_DISABLE: img = &btn->btn_disable; break;
	default : img = NULL; break;
	}
	Widget_SetBackgroundImage( widget, img );
	/* 如果图像不可用,则使用默认样式 */
	if( !Graph_IsValid(img) ) {
		Button_ExecDefalutUpdate( widget );
	} else {
		Widget_SetBackgroundTransparent( widget, TRUE );
		Widget_SetBackgroundLayout( widget, LAYOUT_STRETCH );
	}
}
Esempio n. 4
0
static void 
ActiveBox_ExecUpdate(LCUI_Widget *widget)
/* 功能:更新ActiveBox部件内显示的图像 */
{
	LCUI_Rect rect;
	LCUI_Frames *frames;
	LCUI_Graph *frame_graph;
	LCUI_Pos pos;
	
	frames = ActiveBox_GetFrames( widget );
	frame_graph = Frames_GetGraphSlot( frames );
	pos = Align_Get_Pos( Widget_GetSize(widget), 
				frames->size, ALIGN_MIDDLE_CENTER);

	Widget_SetBackgroundTransparent( widget, TRUE );
	Widget_SetBackgroundImage( widget, frame_graph );
	Widget_SetBackgroundLayout( widget, LAYOUT_NONE );
	rect.x = pos.x;
	rect.y = pos.y;
	rect.width = frame_graph->width;
	rect.height = frame_graph->height;
	Widget_InvalidArea( widget, rect );
}
Esempio n. 5
0
/** 初始化window部件相关数据 */
static void Window_OnInit( LCUI_Widget *window )
{
	LCUI_Window *wnd;
	LCUI_Graph btn_bg;
	LCUI_TextStyle style;
	LCUI_Border border;
	
	wnd = Widget_NewPrivateData( window, LCUI_Window );

	wnd->theme_color = COLOR_EMERALD;
	wnd->theme_color.a = 128;
	wnd->titlebar = Widget_New(NULL); 
	wnd->client_area = Widget_New(NULL); 
	wnd->btn_close = Widget_New(WIDGET_CLOSE_BUTTON); 
	wnd->icon = Widget_New(NULL);
	wnd->text = Label_New();

	wnd->titlebar->focus = FALSE;
	wnd->icon->focus = FALSE;
	wnd->text->focus = FALSE;
	Widget_SetFocus( wnd->client_area );
	Widget_SetClickable( wnd->icon, FALSE );
	Widget_SetClickable( wnd->text, FALSE );
	Widget_SetClickable( wnd->titlebar, FALSE );
	Widget_SetClickable( wnd->client_area, FALSE );

	Graph_Init( &btn_bg );
	/* 载入按钮背景 */
	LoadCloseButtonIMG( &btn_bg );
	/* close按钮显示在左上角 */
	Widget_SetAlign( wnd->btn_close, ALIGN_TOP_RIGHT, Pos(0,0) );
	Widget_Resize( wnd->btn_close, Size(30, 30) );

	Widget_SetBackgroundImage( wnd->btn_close, &btn_bg );
	Widget_SetBackgroundLayout( wnd->btn_close, LAYOUT_CENTER );
	Widget_SetBackgroundTransparent( wnd->icon, TRUE );
	Widget_SetBackgroundTransparent( wnd->titlebar, TRUE );
	Widget_SetBackgroundTransparent( wnd->client_area, FALSE );
	Widget_SetBackgroundTransparent( window, FALSE );
	Widget_SetBackgroundColor( window, RGB(255,255,255) );
	Widget_SetBackgroundLayout( wnd->icon, LAYOUT_ZOOM );
	Widget_SetDock( wnd->titlebar, DOCK_TYPE_TOP );
	Widget_SetDock( wnd->client_area, DOCK_TYPE_BOTTOM );
	Widget_SetPadding( window, Padding(TOP_PANDDING,1,1,1) );
	Widget_SetPadding( wnd->client_area, Padding(1,1,1,1) );
	Widget_SetSize( wnd->titlebar, "100%", "35px" );
	
	Border_Init( &border );
	border.top_width = 0;
	border.bottom_width = 1;
	border.left_width = 1;
	border.right_width = 1;
	border.bottom_color = RGB(200,200,200);
	border.left_color = RGB(255,255,255);
	border.right_color = RGB(255,255,255);
	Widget_SetBorder( wnd->titlebar, border );

	TextStyle_Init( &style );
	TextStyle_FontSize( &style, 18 );
	Label_SetTextStyle( wnd->text, style );

	/* 放入至容器 */
	Widget_Container_Add( wnd->titlebar, wnd->icon );
	Widget_Container_Add( wnd->titlebar, wnd->text );
	Widget_Container_Add( wnd->titlebar, wnd->btn_close );
	Widget_Container_Add( window, wnd->titlebar );
	Widget_Container_Add( window, wnd->client_area );

	Widget_Resize( window, Size(100, 50) );
	Widget_Resize( wnd->icon, Size(24,24) );
	
	Widget_SetAlign( window, ALIGN_MIDDLE_CENTER, Pos(0,0) );
	Widget_SetAlign( wnd->icon, ALIGN_MIDDLE_LEFT, Pos(6,0) );
	Widget_SetAlign( wnd->text, ALIGN_MIDDLE_LEFT, Pos(6,0) );

	/* 关联拖动事件,让鼠标能够拖动标题栏并使窗口移动 */
	Widget_ConnectEvent( window, EVENT_DRAG, Window_ExecMove );
	/* 
	 * 由于需要在窗口获得/失去焦点时进行相关处理,因此需要将回调函数 与部件
	 * 的FOCUS_IN和FOCUS_OUT事件 进行关联
	 * */
	Widget_ConnectEvent( window, EVENT_FOCUSOUT, Window_OnFocusOut );
	Widget_ConnectEvent( window, EVENT_FOCUSIN, Window_OnFocusIn );
	
	Widget_Show( wnd->btn_close );
	Widget_Show( wnd->icon );
	Widget_Show( wnd->text );
	Widget_Show( wnd->titlebar );
	Widget_Show( wnd->client_area );
}
Esempio n. 6
0
static void
Window_ExecUpdate( LCUI_Widget *win_p )
{
	LCUI_Size size;
	LCUI_Graph *graph;
	LCUI_Border border;
	LCUI_Widget *titlebar, *btn, *client_area;
	LCUI_RGB border_color, back_color;
	
	btn = Window_GetCloseButton(win_p);
	titlebar = Window_GetTitleBar(win_p);
	client_area = Window_GetClientArea(win_p);
	graph = Widget_GetSelfGraph( win_p );
	/* 按不同的风格来处理 */ 
	switch( win_p->style_id ) {
	    case WINDOW_STYLE_NONE:  /* 没有边框 */
		/* 先计算坐标和尺寸 */
		Widget_SetDock( client_area, DOCK_TYPE_FILL );
		Widget_Hide( titlebar );/* 隐藏标题栏 */
		Widget_Show( client_area );/* 客户区需要显示 */
		break;
			
	    case WINDOW_STYLE_LINE: /* 线条边框 */
		Widget_SetBorder(win_p,
		 Border(1, BORDER_STYLE_SOLID, RGB(50,50,50)));
		Widget_SetPadding( win_p, Padding(1,1,1,1) );
		Widget_SetDock( client_area, DOCK_TYPE_FILL );
		Widget_Hide( titlebar );
		Widget_Show( client_area );
		break;

	    case WINDOW_STYLE_PURE_BLUE: 
		back_color = RGB(30,160,225); 
		border_color = RGB(0,130,195);
		goto union_draw_method;
	    case WINDOW_STYLE_PURE_GREEN:
		back_color = RGB(140,190,40);
		border_color = RGB(110,160,10);
		goto union_draw_method;
	    case WINDOW_STYLE_PURE_RED: 
		back_color = RGB(230,20,0);
		border_color = RGB(200,0,0);
		goto union_draw_method;
	    case WINDOW_STYLE_PURE_ORANGE: 
		back_color = RGB(240,150,10);
		border_color = RGB(210,120,0); 
		goto union_draw_method;
	    case WINDOW_STYLE_PURE_PURPLE:
		back_color = RGB(110,20,95);
		border_color = RGB(80,0,65); 
union_draw_method:;
		/* 若窗口未获得焦点 */
		if( !Widget_GetFocus( win_p ) ) {
			back_color = RGB(235,235,235);
			border_color = RGB(211,211,211);
		}
		/* 更新窗口标题栏上的关闭按钮 */
		Widget_Update( btn );
		border = Border(1, BORDER_STYLE_SOLID, border_color);
		Widget_SetBorder( client_area, border);
		Widget_SetBorder( win_p, border);
		Widget_SetBackgroundColor( win_p, back_color );
		Graph_FillColor( graph, back_color );
		Widget_SetBackgroundColor( client_area, RGB(255,255,255) );
		Widget_SetBackgroundImage( titlebar, NULL );
		Widget_SetBackgroundLayout( titlebar, 0 );
		Widget_SetBackgroundTransparent( titlebar, TRUE );
		Widget_SetBackgroundTransparent( client_area, FALSE );
		Widget_SetPadding( win_p, Padding(1,4,4,4) );
		Widget_SetPadding( client_area, Padding(1,1,1,1) );
		size = Widget_GetContainerSize( win_p );
		Widget_Resize( titlebar, Size(size.h, 25) );
		Widget_Resize( client_area, Size(size.w, size.h - 25) );
		Widget_SetDock( titlebar, DOCK_TYPE_TOP ); 
		Widget_SetDock( client_area, DOCK_TYPE_BOTTOM );
		Widget_Show( titlebar );
		Widget_Show( client_area ); 
		break;
	    default:
			//
		break;
	}
}
Esempio n. 7
0
static void CreateGUI( LCUI_Widget *win )
{
	/* 创建部件 */
	time_box	= Widget_New(NULL);
	pic_bg		= Widget_New(NULL);
	pic_l1		= Widget_New(NULL);
	pic_l2		= Widget_New(NULL);
	pic_c		= Widget_New(NULL);
	pic_btn		= Widget_New(NULL);
	pic_btn_line	= Widget_New(NULL);
	pic_btn		= Widget_New(NULL);
	pic_r1		= Widget_New(NULL);
	pic_r2		= Widget_New(NULL);
	date_label	= Widget_New("label");
	wday_label	= Widget_New("label");
	/* 设置这些部件的初始背景图 */
	Widget_SetBackgroundImage( pic_bg, &img_bg );
	Widget_SetBackgroundImage( pic_btn_line, &img_btn_bg );
	Widget_SetBackgroundLayout( pic_btn_line, LAYOUT_CENTER );
	Widget_SetBackgroundImage( pic_btn, &img_btn );
	Widget_SetBackgroundImage( pic_l1, &img_digital[0] );
	Widget_SetBackgroundImage( pic_l2, &img_digital[0] );
	Widget_SetBackgroundImage( pic_r1, &img_digital[0] );
	Widget_SetBackgroundImage( pic_r2, &img_digital[0] );
	Widget_SetBackgroundImage( pic_c,  &img_dot );
	/* 调整尺寸 */
	Widget_Resize( time_box,	Size(162, 38) );
	Widget_Resize( pic_bg,		Size(300, 90) );
	Widget_Resize( pic_btn_line,	Size(245, 66) );
	Widget_Resize( pic_btn,		Size(46, 66) );
	Widget_Resize( pic_l1,		Size(33, 36) );
	Widget_Resize( pic_l2,		Size(33, 36) );
	Widget_Resize( pic_c,		Size(30, 38) );
	Widget_Resize( pic_r1,		Size(33, 36) );
	Widget_Resize( pic_r2,		Size(33, 36) );
	/* 调整布局 */
	Widget_SetAlign( pic_l1, ALIGN_MIDDLE_CENTER, Pos(-66,0) );
	Widget_SetAlign( pic_l2, ALIGN_MIDDLE_CENTER, Pos(-33,0) );
	Widget_SetAlign( pic_c, ALIGN_MIDDLE_CENTER, Pos(0,0) );
	Widget_SetAlign( pic_r1, ALIGN_MIDDLE_CENTER, Pos(33,0) );
	Widget_SetAlign( pic_r2, ALIGN_MIDDLE_CENTER, Pos(66,0) );
	Widget_SetAlign( time_box, ALIGN_MIDDLE_CENTER, Pos(0,-50) );
	Widget_SetAlign( pic_bg, ALIGN_MIDDLE_CENTER, Pos(0,5) );
	Widget_SetAlign(date_label, ALIGN_MIDDLE_CENTER, Pos(0,35-50) );
	Widget_SetAlign( wday_label, ALIGN_TOP_CENTER, Pos(0,5) );
	Widget_SetAlign( pic_btn_line, ALIGN_BOTTOM_CENTER, Pos(0,-10) );
	/* 放入容器 */
	Widget_Container_Add( time_box, pic_l1 );
	Widget_Container_Add( time_box, pic_l2 );
	Widget_Container_Add( time_box, pic_c );
	Widget_Container_Add( time_box, pic_r1 );
	Widget_Container_Add( time_box, pic_r2 );
	Widget_Container_Add( pic_btn_line, pic_btn );

	Window_ClientArea_Add( win, pic_bg );
	Window_ClientArea_Add( win, time_box );
	Window_ClientArea_Add( win, date_label );
	Window_ClientArea_Add( win, wday_label );
	Window_ClientArea_Add (win, pic_btn_line );
	/* 限制移动范围 */
	Widget_LimitPos(pic_btn, Pos(0,0), Pos(195,0));
	Widget_ConnectEvent(pic_btn, EVENT_DRAG, move_pic_btn);

	Widget_Show(pic_bg);
	Widget_Show(pic_l1);
	Widget_Show(pic_l2);
	Widget_Show(pic_c);
	Widget_Show(pic_r1);
	Widget_Show(pic_r2);
	Widget_Show(time_box);
	Widget_Show(wday_label);
	Widget_Show(date_label);
	Widget_Show(pic_btn);
	Widget_Show(pic_btn_line);

	UpdateTimeView(NULL);
}