Esempio n. 1
0
int rtgui_system_server_init(void)
{
    rt_mutex_init(&_screen_lock, "screen", RT_IPC_FLAG_FIFO);

    /* the graphic device driver must be set before initialization */
    RT_ASSERT(rtgui_graphic_driver_get_default() != RT_NULL);

    /* init image */
    rtgui_system_image_init();
    /* init font */
    rtgui_font_system_init();

    /* set the rect of main window to full screen */
    rtgui_graphic_driver_get_rect(rtgui_graphic_driver_get_default(), &_mainwin_rect);

    /* init rtgui server */
    rtgui_topwin_init();
    rtgui_server_init();

	/* use driver rect for main window */
	rtgui_graphic_driver_get_rect(rtgui_graphic_driver_get_default(), &_mainwin_rect);

    /* init theme */
    rtgui_system_theme_init();
    return 0;
}
Esempio n. 2
0
void load_img_test(char *fname)
{
	struct rtgui_filerw *filerw;
	struct rtgui_image image;
	struct rtgui_rect rect;
	struct rtgui_dc_hw *dc;
	struct rtgui_image_engine *img_eng;

	printf_syn("fun:%s, line:%d, fn:%s\n", __FUNCTION__, __LINE__, fname);

	filerw = rtgui_filerw_create_file(fname, "rb");
	if (NULL == filerw) {
		printf_syn("fun:%s, line:%d, fn:%s\n", __FUNCTION__, __LINE__, fname);
		return;
	}

	img_eng = &rtgui_image_hdc_engine;

	if (RT_TRUE != img_eng->image_check(filerw)) {
		printf_syn("fun:%s, line:%d\n", __FUNCTION__, __LINE__);
		return;
	}

	if (RT_TRUE != img_eng->image_load(&image, filerw, RT_FALSE)) {
		printf_syn("fun:%s, line:%d\n", __FUNCTION__, __LINE__);
		return;
	}

	dc = (struct rtgui_dc_hw*) rtgui_malloc(sizeof(struct rtgui_dc_hw));
	dc->parent.type = RTGUI_DC_HW;
	dc->parent.engine = &dc_hw_engine;
	dc->owner = NULL;
	dc->hw_driver = rtgui_graphic_driver_get_default();

	rect.x1 = 0;
	rect.y1 = 0;
	rect.x2 = rtgui_graphic_driver_get_default()->width;
	rect.y2 = rtgui_graphic_driver_get_default()->height;
	printf_syn("fun:%s, line:%d, 0x%x\n", __FUNCTION__, __LINE__, img_eng->image_blit);
	img_eng->image_blit(&image, (struct rtgui_dc*)dc, &rect);

	rt_thread_delay(get_ticks_of_ms(5000));
	printf_syn("fun:%s, line:%d, fn:%s\n", __FUNCTION__, __LINE__, fname);

	img_eng->image_unload(&image);
	printf_syn("fun:%s, line:%d, fn:%s\n", __FUNCTION__, __LINE__, fname);

	//rect.x1 = rtgui_filerw_close(filerw); /* unload 已close */

	printf_syn("fun:%s, line:%d, ret:%d, fn:%s\n", __FUNCTION__, __LINE__, rect.x1, fname);

	rtgui_free(dc);
	return;
}
Esempio n. 3
0
static void rtgui_textbox_init_caret(rtgui_textbox_t *box, rt_uint16_t position)
{
	int x, y;
	rtgui_color_t color;
	rtgui_rect_t rect;
	int ofs = 0;

	RT_ASSERT(box != RT_NULL);

	if (!RTGUI_WIDGET_IS_FOCUSED(box))
		return;

	rtgui_textbox_get_caret_rect(box, &box->caret_rect, position);
	rect = box->caret_rect;
	rtgui_widget_rect_to_device(RTGUI_WIDGET(box), &rect);

	if (box->caret == RT_NULL)
		box->caret = rtgui_malloc(rtgui_rect_width(rect) * rtgui_rect_height(rect) * sizeof(rtgui_color_t));

	for (x = rect.x1; x < rect.x2; x++)
	{
		for (y = rect.y1; y < rect.y2; y++)
		{
			rtgui_graphic_driver_get_default()->ops->get_pixel(&color, x, y);
			*(box->caret + ofs) = color;
			ofs++;
		}
	}
}
Esempio n. 4
0
int rtgui_system_server_init(void)
{
    rt_mutex_init(&_screen_lock, "screen", RT_IPC_FLAG_FIFO);

    /* init image */
    rtgui_system_image_init();
    /* init font */
    rtgui_font_system_init();

    /* init rtgui server */
    rtgui_topwin_init();
    rtgui_server_init();

    /* use driver rect for main window */
    rtgui_graphic_driver_get_rect(rtgui_graphic_driver_get_default(), &_mainwin_rect);

    /* set the default font */
#if RTGUI_DEFAULT_FONT_SIZE == 16
    rtgui_font_set_defaut(&rtgui_font_asc16);
#elif RTGUI_DEFAULT_FONT_SIZE == 12
    rtgui_font_set_defaut(&rtgui_font_asc12);
#else
    rtgui_font_set_defaut(&rtgui_font_asc12);
#endif

    return 0;
}
Esempio n. 5
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);
    }
}
Esempio n. 6
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);
	}
}
Esempio n. 7
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;
}
Esempio n. 8
0
struct rtgui_dc *rtgui_dc_buffer_create(int w, int h)
{
	rt_uint8_t pixel_format;

	pixel_format = rtgui_graphic_driver_get_default()->pixel_format;

	/* create a dc_buffer with hardware driver pixel format */
	return rtgui_dc_buffer_create_pixformat(pixel_format, w, h);
}
Esempio n. 9
0
File: server.c Progetto: eyeye/RTGUI
void rtgui_server_handle_update(struct rtgui_event_update_end *event)
{
    struct rtgui_graphic_driver *driver;

    driver = rtgui_graphic_driver_get_default();
    if (driver != RT_NULL)
    {
        rtgui_graphic_driver_screen_update(driver, &(event->rect));
    }
}
Esempio n. 10
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);
}
Esempio n. 11
0
static rt_bool_t rtgui_image_hdc_load(struct rtgui_image *image, struct rtgui_filerw *file, rt_bool_t load)
{
    rt_uint32_t header[5];
    struct rtgui_image_hdc *hdc;

    hdc = (struct rtgui_image_hdc *) rtgui_malloc(sizeof(struct rtgui_image_hdc));
    if (hdc == RT_NULL) return RT_FALSE;

    hdc->hw_driver = rtgui_graphic_driver_get_default();
    if (hdc->hw_driver == RT_NULL)
    {
        rtgui_free(hdc);
        return RT_FALSE;
    }

    rtgui_filerw_read(file, (char *)&header, 1, sizeof(header));

    /* set image information */
    image->w = (rt_uint16_t)header[1];
    image->h = (rt_uint16_t)header[2];
    image->engine = &rtgui_image_hdc_engine;
    image->data = hdc;
    hdc->filerw = file;
    hdc->byte_per_pixel = hdc->hw_driver->bits_per_pixel / 8;
    hdc->pitch = image->w * hdc->byte_per_pixel;
    hdc->pixel_offset = rtgui_filerw_tell(file);

    if (load == RT_TRUE)
    {
        /* load all pixels */
        hdc->pixels = rtgui_malloc(image->h * hdc->pitch);
        if (hdc->pixels == RT_NULL)
        {
            /* release data */
            rtgui_free(hdc);
            return RT_FALSE;
        }

        rtgui_filerw_read(hdc->filerw, hdc->pixels, 1, image->h * hdc->pitch);
        rtgui_filerw_close(hdc->filerw);
        hdc->filerw = RT_NULL;
        hdc->pixel_offset = 0;
    }
    else
    {
        hdc->pixels = RT_NULL;
    }

    return RT_TRUE;
}
Esempio n. 12
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);
}
Esempio n. 13
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);
}
Esempio n. 14
0
static void rtgui_image_png_blit(struct rtgui_image *image, struct rtgui_dc *dc, struct rtgui_rect *rect)
{
	int x, y;
    int w, h;
	struct rtgui_blit_info info;
	struct rtgui_graphic_driver *hw_driver = rtgui_graphic_driver_get_default();

    RT_ASSERT(image != RT_NULL && dc != RT_NULL && rect != RT_NULL);
    RT_ASSERT(image->data != RT_NULL);

#define blending(s, d, a) (((unsigned)(((s) - (d)) * (a)) >> 8) + (d))

	/* this dc is not visible */
	if (rtgui_dc_get_visible(dc) != RT_TRUE) return;

	w = _UI_MIN(image->w, rtgui_rect_width(*rect));
	h = _UI_MIN(image->h, rtgui_rect_height(*rect));

	/* border checking */
	if (rect->x1 < 0) { x = -rect->x1; w += rect->x1; }
	else x = 0;

	if (rect->y1 < 0) { y = -rect->y1; h += rect->y1; }
	else y = 0;

	if (w < 0 || h < 0) return; /* no drawing */

	if ((dc->type == RTGUI_DC_CLIENT) || (dc->type == RTGUI_DC_HW && hw_driver->framebuffer == RT_NULL))
	{
		int dx, dy, start_x;
		rtgui_rect_t r;
		rtgui_color_t *pixel;
		rt_uint8_t alpha;
		rtgui_widget_t *owner = RT_NULL;

		if (dc->type == RTGUI_DC_CLIENT)
		{
			/* get owner and calculate dx,dy */
			owner = RTGUI_CONTAINER_OF(dc, struct rtgui_widget, dc_type);
			dx = owner->extent.x1; dy = owner->extent.y1;
		}
Esempio n. 15
0
void picture_show(void* parameter)
{
    /* create application */
    struct rtgui_app *app;
    struct rtgui_rect rect1;
    rtgui_timer_t *timer;
    
    app = rtgui_app_create(rt_thread_self(), "picture");
    if (app == RT_NULL)
    {
        rt_kprintf("Create application \"picture\" failed!\n");
        return;
    }

    rtgui_graphic_driver_get_rect(rtgui_graphic_driver_get_default(), &rect1);

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

    timer = rtgui_timer_create(500, RT_TIMER_FLAG_PERIODIC, timeout, (void*)win);
    rtgui_timer_start(timer);
    
    rtgui_object_set_event_handler(RTGUI_OBJECT(win), picture_view_event_handler);
    rtgui_win_set_onkey(win, onkey_handle);
    rtgui_win_show(win, RT_FALSE);

    /* show next picture */
    picture_show_next(RTGUI_WIDGET(win));

    rtgui_app_run(app);
    rtgui_app_destroy(app);
}
Esempio n. 16
0
/*
 * 构建应用视图
 */
int app_view_structure(struct rtgui_workbench *workbench, struct rtgui_view *view)
{
	int ret = SUCC;
	rtgui_rect_t rect, body_rect;
	rtgui_label_t* label;
	char str[48];
	//rtgui_radiobox_t *radiobox;
	//rtgui_button_t* button;
	struct tm *ptime;
#if 1==DISPLAY_OVERLOAD_INFO
	rtgui_label_t *rx_overload_label;
#endif

	app_view_get_can_use_rect(view, &rect);
	zvd_gui_debug(("fun:%s(), line:%d, (%d,%d) (%d,%d)!\n", __FUNCTION__, __LINE__,
				   rect.x1, rect.y1, rect.x2, rect.y2));

	body_rect.x1 = 0;
	body_rect.y1 = 0;
	body_rect.x2 = rect.x2;
	body_rect.y2 = TITLE_PANEL_HEIGHT;
	label = rtgui_label_create(DEVICE_NAME);
	if (NULL != label) {
		RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(label)) = RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL;
		RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(label)) = blue;
		rtgui_widget_set_rect(RTGUI_WIDGET(label), &body_rect);
		/* view是一个container控件,调用add_child方法添加这个label控件 */
		rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label));
	} else {
		printf_syn("creat title label fail\n");
	}

	body_rect.x1 = 0;
	body_rect.y1 = TITLE_PANEL_HEIGHT;
	body_rect.x2 = rect.x2;
	body_rect.y2 = rect.y2;
	zvd_gui_debug(("fun:%s(), line:%d, (%d,%d) (%d,%d)!\n", __FUNCTION__, __LINE__,
				   body_rect.x1, body_rect.y1, body_rect.x2, body_rect.y2));

	zvd_notebook = rtgui_notebook_create(&body_rect, RTGUI_NOTEBOOK_TOP);
	rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(zvd_notebook));

	re_form = rtgui_form_create(re_form_head, RE_FORM_ROWS, RE_FORM_COLS, &body_rect);
	rtgui_notebook_add(zvd_notebook, "接收端", RTGUI_WIDGET(re_form));
#if 1
	set_form_px_col(re_form);
	i2str(str, avg_val[AVI_RE_PA]);
	rtgui_form_set_item(re_form, str, RE_PA_AVG_VALUE_ROW, RE_PA_AVG_VALUE_COL, 0);
	rtgui_form_set_item(re_form, print_info_str[PIS_ID_ZHENGCHANG], RE_PA_OVER_RANGE_ROW, RE_PA_OVER_RANGE_COL, 0);

	i2str(str, avg_val[AVI_RE_PB]);
	rtgui_form_set_item(re_form, str, RE_PB_AVG_VALUE_ROW, RE_PB_AVG_VALUE_COL, 0);
	rtgui_form_set_item(re_form, print_info_str[PIS_ID_ZHENGCHANG], RE_PB_OVER_RANGE_ROW, RE_PB_OVER_RANGE_COL, 0);

	i2str(str, avg_val[AVI_RE_PC]);
	rtgui_form_set_item(re_form, str, RE_PC_AVG_VALUE_ROW, RE_PC_AVG_VALUE_COL, 0);
	rtgui_form_set_item(re_form, print_info_str[PIS_ID_ZHENGCHANG], RE_PC_OVER_RANGE_ROW, RE_PC_OVER_RANGE_COL, 0);
#endif

	se_form = rtgui_form_create(se_form_head, SE_FORM_ROWS, SE_FORM_COLS, &body_rect);
	rtgui_notebook_add(zvd_notebook, "发射端", RTGUI_WIDGET(se_form));
#if 1
	set_form_px_col(se_form);
	rtgui_form_set_item(se_form, print_info_str[PIS_ID_ZHENGCHANG], SE_PA_OVER_RANGE_ROW, SE_PA_OVER_RANGE_COL, 0);
	rtgui_form_set_item(se_form, print_info_str[PIS_ID_FOU], SE_PA_POWER_DOWN_ROW, SE_PA_POWER_DOWN_COL, 0);

	rtgui_form_set_item(se_form, print_info_str[PIS_ID_ZHENGCHANG], SE_PB_OVER_RANGE_ROW, SE_PB_OVER_RANGE_COL, 0);
	rtgui_form_set_item(se_form, print_info_str[PIS_ID_FOU], SE_PB_POWER_DOWN_ROW, SE_PB_POWER_DOWN_COL, 0);

	rtgui_form_set_item(se_form, print_info_str[PIS_ID_ZHENGCHANG], SE_PC_OVER_RANGE_ROW, SE_PC_OVER_RANGE_COL, 0);
	rtgui_form_set_item(se_form, print_info_str[PIS_ID_FOU], SE_PC_POWER_DOWN_ROW, SE_PC_POWER_DOWN_COL, 0);
#endif

	sys_form = rtgui_form_create(sys_form_head, SYS_FORM_ROWS, SYS_FORM_COLS, &body_rect);
	rtgui_notebook_add(zvd_notebook, "系统", RTGUI_WIDGET(sys_form));
#if 1
	rtgui_form_set_item(sys_form, "接收端", 1, 0, 0);
	i2str(str, sys_temper[STI_RE_CPU_T]);
	rtgui_form_set_item(sys_form, str, 		RE_RE_CPU_TEMP_ROW, RE_RE_CPU_TEMP_COL, 0);
	i2str(str, sys_temper[STI_RE_CTB_T]);
	rtgui_form_set_item(sys_form, str, 		RE_RE_BOX_TEMP_ROW, RE_RE_BOX_TEMP_COL, 0);
	convert_ver2str(re_version, str);
	rtgui_form_set_item(sys_form, str, 	RE_RE_SOFT_VER_ROW, RE_RE_SOFT_VER_COL, 0);

	rtgui_form_set_item(sys_form, "发射端", 2, 0, 0);
	i2str(str, sys_temper[STI_SE_CPU_T]);
	rtgui_form_set_item(sys_form, str, 		RE_SE_CPU_TEMP_ROW, RE_SE_CPU_TEMP_COL, 0);
	i2str(str, sys_temper[STI_SE_CTB_T]);
	rtgui_form_set_item(sys_form, str, 		RE_SE_BOX_TEMP_ROW, RE_SE_BOX_TEMP_COL, 0);
	convert_ver2str(se_version, str);
	rtgui_form_set_item(sys_form, str, 	RE_SE_SOFT_VER_ROW, RE_SE_SOFT_VER_COL, 0);

	creat_devsn(str, sizeof(str), 0);
	rtgui_form_set_row(sys_form, str, TE_SN_ROW);

	creat_devsn(str, sizeof(str), 1);
	rtgui_form_set_row(sys_form, str, RE_SN_ROW);
#endif


	other_form = rtgui_form_create(other_form_head, OTHER_FORM_ROWS, OTHER_FORM_COLS, &body_rect);
	rtgui_notebook_add(zvd_notebook, "掉电", RTGUI_WIDGET(other_form));
#if 1
	rtgui_form_set_item(other_form, "次数", 1, 0, 0);
	rtgui_form_set_item(other_form, "n", 2, 0, 0);
	rtgui_form_set_item(other_form, "n-1", 3, 0, 0);
	rtgui_form_set_item(other_form, "n-2", 4, 0, 0);
	update_tx_poweroff_info_of_otherform();
	update_rx_poweroff_info_of_otherform();
#endif

	body_rect.x1 = FRAME_GAP;
	body_rect.y1 = body_rect.y2 + WIDGET_ROW_GAP;
	body_rect.x2 = FRAME_GAP + 8 * rt_strlen(RE_IF_SWITCH2CABLE_STR);
	body_rect.y2 = body_rect.y1 + 16;
	zvd_gui_debug(("fun:%s(), line:%d, (%d,%d) (%d,%d)!\n", __FUNCTION__, __LINE__,
				   body_rect.x1, body_rect.y1, body_rect.x2, body_rect.y2));

	switch_cable_label = rtgui_label_create(RE_IF_SWITCH2CABLE_STR);
	if (NULL != switch_cable_label) {
		RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(switch_cable_label)) =  RTGUI_ALIGN_CENTER_VERTICAL;
		//RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(switch_cable_label)) = blue;
		rtgui_widget_set_rect(RTGUI_WIDGET(switch_cable_label), &body_rect);
		/* view是一个container控件,调用add_child方法添加这个label控件 */
		rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(switch_cable_label));
	} else {
		printf_syn("creat cable label fail\n");
	}

#if 1
	body_rect.x1 = body_rect.x2 + 2;
	body_rect.x2 = body_rect.x1 + 16 + 8;
	zvd_gui_debug(("fun:%s(), line:%d, (%d,%d) (%d,%d)!\n", __FUNCTION__, __LINE__,
				   body_rect.x1, body_rect.y1, body_rect.x2, body_rect.y2));

	switch_cable_yn_textview = rtgui_textview_create(print_info_str[PIS_ID_FOU], &body_rect);
	if (NULL != switch_cable_yn_textview) {
		RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(switch_cable_yn_textview)) = RTGUI_ALIGN_CENTER_HORIZONTAL
				| RTGUI_ALIGN_CENTER_VERTICAL;
		//RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(switch_cable_yn_textview)) = red;
		rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(switch_cable_yn_textview));
	} else {
		printf_syn("creat cable yn textview fail\n");
	}
#endif

#if 1
	body_rect.x1 = body_rect.x2 + 2 + 2*8;
	body_rect.x2 = body_rect.x1 + 8*rt_strlen(TE_HAD_POWEROFF_STR);
	zvd_gui_debug(("fun:%s(), line:%d, (%d,%d) (%d,%d)!\n", __FUNCTION__, __LINE__,
				   body_rect.x1, body_rect.y1, body_rect.x2, body_rect.y2));

	tx_poweroff_label = rtgui_label_create(TE_HAD_POWEROFF_STR);
	if (NULL != tx_poweroff_label) {
		RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(tx_poweroff_label)) =  RTGUI_ALIGN_CENTER_VERTICAL;
		rtgui_widget_set_rect(RTGUI_WIDGET(tx_poweroff_label), &body_rect);
		rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(tx_poweroff_label));
	} else {
		printf_syn("tx poweroff label fail\n");
	}

	body_rect.x1 = body_rect.x2 + 2;
	body_rect.x2 = body_rect.x1 + 16 + 8;
	zvd_gui_debug(("fun:%s(), line:%d, (%d,%d) (%d,%d)!\n", __FUNCTION__, __LINE__,
				   body_rect.x1, body_rect.y1, body_rect.x2, body_rect.y2));

	tx_poweroff_yn_textview = rtgui_textview_create(print_info_str[PIS_ID_FOU], &body_rect);
	if (NULL != tx_poweroff_yn_textview) {
		RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(tx_poweroff_yn_textview)) = RTGUI_ALIGN_CENTER_HORIZONTAL
				| RTGUI_ALIGN_CENTER_VERTICAL;
		rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(tx_poweroff_yn_textview));
	} else {
		printf_syn("creat cable yn textview fail\n");
	}
#endif


#if 1
	body_rect.x1 = FRAME_GAP;
	body_rect.y1 = body_rect.y2 + WIDGET_ROW_GAP;
	body_rect.x2 = FRAME_GAP + (8+1) * rt_strlen(RE_BUZZER_DISABLE_STR);
	body_rect.y2 = body_rect.y1 + 16 + 2*WIDGET_ROW_GAP;
	zvd_gui_debug(("fun:%s(), line:%d, (%d,%d) (%d,%d)!\n", __FUNCTION__, __LINE__,
				   body_rect.x1, body_rect.y1, body_rect.x2, body_rect.y2));

	buzzer_button = rtgui_pushbutton_create(RE_BUZZER_DISABLE_STR);
	if (NULL != buzzer_button) {
		RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(buzzer_button)) = RTGUI_ALIGN_CENTER_HORIZONTAL
				| RTGUI_ALIGN_CENTER_VERTICAL;
		//RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(buzzer_button)) = blue;
		rtgui_widget_set_rect(RTGUI_WIDGET(buzzer_button), &body_rect);
		rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(buzzer_button));

		rtgui_button_set_onbutton(buzzer_button, buzzer_btn_onbutton);
	} else {
		printf_syn("creat buzzer pushbutton fail\n");
	}

	body_rect.x1 = body_rect.x2 + FRAME_GAP;
	/* body_rect.y1 = body_rect.y1; */ /* 与前一个按钮在同一行, 所以, y1, y2保持不变 */
	body_rect.x2 = body_rect.x1 + (8+1) * rt_strlen(SWITCH_TO_PT_STR);;
	/* body_rect.y2 = body_rect.y2; */ /* 与前一个按钮在同一行, 所以, y1, y2保持不变 */
	
	switch2pt_button = rtgui_pushbutton_create(SWITCH_TO_PT_STR);
	if (NULL != switch2pt_button) {
		RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(switch2pt_button)) = RTGUI_ALIGN_CENTER_HORIZONTAL
				| RTGUI_ALIGN_CENTER_VERTICAL;
		//RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(switch2pt_button)) = blue;
		rtgui_widget_set_rect(RTGUI_WIDGET(switch2pt_button), &body_rect);
		rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(switch2pt_button));
		rtgui_button_set_onbutton(switch2pt_button, switch2pt_btn_onbutton);
	} else {
		printf_syn("creat switch button fail\n");
	}

#if USE_OPTICX_200S_VERSION
	body_rect.x1 = body_rect.x2 + FRAME_GAP;
	/* body_rect.y1 = body_rect.y1; */ /* 与前一个按钮在同一行, 所以, y1, y2保持不变 */
	body_rect.x2 = body_rect.x1 + (8) * rt_strlen(RE_CUR_CHANNEL_NO_STR) + 2;
	/* body_rect.y2 = body_rect.y2; */ /* 与前一个按钮在同一行, 所以, y1, y2保持不变 */
	zvd_gui_debug(("fun:%s(), line:%d, (%d,%d) (%d,%d)!\n", __FUNCTION__, __LINE__,
				   body_rect.x1, body_rect.y1, body_rect.x2, body_rect.y2));
	rxe_cur_channel_label = rtgui_label_create(RE_CUR_CHANNEL_NO_STR);
	if (NULL != rxe_cur_channel_label) {
		RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(rxe_cur_channel_label)) =  RTGUI_ALIGN_CENTER_VERTICAL;
		rtgui_widget_set_rect(RTGUI_WIDGET(rxe_cur_channel_label), &body_rect);
		rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(rxe_cur_channel_label));
	} else {
		printf_syn("rxe cru channel label fail\n");
	}

	body_rect.x1 = body_rect.x2 + 2;
	body_rect.x2 = body_rect.x1 + 8 + 8;
	zvd_gui_debug(("fun:%s(), line:%d, (%d,%d) (%d,%d)!\n", __FUNCTION__, __LINE__,
				   body_rect.x1, body_rect.y1, body_rect.x2, body_rect.y2));
	str[0] = convert_cur_channel_to_char();
	str[1] = '\0';
	rxe_cur_channel_no_textview = rtgui_textview_create(str, &body_rect);
	if (NULL != rxe_cur_channel_no_textview) {
		RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(rxe_cur_channel_no_textview)) = RTGUI_ALIGN_CENTER_HORIZONTAL
				| RTGUI_ALIGN_CENTER_VERTICAL;
		rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(rxe_cur_channel_no_textview));
	} else {
		printf_syn("creat cable yn textview fail\n");
	}
#endif
#endif

#if 1==DISPLAY_OVERLOAD_INFO
	body_rect.x1 = body_rect.x2 + 2 + 7*8;
	body_rect.x2 = body_rect.x1 + 8*rt_strlen(RE_OVERLOAD_CNT_STR);
	zvd_gui_debug(("fun:%s(), line:%d, (%d,%d) (%d,%d)!\n", __FUNCTION__, __LINE__,
				   body_rect.x1, body_rect.y1, body_rect.x2, body_rect.y2));

	rx_overload_label = rtgui_label_create(RE_OVERLOAD_CNT_STR);
	if (NULL != rx_overload_label) {
		RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(rx_overload_label)) =  RTGUI_ALIGN_CENTER_VERTICAL;
		rtgui_widget_set_rect(RTGUI_WIDGET(rx_overload_label), &body_rect);
		rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(rx_overload_label));
	} else {
		printf_syn("tx poweroff label fail\n");
	}

	body_rect.x1 = body_rect.x2 + 2;
	body_rect.x2 = body_rect.x1 + 16 + 8;
	zvd_gui_debug(("fun:%s(), line:%d, (%d,%d) (%d,%d)!\n", __FUNCTION__, __LINE__,
				   body_rect.x1, body_rect.y1, body_rect.x2, body_rect.y2));

	rx_overload_cnt_textview = rtgui_textview_create("0", &body_rect);
	if (NULL != rx_overload_cnt_textview) {
		RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(rx_overload_cnt_textview)) = RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL;
		rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(rx_overload_cnt_textview));
	} else {
		printf_syn("creat cable yn textview fail\n");
	}
#endif



#if 1
	/* 创建时间标签, 2013-03-18 09:20 */
	rtc_dev = rt_device_find("rtc");
	if (NULL != rtc_dev) {
		time_t time;
		rt_device_control(rtc_dev, RT_DEVICE_CTRL_RTC_GET_TIME, &time);
		ptime = localtime(&time);
		rt_sprintf(sys_time_str, "%4d-%02d-%02d %02d:%02d:%02d", (ptime->tm_year+1900), (ptime->tm_mon+1),
				   ptime->tm_mday,	ptime->tm_hour, ptime->tm_min, ptime->tm_sec);

		body_rect.x2 = rtgui_graphic_driver_get_default()->width;
		body_rect.y2 = rtgui_graphic_driver_get_default()->height;
		body_rect.x1 = body_rect.x2 - (8+1) * 19;
		body_rect.y1 = body_rect.y2 - 20;
#if SYS_TIME_USE_TEXTBOX
		sys_time_textbox = rtgui_textbox_create(sys_time_str, RTGUI_TEXTBOX_SINGLE | RTGUI_TEXTBOX_CARET_HIDE);
		if (NULL != sys_time_textbox) {
			RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(sys_time_textbox)) = RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL;
			//RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(sys_time_textbox)) = blue;
			RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(sys_time_textbox)) = blue; //default_background;
			//RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(view));
			rtgui_widget_set_rect(RTGUI_WIDGET(sys_time_textbox), &body_rect);
			rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(sys_time_textbox));

		} else {
			printf_syn("creat sys time textbox fail\n");
		}
#else
		sys_time_textview = rtgui_textview_create(sys_time_str, &body_rect);
		if (NULL != sys_time_textview) {
			RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(sys_time_textview)) = RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL;
			//RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(sys_time_textbox)) = blue;
			rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(sys_time_textview));
		} else {
			printf_syn("creat sys time textview fail\n");
		}
#endif

	} else {
		printf_syn("find rtc device fail\n");
	}

#endif
	rtgui_view_show(view, RT_FALSE); /* 显示视图 */

	return ret;
}
Esempio n. 17
0
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);
}
Esempio n. 18
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);
}
Esempio n. 19
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;
}
Esempio n. 20
0
/* blit a dc to another dc */
static void rtgui_dc_buffer_blit(struct rtgui_dc *self,
                                 struct rtgui_point *dc_pt,
                                 struct rtgui_dc *dest,
                                 rtgui_rect_t *rect)
{
    int pitch;
    rt_uint16_t rect_width, rect_height;
    struct rtgui_rect _rect, *dest_rect;
    struct rtgui_point dc_point;
    struct rtgui_dc_buffer *dc = (struct rtgui_dc_buffer *)self;

    if (rtgui_dc_get_visible(dest) == RT_FALSE)
        return;

    /* use the (0,0) origin point */
    if (dc_pt == RT_NULL)
        dc_point = rtgui_empty_point;
    else
    {
        dc_point = *dc_pt;
    }

    rtgui_dc_get_rect(dest, &_rect);
    /* use the rect of dest dc */
    if (rect == RT_NULL)
    {
        dest_rect = &_rect;
    }
    else
    {
        dest_rect = rect;
        if (dest_rect->x1 >= _rect.x2 || dest_rect->y1 >= _rect.y2)
            return;
        if (dest_rect->x1 < 0)
        {
            if (-dest_rect->x1 >= dc->width)
                return;
            dc_point.x += -dest_rect->x1;
            dest_rect->x1 = 0;
        }
        if (dest_rect->y1 < 0)
        {
            if (-dest_rect->y1 >= dc->height)
                return;
            dc_point.y += -dest_rect->y1;
            dest_rect->y1 = 0;
        }
        if (dest_rect->x2 > _rect.x2)
            dest_rect->x2 = _rect.x2;
        if (dest_rect->y2 > _rect.y2)
            dest_rect->y2 = _rect.y2;
    }

    if (dest_rect->x2 < dest_rect->x1 || dest_rect->y2 < dest_rect->y1) return;
    if (dc_point.x >= dc->width || dc_point.y >= dc->height) return;

    /* get the minimal width and height */
    rect_width  = _UI_MIN(rtgui_rect_width(*dest_rect), dc->width - dc_point.x);
    rect_height = _UI_MIN(rtgui_rect_height(*dest_rect), dc->height - dc_point.y);

    if ((dest->type == RTGUI_DC_HW) || (dest->type == RTGUI_DC_CLIENT))
    {
        int index;
        rt_uint8_t *line_ptr, *pixels;
        rtgui_blit_line_func blit_line;
        struct rtgui_graphic_driver *hw_driver;

        hw_driver = rtgui_graphic_driver_get_default();
        /* prepare pixel line */
        pixels = _dc_get_pixel(dc, dc_point.x, dc_point.y);

        if (dest->type == RTGUI_DC_HW && hw_driver->framebuffer != RT_NULL)
        {
            /* use rtgui_blit */

            struct rtgui_blit_info info = { 0 };
            struct rtgui_widget *owner;

            if (self->type == RTGUI_DC_BUFFER)
                info.a = dc->pixel_alpha;
            else
                info.a = 255;

            /* blit source */
            info.src = _dc_get_pixel(dc, dc_point.x, dc_point.y);
            info.src_fmt = dc->pixel_format;
            info.src_h = rect_height;
            info.src_w = rect_width;
            info.src_pitch = dc->pitch;
            info.src_skip = info.src_pitch - info.src_w * rtgui_color_get_bpp(dc->pixel_format);

            owner = ((struct rtgui_dc_hw*)dest)->owner;

            /* blit destination */
            info.dst = (rt_uint8_t*)hw_driver->framebuffer;
            info.dst = info.dst + (owner->extent.y1 + dest_rect->y1) * hw_driver->pitch +
                       (owner->extent.x1 + dest_rect->x1) * rtgui_color_get_bpp(hw_driver->pixel_format);
            info.dst_fmt = hw_driver->pixel_format;
            info.dst_h = rect_height;
            info.dst_w = rect_width;
            info.dst_pitch = hw_driver->pitch;
            info.dst_skip = info.dst_pitch - info.dst_w * rtgui_color_get_bpp(hw_driver->pixel_format);

            rtgui_blit(&info);
        }
        else if (dest->type == RTGUI_DC_CLIENT&& hw_driver->framebuffer != RT_NULL)
        {
            /* use rtgui_blit */
            rt_uint8_t bpp, hw_bpp;
            struct rtgui_blit_info info = { 0 };
            struct rtgui_widget *owner;
            struct rtgui_region dest_region;
            struct rtgui_rect dest_extent;
            int num_rects;
            struct rtgui_rect *rects;

            /* get owner */
            owner = RTGUI_CONTAINER_OF(dest, struct rtgui_widget, dc_type);

            dest_extent = *dest_rect;
            rtgui_widget_rect_to_device(owner, &dest_extent);

            rtgui_region_init_with_extents(&dest_region, &dest_extent);
            rtgui_region_intersect_rect(&dest_region, &(owner->clip), &dest_extent);
            bpp = rtgui_color_get_bpp(dc->pixel_format);
            hw_bpp = rtgui_color_get_bpp(hw_driver->pixel_format);

            num_rects = rtgui_region_num_rects(&dest_region);
            rects = rtgui_region_rects(&dest_region);

            /* common info */
            if (self->type == RTGUI_DC_BUFFER)
                info.a = dc->pixel_alpha;
            else
                info.a = 255;
            info.src_fmt = dc->pixel_format;
            info.src_pitch = dc->pitch;

            info.dst_fmt = hw_driver->pixel_format;
            info.dst_pitch = hw_driver->pitch;

            for (index = 0; index < num_rects; index ++)
            {
                struct rtgui_rect *r = &rects[index];

                /* blit source */
                info.src = _dc_get_pixel(dc, dc_point.x + (r->x1 - dest_extent.x1),
                                         dc_point.y + (r->y1 - dest_extent.y1));
                info.src_h = rtgui_rect_height(*r);
                info.src_w = rtgui_rect_width(*r);
                info.src_skip = info.src_pitch - info.src_w * bpp;

                /* blit destination */
                info.dst = (rt_uint8_t*)hw_driver->framebuffer + r->y1 * hw_driver->pitch +
                           r->x1 * hw_bpp;
                info.dst_h = rtgui_rect_height(*r);
                info.dst_w = rtgui_rect_width(*r);
                info.dst_skip = info.dst_pitch - info.dst_w * hw_bpp;

                rtgui_blit(&info);
            }

            rtgui_region_fini(&dest_region);
        }
Esempio n. 21
0
/* blit a dc to another dc */
static void rtgui_dc_buffer_blit(struct rtgui_dc *self, struct rtgui_point *dc_pt, struct rtgui_dc *dest, rtgui_rect_t *rect)
{
	int pitch;
	rt_uint16_t rect_width, rect_height;
	struct rtgui_rect _rect, *dest_rect;
    struct rtgui_point dc_point;
    struct rtgui_dc_buffer *dc = (struct rtgui_dc_buffer *)self;

    if (rtgui_dc_get_visible(dest) == RT_FALSE)
        return;

	/* use the (0,0) origin point */
    if (dc_pt == RT_NULL)
        dc_point = rtgui_empty_point;
    else
    {
        dc_point = *dc_pt;
    }

    rtgui_dc_get_rect(dest, &_rect);
	/* use the rect of dest dc */
	if (rect == RT_NULL)
	{
		dest_rect = &_rect;
	}
	else
    {
        dest_rect = rect;
        if (dest_rect->x1 > _rect.x2 || dest_rect->y1 > _rect.y2)
            return;
        if (dest_rect->x1 < 0)
        {
            if (-dest_rect->x1 > dc->width)
                return;
            dc_point.x += -dest_rect->x1;
            dest_rect->x1 = 0;
        }
        if (dest_rect->y1 < 0)
        {
            if (-dest_rect->y1 > dc->height)
                return;
            dc_point.y += -dest_rect->y1;
            dest_rect->y1 = 0;
        }
        if (dest_rect->x2 > _rect.x2)
            dest_rect->x2 = _rect.x2;
        if (dest_rect->y2 > _rect.y2)
            dest_rect->y2 = _rect.y2;
    }

    if (dc_point.x > dc->width || dc_point.y > dc->height)
        return;

	/* get the minimal width and height */
	rect_width  = _UI_MIN(rtgui_rect_width(*dest_rect), dc->width - dc_point.x);
	rect_height = _UI_MIN(rtgui_rect_height(*dest_rect), dc->height - dc_point.y);

    if ((dest->type == RTGUI_DC_HW) || (dest->type == RTGUI_DC_CLIENT))
    {
		int index;
        rt_uint8_t *line_ptr, *pixels;
        rtgui_blit_line_func blit_line;
		struct rtgui_graphic_driver *hw_driver;

		hw_driver = rtgui_graphic_driver_get_default();
        /* prepare pixel line */
		pixels = _dc_get_pixel(dc, dc_point.x, dc_point.y);

        if (hw_driver->bits_per_pixel == _dc_get_bits_per_pixel(dc))
        {
			if (dest->type == RTGUI_DC_HW && hw_driver->framebuffer != RT_NULL)
			{
				rt_uint8_t *hw_pixels;
				struct rtgui_dc_hw *hw;

				hw = (struct rtgui_dc_hw*)dest;

				/* NOTES: the rect of DC is the logic coordination.
				 * It should be converted to client
				 */
				if (dest_rect != &_rect)
				{
					/* use local rect */
					_rect = *dest_rect;
					dest_rect = &_rect;
				}
				rtgui_rect_moveto(dest_rect, hw->owner->extent.x1, hw->owner->extent.y1);

				pitch = rtgui_color_get_bpp(hw_driver->pixel_format) * rect_width;
				hw_pixels = (rt_uint8_t*)(hw_driver->framebuffer + dest_rect->y1 * hw_driver->pitch +
					dest_rect->x1 * rtgui_color_get_bpp(hw_driver->pixel_format));

				/* do the blit with memory copy */
				for (index = 0; index < rect_height; index ++)
				{
					rt_memcpy(hw_pixels, pixels, pitch);
					pixels += dc->pitch;
					hw_pixels += hw_driver->pitch;
				}
			}
			else
			{
	            /* it's the same bits per pixel, draw it directly */
	            for (index = dest_rect->y1; index < dest_rect->y1 + rect_height; index++)
	            {
	                dest->engine->blit_line(dest, dest_rect->x1, dest_rect->x1 + rect_width, index, pixels);
					pixels += dc->pitch;
	            }
			}
        }
        else
        {
			struct rtgui_graphic_driver *hw_driver;

			hw_driver = rtgui_graphic_driver_get_default();

			if ((dc->pixel_format == RTGRAPHIC_PIXEL_FORMAT_ARGB888) && (dest->type == RTGUI_DC_HW) &&
				(hw_driver->framebuffer != RT_NULL) &&
				(hw_driver->pixel_format == RTGRAPHIC_PIXEL_FORMAT_RGB565))
			{
				/* do the fast ARGB to RGB565 blit */
				struct rtgui_blit_info info;
				struct rtgui_widget *owner;

				/* blit source */
				info.src = _dc_get_pixel(dc, dc_point.x, dc_point.y);
				info.src_fmt = dc->pixel_format;
				info.src_h = rect_height;
				info.src_w = rect_width;
				info.src_pitch = dc->pitch;
				info.src_skip = info.src_pitch - info.src_w * rtgui_color_get_bpp(dc->pixel_format);

				owner = ((struct rtgui_dc_hw*)dest)->owner;

				/* blit destination */
				info.dst = (rt_uint8_t*)hw_driver->framebuffer;
				info.dst = info.dst + (owner->extent.y1 + dest_rect->y1) * hw_driver->pitch +
                    (owner->extent.x1 + dest_rect->x1) * rtgui_color_get_bpp(hw_driver->pixel_format);
				info.dst_fmt = hw_driver->pixel_format;
				info.dst_h = rect_height;
				info.dst_w = rect_width;
				info.dst_pitch = hw_driver->pitch;
				info.dst_skip = info.dst_pitch - info.dst_w * rtgui_color_get_bpp(hw_driver->pixel_format);

				rtgui_blit(&info);
			}
			else
			{
	            /* get blit line function */
	            blit_line = rtgui_blit_line_get(_UI_BITBYTES(hw_driver->bits_per_pixel), rtgui_color_get_bpp(dc->pixel_format));
	            /* calculate pitch */
	            pitch = rect_width * rtgui_color_get_bpp(dc->pixel_format);
	            /* create line buffer */
	            line_ptr = (rt_uint8_t *) rtgui_malloc(rect_width * _UI_BITBYTES(hw_driver->bits_per_pixel));

	            /* draw each line */
	            for (index = dest_rect->y1; index < dest_rect->y1 + rect_height; index ++)
	            {
	                /* blit on line buffer */
	                blit_line(line_ptr, (rt_uint8_t *)pixels, pitch);
	                pixels += dc->pitch;

	                /* draw on hardware dc */
	                dest->engine->blit_line(dest, dest_rect->x1, dest_rect->x1 + rect_width, index, line_ptr);
	            }

	            /* release line buffer */
	            rtgui_free(line_ptr);
			}
        }
    }
	else if (dest->type == RTGUI_DC_BUFFER)
	{
		struct rtgui_dc_buffer *dest_dc = (struct rtgui_dc_buffer*)dest;

		if (dest_dc->pixel_format == dc->pixel_format && dest_dc->pixel_format == RTGRAPHIC_PIXEL_FORMAT_RGB565)
		{
			int index;
			rt_uint8_t *pixels, *dest_pixels;

			/* get pitch */
			pitch = rect_width * rtgui_color_get_bpp(dc->pixel_format);

			pixels = _dc_get_pixel(dc, dc_point.x, dc_point.y);
			dest_pixels = _dc_get_pixel(dest_dc, dest_rect->x1, dest_rect->y1);

			for (index = 0; index < rect_height; index ++)
			{
				rt_memcpy(dest_pixels, pixels, pitch);
				pixels += dc->pitch;
				dest_pixels += dest_dc->pitch;
			}
		}
		else /* use rtgui_blit to handle buffer blit */
		{
			/* do the fast ARGB to RGB565 blit */
			struct rtgui_blit_info info;

			/* blit source */
			info.src = _dc_get_pixel(dc, dc_point.x, dc_point.y);
			info.src_fmt = dc->pixel_format;
			info.src_h = rect_height;
			info.src_w = rect_width;
			info.src_pitch = dc->pitch;
			info.src_skip = info.src_pitch - info.src_w * rtgui_color_get_bpp(dc->pixel_format);

			/* blit destination */
			info.dst = _dc_get_pixel(dest_dc, dest_rect->x1, dest_rect->y1);
			info.dst_fmt = dest_dc->pixel_format;
			info.dst_h = rect_height;
			info.dst_w = rect_width;
			info.dst_pitch = dest_dc->pitch;
			info.dst_skip = info.dst_pitch - info.dst_w * rtgui_color_get_bpp(dest_dc->pixel_format);

			rtgui_blit(&info);
		}
	}
}
Esempio n. 22
0
void rtgui_get_screen_rect(struct rtgui_rect *rect)
{
    rtgui_graphic_driver_get_rect(rtgui_graphic_driver_get_default(), rect);
}
struct rtgui_dc* rtgui_dc_hw_create(rtgui_widget_t* owner)
{
	struct rtgui_dc_hw* dc;
	rtgui_widget_t* widget;

	/* adjudge owner */
	if (owner == RT_NULL || owner->toplevel == RT_NULL) return RT_NULL;
	if (!RTGUI_IS_TOPLEVEL(owner->toplevel)) return RT_NULL;

	/* set init visible as true */
	RTGUI_WIDGET_DC_SET_VISIBLE(owner);

	/* check widget visible */
	widget = owner;
	while (widget != RT_NULL)
	{
		if (RTGUI_WIDGET_IS_HIDE(widget))
		{
			RTGUI_WIDGET_DC_SET_UNVISIBLE(owner);
			return RT_NULL;
		}

		widget = widget->parent;
	}

	if (!RTGUI_WIDGET_IS_DC_VISIBLE(owner)) return RT_NULL;

	/* create DC */
	dc = (struct rtgui_dc_hw*) rtgui_malloc(sizeof(struct rtgui_dc_hw));
	dc->parent.type = RTGUI_DC_HW;
	dc->parent.engine = &dc_hw_engine;
	dc->owner = owner;
	dc->hw_driver = rtgui_graphic_driver_get_default();

	if (RTGUI_IS_WINTITLE(owner->toplevel))
	{
		rtgui_toplevel_t* top = RTGUI_TOPLEVEL(owner->toplevel);
		top->drawing ++;

		if (top->drawing == 1)
		{
#ifdef RTGUI_USING_MOUSE_CURSOR
#ifdef _WIN32
			rt_mutex_take(&cursor_mutex, RT_WAITING_FOREVER);
			rt_kprintf("hide cursor\n");
			rtgui_mouse_hide_cursor();
#else
			/* hide cursor */
			rtgui_mouse_hide_cursor();
#endif
#endif
		}
	}
	else if (RTGUI_IS_APPLICATION(owner->toplevel) ||
		RTGUI_IS_WIN(owner->toplevel))
	{
		rtgui_toplevel_t* top = RTGUI_TOPLEVEL(owner->toplevel);
		top->drawing ++;

		if (top->drawing == 1)
		{
#ifdef _WIN32
#ifdef RTGUI_USING_MOUSE_CURSOR
			rt_mutex_take(&cursor_mutex, RT_WAITING_FOREVER);
			rt_kprintf("hide cursor\n");
			rtgui_mouse_hide_cursor();
#endif
#else
			/* send draw begin to server */
			struct rtgui_event_update_begin eupdate;
			RTGUI_EVENT_UPDATE_BEGIN_INIT(&(eupdate));
			eupdate.rect = RTGUI_WIDGET(top)->extent;

			rtgui_server_post_event((struct rtgui_event*)&eupdate, sizeof(eupdate));
#endif
		}
	}

	return &(dc->parent);
}
Esempio n. 24
0
/* blit a dc to a hardware dc */
static void rtgui_dc_buffer_blit(struct rtgui_dc *self, struct rtgui_point *dc_point, struct rtgui_dc *dest, rtgui_rect_t *rect)
{
	int pitch;
	rt_uint16_t rect_width, rect_height;
    struct rtgui_dc_buffer *dc = (struct rtgui_dc_buffer *)self;

    if (dc_point == RT_NULL) dc_point = &rtgui_empty_point;
    if (rtgui_dc_get_visible(dest) == RT_FALSE) return;

	/* get the minimal width and height */
	rect_width  = _UI_MIN(rtgui_rect_width(*rect), dc->width - dc_point->x);
	rect_height = _UI_MIN(rtgui_rect_height(*rect), dc->height - dc_point->y);

    if ((dest->type == RTGUI_DC_HW) || (dest->type == RTGUI_DC_CLIENT))
    {
		int index;
        rt_uint8_t *line_ptr, *pixels;
        rtgui_blit_line_func blit_line;
		struct rtgui_graphic_driver *hw_driver;

		hw_driver = rtgui_graphic_driver_get_default();
        /* prepare pixel line */
		pixels = _dc_get_pixel(dc, dc_point->x, dc_point->y);

        if (hw_driver->bits_per_pixel == _dc_get_bits_per_pixel(dc))
        {
			if (dest->type == RTGUI_DC_HW && hw_driver->framebuffer != RT_NULL)
			{
				rt_uint8_t *hw_pixels;

				pitch = rtgui_color_get_bpp(hw_driver->pixel_format) * rect_width;
				hw_pixels = (rt_uint8_t*)(hw_driver->framebuffer + rect->y1 * hw_driver->pitch + 
					rect->x1 * rtgui_color_get_bpp(hw_driver->pixel_format));
				for (index = 0; index < rect_height; index ++)
				{
					memcpy(hw_pixels, pixels, pitch);
					pixels += dc->pitch;
					hw_pixels += hw_driver->pitch;
				}
			}
			else
			{
	            /* it's the same bits per pixel, draw it directly */
	            for (index = rect->y1; index < rect->y1 + rect_height; index++)
	            {
	                dest->engine->blit_line(dest, rect->x1, rect->x1 + rect_width, index, pixels);
					pixels += dc->pitch;
	            }
			}
        }
        else
        {
            /* get blit line function */
            blit_line = rtgui_blit_line_get(_UI_BITBYTES(hw_driver->bits_per_pixel), rtgui_color_get_bpp(dc->pixel_format));
            /* calculate pitch */
            pitch = rect_width * rtgui_color_get_bpp(hw_driver->pixel_format);
            /* create line buffer */
            line_ptr = (rt_uint8_t *) rtgui_malloc(rect_width * _UI_BITBYTES(hw_driver->bits_per_pixel));

            /* draw each line */
            for (index = rect->y1; index < rect->y1 + rect_height; index ++)
            {
                /* blit on line buffer */
                blit_line(line_ptr, (rt_uint8_t *)pixels, pitch);
                pixels += dc->pitch;

                /* draw on hardware dc */
                dest->engine->blit_line(dest, rect->x1, rect->x1 + rect_width, index, line_ptr);
            }

            /* release line buffer */
            rtgui_free(line_ptr);
        }
    }
	else if (dest->type == RTGUI_DC_BUFFER)
	{
		struct rtgui_dc_buffer *dest_dc = (struct rtgui_dc_buffer*)dest;

		if (dest_dc->pixel_format == dc->pixel_format)
		{
			int index;
			rt_uint8_t *pixels, *dest_pixels;
			
			/* get pitch */
			pitch = rect_width * rtgui_color_get_bpp(dc->pixel_format);

			pixels = _dc_get_pixel(dc, dc_point->x, dc_point->y);
			dest_pixels = _dc_get_pixel(dest_dc, rect->x1, rect->y1);

			for (index = 0; index < rect_height; index ++)
			{
				memcpy(dest_pixels, pixels, pitch);
				pixels += dc->pitch;
				dest_pixels += dest_dc->pitch;
			}
		}
	}
}