예제 #1
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);
    }
}
rtgui_container_t* demo_view_box(void)
{
    rtgui_rect_t  rect;
    rtgui_container_t* view;
	struct rtgui_panel *panel;
	struct rtgui_box *box;

	struct rtgui_label *label;
	struct rtgui_button *button;

    view = demo_view("Box View");
    demo_view_get_rect(view, &rect);

	panel = rtgui_panel_create(RTGUI_BORDER_NONE);
	rtgui_widget_set_rect(RTGUI_WIDGET(panel), &rect);
	rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(panel));

	box = rtgui_box_create(RTGUI_VERTICAL, 5);
	rtgui_container_set_box(RTGUI_CONTAINER(panel), box);

	label = rtgui_label_create("label 1");
	rtgui_container_add_child(RTGUI_CONTAINER(panel), RTGUI_WIDGET(label));
	label = rtgui_label_create("label 2");
	rtgui_container_add_child(RTGUI_CONTAINER(panel), RTGUI_WIDGET(label));

	button = rtgui_button_create("button 1");
	rtgui_container_add_child(RTGUI_CONTAINER(panel), RTGUI_WIDGET(button));

	button = rtgui_button_create("button 2");
	rtgui_container_add_child(RTGUI_CONTAINER(panel), RTGUI_WIDGET(button));
	rtgui_widget_set_miniheight(RTGUI_WIDGET(button), 25);
	RTGUI_WIDGET_ALIGN(button) = RTGUI_ALIGN_EXPAND;

	rtgui_container_layout(RTGUI_CONTAINER(panel));

    return view;
}
예제 #3
0
파일: application.c 프로젝트: aozima/RTGUI
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");
}