예제 #1
0
파일: button.c 프로젝트: yydaor/LCUI
static void Button_ExecDefalutUpdate( LCUI_Widget *widget )
{
	LCUI_Border border;
	LCUI_RGB border_color;

	switch( widget->state ) {
	case WIDGET_STATE_NORMAL:
		Widget_SetBackgroundColor( widget, RGB(230,230,230) );
		/* 获得焦点的按钮,使用另一种颜色的边框 */
		if( Widget_GetFocus(widget) ) {
			border_color = RGB(50,150,255);
		} else {
			border_color = RGB(172,172,172);
		}
		break;
	case WIDGET_STATE_OVERLAY :
		Widget_SetBackgroundColor( widget, RGB(232,242,252) );
		border_color = RGB(126,180,234);
		break;
	case WIDGET_STATE_ACTIVE :
		Widget_SetBackgroundColor( widget, RGB(207,230,252) );
		border_color = RGB(86,157,229);
		break;
	case WIDGET_STATE_DISABLE :
		Widget_SetBackgroundColor( widget, RGB(200,200,200) );
		border_color = RGB(172,172,172);
		break;
		default : break;
	}
	border = Border(1, BORDER_STYLE_SOLID, border_color );
	Widget_SetBorder( widget, border );
	Widget_SetBackgroundTransparent( widget, FALSE );
}
예제 #2
0
파일: window.c 프로젝트: FrankHB/LCUI
static void Window_OnUpdate( LCUI_Widget *window )
{
	LCUI_Window *wnd;
	LCUI_Border border;
	char h_str[20];

	wnd = (LCUI_Window*)Widget_GetPrivateData( window );
	border = Border( 1, BORDER_STYLE_SOLID, RGB(200,200,200) );
	border.top_width = TOP_PANDDING;
	/* 若窗口已获得焦点 */
	if( Widget_GetFocus( window ) ) {
		border.top_color = wnd->theme_color;
		border.bottom_color = wnd->theme_color;
		border.left_color = wnd->theme_color;
		border.right_color = wnd->theme_color;
		Widget_SetShadow( window, BoxShadow(0,0,8,wnd->theme_color) );
	} else {
		Widget_SetShadow( window, BoxShadow(0,0,8,ARGB(120,200,200,200)) );
	}
	Widget_SetBorder( window, border );
	/* 更新窗口标题栏上的关闭按钮 */
	Widget_Update( wnd->btn_close );
	sprintf( h_str, "%dpx", Widget_GetContainerHeight(window)-35 );
	Widget_SetSize( wnd->client_area, "100%", h_str );
}
예제 #3
0
파일: widget_event.c 프로젝트: FrankHB/LCUI
/** 设定部件是否能够获取焦点 */
LCUI_API void Widget_SetCanGetFocus( LCUI_Widget *widget, LCUI_BOOL flag )
{
	/* 如果该部件已经获得焦点,并且要设置它不能获取焦点,则取消当前焦点 */
	if( Widget_GetFocus(widget) && !flag ) {
		Widget_CancelFocus( widget );
	}
	widget->focus = flag;
}
예제 #4
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 );
}
예제 #5
0
파일: window.c 프로젝트: gateslu/LCUI
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;
	}
}