예제 #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
void rtgui_notebook_add_image(struct rtgui_notebook* notebook, const char* label, struct rtgui_widget* child, 
	struct rtgui_image *pressed_image, struct rtgui_image *unpressed_image)
{
	rtgui_rect_t rect;
	RT_ASSERT(notebook != RT_NULL);

	notebook->count += 1;
	notebook->childs = (struct rtgui_notebook_tab*)
		rtgui_realloc(notebook->childs,
		sizeof(struct rtgui_notebook_tab) * notebook->count);

	notebook->childs[notebook->count - 1].title = rt_strdup(label);
	notebook->childs[notebook->count - 1].widget = child;
	notebook->childs[notebook->count - 1].pressed_image = pressed_image;
	notebook->childs[notebook->count - 1].unpressed_image = unpressed_image;

	/* set parent */
	rtgui_widget_set_parent(child, RTGUI_WIDGET(notebook));

	_rtgui_notebook_get_page_rect(notebook, &rect);
	rtgui_widget_rect_to_device(RTGUI_WIDGET(notebook), &rect);
	rtgui_widget_set_rect(child, &rect);

	if (notebook->count - 1 != notebook->current)
		rtgui_widget_hide(child);

	if (RTGUI_WIDGET(notebook)->toplevel != RT_NULL &&
		RTGUI_IS_WIN(RTGUI_WIDGET(notebook)->toplevel))
	{
		struct rtgui_event_update_toplvl eup;
		RTGUI_EVENT_UPDATE_TOPLVL_INIT(&eup);
		eup.toplvl = RTGUI_WIDGET(notebook)->toplevel;
		if (RTGUI_OBJECT(child)->event_handler)
			RTGUI_OBJECT(child)->event_handler(RTGUI_OBJECT(child), (struct rtgui_event*)&eup);
	}

	return;
}
예제 #3
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;
}
예제 #4
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;
}
예제 #5
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;
}
struct rtgui_dc* rtgui_dc_hw_create(rtgui_widget_t* owner)
{
	struct rtgui_dc_hw* 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;

	/* 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);
			return RT_NULL;
		}

		widget = widget->parent;
	}

	if (!RTGUI_WIDGET_IS_DC_VISIBLE(owner)) return RT_NULL;

	/* create DC */
	dc = (struct rtgui_dc_hw*) rtgui_malloc(sizeof(struct rtgui_dc_hw));
	dc->parent.type = RTGUI_DC_HW;
	dc->parent.engine = &dc_hw_engine;
	dc->owner = owner;
	dc->hw_driver = rtgui_graphic_driver_get_default();

	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_APPLICATION(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_server_post_event((struct rtgui_event*)&eupdate, sizeof(eupdate));
#endif
		}
	}

	return &(dc->parent);
}
static rt_bool_t rtgui_dc_hw_fini(struct rtgui_dc* dc)
{
	rtgui_widget_t* owner;
	struct rtgui_dc_hw* self;

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

	self = (struct rtgui_dc_hw*)dc;
	/* get owner */
	owner = self->owner;

	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(self->hw_driver, &(owner->extent));
#else
#ifdef RTGUI_USING_MOUSE_CURSOR
			/* show cursor */
			rtgui_mouse_show_cursor();
#endif

			/* update screen */
			rtgui_graphic_driver_screen_update(self->hw_driver, &(owner->extent));
#endif
		}
	}
	else if (RTGUI_IS_APPLICATION(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(self->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_server_post_event((struct rtgui_event*)&eupdate, sizeof(eupdate));
#endif
		}
	}

	/* release hardware dc */
	rtgui_free(self);

	return RT_TRUE;
}