예제 #1
0
struct rtgui_checkbox* rtgui_checkbox_create(const char* text, rt_bool_t checked)
{
    struct rtgui_checkbox* box;

    box = (struct rtgui_checkbox*) rtgui_widget_create (RTGUI_CHECKBOX_TYPE);
    if (box != RT_NULL)
    {
		rtgui_rect_t rect;

		/* set default rect */
		rtgui_font_get_metrics(rtgui_font_default(), text, &rect);
		rect.x2 += RTGUI_BORDER_DEFAULT_WIDTH + 5 + (RTGUI_BORDER_DEFAULT_WIDTH << 1);
		rect.y2 += (RTGUI_BORDER_DEFAULT_WIDTH << 1);

		rtgui_widget_set_rect(RTGUI_WIDGET(box), &rect);
		rtgui_label_set_text(RTGUI_LABEL(box), text);
		
		if (checked == RT_TRUE)
			box->status_down = RTGUI_CHECKBOX_STATUS_CHECKED;
		else
			box->status_down = RTGUI_CHECKBOX_STATUS_UNCHECKED;
	}

	return box;
}
예제 #2
0
rtgui_workbench_t *rtgui_workbench_create(const char* panel_name, const unsigned char* title)
{
	struct rtgui_workbench* workbench;

	/* the server thread id */
	rt_thread_t server = rtgui_thread_get_server();
	if (server == RT_NULL)
	{
		rt_kprintf("can't find rtgui server\n");
		return RT_NULL;
	}

	/* create workbench */
	workbench = (rtgui_workbench_t*) rtgui_widget_create (RTGUI_WORKBENCH_TYPE);
	if (workbench != RT_NULL)
	{
		/* the buffer uses to receive event */
		union
		{
			struct rtgui_event_panel_attach ecreate;
			struct rtgui_event_panel_info epanel;

			char buffer[256];	/* use to recv other information */
		} event;

		/* set workbench title */
		workbench->title = (unsigned char*)rt_strdup((char*)title);

		/* create application in server */
		RTGUI_EVENT_PANEL_ATTACH_INIT(&(event.ecreate));

		/* set the panel name and workbench */
		rt_strncpy(event.ecreate.panel_name, panel_name, RTGUI_NAME_MAX);
		event.ecreate.workbench = workbench;

		/* send PANEL ATTACH to server */
		if (rtgui_thread_send_sync(server,
			&(event.ecreate.parent), sizeof(struct rtgui_event_panel_attach)) != RTGUI_STATUS_OK)
		{
			return RT_NULL;
		}

		/* get PANEL INFO */
		rtgui_thread_recv_filter(RTGUI_EVENT_PANEL_INFO, &(event.epanel.parent), sizeof(event));

		/* set panel */
		workbench->panel = (struct rtgui_panel*)event.epanel.panel;

		/* connected */
		RTGUI_TOPLEVEL(workbench)->server = server;

		/* set extent of workbench */
		rtgui_widget_set_rect(RTGUI_WIDGET(workbench), &(event.epanel.extent));

		/* set workbench in thread */
		rtgui_thread_set_widget(RTGUI_WIDGET(workbench));
	}

	return workbench;
}
예제 #3
0
파일: window.c 프로젝트: zdgaoyu/RTGUI
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;
}
예제 #4
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;
}
예제 #5
0
파일: terminal.c 프로젝트: amsl/RTGUI
rtgui_terminal_t* rtgui_terminal_create(pvoid parent,const char* text, int left,int top,int w,int h)
{
	rtgui_container_t *container;
	rtgui_terminal_t* tma;

	RT_ASSERT(parent != RT_NULL);
	container = RTGUI_CONTAINER(parent);

	tma = rtgui_widget_create(RTGUI_TERMINAL_TYPE);
	if(tma != RT_NULL)
	{
		rtgui_rect_t rect;
		rtgui_widget_get_rect(container, &rect);
		rtgui_widget_rect_to_device(container,&rect);
		rect.x1 += left;
		rect.y1 += top;
		rect.x2 = rect.x1+w;
		rect.y2 = rect.y1+h;
		rtgui_widget_set_rect(tma,&rect);
		rtgui_container_add_child(container, tma);

		/* calculate line width and line page count */
		rtgui_terminal_calc_width(tma);
		/* set text */
		rtgui_terminal_calc_line(tma, text);
	}

	return tma;
}
예제 #6
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;
}
예제 #7
0
파일: menu.c 프로젝트: pengdonglin137/iboot
struct rtgui_menu* rtgui_menu_create(const char* title, struct rtgui_menu* parent_menu, 
	const struct rtgui_menu_item* items, rt_uint16_t count)
{
	rtgui_rect_t rect = {0, 0, 100, 100};
    struct rtgui_menu* menu;

    menu = (struct rtgui_menu*) rtgui_widget_create ( RTGUI_MENU_TYPE );
	if (menu != RT_NULL)
	{
		rtgui_win_set_title(RTGUI_WIN(menu), title);
		menu->parent_menu = parent_menu;
		menu->items = items;
		menu->items_count = count;

		rtgui_widget_set_rect(RTGUI_WIDGET(menu), &rect);
		rtgui_rect_inflate(&rect, -1);
		/* create menu item list */
		menu->items_list = rtgui_listctrl_create((rt_uint32_t)items, count, &rect, _rtgui_menu_item_ondraw); 
		RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(menu->items_list)) = rtgui_theme_default_bc();
		rtgui_container_add_child(RTGUI_CONTAINER(menu), RTGUI_WIDGET(menu->items_list));
		rtgui_listctrl_set_onitem(menu->items_list, _rtgui_menu_onitem);
	}

	return menu;
}
예제 #8
0
struct rtgui_plot *rtgui_plot_create(void)
{
    struct rtgui_plot *plot;

    plot = RTGUI_PLOT(rtgui_widget_create(RTGUI_PLOT_TYPE));

    return plot;
}
예제 #9
0
rtgui_staticline_t * rtgui_staticline_create(int orientation)
{
	rtgui_staticline_t* staticline;

	staticline = (struct rtgui_staticline*) rtgui_widget_create(RTGUI_STATICLINE_TYPE);
	if (staticline!= RT_NULL)
	{
		rtgui_staticline_set_orientation(staticline, orientation);
	}

	return staticline;
}
예제 #10
0
rtgui_wintitle_t *rtgui_wintitle_create(struct rtgui_win *window, const char *title)
{
    rtgui_wintitle_t *wintitle;

    wintitle = (rtgui_wintitle_t *)rtgui_widget_create(RTGUI_WINTITLE_TYPE);
    if (wintitle != RT_NULL)
    {
        rtgui_wintitle_set_title(wintitle, title);
        RTGUI_WIDGET(wintitle)->toplevel = window;
    }

    return wintitle;
}
예제 #11
0
rtgui_combobox_t *rtgui_combobox_create(struct rtgui_listbox_item* items, rt_uint16_t count, struct rtgui_rect* rect)
{
	rtgui_combobox_t *box;

	box = (rtgui_combobox_t*)rtgui_widget_create(RTGUI_COMBOBOX_TYPE);
	box->items_count = count;
	box->items = items;
	rtgui_widget_set_rect(RTGUI_WIDGET(box), rect);
	
	box->pd_win = RT_NULL;

	return box;
}
/* 创建一个自定义控件 */
struct rtgui_mywidget* rtgui_mywidget_create(rtgui_rect_t* r)
{
	struct rtgui_mywidget* me;

	/* 让rtgui_widget创建出一个指定类型:RTGUI_MYWIDGET_TYPE类型的控�?*/
	me = (struct rtgui_mywidget*) rtgui_widget_create (RTGUI_MYWIDGET_TYPE);
	if (me != RT_NULL)
	{
		rtgui_widget_set_rect(RTGUI_WIDGET(me), r);
	}

	return me;
}
예제 #13
0
struct rtgui_notebook* rtgui_notebook_create(const rtgui_rect_t* rect, rt_uint8_t style)
{
    struct rtgui_notebook* notebook;

    notebook = (struct rtgui_notebook*) rtgui_widget_create(RTGUI_NOTEBOOK_TYPE);
    if (notebook != RT_NULL)
    {
		notebook->flag = style;
		rtgui_widget_set_rect(RTGUI_WIDGET(notebook), rect);
    }

    return notebook;
}
예제 #14
0
파일: window.c 프로젝트: zhangjinxing/RTGUI
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;
}
예제 #15
0
rtgui_textbox_t *rtgui_textbox_create(const char *text, rt_uint32_t flag)
{
	rtgui_textbox_t *box;

	box = (struct rtgui_textbox *)rtgui_widget_create(RTGUI_TEXTBOX_TYPE);
	if (box != RT_NULL)
	{
		/* allocate default line buffer */
		rtgui_textbox_set_value(box, text);
		box->flag = flag;
	}

	return box;
}
예제 #16
0
파일: fileview.c 프로젝트: amsl/RTGUI
rtgui_fileview_t* rtgui_fileview_create(pvoid parent, const char* directory, const char* pattern, int left, int top, int w, int h)
{
	rtgui_container_t *container;
	rtgui_fileview_t* fview = RT_NULL;

	RT_ASSERT(parent != RT_NULL);
	container = RTGUI_CONTAINER(parent);

	/* create a new view */
	fview = rtgui_widget_create(RTGUI_FILEVIEW_TYPE);

	if(fview != RT_NULL)
	{
		rtgui_rect_t rect;

		rtgui_widget_get_rect(container, &rect);
		rtgui_widget_rect_to_device(container,&rect);
		rect.x1 += left;
		rect.y1 += top;
		rect.x2 = rect.x1+w;
		rect.y2 = rect.y1+h;

		fview->items = RT_NULL;
		fview->pattern = rt_strdup(pattern);
		fview->item_per_page = RC_H(rect) / (1 + RTGUI_SEL_H);

		rtgui_widget_set_rect(fview,&rect);
		rtgui_container_add_child(container, fview);

		{
			/* create scrollbar */
			rt_uint32_t sLeft,sTop,sw=RTGUI_DEFAULT_SB_WIDTH,sLen;
			sLeft = RC_W(rect)-RTGUI_WIDGET_BORDER_SIZE(fview)-sw;
			sTop = RTGUI_WIDGET_BORDER_SIZE(fview);

			sLen = rect.y2-rect.y1-RTGUI_WIDGET_BORDER_SIZE(fview)*2;
			fview->sbar = rtgui_scrollbar_create(fview,sLeft,sTop,sw,sLen,RTGUI_VERTICAL);
			if(fview->sbar != RT_NULL)
			{
				fview->sbar->widget_link = fview;
				fview->sbar->on_scroll = rtgui_fileview_sbar_handle;
				RTGUI_WIDGET_HIDE(fview->sbar);/* default hid scrollbar */
			}
		}

		rtgui_fileview_set_directory(fview, directory);
	}

	return fview;
}
예제 #17
0
struct rtgui_radiobox *rtgui_radiobox_create(const char *label, int orient, char **radio_items, int number)
{
    struct rtgui_radiobox *radiobox;

    radiobox = (struct rtgui_radiobox *) rtgui_widget_create(RTGUI_RADIOBOX_TYPE);
    if (radiobox != RT_NULL)
    {
        rt_uint8_t board_size;
        struct rtgui_rect rect;

        radiobox->items = radio_items;
        radiobox->item_count = number;
        radiobox->item_selection = -1;
        radiobox->text = rt_strdup(label);

        /* set proper of control */
        rtgui_radiobox_set_orientation(radiobox, orient);
        rtgui_font_get_metrics(RTGUI_WIDGET_FONT(radiobox), "H", &rect);
        board_size = rtgui_rect_height(rect);

        if (orient == RTGUI_VERTICAL)
        {
            radiobox->item_size = board_size;
        }
        else
        {
            int index;
            struct rtgui_font *font;
            struct rtgui_rect rect;

            /* set init item size */
            radiobox->item_size = 0;

            font = RTGUI_WIDGET_FONT(radiobox);
            for (index = 0; index < number; index ++)
            {
                rtgui_font_get_metrics(font, radio_items[index], &rect);
                if ((board_size + 3 + rtgui_rect_width(rect)) > radiobox->item_size)
                    radiobox->item_size = board_size + 3 + rtgui_rect_width(rect);
            }
        }

        if (radiobox->item_size < RADIO_BOX_H + 2)
            radiobox->item_size = RADIO_BOX_H + 2;
    }

    return radiobox;
}
예제 #18
0
rtgui_digtube_t *rtgui_digtube_create(
	struct rtgui_digitfont * digitfont, 
	int count, 
	void * value, 
	int style)
{
	struct rtgui_digtube *digtube;
	rtgui_rect_t rect;

	RT_ASSERT(count <= 7 && count > 0)

	digtube = (struct rtgui_digtube *) rtgui_widget_create(RTGUI_DIGTUBE_TYPE);
	if (digtube == RT_NULL)
		return RT_NULL;

	/* set field */
	if (digitfont == RT_NULL)
		digitfont = &digitfont_40;

	rt_memcpy(& digtube->digitfont, digitfont, sizeof(struct rtgui_digitfont));

#ifndef RTGUI_DIGTUBE_USE_CONST_FONT
	if (digtube->digitfont.data == RT_NULL)
		rtgui_digitfont_create(& digtube->digitfont);
#endif

	/* set default rect */
	rtgui_get_digfont_metrics(&digtube->digitfont, &rect);
	digtube->digit_width = rect.x2;
	digtube->digit_hight = rect.y2;
	digtube->tube_count = count;
	digtube->digit_space = RTGUI_DIGTUBE_DEFAULT_SPACE;

	rect.x2 = (rect.x2 + digtube->digit_space) * count - digtube->digit_space;
	rect.y2 = rect.y2;

	RTGUI_WIDGET_BACKGROUND(digtube) = rtgui_theme_default_bc();
	RTGUI_WIDGET_FOREGROUND(digtube) = RTGUI_DIGTUBE_DEFAULT_FC;
	rtgui_widget_set_rect(RTGUI_WIDGET(digtube), &rect);

	/* set display value */
	digtube->digit_bc = RTGUI_DIGTUBE_DEFAULT_DIGIT_BC;
	digtube->value = value;
	digtube->tube_style = style;
	
	return digtube;
}
예제 #19
0
rtgui_listbox_t* rtgui_listbox_create(const struct rtgui_listbox_item* items, rt_uint16_t count, rtgui_rect_t *rect)
{
	struct rtgui_listbox* box = RT_NULL;

	box = (struct rtgui_listbox*) rtgui_widget_create(RTGUI_LISTBOX_TYPE);
	if (box != RT_NULL)
	{
	    box->items = items;
	    box->items_count = count;

		box->page_items = rtgui_rect_height(*rect) / (2 + rtgui_theme_get_selected_height());
		if (box->page_items == 0) box->page_items = 1;
		rtgui_widget_set_rect(RTGUI_WIDGET(box), rect);
	}

	return box;
}
예제 #20
0
struct rtgui_progressbar* rtgui_progressbar_create(int orientation, int range,
	rtgui_rect_t* r)
{
    struct rtgui_progressbar* bar;

    bar = (struct rtgui_progressbar*) rtgui_widget_create (RTGUI_PROGRESSBAR_TYPE);
    if (bar != RT_NULL)
    {
		if (r != RT_NULL)
			rtgui_widget_set_rect(RTGUI_WIDGET(bar), r);

		bar->orient = orientation;
        bar->range = range;
    }

    return bar;
}
예제 #21
0
struct rtgui_iconbox* rtgui_iconbox_create(struct rtgui_image* image,
	const char* text,
	int position)
{
    struct rtgui_iconbox* iconbox;

	iconbox = (struct rtgui_iconbox*)rtgui_widget_create(RTGUI_ICONBOX_TYPE);
    if (iconbox != RT_NULL)
    {
		rtgui_rect_t rect = {0, 0, 0, 0}, text_rect;

		rect.x2 = image->w;
		rect.y2 = image->h;

		/* get text rect */
		rtgui_font_get_metrics(rtgui_font_default(), text, &text_rect);
		if (position == RTGUI_ICONBOX_TEXT_BELOW)
		{
			rect.y2 += RTGUI_WIDGET_DEFAULT_MARGIN;
			if (text_rect.x2 > rect.x2)
			{
				rect.x2 = text_rect.x2;
			}
			rect.y2 += text_rect.y2;
		}
		else if (position == RTGUI_ICONBOX_TEXT_RIGHT)
		{
			rect.x2 += RTGUI_WIDGET_DEFAULT_MARGIN;
			if (text_rect.y2 > rect.y2)
			{
				rect.y2 = text_rect.y2;
			}
			rect.x2 += text_rect.x2;
		}

		/* set widget rect */
		rtgui_widget_set_rect(RTGUI_WIDGET(iconbox), &rect);

		/* set image and text position */
		iconbox->image = image;
		iconbox->text = (char*)rt_strdup((const char*)text);
		iconbox->text_position = position;
	}

	return iconbox;
}
예제 #22
0
파일: listctrl.c 프로젝트: lyyyuna/rtt_ex
rtgui_listctrl_t* rtgui_listctrl_create(rt_uint32_t items, rt_uint16_t count, rtgui_rect_t *rect, 
										rtgui_onitem_draw_t ondraw)
{
	struct rtgui_listctrl* ctrl = RT_NULL;

	ctrl = (struct rtgui_listctrl*) rtgui_widget_create(RTGUI_LISTCTRL_TYPE);
	if (ctrl != RT_NULL)
	{
	    ctrl->items = items;
	    ctrl->items_count = count;
		ctrl->on_item_draw = ondraw;

		ctrl->page_items = rtgui_rect_height(*rect) / (2 + rtgui_theme_get_selected_height());
		rtgui_widget_set_rect(RTGUI_WIDGET(ctrl), rect);
	}

	return ctrl;
}
예제 #23
0
파일: textbox.c 프로젝트: bbw2008good/RTGUI
struct rtgui_textbox* rtgui_textbox_create(const char* text, rt_uint8_t flag)
{
    struct rtgui_textbox* box;

    box = (struct rtgui_textbox*) rtgui_widget_create (RTGUI_TEXTBOX_TYPE);
    if (box != RT_NULL)
    {
		rtgui_rect_t rect = {0, 0, RTGUI_TEXTBOX_DEFAULT_WIDTH, RTGUI_TEXTBOX_DEFAULT_HEIGHT};

		/* allocate default line buffer */
		rtgui_textbox_set_value(box, text);
		box->flag = flag;

		rtgui_font_get_metrics(RTGUI_WIDGET(box)->gc.font, "h", &rect);
	}

	return box;
}
예제 #24
0
rtgui_filelist_view_t* rtgui_filelist_view_create(const char* directory,
												  const char* pattern,
												  const rtgui_rect_t* rect)
{
	struct rtgui_filelist_view* view = RT_NULL;

	/* create a new view */
	view = (struct rtgui_filelist_view*) rtgui_widget_create(RTGUI_FILELIST_VIEW_TYPE);
	if (view != RT_NULL)
	{
		view->items = RT_NULL;
		view->pattern = rt_strdup(pattern);
		view->page_items = rtgui_rect_height(*rect) / (1 + rtgui_theme_get_selected_height());
		rtgui_filelist_view_set_directory(view, directory);
	}

	return view;
}
rtgui_textview_t* rtgui_textview_create(const char* text, const rtgui_rect_t *rect)
{
    struct rtgui_textview* textview;

    textview = (struct rtgui_textview*) rtgui_widget_create(RTGUI_TEXTVIEW_TYPE);
    if (textview != RT_NULL)
    {
		rtgui_widget_set_rect(RTGUI_WIDGET(textview), rect);

		/* calculate line width and line page count */
		_calc_width(textview);

		/* set text */
		_calc_line(textview, text);
    }

    return textview;
}
예제 #26
0
rtgui_button_t* rtgui_button_create(const char* text)
{
    struct rtgui_button* btn;

    btn = (struct rtgui_button*) rtgui_widget_create (RTGUI_BUTTON_TYPE);
    if (btn != RT_NULL)
    {
		rtgui_rect_t rect;

		/* set default rect */
		rtgui_font_get_metrics(rtgui_font_default(), text, &rect);
		rect.x2 += (RTGUI_BORDER_DEFAULT_WIDTH << 1);
		rect.y2 += (RTGUI_BORDER_DEFAULT_WIDTH << 1);
		rtgui_widget_set_rect(RTGUI_WIDGET(btn), &rect);
		rtgui_label_set_text(RTGUI_LABEL(btn), text);
    }

    return btn;
}
예제 #27
0
struct rtgui_slider* rtgui_slider_create(rt_size_t min, rt_size_t max, int orient)
{
    struct rtgui_slider* slider;

    slider = (struct rtgui_slider*) rtgui_widget_create (RTGUI_SLIDER_TYPE);
    if (slider != RT_NULL)
    {
		/* set proper of control */
		slider->min = min;
		slider->max = max;
		slider->value = min;

		slider->ticks = 10;
		slider->thumb_width = 8;

		rtgui_slider_set_orientation(slider, orient);
	}

	return slider;
}
예제 #28
0
struct rtgui_scrollbar* rtgui_scrollbar_create(int orient, rtgui_rect_t* r)
{
    struct rtgui_scrollbar* bar;

    bar = (struct rtgui_scrollbar*) rtgui_widget_create (RTGUI_SCROLLBAR_TYPE);
    if (bar != RT_NULL)
    {
		if (r != RT_NULL)
		{
			rtgui_widget_set_rect(RTGUI_WIDGET(bar), r);
			if (orient == RTGUI_VERTICAL)
				bar->thumb_size = (r->x2 - r->x1);
			else
				bar->thumb_size = (r->y2 - r->y1);
		}

		bar->orient = orient;
    }

    return bar;
}
예제 #29
0
rtgui_label_t* rtgui_label_create(const char* text)
{
    struct rtgui_label* label;

    label = (struct rtgui_label*) rtgui_widget_create(RTGUI_LABEL_TYPE);
    if (label != RT_NULL)
    {
        rtgui_rect_t rect;

        /* set default rect */
        rtgui_font_get_metrics(rtgui_font_default(), text, &rect);
        rect.x2 += (RTGUI_BORDER_DEFAULT_WIDTH << 1);
        rect.y2 += (RTGUI_BORDER_DEFAULT_WIDTH << 1);
        rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);

        /* set text */
        label->text = (char*)rt_strdup((const char*)text);
    }

    return label;
}
예제 #30
0
rtgui_filelist_view_t *rtgui_filelist_view_create(const char *directory,
                                                  const char *pattern,
                                                  const rtgui_rect_t *rect)
{
    struct rtgui_filelist_view *view = RT_NULL;

    /* create a new view */
    view = (struct rtgui_filelist_view *) rtgui_widget_create(RTGUI_FILELIST_VIEW_TYPE);
    if (view != RT_NULL)
    {
        rtgui_widget_set_rect(RTGUI_WIDGET(view), rect);
        view->items = RT_NULL;
        view->pattern = rt_strdup(pattern);
        view->page_items = rtgui_rect_height(*rect) / (1 + rtgui_theme_get_selected_height());
        /* Avoid divide by 0 error, display at least one item. */
        if (view->page_items == 0)
            view->page_items = 1;
        rtgui_filelist_view_set_directory(view, directory);
    }

    return view;
}