int test_widget_rect( void ) { int i, ret = 0; float values[3] = { 1.0f, 1.5f, 2.0f }; for( i = 0; i < 3; ++i ) { memset( &self, 0, sizeof( self ) ); TEST_LOG( "test widget rectagle in " "%g%% scaling mode\n", values[i] * 100 ); LCUI_Init(); #ifdef _WIN32 Logger_SetHandler( LoggerHandler ); Logger_SetHandlerW( LoggerHandlerW ); #endif self.widget = create_widget(); LCUIMetrics_SetScale( values[i] ); LCUIDisplay_SetSize( SCREEN_WIDTH, SCREEN_HEIGHT ); /* 等一段时间后再开始测试,避免初始化 LCUI 时产生的脏矩形影响测试结果 */ LCUITimer_Set( 100, start_test, NULL, FALSE ); LCUIWidget_Update(); if( LCUI_Main() != 0 ) { ret -= 1; } } return ret; }
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(); }
static int LCUIDisplay_FullScreen( void ) { switch( display.mode ) { case LDM_SEAMLESS: LCUIDisplay_CleanSurfaces(); LCUIDisplay_BindSurface( LCUIRootWidget ); case LDM_WINDOWED: default: break; case LDM_FULLSCREEN: return 0; } LCUIDisplay_SetSize( display.info.getWidth(), display.info.getHeight() ); display.mode = LDM_FULLSCREEN; return 0; }
static int LCUIDisplay_FullScreen( void ) { LCUI_Widget root = LCUIWidget_GetRoot(); switch( display.mode ) { case LCDM_SEAMLESS: LCUIDisplay_CleanSurfaces(); LCUIDisplay_BindSurface(root ); case LCDM_WINDOWED: default: break; case LCDM_FULLSCREEN: return 0; } display.mode = LCDM_FULLSCREEN; LCUIDisplay_SetSize( LCUIDisplay_GetWidth(), LCUIDisplay_GetHeight() ); return 0; }
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; }