コード例 #1
0
ファイル: apps_list.c プロジェクト: amsl/RTGUI
struct rtgui_panel* apps_list_create(struct rtgui_panel* panel)
{
	struct rtgui_rect rect;

	RT_ASSERT(panel != RT_NULL);

	if (app_default_icon == RT_NULL)
	{
		app_default_icon = rtgui_image_create_from_mem("xpm", (const rt_uint8_t*)exec_xpm, sizeof(exec_xpm), RT_FALSE);
	}
	if (app_close == RT_NULL)
	{
		app_close = rtgui_image_create_from_mem("xpm", (const rt_uint8_t *)close_xpm, sizeof(close_xpm), RT_FALSE);
	}

	rtgui_widget_get_extent(RTGUI_WIDGET(panel), &rect);

	/* create application list */
	rtgui_rect_inflate(&rect, -15);

	app_list = rtgui_listctrl_create(RTGUI_CONTAINER(panel), (rt_uint32_t)app_items, app_count, 15,15,RC_W(rect)-30,RC_H(rect)-30, _app_info_draw);
	rtgui_listctrl_set_itemheight(app_list, app_default_icon->h + 2);
	rtgui_listctrl_set_onitem(app_list, _handle_app_activate);
	rtgui_object_set_event_handler(RTGUI_OBJECT(app_list), apps_listctrl_event_handler);

	//rtgui_container_add_child(RTGUI_CONTAINER(panel), RTGUI_WIDGET(app_list));

	return RTGUI_PANEL(panel);
}
コード例 #2
0
ファイル: button.c プロジェクト: 003900107/realboard-lpc4088
int main(int argc, char** argv)
{
	struct rtgui_app* application;
	struct rtgui_win* win;
    struct rtgui_button *button;

	application = rtgui_app_create("button");
	if (application != RT_NULL)
	{
		rtgui_rect_t rect;

		win = rtgui_mainwin_create(RT_NULL, "button",
			RTGUI_WIN_STYLE_MAINWIN | RTGUI_WIN_STYLE_DESTROY_ON_CLOSE);
        rtgui_widget_get_extent(RTGUI_WIDGET(win), &rect);

		/* create lable in app window */
        button = rtgui_button_create("close");
		rtgui_button_set_onbutton(button, _on_close);
        rect.x2 -= 5; rect.y2 -= 5;
        rect.x1 = rect.x2 - 80; rect.y1 = rect.y2 - 25;
		rtgui_widget_set_rect(RTGUI_WIDGET(button), &rect);
		rtgui_container_add_child(RTGUI_CONTAINER(win), RTGUI_WIDGET(button));

		rtgui_win_show(win, RT_TRUE);
		rtgui_app_destroy(application);
	}

    return 0;
}
コード例 #3
0
int creat_software_ver_not_match_win(struct rtgui_widget* widget)
{
	rtgui_rect_t rect = {60, 45, 260, 160};
	rtgui_label_t *label1;
	rtgui_label_t *label2;
	rtgui_toplevel_t *parent;

	if (RT_NULL != software_version_not_match_win)
		return FAIL;

	parent = RTGUI_TOPLEVEL(rtgui_widget_get_toplevel(widget));

	software_version_not_match_win = rtgui_win_create(parent,
		"致命错误", &rect, RTGUI_WIN_STYLE_MODAL);

	rtgui_widget_get_extent(RTGUI_WIDGET(software_version_not_match_win),&rect);
	rect.x1 += 20;
	rect.x2 -= 20;
	rect.y1 += 20;
	rect.y2 = rect.y1 + 30;
	label1 = rtgui_label_create("接收端与lcd软件版本");
	if (NULL != label1) {
		rtgui_widget_set_rect(RTGUI_WIDGET(label1), &rect);
		rtgui_container_add_child(RTGUI_CONTAINER(software_version_not_match_win), RTGUI_WIDGET(label1));
	}

	rtgui_widget_get_extent(RTGUI_WIDGET(software_version_not_match_win),&rect);
	rect.x1 += 70;
	rect.x2 -= 30;
	rect.y1 += 50;
	rect.y2 = rect.y1 + 30;
	label2 = rtgui_label_create("不匹配!");
	if (NULL != label2) {
		rtgui_widget_set_rect(RTGUI_WIDGET(label2), &rect);
		rtgui_container_add_child(RTGUI_CONTAINER(software_version_not_match_win), RTGUI_WIDGET(label2));
	}

	send_cmd_to_rxe(1, SWITCH2PT);

	rtgui_win_show(software_version_not_match_win, RT_TRUE);

	rtgui_win_destroy(software_version_not_match_win);
	software_version_not_match_win = RT_NULL;

	return SUCC;
}
コード例 #4
0
ファイル: apps_list.c プロジェクト: amsl/RTGUI
static rt_bool_t apps_listctrl_event_handler(struct rtgui_object* object, struct rtgui_event* event)
{
	struct rtgui_listctrl* ctrl;

	ctrl = RTGUI_LISTCTRL(object);
	if (event->type == RTGUI_EVENT_MOUSE_BUTTON)
	{
		struct rtgui_rect rect, close_rect;
		struct rtgui_event_mouse* emouse;

		emouse = (struct rtgui_event_mouse*)event;
		if (emouse->button & RTGUI_MOUSE_BUTTON_UP)
		{
			/* get physical extent information */
			rtgui_widget_get_extent(RTGUI_WIDGET(ctrl), &rect);
			close_rect = rect;
			close_rect.x1 = close_rect.x2 - 50;

			if ((rtgui_rect_contains_point(&close_rect, emouse->x, emouse->y) == RT_EOK) &&
					(ctrl->items_count > 0))
			{
				rt_uint16_t index;
				index = (emouse->y - rect.y1) / (2 + ctrl->item_height);

				if ((index < ctrl->page_items) &&
					(ctrl->current_item/ctrl->page_items)* ctrl->page_items + index < ctrl->items_count)
				{
					rt_uint16_t cur_item;

					/* get current item */
					cur_item = (ctrl->current_item/ctrl->page_items) * ctrl->page_items + index;
					if (cur_item == ctrl->current_item)
					{
						rt_kprintf("close app\n");
						rtgui_app_close(app_items[ctrl->current_item].app);
						return RT_TRUE;
					}
				}
			}
		}
	}

	return rtgui_listctrl_event_handler(object, event);
}
コード例 #5
0
ファイル: listctrl.c プロジェクト: lyyyuna/rtt_ex
rt_bool_t rtgui_listctrl_get_item_rect(rtgui_listctrl_t* ctrl, rt_uint16_t item, rtgui_rect_t* item_rect)
{
	if (item < ctrl->items_count)
	{
		rt_uint16_t index;

		/* check whether this item in current page */
		index = (ctrl->current_item / ctrl->page_items) * ctrl->page_items;
		if (index > item || index + ctrl->page_items <= item) return RT_FALSE;

		rtgui_widget_get_extent(RTGUI_WIDGET(ctrl), item_rect);
		item_rect->y1 -= 2;
		item_rect->y1 += (item % ctrl->page_items) * (2 + rtgui_theme_get_selected_height());
		item_rect->y2 = item_rect->y1 + (2 + rtgui_theme_get_selected_height());
		return RT_TRUE;
	}

	return RT_FALSE;
}
コード例 #6
0
ファイル: program.c プロジェクト: lgnq/mini2440
struct rtgui_panel* program_create(struct rtgui_panel* panel)
{
    int i = 0;
    struct rtgui_rect rect;

    RT_ASSERT(panel != RT_NULL);
    rtgui_widget_get_extent(RTGUI_WIDGET(panel), &rect);

    items = (struct rtgui_list_item *) rtgui_malloc((ITEM_MAX) * sizeof(struct rtgui_list_item));
    for(i=0; i< ITEM_MAX; i++) items[i].action = exec_app;

    /* create application list */
    rtgui_rect_inflate(&rect, -15);

    scan_app_dir(APP_PATH);
    if(pos >= 0) 
    {
        _view = rtgui_list_view_create(items, pos + 1, &rect, RTGUI_LIST_VIEW_ICON);
        rtgui_container_add_child(RTGUI_CONTAINER(panel), RTGUI_WIDGET(_view));
    }        

    return RTGUI_PANEL(panel);
}
コード例 #7
0
ファイル: filelist.c プロジェクト: ADTL/realtouch-stm32f4
void main(void)
{
	struct rtgui_app* application;
	struct rtgui_win* win;	

	application = rtgui_app_create(rt_thread_self(), "filelist");
	if (application != RT_NULL)
	{			
		struct rtgui_rect rect;
	    rtgui_filelist_view_t *view;

		win = rtgui_mainwin_create(RT_NULL, "filelist", 
			RTGUI_WIN_STYLE_MAINWIN | RTGUI_WIN_STYLE_DESTROY_ON_CLOSE);
        
		rtgui_widget_get_extent(RTGUI_WIDGET(win), &rect);

	    view = rtgui_filelist_view_create("/", "*.*", &rect);
        rtgui_container_add_child(RTGUI_CONTAINER(win), RTGUI_WIDGET(view));

		rtgui_win_show(win, RT_TRUE);
		rtgui_app_destroy(application);
	}
}
コード例 #8
0
static void creat_switch2pt_win(rtgui_widget_t* widget)
{
	rtgui_label_t *label;
	rtgui_button_t *cancel_button;
	rtgui_button_t *sure_button;
	rtgui_toplevel_t *parent;
	rtgui_rect_t rect = {60, 45, 260, 160};

	parent = RTGUI_TOPLEVEL(rtgui_widget_get_toplevel(widget));

	switch2pt_confirm_win = rtgui_win_create(parent, "警告", &rect, RTGUI_WIN_STYLE_MODAL);

	rtgui_widget_get_extent(RTGUI_WIDGET(switch2pt_confirm_win), &rect);
	rect.x1 += 30;
	rect.x2 -= 30;
	rect.y1 += 20;
	rect.y2 = rect.y1 + 30;
	label = rtgui_label_create("确定切换到PT侧?");
	if (NULL != label) {
		rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
		rtgui_container_add_child(RTGUI_CONTAINER(switch2pt_confirm_win), RTGUI_WIDGET(label));			
	}

	rtgui_widget_get_extent(RTGUI_WIDGET(switch2pt_confirm_win),&rect);
	rect.x1 += 20;
	rect.x2 -= 120;
	rect.y1 += 70;
	rect.y2 -= 20;
	sure_button = rtgui_button_create("确定");
	if (NULL != sure_button) {
		RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(sure_button)) = RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL;
		rtgui_widget_set_rect(RTGUI_WIDGET(sure_button), &rect);
		rtgui_container_add_child(RTGUI_CONTAINER(switch2pt_confirm_win), RTGUI_WIDGET(sure_button));
		rtgui_button_set_onbutton(sure_button, sure_btn_onbutton);
	} else {
		printf_syn("creat sure button fail\n");
	}
	
	rtgui_widget_get_extent(RTGUI_WIDGET(switch2pt_confirm_win),&rect);
	rect.x1 += 120;
	rect.x2 -= 20;
	rect.y1 += 70;
	rect.y2 -= 20;
	cancel_button = rtgui_button_create("取消");
	if (NULL != cancel_button) {
		RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(cancel_button)) = RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL;
		rtgui_widget_set_rect(RTGUI_WIDGET(cancel_button), &rect);
		rtgui_container_add_child(RTGUI_CONTAINER(switch2pt_confirm_win), RTGUI_WIDGET(cancel_button));
		rtgui_button_set_onbutton(cancel_button, cancel_btn_onbutton);
	} else {
		printf_syn("creat cancel button fail\n");
	}
	
	/* 模态显示窗口 */
	rtgui_win_show(switch2pt_confirm_win, RT_TRUE);

	/* 采用模态显示窗口,关闭时不会自行删除窗口,需要主动删除窗口 */
	rtgui_win_destroy(switch2pt_confirm_win);
	switch2pt_confirm_win = NULL;

	return;
}
コード例 #9
0
ファイル: appmgr.c プロジェクト: aozima/RTGUI
void app_mgr_win_init(void)
{
	struct rtgui_win* win;
	rtgui_rect_t rect;
	struct rtgui_notebook *notebook;
	rtgui_listbox_t* box;
	struct rtgui_image* pressed_image;
	struct rtgui_image* unpressed_image;
	int font_size;
	struct block_panel* block;
	int angle_y;
	
	/* create main window of Application Manager */
	win = rtgui_mainwin_create(RT_NULL, "AppMgr", RTGUI_WIN_STYLE_MAINWIN);
	RTGUI_WIDGET_BACKGROUND(win) = RTGUI_RGB(241, 241, 241);

	/* create icon image */
	pressed_image = rtgui_image_create_from_mem("xpm", (const rt_uint8_t*)home_xpm, sizeof(home_xpm), RT_FALSE);
	unpressed_image = rtgui_image_create_from_mem("xpm", (const rt_uint8_t*)home_gray_xpm, sizeof(home_gray_xpm), RT_FALSE);
	rtgui_font_get_metrics(RTGUI_WIDGET_FONT(win), "AppMgr", &rect);
	font_size = rtgui_rect_height(rect);

	/* create notebook */
	rtgui_widget_get_extent(RTGUI_WIDGET(win), &rect);
	notebook = rtgui_notebook_create(&rect, RTGUI_NOTEBOOK_LEFT);
	RTGUI_WIDGET_BACKGROUND(notebook) = RTGUI_RGB(241, 241, 241);
	rtgui_notebook_set_tab_height(notebook, pressed_image->h + font_size + 3 * RTGUI_WIDGET_DEFAULT_MARGIN);
	rtgui_notebook_set_tab_width(notebook, 65);
	angle_y = rect.x1;

	/* create navigation */
	rtgui_notebook_get_client_rect(notebook, &rect);
	block = block_panel_create(angle_y + notebook->tab_h/2, &rect);
	RTGUI_WIDGET_BACKGROUND(block) = RTGUI_RGB(241, 241, 241);
	rtgui_notebook_add_image(notebook, "AppTask", RTGUI_WIDGET(block),
		pressed_image, unpressed_image);
	apps_list_create(RTGUI_PANEL(block));
	angle_y += notebook->tab_h;

	block = block_panel_create(angle_y + notebook->tab_h/2, &rect);
	RTGUI_WIDGET_BACKGROUND(block) = RTGUI_RGB(241, 241, 241);
	rtgui_notebook_add_image(notebook, "Tab 1", RTGUI_WIDGET(block),
		pressed_image, unpressed_image);
	{
		struct rtgui_rect box_rect;
		block_panel_get_client_extent(block, &box_rect);
		// rtgui_widget_get_extent(RTGUI_WIDGET(block), &box_rect);
		// rtgui_rect_inflate(&box_rect, -15);
		box = rtgui_listbox_create(items, sizeof(items)/sizeof(struct rtgui_listbox_item), &box_rect);
		rtgui_container_add_child(RTGUI_CONTAINER(block), RTGUI_WIDGET(box));
	}
	angle_y += notebook->tab_h;

	block = block_panel_create(angle_y + notebook->tab_h/2, &rect);
	RTGUI_WIDGET_BACKGROUND(block) = RTGUI_RGB(241, 241, 241);
	rtgui_notebook_add_image(notebook, "Tab 2", RTGUI_WIDGET(block), 
		pressed_image, unpressed_image);
	angle_y += notebook->tab_h;

	rtgui_container_add_child(RTGUI_CONTAINER(win), RTGUI_WIDGET(notebook));

	rtgui_win_show(win, RT_FALSE);

	/* set as main window */
	rtgui_app_set_main_win(win);
}