Esempio n. 1
0
void rtgui_win_destroy(struct rtgui_win* win)
{
	/* close the window first if it's not. */
	if (!(win->flag & RTGUI_WIN_FLAG_CLOSED))
	{
		struct rtgui_event_win_close eclose;

		RTGUI_EVENT_WIN_CLOSE_INIT(&eclose);
		eclose.wid = win;

		if (win->style & RTGUI_WIN_STYLE_DESTROY_ON_CLOSE)
		{
			_rtgui_win_deal_close(win,
					(struct rtgui_event*)&eclose,
					RT_TRUE);
			return;
		}
		else
			_rtgui_win_deal_close(win,
					(struct rtgui_event*)&eclose,
					RT_TRUE);
	}

	if (win->flag & RTGUI_WIN_FLAG_MODAL)
	{
		/* set the RTGUI_WIN_STYLE_DESTROY_ON_CLOSE flag so the window will be
		 * destroyed after the event_loop */
		win->style |= RTGUI_WIN_STYLE_DESTROY_ON_CLOSE;
		rtgui_win_end_modal(win, RTGUI_MODAL_CANCEL);
	}
	else
	{
		rtgui_widget_destroy(RTGUI_WIDGET(win));
	}
}
Esempio n. 2
0
rtgui_win_t* rtgui_win_create(rtgui_toplevel_t* parent_toplevel, const char* title, rtgui_rect_t *rect, rt_uint8_t style)
{
	struct rtgui_win* win;

	/* allocate win memory */
	win = (struct rtgui_win*) rtgui_widget_create (RTGUI_WIN_TYPE);
	if (win != RT_NULL)
	{
		/* set parent toplevel */
		win->parent_toplevel = parent_toplevel;

		/* set title, rect and style */
		if (title != RT_NULL) win->title = rt_strdup(title);
		else win->title = RT_NULL;

		rtgui_widget_set_rect(RTGUI_WIDGET(win), rect);
		win->style = style;

		if (_rtgui_win_create_in_server(win) == RT_FALSE)
		{
			rtgui_widget_destroy(RTGUI_WIDGET(win));
			return RT_NULL;
		}
	}

	return win;
}
Esempio n. 3
0
/*
 * head_name[] -- 最后一个元素必须是NULL
 * rows -- 包含表头在内
 */
rtgui_form_t *rtgui_form_create(const char *head_name[], int rows, int cols, rtgui_rect_t *rect)
{
	int i, len;
	struct rtgui_form *form;

	if (NULL==head_name || NULL==rect)
		return NULL;

	form = (struct rtgui_form *)rtgui_widget_create(RTGUI_FORM_TYPE);
	if (NULL == form)
		return NULL;

	i = 0;
	while (NULL != head_name[i])
		++i;

	if (i != cols) {
		form_debug(("%s(), head items (%d) not same as cols(%d)!\n", __FUNCTION__, i, cols));
		goto err_entry;
	}

	form_debug(("%s(), line:%d: rows:%d, cols:%d!\n", __FUNCTION__, __LINE__, rows, cols));

	len = 0;
	for (i=0; i<cols; ++i) {
		len += rt_strlen(head_name[i]);
	}
	len += cols * GAG_BETWEEN_COL;

	form->fbody = rt_calloc(len*(rows-1), 1); /* 不包含表格头部占用的存储空间 */
	if (NULL == form->fbody) {
		form_debug(("fun:%s(), line:%d:%d malloc fail!\n", __FUNCTION__, __LINE__, len*(rows-1)));
		goto err_entry;
	}

	form->head_name = rt_calloc(cols, sizeof(head_name[0]));
	if (NULL == form->head_name) {
		form_debug(("fun:%s(), line:%d:%d malloc fail!\n", __FUNCTION__, __LINE__, cols * sizeof(head_name[0])));
		rt_free(form->fbody);
		goto err_entry;
	}

	form_debug(("%s(), line:%d: fbody-len:%d, head-name-len:%d!\n", __FUNCTION__, __LINE__,
				len*(rows-1), cols * sizeof(head_name[0])));

	for (i=0; i<cols; ++i) {
		form->head_name[i] = head_name[i];
	}
	form->head_item_cnt		= cols;
	form->row_cnt_of_fbody	= rows - 1;
	form->bytes_of_row		= len;

	rtgui_widget_set_rect(RTGUI_WIDGET(form), rect);

	return form;

err_entry:
	rtgui_widget_destroy(RTGUI_WIDGET(form));
	return NULL;
}
Esempio n. 4
0
rtgui_win_t* rtgui_win_create(struct rtgui_win* parent_window,
		                      const char* title,
							  rtgui_rect_t *rect,
							  rt_uint16_t style)
{
	struct rtgui_win* win;

	/* allocate win memory */
	win = RTGUI_WIN(rtgui_widget_create(RTGUI_WIN_TYPE));
	if (win == RT_NULL)
		return RT_NULL;

	/* set parent toplevel */
	win->parent_window = parent_window;

	/* set title, rect and style */
	if (title != RT_NULL)
		win->title = rt_strdup(title);
	else
		win->title = RT_NULL;

	rtgui_widget_set_rect(RTGUI_WIDGET(win), rect);
	win->style = style;

	if (_rtgui_win_create_in_server(win) == RT_FALSE)
	{
		goto __on_err;
	}
	return win;

__on_err:
	rtgui_widget_destroy(RTGUI_WIDGET(win));
	return RT_NULL;
}
Esempio n. 5
0
void rtgui_win_destroy(struct rtgui_win* win)
{
	if (win->style & RTGUI_WIN_STYLE_MODAL)
	{
		/* end modal */
		rtgui_win_end_modal(win, RTGUI_MODAL_CANCEL);
	}
	else
	{
		rtgui_widget_destroy(RTGUI_WIDGET(win));
	}
}
Esempio n. 6
0
void rtgui_win_destroy(struct rtgui_win* win)
{
    if (win->flag & RTGUI_WIN_FLAG_MODAL)
    {
        /* set the RTGUI_WIN_STYLE_DESTROY_ON_CLOSE flag so the window will be
         * destroyed after the event_loop */
        win->style |= RTGUI_WIN_STYLE_DESTROY_ON_CLOSE;
        rtgui_win_end_modal(win, RTGUI_MODAL_CANCEL);
    }
    else
        rtgui_widget_destroy(RTGUI_WIDGET(win));
}
Esempio n. 7
0
rtgui_win_t* rtgui_win_create(struct rtgui_win* parent_window,
                              const char* title,
                              rtgui_rect_t *rect,
                              rt_uint16_t style)
{
    struct rtgui_win* win;

    /* allocate win memory */
    win = RTGUI_WIN(rtgui_widget_create(RTGUI_WIN_TYPE));
    if (win == RT_NULL)
        return RT_NULL;

    /* set parent toplevel */
#ifdef RTGUI_USING_DESKTOP_WINDOW
    if (style & RTGUI_WIN_STYLE_DESKTOP)
    {
        RT_ASSERT(the_desktop_window == RT_NULL);
        win->parent_window = RT_NULL;
        the_desktop_window = win;
    }
    else if (parent_window == RT_NULL)
    {
        RT_ASSERT(the_desktop_window != RT_NULL);
        win->parent_window = the_desktop_window;
    }
    else
        win->parent_window = parent_window;
#else
    win->parent_window = parent_window;
#endif

    /* set title, rect and style */
    if (title != RT_NULL)
        win->title = rt_strdup(title);
    else
        win->title = RT_NULL;

    rtgui_widget_set_rect(RTGUI_WIDGET(win), rect);
    win->style = style;

    if (_rtgui_win_create_in_server(win) == RT_FALSE)
    {
        goto __on_err;
    }
    return win;

__on_err:
    rtgui_widget_destroy(RTGUI_WIDGET(win));
    return RT_NULL;
}
Esempio n. 8
0
void rtgui_workbench_destroy(rtgui_workbench_t* workbench)
{
	RT_ASSERT(workbench != RT_NULL);

	if (workbench->flag & RTGUI_WORKBENCH_FLAG_CLOSED)
	{
		rtgui_widget_destroy(RTGUI_WIDGET(workbench));
	}
	else
	{
		/* just close workbench */
		rtgui_workbench_close(workbench);
	}
}
Esempio n. 9
0
static void _rtgui_notebook_destructor(struct rtgui_notebook *notebook)
{
	int index;

	if (notebook->childs != RT_NULL)
	{
		for (index = 0; index < notebook->count; index ++)
		{
			rtgui_widget_destroy(notebook->childs[index].widget);
			rt_free(notebook->childs[index].title);
		}

		rtgui_free(notebook->childs);
	}
}
Esempio n. 10
0
void rtgui_form_destroy(rtgui_form_t* form)
{
	if (NULL != form->head_name) {
		rt_free(form->head_name);
		form->head_name = NULL;
	}

	if (NULL != form->fbody) {
		rt_free(form->fbody);
		form->fbody = NULL;
	}

	/* destroy form */
	rtgui_widget_destroy(RTGUI_WIDGET(form));
	return;
}
Esempio n. 11
0
void rtgui_progressbar_destroy(struct rtgui_progressbar* bar)
{
	rtgui_widget_destroy(RTGUI_WIDGET(bar));
}
/* 删除一个自定义控件 */
void rtgui_mywidget_destroy(struct rtgui_mywidget* me)
{
	rtgui_widget_destroy(RTGUI_WIDGET(me));
}
Esempio n. 13
0
void rtgui_radiobox_destroy(struct rtgui_radiobox *radiobox)
{
    rtgui_widget_destroy(RTGUI_WIDGET(radiobox));
}
Esempio n. 14
0
void rtgui_combo_destroy(rtgui_combo_t* cbo)
{
	rtgui_widget_destroy(cbo);
}
Esempio n. 15
0
void rtgui_button_destroy(rtgui_button_t* btn)
{
	rtgui_widget_destroy(RTGUI_WIDGET(btn));
}
Esempio n. 16
0
void rtgui_scrollbar_destroy(struct rtgui_scrollbar* bar)
{
	rtgui_widget_destroy(RTGUI_WIDGET(bar));
}
Esempio n. 17
0
void rtgui_staticline_destroy(rtgui_staticline_t* staticline)
{
	rtgui_widget_destroy(RTGUI_WIDGET(staticline));
}
Esempio n. 18
0
void rtgui_textbox_destroy(struct rtgui_textbox* box)
{
	rtgui_widget_destroy(RTGUI_WIDGET(box));
}
Esempio n. 19
0
void rtgui_wintitle_destroy(rtgui_wintitle_t *wintitle)
{
    rtgui_widget_destroy(RTGUI_WIDGET(wintitle));
}
Esempio n. 20
0
File: edit.c Progetto: amsl/RTGUI
void rtgui_edit_destroy(struct rtgui_edit* edit)
{
	rtgui_widget_destroy(RTGUI_WIDGET(edit));
}
Esempio n. 21
0
void rtgui_checkbox_destroy(rtgui_checkbox_t* box)
{
	rtgui_widget_destroy(RTGUI_WIDGET(box));
}
Esempio n. 22
0
void rtgui_mv_view_destroy(struct rtgui_mv_view *view)
{
    rtgui_widget_destroy(RTGUI_WIDGET(view));
}
Esempio n. 23
0
/* windows event loop */
void rtgui_win_event_loop(rtgui_win_t* wnd)
{
	rt_err_t result;
	rtgui_thread_t* tid;
	struct rtgui_event* event;

	tid = rtgui_thread_self();
	RT_ASSERT(tid != RT_NULL);

	/* point to event buffer */
	event = (struct rtgui_event*)tid->event_buffer;

	if (wnd->style & RTGUI_WIN_STYLE_UNDER_MODAL)
	{
		while (wnd->style & RTGUI_WIN_STYLE_UNDER_MODAL)
		{
			if (tid->on_idle != RT_NULL)
			{
				result = rtgui_thread_recv_nosuspend(event, RTGUI_EVENT_BUFFER_SIZE);
				if (result == RT_EOK)
				{
					/* perform event handler */
					RTGUI_WIDGET(wnd)->event_handler(RTGUI_WIDGET(wnd), event);
				}
				else if (result == -RT_ETIMEOUT)
				{
					tid->on_idle(RTGUI_WIDGET(wnd), RT_NULL);
				}
			}
			else
			{
				result = rtgui_thread_recv(event, RTGUI_EVENT_BUFFER_SIZE);
				if (result == RT_EOK)
				{
					/* perform event handler */
					RTGUI_WIDGET(wnd)->event_handler(RTGUI_WIDGET(wnd), event);
				}
			}
		}
	}
	else
	{
		while (!(wnd->style & RTGUI_WIN_STYLE_CLOSED))
		{
			if (tid->on_idle != RT_NULL)
			{
				result = rtgui_thread_recv_nosuspend(event, RTGUI_EVENT_BUFFER_SIZE);
				if (result == RT_EOK)
				{
					/* perform event handler */
					RTGUI_WIDGET(wnd)->event_handler(RTGUI_WIDGET(wnd), event);
				}
				else if (result == -RT_ETIMEOUT)
				{
					tid->on_idle(RTGUI_WIDGET(wnd), RT_NULL);
				}
			}
			else
			{
				result = rtgui_thread_recv(event, RTGUI_EVENT_BUFFER_SIZE);
				if (result == RT_EOK)
				{
					/* perform event handler */
					RTGUI_WIDGET(wnd)->event_handler(RTGUI_WIDGET(wnd), event);
				}
			}
		}
	}

	/* destroy window */
	rtgui_widget_destroy(RTGUI_WIDGET(wnd));
}
void rtgui_textview_destroy(rtgui_textview_t* textview)
{
	rtgui_widget_destroy(RTGUI_WIDGET(textview));
}
Esempio n. 25
0
void rtgui_terminal_destroy(rtgui_terminal_t* tma)
{
	rtgui_widget_destroy(tma);
}
Esempio n. 26
0
void rtgui_notebook_destroy(struct rtgui_notebook* notebook)
{
	rtgui_widget_destroy(RTGUI_WIDGET(notebook));
}
Esempio n. 27
0
void rtgui_menu_destroy(struct rtgui_menu* menu)
{
	rtgui_widget_destroy (RTGUI_WIDGET(menu));
}
Esempio n. 28
0
void rtgui_listctrl_destroy(rtgui_listctrl_t* ctrl)
{
    /* destroy ctrl */
	rtgui_widget_destroy(RTGUI_WIDGET(ctrl));
}
Esempio n. 29
0
void rtgui_list_view_destroy(rtgui_list_view_t* view)
{
    /* destroy view */
	rtgui_widget_destroy(RTGUI_WIDGET(view));
}
Esempio n. 30
0
void rtgui_label_destroy(rtgui_label_t* label)
{
    rtgui_widget_destroy(RTGUI_WIDGET(label));
}