Example #1
0
static void app_mainmenu_init(void)
{
    struct rtgui_image *bg_image;
    rtgui_rect_t rect;

    /* create main window of Application Manager */
    win = rtgui_mainwin_create(RT_NULL, "mainmenu", RTGUI_WIN_STYLE_MAINWIN);
    if (win != RT_NULL)
    {
        rtgui_object_set_event_handler(RTGUI_OBJECT(win), mainmenu_event_handler);
        rtgui_widget_get_rect(RTGUI_WIDGET(win), &rect);

#ifdef RT_USING_MODULE 
        mainmenu_scan_apps();
#endif
        /* create background image */
        bg_image = rtgui_image_create("/resource/bg_image.jpg", RT_TRUE);
        if (bg_image == RT_NULL)
        {
            rt_kprintf("open \"/resource/bg_image.jpg\" failed\n");
        }
        ycircle_image = rtgui_image_create("/resource/ycircle.png", RT_TRUE);
        gcircle_image = rtgui_image_create("/resource/gcircle.png", RT_TRUE);
        app_list = app_list_create(&rect, items, ITEM_MAX, 2, 5, bg_image);
        rtgui_image_destroy(bg_image);
        app_list_draw(app_list);
        app_list_draw_pagemark(app_list);
        app_list->on_select = exec_internal_app;
        rtgui_win_show(win, RT_FALSE);
        /* set as main window */
        rtgui_app_set_main_win(rtgui_app_self(), win);
    }
}
Example #2
0
int main(int argc, char** argv)
{
	struct rtgui_app* application;
	struct rtgui_win* win;
    struct rtgui_button *button;

	application = rtgui_app_create("button");
	if (application != RT_NULL)
	{
		rtgui_rect_t rect;

		win = rtgui_mainwin_create(RT_NULL, "button",
			RTGUI_WIN_STYLE_MAINWIN | RTGUI_WIN_STYLE_DESTROY_ON_CLOSE);
        rtgui_widget_get_extent(RTGUI_WIDGET(win), &rect);

		/* create lable in app window */
        button = rtgui_button_create("close");
		rtgui_button_set_onbutton(button, _on_close);
        rect.x2 -= 5; rect.y2 -= 5;
        rect.x1 = rect.x2 - 80; rect.y1 = rect.y2 - 25;
		rtgui_widget_set_rect(RTGUI_WIDGET(button), &rect);
		rtgui_container_add_child(RTGUI_CONTAINER(win), RTGUI_WIDGET(button));

		rtgui_win_show(win, RT_TRUE);
		rtgui_app_destroy(application);
	}

    return 0;
}
Example #3
0
File: picture.c Project: amsl/RTGUI
void picture_show(void* parameter)
{
    /* create application */
    struct rtgui_app *app;
    struct rtgui_rect rect1;
    rtgui_timer_t *timer;
    
    app = rtgui_app_create(rt_thread_self(), "gui_app");
    if (app == RT_NULL)
    {
        rt_kprintf("Create application \"gui_app\" failed!\n");
        return;
    }

    rtgui_graphic_driver_get_rect(rtgui_graphic_driver_get_default(), &rect1);

    /* create main window */
    win = rtgui_mainwin_create(RT_NULL, "main",
                    RTGUI_WIN_STYLE_NO_BORDER | RTGUI_WIN_STYLE_NO_TITLE);
    if (win == RT_NULL)
    {
        rt_kprintf("Create window \"main\" failed!\n");
                rtgui_app_destroy(app);
        return;
    }

    timer = rtgui_timer_create(500, RT_TIMER_FLAG_PERIODIC, timeout, (void*)win);
    rtgui_timer_start(timer);
    
	rtgui_object_set_event_handler(RTGUI_OBJECT(win), picture_view_event_handler);
    rtgui_win_set_onkey(win, onkey_handle);
    rtgui_win_show(win, RT_FALSE);

    /* show next picture */
    picture_show_next(RTGUI_WIDGET(win));

    rtgui_app_run(app);
    rtgui_app_destroy(app);
}
Example #4
0
void main(void)
{
	struct rtgui_app* application;
	struct rtgui_win* win;	
	struct rtgui_label* label;

	application = rtgui_app_create(rt_thread_self(), "label");
	if (application != RT_NULL)
	{	
		rtgui_rect_t rect = {220, 250, 400, 450};
		win = rtgui_mainwin_create(RT_NULL, "Label", 
			RTGUI_WIN_STYLE_MAINWIN | RTGUI_WIN_STYLE_DESTROY_ON_CLOSE);

		/* create lable in app window */
		label = rtgui_label_create("This is a RTGUI label Demo");
		rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
		rtgui_container_add_child(RTGUI_CONTAINER(win), RTGUI_WIDGET(label));

		rtgui_win_show(win, RT_TRUE);
		rtgui_app_destroy(application);
	}
}
Example #5
0
void main(void)
{
	struct rtgui_app* application;
	struct rtgui_win* win;	
	struct rtgui_button* button;

	application = rtgui_app_create(rt_thread_self(), "button");
	if (application != RT_NULL)
	{			
		rtgui_rect_t rect = {220, 250, 400, 450};
		win = rtgui_mainwin_create(RT_NULL, "Button", 
			RTGUI_WIN_STYLE_MAINWIN | RTGUI_WIN_STYLE_DESTROY_ON_CLOSE);

		/* create button in app window */
		button = rtgui_button_create("Button Demo");
		rtgui_widget_set_rect(RTGUI_WIDGET(button), &rect);
		rtgui_container_add_child(RTGUI_CONTAINER(win), RTGUI_WIDGET(button));

		rtgui_win_show(win, RT_TRUE);
		rtgui_app_destroy(application);
	}
}
Example #6
0
void app1_entry(void* parameter)
{
    struct rtgui_app* application;
    struct rtgui_win* win;

    application = rtgui_app_create(rt_thread_self(), "ExApp1");
    if (application != RT_NULL)
    {
        struct rtgui_label *label;
        struct rtgui_box *box;

        box = rtgui_box_create(RTGUI_VERTICAL, 10);
        label = rtgui_label_create("Hello World");
        win = rtgui_mainwin_create(RT_NULL, "MainWin", RTGUI_WIN_STYLE_MAINWIN);
        rtgui_container_set_box(RTGUI_CONTAINER(win), box);
        rtgui_container_add_child(RTGUI_CONTAINER(win), RTGUI_WIDGET(label));
        rtgui_container_layout(RTGUI_CONTAINER(win));
        
        rtgui_win_show(win, RT_TRUE);

        rtgui_app_destroy(application);
    }
}
Example #7
0
void main(void)
{
	struct rtgui_app* application;
	struct rtgui_win* win;	

	application = rtgui_app_create(rt_thread_self(), "filelist");
	if (application != RT_NULL)
	{			
		struct rtgui_rect rect;
	    rtgui_filelist_view_t *view;

		win = rtgui_mainwin_create(RT_NULL, "filelist", 
			RTGUI_WIN_STYLE_MAINWIN | RTGUI_WIN_STYLE_DESTROY_ON_CLOSE);
        
		rtgui_widget_get_extent(RTGUI_WIDGET(win), &rect);

	    view = rtgui_filelist_view_create("/", "*.*", &rect);
        rtgui_container_add_child(RTGUI_CONTAINER(win), RTGUI_WIDGET(view));

		rtgui_win_show(win, RT_TRUE);
		rtgui_app_destroy(application);
	}
}
Example #8
0
void snake_main(void)
{
    struct rtgui_app *application;
    struct rtgui_win *win;
    rtgui_rect_t rect;

    application = rtgui_app_create(rt_thread_self(), "sanke_app");
    if (application != RT_NULL)
    {
        rtgui_get_screen_rect(&rect);
        rtgui_set_mainwin_rect(&rect);
        win = rtgui_mainwin_create(RT_NULL,
                                   "sanke_win",
                                   RTGUI_WIN_STYLE_MAINWIN | RTGUI_WIN_STYLE_DESTROY_ON_CLOSE);
        if (win == RT_NULL)
        {
            rt_kprintf("sanke_win create fail!\r\n");
            return;
        }

        rtgui_object_set_event_handler(RTGUI_OBJECT(win), event_handler);

        timer = rtgui_timer_create(RT_TICK_PER_SECOND / 2,
                                   RT_TIMER_FLAG_PERIODIC,
                                   timeout,
                                   (void *)win);

        rtgui_win_show(win, RT_TRUE);

        //Í˳öºó²Å·µ»Ø
        map_deinit(map);
        snake_deinit();
        food_deinit();
        rtgui_app_destroy(application);
    }
}
Example #9
0
void win_thread_entry(void* parameter)
{
	struct rtgui_app* app;
	struct rtgui_win *win;
	struct rtgui_panel *panel;
    struct rtgui_box *box;
    struct rtgui_label *label;
    struct rtgui_notebook *notebook;

    struct rtgui_rect rect = {50, 50, 350, 350};

	app = rtgui_app_create(rt_thread_self(), "MyApp");
	RT_ASSERT(app != RT_NULL);

    win = rtgui_mainwin_create(RT_NULL, "MyWindow", RTGUI_WIN_STYLE_DEFAULT);
    box = rtgui_box_create(RTGUI_VERTICAL, 10);
    rtgui_container_set_box(RTGUI_CONTAINER(win), box);

    /* create a panel */
    panel = rtgui_panel_create(RTGUI_BORDER_BOX);
    RTGUI_WIDGET_ALIGN(panel) = RTGUI_ALIGN_EXPAND;
    rtgui_container_add_child(RTGUI_CONTAINER(win), RTGUI_WIDGET(panel));

    /* create sub-child for panel */
    box = rtgui_box_create(RTGUI_VERTICAL, 10);
    rtgui_container_set_box(RTGUI_CONTAINER(panel), box);

    label = rtgui_label_create("hello panel!");
    rtgui_container_add_child(RTGUI_CONTAINER(panel), RTGUI_WIDGET(label));

    /* create a notebook */
    notebook = rtgui_notebook_create(&rect, RTGUI_NOTEBOOK_TOP);
    RTGUI_WIDGET_ALIGN(notebook) = RTGUI_ALIGN_EXPAND;
    rtgui_container_add_child(RTGUI_CONTAINER(win), RTGUI_WIDGET(notebook));
	_notebook = notebook;

    /* create tab-page for notebook  */
    panel = rtgui_panel_create(RTGUI_BORDER_STATIC);
	_panel = panel;
    box = rtgui_box_create(RTGUI_VERTICAL, 10);
    rtgui_container_set_box(RTGUI_CONTAINER(panel), box);

    label = rtgui_label_create("hello panel!");
    rtgui_container_add_child(RTGUI_CONTAINER(panel), RTGUI_WIDGET(label));
    rtgui_notebook_add(notebook, "Panel", RTGUI_WIDGET(panel));

    /* create another page with label */
    label = rtgui_label_create("hello notebook");
    rtgui_notebook_add(notebook, "Text", RTGUI_WIDGET(label));

    /* layout for window */
    rtgui_container_layout(RTGUI_CONTAINER(win));

	rtgui_win_show(win, RT_FALSE);

	rtgui_app_run(app);

	rtgui_win_destroy(win);
	rtgui_app_destroy(app);
	rt_kprintf("MyApp Quit.\n");
}
Example #10
0
void app_mgr_win_init(void)
{
	struct rtgui_win* win;
	rtgui_rect_t rect;
	struct rtgui_notebook *notebook;
	rtgui_listbox_t* box;
	struct rtgui_image* pressed_image;
	struct rtgui_image* unpressed_image;
	int font_size;
	struct block_panel* block;
	int angle_y;
	
	/* create main window of Application Manager */
	win = rtgui_mainwin_create(RT_NULL, "AppMgr", RTGUI_WIN_STYLE_MAINWIN);
	RTGUI_WIDGET_BACKGROUND(win) = RTGUI_RGB(241, 241, 241);

	/* create icon image */
	pressed_image = rtgui_image_create_from_mem("xpm", (const rt_uint8_t*)home_xpm, sizeof(home_xpm), RT_FALSE);
	unpressed_image = rtgui_image_create_from_mem("xpm", (const rt_uint8_t*)home_gray_xpm, sizeof(home_gray_xpm), RT_FALSE);
	rtgui_font_get_metrics(RTGUI_WIDGET_FONT(win), "AppMgr", &rect);
	font_size = rtgui_rect_height(rect);

	/* create notebook */
	rtgui_widget_get_extent(RTGUI_WIDGET(win), &rect);
	notebook = rtgui_notebook_create(&rect, RTGUI_NOTEBOOK_LEFT);
	RTGUI_WIDGET_BACKGROUND(notebook) = RTGUI_RGB(241, 241, 241);
	rtgui_notebook_set_tab_height(notebook, pressed_image->h + font_size + 3 * RTGUI_WIDGET_DEFAULT_MARGIN);
	rtgui_notebook_set_tab_width(notebook, 65);
	angle_y = rect.x1;

	/* create navigation */
	rtgui_notebook_get_client_rect(notebook, &rect);
	block = block_panel_create(angle_y + notebook->tab_h/2, &rect);
	RTGUI_WIDGET_BACKGROUND(block) = RTGUI_RGB(241, 241, 241);
	rtgui_notebook_add_image(notebook, "AppTask", RTGUI_WIDGET(block),
		pressed_image, unpressed_image);
	apps_list_create(RTGUI_PANEL(block));
	angle_y += notebook->tab_h;

	block = block_panel_create(angle_y + notebook->tab_h/2, &rect);
	RTGUI_WIDGET_BACKGROUND(block) = RTGUI_RGB(241, 241, 241);
	rtgui_notebook_add_image(notebook, "Tab 1", RTGUI_WIDGET(block),
		pressed_image, unpressed_image);
	{
		struct rtgui_rect box_rect;
		block_panel_get_client_extent(block, &box_rect);
		// rtgui_widget_get_extent(RTGUI_WIDGET(block), &box_rect);
		// rtgui_rect_inflate(&box_rect, -15);
		box = rtgui_listbox_create(items, sizeof(items)/sizeof(struct rtgui_listbox_item), &box_rect);
		rtgui_container_add_child(RTGUI_CONTAINER(block), RTGUI_WIDGET(box));
	}
	angle_y += notebook->tab_h;

	block = block_panel_create(angle_y + notebook->tab_h/2, &rect);
	RTGUI_WIDGET_BACKGROUND(block) = RTGUI_RGB(241, 241, 241);
	rtgui_notebook_add_image(notebook, "Tab 2", RTGUI_WIDGET(block), 
		pressed_image, unpressed_image);
	angle_y += notebook->tab_h;

	rtgui_container_add_child(RTGUI_CONTAINER(win), RTGUI_WIDGET(notebook));

	rtgui_win_show(win, RT_FALSE);

	/* set as main window */
	rtgui_app_set_main_win(win);
}