예제 #1
0
/* 触发自动窗口显示 */
static void demo_autowin_onbutton(struct rtgui_object *object, rtgui_event_t *event)
{
    struct rtgui_rect rect = {50, 50, 200, 200};

    /* don't create the window twice */
    if (autowin)
        return;

    autowin = rtgui_win_create(main_win, "Information",
                              &rect, RTGUI_WIN_STYLE_DEFAULT | RTGUI_WIN_STYLE_DESTROY_ON_CLOSE);
    if (autowin == RT_NULL)
        return;

    cnt = 5;
    rt_sprintf(label_text, "closed then %d second!", cnt);
    label = rtgui_label_create(label_text);
    rect.x1 += 5;
    rect.x2 -= 5;
    rect.y1 += 5;
    rect.y2 = rect.y1 + 20;
    rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
    rtgui_container_add_child(RTGUI_CONTAINER(autowin),
                              RTGUI_WIDGET(label));

    /* 设置关闭窗口时的动作 */
    rtgui_win_set_onclose(autowin, auto_window_close);

    rtgui_win_show(autowin, RT_FALSE);
    /* 创建一个定时器 */
    timer = rtgui_timer_create(100, RT_TIMER_FLAG_PERIODIC, diag_close, RT_NULL);
    rtgui_timer_start(timer);
}
예제 #2
0
static void rtgui_filelist_view_menu_pop(rtgui_widget_t *parent)
{
    struct rtgui_win *menu;
    rtgui_rect_t screen, rect = {0, 0, 140, 85};

    rtgui_graphic_driver_get_rect(rtgui_graphic_driver_get_default(), &screen);
    rtgui_rect_moveto_align(&screen, &rect, RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL);

    menu = rtgui_win_create(RTGUI_WIN(rtgui_widget_get_toplevel(parent)),
                            "Folder Menu", &rect, RTGUI_WIN_STYLE_DESTROY_ON_CLOSE);
    if (menu != RT_NULL)
    {
        rtgui_listbox_t *listbox;
        /* Pass the pointer to filelist_view via user_data. */
        menu->user_data = (rt_uint32_t)parent;

        rtgui_win_set_ondeactivate(menu, rtgui_filelist_view_on_menu_deactivate);

        listbox = rtgui_listbox_create(_folder_actions,
                                       sizeof(_folder_actions) / sizeof(_folder_actions[0]),
                                       &rect);
        /* Set the item index *before* setup the callback. `set_current_item`
         * will invoke the "onitem". So just keep it clean when setting the
         * current item. */
        rtgui_listbox_set_current_item(listbox, 0);
        rtgui_listbox_set_onitem(listbox, rtgui_filelist_view_on_folder_item);

        rtgui_container_add_child(RTGUI_CONTAINER(menu), RTGUI_WIDGET(listbox));

        rtgui_win_show(menu, RT_TRUE);
    }
}
예제 #3
0
/* 触发模态窗口显示 */
static void demo_modalwin_onbutton(struct rtgui_object *object, rtgui_event_t *event)
{
    rtgui_win_t *win;
    rtgui_label_t *label;
    rtgui_rect_t rect = {0, 0, 150, 80};

    rtgui_rect_moveto(&rect, delta_x, delta_y);
    delta_x += 20;
    delta_y += 20;

    /* 创建一个窗口 */
    win = rtgui_win_create(main_win,
                           get_win_title(), &rect, RTGUI_WIN_STYLE_DEFAULT);

    rect.x1 += 20;
    rect.x2 -= 5;
    rect.y1 += 5;
    rect.y2 = rect.y1 + 20;

    label = rtgui_label_create("这是一个模式窗口");
    rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
    rtgui_container_add_child(RTGUI_CONTAINER(win), RTGUI_WIDGET(label));

    /* 模态显示窗口 */
    rtgui_win_show(win, RT_TRUE);

    /* 删除非自动删除窗口 */
    rtgui_win_destroy(win);
}
예제 #4
0
/* 触发自动窗口显示 */
static void demo_autowin_onbutton(struct rtgui_widget* widget, rtgui_event_t* event)
{
	rtgui_toplevel_t *parent;
	struct rtgui_rect rect ={50, 50, 200, 200};

	parent = RTGUI_TOPLEVEL(rtgui_widget_get_toplevel(widget));
	msgbox = rtgui_win_create(parent, "Information", &rect, RTGUI_WIN_STYLE_DEFAULT);
	if (msgbox != RT_NULL)
	{
		cnt = 5;
		rt_sprintf(label_text, "closed then %d second!", cnt);
		label = rtgui_label_create(label_text);
		rect.x1 += 5;
		rect.x2 -= 5;
		rect.y1 += 5;
		rect.y2 = rect.y1 + 20;
		rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
		rtgui_container_add_child(RTGUI_CONTAINER(msgbox), RTGUI_WIDGET(label));

		rtgui_win_show(msgbox, RT_FALSE);
	}

	/* 创建一个定时器 */
	timer = rtgui_timer_create(100, RT_TIMER_FLAG_PERIODIC, diag_close, RT_NULL);
	rtgui_timer_start(timer);
}
예제 #5
0
static void rtgui_filelist_view_menu_pop(rtgui_widget_t *parent)
{
	rtgui_win_t *menu;
	rtgui_listbox_t *listbox;
	rtgui_rect_t screen, rect = {0, 0, 140, 85};

	rtgui_graphic_driver_get_rect(rtgui_graphic_driver_get_default(), &screen);
	rtgui_rect_moveto_align(&screen, &rect, RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL);

	menu = rtgui_win_create(RTGUI_WIN(rtgui_widget_get_toplevel(parent)),
							"Folder Menu", &rect, RTGUI_WIN_STYLE_DEFAULT);
	if (menu != RT_NULL)
	{
		/* set user data on menu window */
		menu->user_data = (rt_uint32_t)parent;

		rtgui_win_set_ondeactivate(menu, rtgui_filelist_view_on_menu_deactivate);

		listbox = rtgui_listbox_create(items, sizeof(items)/sizeof(items[0]), &rect);
		rtgui_listbox_set_onitem(listbox, rtgui_filelist_view_on_folder_item);
		rtgui_container_add_child(RTGUI_CONTAINER(menu), RTGUI_WIDGET(listbox));
		rtgui_win_show(menu, RT_FALSE);
		rtgui_widget_focus(RTGUI_WIDGET(listbox));
		rtgui_listbox_set_current_item(listbox, 0);
	}
}
예제 #6
0
파일: win.c 프로젝트: Manish-cimcon/micro
void window_entry(void* parameter)
{
	rt_mq_t mq;
	char name[32];
	rtgui_win_t *win;
	rtgui_rect_t rect = {10, 30, 110, 130};

	mq = rt_mq_create("wmq", 256, 8, RT_IPC_FLAG_FIFO);
	/* 注册当前线程为GUI线程 */
	rtgui_thread_register(rt_thread_self(), mq);

	snprintf(name, sizeof(name), "win %d", (rt_uint32_t)parameter);
	win = rtgui_win_create(RT_NULL, name, &rect, RTGUI_WIN_STYLE_DEFAULT);
	/* 显示窗口 */
	rtgui_win_show(win, RT_FALSE);

	/* 执行窗口的事件循环 */
	rtgui_win_event_loop(win);

	/* 去注册GUI线程 */
	rtgui_thread_deregister(rt_thread_self());

	/* delete message queue */
	rt_mq_delete(mq);
}
예제 #7
0
/* 触发正常窗口显示 */
static void demo_win_onbutton(struct rtgui_widget* widget, rtgui_event_t* event)
{
	rtgui_win_t *win;
	rtgui_label_t *label;
	rtgui_toplevel_t *parent;
	rtgui_rect_t rect = {0, 0, 150, 80};

	parent = RTGUI_TOPLEVEL(rtgui_widget_get_toplevel(widget));
	rtgui_rect_moveto(&rect, delta_x, delta_y);
	delta_x += 20;
	delta_y += 20;

	/* 创建一个窗口 */
	win = rtgui_win_create(parent,
		get_win_title(), &rect, RTGUI_WIN_STYLE_DEFAULT);

	rect.x1 += 20;
	rect.x2 -= 5;
	rect.y1 += 5;
	rect.y2 = rect.y1 + 20;

	/* 添加一个文本标签 */
	label = rtgui_label_create("这是一个普通窗口");
	rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
	rtgui_container_add_child(RTGUI_CONTAINER(win), RTGUI_WIDGET(label));

	/* 非模态显示窗口 */
	rtgui_win_show(win, RT_FALSE);
}
예제 #8
0
/* 列表项的动作函数 */
static void listitem_action(rtgui_widget_t *widget, void *parameter)
{
    char label_text[32];
    rtgui_win_t *win;
    rtgui_label_t *label;
    rtgui_rect_t rect = {0, 0, 150, 80};
    int no = (int)parameter;

    rtgui_rect_moveto(&rect, 20, 50);

    /* 显示消息窗口 */
    win = rtgui_win_create(main_win,
                           "窗口", &rect, RTGUI_WIN_STYLE_DEFAULT);

    rect.x1 += 20;
    rect.x2 -= 5;
    rect.y1 += 5;
    rect.y2 = rect.y1 + 20;

    /* 添加相应的标签 */
    rt_sprintf(label_text, "动作 %d", no);
    label = rtgui_label_create(label_text);

    rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
    rtgui_container_add_child(win, RTGUI_WIDGET(label));

    /* 非模态显示窗口 */
    rtgui_win_show(win, RT_FALSE);
}
예제 #9
0
rt_bool_t show_modal_info(struct rtgui_widget *object, struct rtgui_event *event)
{
	rtgui_label_t *label;
	struct rtgui_win *win;
	rtgui_rect_t rect = {0, 60, 150, 100};
	win = rtgui_win_create(main_win,
						   "Info",
						   &rect,
						   RTGUI_WIN_STYLE_DEFAULT);

	rect.x1 += 20;
	rect.x2 -= 5;
	rect.y1 += 5;
	rect.y2 = rect.y1 + 20;

	label = rtgui_label_create("modal mode info");
	rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
	rtgui_container_add_child(RTGUI_CONTAINER(win), RTGUI_WIDGET(label));

	rtgui_win_show(win, RT_TRUE);

	rtgui_win_destroy(win);

	return RT_TRUE;
}
예제 #10
0
void calibration_entry(void* parameter)
{
    rt_device_t device;
    struct rtgui_rect rect;
    struct setup_items setup;

    device = rt_device_find("touch");
    if (device == RT_NULL) return; /* no this device */

    calibration_ptr = (struct calibration_session*)
        rt_malloc(sizeof(struct calibration_session));
    rt_memset(calibration_ptr, 0, sizeof(struct calibration_data));
    calibration_ptr->device = device;
    
    rt_device_control(calibration_ptr->device, RT_TOUCH_CALIBRATION, 
        (void*)calibration_data_post);
    
    rtgui_graphic_driver_get_rect(rtgui_graphic_driver_get_default(), &rect);
    
    /* set screen rect */
    calibration_ptr->width = rect.x2;
    calibration_ptr->height = rect.y2;

    calibration_ptr->app = rtgui_app_create("calibration");
    if (calibration_ptr->app != RT_NULL)
    {
        /* create calibration window */
        calibration_ptr->win = rtgui_win_create(RT_NULL,
            "calibration", &rect, 
            RTGUI_WIN_STYLE_NO_TITLE | RTGUI_WIN_STYLE_NO_BORDER | 
            RTGUI_WIN_STYLE_ONTOP | RTGUI_WIN_STYLE_DESTROY_ON_CLOSE);
        if (calibration_ptr->win != RT_NULL)
        {   			
            rtgui_object_set_event_handler(RTGUI_OBJECT(calibration_ptr->win),
                calibration_event_handler);
            rtgui_win_show(calibration_ptr->win, RT_TRUE);
        }
        
        rtgui_app_destroy(calibration_ptr->app);
    }

    /* set calibration data */
    rt_device_control(calibration_ptr->device, RT_TOUCH_CALIBRATION_DATA, 
        &calibration_ptr->data);

    //save setup
    setup.touch_min_x = calibration_ptr->data.min_x;
    setup.touch_max_x = calibration_ptr->data.max_x;
    setup.touch_min_y = calibration_ptr->data.min_y;
    setup.touch_max_y = calibration_ptr->data.max_y;
    setup_save(&setup);
    
    /* recover to normal */
    rt_device_control(calibration_ptr->device, RT_TOUCH_NORMAL, RT_NULL);

    /* release memory */
    rt_free(calibration_ptr);
    calibration_ptr = RT_NULL;
}
예제 #11
0
static rt_bool_t rtgui_combobox_onmouse_button(struct rtgui_combobox* box, struct rtgui_event_mouse* event)
{
	struct rtgui_rect rect;

	/* get widget rect */
	rect = RTGUI_WIDGET(box)->extent;

	/* move to the pull down button */
	rect.x1 = rect.x2 - RTGUI_COMBOBOX_BUTTON_WIDTH;
	if (rtgui_rect_contains_point(&rect, event->x, event->y) == RT_EOK)
	{
		/* handle mouse button on pull down button */
		if (event->button & RTGUI_MOUSE_BUTTON_LEFT &&
			event->button & RTGUI_MOUSE_BUTTON_DOWN)
		{
			box->pd_pressed = RT_TRUE;
			rtgui_widget_update(RTGUI_WIDGET(box));
		}
		else if (event->button & RTGUI_MOUSE_BUTTON_LEFT &&
			event->button & RTGUI_MOUSE_BUTTON_UP)
		{
			box->pd_pressed = RT_FALSE;
			rtgui_widget_update(RTGUI_WIDGET(box));

			/* pop pull down window */
			if (box->pd_win == RT_NULL)
			{
				rtgui_listbox_t  *list;

				/* create pull down window */
				rect = RTGUI_WIDGET(box)->extent;
				rect.y1 = rect.y2;
				rect.y2 = rect.y1 + 5 * (2 + rtgui_theme_get_selected_height());
				box->pd_win = rtgui_win_create(RT_NULL, "combo", &rect, RTGUI_WIN_STYLE_NO_TITLE);
				rtgui_win_set_ondeactivate(RTGUI_WIN(box->pd_win), rtgui_combobox_pulldown_hide);
				/* set user data to parent combobox */
				box->pd_win->user_data = (rt_uint32_t)box;

				/* create list box */
				rtgui_rect_inflate(&rect, -1);
				list = rtgui_listbox_create(box->items, box->items_count, &rect);
				rtgui_container_add_child(RTGUI_CONTAINER(box->pd_win), RTGUI_WIDGET(list));
				rtgui_widget_focus(RTGUI_WIDGET(list));

				rtgui_listbox_set_onitem(list, rtgui_combobox_pdwin_onitem);
				rtgui_win_set_ondeactivate(box->pd_win, rtgui_combobox_pdwin_ondeactive);
			}

			/* show combo box pull down window */
			rtgui_win_show(RTGUI_WIN(box->pd_win), RT_FALSE);
		}

		return RT_TRUE;
	}

	return RT_FALSE;
}
예제 #12
0
파일: window.c 프로젝트: zdgaoyu/RTGUI
rtgui_win_t* rtgui_mainwin_create(struct rtgui_win *parent_window, const char* title, rt_uint16_t style)
{
	struct rtgui_rect rect;

	/* get rect of main window */
	rtgui_get_mainwin_rect(&rect);

	return rtgui_win_create(parent_window, title, &rect, style);
}
예제 #13
0
static void app_lcd(void *parameter)
{
    /* create application */
	struct rtgui_app *app;
    struct rtgui_rect rect1 = {0, 0, 240, 320};
    struct rtgui_button* btn;
    struct rtgui_label *lb;

	app = rtgui_app_create("lcd_app");

    if (!app)
    {
        rt_kprintf("Create application \"lcd_app\" failed!\n");
        return;
    }

    /* create main window */
    win_main = rtgui_win_create(RT_NULL, "main",
                    &rect1,
                    RTGUI_WIN_STYLE_NO_BORDER | RTGUI_WIN_STYLE_NO_TITLE);
    if (win_main == RT_NULL)
    {
        rt_kprintf("Create window \"main\" failed!\n");
        rtgui_app_destroy(app);
        return;
    }
    RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(win_main)) = green;

    rect1.x1 = rect1.y1 = 50;
    rect1.x2 -= 50;
    rect1.y2 -= 50;
    lb = rtgui_label_create("I am a transparent label!!!!!!!!!");
    rtgui_widget_set_rect(RTGUI_WIDGET(lb), &rect1);
    RTGUI_WIDGET_FLAG(RTGUI_WIDGET(lb)) |= RTGUI_WIDGET_FLAG_TRANSPARENT;

    rect1.x1 += 20;
    rect1.y1 += 20;
	notebook = rtgui_notebook_create(&rect1, 0);
    /* create lable in main container */
    btn = rtgui_button_create("Here I am.");
    rtgui_notebook_add(notebook, "btn A", RTGUI_WIDGET(btn));
    rtgui_button_set_onbutton(btn, remove_myself);
    btn = rtgui_button_create("There I am.");
    rtgui_notebook_add(notebook, "btn B", RTGUI_WIDGET(btn));

    rtgui_container_add_child(RTGUI_CONTAINER(win_main), RTGUI_WIDGET(lb));
	rtgui_container_add_child(RTGUI_CONTAINER(win_main), RTGUI_WIDGET(notebook));

    rtgui_win_show(win_main, RT_FALSE);

    rtgui_app_run(app);
    rtgui_app_destroy(app);
}
예제 #14
0
void picture_show(void)
{
    /* create application */
    struct rtgui_app *app;
    struct rtgui_rect rect1;
    struct rtgui_win *win_main;
    rtgui_timer_t *timer;
    
    app = rtgui_app_create(rt_thread_self(), "gui_app");
    if (app == RT_NULL)
    {
        rt_kprintf("Create application \"gui_app\" failed!\n");
        return;
    }

    rtgui_graphic_driver_get_rect(rtgui_graphic_driver_get_default(), &rect1);

    /* create main window */
    win_main = rtgui_win_create(RT_NULL, "main",
                    &rect1,
                    RTGUI_WIN_STYLE_NO_BORDER | RTGUI_WIN_STYLE_NO_TITLE);
    if (win_main == RT_NULL)
    {
        rt_kprintf("Create window \"main\" failed!\n");
                rtgui_app_destroy(app);
        return;
    }

    /* create container in main window */
    container = rtgui_container_create();
    if (container == RT_NULL)
    {
        rt_kprintf("Create container failed!\n");
        return;
    }

    rtgui_widget_set_rect(RTGUI_WIDGET(container), &rect1);
    rtgui_object_set_event_handler(RTGUI_OBJECT(container), picture_view_event_handler);
    rtgui_container_add_child(RTGUI_CONTAINER(win_main), RTGUI_WIDGET(container));

    timer = rtgui_timer_create(500, RT_TIMER_FLAG_PERIODIC, timeout, RT_NULL);
    rtgui_timer_start(timer);
    
    rtgui_win_set_onkey(win_main, onkey_handle);
    rtgui_win_show(win_main, RT_FALSE);

    /* show next picture */
    picture_show_next();

    rtgui_app_run(app);
    rtgui_app_destroy(app);
}
예제 #15
0
void app2_entry(void* parameter)
{
    struct rtgui_app* application;
    struct rtgui_win* win;

    application = rtgui_app_create(rt_thread_self(), "ExApp2");
    if (application != RT_NULL)
    {
        rtgui_rect_t rect = {220, 250, 400, 450};
        win = rtgui_win_create(RT_NULL, "Window #2", &rect, RTGUI_WIN_STYLE_DEFAULT);
        rtgui_win_show(win, RT_TRUE);

        rtgui_app_destroy(application);
    }
}
예제 #16
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;
}
예제 #17
0
static void gui_win_entry(void* parameter)
{
	const struct rtgui_graphic_driver* gd = rtgui_graphic_driver_get_default();
	struct rt_messagequeue *mq;
	rtgui_win_t *win;
	rtgui_button_t *button;
	rtgui_point_t p;
	rtgui_rect_t rect = {0,0,200,180};
	rtgui_label_t *label;
	rtgui_font_t *font;
	
	/* 创建GUI应用需要的消息队列 */
	mq = rt_mq_create("demo_win", 256, 32, RT_IPC_FLAG_FIFO);
	/* 注册当前线程 */
	rtgui_thread_register(rt_thread_self(), mq);

	/* 窗口居中 */
	rtgui_rect_moveto(&rect, (gd->width - rtgui_rect_width(rect))/2, (gd->height - rtgui_rect_height(rect))/2);
	/* 创建窗口 */
	win = rtgui_win_create(RT_NULL,"demo_win",&rect,RTGUI_WIN_DEFAULT);
	if(win == RT_NULL) return;
 
	/* 取得客户区坐标零点 */
	p = rtgui_win_get_client_zero(win);
	label = rtgui_label_create(win, "hello world!", p.x+5, p.y+5, 100,25);
	font = rtgui_font_refer("asc", 12);	
	RTGUI_WIDGET_FONT(label) = font;

	button = rtgui_button_create(win, "Exit", (rtgui_rect_width(rect)-50)/2,
								rtgui_rect_height(rect)-40,50,25);
	rtgui_button_set_onbutton(button,rtgui_win_close);

	rtgui_widget_set_event_handler(win, demo_gui_win_event_handler);
	
	rtgui_win_show(win,RT_FALSE);
	
	/* 执行工作台事件循环 */
	rtgui_win_event_loop(win);

	demo_win_inited = RT_FALSE;
	
	/* 去注册GUI线程 */
	rtgui_thread_deregister(rt_thread_self());
	rt_mq_delete(mq);
}
예제 #18
0
/* 触发无标题窗口显示 */
static void demo_ntitlewin_onbutton(struct rtgui_widget* widget, rtgui_event_t* event)
{
	rtgui_win_t *win;
	rtgui_label_t *label;
	rtgui_button_t *button;
	rtgui_toplevel_t *parent;
	rtgui_rect_t widget_rect, rect = {0, 0, 150, 80};

	parent = RTGUI_TOPLEVEL(rtgui_widget_get_toplevel(widget));
	rtgui_rect_moveto(&rect, delta_x, delta_y);
	delta_x += 20;
	delta_y += 20;

	/* 创建一个窗口,风格为无标题及无边框 */
	win = rtgui_win_create(parent,
		"no title", &rect, RTGUI_WIN_STYLE_NO_TITLE | RTGUI_WIN_STYLE_NO_BORDER);
	RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(win)) = white;

	/* 创建一个文本标签 */
	label = rtgui_label_create("无边框窗口");
	rtgui_font_get_metrics(RTGUI_WIDGET_FONT(RTGUI_WIDGET(label)), "无边框窗口", &widget_rect);
	rtgui_rect_moveto_align(&rect, &widget_rect, RTGUI_ALIGN_CENTER_HORIZONTAL);
	widget_rect.y1 += 20;
	widget_rect.y2 += 20;
	rtgui_widget_set_rect(RTGUI_WIDGET(label), &widget_rect);
	rtgui_container_add_child(RTGUI_CONTAINER(win), RTGUI_WIDGET(label));
	RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(label)) = white;

	/* 创建一个关闭按钮 */
	widget_rect.x1 = 0;
	widget_rect.y1 = 0;
	widget_rect.x2 = 40;
	widget_rect.y2 = 20;
	rtgui_rect_moveto_align(&rect, &widget_rect, RTGUI_ALIGN_CENTER_HORIZONTAL);
	widget_rect.y1 += 40;
	widget_rect.y2 += 40;
	button = rtgui_button_create("关闭");
	rtgui_widget_set_rect(RTGUI_WIDGET(button), &widget_rect);
	rtgui_container_add_child(RTGUI_CONTAINER(win), RTGUI_WIDGET(button));
	rtgui_button_set_onbutton(button, window_demo_close);

	/* 非模态显示窗口 */
	rtgui_win_show(win, RT_FALSE);
}
예제 #19
0
파일: application.c 프로젝트: aozima/RTGUI
static void app_lcd(void *parameter)
{
    /* create application */
	struct rtgui_app *app;
    struct rtgui_rect rect1 = {0, 0, 240, 320};
    struct rtgui_win *win_main;
    struct rtgui_button* btn;

	app = rtgui_app_create(rt_thread_self(), "lcd_app");

    if (!app)
    {
        rt_kprintf("Create application \"lcd_app\" failed!\n");
        return;
    }

    /* create main window */
    win_main = rtgui_win_create(RT_NULL, "main",
                    &rect1,
                    RTGUI_WIN_STYLE_NO_BORDER | RTGUI_WIN_STYLE_NO_TITLE);
    if (win_main == RT_NULL)
    {
        rt_kprintf("Create window \"main\" failed!\n");
        rtgui_app_destroy(app);
        return;
    }

	notebook = rtgui_notebook_create(&rect1, 0);

    /* create lable in main container */
    btn = rtgui_button_create("Here I am.");
    rtgui_notebook_add(notebook, "btn A", RTGUI_WIDGET(btn));
    rtgui_button_set_onbutton(btn, remove_myself);
    btn = rtgui_button_create("There I am.");
    rtgui_notebook_add(notebook, "btn B", RTGUI_WIDGET(btn));

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

    rtgui_win_show(win_main, RT_FALSE);

    rtgui_app_run(app);
    rtgui_app_destroy(app);
}
예제 #20
0
void calibration_entry(void* parameter)
{
	rt_mq_t mq;
	rtgui_win_t* win;
	struct rtgui_rect rect;

	mq = rt_mq_create("cali", 40, 8, RT_IPC_FLAG_FIFO);
	if (mq == RT_NULL) return;

	rtgui_thread_register(rt_thread_self(), mq);

	rtgui_graphic_driver_get_rect(rtgui_graphic_driver_get_default(), &rect);

	/* set screen rect */
	calibration_ptr->width = rect.x2;
	calibration_ptr->height = rect.y2;

	/* create calibration window */
	win = rtgui_win_create(RT_NULL,
		"calibration", &rect, RTGUI_WIN_STYLE_NO_TITLE | RTGUI_WIN_STYLE_NO_BORDER);
	rtgui_widget_set_event_handler(RTGUI_WIDGET(win), calibration_event_handler);
	if (win != RT_NULL)
	{
		rtgui_win_show(win, RT_FALSE);
		// rtgui_widget_update(RTGUI_WIDGET(win));
		rtgui_win_event_loop(win);
	}

	rtgui_thread_deregister(rt_thread_self());
	rt_mq_delete(mq);

	/* set calibration data */
	rt_device_control(calibration_ptr->device, RT_TOUCH_CALIBRATION_DATA, &calibration_ptr->data);

	/* recover to normal */
	rt_device_control(calibration_ptr->device, RT_TOUCH_NORMAL, RT_NULL);

	/* release memory */
	rt_free(calibration_ptr);
	calibration_ptr = RT_NULL;
    /* tell other thread that we finished calibration */
    rt_sem_release(touch_screen_calibrated);
}
예제 #21
0
static void create_normal_win(void)
{
    rtgui_rect_t rect = {30, 40, 150, 80};

    normal_window = rtgui_win_create(RT_NULL, "普通窗口",
                                     &rect, RTGUI_WIN_STYLE_DEFAULT);

    rect.x1 += 20;
    rect.x2 -= 5;
    rect.y1 += 5;
    rect.y2 = rect.y1 + 20;

    /* 添加一个文本标签 */
    rt_sprintf(normal_window_label_text,
               "第 %d 次显示", normal_window_show_count);
    normal_window_label = rtgui_label_create(normal_window_label_text);
    rtgui_widget_set_rect(RTGUI_WIDGET(normal_window_label), &rect);
    rtgui_container_add_child(RTGUI_CONTAINER(normal_window),
                              RTGUI_WIDGET(normal_window_label));

    rtgui_win_set_onclose(normal_window,
                          normal_window_onclose);
}
예제 #22
0
rt_bool_t window_focus(void)
{
	rtgui_label_t *label;

	rtgui_button_t* start_btn;
	rtgui_button_t* stop_btn;
    rtgui_win_t *picture_win;
	rtgui_rect_t rect = {0, 20, 240, 320};

	/* 创建一个窗口 */
	main_win = rtgui_win_create(RT_NULL,
			"主窗口",
			&rect,
			RTGUI_WIN_STYLE_DEFAULT | RTGUI_WIN_STYLE_DESTROY_ON_CLOSE);
	/* 获得视图的位置信息 */
	rtgui_widget_get_rect(RTGUI_WIDGET(main_win), &rect);
	rtgui_widget_rect_to_device(RTGUI_WIDGET(main_win), &rect);
	rect.x1 += 10;
	rect.x2 -= 5;
	rect.y2 = rect.y1 + 20;

	/* 创建标题用的标签 */
	label = rtgui_label_create("主窗口");
	/* 设置标签位置信息 */
	rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
	/* 添加标签到视图中 */
	rtgui_container_add_child(RTGUI_CONTAINER(main_win),
			RTGUI_WIDGET(label));

	/* 获得视图的位置信息 */
	rtgui_widget_get_rect(RTGUI_WIDGET(main_win), &rect);
	rtgui_widget_rect_to_device(RTGUI_WIDGET(main_win), &rect);
	rect.x1 += 10;
	rect.y2 -= 10;
	rect.y1 = rect.y2 - 25;
	rect.x2 = rect.x1 + 50;

	/* 创建"启动"按钮 */
	start_btn = rtgui_button_create("按钮1");
	/* 设置按钮的位置信息 */
	rtgui_widget_set_rect(RTGUI_WIDGET(start_btn), &rect);

	rtgui_button_set_onbutton(start_btn, show_modal_info);

	/* 添加按钮到视图中 */
	rtgui_container_add_child(RTGUI_CONTAINER(main_win),
			RTGUI_WIDGET(start_btn));

	/* 添加停止按钮*/
	rtgui_widget_get_rect(RTGUI_WIDGET(main_win), &rect);
	rtgui_widget_rect_to_device(RTGUI_WIDGET(main_win), &rect);
	rect.x2 -= 10;
	rect.y2 -= 10;
	rect.x1 = rect.x2 - 50;
	rect.y1 = rect.y2 - 25;

	/* 创建"停止"按钮 */
	stop_btn = rtgui_button_create("按钮2");
	/* 设置按钮的位置信息 */
	rtgui_widget_set_rect(RTGUI_WIDGET(stop_btn), &rect);

	rtgui_button_set_onbutton(stop_btn, echo_btn_pressed);

	/* 添加按钮到视图中 */
	rtgui_container_add_child(RTGUI_CONTAINER(main_win),
			RTGUI_WIDGET(stop_btn));

	/*创建一个绘图Windows控件*/
	rtgui_widget_get_rect(RTGUI_WIDGET(main_win), &rect);
	rtgui_widget_rect_to_device(RTGUI_WIDGET(main_win), &rect);
	rect.x1 += 10;
	rect.y1 += 20;
	rect.x2 = rect.x1 + 200;
	rect.y2 = rect.y1 + 150;
	picture_win = rtgui_win_create(main_win, "绘图窗口", &rect,
            RTGUI_WIN_STYLE_NO_TITLE|RTGUI_WIN_STYLE_NO_BORDER|RTGUI_WIN_STYLE_NO_FOCUS);
    //创建窗口,没有标题栏,没有最小化窗口,也不能获取焦点
	/* 添加windows的事件*/
	/* all of the windows are managed by topwin. Never set a window as other
	 * window's child.
	 *
	 *rtgui_container_add_child(RTGUI_CONTAINER(main_win),
	 *        RTGUI_WIDGET(picture_win));
     */
	rtgui_object_set_event_handler(RTGUI_OBJECT(picture_win),
			picture_win_onpaint);

	/* 非模态显示窗口 */
	rtgui_widget_focus(RTGUI_WIDGET(main_win));//设定主窗体获取焦点
	rtgui_win_show(main_win, RT_FALSE);
	rtgui_win_show(picture_win,RT_FALSE);

	return RT_TRUE;
}
예제 #23
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;
}
예제 #24
0
static void application_entry(void* parameter)
{
	struct rtgui_application *app;
	struct rtgui_rect rect;

	app = rtgui_application_create(rt_thread_self(), "gui_demo");
	if (app == RT_NULL)
		return;

	/* create a full screen window */
	rtgui_graphic_driver_get_rect(rtgui_graphic_driver_get_default(), &rect);

	main_win = rtgui_win_create(RT_NULL, "demo_win", &rect,
                        RTGUI_WIN_STYLE_NO_BORDER | RTGUI_WIN_STYLE_NO_TITLE);
	if (main_win == RT_NULL)
	{
		rtgui_application_destroy(app);
		return;
	}

	rtgui_win_set_onkey(main_win, demo_handle_key);

	/* create a no title notebook that we can switch demo on it easily. */
	the_notebook = rtgui_notebook_create(&rect, RTGUI_NOTEBOOK_NOTAB);
	if (the_notebook == RT_NULL)
	{
		rtgui_win_destroy(main_win);
		rtgui_application_destroy(app);
		return;
	}

	rtgui_container_add_child(RTGUI_CONTAINER(main_win), RTGUI_WIDGET(the_notebook));

	/* 初始化各个例子的视图 */
	demo_view_benchmark();

	demo_view_dc();
#ifdef RTGUI_USING_TTF
	demo_view_ttf();
#endif

#ifndef RTGUI_USING_SMALL_SIZE
	demo_view_dc_buffer();
#endif
	demo_view_animation();
#ifndef RTGUI_USING_SMALL_SIZE
	demo_view_buffer_animation();
	demo_view_instrument_panel();
#endif
	demo_view_window();
	demo_view_label();
	demo_view_button();
	demo_view_checkbox();
	demo_view_progressbar();
	demo_view_scrollbar();
	demo_view_radiobox();
	demo_view_textbox();
	demo_view_listbox();
	demo_view_menu();
	demo_view_listctrl();
	demo_view_combobox();
	demo_view_slider();
	demo_view_notebook();
	demo_view_mywidget();
#if 0
#if defined(RTGUI_USING_DFS_FILERW) || defined(RTGUI_USING_STDIO_FILERW)
	demo_view_image();
#endif
#ifdef RT_USING_MODULE	
#if defined(RTGUI_USING_DFS_FILERW) || defined(RTGUI_USING_STDIO_FILERW)
	demo_view_module();
#endif
#endif
	demo_listview_view();
	demo_listview_icon_view();
#if defined(RTGUI_USING_DFS_FILERW) || defined(RTGUI_USING_STDIO_FILERW)
	demo_fn_view();
#endif
#endif

	rtgui_win_show(main_win, RT_FALSE);

	/* 执行工作台事件循环 */
	rtgui_application_run(app);

	rtgui_application_destroy(app);
}
예제 #25
0
파일: application.c 프로젝트: aozima/RTGUI
void create_wins(struct rtgui_app *app, void *parameter)
{
	struct rtgui_win *win1, *win2, *win3, *win4;
	struct rtgui_label *label;
	struct rtgui_rect rect;

	if (parameter)
	{
        struct rtgui_win *dsk;
		rtgui_graphic_driver_get_rect(rtgui_graphic_driver_get_default(), &rect);
		dsk = rtgui_win_create(RT_NULL, "desktop", &rect, RTGUI_WIN_STYLE_ONBTM);
		rtgui_win_show(dsk, RT_FALSE);
	}

	rect.x1 = 40, rect.y1 = 40, rect.x2 = 200, rect.y2 = 80;

	win1 = rtgui_win_create(RT_NULL,
		"test window", &rect, RTGUI_WIN_STYLE_DEFAULT);

	rtgui_win_set_onclose(win1, on_window_close);

	rect.x1 += 20;
	rect.x2 -= 5;
	rect.y1 += 5;
	rect.y2 = rect.y1 + 20;

	label = rtgui_label_create("window in modal mode");
	rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
	rtgui_container_add_child(RTGUI_CONTAINER(win1), RTGUI_WIDGET(label));

	rtgui_win_show(win1, RT_TRUE);

	rt_kprintf("win1 terminated\n");
	/*rtgui_win_destroy(win1);*/

	rect.x1 = 20;
	rect.y1 = 80;
	rect.x2 = 180;
	rect.y2 = 90;
	win2 = rtgui_win_create(win1,
		"test window2", &rect, RTGUI_WIN_STYLE_DEFAULT);

	rtgui_win_set_onclose(win2, on_window_close);
	rtgui_win_show(win1, RT_FALSE);
	/*rtgui_win_show(win2, RT_TRUE);*/

	/* create second window tree */
	rect.y1 = 150;
	rect.y2 = rect.y1 + 50;
	win3 = rtgui_win_create(RT_NULL,
		"test tree2", &rect, RTGUI_WIN_STYLE_DEFAULT);

	rtgui_win_set_onclose(win3, on_window_close);

	rect.x1 += 20;
	rect.x2 -= 5;
	rect.y1 += 5;
	rect.y2 = rect.y1 + 20;

	label = rtgui_label_create("window in modal mode");
	rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
	rtgui_container_add_child(RTGUI_CONTAINER(win3), RTGUI_WIDGET(label));

	rect.x1 = 20;
	rect.y1 = 180;
	rect.x2 = 180;
	rect.y2 = 190;
	win4 = rtgui_win_create(win3,
		"test tree2.1", &rect, RTGUI_WIN_STYLE_DEFAULT);

	rtgui_win_set_onclose(win4, on_window_close);
	rtgui_win_show(win3, RT_FALSE);
	/*rtgui_win_show(win4, RT_TRUE);*/

	rtgui_app_run(app);

	rtgui_win_destroy(win1);
	rtgui_win_destroy(win2);
	rtgui_win_destroy(win3);
	rtgui_win_destroy(win4);
}
예제 #26
0
static void calibration_entry(void *parameter)
{
    rt_device_t device;
    struct rtgui_rect rect;

    device = rt_device_find("touch");
    if (device == RT_NULL)
    {
        rt_kprintf("RTGUI: no touch device to calibrate\n");
        return;
    }

    calibration_ptr = (struct calibration_session *)
                      rt_malloc(sizeof(*calibration_ptr));
    rt_memset(calibration_ptr, 0, sizeof(*calibration_ptr));
    calibration_ptr->device = device;

    rt_device_control(calibration_ptr->device, RT_TOUCH_CALIBRATION,
                      (void *)calibration_data_post);

    rtgui_graphic_driver_get_rect(rtgui_graphic_driver_get_default(), &rect);

    /* set screen rect */
    calibration_ptr->width = rect.x2;
    calibration_ptr->height = rect.y2;
    calibration_ptr->app = rtgui_app_create("calibration");
    if (calibration_ptr->app == RT_NULL)
    {
        rt_kprintf("RTGUI: no mem to create calibration app\n");
        goto __free_ptr;
    }
    /* create calibration window */
    calibration_ptr->win = rtgui_win_create(RT_NULL,
                                            "calibration", &rect,
                                            RTGUI_WIN_STYLE_NO_TITLE | RTGUI_WIN_STYLE_NO_BORDER |
                                            RTGUI_WIN_STYLE_ONTOP | RTGUI_WIN_STYLE_DESTROY_ON_CLOSE);
    if (calibration_ptr->win != RT_NULL)
    {
        rtgui_object_set_event_handler(RTGUI_OBJECT(calibration_ptr->win),
                                       calibration_event_handler);
        rtgui_win_show(calibration_ptr->win, RT_TRUE);
    }

    rtgui_app_destroy(calibration_ptr->app);

    /* set calibration data */
    rt_device_control(calibration_ptr->device,
                      RT_TOUCH_CALIBRATION_DATA,
                      RT_NULL);

    if (_cali_after)
        _cali_after(cal_data);

    /* recover to normal */
    rt_device_control(calibration_ptr->device, RT_TOUCH_NORMAL, RT_NULL);

__free_ptr:
    /* release memory */
    rt_free(calibration_ptr);
    calibration_ptr = RT_NULL;
}