示例#1
0
void rtgui_win_end_modal(struct rtgui_win* win, rtgui_modal_code_t modal_code)
{
	if (win->parent_toplevel != RT_NULL)
	{
		if (RTGUI_IS_WORKBENCH(win->parent_toplevel))
		{
			rtgui_workbench_t* workbench;

			/* which is shown under workbench */
			workbench = RTGUI_WORKBENCH(win->parent_toplevel);
			workbench->modal_code = modal_code;
			workbench->flag &= ~RTGUI_WORKBENCH_FLAG_MODAL_MODE;
		}
		else if (RTGUI_IS_WIN(win->parent_toplevel))
		{
			rtgui_win_t* parent_win;

			/* which is shown under win */
			parent_win = RTGUI_WIN(win->parent_toplevel);
			parent_win->modal_code = modal_code;
			parent_win->style &= ~RTGUI_WIN_STYLE_UNDER_MODAL;		
		}
	}
	else
	{
		/* which is a stand alone window */
		win->modal_code = modal_code;
	}

	/* remove modal mode */
	win->style &= ~RTGUI_WIN_STYLE_MODAL;
}
示例#2
0
struct rtgui_dc* rtgui_dc_client_create(rtgui_widget_t* owner)
{
	struct rtgui_dc* dc;
	rtgui_widget_t* widget;

	/* adjudge owner */
	if (owner == RT_NULL || owner->toplevel == RT_NULL) return RT_NULL;
	if (!RTGUI_IS_TOPLEVEL(owner->toplevel)) return RT_NULL;

	dc = RTGUI_WIDGET_DC(owner);
	/* set init visible as true */
	RTGUI_WIDGET_DC_SET_VISIBLE(owner);

	/* check widget visible */
	widget = owner;
	while (widget != RT_NULL) {
		if (RTGUI_WIDGET_IS_HIDE(widget)) {
			RTGUI_WIDGET_DC_SET_UNVISIBLE(owner);
			break;
		}

		widget = widget->parent;
	}

	if (RTGUI_IS_WINTITLE(owner->toplevel)) {
		rtgui_toplevel_t* top = RTGUI_TOPLEVEL(owner->toplevel);
		top->drawing ++;

		if (top->drawing == 1) {
#ifdef RTGUI_USING_MOUSE_CURSOR
#ifdef __WIN32__
			rt_mutex_take(&cursor_mutex, RT_WAITING_FOREVER);
			rt_kprintf("hide cursor\n");
			rtgui_mouse_hide_cursor();
#else
			/* hide cursor */
			rtgui_mouse_hide_cursor();
#endif
#endif
		}
	} else if (RTGUI_IS_WORKBENCH(owner->toplevel) ||
			   RTGUI_IS_WIN(owner->toplevel)) {
		rtgui_toplevel_t* top = RTGUI_TOPLEVEL(owner->toplevel);
		top->drawing ++;

		if (top->drawing == 1) {
#ifdef __WIN32__
#ifdef RTGUI_USING_MOUSE_CURSOR
			rt_mutex_take(&cursor_mutex, RT_WAITING_FOREVER);
			rt_kprintf("hide cursor\n");
			rtgui_mouse_hide_cursor();
#endif
#else
			/* send draw begin to server */
			struct rtgui_event_update_begin eupdate;
			RTGUI_EVENT_UPDATE_BEGIN_INIT(&(eupdate));
			eupdate.rect = RTGUI_WIDGET(top)->extent;

			rtgui_thread_send(top->server, (struct rtgui_event*)&eupdate, sizeof(eupdate));
#endif
		}
	}

	return dc;
}
示例#3
0
static rt_bool_t rtgui_dc_client_fini(struct rtgui_dc* dc)
{
	rtgui_widget_t* owner;

	if (dc == RT_NULL || dc->type != RTGUI_DC_CLIENT) return RT_FALSE;

	/* get owner */
	owner = RTGUI_CONTAINER_OF(dc, struct rtgui_widget, dc_type);

	if (RTGUI_IS_WINTITLE(owner->toplevel)) {
		/* update title extent */
		rtgui_toplevel_t* top = RTGUI_TOPLEVEL(owner->toplevel);

		top->drawing --;
		if ((top->drawing == 0) && RTGUI_WIDGET_IS_DC_VISIBLE(owner)) {
#ifdef __WIN32__
#ifdef RTGUI_USING_MOUSE_CURSOR
			rt_mutex_release(&cursor_mutex);
			/* show cursor */
			rtgui_mouse_show_cursor();
			rt_kprintf("show cursor\n");
#endif
			/* update screen */
			rtgui_graphic_driver_screen_update(hw_driver, &(owner->extent));
#else
#ifdef RTGUI_USING_MOUSE_CURSOR
			/* show cursor */
			rtgui_mouse_show_cursor();
#endif

			/* update screen */
			rtgui_graphic_driver_screen_update(hw_driver, &(owner->extent));
#endif
		}
	} else if (RTGUI_IS_WORKBENCH(owner->toplevel) ||
			   RTGUI_IS_WIN(owner->toplevel)) {
		rtgui_toplevel_t* top = RTGUI_TOPLEVEL(owner->toplevel);
		top->drawing --;

		if ((top->drawing == 0) && RTGUI_WIDGET_IS_DC_VISIBLE(owner)) {
#ifdef __WIN32__
#ifdef RTGUI_USING_MOUSE_CURSOR
			rt_mutex_release(&cursor_mutex);
			/* show cursor */
			rtgui_mouse_show_cursor();
			rt_kprintf("show cursor\n");
#endif
			/* update screen */
			rtgui_graphic_driver_screen_update(hw_driver, &(owner->extent));
#else
			/* send to server to end drawing */
			struct rtgui_event_update_end eupdate;
			RTGUI_EVENT_UPDATE_END_INIT(&(eupdate));
			eupdate.rect = owner->extent;

			rtgui_thread_send(top->server, (struct rtgui_event*)&eupdate, sizeof(eupdate));
#endif
		}
	}

	return RT_TRUE;
}
示例#4
0
rtgui_modal_code_t rtgui_win_show(struct rtgui_win* win, rt_bool_t is_modal)
{
	rtgui_modal_code_t result;

	RT_ASSERT(win != RT_NULL);
	result = RTGUI_MODAL_CANCEL;

	/* if it does not register into server, create it in server */
	if (RTGUI_TOPLEVEL(win)->server == RT_NULL)
	{
		if (_rtgui_win_create_in_server(win) == RT_FALSE)
			return result;
	}

	if (RTGUI_WIDGET_IS_HIDE(RTGUI_WIDGET(win)))
	{
		/* send show message to server */
		struct rtgui_event_win_show eshow;
		RTGUI_EVENT_WIN_SHOW_INIT(&eshow);
		eshow.wid = win;

		if (rtgui_thread_send_sync(RTGUI_TOPLEVEL(win)->server, RTGUI_EVENT(&eshow),
			sizeof(struct rtgui_event_win_show)) != RT_EOK)
		{
			/* hide window failed */
			return result;
		}

		/* set window unhidden */
		RTGUI_WIDGET_UNHIDE(RTGUI_WIDGET(win));
	}
	else rtgui_widget_update(RTGUI_WIDGET(win));

	if (is_modal == RT_TRUE)
	{
		if (win->parent_toplevel != RT_NULL)
		{
			rtgui_widget_t *parent_widget;

			/* set style */
			win->style |= RTGUI_WIN_STYLE_MODAL;

			/* get root toplevel */
			parent_widget = RTGUI_WIDGET(win->parent_toplevel);
			if (RTGUI_IS_WORKBENCH(parent_widget))
			{
				rtgui_workbench_t* workbench;
				workbench = RTGUI_WORKBENCH(win->parent_toplevel);
				workbench->flag |= RTGUI_WORKBENCH_FLAG_MODAL_MODE;
				workbench->modal_widget = RTGUI_WIDGET(win);

				rtgui_workbench_event_loop(workbench);
				result = workbench->modal_code;
				workbench->flag &= ~RTGUI_WORKBENCH_FLAG_MODAL_MODE;
				workbench->modal_widget = RT_NULL;
			}
			else if (RTGUI_IS_WIN(parent_widget))
			{
				rtgui_win_t* parent_win;
				parent_win = RTGUI_WIN(win->parent_toplevel);
				parent_win->style |= RTGUI_WIN_STYLE_UNDER_MODAL;
				parent_win->modal_widget = RTGUI_WIDGET(win);

				rtgui_win_event_loop(parent_win);
				result = parent_win->modal_code;
				parent_win->style &= ~RTGUI_WIN_STYLE_UNDER_MODAL;
				parent_win->modal_widget = RT_NULL;
			}
		}
		else
		{
			/* which is a root window */
			win->style |= RTGUI_WIN_STYLE_MODAL;
			rtgui_win_event_loop(win);

			result = win->modal_code;
			win->style &= ~RTGUI_WIN_STYLE_MODAL;
		}
	}

	return result;
}