Exemplo n.º 1
0
int Widget_RemoveClass(LCUI_Widget w, const char *class_name)
{
	if (strshas(w->classes, class_name)) {
		Widget_HandleChildrenStyleChange(w, 0, class_name);
		strsdel(&w->classes, class_name);
		Widget_UpdateStyle(w, TRUE);
		return 1;
	}
	return 0;
}
Exemplo n.º 2
0
static void OnToggle( LCUI_Widget w, LCUI_WidgetEvent e, void *arg )
{
	LCUI_Widget sidebar = w->parent->parent;
	if( Widget_HasClass( sidebar, "sidebar-mini" ) ) {
		Widget_RemoveClass( sidebar, "sidebar-mini" );
	} else {
		Widget_AddClass( sidebar, "sidebar-mini" );
	}
	Widget_UpdateStyle( sidebar, TRUE );
	e->cancel_bubble = TRUE;
}
Exemplo n.º 3
0
int Widget_AddClass(LCUI_Widget w, const char *class_name)
{
	if (strshas(w->classes, class_name)) {
		return 1;
	}
	if (strsadd(&w->classes, class_name) <= 0) {
		return 0;
	}
	Widget_HandleChildrenStyleChange(w, 0, class_name);
	Widget_UpdateStyle(w, TRUE);
	return 1;
}
Exemplo n.º 4
0
int TestCSSParser(void)
{
	LCUI_Widget box, btn, text;
	box = LCUIBuilder_LoadFile( "test_css_parser.xml" );
	if( !box ) {
		return -1;
	}
	text = LCUIWidget_GetById( "test-textview" );
	Widget_UpdateStyle( text, TRUE );
	Widget_Update( text );
	assert( text->style->sheet[key_width].val_px == 100 );
	assert( text->style->sheet[key_height].val_px == 60 );
	assert( text->style->sheet[key_position].val_style == SV_ABSOLUTE );
	assert( text->style->sheet[key_top].val_px == 12 );
	assert( text->style->sheet[key_left].val_px == 20 );
	btn = LCUIWidget_GetById( "test-btn" );
	Widget_AddStatus( btn, "hover" );
	Widget_UpdateStyle( btn, TRUE );
	Widget_UpdateStyle( text, TRUE );
	Widget_Update( text );
	assert( text->style->sheet[key_background_color].val_color.value == 0xffff0000 );
	assert( text->style->sheet[key_background_size].val_style == SV_CONTAIN );
	return 0;
}
Exemplo n.º 5
0
int test_xml_parser( void )
{
	int ret = 0;
	LCUI_Widget root, pack;

	LCUI_Init();
	TEST_LOG( "test widget layout\n" );
	LCUIDisplay_SetSize( 960, 680 );
	root = LCUIWidget_GetRoot();
	CHECK( pack = LCUIBuilder_LoadFile( "test_xml_parser.xml" ) );
	if( !pack ) {
		LCUI_Destroy();
		return ret;
	}
	Widget_UpdateStyle( root, TRUE );
	Widget_Append( root, pack );
	Widget_Unwrap( pack );
	LCUIWidget_Update();
	ret += check_widget_attribute();
	LCUI_Destroy();
	return ret;
}
int test_widget_inline_block_layout( void )
{
	int ret = 0;
	LCUI_Widget root, pack;

	LCUI_Init();
	TEST_LOG( "test widget inline block layout\n" );
	LCUIDisplay_SetSize( SCREEN_WIDTH, SCREEN_HEIGHT );
	root = LCUIWidget_GetRoot();
	CHECK( pack = LCUIBuilder_LoadFile( "test_widget_inline_block_layout.xml" ) );
	if( !pack ) {
		LCUI_Destroy();
		return ret;
	}
	Widget_UpdateStyle( root, TRUE );
	Widget_Append( root, pack );
	Widget_Unwrap( pack );
	LCUIWidget_Update();
	ret += check_layout();
	LCUI_Destroy();
	return ret;
}
Exemplo n.º 7
0
static void OnSidebarBtnClick( LCUI_Widget self, LCUI_WidgetEvent e, void *unused )
{
	int i;
	LCUI_Widget sidebar;
	LCUI_Widget btn, view = e->data;
	const char *view_id = view->id;
	Widget_RemoveClass( view, "hide" );
	Widget_UpdateStyle( view, TRUE );
	Widget_Show( view );
	for( i = 0; i < MAX_VIEWS; ++i ) {
		if( strcmp( view_id, btn_view_ids[i][1] ) == 0 ) {
			continue;
		}
		btn = LCUIWidget_GetById( btn_view_ids[i][0] );
		view = LCUIWidget_GetById( btn_view_ids[i][1] );
		Widget_AddClass( view, "hide" );
		Widget_RemoveClass( btn, "active" );
		Widget_Hide( view );
	}
	sidebar = LCUIWidget_GetById( "main-sidebar" );
	Widget_AddClass( sidebar, "sidebar-mini" );
	Widget_AddClass( self, "active" );
}
Exemplo n.º 8
0
void LCUIWidget_RefreshStyle(void)
{
	LCUI_Widget root = LCUIWidget_GetRoot();
	Widget_UpdateStyle(root, TRUE);
	Widget_AddTaskForChildren(root, LCUI_WTASK_REFRESH_STYLE);
}