int main( int argc, char **argv ) { LCUI_Widget root, pack, btn; LCUI_Init(); root = LCUIWidget_GetRoot(); pack = LCUIBuilder_LoadFile( "helloworld.xml" ); if( !pack ) { return -1; } Widget_Append( root, pack ); Widget_Unwrap( pack ); btn = LCUIWidget_GetById( "btn" ); Widget_BindEvent( btn, "click", OnBtnClick, NULL, NULL ); return LCUI_Main(); }
int main( int argc, char **argv ) { LCUI_Widget root, box; #ifdef LCUI_BUILD_IN_WIN32 InitConsoleWindow(); #endif LCUI_Init(); LCUIDisplay_SetMode( LDM_WINDOWED ); LCUIDisplay_SetSize( 960, 540 ); box = LCUIBuilder_LoadFile("hello.xml"); if( box ) { root = LCUIWidget_GetRoot(); Widget_Append( root, box ); Widget_Unwrap( &box ); } return LCUI_Main(); }
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; }
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; }
}; static void OnBtnClick( LCUI_Widget self, LCUI_WidgetEvent e, void *arg ) { wchar_t str[256]; LCUI_Widget edit = LCUIWidget_GetById( "edit" ); LCUI_Widget txt = LCUIWidget_GetById( "text-hello" ); TextEdit_GetTextW( edit, 0, 255, str ); TextView_SetTextW( txt, str ); } void App::Load( Platform::String^ entryPoint ) { LCUI_Widget btn, root, pack; root = LCUIWidget_GetRoot(); pack = LCUIBuilder_LoadFile( "helloworld.xml" ); if( !pack ) { return; } Widget_Append( root, pack ); Widget_Unwrap( pack ); btn = LCUIWidget_GetById( "btn" ); Widget_BindEvent( btn, "click", OnBtnClick, NULL, NULL ); } [Platform::MTAThread] int main( Platform::Array<Platform::String^>^ ) { App app; LCUI::Initialize(); LCUI::Run( app );