示例#1
0
static rt_bool_t _rtgui_win_create_in_server(struct rtgui_win *win)
{
    if (!(win->flag & RTGUI_WIN_FLAG_CONNECTED))
    {
        struct rtgui_event_win_create ecreate;
        RTGUI_EVENT_WIN_CREATE_INIT(&ecreate);

        /* send win create event to server */
        ecreate.parent_window = win->parent_window;
        ecreate.wid           = win;
        ecreate.parent.user	  = win->style;
#ifndef RTGUI_USING_SMALL_SIZE
        ecreate.extent        = RTGUI_WIDGET(win)->extent;
        rt_strncpy((char*)ecreate.title, (char*)win->title, RTGUI_NAME_MAX);
#endif

        if (rtgui_server_post_event_sync(RTGUI_EVENT(&ecreate),
                                         sizeof(struct rtgui_event_win_create)
                                        ) != RT_EOK)
        {
            rt_kprintf("create win: %s failed\n", win->title);
            return RT_FALSE;
        }

        win->flag |= RTGUI_WIN_FLAG_CONNECTED;
    }

    return RT_TRUE;
}
示例#2
0
static rt_bool_t _rtgui_win_create_in_server(rtgui_win_t* win)
{
	if (RTGUI_TOPLEVEL(win)->server == RT_NULL)
	{
		rt_thread_t server;
		struct rtgui_event_win_create ecreate;
		RTGUI_EVENT_WIN_CREATE_INIT(&ecreate);

		/* get server thread id */
		server = rtgui_thread_get_server();
		if (server == RT_NULL)
		{
			rt_kprintf("RTGUI server is not running...\n");
			return RT_FALSE;
		}

		/* send win create event to server */
		ecreate.wid 		= win;
		ecreate.parent.user	= win->style;
#ifndef RTGUI_USING_SMALL_SIZE
		ecreate.extent 		= RTGUI_WIDGET(win)->extent;
		rt_strncpy((char*)ecreate.title, (char*)win->title, RTGUI_NAME_MAX);
#endif

		if (rtgui_thread_send_sync(server, RTGUI_EVENT(&ecreate),
			sizeof(struct rtgui_event_win_create)) != RT_EOK)
		{
			rt_kprintf("create win: %s failed\n", win->title);
			return RT_FALSE;
		}

		/* set server */
		RTGUI_TOPLEVEL(win)->server = server;
	}

	return RT_TRUE;
}