Beispiel #1
0
int main()
{
	LCUI_Graph graph_buff;
	LCUI_GraphLayer *root_glayer;
	LCUI_GraphLayer *a_glayer, *b_glayer, *c_glayer;

	Graph_Init( &graph_buff );
	/* 新建图层 */
	root_glayer = GraphLayer_New();
	a_glayer = GraphLayer_New();
	b_glayer = GraphLayer_New();
	c_glayer = GraphLayer_New();
	/* 调整图层尺寸 */
	GraphLayer_Resize( root_glayer, 320, 240 );
	GraphLayer_Resize( a_glayer, 200, 150 );
	GraphLayer_Resize( b_glayer, 100, 100 );
	GraphLayer_Resize( c_glayer, 80, 80 );
	/* 填充颜色 */
	Graph_FillColor( &root_glayer->graph, RGB(255,255,255) );
	Graph_FillColor( &a_glayer->graph, RGB(255,50,50) );
	Graph_FillColor( &b_glayer->graph, RGB(50,255,50) );
	Graph_FillColor( &c_glayer->graph, RGB(50,50,255) );
	/* 建立父子图层关系 */
	GraphLayer_AddChild( b_glayer, c_glayer );
	GraphLayer_AddChild( root_glayer, a_glayer );
	GraphLayer_AddChild( root_glayer, b_glayer );
	/* 调整图层坐标 */
	GraphLayer_SetPos( a_glayer, 50, 50 );
	GraphLayer_SetPos( b_glayer, 175, 125 );
	GraphLayer_SetPos( c_glayer, -15, 30 );
	/* 显示图层 */
	GraphLayer_Show( root_glayer );
	GraphLayer_Show( a_glayer );
	GraphLayer_Show( b_glayer );
	GraphLayer_Show( c_glayer );
	/* 获取根图层指定区域内实际显示的图形 */
	GraphLayer_GetGraph( root_glayer, &graph_buff, Rect(0,0,320,240) );
	/* 写入至文件 */
	Graph_WritePNG( OUTPUT_GRAPHFILE, &graph_buff );
	printf( "please see file: %s \n", OUTPUT_GRAPHFILE );
	GraphLayer_Free( root_glayer );
	return 0;
}
Beispiel #2
0
LCUI_API int
LCUIScreen_Init( void )
{
	RECT client_rect;
	LCUI_Graph *graph;
	WNDCLASS wndclass;
	TCHAR szAppName[] = TEXT ("Typer");
	
	wndclass.style         = CS_HREDRAW | CS_VREDRAW ;
	wndclass.lpfnWndProc   = Win32_LCUI_WndProc;
	wndclass.cbClsExtra    = 0 ;
	wndclass.cbWndExtra    = 0 ;
	wndclass.hInstance     = win32_hInstance;
	wndclass.hIcon         = LoadIcon (NULL, IDI_APPLICATION) ;
	wndclass.hCursor       = LoadCursor (NULL, IDC_ARROW) ;
	wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
	wndclass.lpszMenuName  = NULL ;
	wndclass.lpszClassName = szAppName ;

	if (!RegisterClass (&wndclass)) {
		MessageBox (NULL, TEXT ("This program requires Windows NT!"), 
		szAppName, MB_ICONERROR) ;
		return 0;
	}
	
	current_hwnd = CreateWindow (
			szAppName, TEXT ("LCUI"),
			WS_OVERLAPPEDWINDOW &~WS_THICKFRAME,
			CW_USEDEFAULT, CW_USEDEFAULT,
			WIN32_WINDOW_WIDTH, WIN32_WINDOW_HEIGHT,
			NULL, NULL, win32_hInstance, NULL);
	
	GetClientRect( current_hwnd, &client_rect );

	LCUI_Sys.screen.fb_dev_fd = -1;
	LCUI_Sys.screen.fb_dev_name = "win32";
	LCUI_Sys.screen.bits = 32;
	LCUI_Sys.screen.size.w = client_rect.right;
	LCUI_Sys.screen.size.h = client_rect.bottom; 
	LCUI_Sys.screen.smem_len = LCUI_Sys.screen.size.w * LCUI_Sys.screen.size.h * 4;
	/* 分配内存,储存像素数据 */ 
	pixel_mem = malloc ( LCUI_Sys.screen.smem_len );
	LCUI_Sys.screen.fb_mem = pixel_mem;
	LCUI_Sys.root_glayer = GraphLayer_New();
	GraphLayer_Resize( LCUI_Sys.root_glayer, LCUI_Sys.screen.size.w, LCUI_Sys.screen.size.h );
	graph = GraphLayer_GetSelfGraph( LCUI_Sys.root_glayer );
	Graph_FillColor( graph, RGB(255,255,255) );

	/* 获取客户区的DC */
	hdc_client = GetDC( current_hwnd );
	/* 为帧缓冲创建一个DC */
	hdc_framebuffer = CreateCompatibleDC( hdc_client );
	/* 为客户区创建一个Bitmap */ 
	client_bitmap = CreateCompatibleBitmap( hdc_client, LCUI_Sys.screen.size.w, LCUI_Sys.screen.size.h );
	/* 为帧缓冲的DC选择client_bitmap作为对象 */
	SelectObject( hdc_framebuffer, client_bitmap );
	
	GraphLayer_Show( LCUI_Sys.root_glayer );
	ShowWindow( current_hwnd, SW_SHOWNORMAL );
	UpdateWindow( current_hwnd );
	return 0;
}