Esempio n. 1
0
static void _handle_app_destroy(struct rtgui_event_application* event)
{
	rt_uint32_t index;
	struct rtgui_app* app;

	for (index = 0; index < app_count; index ++)
	{
		app = (struct rtgui_app*)app_items[index].app;
		if (app == event->app)
		{
			/* remove this application */
			app_count --;
			if (app_count == 0) 
			{
				rtgui_free(app_items);
				app_items = RT_NULL;
			}
			else if (index == app_count)
			{
				app_items = rtgui_realloc(app_items, app_count * sizeof(struct rtgui_application_item));
			}
			else
			{
				rt_uint32_t j;
				for (j = index; j < app_count; j ++)
				{
					app_items[j] = app_items[j + 1];
				}
				app_items = rtgui_realloc(app_items, app_count * sizeof(struct rtgui_application_item));
			}
			rtgui_listctrl_set_items(app_list, (rt_uint32_t)app_items, app_count);
			rtgui_ack(RTGUI_EVENT(event), RTGUI_STATUS_OK);
			return ;
		}
	}

	/* send ack to the application */
	rtgui_ack(RTGUI_EVENT(event), RTGUI_STATUS_ERROR);
	return;
}
Esempio n. 2
0
void rtgui_notebook_remove(struct rtgui_notebook* notebook, rt_uint16_t index)
{
	struct rtgui_notebook_tab tab;
    rt_bool_t need_update = RT_FALSE;

	RT_ASSERT(notebook != RT_NULL);

	if (index < notebook->count)
	{
		if (notebook->count == 1)
		{
			tab = notebook->childs[0];
			rtgui_free(notebook->childs);
			notebook->childs = RT_NULL;
			notebook->count = 0;
		}
		else
		{
            if (notebook->current == index)
                need_update = RT_TRUE;

			tab = notebook->childs[index];
			for (;index < notebook->count - 1; index++)
			{
				notebook->childs[index] = notebook->childs[index + 1];
			}

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

		rt_free(tab.title);

		if (need_update)
		{
			if (notebook->current > notebook->count - 1)
				notebook->current = notebook->count - 1;

            rtgui_widget_hide(tab.widget);
            rtgui_widget_show(notebook->childs[notebook->current].widget);
			rtgui_widget_update(RTGUI_WIDGET(notebook));
            rtgui_widget_set_parent(tab.widget, RT_NULL);
		}
	}
}
Esempio n. 3
0
static void _handle_app_create(struct rtgui_event_application* event)
{
	rt_uint32_t index;
	rt_int32_t status;
	struct rtgui_app* app;

	status = RTGUI_STATUS_OK;
	for (index = 0; index < app_count; index ++)
	{
		app = (struct rtgui_app*)app_items[index].app;
		if (app == event->app)
		{
			/* application is created already */
			status = RTGUI_STATUS_ERROR;
			goto __exit;
		}
	}

	app_count += 1;
	if (app_items == RT_NULL)
		app_items = (struct rtgui_application_item*) rtgui_malloc(sizeof(struct rtgui_application_item));
	else
		app_items = (struct rtgui_application_item*) rtgui_realloc(app_items, sizeof(struct rtgui_application_item) * app_count);

	if (app_items == RT_NULL) 
	{
		status = RTGUI_STATUS_ERROR;
		goto __exit;
	}

	app = event->app;

	app_items[app_count - 1].app = app;
	rtgui_listctrl_set_items(app_list, (rt_uint32_t)app_items, app_count);

__exit:
	/* send ack to the application */
	rtgui_ack(RTGUI_EVENT(event), status);
	return;
}
Esempio n. 4
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;
}