Ejemplo n.º 1
0
/* 触发模态窗口显示 */
static void demo_modalwin_onbutton(struct rtgui_object *object, rtgui_event_t *event)
{
    rtgui_win_t *win;
    rtgui_label_t *label;
    rtgui_rect_t rect = {0, 0, 150, 80};

    rtgui_rect_moveto(&rect, delta_x, delta_y);
    delta_x += 20;
    delta_y += 20;

    /* 创建一个窗口 */
    win = rtgui_win_create(main_win,
                           get_win_title(), &rect, RTGUI_WIN_STYLE_DEFAULT);

    rect.x1 += 20;
    rect.x2 -= 5;
    rect.y1 += 5;
    rect.y2 = rect.y1 + 20;

    label = rtgui_label_create("这是一个模式窗口");
    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_win_destroy(win);
}
Ejemplo n.º 2
0
static rt_bool_t _rtgui_win_deal_close(struct rtgui_win *win,
									   struct rtgui_event *event,
									   rt_bool_t force_close)
{
	if (win->on_close != RT_NULL)
	{
		if ((win->on_close(RTGUI_OBJECT(win), event) == RT_FALSE) && !force_close)
			return RT_FALSE;
	}

	rtgui_win_hiden(win);

	win->flag |= RTGUI_WIN_FLAG_CLOSED;

	if (win->flag & RTGUI_WIN_FLAG_MODAL)
	{
		rtgui_win_end_modal(win, RTGUI_MODAL_CANCEL);
	}
	else if (win->style & RTGUI_WIN_STYLE_DESTROY_ON_CLOSE)
	{
		rtgui_win_destroy(win);
	}

	return RT_TRUE;
}
Ejemplo n.º 3
0
rt_bool_t show_modal_info(struct rtgui_widget *object, struct rtgui_event *event)
{
	rtgui_label_t *label;
	struct rtgui_win *win;
	rtgui_rect_t rect = {0, 60, 150, 100};
	win = rtgui_win_create(main_win,
						   "Info",
						   &rect,
						   RTGUI_WIN_STYLE_DEFAULT);

	rect.x1 += 20;
	rect.x2 -= 5;
	rect.y1 += 5;
	rect.y2 = rect.y1 + 20;

	label = rtgui_label_create("modal mode info");
	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_win_destroy(win);

	return RT_TRUE;
}
Ejemplo n.º 4
0
static void _rtgui_combobox_destructor(rtgui_combobox_t *box)
{
	/* destroy pull down window */
	rtgui_win_destroy(box->pd_win);

	/* reset box field */
	box->pd_win    = RT_NULL;
}
Ejemplo n.º 5
0
static rt_bool_t rtgui_filelist_view_on_menu_deactivate(rtgui_object_t *object, struct rtgui_event *event)
{
    rtgui_win_t *menu;
    menu = RTGUI_WIN(rtgui_widget_get_toplevel(RTGUI_WIDGET(object)));

    /* destroy menu window */
    rtgui_win_destroy(menu);

    return RT_TRUE;
}
Ejemplo n.º 6
0
/* 窗口关闭时的事件处理 */
void window_demo_close(struct rtgui_widget* widget, rtgui_event_t *even)
{
	rtgui_win_t* win;

	/* 获得最顶层控件 */
	win = RTGUI_WIN(rtgui_widget_get_toplevel(widget));

	/* 销毁窗口 */
	rtgui_win_destroy(win);
}
Ejemplo n.º 7
0
static void demo_close_ntitle_window(struct rtgui_object *object, rtgui_event_t *event)
{
    rtgui_win_t *win;

    /* 获得最顶层控件 */
    win = RTGUI_WIN(rtgui_widget_get_toplevel(RTGUI_WIDGET(object)));

    /* 销毁窗口 */
    rtgui_win_destroy(win);
}
Ejemplo n.º 8
0
static void cancel_btn_onbutton(rtgui_widget_t* widget, struct rtgui_event* event)
{
	if (NULL != switch2pt_confirm_win) {
		printf_syn("fun:%s(), switch2pt_win pointer cancel button\n", __FUNCTION__);
		rtgui_win_destroy(switch2pt_confirm_win);
	} else {
		printf_syn("fun:%s(), switch2pt_win pointer is NULL\n", __FUNCTION__);
	}

	return;
}
Ejemplo n.º 9
0
static rt_bool_t rtgui_filelist_view_on_folder_item(rtgui_object_t *object, struct rtgui_event *event)
{
    rtgui_win_t *menu;
    rtgui_listbox_t *listbox;
    rtgui_filelist_view_t *view;

    listbox = RTGUI_LISTBOX(object);
    menu = RTGUI_WIN(rtgui_widget_get_toplevel(RTGUI_WIDGET(object)));
    view = RTGUI_FILELIST_VIEW(menu->user_data);

    /* hide window */
    rtgui_win_hide(menu);

    switch (listbox->current_item)
    {
    case 0:
    {
        char *dir_ptr;

        /* destroy menu window */
        rtgui_win_destroy(menu);

        dir_ptr = (char *) rtgui_malloc(256);
        rtgui_filelist_view_get_fullpath(view, dir_ptr, 256);
        rtgui_filelist_view_set_directory(view, dir_ptr);
        rtgui_free(dir_ptr);
    }
    break;
    case 1:
        /* destroy menu window */
        rtgui_win_destroy(menu);
        break;

    default:
        /* destroy menu window */
        rtgui_win_destroy(menu);
        break;
    }

    return RT_TRUE;
}
Ejemplo n.º 10
0
static void sure_btn_onbutton(rtgui_widget_t* widget, struct rtgui_event* event)
{
	if (NULL != switch2pt_confirm_win) {
		send_cmd_to_rxe(1, SWITCH2PT);
		printf_syn("fun:%s(), switch2pt_win pointer confirm button\n", __FUNCTION__);
		rtgui_win_destroy(switch2pt_confirm_win);
	} else {
		printf_syn("fun:%s(), switch2pt_win pointer is NULL\n", __FUNCTION__);
	}

	return;
}
Ejemplo n.º 11
0
/* 关闭对话框时的回调函数 */
void diag_close(struct rtgui_timer *timer, void *parameter)
{
    cnt --;
    rt_sprintf(label_text, "closed then %d second!", cnt);

    /* 设置标签文本并更新控件 */
    rtgui_label_set_text(label, label_text);
    rtgui_widget_update(RTGUI_WIDGET(label));

    if (cnt == 0)
    {
        /* 超时,关闭对话框 */
        rtgui_win_destroy(autowin);
    }
}
Ejemplo n.º 12
0
int creat_software_ver_not_match_win(struct rtgui_widget* widget)
{
	rtgui_rect_t rect = {60, 45, 260, 160};
	rtgui_label_t *label1;
	rtgui_label_t *label2;
	rtgui_toplevel_t *parent;

	if (RT_NULL != software_version_not_match_win)
		return FAIL;

	parent = RTGUI_TOPLEVEL(rtgui_widget_get_toplevel(widget));

	software_version_not_match_win = rtgui_win_create(parent,
		"致命错误", &rect, RTGUI_WIN_STYLE_MODAL);

	rtgui_widget_get_extent(RTGUI_WIDGET(software_version_not_match_win),&rect);
	rect.x1 += 20;
	rect.x2 -= 20;
	rect.y1 += 20;
	rect.y2 = rect.y1 + 30;
	label1 = rtgui_label_create("接收端与lcd软件版本");
	if (NULL != label1) {
		rtgui_widget_set_rect(RTGUI_WIDGET(label1), &rect);
		rtgui_container_add_child(RTGUI_CONTAINER(software_version_not_match_win), RTGUI_WIDGET(label1));
	}

	rtgui_widget_get_extent(RTGUI_WIDGET(software_version_not_match_win),&rect);
	rect.x1 += 70;
	rect.x2 -= 30;
	rect.y1 += 50;
	rect.y2 = rect.y1 + 30;
	label2 = rtgui_label_create("不匹配!");
	if (NULL != label2) {
		rtgui_widget_set_rect(RTGUI_WIDGET(label2), &rect);
		rtgui_container_add_child(RTGUI_CONTAINER(software_version_not_match_win), RTGUI_WIDGET(label2));
	}

	send_cmd_to_rxe(1, SWITCH2PT);

	rtgui_win_show(software_version_not_match_win, RT_TRUE);

	rtgui_win_destroy(software_version_not_match_win);
	software_version_not_match_win = RT_NULL;

	return SUCC;
}
Ejemplo n.º 13
0
void app1_entry(void* parameter)
{
	struct rtgui_app* application;
	struct rtgui_win* win;

	application = rtgui_app_create("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_win_destroy(win);

		rtgui_app_destroy(application);
	}
}
Ejemplo n.º 14
0
rt_base_t rtgui_win_show(struct rtgui_win* win, rt_bool_t is_modal)
{
    struct rtgui_event_win_show eshow;
    rt_base_t exit_code = -1;

    RTGUI_EVENT_WIN_SHOW_INIT(&eshow);
    eshow.wid = win;

    if (win == RT_NULL)
        return exit_code;

    /* if it does not register into server, create it in server */
    if (!(win->flag & RTGUI_WIN_FLAG_CONNECTED))
    {
        if (_rtgui_win_create_in_server(win) == RT_FALSE)
            return exit_code;
    }

    if (rtgui_server_post_event_sync(RTGUI_EVENT(&eshow),
                                     sizeof(struct rtgui_event_win_show)
                                    ) != RT_EOK)
    {
        rt_kprintf("show win failed\n");
        return exit_code;
    }

    /* set window unhidden */
    RTGUI_WIDGET_UNHIDE(RTGUI_WIDGET(win));

    if (win->focused_widget == RT_NULL)
        rtgui_widget_focus(RTGUI_WIDGET(win));

    if (is_modal == RT_TRUE)
    {
        struct rtgui_application *app;
        struct rtgui_event_win_modal_enter emodal;

        RTGUI_EVENT_WIN_MODAL_ENTER_INIT(&emodal);
        emodal.wid = win;

        app = rtgui_application_self();
        RT_ASSERT(app != RT_NULL);

        win->flag |= RTGUI_WIN_FLAG_MODAL;

        if (rtgui_server_post_event_sync((struct rtgui_event*)&emodal,
                                         sizeof(emodal)) != RT_EOK)
            return exit_code;

        app->modal_object = RTGUI_OBJECT(win);

        exit_code = rtgui_application_run(app);

        app->modal_object = RT_NULL;
        win->flag &= ~RTGUI_WIN_FLAG_MODAL;

        if (win->style & RTGUI_WIN_STYLE_DESTROY_ON_CLOSE)
        {
            rtgui_win_destroy(win);
        }
    }

    return exit_code;
}
Ejemplo n.º 15
0
void create_wins(struct rtgui_app *app, void *parameter)
{
	struct rtgui_win *win1, *win2, *win3, *win4;
	struct rtgui_label *label;
	struct rtgui_rect rect;

	if (parameter)
	{
        struct rtgui_win *dsk;
		rtgui_graphic_driver_get_rect(rtgui_graphic_driver_get_default(), &rect);
		dsk = rtgui_win_create(RT_NULL, "desktop", &rect, RTGUI_WIN_STYLE_ONBTM);
		rtgui_win_show(dsk, RT_FALSE);
	}

	rect.x1 = 40, rect.y1 = 40, rect.x2 = 200, rect.y2 = 80;

	win1 = rtgui_win_create(RT_NULL,
		"test window", &rect, RTGUI_WIN_STYLE_DEFAULT);

	rtgui_win_set_onclose(win1, on_window_close);

	rect.x1 += 20;
	rect.x2 -= 5;
	rect.y1 += 5;
	rect.y2 = rect.y1 + 20;

	label = rtgui_label_create("window in modal mode");
	rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
	rtgui_container_add_child(RTGUI_CONTAINER(win1), RTGUI_WIDGET(label));

	rtgui_win_show(win1, RT_TRUE);

	rt_kprintf("win1 terminated\n");
	/*rtgui_win_destroy(win1);*/

	rect.x1 = 20;
	rect.y1 = 80;
	rect.x2 = 180;
	rect.y2 = 90;
	win2 = rtgui_win_create(win1,
		"test window2", &rect, RTGUI_WIN_STYLE_DEFAULT);

	rtgui_win_set_onclose(win2, on_window_close);
	rtgui_win_show(win1, RT_FALSE);
	/*rtgui_win_show(win2, RT_TRUE);*/

	/* create second window tree */
	rect.y1 = 150;
	rect.y2 = rect.y1 + 50;
	win3 = rtgui_win_create(RT_NULL,
		"test tree2", &rect, RTGUI_WIN_STYLE_DEFAULT);

	rtgui_win_set_onclose(win3, on_window_close);

	rect.x1 += 20;
	rect.x2 -= 5;
	rect.y1 += 5;
	rect.y2 = rect.y1 + 20;

	label = rtgui_label_create("window in modal mode");
	rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
	rtgui_container_add_child(RTGUI_CONTAINER(win3), RTGUI_WIDGET(label));

	rect.x1 = 20;
	rect.y1 = 180;
	rect.x2 = 180;
	rect.y2 = 190;
	win4 = rtgui_win_create(win3,
		"test tree2.1", &rect, RTGUI_WIN_STYLE_DEFAULT);

	rtgui_win_set_onclose(win4, on_window_close);
	rtgui_win_show(win3, RT_FALSE);
	/*rtgui_win_show(win4, RT_TRUE);*/

	rtgui_app_run(app);

	rtgui_win_destroy(win1);
	rtgui_win_destroy(win2);
	rtgui_win_destroy(win3);
	rtgui_win_destroy(win4);
}
Ejemplo n.º 16
0
static void application_entry(void* parameter)
{
	struct rtgui_application *app;
	struct rtgui_rect rect;

	app = rtgui_application_create(rt_thread_self(), "gui_demo");
	if (app == RT_NULL)
		return;

	/* create a full screen window */
	rtgui_graphic_driver_get_rect(rtgui_graphic_driver_get_default(), &rect);

	main_win = rtgui_win_create(RT_NULL, "demo_win", &rect,
                        RTGUI_WIN_STYLE_NO_BORDER | RTGUI_WIN_STYLE_NO_TITLE);
	if (main_win == RT_NULL)
	{
		rtgui_application_destroy(app);
		return;
	}

	rtgui_win_set_onkey(main_win, demo_handle_key);

	/* create a no title notebook that we can switch demo on it easily. */
	the_notebook = rtgui_notebook_create(&rect, RTGUI_NOTEBOOK_NOTAB);
	if (the_notebook == RT_NULL)
	{
		rtgui_win_destroy(main_win);
		rtgui_application_destroy(app);
		return;
	}

	rtgui_container_add_child(RTGUI_CONTAINER(main_win), RTGUI_WIDGET(the_notebook));

	/* 初始化各个例子的视图 */
	demo_view_benchmark();

	demo_view_dc();
#ifdef RTGUI_USING_TTF
	demo_view_ttf();
#endif

#ifndef RTGUI_USING_SMALL_SIZE
	demo_view_dc_buffer();
#endif
	demo_view_animation();
#ifndef RTGUI_USING_SMALL_SIZE
	demo_view_buffer_animation();
	demo_view_instrument_panel();
#endif
	demo_view_window();
	demo_view_label();
	demo_view_button();
	demo_view_checkbox();
	demo_view_progressbar();
	demo_view_scrollbar();
	demo_view_radiobox();
	demo_view_textbox();
	demo_view_listbox();
	demo_view_menu();
	demo_view_listctrl();
	demo_view_combobox();
	demo_view_slider();
	demo_view_notebook();
	demo_view_mywidget();
#if 0
#if defined(RTGUI_USING_DFS_FILERW) || defined(RTGUI_USING_STDIO_FILERW)
	demo_view_image();
#endif
#ifdef RT_USING_MODULE	
#if defined(RTGUI_USING_DFS_FILERW) || defined(RTGUI_USING_STDIO_FILERW)
	demo_view_module();
#endif
#endif
	demo_listview_view();
	demo_listview_icon_view();
#if defined(RTGUI_USING_DFS_FILERW) || defined(RTGUI_USING_STDIO_FILERW)
	demo_fn_view();
#endif
#endif

	rtgui_win_show(main_win, RT_FALSE);

	/* 执行工作台事件循环 */
	rtgui_application_run(app);

	rtgui_application_destroy(app);
}
Ejemplo n.º 17
0
rt_bool_t rtgui_win_event_handler(struct rtgui_widget* widget, struct rtgui_event* event)
{
	struct rtgui_win* win = (struct rtgui_win*)widget;

	RT_ASSERT((win != RT_NULL) && (event != RT_NULL));

	switch (event->type)
	{
	case RTGUI_EVENT_WIN_SHOW:
		rtgui_win_show(win, RT_FALSE);
		break;

	case RTGUI_EVENT_WIN_HIDE:
		rtgui_win_hiden(win);
		break;

	case RTGUI_EVENT_WIN_CLOSE:
		if (win->on_close != RT_NULL)
		{
			if (win->on_close(widget, event) == RT_FALSE) return RT_TRUE;
		}

		if (win->style & RTGUI_WIN_STYLE_MODAL)
		{
			rtgui_win_end_modal(win, RTGUI_MODAL_CANCEL);
		}
		else
		{
			/* destroy window */
			rtgui_win_destroy(win);
		}

		/* exit event loop */
		return RT_TRUE;

	case RTGUI_EVENT_WIN_MOVE:
	{
		struct rtgui_event_win_move* emove = (struct rtgui_event_win_move*)event;

		/* move window */
		rtgui_win_move(win, emove->x, emove->y);
	}
	break;

	case RTGUI_EVENT_WIN_ACTIVATE:
		if (RTGUI_WIDGET_IS_HIDE(RTGUI_WIDGET(win)))
		{
			/* activate a hide window */
			return RT_TRUE;
		}

		win->style |= RTGUI_WIN_STYLE_ACTIVATE;
#ifndef RTGUI_USING_SMALL_SIZE
		if (widget->on_draw != RT_NULL) widget->on_draw(widget, event);
		else 
#endif
		rtgui_widget_update(RTGUI_WIDGET(win));

		if (win->on_activate != RT_NULL)
		{
			win->on_activate(widget, event);
		}
		break;

	case RTGUI_EVENT_WIN_DEACTIVATE:
		if (win->style & RTGUI_WIN_STYLE_MODAL)
		{
			/* do not deactivate a modal win, re-send win-show event */
			struct rtgui_event_win_show eshow;
			RTGUI_EVENT_WIN_SHOW_INIT(&eshow);
			eshow.wid = win;

			rtgui_thread_send(RTGUI_TOPLEVEL(win)->server, RTGUI_EVENT(&eshow),
				sizeof(struct rtgui_event_win_show));
		}
		else
		{
			win->style &= ~RTGUI_WIN_STYLE_ACTIVATE;
#ifndef RTGUI_USING_SMALL_SIZE
			if (widget->on_draw != RT_NULL) widget->on_draw(widget, event);
			else 
#endif
				rtgui_win_ondraw(win);

			if (win->on_deactivate != RT_NULL)
			{
				win->on_deactivate(widget, event);
			}
		}
		break;

	case RTGUI_EVENT_PAINT:
#ifndef RTGUI_USING_SMALL_SIZE
		if (widget->on_draw != RT_NULL) widget->on_draw(widget, event);
		else
#endif
			rtgui_win_ondraw(win);
		break;

	case RTGUI_EVENT_MOUSE_BUTTON:
		if (win->style & RTGUI_WIN_STYLE_UNDER_MODAL)
		{
			if (win->modal_widget != RT_NULL)
				return win->modal_widget->event_handler(win->modal_widget, event);
		}
 		else if (rtgui_container_dispatch_mouse_event(RTGUI_CONTAINER(win), 
			(struct rtgui_event_mouse*)event) == RT_FALSE)
		{
#ifndef RTGUI_USING_SMALL_SIZE
			if (widget->on_mouseclick != RT_NULL)
			{
				return widget->on_mouseclick(widget, event);
			}
#endif
		}
		break;

	case RTGUI_EVENT_MOUSE_MOTION:
#if 0
		if (rtgui_widget_dispatch_mouse_event(widget,
			(struct rtgui_event_mouse*)event) == RT_FALSE)
		{
#ifndef RTGUI_USING_SMALL_SIZE
			/* handle event in current widget */
			if (widget->on_mousemotion != RT_NULL)
			{
				return widget->on_mousemotion(widget, event);
			}
#endif
		}
		else return RT_TRUE;
#endif
		break;

    case RTGUI_EVENT_KBD:
		if (win->style & RTGUI_WIN_STYLE_UNDER_MODAL)
		{
			if (win->modal_widget != RT_NULL)
				return win->modal_widget->event_handler(win->modal_widget, event);
		}
		else if (RTGUI_CONTAINER(win)->focused != widget)
		{
			RTGUI_CONTAINER(win)->focused->event_handler(RTGUI_CONTAINER(win)->focused, event);
		}
        break;

	default:
		/* call parent event handler */
		return rtgui_toplevel_event_handler(widget, event);
	}

	return RT_FALSE;
}
Ejemplo n.º 18
0
static void creat_switch2pt_win(rtgui_widget_t* widget)
{
	rtgui_label_t *label;
	rtgui_button_t *cancel_button;
	rtgui_button_t *sure_button;
	rtgui_toplevel_t *parent;
	rtgui_rect_t rect = {60, 45, 260, 160};

	parent = RTGUI_TOPLEVEL(rtgui_widget_get_toplevel(widget));

	switch2pt_confirm_win = rtgui_win_create(parent, "警告", &rect, RTGUI_WIN_STYLE_MODAL);

	rtgui_widget_get_extent(RTGUI_WIDGET(switch2pt_confirm_win), &rect);
	rect.x1 += 30;
	rect.x2 -= 30;
	rect.y1 += 20;
	rect.y2 = rect.y1 + 30;
	label = rtgui_label_create("确定切换到PT侧?");
	if (NULL != label) {
		rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
		rtgui_container_add_child(RTGUI_CONTAINER(switch2pt_confirm_win), RTGUI_WIDGET(label));			
	}

	rtgui_widget_get_extent(RTGUI_WIDGET(switch2pt_confirm_win),&rect);
	rect.x1 += 20;
	rect.x2 -= 120;
	rect.y1 += 70;
	rect.y2 -= 20;
	sure_button = rtgui_button_create("确定");
	if (NULL != sure_button) {
		RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(sure_button)) = RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL;
		rtgui_widget_set_rect(RTGUI_WIDGET(sure_button), &rect);
		rtgui_container_add_child(RTGUI_CONTAINER(switch2pt_confirm_win), RTGUI_WIDGET(sure_button));
		rtgui_button_set_onbutton(sure_button, sure_btn_onbutton);
	} else {
		printf_syn("creat sure button fail\n");
	}
	
	rtgui_widget_get_extent(RTGUI_WIDGET(switch2pt_confirm_win),&rect);
	rect.x1 += 120;
	rect.x2 -= 20;
	rect.y1 += 70;
	rect.y2 -= 20;
	cancel_button = rtgui_button_create("取消");
	if (NULL != cancel_button) {
		RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(cancel_button)) = RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL;
		rtgui_widget_set_rect(RTGUI_WIDGET(cancel_button), &rect);
		rtgui_container_add_child(RTGUI_CONTAINER(switch2pt_confirm_win), RTGUI_WIDGET(cancel_button));
		rtgui_button_set_onbutton(cancel_button, cancel_btn_onbutton);
	} else {
		printf_syn("creat cancel button fail\n");
	}
	
	/* 模态显示窗口 */
	rtgui_win_show(switch2pt_confirm_win, RT_TRUE);

	/* 采用模态显示窗口,关闭时不会自行删除窗口,需要主动删除窗口 */
	rtgui_win_destroy(switch2pt_confirm_win);
	switch2pt_confirm_win = NULL;

	return;
}
Ejemplo n.º 19
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");
}
Ejemplo n.º 20
0
rt_base_t rtgui_win_show(struct rtgui_win* win, rt_bool_t is_modal)
{
	rt_base_t exit_code = -1;
	struct rtgui_app *app;
	struct rtgui_event_win_show eshow;

	app = rtgui_app_self();
	RTGUI_EVENT_WIN_SHOW_INIT(&eshow);
	eshow.wid = win;

	if (win == RT_NULL)
		return exit_code;

	/* if it does not register into server, create it in server */
	if (!(win->flag & RTGUI_WIN_FLAG_CONNECTED))
	{
		if (_rtgui_win_create_in_server(win) == RT_FALSE)
			return exit_code;
	}

	/* set window unhidden before notify the server */
	rtgui_widget_show(RTGUI_WIDGET(win));

	if (rtgui_server_post_event_sync(RTGUI_EVENT(&eshow),
		sizeof(struct rtgui_event_win_show)) != RT_EOK)
	{
		/* It could not be shown if a parent window is hidden. */
		rtgui_widget_hide(RTGUI_WIDGET(win));
		return exit_code;
	}

	if (win->focused_widget == RT_NULL)
		rtgui_widget_focus(RTGUI_WIDGET(win));

	/* set main window */
	if (app->main_object == RT_NULL)
		rtgui_app_set_main_win(win);

    if (is_modal == RT_TRUE)
    {
		struct rtgui_app *app;
		struct rtgui_event_win_modal_enter emodal;

		RTGUI_EVENT_WIN_MODAL_ENTER_INIT(&emodal);
		emodal.wid = win;

		app = rtgui_app_self();
		RT_ASSERT(app != RT_NULL);

		win->flag |= RTGUI_WIN_FLAG_MODAL;

		if (rtgui_server_post_event_sync((struct rtgui_event*)&emodal,
										 sizeof(emodal)) != RT_EOK)
			return exit_code;

		app->modal_object = RTGUI_OBJECT(win);

		exit_code = rtgui_app_run(app);

		app->modal_object = RT_NULL;
		win->flag &= ~RTGUI_WIN_FLAG_MODAL;

		if (win->style & RTGUI_WIN_STYLE_DESTROY_ON_CLOSE)
		{
			rtgui_win_destroy(win);
		}
    }

	return exit_code;
}